aboutsummaryrefslogtreecommitdiff
path: root/Examples/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/Modules')
-rwxr-xr-xExamples/Modules/RigidInjection/analysis_rigid_injection_BoostedFrame.py10
-rwxr-xr-xExamples/Modules/RigidInjection/analysis_rigid_injection_LabFrame.py11
-rwxr-xr-xExamples/Modules/boosted_diags/analysis_3Dbacktransformed_diag.py10
-rwxr-xr-xExamples/Modules/ionization/analysis_ionization.py8
-rwxr-xr-xExamples/Modules/qed/breit_wheeler/analysis_2d_tau_init.py15
-rwxr-xr-xExamples/Modules/qed/breit_wheeler/analysis_3d_optical_depth_evolution.py1
-rwxr-xr-xExamples/Modules/qed/quantum_synchrotron/analysis_2d_tau_init.py22
-rwxr-xr-xExamples/Modules/space_charge_initialization/analysis.py4
8 files changed, 60 insertions, 21 deletions
diff --git a/Examples/Modules/RigidInjection/analysis_rigid_injection_BoostedFrame.py b/Examples/Modules/RigidInjection/analysis_rigid_injection_BoostedFrame.py
index 61bb28d43..9e97f28ff 100755
--- a/Examples/Modules/RigidInjection/analysis_rigid_injection_BoostedFrame.py
+++ b/Examples/Modules/RigidInjection/analysis_rigid_injection_BoostedFrame.py
@@ -39,10 +39,14 @@ theta0 = np.arcsin(0.1)
# Theoretical beam width after propagation if rigid ON
wth = np.sqrt( w0**2 + (z-z0)**2*theta0**2 )
-error = np.abs((w-wth)/wth)
+error_rel = np.abs((w-wth)/wth)
+tolerance_rel = 0.03
# Print error and assert small error
print("Beam position: " + str(z))
print("Beam width : " + str(w))
-print("error: " + str(error))
-assert( error < 0.03 )
+
+print("error_rel : " + str(error_rel))
+print("tolerance_rel: " + str(tolerance_rel))
+
+assert( error_rel < tolerance_rel )
diff --git a/Examples/Modules/RigidInjection/analysis_rigid_injection_LabFrame.py b/Examples/Modules/RigidInjection/analysis_rigid_injection_LabFrame.py
index 6977f6ff6..380212adb 100755
--- a/Examples/Modules/RigidInjection/analysis_rigid_injection_LabFrame.py
+++ b/Examples/Modules/RigidInjection/analysis_rigid_injection_LabFrame.py
@@ -68,9 +68,14 @@ if ( error_no_rigid < 0.05):
# Theoretical beam width after propagation if rigid ON
wth = np.sqrt( w0**2 + (z-z0)**2*theta0**2 )
-error = np.abs((w-wth)/wth)
+error_rel = np.abs((w-wth)/wth)
+tolerance_rel = 0.05
+
# Print error and assert small error
print("Beam position: " + str(z))
print("Beam width : " + str(w))
-print("error: " + str(error))
-assert( error < 0.05 )
+
+print("error_rel : " + str(error_rel))
+print("tolerance_rel: " + str(tolerance_rel))
+
+assert( error_rel < tolerance_rel )
diff --git a/Examples/Modules/boosted_diags/analysis_3Dbacktransformed_diag.py b/Examples/Modules/boosted_diags/analysis_3Dbacktransformed_diag.py
index 262354fe6..eac8e4ae9 100755
--- a/Examples/Modules/boosted_diags/analysis_3Dbacktransformed_diag.py
+++ b/Examples/Modules/boosted_diags/analysis_3Dbacktransformed_diag.py
@@ -36,8 +36,10 @@ Fs = allrd['Ez']
print("Fs.shape", Fs.shape)
Fs_1D = np.squeeze(Fs[Fs.shape[0]//2,1,:])
-error = np.max(np.abs(Fs_1D - F_1D)) / np.max(np.abs(F_1D))
+error_rel = np.max(np.abs(Fs_1D - F_1D)) / np.max(np.abs(F_1D))
+tolerance_rel = 1E-15
-# Print error and assert small error
-print("relative error: " + str(error))
-assert( error < 1E-15 )
+print("error_rel : " + str(error_rel))
+print("tolerance_rel: " + str(tolerance_rel))
+
+assert( error_rel < tolerance_rel )
diff --git a/Examples/Modules/ionization/analysis_ionization.py b/Examples/Modules/ionization/analysis_ionization.py
index 6d8bda1e0..80d49f3d5 100755
--- a/Examples/Modules/ionization/analysis_ionization.py
+++ b/Examples/Modules/ionization/analysis_ionization.py
@@ -80,4 +80,10 @@ if do_plot:
plt.ylabel("x (m)")
plt.savefig("image_ionization.pdf", bbox_inches='tight')
-assert ((N5_fraction > 0.30) and (N5_fraction < 0.34))
+error_rel = abs(N5_fraction-0.32) / 0.32
+tolerance_rel = 0.07
+
+print("error_rel : " + str(error_rel))
+print("tolerance_rel: " + str(tolerance_rel))
+
+assert( error_rel < tolerance_rel )
diff --git a/Examples/Modules/qed/breit_wheeler/analysis_2d_tau_init.py b/Examples/Modules/qed/breit_wheeler/analysis_2d_tau_init.py
index b5e470e61..2dc0577c2 100755
--- a/Examples/Modules/qed/breit_wheeler/analysis_2d_tau_init.py
+++ b/Examples/Modules/qed/breit_wheeler/analysis_2d_tau_init.py
@@ -15,7 +15,7 @@ import sys
# do actually have an exponentially distributed optical depth
# Tolerance
-tol = 1e-2
+tolerance_rel = 1e-2
def check():
filename = sys.argv[1]
@@ -27,12 +27,19 @@ def check():
loc, scale = st.expon.fit(res_tau)
# loc should be very close to 0, scale should be very close to 1
- assert(np.abs(loc - 0) < tol)
- assert(np.abs(scale - 1) < tol)
+
+ error_rel = np.abs(loc - 0)
+ print("error_rel for location: " + str(error_rel))
+ print("tolerance_rel: " + str(tolerance_rel))
+ assert( error_rel < tolerance_rel )
+
+ error_rel = np.abs(scale - 1)
+ print("error_rel for scale: " + str(error_rel))
+ print("tolerance_rel: " + str(tolerance_rel))
+ assert( error_rel < tolerance_rel )
def main():
check()
if __name__ == "__main__":
main()
-
diff --git a/Examples/Modules/qed/breit_wheeler/analysis_3d_optical_depth_evolution.py b/Examples/Modules/qed/breit_wheeler/analysis_3d_optical_depth_evolution.py
index b11e4786d..542aa5ce0 100755
--- a/Examples/Modules/qed/breit_wheeler/analysis_3d_optical_depth_evolution.py
+++ b/Examples/Modules/qed/breit_wheeler/analysis_3d_optical_depth_evolution.py
@@ -111,6 +111,7 @@ def check():
exp_scale = 1.0
loc_discrepancy = np.abs(opt_depth_loc-exp_loc)
scale_discrepancy = np.abs(opt_depth_scale-exp_scale)
+ print("tolerance_rel: " + str(tol))
print("species " + name)
print("exp distrib loc tol = " + str(tol))
print("exp distrib loc discrepancy = " + str(loc_discrepancy))
diff --git a/Examples/Modules/qed/quantum_synchrotron/analysis_2d_tau_init.py b/Examples/Modules/qed/quantum_synchrotron/analysis_2d_tau_init.py
index bdbcf78f3..9ad2b754c 100755
--- a/Examples/Modules/qed/quantum_synchrotron/analysis_2d_tau_init.py
+++ b/Examples/Modules/qed/quantum_synchrotron/analysis_2d_tau_init.py
@@ -16,7 +16,8 @@ import sys
# do actually have an exponentially distributed optical depth
# Tolerance
-tol = 1e-2
+tolerance_rel = 1e-2
+print("tolerance_rel: " + str(tolerance_rel))
def check():
filename = sys.argv[1]
@@ -30,10 +31,21 @@ def check():
loc_pos, scale_pos = st.expon.fit(res_pos_tau)
# loc should be very close to 0, scale should be very close to 1
- assert(np.abs(loc_ele - 0) < tol)
- assert(np.abs(loc_pos - 0) < tol)
- assert(np.abs(scale_ele - 1) < tol)
- assert(np.abs(scale_pos - 1) < tol)
+ error_rel = np.abs(loc_ele - 0)
+ print("error_rel loc_ele: " + str(error_rel))
+ assert( error_rel < tolerance_rel )
+
+ error_rel = np.abs(loc_pos - 0)
+ print("error_rel loc_pos: " + str(error_rel))
+ assert( error_rel < tolerance_rel )
+
+ error_rel = np.abs(scale_ele - 1)
+ print("error_rel scale_ele: " + str(error_rel))
+ assert( error_rel < tolerance_rel )
+
+ error_rel = np.abs(scale_pos - 1)
+ print("error_rel scale_pos: " + str(error_rel))
+ assert( error_rel < tolerance_rel )
def main():
check()
diff --git a/Examples/Modules/space_charge_initialization/analysis.py b/Examples/Modules/space_charge_initialization/analysis.py
index 675a8e5b5..1c90aa0dc 100755
--- a/Examples/Modules/space_charge_initialization/analysis.py
+++ b/Examples/Modules/space_charge_initialization/analysis.py
@@ -90,7 +90,9 @@ plt.savefig('Comparison.png')
def check(E, E_th, label):
print( 'Relative error in %s: %.3f'%(
label, abs(E-E_th).max()/E_th.max()))
- assert np.allclose( E, E_th, atol=0.1*E_th.max() )
+ tolerance_rel = 0.1
+ print("tolerance_rel: " + str(tolerance_rel))
+ assert np.allclose( E, E_th, atol=tolerance_rel*E_th.max() )
check( Ex_array, Ex_th, 'Ex' )
check( Ey_array, Ey_th, 'Ey' )