diff options
author | 2019-09-04 11:19:46 -0700 | |
---|---|---|
committer | 2019-09-04 11:19:46 -0700 | |
commit | ec2e29879d9deb4e4341d5890c806e54ee4a79e8 (patch) | |
tree | 4c890dbe051da04bbae4d150edc58c635424a32c | |
parent | d1c6963e66cfb9769acbed1f013c0a23bab8d81f (diff) | |
download | WarpX-ec2e29879d9deb4e4341d5890c806e54ee4a79e8.tar.gz WarpX-ec2e29879d9deb4e4341d5890c806e54ee4a79e8.tar.zst WarpX-ec2e29879d9deb4e4341d5890c806e54ee4a79e8.zip |
print errors
-rwxr-xr-x | Examples/Tests/Langmuir/langmuir_analysis.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Examples/Tests/Langmuir/langmuir_analysis.py b/Examples/Tests/Langmuir/langmuir_analysis.py index 32ea9dad2..7dd5acd83 100755 --- a/Examples/Tests/Langmuir/langmuir_analysis.py +++ b/Examples/Tests/Langmuir/langmuir_analysis.py @@ -48,14 +48,32 @@ 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 assert np.allclose( E[2:30,:,:], E_predicted, rtol=0.1 ) assert np.allclose( E[34:-2,:,:], 0, atol=1.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 assert np.allclose( E[:,2:30,:], E_predicted, rtol=0.1 ) assert np.allclose( E[:,34:-2,:], 0, atol=1.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 assert np.allclose( E[:,:,2:30], E_predicted, rtol=0.1 ) assert np.allclose( E[:,:,34:-2], 0, atol=1.e-5 ) |