-
Notifications
You must be signed in to change notification settings - Fork 191
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
[WIP] Add ability to load external particle fields from file #4981
Changes from all commits
4c83300
fda9e4d
6e84dbf
844b21c
d7252d2
a18621f
8946e39
16fd303
8f2c89a
a479608
fd28932
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
warpx.serialize_initial_conditions = 0 | ||
warpx.do_dynamic_scheduling = 0 | ||
particles.do_tiling = 0 | ||
|
||
particles.B_ext_particle_init_style = "read_from_file" | ||
warpx.read_fields_from_path = "../../../../openPMD-example-datasets/example-femm-thetaMode.h5" | ||
|
||
warpx.grid_type = collocated | ||
warpx.do_electrostatic = labframe | ||
|
||
################################# | ||
####### GENERAL PARAMETERS ###### | ||
################################# | ||
max_step = 300 | ||
amr.n_cell = 40 40 | ||
warpx.numprocs = 1 1 | ||
amr.max_level = 0 | ||
geometry.dims = RZ | ||
|
||
geometry.prob_lo = 0.0 0.0 | ||
geometry.prob_hi = 1.0 5.0 | ||
|
||
################################# | ||
###### Boundary Condition ####### | ||
################################# | ||
boundary.field_lo = none pec | ||
boundary.field_hi = pec pec | ||
boundary.potential_lo_x = 0 | ||
boundary.potential_hi_x = 0 | ||
boundary.potential_lo_y = 0 | ||
boundary.potential_hi_y = 0 | ||
boundary.potential_lo_z = 0 | ||
boundary.potential_hi_z = 0 | ||
|
||
################################# | ||
############ NUMERICS ########### | ||
################################# | ||
warpx.serialize_initial_conditions = 1 | ||
warpx.verbose = 1 | ||
warpx.const_dt = 4.40917904849092e-7 | ||
warpx.use_filter = 0 | ||
|
||
# Order of particle shape factors | ||
algo.particle_shape = 1 | ||
|
||
################################# | ||
############ PLASMA ############# | ||
################################# | ||
particles.species_names = proton | ||
proton.injection_style = "SingleParticle" | ||
proton.single_particle_pos = 0.0 0.2 2.5 | ||
proton.single_particle_u = 9.506735958279367e-05 0.0 0.00013435537232359165 | ||
proton.single_particle_weight = 1.0 | ||
proton.do_not_deposit = 1 | ||
proton.mass = m_p | ||
proton.charge = q_e | ||
|
||
# Diagnostics | ||
diagnostics.diags_names = diag1 chk | ||
diag1.intervals = 300 | ||
diag1.diag_type = Full | ||
|
||
chk.intervals = 150 | ||
chk.diag_type = Full | ||
chk.format = checkpoint |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"lev=0": { | ||
"Br": 0.6380326770459374, | ||
"Bt": 0.0, | ||
"Bz": 4.850698699951099, | ||
"Er": 0.0, | ||
"Et": 0.0, | ||
"Ez": 0.0, | ||
"jr": 0.0, | ||
"jt": 0.0, | ||
"jz": 0.0 | ||
}, | ||
"proton": { | ||
"particle_momentum_x": 1.2945379007125463e-23, | ||
"particle_momentum_y": 7.901629565307941e-23, | ||
"particle_momentum_z": 2.0004592432172922e-23, | ||
"particle_position_x": 0.12402004585603355, | ||
"particle_position_y": 4.363249204658946, | ||
"particle_theta": 0.22200801011337173, | ||
"particle_weight": 1.0 | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
#include "Utils/WarpXProfilerWrapper.H" | ||
#include "WarpXComm_K.H" | ||
#include "WarpXSumGuardCells.H" | ||
#include "Particles/MultiParticleContainer.H" | ||
|
||
#include <ablastr/coarsen/average.H> | ||
#include <ablastr/utils/Communication.H> | ||
|
@@ -59,6 +60,24 @@ | |
} else { | ||
UpdateAuxilaryDataStagToNodal(); | ||
} | ||
|
||
// When loading particle fields from file: add the external fields: | ||
// TODO reuse WarpX::AddExternalFields | ||
// TODO replace fp_external with simply external | ||
for (int lev = 0; lev <= finest_level; ++lev) { | ||
// FIXME: RZ multimode has more than one component for all these | ||
if (mypc->m_E_ext_particle_s == "read_from_file") { | ||
amrex::MultiFab::Add(*Efield_aux[lev][0], *Efield_fp_external[lev][0], 0, 0, 1, guard_cells.ng_alloc_EB); | ||
amrex::MultiFab::Add(*Efield_aux[lev][1], *Efield_fp_external[lev][1], 0, 0, 1, guard_cells.ng_alloc_EB); | ||
amrex::MultiFab::Add(*Efield_aux[lev][2], *Efield_fp_external[lev][2], 0, 0, 1, guard_cells.ng_alloc_EB); | ||
} | ||
if (mypc->m_B_ext_particle_s == "read_from_file") { | ||
amrex::MultiFab::Add(*Bfield_aux[lev][0], *Bfield_fp_external[lev][0], 0, 0, 1, guard_cells.ng_alloc_EB); | ||
amrex::MultiFab::Add(*Bfield_aux[lev][1], *Bfield_fp_external[lev][1], 0, 0, 1, guard_cells.ng_alloc_EB); | ||
amrex::MultiFab::Add(*Bfield_aux[lev][2], *Bfield_fp_external[lev][2], 0, 0, 1, guard_cells.ng_alloc_EB); | ||
} | ||
} | ||
|
||
} | ||
|
||
void | ||
|
@@ -293,6 +312,18 @@ | |
void | ||
WarpX::UpdateAuxilaryDataSameType () | ||
{ | ||
// Update aux field, including guard cells, up to ng_FieldGather | ||
const amrex::IntVect& ng_src = guard_cells.ng_FieldGather; | ||
|
||
// Level 0: Copy from fine to aux | ||
// TODO Check if aux and fp are aliases of each other. If so, we can skip the copy. | ||
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. Not needed anymore after this PR is merged: |
||
MultiFab::Copy(*Efield_aux[0][0], *Efield_fp[0][0], 0, 0, Efield_aux[0][0]->nComp(), ng_src); | ||
MultiFab::Copy(*Efield_aux[0][1], *Efield_fp[0][1], 0, 0, Efield_aux[0][1]->nComp(), ng_src); | ||
MultiFab::Copy(*Efield_aux[0][2], *Efield_fp[0][2], 0, 0, Efield_aux[0][2]->nComp(), ng_src); | ||
MultiFab::Copy(*Bfield_aux[0][0], *Bfield_fp[0][0], 0, 0, Bfield_aux[0][0]->nComp(), ng_src); | ||
MultiFab::Copy(*Bfield_aux[0][1], *Bfield_fp[0][1], 0, 0, Bfield_aux[0][1]->nComp(), ng_src); | ||
MultiFab::Copy(*Bfield_aux[0][2], *Bfield_fp[0][2], 0, 0, Bfield_aux[0][2]->nComp(), ng_src); | ||
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. Here, we need to check whether
and otherwise, keep this code |
||
|
||
for (int lev = 1; lev <= finest_level; ++lev) | ||
{ | ||
const amrex::Periodicity& crse_period = Geom(lev-1).periodicity(); | ||
|
@@ -308,8 +339,6 @@ | |
dBy.setVal(0.0); | ||
dBz.setVal(0.0); | ||
|
||
// Guard cells may not be up to date beyond ng_FieldGather | ||
const amrex::IntVect& ng_src = guard_cells.ng_FieldGather; | ||
// Copy Bfield_aux to the dB MultiFabs, using up to ng_src (=ng_FieldGather) guard | ||
// cells from Bfield_aux and filling up to ng (=nGrow) guard cells in the dB MultiFabs | ||
|
||
|
@@ -379,8 +408,6 @@ | |
dEy.setVal(0.0); | ||
dEz.setVal(0.0); | ||
|
||
// Guard cells may not be up to date beyond ng_FieldGather | ||
const amrex::IntVect& ng_src = guard_cells.ng_FieldGather; | ||
// Copy Efield_aux to the dE MultiFabs, using up to ng_src (=ng_FieldGather) guard | ||
// cells from Efield_aux and filling up to ng (=nGrow) guard cells in the dE MultiFabs | ||
ablastr::utils::communication::ParallelCopy(dEx, *Efield_aux[lev - 1][0], 0, 0, | ||
|
Check notice
Code scanning / CodeQL
FIXME comment Note