Skip to content

Commit

Permalink
Cleanup deposition and gather routines (#4978)
Browse files Browse the repository at this point in the history
* Initial clean up of current deposition

* Fix of current deposition

* Further cleanup of current deposition

* Cleanup SharedDepositionUtils

* Clean up in charge deposition

* Clean up field gather plus other fixes

* Change LowerCorner to return XDim3, add InvCellSize

* Change variable name in Lower and UpperCorner to avoid confusion

* Add const

* Update RepellingParticles CI test

* Update Python_ionization CI test

* Update ionization_boost and ionization_lab CI tests

* Update PEC_particle CI test

* Update BTD_rz CI test
  • Loading branch information
dpgrote authored Jun 18, 2024
1 parent 8283320 commit 41fc45b
Show file tree
Hide file tree
Showing 33 changed files with 496 additions and 876 deletions.
10 changes: 5 additions & 5 deletions Examples/Tests/repelling_particles/analysis_repelling.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

# Check plotfile name specified in command line
last_filename = sys.argv[1]
filename_radical = re.findall('(.*?)\d+/*$', last_filename)[0]
filename_radical = re.findall(r'(.*?)\d+/*$', last_filename)[0]

# Loop through files, and extract the position and velocity of both particles
x1 = []
Expand All @@ -48,10 +48,10 @@
ds = yt.load(filename)
ad = ds.all_data()

x1.append( float(ad[('electron1','particle_position_x')]) )
x2.append( float(ad[('electron2','particle_position_x')]) )
beta1.append( float(ad[('electron1','particle_momentum_x')])/(m_e*c) )
beta2.append( float(ad[('electron2','particle_momentum_x')])/(m_e*c) )
x1.append( float(ad[('electron1','particle_position_x')][0]) )
x2.append( float(ad[('electron2','particle_position_x')][0]) )
beta1.append( float(ad[('electron1','particle_momentum_x')][0])/(m_e*c) )
beta2.append( float(ad[('electron2','particle_momentum_x')][0])/(m_e*c) )

# Convert to numpy array
x1 = np.array(x1)
Expand Down
12 changes: 6 additions & 6 deletions Regression/Checksum/benchmarks_json/BTD_rz.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"lev=0": {
"Br": 1.8705552264208163e-08,
"Bt": 2380179.5677922587,
"Bz": 2.4079077116116535e-08,
"Br": 1.8705569155952808e-08,
"Bt": 2380179.567792259,
"Bz": 2.4079063431898616e-08,
"Er": 497571119514841.25,
"Et": 7.048225464720808,
"Ez": 137058870936728.28,
"Et": 7.048223219552,
"Ez": 137058870936728.23,
"jr": 0.0,
"jt": 0.0,
"jz": 0.0
}
}
}
40 changes: 20 additions & 20 deletions Regression/Checksum/benchmarks_json/PEC_particle.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"lev=0": {
"Bx": 6.52080713617892e-07,
"By": 5.323555640562078e-18,
"Bz": 1.1834601056649145e-06,
"Ex": 300.06725745121753,
"Ey": 320.82687281173185,
"Ez": 185.62208934593673,
"jx": 1.857782359527958e-06,
"jy": 257766.55567863808,
"Bx": 6.5208071361789e-07,
"By": 5.323579900863346e-18,
"Bz": 1.1834601056649094e-06,
"Ex": 300.0672574512165,
"Ey": 320.82687281173,
"Ez": 185.62208934593605,
"jx": 1.8577823595279576e-06,
"jy": 257766.5556786359,
"jz": 0.0
},
"electron": {
"particle_momentum_x": 1.1142179380730402e-32,
"particle_momentum_y": 4.5160903214571184e-36,
"particle_momentum_z": 5.735409609139057e-50,
"particle_position_x": 3.199800000000006e-05,
"particle_position_y": 6.267072536608953e-23,
"particle_position_z": 3.3938629027782103e-37,
"particle_weight": 1.0
},
"proton": {
"particle_momentum_x": 1.0975605406855061e-33,
"particle_momentum_x": 1.097560540685506e-33,
"particle_momentum_y": 1.002878875615427e-18,
"particle_momentum_z": 5.084424741580567e-51,
"particle_momentum_z": 8.484417024161229e-51,
"particle_position_x": 3.1998e-05,
"particle_position_y": 6.572670690061996e-06,
"particle_position_z": 5.681444715216788e-38,
"particle_weight": 1.0
},
"electron": {
"particle_momentum_x": 1.1142179380730476e-32,
"particle_momentum_y": 4.516090321457367e-36,
"particle_momentum_z": 2.2354046360787e-50,
"particle_position_x": 3.199800000000006e-05,
"particle_position_y": 6.267072536609136e-23,
"particle_position_z": 1.4145775327446577e-37,
"particle_position_z": 4.372139867361774e-39,
"particle_weight": 1.0
}
}
30 changes: 15 additions & 15 deletions Regression/Checksum/benchmarks_json/Python_ionization.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
"Bx": 0.0,
"By": 26296568.434868,
"Bz": 0.0,
"Ex": 7878103122971888.0,
"Ex": 7878103122971890.0,
"Ey": 0.0,
"Ez": 3027.995293554466,
"jx": 1.2111358330750162e+16,
"Ez": 3027.738911163427,
"jx": 1.2111358330750164e+16,
"jy": 0.0,
"jz": 1.3483401471475687e-07
"jz": 1.3523766702993914e-07
},
"electrons": {
"particle_momentum_x": 4.4237309006289776e-18,
"particle_momentum_y": 0.0,
"particle_momentum_z": 2.643146520891287e-18,
"particle_orig_z": 0.4306994012391905,
"particle_position_x": 0.11013574385450274,
"particle_position_y": 0.6415447480129455,
"particle_weight": 3.4456249999999997e-10
},
"ions": {
"particle_ionizationLevel": 72897.0,
"particle_momentum_x": 1.76132401934254e-18,
"particle_momentum_x": 1.7613240193425407e-18,
"particle_momentum_y": 0.0,
"particle_momentum_z": 3.644887053263054e-23,
"particle_momentum_z": 3.6448870533515125e-23,
"particle_orig_z": 0.128,
"particle_position_x": 0.03200001189420337,
"particle_position_y": 0.1280000046901387,
"particle_weight": 9.999999999999999e-11
},
"electrons": {
"particle_momentum_x": 4.4206237143449475e-18,
"particle_momentum_y": 0.0,
"particle_momentum_z": 2.6361297302081026e-18,
"particle_orig_z": 0.4305565137391907,
"particle_position_x": 0.11009154442846772,
"particle_position_y": 0.6414658436421568,
"particle_weight": 3.4450781249999996e-10
}
}
44 changes: 22 additions & 22 deletions Regression/Checksum/benchmarks_json/RepellingParticles.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
{
"lev=0": {
"Bx": 0.0,
"By": 10603.681421961119,
"Bz": 0.0,
"Ex": 12084698236273.04,
"Ey": 0.0,
"Ez": 16282812598779.527,
"F": 21124.39775810062,
"divE": 1.495787831639977e+18,
"jx": 496020344341010.9,
"jy": 0.0,
"jz": 10.641859867595102,
"rho": 6408706.535999998
},
"electron1": {
"particle_momentum_x": 7.303686586478214e-23,
"particle_momentum_x": 7.303686586478215e-23,
"particle_momentum_y": 0.0,
"particle_momentum_z": 1.556862195127266e-36,
"particle_position_x": 1.293487226551532e-05,
"particle_position_y": 1.777889117487881e-19,
"particle_momentum_z": 1.552083282915395e-36,
"particle_position_x": 1.293487226551533e-05,
"particle_position_y": 1.7783750855614515e-19,
"particle_weight": 5000000000000.0
},
"electron2": {
"particle_momentum_x": 7.303686586477884e-23,
"particle_momentum_x": 7.303686586477887e-23,
"particle_momentum_y": 0.0,
"particle_momentum_z": 1.567350238825104e-36,
"particle_momentum_z": 1.5731022908002534e-36,
"particle_position_x": 1.293487226551495e-05,
"particle_position_y": 1.797289839952283e-19,
"particle_position_y": 1.7989574553330234e-19,
"particle_weight": 5000000000000.0
},
"lev=0": {
"Bx": 0.0,
"By": 10603.68142196111,
"Bz": 0.0,
"Ex": 12084698236273.04,
"Ey": 0.0,
"Ez": 16282812598779.53,
"F": 21124.39775810061,
"divE": 1.495787831639981e+18,
"jx": 496020344341011.4,
"jy": 0.0,
"jz": 10.93513947024536,
"rho": 6408706.535999998
}
}
}
30 changes: 15 additions & 15 deletions Regression/Checksum/benchmarks_json/ionization_boost.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
{
"lev=0": {
"Bx": 0.0,
"By": 18263123.342891,
"By": 18263123.342890993,
"Bz": 0.0,
"Ex": 5472992180428804.0,
"Ex": 5472992180428803.0,
"Ey": 0.0,
"Ez": 922.5589707939612,
"jx": 12440856508004.96,
"Ez": 922.2798874201462,
"jx": 12440856508004.957,
"jy": 0.0,
"jz": 78616.0000011086
},
"electrons": {
"particle_momentum_x": 2.1386770170623736e-17,
"particle_momentum_y": 0.0,
"particle_momentum_z": 1.7287241262743654e-17,
"particle_position_x": 0.11064981928849067,
"particle_position_y": 1.7121826057017473,
"particle_weight": 3.0755014319061045e-09
"jz": 78616.00000110897
},
"ions": {
"particle_ionizationLevel": 52741.0,
"particle_momentum_x": 3.630619728387593e-18,
"particle_momentum_x": 3.630619728387586e-18,
"particle_momentum_y": 0.0,
"particle_momentum_z": 1.0432995297946715e-13,
"particle_position_x": 0.021439968272741083,
"particle_position_y": 0.4742770090248555,
"particle_weight": 5.000948082142308e-10
},
"electrons": {
"particle_momentum_x": 2.138486151076505e-17,
"particle_momentum_y": 0.0,
"particle_momentum_z": 1.7285619821244245e-17,
"particle_position_x": 0.11066682695880013,
"particle_position_y": 1.712069774427624,
"particle_weight": 3.0755014319061037e-09
}
}
}
32 changes: 16 additions & 16 deletions Regression/Checksum/benchmarks_json/ionization_lab.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
"Bx": 0.0,
"By": 26296568.434868,
"Bz": 0.0,
"Ex": 7878103122971888.0,
"Ex": 7878103122971890.0,
"Ey": 0.0,
"Ez": 3027.995293554467,
"jx": 1.2111358330750162e+16,
"Ez": 3027.7389111634266,
"jx": 1.2111358330750164e+16,
"jy": 0.0,
"jz": 1.3575651149270143e-07
"jz": 1.355962687103163e-07
},
"electrons": {
"particle_momentum_x": 4.4195594812814575e-18,
"particle_momentum_y": 0.0,
"particle_momentum_z": 2.6520195422151263e-18,
"particle_orig_z": 0.43004993872230357,
"particle_position_x": 0.11017033205040265,
"particle_position_y": 0.6412498318709239,
"particle_weight": 3.442265625e-10
},
"ions": {
"particle_ionizationLevel": 72897.0,
"particle_momentum_x": 1.7613240052056494e-18,
"particle_momentum_x": 1.761324005205651e-18,
"particle_momentum_y": 0.0,
"particle_momentum_z": 3.6186967375178554e-23,
"particle_momentum_z": 3.618696737610014e-23,
"particle_position_x": 0.0320000118071032,
"particle_position_y": 0.12800000462171646,
"particle_weight": 9.999999999999999e-11
},
"electrons": {
"particle_momentum_x": 4.428135211584547e-18,
"particle_momentum_y": 0.0,
"particle_momentum_z": 2.6627518442038486e-18,
"particle_orig_z": 0.43043207622230534,
"particle_position_x": 0.11023346490802505,
"particle_position_y": 0.6417814148540429,
"particle_weight": 3.44453125e-10
}
}
}
2 changes: 1 addition & 1 deletion Source/AcceleratorLattice/LatticeElementFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ LatticeElementFinder::UpdateIndices (int const lev, amrex::MFIter const& a_mfi,
// Note that the current box is used since the box may have been updated since
// the initialization in InitElementFinder.
const amrex::Box box = a_mfi.tilebox();
m_zmin = WarpX::LowerCorner(box, lev, 0._rt)[2];
m_zmin = WarpX::LowerCorner(box, lev, 0._rt).z;
m_time = warpx.gett_new(lev);

if (accelerator_lattice.h_quad.nelements > 0) {
Expand Down
4 changes: 2 additions & 2 deletions Source/BoundaryConditions/WarpXFieldBoundaries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ WarpX::ApplyFieldBoundaryOnAxis (amrex::MultiFab* Er, amrex::MultiFab* Et, amrex
// Lower corner of tile box physical domain
// Note that this is done before the tilebox.grow so that
// these do not include the guard cells.
const std::array<amrex::Real, 3>& xyzmin = LowerCorner(tilebox, lev, 0._rt);
const amrex::Real rmin = xyzmin[0];
const amrex::XDim3 xyzmin = LowerCorner(tilebox, lev, 0._rt);
const amrex::Real rmin = xyzmin.x;

// Skip blocks that don't touch the axis
if (rmin > 0._rt) { continue; }
Expand Down
8 changes: 3 additions & 5 deletions Source/Diagnostics/ReducedDiags/ColliderRelevant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,7 @@ void ColliderRelevant::ComputeDiags (int step)
const int lev = 0;

// define variables in preparation for field gathering
const std::array<amrex::Real,3>& dx = WarpX::CellSize(std::max(lev, 0));
const amrex::GpuArray<amrex::Real, 3> dx_arr = {dx[0], dx[1], dx[2]};
const amrex::XDim3 dinv = WarpX::InvCellSize(std::max(lev, 0));
const amrex::MultiFab & Ex = warpx.getField(FieldType::Efield_aux, lev,0);
const amrex::MultiFab & Ey = warpx.getField(FieldType::Efield_aux, lev,1);
const amrex::MultiFab & Ez = warpx.getField(FieldType::Efield_aux, lev,2);
Expand Down Expand Up @@ -478,8 +477,7 @@ void ColliderRelevant::ComputeDiags (int step)
amrex::Box box = pti.tilebox();
box.grow(ngEB);
const amrex::Dim3 lo = amrex::lbound(box);
const std::array<amrex::Real, 3>& xyzmin = WarpX::LowerCorner(box, lev, 0._rt);
const amrex::GpuArray<amrex::Real, 3> xyzmin_arr = {xyzmin[0], xyzmin[1], xyzmin[2]};
const amrex::XDim3 xyzmin = WarpX::LowerCorner(box, lev, 0._rt);
const amrex::Array4<const amrex::Real> & ex_arr = Ex[pti].array();
const amrex::Array4<const amrex::Real> & ey_arr = Ey[pti].array();
const amrex::Array4<const amrex::Real> & ez_arr = Ez[pti].array();
Expand Down Expand Up @@ -515,7 +513,7 @@ void ColliderRelevant::ComputeDiags (int step)
ex_arr, ey_arr, ez_arr, bx_arr, by_arr, bz_arr,
ex_type, ey_type, ez_type,
bx_type, by_type, bz_type,
dx_arr, xyzmin_arr, lo,
dinv, xyzmin, lo,
n_rz_azimuthal_modes, nox, galerkin_interpolation);
// compute chi
amrex::Real chi = 0.0_rt;
Expand Down
4 changes: 2 additions & 2 deletions Source/Diagnostics/ReducedDiags/FieldEnergy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ FieldEnergy::ComputeNorm2RZ(const amrex::MultiFab& field, const int lev)
amrex::Box tb = convert(tilebox, field.ixType().toIntVect());

// Lower corner of tile box physical domain
const std::array<amrex::Real, 3>& xyzmin = WarpX::LowerCorner(tilebox, lev, 0._rt);
const amrex::XDim3 xyzmin = WarpX::LowerCorner(tilebox, lev, 0._rt);
const Dim3 lo = lbound(tilebox);
const Dim3 hi = ubound(tilebox);
const Real rmin = xyzmin[0] + (tb.ixType().nodeCentered(0) ? 0._rt : 0.5_rt*dr);
const Real rmin = xyzmin.x + (tb.ixType().nodeCentered(0) ? 0._rt : 0.5_rt*dr);
const int irmin = lo.x;
const int irmax = hi.x;

Expand Down
9 changes: 3 additions & 6 deletions Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,8 @@ void FieldProbe::ComputeDiags (int step)

auto * const AMREX_RESTRICT idcpu = pti.GetStructOfArrays().GetIdCPUData().data();

const auto &xyzmin = WarpX::LowerCorner(box, lev, 0._rt);
const std::array<Real, 3> &dx = WarpX::CellSize(lev);

const amrex::GpuArray<amrex::Real, 3> dx_arr = {dx[0], dx[1], dx[2]};
const amrex::GpuArray<amrex::Real, 3> xyzmin_arr = {xyzmin[0], xyzmin[1], xyzmin[2]};
const amrex::XDim3 xyzmin = WarpX::LowerCorner(box, lev, 0._rt);
const amrex::XDim3 dinv = WarpX::InvCellSize(lev);
const Dim3 lo = lbound(box);

// Temporarily defining modes and interp outside ParallelFor to avoid GPU compilation errors.
Expand All @@ -514,7 +511,7 @@ void FieldProbe::ComputeDiags (int step)
doGatherShapeN(xp, yp, zp, Exp, Eyp, Ezp, Bxp, Byp, Bzp,
arrEx, arrEy, arrEz, arrBx, arrBy, arrBz,
Extype, Eytype, Eztype, Bxtype, Bytype, Bztype,
dx_arr, xyzmin_arr, lo, temp_modes,
dinv, xyzmin, lo, temp_modes,
temp_interp_order, false);

//Calculate the Poynting Vector S
Expand Down
Loading

0 comments on commit 41fc45b

Please sign in to comment.