Skip to content

Commit

Permalink
clean up and adjust tolerances
Browse files Browse the repository at this point in the history
  • Loading branch information
aeriforme committed Jan 14, 2025
1 parent 95aedcf commit a5be100
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
9 changes: 4 additions & 5 deletions Examples/Tests/diff_lumi_diag/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
# Extract the 2D differential luminosity from the file
series = OpenPMDTimeSeries("./diags/reducedfiles/DifferentialLuminosity2d_beam1_beam2/")
d2L_dE1_dE2, info = series.get_field("d2L_dE1_dE2", iteration=80)
E1, E2 = info.E1, info.E2
dE1, dE2 = info.dE1, info.dE2

# Extract test name from path
Expand All @@ -50,14 +49,14 @@

# Pick tolerance
if "leptons" in test_name:
tol1 = 1e-2
tol2 = 1e-5
tol1 = 0.02
tol2 = 0.003
elif "photons" in test_name:
# In the photons case, the particles are
# initialized from a density distribution ;
# tolerance is larger due to lower particle statistics
tol1 = 6e-2
tol2 = 1e-5
tol1 = 0.02
tol2 = 0.003

# Check that the 1D diagnostic and analytical result match
error1 = abs(dL_dE_sim - dL_dE_th).max() / abs(dL_dE_th).max()
Expand Down
8 changes: 2 additions & 6 deletions Source/Diagnostics/ReducedDiags/DifferentialLuminosity2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ void DifferentialLuminosity2D::WriteToFile (int step) const
io::Access::CREATE);
auto i = series.iterations[step + 1];
// record
auto f_mesh = i.meshes["d2L_dE1_dE2"];
auto f_mesh = i.meshes["d2L_dE1_dE2"]; // m^-2 eV^-2
f_mesh.setUnitDimension({
{io::UnitDimension::L, -6},
{io::UnitDimension::M, -2},
Expand All @@ -368,15 +368,11 @@ void DifferentialLuminosity2D::WriteToFile (int step) const
auto data = f_mesh[io::RecordComponent::SCALAR];

// meta data
f_mesh.setAxisLabels({"E2", "E1"}); // ordinate, abscissa
f_mesh.setAxisLabels({"E2", "E1"}); // eV, eV
std::vector< double > const& gridGlobalOffset = {m_bin_min_2, m_bin_min_1};
f_mesh.setGridGlobalOffset(gridGlobalOffset);
f_mesh.setGridSpacing<amrex::Real>({m_bin_size_2, m_bin_size_1});

// to save the data in SI add the following:
// f_mesh.setGridUnitSI(PhysConst::q_e);
// data.setUnitSI(std::pow(PhysConst::q_e, -2));

data.setPosition<amrex::Real>({0.5, 0.5});

auto dataset = io::Dataset(
Expand Down

0 comments on commit a5be100

Please sign in to comment.