Peano 4
Loading...
Searching...
No Matches
planet-orbit Namespace Reference

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
 

Variable Documentation

◆ a

planet-orbit.a = p / (1.0 - e * e)

Definition at line 231 of file planet-orbit.py.

◆ action

planet-orbit.action

Definition at line 23 of file planet-orbit.py.

◆ Always

planet-orbit.Always

Definition at line 521 of file planet-orbit.py.

◆ args

planet-orbit.args = parser.parse_args()

Definition at line 93 of file planet-orbit.py.

◆ b

planet-orbit.b = np.sqrt(R_MAX * R_MIN)

Definition at line 227 of file planet-orbit.py.

◆ build_mode

planet-orbit.build_mode = peano4.output.CompileMode.Asserts

Definition at line 170 of file planet-orbit.py.

◆ cell_kernel

planet-orbit.cell_kernel

Definition at line 334 of file planet-orbit.py.

◆ choices

planet-orbit.choices

Definition at line 89 of file planet-orbit.py.

◆ default

planet-orbit.default

Definition at line 17 of file planet-orbit.py.

◆ dest

planet-orbit.dest

Definition at line 17 of file planet-orbit.py.

◆ dimensions

planet-orbit.dimensions = args.dimensions

Generate SWIFT project.

Definition at line 100 of file planet-orbit.py.

◆ dirs

list planet-orbit.dirs = ["vertexdata/", "repositories/", "globaldata/", "observers/"]

Definition at line 516 of file planet-orbit.py.

◆ domain_size

planet-orbit.domain_size = [1, 1, 1]

Definition at line 175 of file planet-orbit.py.

◆ dt

int planet-orbit.dt = 1e-3 * T

Definition at line 237 of file planet-orbit.py.

◆ e

tuple planet-orbit.e = (R_MAX - R_MIN) / (R_MAX + R_MIN)

Definition at line 225 of file planet-orbit.py.

◆ EARTH_V_INI_X

planet-orbit.EARTH_V_INI_X = str(0.0)

Definition at line 244 of file planet-orbit.py.

◆ EARTH_V_INI_Y

planet-orbit.EARTH_V_INI_Y = str(V_MAX / LENGTH_UNIT * T)

Definition at line 245 of file planet-orbit.py.

◆ EARTH_X_INI

planet-orbit.EARTH_X_INI = str(float(SUN_X_COORD) + R_MAX / LENGTH_UNIT)

Definition at line 221 of file planet-orbit.py.

◆ EARTH_Y_INI

planet-orbit.EARTH_Y_INI = SUN_Y_COORD

Definition at line 222 of file planet-orbit.py.

◆ energy_kin_attr

planet-orbit.energy_kin_attr = dastgen2.attributes.Double("energyKin")

Definition at line 159 of file planet-orbit.py.

◆ energy_pot_attr

planet-orbit.energy_pot_attr = dastgen2.attributes.Double("energyPot")

Definition at line 160 of file planet-orbit.py.

◆ energy_tot_attr

planet-orbit.energy_tot_attr = dastgen2.attributes.Double("energyTot")

Definition at line 161 of file planet-orbit.py.

◆ first_plot_time_stamp

planet-orbit.first_plot_time_stamp

Definition at line 184 of file planet-orbit.py.

◆ G_NEWTON

float planet-orbit.G_NEWTON = 6.67384e-11

Definition at line 204 of file planet-orbit.py.

◆ GLOBAL_TIME_STEP_SIZE

planet-orbit.GLOBAL_TIME_STEP_SIZE = str(dt)

Definition at line 241 of file planet-orbit.py.

◆ help

planet-orbit.help

Definition at line 17 of file planet-orbit.py.

◆ initialisation_snippet

tuple planet-orbit.initialisation_snippet
Initial value:
1= (
2
3 + str(search_radius)
4 +
5)

Definition at line 350 of file planet-orbit.py.

◆ int

planet-orbit.int

Definition at line 17 of file planet-orbit.py.

◆ LENGTH_UNIT

float planet-orbit.LENGTH_UNIT = 4.0 * R_MAX

Definition at line 218 of file planet-orbit.py.

◆ M_EARTH

float planet-orbit.M_EARTH = 5.97219e24

Definition at line 208 of file planet-orbit.py.

◆ M_SUN

float planet-orbit.M_SUN = 1.9885e30

Definition at line 206 of file planet-orbit.py.

◆ make_clean_first

planet-orbit.make_clean_first

Definition at line 523 of file planet-orbit.py.

◆ max_end_time

planet-orbit.max_end_time

Definition at line 183 of file planet-orbit.py.

◆ min_end_time

planet-orbit.min_end_time

Definition at line 182 of file planet-orbit.py.

◆ N

int planet-orbit.N = N_orbits / dt

Definition at line 240 of file planet-orbit.py.

◆ N_orbits

int planet-orbit.N_orbits = 8

Definition at line 202 of file planet-orbit.py.

◆ number_of_parallel_builds

planet-orbit.number_of_parallel_builds

Definition at line 523 of file planet-orbit.py.

◆ offset

planet-orbit.offset = [0, 0, 0]

Definition at line 174 of file planet-orbit.py.

◆ output_files

list planet-orbit.output_files
Initial value:
1= [
2 f
3 for f in os.listdir(".")
4 if f.endswith(".peano-patch-file") or f.endswith(".vtu") or f.endswith(".pvd")
5]

Definition at line 526 of file planet-orbit.py.

◆ overwrite

planet-orbit.overwrite

Definition at line 521 of file planet-orbit.py.

◆ p

planet-orbit.p = b * np.sqrt(1.0 - e * e)

Definition at line 229 of file planet-orbit.py.

◆ parser

planet-orbit.parser = argparse.ArgumentParser(description="SPH benchmarking script")

Parse user input.

Definition at line 15 of file planet-orbit.py.

◆ particle

planet-orbit.particle
Initial value:
2 name="Planet",
3 cfl_factor=0.2,
4 initial_time_step_size=args.timestep_size,
5 particles_per_cell=0,
6 min_h=args.cell_size,
7 max_h=0.3,
8 )

Definition at line 124 of file planet-orbit.py.

◆ particle_force

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:

  • We can calculate them within Python and then export them into the Peano project. This is the strategy implemented here: The statements
         peano4_project.constants.export_const_with_type
    
    below 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.
  • We can construct the string in Python and replace the constants straightaway. In this case, we don't have to add the constants to the makefile, as they are not required throughout the compile. In return, we have to ensure that the constants within the code snippet here are replaced with their actual value before we hand the kernel particle_force over.

Definition at line 289 of file planet-orbit.py.

◆ particle_plotter

planet-orbit.particle_plotter
Initial value:
2 "particles",
3 particle_set,
4 "globaldata::{}::getSpecies().getMinTimeStamp()".format(particle.name),
5)

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 446 of file planet-orbit.py.

◆ particle_set

planet-orbit.particle_set = project.add_particle_species(particle)

Definition at line 132 of file planet-orbit.py.

◆ peano4_project

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 479 of file planet-orbit.py.

◆ periodic_BC

planet-orbit.periodic_BC

Definition at line 186 of file planet-orbit.py.

◆ periodic_boundary_conditions

list planet-orbit.periodic_boundary_conditions = [False, False, False]

Definition at line 176 of file planet-orbit.py.

◆ plotter_precision

planet-orbit.plotter_precision

Definition at line 187 of file planet-orbit.py.

◆ project

planet-orbit.project
Initial value:
2 namespace=["tests", "swift2", "planetorbit"],
3 project_name="planetorbit",
4 executable="orbit-" + str(args.cell_size),
5)
Swift2 project.
Definition Project.py:23

Definition at line 104 of file planet-orbit.py.

◆ R_MAX

float planet-orbit.R_MAX = 152097701000.0

Definition at line 210 of file planet-orbit.py.

◆ R_MIN

float planet-orbit.R_MIN = 147098074000.0

Definition at line 212 of file planet-orbit.py.

◆ required

planet-orbit.required

Definition at line 90 of file planet-orbit.py.

◆ search_radius

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 349 of file planet-orbit.py.

◆ SUN_X_COORD

planet-orbit.SUN_X_COORD = str(0.5)

Definition at line 219 of file planet-orbit.py.

◆ SUN_Y_COORD

planet-orbit.SUN_Y_COORD = str(0.5)

Definition at line 220 of file planet-orbit.py.

◆ T

planet-orbit.T = np.sqrt(4.0 * np.pi * np.pi * a * a * a / (G_NEWTON * (M_SUN + M_EARTH)))

Definition at line 233 of file planet-orbit.py.

◆ throw_away_data_after_generation

planet-orbit.throw_away_data_after_generation

Definition at line 521 of file planet-orbit.py.

◆ time_in_between_plots

planet-orbit.time_in_between_plots

Definition at line 185 of file planet-orbit.py.

◆ True

planet-orbit.True

Definition at line 523 of file planet-orbit.py.

◆ type

planet-orbit.type

Definition at line 17 of file planet-orbit.py.

◆ V_MAX

float planet-orbit.V_MAX = 30287.0

Definition at line 214 of file planet-orbit.py.