added a nice way to tweak the simulation

This commit is contained in:
Daniel Knüttel 2019-07-12 22:50:36 +02:00
parent 2475186d79
commit 1c44584db8
3 changed files with 41 additions and 5 deletions

23
coefficients.py Normal file
View File

@ -0,0 +1,23 @@
import numpy as np
c = np.array(
[ 15 # (x**0
, 1 # x**1
, -6 # x**2
, 0 # x**3
, 0 # x**4
, 0 # x**5
, 0 # x**6)
, 1 # *c*exp(
, -1 # c
, 0 # (r - c))
, -1 # + c*exp(
, -.1 # c
, 2 # (r - c))
, -4 # + c*exp(
, -0.05 # c
, 40 # (r - c)**2)
, 10 # + c*exp(
, -0.05 # c
, 20] # (r - c)**2)
, dtype=np.float16)

11
force.py Normal file
View File

@ -0,0 +1,11 @@
from brown.interaction import UFuncWrapper
import numpy as np
import matplotlib.pyplot as plt
from coefficients import c
force_function = UFuncWrapper(0, c)
r = np.arange(0, 100, 0.02, dtype=np.float16)
plt.plot(r, force_function(r))
plt.show()

View File

@ -6,17 +6,19 @@ from copy import copy
import matplotlib.pyplot as plt
import matplotlib.animation as ani
c = np.array([5, 10, 20, 30, 0, 0, 0, 1, -20, 0, -2, -0.1, 2, 0, 0, 0, 0, 0, 0], dtype=np.float16)
from coefficients import c
#force_function = UFuncWrapper(0, c)
#interaction2D = UFuncWrapper(1, c)
borders_x = [-100, 100]
borders_y = [-100, 100]
n_particles = 6
n_particles = 600
frames = 1000
spawn_restriction = 1.1
x_coords = np.random.uniform(borders_x[0] / 2, borders_x[1] / 2, n_particles).astype(np.float16)
y_coords = np.random.uniform(borders_y[0] / 2, borders_y[1] / 2, n_particles).astype(np.float16)
x_coords = np.random.uniform(borders_x[0] / spawn_restriction, borders_x[1] / spawn_restriction, n_particles).astype(np.float16)
y_coords = np.random.uniform(borders_y[0] / spawn_restriction, borders_y[1] / spawn_restriction, n_particles).astype(np.float16)
x_momenta = np.zeros(n_particles, dtype=np.float16)
@ -41,7 +43,7 @@ brown = BrownIterator(-1, c
, y_momenta, y_momenta
, borders_x, borders_y
, border_dampening=1
, dt=0.001)
, dt=0.0001)
u = iter(brown)