From 1c44584db81b6bb1f2d9d335a48cf2ede945249c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kn=C3=BCttel?= Date: Fri, 12 Jul 2019 22:50:36 +0200 Subject: [PATCH] added a nice way to tweak the simulation --- coefficients.py | 23 +++++++++++++++++++++++ force.py | 11 +++++++++++ particles.py | 12 +++++++----- 3 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 coefficients.py create mode 100644 force.py diff --git a/coefficients.py b/coefficients.py new file mode 100644 index 0000000..c9d1bcd --- /dev/null +++ b/coefficients.py @@ -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) + diff --git a/force.py b/force.py new file mode 100644 index 0000000..97eedc4 --- /dev/null +++ b/force.py @@ -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() diff --git a/particles.py b/particles.py index 969bdc3..5d71a4a 100644 --- a/particles.py +++ b/particles.py @@ -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)