From 2af16451f5119398c34ef9bd8626791e0498b9ab Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Wed, 25 Mar 2020 22:05:08 +0100 Subject: Add example for random initial velocities --- gas.py | 25 ------------------------- random_velocities.py | 23 +++++++++++++++++++++++ zero_velocities.py | 25 +++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 25 deletions(-) delete mode 100644 gas.py create mode 100644 random_velocities.py create mode 100644 zero_velocities.py diff --git a/gas.py b/gas.py deleted file mode 100644 index 135796a..0000000 --- a/gas.py +++ /dev/null @@ -1,25 +0,0 @@ -import boltzgas.visualizer - -from boltzgas import HardSphereSetup, HardSphereSimulation -from boltzgas.initial_condition import grid_of_random_velocity_particles -from boltzgas.visual import VelocityHistogram, ColoredBox - -grid_width = 40 -radius = 0.002 -char_u = 1120 - -position, velocity = grid_of_random_velocity_particles(grid_width, radius, char_u) -velocity[:,:] = 0 -velocity[0,0] = 10*char_u -velocity[0,1] = 4*char_u - -config = HardSphereSetup(radius, char_u, position, velocity) -gas = HardSphereSimulation(config, opengl = True, t_scale = 0.5) - -histogram = VelocityHistogram(gas, [1.1,0], [1,1]) - -decorations = [ ColoredBox([0,0], [1,1], (0.2,0.2,0.2)) ] -instruments = [ histogram ] -windows = [ histogram ] - -boltzgas.visualizer.simulate(config, gas, instruments, decorations, windows) diff --git a/random_velocities.py b/random_velocities.py new file mode 100644 index 0000000..cf7a503 --- /dev/null +++ b/random_velocities.py @@ -0,0 +1,23 @@ +import boltzgas.visualizer + +from boltzgas import HardSphereSetup, HardSphereSimulation +from boltzgas.initial_condition import grid_of_random_velocity_particles +from boltzgas.visual import VelocityHistogram, ColoredBox, Tracer + +grid_width = 50 +radius = 0.002 +char_u = 1120 + +position, velocity = grid_of_random_velocity_particles(grid_width, radius, char_u) + +config = HardSphereSetup(radius, char_u, position, velocity) +gas = HardSphereSimulation(config, opengl = True) + +tracer = Tracer(gas, int((grid_width**2)/2+grid_width/2)) +histogram = VelocityHistogram(gas, [1.1,0], [1,1]) + +decorations = [ ColoredBox([0,0], [1,1], (0.2,0.2,0.2)), tracer ] +instruments = [ histogram, tracer ] +windows = [ histogram ] + +boltzgas.visualizer.simulate(config, gas, instruments, decorations, windows) diff --git a/zero_velocities.py b/zero_velocities.py new file mode 100644 index 0000000..135796a --- /dev/null +++ b/zero_velocities.py @@ -0,0 +1,25 @@ +import boltzgas.visualizer + +from boltzgas import HardSphereSetup, HardSphereSimulation +from boltzgas.initial_condition import grid_of_random_velocity_particles +from boltzgas.visual import VelocityHistogram, ColoredBox + +grid_width = 40 +radius = 0.002 +char_u = 1120 + +position, velocity = grid_of_random_velocity_particles(grid_width, radius, char_u) +velocity[:,:] = 0 +velocity[0,0] = 10*char_u +velocity[0,1] = 4*char_u + +config = HardSphereSetup(radius, char_u, position, velocity) +gas = HardSphereSimulation(config, opengl = True, t_scale = 0.5) + +histogram = VelocityHistogram(gas, [1.1,0], [1,1]) + +decorations = [ ColoredBox([0,0], [1,1], (0.2,0.2,0.2)) ] +instruments = [ histogram ] +windows = [ histogram ] + +boltzgas.visualizer.simulate(config, gas, instruments, decorations, windows) -- cgit v1.2.3