aboutsummaryrefslogtreecommitdiff
path: root/Examples/Tests/Langmuir/analysis_langmuir2d.py
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/Tests/Langmuir/analysis_langmuir2d.py')
-rwxr-xr-xExamples/Tests/Langmuir/analysis_langmuir2d.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Examples/Tests/Langmuir/analysis_langmuir2d.py b/Examples/Tests/Langmuir/analysis_langmuir2d.py
index 87e3e5b33..1ffe39e69 100755
--- a/Examples/Tests/Langmuir/analysis_langmuir2d.py
+++ b/Examples/Tests/Langmuir/analysis_langmuir2d.py
@@ -34,9 +34,9 @@ it = int(fn[-5:])
# Machine precision of the simulation
if ds.index._dtype == "float32":
- dfloat = 1.e-4 # single: ok, just a somewhat larger than 1.e-6
+ dfloat = 0.7e-4 # single: ok, just somewhat larger than 1.e-6 (6 digits)
else:
- dfloat = 1.e-14 # double: ok, just a little larger than 1.e-15
+ dfloat = 2.0e-14 # double: ok, just a little larger than 1.e-15 (15 digits)
# Check the Jx field, which oscillates at wp
j_predicted = -n0*e*c*ux*np.cos( wp*t*(it-0.5)/it ) # j at half-timestep
@@ -55,8 +55,11 @@ Ex = data['Ex'].to_ndarray()
print( "relative error: np.max( np.abs( ( Ex[:32,:,0] - E_predicted ) / E_predicted ) ) = %s" \
%np.max( np.abs( ( Ex[:32,:,0] - E_predicted ) / E_predicted ) ) )
assert np.allclose( Ex[:32,:,0], E_predicted, rtol=0.1 )
+# predicted values should be zero here, but floating-point noise from E_predicted areas will sneak in
print( "absolute error: np.max( np.abs( Ex[32:,:,0] ) ) = %s" %np.max( np.abs( Ex[32:,:,0] ) ) )
-assert np.allclose( Ex[32:,:,0], 0, atol=np.abs(E_predicted)*dfloat )
+float_noise_zero = np.max( np.abs( E_predicted * dfloat ) )
+print( "float_noise_zero = %s" % float_noise_zero )
+assert np.allclose( Ex[32:,:,0], 0., atol=float_noise_zero )
# Save an image to be displayed on the website
t_plot = np.linspace(0.0, t, 200)