![]() |
Peano
|
Variables | |
parser = argparse.ArgumentParser(description="SPH benchmarking script") | |
Parse user input. | |
dest | |
type | |
int | |
default | |
help | |
action | |
choices | |
required | |
args = parser.parse_args() | |
dimensions = args.dimensions | |
Generate SWIFT project. | |
project | |
particle | |
particle_set = project.add_particle_species(particle) | |
energy_kin_attr = dastgen2.attributes.Double("energyKin") | |
energy_pot_attr = dastgen2.attributes.Double("energyPot") | |
energy_tot_attr = dastgen2.attributes.Double("energyTot") | |
build_mode = peano4.output.CompileMode.Asserts | |
list | offset = [0, 0, 0] |
list | domain_size = [1, 1, 1] |
list | periodic_boundary_conditions = [False, False, False] |
min_end_time | |
max_end_time | |
first_plot_time_stamp | |
time_in_between_plots | |
periodic_BC | |
plotter_precision | |
int | N_orbits = 8 |
float | G_NEWTON = 6.67384e-11 |
float | M_SUN = 1.9885e30 |
float | M_EARTH = 5.97219e24 |
float | R_MAX = 152097701000.0 |
float | R_MIN = 147098074000.0 |
float | V_MAX = 30287.0 |
float | LENGTH_UNIT = 4.0 * R_MAX |
SUN_X_COORD = str(0.5) | |
SUN_Y_COORD = str(0.5) | |
EARTH_X_INI = str(float(SUN_X_COORD) + R_MAX / LENGTH_UNIT) | |
EARTH_Y_INI = SUN_Y_COORD | |
tuple | e = (R_MAX - R_MIN) / (R_MAX + R_MIN) |
b = np.sqrt(R_MAX * R_MIN) | |
p = b * np.sqrt(1.0 - e * e) | |
a = p / (1.0 - e * e) | |
T = np.sqrt(4.0 * np.pi * np.pi * a * a * a / (G_NEWTON * (M_SUN + M_EARTH))) | |
int | dt = 1e-3 * T |
int | N = N_orbits / dt |
GLOBAL_TIME_STEP_SIZE = str(dt) | |
EARTH_V_INI_X = str(0.0) | |
EARTH_V_INI_Y = str(V_MAX / LENGTH_UNIT * T) | |
str | particle_force |
Declare the force acting on the particle. | |
cell_kernel | |
float | search_radius = args.cell_size / 100.0 |
Initialisation snippet for the particle. | |
tuple | initialisation_snippet |
particle_plotter | |
Set up the plotter. | |
peano4_project = project.generate_Peano4_project(verbose=args.verbose) | |
Generate plain Peano 4 project. | |
list | dirs = ["vertexdata/", "repositories/", "globaldata/", "observers/"] |
overwrite | |
Always | |
throw_away_data_after_generation | |
make_clean_first | |
True | |
number_of_parallel_builds | |
list | output_files |
Definition at line 230 of file planet-orbit.py.
planet-orbit.action |
Definition at line 23 of file planet-orbit.py.
planet-orbit.Always |
Definition at line 523 of file planet-orbit.py.
planet-orbit.args = parser.parse_args() |
Definition at line 93 of file planet-orbit.py.
Definition at line 226 of file planet-orbit.py.
planet-orbit.build_mode = peano4.output.CompileMode.Asserts |
Definition at line 170 of file planet-orbit.py.
planet-orbit.cell_kernel |
Definition at line 337 of file planet-orbit.py.
planet-orbit.choices |
Definition at line 89 of file planet-orbit.py.
planet-orbit.default |
Definition at line 17 of file planet-orbit.py.
planet-orbit.dest |
Definition at line 17 of file planet-orbit.py.
planet-orbit.dimensions = args.dimensions |
Generate SWIFT project.
Definition at line 100 of file planet-orbit.py.
list planet-orbit.dirs = ["vertexdata/", "repositories/", "globaldata/", "observers/"] |
Definition at line 518 of file planet-orbit.py.
planet-orbit.domain_size = [1, 1, 1] |
Definition at line 175 of file planet-orbit.py.
Definition at line 236 of file planet-orbit.py.
Definition at line 224 of file planet-orbit.py.
planet-orbit.EARTH_V_INI_X = str(0.0) |
Definition at line 243 of file planet-orbit.py.
planet-orbit.EARTH_V_INI_Y = str(V_MAX / LENGTH_UNIT * T) |
Definition at line 244 of file planet-orbit.py.
planet-orbit.EARTH_X_INI = str(float(SUN_X_COORD) + R_MAX / LENGTH_UNIT) |
Definition at line 220 of file planet-orbit.py.
planet-orbit.EARTH_Y_INI = SUN_Y_COORD |
Definition at line 221 of file planet-orbit.py.
planet-orbit.energy_kin_attr = dastgen2.attributes.Double("energyKin") |
Definition at line 159 of file planet-orbit.py.
planet-orbit.energy_pot_attr = dastgen2.attributes.Double("energyPot") |
Definition at line 160 of file planet-orbit.py.
planet-orbit.energy_tot_attr = dastgen2.attributes.Double("energyTot") |
Definition at line 161 of file planet-orbit.py.
planet-orbit.first_plot_time_stamp |
Definition at line 184 of file planet-orbit.py.
float planet-orbit.G_NEWTON = 6.67384e-11 |
Definition at line 203 of file planet-orbit.py.
planet-orbit.GLOBAL_TIME_STEP_SIZE = str(dt) |
Definition at line 240 of file planet-orbit.py.
planet-orbit.help |
Definition at line 17 of file planet-orbit.py.
tuple planet-orbit.initialisation_snippet |
Definition at line 353 of file planet-orbit.py.
planet-orbit.int |
Definition at line 17 of file planet-orbit.py.
float planet-orbit.LENGTH_UNIT = 4.0 * R_MAX |
Definition at line 217 of file planet-orbit.py.
float planet-orbit.M_EARTH = 5.97219e24 |
Definition at line 207 of file planet-orbit.py.
float planet-orbit.M_SUN = 1.9885e30 |
Definition at line 205 of file planet-orbit.py.
planet-orbit.make_clean_first |
Definition at line 525 of file planet-orbit.py.
planet-orbit.max_end_time |
Definition at line 183 of file planet-orbit.py.
planet-orbit.min_end_time |
Definition at line 182 of file planet-orbit.py.
Definition at line 239 of file planet-orbit.py.
int planet-orbit.N_orbits = 8 |
Definition at line 201 of file planet-orbit.py.
planet-orbit.number_of_parallel_builds |
Definition at line 525 of file planet-orbit.py.
planet-orbit.offset = [0, 0, 0] |
Definition at line 174 of file planet-orbit.py.
list planet-orbit.output_files |
Definition at line 528 of file planet-orbit.py.
planet-orbit.overwrite |
Definition at line 523 of file planet-orbit.py.
Definition at line 228 of file planet-orbit.py.
planet-orbit.parser = argparse.ArgumentParser(description="SPH benchmarking script") |
Parse user input.
Definition at line 15 of file planet-orbit.py.
planet-orbit.particle |
Definition at line 124 of file planet-orbit.py.
str planet-orbit.particle_force |
Declare the force acting on the particle.
We effectively solve a 2d setup even in 3d. Peano's vector classes can be used over the compiler symbol Dimensions, but then we have to use different initialisation lists - one with two entries and one if three - and distinguish them via an ifdef. If we compile without assertions, an additional entry in the initialisation list will simply be ignored. If we compile with assertions however the code will complain, as initialisation lists with "too many" entries are a hint that something in the code is wrong.
We have two variants covered by this script: Either we work with only one particle or we resolve the sun explicitly. If we model the sun as explicit particle, then we have to be careful not to update it.
The code snippets here rely on some global constants that we compute here in the Python code base. We have various ways how to deal with such constants:
peano4_project.constants.export_const_with_typebelow make the constants known to the build environment. Consequently, we can use them within our C code snippets, as they will be well-defined by the time we compile.
Definition at line 286 of file planet-orbit.py.
planet-orbit.particle_plotter |
Set up the plotter.
A plotter has to be told explicitly which data to visualisation. We visualise the velocity here as scalar attribute. To some degree, this is redundant info as we implicitly have the position of the particle and can "see" its velocity when we play through a movie. But the explicit visualisation shows how to handle attributes per particle.
When we create the plotter, we have to inform it how to enumerate the individual snapshots. Obviously, we can just count through the snapshots. In this case, you have to pass the constant peano4.toolbox.particles.PlotParticlesInVTKFormat.CountTimeSteps into the field time_stamp_evaluation. You can also define your own time stamp. For this, it is useful to know that each particle definition in the Python script will yield a particle class with the same name in the subnamespace globaldata. Every particle class in return has a class attribute
getSpecies()
which returns an object that holds global information about this particle type.
Definition at line 449 of file planet-orbit.py.
planet-orbit.particle_set = project.add_particle_species(particle) |
Definition at line 132 of file planet-orbit.py.
planet-orbit.peano4_project = project.generate_Peano4_project(verbose=args.verbose) |
Generate plain Peano 4 project.
See commments above (for the force interaction kernel) why we might want to have some of the constants from the Python script within the C++ code base that's generated.
! [tutorials swift2 planet-orbit Create Peano project]
Definition at line 481 of file planet-orbit.py.
planet-orbit.periodic_BC |
Definition at line 186 of file planet-orbit.py.
list planet-orbit.periodic_boundary_conditions = [False, False, False] |
Definition at line 176 of file planet-orbit.py.
planet-orbit.plotter_precision |
Definition at line 187 of file planet-orbit.py.
planet-orbit.project |
Definition at line 104 of file planet-orbit.py.
float planet-orbit.R_MAX = 152097701000.0 |
Definition at line 209 of file planet-orbit.py.
float planet-orbit.R_MIN = 147098074000.0 |
Definition at line 211 of file planet-orbit.py.
planet-orbit.required |
Definition at line 90 of file planet-orbit.py.
float planet-orbit.search_radius = args.cell_size / 100.0 |
Initialisation snippet for the particle.
If we work with only one particle, then we can simply set its velocity. However, our script works both if we only module the earth but also when we model earth and sun explicitly. In the latter case, we have to ensure that only the earth is given an initial velocity.
Definition at line 352 of file planet-orbit.py.
planet-orbit.SUN_X_COORD = str(0.5) |
Definition at line 218 of file planet-orbit.py.
planet-orbit.SUN_Y_COORD = str(0.5) |
Definition at line 219 of file planet-orbit.py.
Definition at line 232 of file planet-orbit.py.
planet-orbit.throw_away_data_after_generation |
Definition at line 523 of file planet-orbit.py.
planet-orbit.time_in_between_plots |
Definition at line 185 of file planet-orbit.py.
planet-orbit.True |
Definition at line 525 of file planet-orbit.py.
planet-orbit.type |
Definition at line 17 of file planet-orbit.py.
float planet-orbit.V_MAX = 30287.0 |
Definition at line 213 of file planet-orbit.py.