Loading [MathJax]/jax/output/HTML-CSS/config.js
Peano
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
test-density-calculation Namespace Reference

Variables

 parser = argparse.ArgumentParser(description="SPH benchmarking script")
 Parse user input.
 
 dest
 
 type
 
 int
 
 default
 
 help
 
 action
 
 required
 
 choices
 
 args = parser.parse_args()
 
list project_namespace = ["benchmarks", "swift2", "densityTest"]
 Generate SWIFT project.
 
 dimensions = args.dimensions
 
 project
 
int HYDRO_DIMENSIONS = 1
 
 HYDRO_PART_NUMBER = str(args.particle_number)
 Set parameters for the SPH simulation If no parameters are passed to the swift2 project, it initializes with default values.
 
 particle
 
 GLOBAL_TIME_STEP_SIZE = args.timestep_size
 
 CFL_CONSTANT = particle._cfl_factor
 
list gamma_hydro_list = [str(5 / 3), str(7 / 5), str(4 / 3), str(2 / 1)]
 
list gamma_hydro_list_symbols
 
list GAMMA = gamma_hydro_list[0]
 
list GAMMA_HYDRO_SYMBOL = gamma_hydro_list_symbols[0]
 
 kernel = args.kernel
 
 KERNEL_SYMBOL = sphtools.sph_kernel_macro_name[kernel]
 
 KERNEL_SUPPORT_RAD = sphtools.sph_kernel_H_over_h[HYDRO_DIMENSIONS - 1][kernel]
 
int hydro_h_max = args.cell_size / 2
 
 h_hydro_max
 
 particle_set = project.add_particle_species(particle)
 
 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
 
 ICs = swift2.scenario.TestDensityCalculation()
 Initialisation snippet for the particle.
 
 initialisation_snippet = ICs.initialisation_snippet
 
 Npart = args.particle_number
 
 coords = np.zeros((Npart**HYDRO_DIMENSIONS, 3))
 
 endpoint
 
 x = np.linspace(offset, 1, Npart, endpoint=False)
 
 y = np.linspace(offset, 1, Npart, endpoint=False)
 
 xp = xp.reshape((np.prod(xp.shape),))
 
 yp = yp.reshape((np.prod(yp.shape),))
 
 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/"]
 Cleanup and compilation.
 
 overwrite
 
 Always
 
 throw_away_data_after_generation
 
 make_clean_first
 
 True
 
 number_of_parallel_builds
 
list output_files
 

Variable Documentation

◆ action

test-density-calculation.action

Definition at line 26 of file test-density-calculation.py.

◆ Always

test-density-calculation.Always

Definition at line 379 of file test-density-calculation.py.

◆ args

test-density-calculation.args = parser.parse_args()

Definition at line 101 of file test-density-calculation.py.

◆ build_mode

test-density-calculation.build_mode = peano4.output.CompileMode.Asserts

Definition at line 193 of file test-density-calculation.py.

◆ CFL_CONSTANT

test-density-calculation.CFL_CONSTANT = particle._cfl_factor

Definition at line 148 of file test-density-calculation.py.

◆ choices

test-density-calculation.choices

Definition at line 98 of file test-density-calculation.py.

◆ coords

test-density-calculation.coords = np.zeros((Npart**HYDRO_DIMENSIONS, 3))

Definition at line 241 of file test-density-calculation.py.

◆ default

test-density-calculation.default

Definition at line 20 of file test-density-calculation.py.

◆ dest

test-density-calculation.dest

Definition at line 20 of file test-density-calculation.py.

◆ dimensions

test-density-calculation.dimensions = args.dimensions

Definition at line 110 of file test-density-calculation.py.

◆ dirs

list test-density-calculation.dirs = ["vertexdata/", "repositories/", "globaldata/", "observers/"]

Cleanup and compilation.

Definition at line 372 of file test-density-calculation.py.

◆ domain_size

test-density-calculation.domain_size = [1, 1, 1]

Definition at line 198 of file test-density-calculation.py.

◆ endpoint

test-density-calculation.endpoint

Definition at line 245 of file test-density-calculation.py.

◆ first_plot_time_stamp

test-density-calculation.first_plot_time_stamp

Definition at line 207 of file test-density-calculation.py.

◆ GAMMA

list test-density-calculation.GAMMA = gamma_hydro_list[0]

Definition at line 158 of file test-density-calculation.py.

◆ gamma_hydro_list

list test-density-calculation.gamma_hydro_list = [str(5 / 3), str(7 / 5), str(4 / 3), str(2 / 1)]

Definition at line 151 of file test-density-calculation.py.

◆ gamma_hydro_list_symbols

list test-density-calculation.gamma_hydro_list_symbols
Initial value:
1= [
2 "HYDRO_GAMMA_5_3",
3 "HYDRO_GAMMA_7_5",
4 "HYDRO_GAMMA_4_3",
5 "HYDRO_GAMMA_2_1",
6]

Definition at line 152 of file test-density-calculation.py.

◆ GAMMA_HYDRO_SYMBOL

list test-density-calculation.GAMMA_HYDRO_SYMBOL = gamma_hydro_list_symbols[0]

Definition at line 159 of file test-density-calculation.py.

◆ GLOBAL_TIME_STEP_SIZE

test-density-calculation.GLOBAL_TIME_STEP_SIZE = args.timestep_size

Definition at line 147 of file test-density-calculation.py.

◆ h_hydro_max

test-density-calculation.h_hydro_max

Definition at line 170 of file test-density-calculation.py.

◆ help

test-density-calculation.help

Definition at line 20 of file test-density-calculation.py.

◆ HYDRO_DIMENSIONS

int test-density-calculation.HYDRO_DIMENSIONS = 1

Definition at line 117 of file test-density-calculation.py.

◆ hydro_h_max

int test-density-calculation.hydro_h_max = args.cell_size / 2

Definition at line 169 of file test-density-calculation.py.

◆ HYDRO_PART_NUMBER

test-density-calculation.HYDRO_PART_NUMBER = str(args.particle_number)

Set parameters for the SPH simulation If no parameters are passed to the swift2 project, it initializes with default values.

The values of the parameters can be modified or retrieved using the set/get methods.

Definition at line 120 of file test-density-calculation.py.

◆ ICs

test-density-calculation.ICs = swift2.scenario.TestDensityCalculation()

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 233 of file test-density-calculation.py.

◆ initialisation_snippet

test-density-calculation.initialisation_snippet = ICs.initialisation_snippet

Definition at line 234 of file test-density-calculation.py.

◆ int

test-density-calculation.int

Definition at line 20 of file test-density-calculation.py.

◆ kernel

test-density-calculation.kernel = args.kernel

Definition at line 163 of file test-density-calculation.py.

◆ KERNEL_SUPPORT_RAD

test-density-calculation.KERNEL_SUPPORT_RAD = sphtools.sph_kernel_H_over_h[HYDRO_DIMENSIONS - 1][kernel]

Definition at line 165 of file test-density-calculation.py.

◆ KERNEL_SYMBOL

test-density-calculation.KERNEL_SYMBOL = sphtools.sph_kernel_macro_name[kernel]

Definition at line 164 of file test-density-calculation.py.

◆ make_clean_first

test-density-calculation.make_clean_first

Definition at line 381 of file test-density-calculation.py.

◆ max_end_time

test-density-calculation.max_end_time

Definition at line 206 of file test-density-calculation.py.

◆ min_end_time

test-density-calculation.min_end_time

Definition at line 205 of file test-density-calculation.py.

◆ Npart

test-density-calculation.Npart = args.particle_number

Definition at line 240 of file test-density-calculation.py.

◆ number_of_parallel_builds

test-density-calculation.number_of_parallel_builds

Definition at line 381 of file test-density-calculation.py.

◆ offset

test-density-calculation.offset = [0, 0, 0]

Definition at line 197 of file test-density-calculation.py.

◆ output_files

list test-density-calculation.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 384 of file test-density-calculation.py.

◆ overwrite

test-density-calculation.overwrite

Definition at line 379 of file test-density-calculation.py.

◆ parser

test-density-calculation.parser = argparse.ArgumentParser(description="SPH benchmarking script")

Parse user input.

Definition at line 18 of file test-density-calculation.py.

◆ particle

test-density-calculation.particle
Initial value:
2 name="testDensityCalculation",
3 dimensions_hydro=HYDRO_DIMENSIONS,
4 cfl_factor=0.1,
5 initial_time_step_size=1e-4,
6 particles_per_cell=5,
7 min_h=args.cell_size,
8 max_h=args.cell_size,
9)

Definition at line 123 of file test-density-calculation.py.

◆ particle_plotter

test-density-calculation.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.

particle_plotter = peano4.toolbox.particles.PlotParticlesInVTKFormat( "particles", particle_set, time_stamp_evaluation=peano4.toolbox.particles.PlotParticlesInVTKFormat.CountTimeSteps )

Definition at line 304 of file test-density-calculation.py.

◆ particle_set

test-density-calculation.particle_set = project.add_particle_species(particle)

Definition at line 190 of file test-density-calculation.py.

◆ peano4_project

test-density-calculation.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.

Definition at line 330 of file test-density-calculation.py.

◆ periodic_BC

test-density-calculation.periodic_BC

Definition at line 209 of file test-density-calculation.py.

◆ periodic_boundary_conditions

list test-density-calculation.periodic_boundary_conditions = [False, False, False]

Definition at line 199 of file test-density-calculation.py.

◆ plotter_precision

test-density-calculation.plotter_precision

Definition at line 210 of file test-density-calculation.py.

◆ project

test-density-calculation.project
Initial value:
2 namespace=project_namespace, project_name="test_density", executable="test_density"
3)
Swift2 project.
Definition Project.py:24

Definition at line 112 of file test-density-calculation.py.

◆ project_namespace

list test-density-calculation.project_namespace = ["benchmarks", "swift2", "densityTest"]

Generate SWIFT project.

Definition at line 108 of file test-density-calculation.py.

◆ required

test-density-calculation.required

Definition at line 49 of file test-density-calculation.py.

◆ throw_away_data_after_generation

test-density-calculation.throw_away_data_after_generation

Definition at line 379 of file test-density-calculation.py.

◆ time_in_between_plots

test-density-calculation.time_in_between_plots

Definition at line 208 of file test-density-calculation.py.

◆ True

test-density-calculation.True

Definition at line 381 of file test-density-calculation.py.

◆ type

test-density-calculation.type

Definition at line 20 of file test-density-calculation.py.

◆ x

test-density-calculation.x = np.linspace(offset, 1, Npart, endpoint=False)

Definition at line 248 of file test-density-calculation.py.

◆ xp

test-density-calculation.xp = xp.reshape((np.prod(xp.shape),))

Definition at line 251 of file test-density-calculation.py.

◆ y

test-density-calculation.y = np.linspace(offset, 1, Npart, endpoint=False)

Definition at line 249 of file test-density-calculation.py.

◆ yp

test-density-calculation.yp = yp.reshape((np.prod(yp.shape),))

Definition at line 251 of file test-density-calculation.py.