-
Notifications
You must be signed in to change notification settings - Fork 1
Codex/add methods for openpmd data storage #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cwoolfo1
merged 14 commits into
uwplasma:main
from
cwoolfo1:codex/add-methods-for-openpmd-data-storage
Jan 19, 2026
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
588cfe0
Add openPMD output for fields and particles
cwoolfo1 1a74456
changing plotting
cwoolfo1 cbfe838
restructuring particle diagnostics and adding openPMD format
cwoolfo1 ff3ecf2
still debugging openPMD
cwoolfo1 bc97718
fixing issues with openPMD particle writes
cwoolfo1 b3dc6d1
updating openpmd data format writing methods
cwoolfo1 59654da
updating logo
cwoolfo1 4dfe6cf
Update PyPIC3D/diagnostics/openPMD.py
cwoolfo1 b724947
Update PyPIC3D/__main__.py
cwoolfo1 9331f0d
Update PyPIC3D/diagnostics/openPMD.py
cwoolfo1 1275f88
Update PyPIC3D/diagnostics/plotting.py
cwoolfo1 7bf91dc
Update PyPIC3D/diagnostics/plotting.py
cwoolfo1 3b1fa7a
Update PyPIC3D/diagnostics/plotting.py
cwoolfo1 fc3e057
Update PyPIC3D/utils.py
cwoolfo1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -11,23 +11,36 @@ | |||||
| from jax import block_until_ready | ||||||
| import jax.numpy as jnp | ||||||
| from tqdm import tqdm | ||||||
|
|
||||||
| #from memory_profiler import profile | ||||||
| # Importing relevant libraries | ||||||
|
|
||||||
| from PyPIC3D.plotting import ( | ||||||
| write_particles_phase_space, write_data, plot_vtk_particles, plot_field_slice_vtk, | ||||||
| plot_vectorfield_slice_vtk | ||||||
| from PyPIC3D.diagnostics.plotting import ( | ||||||
| write_particles_phase_space, write_data | ||||||
| ) | ||||||
|
|
||||||
| from PyPIC3D.diagnostics.openPMD import ( | ||||||
| write_openpmd_particles, write_openpmd_fields | ||||||
| ) | ||||||
|
|
||||||
| from PyPIC3D.diagnostics.vtk import ( | ||||||
| plot_field_slice_vtk, plot_vectorfield_slice_vtk, plot_vtk_particles | ||||||
| ) | ||||||
|
|
||||||
| from PyPIC3D.utils import ( | ||||||
| dump_parameters_to_toml, load_config_file, compute_energy | ||||||
| dump_parameters_to_toml, load_config_file, compute_energy, | ||||||
| setup_pmd_files | ||||||
| ) | ||||||
|
|
||||||
| from PyPIC3D.initialization import ( | ||||||
| initialize_simulation | ||||||
| ) | ||||||
|
|
||||||
| from PyPIC3D.rho import compute_rho, compute_mass_density, compute_velocity_field | ||||||
| from PyPIC3D.diagnostics.fluid_quantities import ( | ||||||
| compute_mass_density | ||||||
| ) | ||||||
|
|
||||||
| from PyPIC3D.rho import compute_rho | ||||||
|
|
||||||
|
|
||||||
| # Importing functions from the PyPIC3D package | ||||||
|
|
@@ -57,6 +70,10 @@ def run_PyPIC3D(config_file): | |||||
| # Compute the energy of the system | ||||||
| initial_energy = e_energy + b_energy + kinetic_energy | ||||||
|
|
||||||
| if plotting_parameters['plot_openpmd_fields']: setup_pmd_files( os.path.join(output_dir, "data"), "fields", ".h5") | ||||||
| if plotting_parameters['plot_openpmd_particles']: setup_pmd_files( os.path.join(output_dir, "data"), "particles", ".h5") | ||||||
| # setup the openPMD files if needed | ||||||
|
|
||||||
| ############################################################################################################ | ||||||
|
|
||||||
| ###################################################### SIMULATION LOOP ##################################### | ||||||
|
|
@@ -66,6 +83,9 @@ def run_PyPIC3D(config_file): | |||||
| # plot the data | ||||||
| if t % plotting_parameters['plotting_interval'] == 0: | ||||||
|
|
||||||
| plot_num = t // plotting_parameters['plotting_interval'] | ||||||
| # determine the plot number | ||||||
|
|
||||||
| E, B, J, rho, *rest = fields | ||||||
| # unpack the fields | ||||||
|
|
||||||
|
|
@@ -82,34 +102,45 @@ def run_PyPIC3D(config_file): | |||||
| write_data(f"{output_dir}/data/total_momentum.txt", t * dt, total_momentum) | ||||||
| # Write the total momentum to a file | ||||||
|
|
||||||
| for species in particles: | ||||||
| write_data(f"{output_dir}/data/{species.name}_kinetic_energy.txt", t * dt, species.kinetic_energy()) | ||||||
| # for species in particles: | ||||||
| # write_data(f"{output_dir}/data/{species.name}_kinetic_energy.txt", t * dt, species.kinetic_energy()) | ||||||
|
|
||||||
|
|
||||||
|
Comment on lines
+105
to
108
|
||||||
| # for species in particles: | |
| # write_data(f"{output_dir}/data/{species.name}_kinetic_energy.txt", t * dt, species.kinetic_energy()) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diagnostics directory is missing an init.py file, which is required for Python to recognize it as a package. This will cause import failures when trying to import from PyPIC3D.diagnostics.plotting, PyPIC3D.diagnostics.openPMD, PyPIC3D.diagnostics.vtk, and PyPIC3D.diagnostics.fluid_quantities.