diff options
author | 2019-11-13 15:16:36 -0800 | |
---|---|---|
committer | 2019-11-13 15:16:36 -0800 | |
commit | dfecd2994e2270bf16d4339ac980457b1caa2c73 (patch) | |
tree | 5228222ab5fd6fc85eaa5cfb66c8f18ee493c186 /Examples/Modules/space_charge_initialization/analysis.py | |
parent | 62e29da6c118ea84c81c7381212ef40826ded614 (diff) | |
download | WarpX-dfecd2994e2270bf16d4339ac980457b1caa2c73.tar.gz WarpX-dfecd2994e2270bf16d4339ac980457b1caa2c73.tar.zst WarpX-dfecd2994e2270bf16d4339ac980457b1caa2c73.zip |
Update analysis script
Diffstat (limited to 'Examples/Modules/space_charge_initialization/analysis.py')
-rwxr-xr-x | Examples/Modules/space_charge_initialization/analysis.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Examples/Modules/space_charge_initialization/analysis.py b/Examples/Modules/space_charge_initialization/analysis.py index 30954c41d..c84962e89 100755 --- a/Examples/Modules/space_charge_initialization/analysis.py +++ b/Examples/Modules/space_charge_initialization/analysis.py @@ -78,8 +78,12 @@ plt.colorbar() plt.savefig('Comparison.png') # Automatically check the results -print( 'Relative error in Ex: %.3f'%(abs(Ex_array-Ex_th).max()/Ex_th.max())) -assert np.allclose( Ex_array, Ex_th, atol=0.15*Ex_th.max() ) -assert np.allclose( Ey_array, Ey_th, atol=0.15*Ey_th.max() ) +def check(E, E_th, label): + print( 'Relative error in %s: %.3f'%( + label, abs(E-E_th).max()/E_th.max())) + assert np.allclose( E, E_th, atol=0.15*E_th.max() ) + +check( Ex_array, Ex_th, 'Ex' ) +check( Ey_array, Ey_th, 'Ey' ) if ds.dimensionality == 3: - assert np.allclose( Ez_array, Ez_th, atol=0.15*Ez_th.max() ) + check( Ez_array, Ez_th, 'Ez' ) |