aboutsummaryrefslogtreecommitdiff
path: root/Examples/Tests/Langmuir/langmuir_analysis.py
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/Tests/Langmuir/langmuir_analysis.py')
-rwxr-xr-xExamples/Tests/Langmuir/langmuir_analysis.py32
1 files changed, 13 insertions, 19 deletions
diff --git a/Examples/Tests/Langmuir/langmuir_analysis.py b/Examples/Tests/Langmuir/langmuir_analysis.py
index 578ecc8b7..2ffb7f56b 100755
--- a/Examples/Tests/Langmuir/langmuir_analysis.py
+++ b/Examples/Tests/Langmuir/langmuir_analysis.py
@@ -48,33 +48,27 @@ E_predicted = m_e * wp * u * c / e * np.sin(wp*t)
# at the edges of the plasma
if direction == 'x':
E = data[ 'Ex' ].to_ndarray()
- # compute and print errors
- max_rel_error_nonzero = np.max(np.abs((E[2:30,:,:]-E_predicted)/E_predicted))
- max_rel_error_zero = np.max(E[34:-2,:,:])
- print('relative error: %s' %max_rel_error_nonzero)
- print('absolute field error (where field should be 0): %s' %max_rel_error_zero)
- # assert small errors
+ # Print errors, and assert small error
+ print( "relative error: np.max( np.abs( ( E[2:30,:,:] - E_predicted ) / E_predicted ) ) = %s" \
+ %np.max( np.abs( ( E[2:30,:,:] - E_predicted ) / E_predicted ) ) )
assert np.allclose( E[2:30,:,:], E_predicted, rtol=0.1 )
- assert np.allclose( E[34:-2,:,:], 0, atol=2.e-5 )
+ print( "absolute error: np.max( np.abs( E[34:-2,:,:] ) ) = %s" %np.max( np.abs( E[34:-2,:,:] ) ) )
+ assert np.allclose( E[34:-2,:,:], 0, atol=5.e-5 )
elif direction == 'y':
E = data[ 'Ey' ].to_ndarray()
- # compute and print errors
- max_rel_error_nonzero = np.max(np.abs((E[:,2:30,:]-E_predicted)/E_predicted))
- max_rel_error_zero = np.max(E[:,34:-2,:])
- print('relative error: %s' %max_rel_error_nonzero)
- print('absolute field error (where field should be 0): %s' %max_rel_error_zero)
- # assert small errors
+ # Print errors, and assert small error
+ print( "relative error: np.max( np.abs( ( E[:,2:30,:] - E_predicted ) / E_predicted ) ) = %s" \
+ %np.max( np.abs( ( E[:,2:30,:] - E_predicted ) / E_predicted ) ) )
assert np.allclose( E[:,2:30,:], E_predicted, rtol=0.1 )
+ print( "absolute error: np.max( np.abs( E[:,34:-2,:] ) ) = %s" %np.max( np.abs( E[:,34:-2,:] ) ) )
assert np.allclose( E[:,34:-2,:], 0, atol=2.e-5 )
elif direction == 'z':
E = data[ 'Ez' ].to_ndarray()
- # compute and print errors
- max_rel_error_nonzero = np.max(np.abs((E[:,:,2:30]-E_predicted)/E_predicted))
- max_rel_error_zero = np.max(E[:,:,34:-2])
- print('relative error: %s' %max_rel_error_nonzero)
- print('absolute field error (where field should be 0): %s' %max_rel_error_zero)
- # assert small errors
+ # Print errors, and assert small error
+ print( "relative error: np.max( np.abs( ( E[:,:,2:30] - E_predicted ) / E_predicted ) ) = %s" \
+ %np.max( np.abs( ( E[:,:,2:30] - E_predicted ) / E_predicted ) ) )
assert np.allclose( E[:,:,2:30], E_predicted, rtol=0.1 )
+ print( "absolute error: np.max( np.abs( E[:,:,34:-2] ) ) = %s" %np.max( np.abs( E[:,:,34:-2] ) ) )
assert np.allclose( E[:,:,34:-2], 0, atol=2.e-5 )
# Save an image to be displayed on the website