diff options
author | 2020-02-03 10:34:20 -0600 | |
---|---|---|
committer | 2020-02-10 23:17:17 -0800 | |
commit | 2cd83ca6d869527cb670e52aa65da99f5e3ad58a (patch) | |
tree | 41d1d9696711617fd082e9702be928c6cd2461cf /Examples/Tests/Langmuir/analysis_langmuir2d.py | |
parent | 4f1557d3ba9f6f56f47dbd57b0d050ab43ce8685 (diff) | |
download | WarpX-2cd83ca6d869527cb670e52aa65da99f5e3ad58a.tar.gz WarpX-2cd83ca6d869527cb670e52aa65da99f5e3ad58a.tar.zst WarpX-2cd83ca6d869527cb670e52aa65da99f5e3ad58a.zip |
Langmuir Analysis: absolute dfloat to 0
Diffstat (limited to 'Examples/Tests/Langmuir/analysis_langmuir2d.py')
-rwxr-xr-x | Examples/Tests/Langmuir/analysis_langmuir2d.py | 9 |
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) |