Skip to content

Commit

Permalink
Change default behavior of picmi.FieldDiagnostic and picmi.ParticleDi…
Browse files Browse the repository at this point in the history
…agnostic & fix CI tests (ECP-WarpX#4317)

* Do not write particles with `FieldDiagnostic`

Do not write fields with `ParticleDiagnostic

Update implementation

Revert "Update implementation"

This reverts commit 77b473f.

Use syntax with argvattrs

Correct typo

Force writing of species

Add function that can replace existing attributes

Revert "Revert "Update implementation""

This reverts commit d946fe6.

Correct syntax typo

[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Revert "Revert "Revert "Update implementation"""

This reverts commit 69092be.

Generalization for backtransformed diagnostics

Update lab-frame diagnostics

Update 1D CI case

Fix additional merge errors

Remove particle diagnostic

Add particle diagnostic where needed

Use latest PICMI version

Handle the case when species is None

Add missing `add_diagnostic` calls

* Update 1D ion beam case

Fixed CI: plasma_lens

Fixed CI: LoadExternalField

Fixed CI: Python_reduced_diags_loadbalancecosts_timers

Clean up

* Fixed CI: Python_ionization, Ohm Solver

* Clean up: removed jx, jy, jz

* More fixes in Ohm solver's CIs

* Placed species in squire brackets

* Wrtie FieldDiagnostics in CI: Python_prev_positions

* Do not specify datalist in test

---------

Co-authored-by: Remi Lehe <[email protected]>
  • Loading branch information
oshapoval and RemiLehe authored Oct 11, 2023
1 parent b71b89c commit 419d47a
Show file tree
Hide file tree
Showing 32 changed files with 280 additions and 62 deletions.
2 changes: 1 addition & 1 deletion Docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ docutils>=0.17.1

# PICMI API docs
# note: keep in sync with version in ../requirements.txt
picmistandard==0.26.0
picmistandard==0.28.0
# for development against an unreleased PICMI version, use:
# picmistandard @ git+https://github.com/picmi-standard/picmi.git#subdirectory=PICMI_Python

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,12 @@ def setup_run(self):
else:
file_prefix = 'Python_background_mcc_1d_tridiag_plt'

particle_diag = picmi.ParticleDiagnostic(
name='diag1',
period=0,
write_dir='.',
warpx_file_prefix=file_prefix
)
field_diag = picmi.FieldDiagnostic(
name='diag1',
grid=self.grid,
Expand All @@ -332,6 +338,7 @@ def setup_run(self):
write_dir='.',
warpx_file_prefix=file_prefix
)
self.sim.add_diagnostic(particle_diag)
self.sim.add_diagnostic(field_diag)

def _get_rho_ions(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@ def solve(self):
# diagnostics
##########################

particle_diag = picmi.ParticleDiagnostic(
name = 'diag1',
period = diagnostic_intervals,
write_dir = '.',
warpx_file_prefix = 'Python_background_mcc_plt'
)
field_diag = picmi.FieldDiagnostic(
name = 'diag1',
grid = grid,
Expand Down Expand Up @@ -345,6 +351,7 @@ def solve(self):
)
)

sim.add_diagnostic(particle_diag)
sim.add_diagnostic(field_diag)

##########################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@

# Diagnostics
diag_field_list = ['B', 'E', 'J', 'rho']
particle_diag = picmi.ParticleDiagnostic(
name = 'diag1',
period = 100,
write_dir = '.',
warpx_file_prefix = 'Python_LaserAcceleration_1d_plt')
field_diag = picmi.FieldDiagnostic(
name = 'diag1',
grid = grid,
Expand Down Expand Up @@ -108,6 +113,7 @@
injection_method = laser_antenna)

# Add diagnostics
sim.add_diagnostic(particle_diag)
sim.add_diagnostic(field_diag)

# Write input file that can be used to run with the compiled version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@

# Diagnostics
diag_field_list = ['B', 'E', 'J', 'rho']
particle_diag = picmi.ParticleDiagnostic(
name = 'diag1',
period = 200,
write_dir = '.',
warpx_file_prefix = 'Python_LaserAccelerationMR_plt')
field_diag = picmi.FieldDiagnostic(
name = 'diag1',
grid = grid,
Expand Down Expand Up @@ -145,6 +150,7 @@
injection_method = laser_antenna)

# Add diagnostics
sim.add_diagnostic(particle_diag)
sim.add_diagnostic(field_diag)

# Write input file that can be used to run with the compiled version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@

# Diagnostics
diag_field_list = ['B', 'E', 'J', 'rho']
particle_diag = picmi.ParticleDiagnostic(
name = 'diag1',
period = 100,
write_dir = '.',
warpx_file_prefix = 'Python_LaserAcceleration_plt')
field_diag = picmi.FieldDiagnostic(
name = 'diag1',
grid = grid,
Expand Down Expand Up @@ -144,6 +149,7 @@
injection_method = laser_antenna)

# Add diagnostics
sim.add_diagnostic(particle_diag)
sim.add_diagnostic(field_diag)

# Write input file that can be used to run with the compiled version
Expand Down
10 changes: 10 additions & 0 deletions Examples/Tests/LoadExternalField/PICMI_inputs_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,19 @@
######### DIAGNOSTICS ###########
#################################

particle_diag = picmi.ParticleDiagnostic(
name='diag1',
period=300,
species=[ions],
data_list = ['ux', 'uy', 'uz', 'x', 'y', 'z', 'weighting'],
write_dir='.',
warpx_file_prefix='Python_LoadExternalField3D_plt'
)
field_diag = picmi.FieldDiagnostic(
name='diag1',
grid=grid,
period=300,
data_list = ['Bx', 'By', 'Bz', 'Ex', 'Ey', 'Ez', 'Jx', 'Jy', 'Jz'],
write_dir='.',
warpx_file_prefix='Python_LoadExternalField3D_plt'
)
Expand Down Expand Up @@ -121,6 +130,7 @@
)

sim.add_diagnostic(field_diag)
sim.add_diagnostic(particle_diag)

#################################
##### SIMULATION EXECUTION ######
Expand Down
7 changes: 7 additions & 0 deletions Examples/Tests/collision/PICMI_inputs_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@
######### DIAGNOSTICS ###########
#################################

particle_diag = picmi.ParticleDiagnostic(
name='diag1',
period=10,
write_dir='.',
warpx_file_prefix='Python_collisionXZ_plt'
)
field_diag = picmi.FieldDiagnostic(
name='diag1',
grid=grid,
Expand Down Expand Up @@ -140,6 +146,7 @@
)
)

sim.add_diagnostic(particle_diag)
sim.add_diagnostic(field_diag)

#################################
Expand Down
7 changes: 7 additions & 0 deletions Examples/Tests/electrostatic_dirichlet_bc/PICMI_inputs_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
# diagnostics
##########################

particle_diag = picmi.ParticleDiagnostic(
name = 'diag1',
period = 4,
write_dir = '.',
warpx_file_prefix = 'Python_dirichletbc_plt'
)
field_diag = picmi.FieldDiagnostic(
name = 'diag1',
grid = grid,
Expand All @@ -79,6 +85,7 @@
verbose = 0
)

sim.add_diagnostic(particle_diag)
sim.add_diagnostic(field_diag)

##########################
Expand Down
7 changes: 7 additions & 0 deletions Examples/Tests/electrostatic_sphere_eb/PICMI_inputs_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@
# diagnostics
##########################

particle_diag = picmi.ParticleDiagnostic(
name = 'diag1',
period = 1,
write_dir = '.',
warpx_file_prefix = 'Python_ElectrostaticSphereEB_plt'
)
field_diag = picmi.FieldDiagnostic(
name = 'diag1',
grid = grid,
Expand Down Expand Up @@ -102,6 +108,7 @@
warpx_field_gathering_algo='momentum-conserving'
)

sim.add_diagnostic(particle_diag)
sim.add_diagnostic(field_diag)
sim.add_diagnostic(reduced_diag)
sim.add_diagnostic(reduced_diag_one_eighth)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
# diagnostics
##########################

particle_diag = picmi.ParticleDiagnostic(
name = 'diag1',
period = 1,
write_dir = '.',
warpx_file_prefix = "embedded_boundary_python_API_plt"
)
field_diag = picmi.FieldDiagnostic(
name = 'diag1',
grid = grid,
Expand All @@ -78,6 +84,7 @@
verbose = 1
)

sim.add_diagnostic(particle_diag)
sim.add_diagnostic(field_diag)

sim.initialize_inputs()
Expand Down
13 changes: 11 additions & 2 deletions Examples/Tests/ionization/PICMI_inputs_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,18 @@
cfl = 0.999)

# Diagnostics
diag = picmi.FieldDiagnostic(
particle_diag = picmi.ParticleDiagnostic(
name = 'diag1',
period = 10000,
species = [electrons, ions],
data_list = ['ux', 'uy', 'uz', 'x', 'y', 'weighting'],
write_dir = '.',
warpx_file_prefix = 'Python_ionization_plt')
field_diag = picmi.FieldDiagnostic(
name = 'diag1',
grid = grid,
period = 10000,
data_list = ['Bx', 'By', 'Bz', 'Ex', 'Ey', 'Ez', 'Jx', 'Jy', 'Jz'],
write_dir = '.',
warpx_file_prefix = 'Python_ionization_plt')

Expand Down Expand Up @@ -115,7 +123,8 @@
injection_method = laser_antenna)

# Add diagnostics
sim.add_diagnostic(diag)
sim.add_diagnostic(particle_diag)
sim.add_diagnostic(field_diag)

# Write input file that can be used to run with the compiled version
sim.write_input_file(file_name = 'inputs_2d_picmi')
Expand Down
7 changes: 7 additions & 0 deletions Examples/Tests/magnetostatic_eb/PICMI_inputs_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@
# diagnostics
##########################

particle_diag = picmi.ParticleDiagnostic(
name = 'diag1',
period = 1,
write_dir = '.',
warpx_file_prefix = 'Python_magnetostatic_eb_3d_plt'
)
field_diag = picmi.FieldDiagnostic(
name = 'diag1',
grid = grid,
Expand Down Expand Up @@ -140,6 +146,7 @@

sim.add_species(beam, layout=beam_layout, initialize_self_field=True)

sim.add_diagnostic(particle_diag)
sim.add_diagnostic(field_diag)

##########################
Expand Down
7 changes: 7 additions & 0 deletions Examples/Tests/magnetostatic_eb/PICMI_inputs_rz.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@
# diagnostics
##########################

particle_diag = picmi.ParticleDiagnostic(
name = 'diag1',
period = 1,
write_dir = '.',
warpx_file_prefix = 'Python_magnetostatic_eb_rz_plt'
)
field_diag = picmi.FieldDiagnostic(
name = 'diag1',
grid = grid,
Expand Down Expand Up @@ -137,6 +143,7 @@

sim.add_species(beam, layout=beam_layout, initialize_self_field=True)

sim.add_diagnostic(particle_diag)
sim.add_diagnostic(field_diag)

##########################
Expand Down
14 changes: 13 additions & 1 deletion Examples/Tests/ohm_solver_EM_modes/PICMI_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@

comm = mpi.COMM_WORLD

simulation = picmi.Simulation(verbose=0)
simulation = picmi.Simulation(
warpx_serialize_initial_conditions=True,
verbose=0
)
# make a shorthand for simulation.extension since we use it a lot
sim_ext = simulation.extension

Expand Down Expand Up @@ -256,6 +259,15 @@ def setup_run(self):
self.output_file_name = 'perp_field_data.txt'

if self.test:
particle_diag = picmi.ParticleDiagnostic(
name='field_diag',
period=self.total_steps,
write_dir='.',
warpx_file_prefix='Python_ohms_law_solver_EM_modes_1d_plt',
# warpx_format = 'openpmd',
# warpx_openpmd_backend = 'h5'
)
simulation.add_diagnostic(particle_diag)
field_diag = picmi.FieldDiagnostic(
name='field_diag',
grid=self.grid,
Expand Down
16 changes: 14 additions & 2 deletions Examples/Tests/ohm_solver_ion_Landau_damping/PICMI_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

comm = mpi.COMM_WORLD

simulation = picmi.Simulation(verbose=0)
simulation = picmi.Simulation(
warpx_serialize_initial_conditions=True,
verbose=0)
# make a shorthand for simulation.extension since we use it a lot
sim_ext = simulation.extension

Expand Down Expand Up @@ -216,11 +218,21 @@ def setup_run(self):
callbacks.installafterstep(self.text_diag)

if self.test:
particle_diag = picmi.ParticleDiagnostic(
name='diag1',
period=100,
write_dir='.',
species=[self.ions],
data_list = ['ux', 'uy', 'uz', 'x', 'y', 'weighting'],
warpx_file_prefix=f'Python_ohms_law_solver_landau_damping_{self.dim}d_plt',
)
simulation.add_diagnostic(particle_diag)
field_diag = picmi.FieldDiagnostic(
name='field_diag',
name='diag1',
grid=self.grid,
period=100,
write_dir='.',
data_list = ['Bx', 'By', 'Bz', 'Ex', 'Ey', 'Ez', 'Jx', 'Jy', 'Jz'],
warpx_file_prefix=f'Python_ohms_law_solver_landau_damping_{self.dim}d_plt',
)
simulation.add_diagnostic(field_diag)
Expand Down
16 changes: 14 additions & 2 deletions Examples/Tests/ohm_solver_ion_beam_instability/PICMI_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

comm = mpi.COMM_WORLD

simulation = picmi.Simulation(verbose=0)
simulation = picmi.Simulation(
warpx_serialize_initial_conditions=True,
verbose=0)
# make a shorthand for simulation.extension since we use it a lot
sim_ext = simulation.extension

Expand Down Expand Up @@ -256,10 +258,20 @@ def setup_run(self):
callbacks.installafterstep(self.text_diag)

if self.test:
part_diag = picmi.ParticleDiagnostic(
name='diag1',
period=1250,
species=[self.ions, self.beam_ions],
data_list = ['ux', 'uy', 'uz', 'x', 'weighting'],
write_dir='.',
warpx_file_prefix='Python_ohms_law_solver_ion_beam_1d_plt',
)
simulation.add_diagnostic(part_diag)
field_diag = picmi.FieldDiagnostic(
name='field_diag',
name='diag1',
grid=self.grid,
period=1250,
data_list = ['Bx', 'By', 'Bz', 'Ex', 'Ey', 'Ez', 'Jx', 'Jy', 'Jz'],
write_dir='.',
warpx_file_prefix='Python_ohms_law_solver_ion_beam_1d_plt',
)
Expand Down
Loading

0 comments on commit 419d47a

Please sign in to comment.