Skip to content

Commit 88412f3

Browse files
authored
Clean up analysis script of test_rz_particle_boundary_interaction_picmi (#5586)
1 parent 961d9a6 commit 88412f3

File tree

1 file changed

+7
-7
lines changed
  • Examples/Tests/particle_boundary_interaction

1 file changed

+7
-7
lines changed

Examples/Tests/particle_boundary_interaction/analysis.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@
2929
z_analytic = -0.20531
3030

3131
print("NUMERICAL coordinates of the point of contact:")
32-
print("x=%5.5f, y=%5.5f, z=%5.5f" % (x[0], y[0], z[0]))
32+
print(f"x={x[0]:5.5f}, y={y[0]:5.5f}, z={z[0]:5.5f}")
3333
print("\n")
3434
print("ANALYTICAL coordinates of the point of contact:")
35-
print("x=%5.5f, y=%5.5f, z=%5.5f" % (x_analytic, y_analytic, z_analytic))
35+
print(f"x={x_analytic:5.5f}, y={y_analytic:5.5f}, z={z_analytic:5.5f}")
3636

3737
tolerance = 1e-5
3838

39-
diff_x = np.abs((x[0] - x_analytic) / x_analytic)
40-
diff_z = np.abs((z[0] - z_analytic) / z_analytic)
39+
rel_err_x = np.abs((x[0] - x_analytic) / x_analytic)
40+
rel_err_z = np.abs((z[0] - z_analytic) / z_analytic)
4141

4242
print("\n")
43-
print("percentage error for x = %5.4f %%" % (diff_x * 100))
44-
print("percentage error for z = %5.4f %%" % (diff_z * 100))
43+
print(f"Relative percentage error for x = {rel_err_x * 100:5.4f} %")
44+
print(f"Relative percentage error for z = {rel_err_z * 100:5.4f} %")
4545

46-
assert (diff_x < tolerance) and (y[0] < 1e-8) and (diff_z < tolerance), (
46+
assert (rel_err_x < tolerance) and (y[0] < 1e-8) and (rel_err_z < tolerance), (
4747
"Test particle_boundary_interaction did not pass"
4848
)

0 commit comments

Comments
 (0)