technically everything works, but CoM is not preserved

This commit is contained in:
Daniel Knüttel 2019-07-12 21:51:24 +02:00
parent c52fbe796d
commit dba5664cf3
3 changed files with 38 additions and 34 deletions

View File

@ -115,10 +115,11 @@ interaction_ufunc_float2D
// Update the momenta. // Update the momenta.
delta_p_x = delta_x_e * interaction_force_function(r, coefficients); delta_p_x = delta_x_e * interaction_force_function(r, coefficients);
delta_p_y = delty_y_e * interaction_force_function(r, coefficients); delta_p_y = delty_y_e * interaction_force_function(r, coefficients);
*(float *)(p_x_new + i*p_x_new_steps) -= delta_p_x; //printf("%d, %d: %f, %f\n", i, j, delta_p_x, delta_p_y);
*(float *)(p_y_new + i*p_y_new_steps) -= delta_p_y; *(float *)(p_x_new + i*p_x_new_steps) += delta_p_x;
*(float *)(p_x_new + j*p_x_new_steps) += delta_p_x; *(float *)(p_y_new + i*p_y_new_steps) += delta_p_y;
*(float *)(p_y_new + j*p_y_new_steps) += delta_p_y; *(float *)(p_x_new + j*p_x_new_steps) -= delta_p_x;
*(float *)(p_y_new + j*p_y_new_steps) -= delta_p_y;
} }
} }
} }

View File

@ -1,30 +1,31 @@
#from distutils.core import setup, Extension from distutils.core import setup, Extension
#
#
#interaction = Extension("brown.interaction",
# sources = ["c/interaction/interaction.c"])
#
#setup(name = "brown",
# version = "0.0.1",
# description = "Me playing around with single-atom classical gases",
# ext_modules = [interaction],
# packages = [
# "brown"
# ],
# package_dir = {"brown": "py/brown"},
# #url="https://github.com/daknuett/python3-nf",
# author = "Daniel Knüttel",
# author_email = "daniel.knuettel@daknuett.eu")
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('brown' interaction = Extension("brown.interaction",
, parent_package sources = ["c/interaction/interaction.c"])
, top_path)
config.add_extension('interaction', ['c/interaction/interaction.c'], extra_compile_args=["-g"])
return config
if __name__ == "__main__": setup(name = "brown",
from numpy.distutils.core import setup version = "0.0.1",
setup(configuration=configuration) description = "Me playing around with single-atom classical gases",
ext_modules = [interaction],
packages = [
"brown"
],
package_dir = {"brown": "py/brown"},
#url="https://github.com/daknuett/python3-nf",
author = "Daniel Knüttel",
author_email = "daniel.knuettel@daknuett.eu")
#def configuration(parent_package='', top_path=None):
# from numpy.distutils.misc_util import Configuration
#
# config = Configuration('brown'
# , parent_package
# , top_path="py/")
# config.add_extension('interaction', ['c/interaction/interaction.c'], extra_compile_args=["-g"])
# #config.add_subpackage("brown.brown", "py/brown")
# return config
#
#if __name__ == "__main__":
# from numpy.distutils.core import setup
# setup(configuration=configuration)

View File

@ -14,14 +14,16 @@ y_coords = np.array([0, 0], dtype=np.float16)
x_momenta = np.array([0, 0], dtype=np.float16) x_momenta = np.array([0, 0], dtype=np.float16)
y_momenta = np.array([0, 0], dtype=np.float16) y_momenta = np.array([0, 0], dtype=np.float16)
time = np.arange(0, 5, 1, dtype=np.float16) time = np.arange(0, 50, 1, dtype=np.float16)
time_evolution = deque() time_evolution = deque()
dt = 0.1
for t in time: for t in time:
x_momenta, y_momenta = interaction2D(x_coords, y_coords, x_momenta, y_momenta) x_momenta, y_momenta = interaction2D(x_coords, y_coords, x_momenta, y_momenta)
x_coords += x_momenta x_coords += dt * x_momenta
y_coords += y_momenta y_coords += dt * y_momenta
time_evolution.append(copy(x_coords)) time_evolution.append(copy(x_coords))