-
Notifications
You must be signed in to change notification settings - Fork 223
Add example of basic python input file #6149
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
ax3l
merged 8 commits into
BLAST-WarpX:development
from
dpgrote:add_basic_python_example
Sep 17, 2025
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
85180f3
Add example of basic python input file
dpgrote 32a3ab7
Fix input file name
dpgrote 24d36c2
Merge branch 'development' into add_basic_python_example
dpgrote 1bb1fd4
Cleanup the interface some
dpgrote 99b6776
geometry.dims is now always converted to a str
dpgrote a97f042
Use integer for geometry.dims in example
dpgrote c10600a
Add new Particles class that allows injection source attributes
dpgrote ba48854
Remove obsolete code from WarpX.py
dpgrote 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
77 changes: 77 additions & 0 deletions
77
Examples/Tests/plasma_lens/inputs_test_3d_plasma_lens_python.py
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
from pywarpx import ( | ||
Bucket, | ||
Diagnostics, | ||
Particles, | ||
algo, | ||
amr, | ||
boundary, | ||
diagnostics, | ||
geometry, | ||
particles, | ||
picmi, | ||
warpx, | ||
) | ||
|
||
clight = picmi.constants.c | ||
m_e = picmi.constants.m_e | ||
q_e = picmi.constants.q_e | ||
|
||
# Maximum number of time steps | ||
max_step = 84 | ||
|
||
# number of grid points | ||
amr.n_cell = 16, 16, 16 | ||
|
||
amr.max_level = 0 | ||
|
||
# Geometry | ||
geometry.dims = "3" | ||
geometry.prob_lo = -1.0, -1.0, 0.0 # physical domain | ||
geometry.prob_hi = 1.0, 1.0, 2.0 | ||
|
||
boundary.field_lo = "pec", "pec", "pec" | ||
boundary.field_hi = "pec", "pec", "pec" | ||
boundary.particle_lo = "absorbing", "absorbing", "absorbing" | ||
boundary.particle_hi = "absorbing", "absorbing", "absorbing" | ||
|
||
# Algorithms | ||
algo.particle_shape = 1 | ||
warpx.cfl = 0.7 | ||
|
||
vel_z = 0.5 * clight | ||
|
||
# particles | ||
particles.species_names = ("electrons",) | ||
|
||
electrons = Particles.newspecies("electrons") | ||
electrons.charge = -q_e | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be slightly different behavior since the -q_e will be evaluated in the input file rather than in the C++ parameter parsing. This could also be |
||
electrons.mass = m_e | ||
electrons.injection_style = "MultipleParticles" | ||
electrons.multiple_particles_pos_x = 0.05, 0.0 | ||
electrons.multiple_particles_pos_y = 0.0, 0.04 | ||
electrons.multiple_particles_pos_z = 0.05, 0.05 | ||
electrons.multiple_particles_ux = 0.0, 0.0 | ||
electrons.multiple_particles_uy = 0.0, 0.0 | ||
electrons.multiple_particles_uz = vel_z / clight, vel_z / clight | ||
electrons.multiple_particles_weight = 1.0, 1.0 | ||
|
||
particles.E_ext_particle_init_style = "repeated_plasma_lens" | ||
particles.B_ext_particle_init_style = "repeated_plasma_lens" | ||
particles.repeated_plasma_lens_period = 0.5 | ||
particles.repeated_plasma_lens_starts = 0.1, 0.11, 0.12, 0.13 | ||
particles.repeated_plasma_lens_lengths = 0.1, 0.11, 0.12, 0.13 | ||
particles.repeated_plasma_lens_strengths_E = 600000.0, 800000.0, 600000.0, 200000.0 | ||
particles.repeated_plasma_lens_strengths_B = 0.0, 0.0, 0.0, 0.0 | ||
|
||
# Diagnostics | ||
dpgrote marked this conversation as resolved.
Show resolved
Hide resolved
|
||
diag1 = Diagnostics.Diagnostic("diag1", _species_dict={}) | ||
diagnostics._diagnostics_dict["diag1"] = diag1 | ||
diag1._electrons = Bucket.Bucket("diag1.electrons") | ||
diag1._species_dict["electrons"] = diag1._electrons | ||
|
||
diag1.intervals = 84 | ||
diag1.diag_type = "Full" | ||
diag1._electrons.variables = "x", "y", "z", "ux", "uy", "uz" | ||
|
||
warpx.init() | ||
warpx.evolve(max_step) |
21 changes: 21 additions & 0 deletions
21
Regression/Checksum/benchmarks_json/test_3d_plasma_lens_python.json
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"lev=0": { | ||
"Bx": 3.742282884162779e-14, | ||
"By": 3.7336535598484914e-14, | ||
"Bz": 3.159003718717131e-16, | ||
"Ex": 4.413173821920794e-06, | ||
"Ey": 4.4408071078056295e-06, | ||
"Ez": 8.994610614847082e-06, | ||
"jx": 2.294712258053488e-10, | ||
"jy": 1.8314117729146456e-10, | ||
"jz": 2.1990787829488006e-08 | ||
}, | ||
"electrons": { | ||
"particle_momentum_x": 7.424668342068345e-24, | ||
"particle_momentum_y": 5.939638944348394e-24, | ||
"particle_momentum_z": 2.730924534454989e-22, | ||
"particle_position_x": 0.036083894319082634, | ||
"particle_position_y": 0.028872102206249608, | ||
"particle_position_z": 3.8947999633253403 | ||
} | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.