diff --git a/Docs/source/usage/parameters.rst b/Docs/source/usage/parameters.rst index 31c3ca947fb..c3756d44d96 100644 --- a/Docs/source/usage/parameters.rst +++ b/Docs/source/usage/parameters.rst @@ -3589,22 +3589,27 @@ This shifts analysis from post-processing to runtime calculation of reduction op * ``Timestep`` This type outputs the simulation's physical timestep (in seconds) at each mesh refinement level. -* ``.intervals`` (`string`) +* ``reduced_diags.intervals`` (`string`) Using the `Intervals Parser`_ syntax, this string defines the timesteps at which reduced - diagnostics are written to file. + diagnostics are written to the file. + This can also be specified for the specific diagnostic by setting ``.intervals``. -* ``.path`` (`string`) optional (default `./diags/reducedfiles/`) - The path that the output file will be stored. +* ``reduced_diags.path`` (`string`) optional (default `./diags/reducedfiles/`) + The path where the output file will be stored. + This can also be specified for the specific diagnostic by setting ``.path``. -* ``.extension`` (`string`) optional (default `txt`) - The extension of the output file. +* ``reduced_diags.extension`` (`string`) optional (default `txt`) + The extension of the output file (the suffix). + This can also be specified for the specific diagnostic by setting ``.extension``. -* ``.separator`` (`string`) optional (default a `whitespace`) +* ``reduced_diags.separator`` (`string`) optional (default a `whitespace`) The separator between row values in the output file. The default separator is a whitespace. + This can also be specified for the specific diagnostic by setting ``.separator``. -* ``.precision`` (`integer`) optional (default `14`) +* ``reduced_diags.precision`` (`integer`) optional (default `14`) The precision used when writing out the data to the text files. + This can also be specified for the specific diagnostic by setting ``.precision``. Lookup tables and other settings for QED modules ------------------------------------------------ diff --git a/Examples/Physics_applications/laser_ion/inputs_test_2d_laser_ion_acc_picmi.py b/Examples/Physics_applications/laser_ion/inputs_test_2d_laser_ion_acc_picmi.py index 66ba5f64091..c869c770b99 100755 --- a/Examples/Physics_applications/laser_ion/inputs_test_2d_laser_ion_acc_picmi.py +++ b/Examples/Physics_applications/laser_ion/inputs_test_2d_laser_ion_acc_picmi.py @@ -196,7 +196,6 @@ histuH_rdiag = picmi.ReducedDiagnostic( diag_type="ParticleHistogram", name="histuH", - period=100, species=hydrogen, bin_number=1000, bin_min=0.0, @@ -208,7 +207,6 @@ histue_rdiag = picmi.ReducedDiagnostic( diag_type="ParticleHistogram", name="histue", - period=100, species=electrons, bin_number=1000, bin_min=0.0, @@ -222,7 +220,6 @@ histuzAll_rdiag = picmi.ReducedDiagnostic( diag_type="ParticleHistogram", name="histuzAll", - period=100, species=hydrogen, bin_number=1000, bin_min=-0.474, @@ -233,7 +230,6 @@ field_probe_z_rdiag = picmi.ReducedDiagnostic( diag_type="FieldProbe", name="FieldProbe_Z", - period=100, integrate=0, probe_geometry="Line", x_probe=0.0, @@ -246,7 +242,6 @@ field_probe_scat_point_rdiag = picmi.ReducedDiagnostic( diag_type="FieldProbe", name="FieldProbe_ScatPoint", - period=1, integrate=0, probe_geometry="Point", x_probe=0.0, @@ -256,7 +251,6 @@ field_probe_scat_line_rdiag = picmi.ReducedDiagnostic( diag_type="FieldProbe", name="FieldProbe_ScatLine", - period=100, integrate=1, probe_geometry="Line", x_probe=-2.5e-6, @@ -267,7 +261,8 @@ ) load_balance_costs_rdiag = picmi.ReducedDiagnostic( - diag_type="LoadBalanceCosts", name="LBC", period=100 + diag_type="LoadBalanceCosts", + name="LBC", ) # Set up simulation @@ -278,6 +273,7 @@ particle_shape="cubic", warpx_numprocs=[1, 2], # deactivate `numprocs` for dynamic load balancing warpx_use_filter=1, + warpx_reduced_diags_intervals=100, warpx_load_balance_intervals=100, warpx_load_balance_costs_update="heuristic", ) diff --git a/Examples/Tests/implicit/inputs_test_1d_semi_implicit_picard b/Examples/Tests/implicit/inputs_test_1d_semi_implicit_picard index 8ef0304bebb..39df05ff72c 100644 --- a/Examples/Tests/implicit/inputs_test_1d_semi_implicit_picard +++ b/Examples/Tests/implicit/inputs_test_1d_semi_implicit_picard @@ -85,7 +85,6 @@ diag1.electrons.variables = z w ux uy uz diag1.protons.variables = z w ux uy uz warpx.reduced_diags_names = particle_energy field_energy +reduced_diags.intervals = 1 particle_energy.type = ParticleEnergy -particle_energy.intervals = 1 field_energy.type = FieldEnergy -field_energy.intervals = 1 diff --git a/Examples/Tests/implicit/inputs_test_1d_theta_implicit_picard b/Examples/Tests/implicit/inputs_test_1d_theta_implicit_picard index 2ed4d746708..80e4e7033fc 100644 --- a/Examples/Tests/implicit/inputs_test_1d_theta_implicit_picard +++ b/Examples/Tests/implicit/inputs_test_1d_theta_implicit_picard @@ -85,7 +85,6 @@ diag1.electrons.variables = z w ux uy uz diag1.protons.variables = z w ux uy uz warpx.reduced_diags_names = particle_energy field_energy +reduced_diags.intervals = 1 particle_energy.type = ParticleEnergy -particle_energy.intervals = 1 field_energy.type = FieldEnergy -field_energy.intervals = 1 diff --git a/Examples/Tests/implicit/inputs_test_2d_theta_implicit_jfnk_vandb b/Examples/Tests/implicit/inputs_test_2d_theta_implicit_jfnk_vandb index 0cdf2ebe40d..bab9a03878c 100644 --- a/Examples/Tests/implicit/inputs_test_2d_theta_implicit_jfnk_vandb +++ b/Examples/Tests/implicit/inputs_test_2d_theta_implicit_jfnk_vandb @@ -109,7 +109,6 @@ diag1.electrons.variables = x z w ux uy uz diag1.protons.variables = x z w ux uy uz warpx.reduced_diags_names = particle_energy field_energy +reduced_diags.intervals = 1 particle_energy.type = ParticleEnergy -particle_energy.intervals = 1 field_energy.type = FieldEnergy -field_energy.intervals = 1 diff --git a/Examples/Tests/implicit/inputs_test_2d_theta_implicit_jfnk_vandb_filtered b/Examples/Tests/implicit/inputs_test_2d_theta_implicit_jfnk_vandb_filtered index 4849a5e30a3..c7457e02af8 100644 --- a/Examples/Tests/implicit/inputs_test_2d_theta_implicit_jfnk_vandb_filtered +++ b/Examples/Tests/implicit/inputs_test_2d_theta_implicit_jfnk_vandb_filtered @@ -109,7 +109,6 @@ diag1.electrons.variables = x z w ux uy uz diag1.protons.variables = x z w ux uy uz warpx.reduced_diags_names = particle_energy field_energy +reduced_diags.intervals = 1 particle_energy.type = ParticleEnergy -particle_energy.intervals = 1 field_energy.type = FieldEnergy -field_energy.intervals = 1 diff --git a/Examples/Tests/implicit/inputs_test_2d_theta_implicit_strang_psatd b/Examples/Tests/implicit/inputs_test_2d_theta_implicit_strang_psatd index f68d1d324ac..46bc6b3d301 100644 --- a/Examples/Tests/implicit/inputs_test_2d_theta_implicit_strang_psatd +++ b/Examples/Tests/implicit/inputs_test_2d_theta_implicit_strang_psatd @@ -92,7 +92,6 @@ diag1.electrons.variables = x z w ux uy uz diag1.protons.variables = x z w ux uy uz warpx.reduced_diags_names = particle_energy field_energy +reduced_diags.intervals = 1 particle_energy.type = ParticleEnergy -particle_energy.intervals = 1 field_energy.type = FieldEnergy -field_energy.intervals = 1 diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py index afd28851f70..c5946376d52 100644 --- a/Python/pywarpx/picmi.py +++ b/Python/pywarpx/picmi.py @@ -2770,6 +2770,21 @@ class Simulation(picmistandard.PICMI_Simulation): warpx_used_inputs_file: string, optional The name of the text file that the used input parameters is written to, + + warpx_reduced_diags_path: string, optional + Sets the default path for reduced diagnostic output files + + warpx_reduced_diags_extension: string, optional + Sets the default extension for reduced diagnostic output files + + warpx_reduced_diags_intervals: string, optional + Sets the default intervals for reduced diagnostic output files + + warpx_reduced_diags_separator: string, optional + Sets the default separator for reduced diagnostic output files + + warpx_reduced_diags_precision: integer, optional + Sets the default precision for reduced diagnostic output files """ # Set the C++ WarpX interface (see _libwarpx.LibWarpX) as an extension to @@ -2836,6 +2851,12 @@ def init(self, kw): self.checkpoint_signals = kw.pop("warpx_checkpoint_signals", None) self.numprocs = kw.pop("warpx_numprocs", None) + self.reduced_diags_path = kw.pop("warpx_reduced_diags_path", None) + self.reduced_diags_extension = kw.pop("warpx_reduced_diags_extension", None) + self.reduced_diags_intervals = kw.pop("warpx_reduced_diags_intervals", None) + self.reduced_diags_separator = kw.pop("warpx_reduced_diags_separator", None) + self.reduced_diags_precision = kw.pop("warpx_reduced_diags_precision", None) + self.inputs_initialized = False self.warpx_initialized = False @@ -2902,6 +2923,13 @@ def initialize_inputs(self): pywarpx.warpx.numprocs = self.numprocs + reduced_diags = pywarpx.warpx.get_bucket("reduced_diags") + reduced_diags.path = self.reduced_diags_path + reduced_diags.extension = self.reduced_diags_extension + reduced_diags.intervals = self.reduced_diags_intervals + reduced_diags.separator = self.reduced_diags_separator + reduced_diags.precision = self.reduced_diags_precision + particle_shape = self.particle_shape for s in self.species: if s.particle_shape is not None: @@ -3943,7 +3971,7 @@ def __init__( self, diag_type, name=None, - period=1, + period=None, path=None, extension=None, separator=None, diff --git a/Source/Diagnostics/ReducedDiags/ReducedDiags.cpp b/Source/Diagnostics/ReducedDiags/ReducedDiags.cpp index ec31d9de81c..a3529cd305d 100644 --- a/Source/Diagnostics/ReducedDiags/ReducedDiags.cpp +++ b/Source/Diagnostics/ReducedDiags/ReducedDiags.cpp @@ -28,12 +28,15 @@ m_rd_name{rd_name} { BackwardCompatibility(); + const ParmParse pp_rd("reduced_diags"); const ParmParse pp_rd_name(m_rd_name); // read path + pp_rd.query("path", m_path); pp_rd_name.query("path", m_path); // read extension + pp_rd.query("extension", m_extension); pp_rd_name.query("extension", m_extension); // check if it is a restart run @@ -61,13 +64,16 @@ m_rd_name{rd_name} // read reduced diags intervals std::vector intervals_string_vec = {"1"}; - pp_rd_name.getarr("intervals", intervals_string_vec); + pp_rd.queryarr("intervals", intervals_string_vec); + pp_rd_name.queryarr("intervals", intervals_string_vec); m_intervals = utils::parser::IntervalsParser(intervals_string_vec); // read separator + pp_rd.query("separator", m_sep); pp_rd_name.query("separator", m_sep); // precision of data in the output file + utils::parser::queryWithParser(pp_rd, "precision", m_precision); utils::parser::queryWithParser(pp_rd_name, "precision", m_precision); } // end constructor