diff options
Diffstat (limited to 'Examples/Tests')
-rwxr-xr-x | Examples/Tests/Langmuir/langmuir2d_analysis.py | 8 | ||||
-rwxr-xr-x | Examples/Tests/Langmuir/langmuir_analysis.py | 32 | ||||
-rwxr-xr-x | Examples/Tests/PML/analysis_pml_ckc.py | 4 | ||||
-rwxr-xr-x | Examples/Tests/PML/analysis_pml_psatd.py | 3 | ||||
-rwxr-xr-x | Examples/Tests/PML/analysis_pml_yee.py | 3 | ||||
-rwxr-xr-x | Examples/Tests/SingleParticle/bilinear_filter_analysis.py | 2 | ||||
-rwxr-xr-x | Examples/Tests/particles_in_PML/analysis.py | 2 | ||||
-rwxr-xr-x | Examples/Tests/photon_pusher/check.py | 5 |
8 files changed, 36 insertions, 23 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 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 diff --git a/Examples/Tests/PML/analysis_pml_ckc.py b/Examples/Tests/PML/analysis_pml_ckc.py index d6bef942f..08019e60b 100755 --- a/Examples/Tests/PML/analysis_pml_ckc.py +++ b/Examples/Tests/PML/analysis_pml_ckc.py @@ -30,8 +30,8 @@ energy_end = energyE + energyB Reflectivity = energy_end/energy_start Reflectivity_theory = 1.8015e-06 -print("Reflectivity", Reflectivity) -print("Reflectivity_theory", Reflectivity_theory) +print("Reflectivity: %s" %Reflectivity) +print("Reflectivity_theory: %s" %Reflectivity_theory) assert( Reflectivity < 105./100 * Reflectivity_theory ) diff --git a/Examples/Tests/PML/analysis_pml_psatd.py b/Examples/Tests/PML/analysis_pml_psatd.py index ba9120c8d..c8c1aea6c 100755 --- a/Examples/Tests/PML/analysis_pml_psatd.py +++ b/Examples/Tests/PML/analysis_pml_psatd.py @@ -30,5 +30,8 @@ energy_end = energyE + energyB Reflectivity = energy_end/energy_start Reflectivity_theory = 1.3806831258153887e-06 +print("Reflectivity: %s" %Reflectivity) +print("Reflectivity_theory: %s" %Reflectivity_theory) + assert( abs(Reflectivity-Reflectivity_theory) < 5./100 * Reflectivity_theory ) diff --git a/Examples/Tests/PML/analysis_pml_yee.py b/Examples/Tests/PML/analysis_pml_yee.py index 0def05450..c0c91329d 100755 --- a/Examples/Tests/PML/analysis_pml_yee.py +++ b/Examples/Tests/PML/analysis_pml_yee.py @@ -30,5 +30,8 @@ energy_end = energyE + energyB Reflectivity = energy_end/energy_start Reflectivity_theory = 5.683000058954201e-07 +print("Reflectivity: %s" %Reflectivity) +print("Reflectivity_theory: %s" %Reflectivity_theory) + assert( abs(Reflectivity-Reflectivity_theory) < 5./100 * Reflectivity_theory ) diff --git a/Examples/Tests/SingleParticle/bilinear_filter_analysis.py b/Examples/Tests/SingleParticle/bilinear_filter_analysis.py index 269a4d329..494434279 100755 --- a/Examples/Tests/SingleParticle/bilinear_filter_analysis.py +++ b/Examples/Tests/SingleParticle/bilinear_filter_analysis.py @@ -42,5 +42,5 @@ F_filtered = all_data_level_0['boxlib', 'jx'].v.squeeze() # Compare theory and PIC for filtered value error = np.sum( np.abs(F_filtered - my_F_filtered) ) / np.sum( np.abs(my_F_filtered) ) -print( "error: %s" %error ) +print( "error: np.sum( np.abs(F_filtered - my_F_filtered) ) / np.sum( np.abs(my_F_filtered) ) = %s" %error ) assert( error < 1.e-14 ) diff --git a/Examples/Tests/particles_in_PML/analysis.py b/Examples/Tests/particles_in_PML/analysis.py index ab5792082..96406d717 100755 --- a/Examples/Tests/particles_in_PML/analysis.py +++ b/Examples/Tests/particles_in_PML/analysis.py @@ -24,7 +24,7 @@ Ex_array = ad0['Ex'].to_ndarray() Ey_array = ad0['Ey'].to_ndarray() Ez_array = ad0['Ez'].to_ndarray() max_Efield = max(Ex_array.max(), Ey_array.max(), Ez_array.max()) -print( max_Efield ) +print( "max_Efield = %s" %max_Efield ) # The field associated with the particle does not have # the same amplitude in 2d and 3d diff --git a/Examples/Tests/photon_pusher/check.py b/Examples/Tests/photon_pusher/check.py index b1f6d916c..3e6873842 100755 --- a/Examples/Tests/photon_pusher/check.py +++ b/Examples/Tests/photon_pusher/check.py @@ -87,6 +87,11 @@ def check(): disc_mom = [np.linalg.norm(a-b)/np.linalg.norm(b) for a,b in zip(res_mom, answ_mom)] + print("max(disc_pos) = %s" %max(disc_pos)) + print("tol_pos = %s" %tol_pos) + print("max(disc_mom) = %s" %max(disc_mom)) + print("tol_mom = %s" %tol_mom) + assert ((max(disc_pos) <= tol_pos) and (max(disc_mom) <= tol_mom)) # This function generates the input file to test the photon pusher. |