aboutsummaryrefslogtreecommitdiff
path: root/Examples
diff options
context:
space:
mode:
Diffstat (limited to 'Examples')
-rwxr-xr-xExamples/Modules/nci_corrector/ncicorr_analysis.py8
-rwxr-xr-xExamples/Physics_applications/laser_acceleration/inputs.rz87
-rwxr-xr-xExamples/Tests/Langmuir/langmuir2d_analysis.py8
-rwxr-xr-xExamples/Tests/Langmuir/langmuir_analysis.py32
-rwxr-xr-xExamples/Tests/PML/analysis_pml_ckc.py4
-rwxr-xr-xExamples/Tests/PML/analysis_pml_psatd.py3
-rwxr-xr-xExamples/Tests/PML/analysis_pml_yee.py3
-rwxr-xr-xExamples/Tests/SingleParticle/bilinear_filter_analysis.py2
-rwxr-xr-xExamples/Tests/particles_in_PML/analysis.py2
-rwxr-xr-xExamples/Tests/photon_pusher/check.py5
10 files changed, 127 insertions, 27 deletions
diff --git a/Examples/Modules/nci_corrector/ncicorr_analysis.py b/Examples/Modules/nci_corrector/ncicorr_analysis.py
index b9e46628d..5b7da2447 100755
--- a/Examples/Modules/nci_corrector/ncicorr_analysis.py
+++ b/Examples/Modules/nci_corrector/ncicorr_analysis.py
@@ -14,8 +14,8 @@ ex = np.reshape(ad['boxlib', 'Ex'].v,(128,128))
ez = np.reshape(ad['boxlib', 'Ez'].v,(128,128))
by = np.reshape(ad['boxlib', 'By'].v,(128,128))
energy = np.sum(ex**2 + ez**2 + scc.c**2*by**2)*1.e-12
-assert( energy < 7. )
-# Energy should be:
-# FILTER OFF: ~15000.
-# FILTER ON : ~6.
+print("energy: %s" %energy)
+print("Should be ~1.e0 if filter ON, ~1.e5 if filter OFF.")
+
+assert( energy < 7. )
diff --git a/Examples/Physics_applications/laser_acceleration/inputs.rz b/Examples/Physics_applications/laser_acceleration/inputs.rz
new file mode 100755
index 000000000..83071834e
--- /dev/null
+++ b/Examples/Physics_applications/laser_acceleration/inputs.rz
@@ -0,0 +1,87 @@
+#################################
+####### GENERAL PARAMETERS ######
+#################################
+max_step = 1000
+amr.n_cell = 64 512
+amr.max_grid_size = 64 # maximum size of each AMReX box, used to decompose the domain
+amr.blocking_factor = 32 # minimum size of each AMReX box, used to decompose the domain
+amr.plot_int = 200
+geometry.coord_sys = 1 # 0: Cartesian
+geometry.is_periodic = 0 0 # Is periodic?
+geometry.prob_lo = 0. -56.e-6 # physical domain
+geometry.prob_hi = 30.e-6 12.e-6
+amr.max_level = 0 # Maximum level in hierarchy (1 might be unstable, >1 is not supported)
+
+warpx.n_rz_azimuthal_modes = 2
+
+#################################
+############ NUMERICS ###########
+#################################
+interpolation.nox = 3 # Particle interpolation order. Must be the same in x, y, and z
+interpolation.noy = 3
+interpolation.noz = 3
+warpx.verbose = 1
+warpx.do_dive_cleaning = 0
+warpx.plot_raw_fields = 1
+warpx.plot_raw_fields_guards = 1
+warpx.use_filter = 1
+warpx.cfl = 1. # if 1., the time step is set to its CFL limit
+warpx.do_pml = 0 # use Perfectly Matched Layer as boundary condition
+warpx.do_moving_window = 1
+warpx.moving_window_dir = z # Only z is supported for the moment
+warpx.moving_window_v = 1.0 # units of speed of light
+
+#################################
+############ PLASMA #############
+#################################
+particles.nspecies = 2 # number of species
+particles.species_names = electrons beam
+
+electrons.charge = -q_e
+electrons.mass = m_e
+electrons.injection_style = "NUniformPerCell"
+electrons.num_particles_per_cell_each_dim = 1 1 1
+electrons.xmin = -20.e-6
+electrons.xmax = 20.e-6
+electrons.zmin = 10.e-6
+electrons.profile = constant
+electrons.density = 2.e23 # number of electrons per m^3
+electrons.momentum_distribution_type = "constant"
+electrons.do_continuous_injection = 1
+
+beam.charge = -q_e
+beam.mass = m_e
+beam.injection_style = "gaussian_beam"
+beam.x_rms = .5e-6
+beam.y_rms = .5e-6
+beam.z_rms = .5e-6
+beam.x_m = 0.
+beam.y_m = 0.
+beam.z_m = -28.e-6
+beam.npart = 100
+beam.q_tot = -1.e-12
+beam.profile = "constant"
+beam.density = 8.e23 # not used in case of a gaussian beam
+beam.momentum_distribution_type = "gaussian"
+beam.ux_m = 0.0
+beam.uy_m = 0.0
+beam.uz_m = 500.
+beam.ux_th = 2.
+beam.uy_th = 2.
+beam.uz_th = 50.
+
+#################################
+############ PLASMA #############
+#################################
+lasers.nlasers = 1
+lasers.names = laser1
+laser1.profile = Gaussian
+laser1.position = 0. 0. 9.e-6 # This point is on the laser plane
+laser1.direction = 0. 0. 1. # The plane normal direction
+laser1.polarization = 0. 1. 0. # The main polarization vector
+laser1.e_max = 16.e12 # Maximum amplitude of the laser field (in V/m)
+laser1.profile_waist = 5.e-6 # The waist of the laser (in m)
+laser1.profile_duration = 15.e-15 # The duration of the laser (in s)
+laser1.profile_t_peak = 30.e-15 # Time at which the laser reaches its peak (in s)
+laser1.profile_focal_distance = 100.e-6 # Focal distance from the antenna (in m)
+laser1.wavelength = 0.8e-6 # The wavelength of the laser (in m)
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.