-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
192 additions
and
3 deletions.
There are no files selected for viewing
File renamed without changes.
140 changes: 140 additions & 0 deletions
140
Examples/Tests/LoadExternalField/PICMI_inputs_3d_particle_fields.py
This file contains 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,140 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# --- Input file for loading initial field from openPMD file. | ||
|
||
from pywarpx import picmi | ||
|
||
constants = picmi.constants | ||
|
||
################################# | ||
####### GENERAL PARAMETERS ###### | ||
################################# | ||
|
||
max_steps = 300 | ||
|
||
max_grid_size = 40 | ||
nx = max_grid_size | ||
ny = max_grid_size | ||
nz = max_grid_size | ||
|
||
xmin = -1 | ||
xmax = 1 | ||
ymin = xmin | ||
ymax = xmax | ||
zmin = 0 | ||
zmax = 5 | ||
|
||
number_per_cell = 200 | ||
|
||
################################# | ||
############ NUMERICS ########### | ||
################################# | ||
|
||
verbose = 1 | ||
dt = 4.4e-7 | ||
use_filter = 0 | ||
|
||
# Order of particle shape factors | ||
particle_shape = 1 | ||
|
||
################################# | ||
############ PLASMA ############# | ||
################################# | ||
|
||
ion_dist = picmi.ParticleListDistribution( | ||
x=0.0, | ||
y=0.2, | ||
z=2.5, | ||
ux=9.5e-05*constants.c, | ||
uy=0.0*constants.c, | ||
uz=1.34e-4*constants.c, | ||
weight=1.0 | ||
) | ||
|
||
ions = picmi.Species( | ||
particle_type='H', | ||
name='proton', charge='q_e',mass="m_p", | ||
warpx_do_not_deposit=1, | ||
initial_distribution=ion_dist | ||
) | ||
|
||
################################# | ||
######## INITIAL FIELD ########## | ||
################################# | ||
|
||
applied_field = picmi.LoadAppliedField( | ||
read_fields_from_path="../../../../openPMD-example-datasets/example-femm-3d.h5", | ||
load_E=False | ||
) | ||
|
||
################################# | ||
###### GRID AND SOLVER ########## | ||
################################# | ||
|
||
grid = picmi.Cartesian3DGrid( | ||
number_of_cells=[nx, ny, nz], | ||
warpx_max_grid_size=max_grid_size, | ||
lower_bound=[xmin, ymin, zmin], | ||
upper_bound=[xmax, ymax, zmax], | ||
lower_boundary_conditions=['dirichlet', 'dirichlet', 'dirichlet'], | ||
upper_boundary_conditions=['dirichlet', 'dirichlet', 'dirichlet'], | ||
lower_boundary_conditions_particles=['absorbing', 'absorbing', 'absorbing'], | ||
upper_boundary_conditions_particles=['absorbing', 'absorbing', 'absorbing'] | ||
) | ||
solver = picmi.ElectrostaticSolver(grid=grid) | ||
|
||
################################# | ||
######### 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' | ||
) | ||
|
||
################################# | ||
####### SIMULATION SETUP ######## | ||
################################# | ||
|
||
sim = picmi.Simulation( | ||
solver=solver, | ||
max_steps=max_steps, | ||
verbose=verbose, | ||
warpx_serialize_initial_conditions=False, | ||
warpx_grid_type='collocated', | ||
warpx_do_dynamic_scheduling=False, | ||
warpx_use_filter=use_filter, | ||
time_step_size=dt, | ||
particle_shape=particle_shape | ||
) | ||
|
||
sim.add_applied_field(applied_field) | ||
|
||
sim.add_species( | ||
ions, | ||
layout=picmi.PseudoRandomLayout( | ||
n_macroparticles_per_cell=number_per_cell, grid=grid | ||
) | ||
) | ||
|
||
sim.add_diagnostic(field_diag) | ||
sim.add_diagnostic(particle_diag) | ||
|
||
################################# | ||
##### SIMULATION EXECUTION ###### | ||
################################# | ||
|
||
#sim.write_input_file('PICMI_inputs_3d') | ||
sim.step(max_steps) |
This file contains 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
File renamed without changes.
22 changes: 22 additions & 0 deletions
22
Regression/Checksum/benchmarks_json/Python_LoadExternalParticleField3D.json
This file contains 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,22 @@ | ||
{ | ||
"lev=0": { | ||
"Bx": 29.8448958859583, | ||
"By": 29.844895885958305, | ||
"Bz": 197.55124310523018, | ||
"Ex": 0.0, | ||
"Ey": 0.0, | ||
"Ez": 0.0, | ||
"jx": 0.0, | ||
"jy": 0.0, | ||
"jz": 0.0 | ||
}, | ||
"proton": { | ||
"particle_momentum_x": 1.2118953253556959e-23, | ||
"particle_momentum_y": 7.822512598009088e-23, | ||
"particle_momentum_z": 2.2761898274347412e-23, | ||
"particle_position_x": 0.12238072371983327, | ||
"particle_position_y": 0.009653941154598592, | ||
"particle_position_z": 4.317544769595657, | ||
"particle_weight": 1.0 | ||
} | ||
} |
This file contains 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