aboutsummaryrefslogtreecommitdiff
path: root/Examples/Tests/Langmuir/langmuir2d_analysis.py
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/Tests/Langmuir/langmuir2d_analysis.py')
-rwxr-xr-xExamples/Tests/Langmuir/langmuir2d_analysis.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Examples/Tests/Langmuir/langmuir2d_analysis.py b/Examples/Tests/Langmuir/langmuir2d_analysis.py
index 40125d6f5..016eabbce 100755
--- a/Examples/Tests/Langmuir/langmuir2d_analysis.py
+++ b/Examples/Tests/Langmuir/langmuir2d_analysis.py
@@ -25,13 +25,21 @@ data = ds.covering_grid( 0, ds.domain_left_edge, ds.domain_dimensions )
# Check the Jx field, which oscillates at wp
j_predicted = -n0*e*c*ux*np.cos( wp*t*39.5/40 ) # 40 timesteps / j at half-timestep
jx = data['jx'].to_ndarray()
+# Print errors, and assert small error
+print( "relative error: np.max( np.abs( ( jx[:32,:,0] - j_predicted ) / j_predicted ) ) = %s" \
+ %np.max( np.abs( ( jx[:32,:,0] - j_predicted ) / j_predicted ) ) )
assert np.allclose( jx[:32,:,0], j_predicted, rtol=0.1 )
+print( "absolute error: np.max( np.abs( jx[32:,:,0] ) ) = %s" %np.max( np.abs( jx[:32,:,0] ) ) )
assert np.allclose( jx[32:,:,0], 0, atol=1.e-2 )
# Check the Ex field, which oscillates at wp
E_predicted = m_e * wp * ux * c / e * np.sin(wp*t)
Ex = data['Ex'].to_ndarray()
+# Print errors, and assert small error
+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 )
+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=1.e-4 )
# Save an image to be displayed on the website