Skip to content

Commit

Permalink
Add Checksums for RigidInjection_BTD (BTD data)
Browse files Browse the repository at this point in the history
  • Loading branch information
EZoni committed Aug 24, 2022
1 parent 988541d commit 43ba4de
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,21 @@
frame, i.e., on the back-transformed diagnostics.
'''

import os
import sys

import numpy as np
import openpmd_api as io
import read_raw_data
import yt

yt.funcs.mylog.setLevel(0)

sys.path.insert(1, '../../../../warpx/Regression/Checksum/')
import checksumAPI

filename = sys.argv[1]

# Read data from legacy back-transformed diagnostics
snapshot = './lab_frame_data/snapshots/snapshot00001'
header = './lab_frame_data/snapshots/Header'
Expand All @@ -37,14 +45,14 @@
x_btd_legacy_std = np.std(x_btd_legacy)

# Read data from new back-transformed diagnostics (plotfile)
ds_plotfile = yt.load('./diags/btd_pltfile000001')
ds_plotfile = yt.load(filename)
z_btd_plotfile = ds_plotfile.all_data()['beam', 'particle_position_y'].v
x_btd_plotfile = ds_plotfile.all_data()['beam', 'particle_position_x'].v
z_btd_plotfile_mean = np.mean(z_btd_plotfile)
x_btd_plotfile_std = np.std(x_btd_plotfile)

# Read data from new back-transformed diagnostics (openPMD)
series = io.Series("./diags/btd_openpmd/openpmd_%T.h5", io.Access.read_only)
series = io.Series("./diags/diag2/openpmd_%T.h5", io.Access.read_only)
ds_openpmd = series.iterations[1]
z_btd_openpmd = ds_openpmd.particles['beam']['position']['z'][:]
x_btd_openpmd = ds_openpmd.particles['beam']['position']['x'][:]
Expand Down Expand Up @@ -80,3 +88,6 @@
print("tolerance_rel: " + str(tolerance_rel))

assert( error_rel < tolerance_rel )

test_name = os.path.split(os.getcwd())[1]
checksumAPI.evaluate_checksum(test_name, filename)
36 changes: 17 additions & 19 deletions Examples/Modules/RigidInjection/inputs_2d_BoostedFrame
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,25 @@ beam.zinject_plane = 20.e-6
beam.rigid_advance = true

# Diagnostics
diagnostics.diags_names = diag1 btd_pltfile btd_openpmd
diag1.intervals = 10000
diag1.diag_type = Full
diagnostics.diags_names = diag1 diag2

btd_openpmd.diag_type = BackTransformed
btd_openpmd.do_back_transformed_fields = 1
btd_openpmd.num_snapshots_lab = 2
btd_openpmd.dt_snapshots_lab = 1.8679589331096515e-13
btd_openpmd.fields_to_plot = Ex Ey Ez Bx By Bz jx jy jz rho
btd_openpmd.format = openpmd
btd_openpmd.openpmd_backend = h5
btd_openpmd.buffer_size = 32
diag1.diag_type = BackTransformed
diag1.do_back_transformed_fields = 1
diag1.num_snapshots_lab = 2
diag1.dt_snapshots_lab = 1.8679589331096515e-13
diag1.fields_to_plot = Ex Ey Ez Bx By Bz jx jy jz rho
diag1.format = plotfile
diag1.buffer_size = 32
diag1.write_species = 1

btd_pltfile.diag_type = BackTransformed
btd_pltfile.do_back_transformed_fields = 1
btd_pltfile.num_snapshots_lab = 2
btd_pltfile.dt_snapshots_lab = 1.8679589331096515e-13
btd_pltfile.fields_to_plot = Ex Ey Ez Bx By Bz jx jy jz rho
btd_pltfile.format = plotfile
btd_pltfile.buffer_size = 32
btd_pltfile.write_species = 1
diag2.diag_type = BackTransformed
diag2.do_back_transformed_fields = 1
diag2.num_snapshots_lab = 2
diag2.dt_snapshots_lab = 1.8679589331096515e-13
diag2.fields_to_plot = Ex Ey Ez Bx By Bz jx jy jz rho
diag2.format = openpmd
diag2.openpmd_backend = h5
diag2.buffer_size = 32

# old BTD diagnostics
warpx.do_back_transformed_diagnostics = 1
Expand Down
22 changes: 22 additions & 0 deletions Regression/Checksum/benchmarks_json/RigidInjection_BTD.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"beam": {
"particle_momentum_x": 242389779182460.88,
"particle_momentum_y": 240094258116272.8,
"particle_momentum_z": 2997924579999642.0,
"particle_position_x": 0.0260823588888081,
"particle_position_y": 0.5049438607316916,
"particle_weight": 62415.090744607645
},
"lev=0": {
"Bx": 3.721807007218884e-05,
"By": 0.004860056238272468,
"Bz": 5.5335765596325185e-06,
"Ex": 1466447.517373168,
"Ey": 11214.10223280318,
"Ez": 283216.0961218869,
"jx": 16437877.898892513,
"jy": 2492340.31499804,
"jz": 215102423.57036877,
"rho": 0.7246235591902177
}
}

0 comments on commit 43ba4de

Please sign in to comment.