aboutsummaryrefslogtreecommitdiff
path: root/Examples
diff options
context:
space:
mode:
Diffstat (limited to 'Examples')
-rwxr-xr-xExamples/Tests/FieldProbe/analysis_field_probe.py57
-rw-r--r--Examples/Tests/FieldProbe/inputs_2d83
-rw-r--r--Examples/Tests/reduced_diags/inputs29
3 files changed, 167 insertions, 2 deletions
diff --git a/Examples/Tests/FieldProbe/analysis_field_probe.py b/Examples/Tests/FieldProbe/analysis_field_probe.py
new file mode 100755
index 000000000..7d7eaa0eb
--- /dev/null
+++ b/Examples/Tests/FieldProbe/analysis_field_probe.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python3
+#
+# Copyright 2021-2022 Tiberius Rheaume
+#
+# This file is part of WarpX.
+#
+# License: BSD-3-Clause-LBNL
+
+"""
+This script tests the accuracy of the FieldProbe diagnostic by observing a plane
+wave undergoing single slit diffraction. The input file inputs_2d is used. This
+file defines the simulation box, laser pulse, embeded boundary with single slit,
+and line of detector points. The plane wave initializes near the negative Z end
+of the simulation box. The wave interacts with the embeded boundary at Z=0. The
+wave undergoes diffraction at the slit. The electromagnetic flux is calculated
+at the line detector which is placed perpendicular to Z beyond the slit. This
+test will check if the detected EM flux matches expected values,
+which can be solved analytically.
+"""
+import numpy as np
+import pandas as pd
+
+filename = "diags/reducedfiles/FP_line.txt"
+
+# Open data file
+df = pd.read_csv(filename, sep=' ')
+df = df.sort_values(by=['[2]part_x_lev0-(m)'])
+
+# Select position and Intensity of timestep 500
+x = df.query('`[0]step()` == 500')['[2]part_x_lev0-(m)']
+S = df.query('`[0]step()` == 500')['[11]part_S_lev0-(W*s/m^2)']
+xvals = x.to_numpy()
+svals = S.to_numpy()
+
+# Default intensity is highest measured value for plane
+# wave interacting with single slit
+I_0 = np.max(S)
+def I_envelope (x, lam = 0.2e-6, a = 0.3e-6, D = 1.7e-6):
+ arg = np.pi * a / lam * np.sin(np.arctan(x / D))
+ return np.sinc( arg / np.pi )**2
+
+# Count non-outlyer values away from simulation boundaries
+counter = np.arange(60, 140, 2)
+
+# Count average error from expected values
+error = 0
+for a in counter:
+ b = I_0 * I_envelope(xvals[a])
+ c = svals[a]
+ error += abs((c-b)/b) * 100.0
+averror = error / (len(counter) - 1)
+
+# average error range set at 2.5%
+if averror > 2.5:
+ print('Average error greater than 2.5%')
+
+assert averror < 2.5
diff --git a/Examples/Tests/FieldProbe/inputs_2d b/Examples/Tests/FieldProbe/inputs_2d
new file mode 100644
index 000000000..92189d278
--- /dev/null
+++ b/Examples/Tests/FieldProbe/inputs_2d
@@ -0,0 +1,83 @@
+#################################
+# Domain, Resolution & Numerics
+#
+
+# time-scale
+stop_time = 0.016e-12 # [s]
+
+# Coarse resolution with cell size = lambda/16 allows for quick CI tests
+amr.n_cell = 320 192
+
+# simulation box, no MR
+# note: increase z (space & cells) for converging ion energy
+amr.max_level = 0
+geometry.dims = 2
+geometry.prob_lo = -2e-6 -.4e-6 # [m]
+geometry.prob_hi = 2e-6 2e-6
+
+# Boundary condition
+boundary.field_lo = absorbing_silver_mueller absorbing_silver_mueller
+boundary.field_hi = absorbing_silver_mueller absorbing_silver_mueller
+
+# Order of particle shape factors
+algo.particle_shape = 1
+
+# numerical tuning
+warpx.cfl = 0.999
+warpx.use_filter = 1 # bilinear current/charge filter
+
+# field solver yee (default) ckc psatd (fft)
+algo.maxwell_solver = yee
+
+##################################
+## Embedded Boundary
+
+my_constants.sheetRadius = 6.25e-9 # [m] 1/2 cell
+my_constants.slitWidth = 0.3e-6 # [m] width of slit = lambda * 2
+warpx.eb_implicit_function = "(
+ if(abs(z)<=sheetRadius and abs(x)>=(slitWidth/2.0), 1.0, -1.0) )"
+
+#################################
+## Laser Pulse Profile
+#
+# Note: we make the beam really wide so it behaves like a plane wave
+##
+lasers.names = laser1
+laser1.position = 0. 0. -.35e-6 # point the laser plane (antenna)
+laser1.direction = 0. 0. 1. # the plane's (antenna's) normal direction
+laser1.polarization = 1. 0. 0. # the main polarization vector
+laser1.a0 = 0.001 # maximum amplitude of the laser field [V/m]
+laser1.wavelength = .2e-6 # central wavelength of the laser pulse [m]
+laser1.profile = Gaussian
+laser1.profile_waist = 2.2e-5 # beam waist (E(w_0)=E_0/e) [m]
+laser1.profile_duration = 5.e-15 # pulse length (E(tau)=E_0/e; tau=tau_E=FWHM_I/1.17741) [s]
+laser1.profile_t_peak = 5.e-15 # time until peak intensity reached at the laser plane [s]
+laser1.profile_focal_distance = .35e-6 # focal distance from the antenna [m]
+
+#################################
+## Diagnostics
+##
+diagnostics.diags_names = diag1
+diag1.intervals = 100
+diag1.diag_type = Full
+#diag1.format = openpmd
+diag1.fields_to_plot = Ex Ey Ez Bx By Bz
+
+#################################
+## Reduced Diagnostics
+##
+#
+warpx.reduced_diags_names = FP_line
+FP_line.type = FieldProbe
+FP_line.intervals = 100
+FP_line.integrate = 1
+FP_line.probe_geometry = Line
+FP_line.x_probe = -1.5e-6
+FP_line.y_probe = 0.
+FP_line.z_probe = 1.7e-6
+FP_line.x1_probe = 1.5e-6
+FP_line.y1_probe = 0.
+FP_line.z1_probe = 1.7e-6
+FP_line.resolution = 201
+
+authors = "Tiberius Rheaume <tiberiusrheaume@lbl.gov>, Axel Huebl <axelhuebl@lbl.gov>"
diff --git a/Examples/Tests/reduced_diags/inputs b/Examples/Tests/reduced_diags/inputs
index 293115f1e..9b8e45d3e 100644
--- a/Examples/Tests/reduced_diags/inputs
+++ b/Examples/Tests/reduced_diags/inputs
@@ -68,7 +68,7 @@ photons.uz_th = 0.2
#################################
###### REDUCED DIAGS ############
#################################
-warpx.reduced_diags_names = EP NP EF PP PF MF FP FP_integrate MR FR_Max FR_Min FR_Integral
+warpx.reduced_diags_names = EP NP EF PP PF MF MR FP FP_integrate FP_line FP_plane FR_Max FR_Min FR_Integral
EP.type = ParticleEnergy
EP.intervals = 200
EF.type = FieldEnergy
@@ -86,11 +86,36 @@ FP.x_probe = 0.53125
FP.y_probe = 0.53125
FP.z_probe = 0.53125
FP_integrate.type = FieldProbe
-FP_integrate.intervals = 200
+FP_integrate.intervals = 20
+FP_integrate.probe_geometry = Point
FP_integrate.x_probe = 0.53125
FP_integrate.y_probe = 0.53125
FP_integrate.z_probe = 0.53125
FP_integrate.integrate = 1
+FP_line.type = FieldProbe
+FP_line.intervals = 200
+FP_line.probe_geometry = Line
+FP_line.x_probe = 0.53125
+FP_line.y_probe = 0.53125
+FP_line.z_probe = 0.53125
+FP_line.x1_probe = 0.70225
+FP_line.y1_probe = 0.70225
+FP_line.z1_probe = 0.70225
+FP_line.resolution = 100
+FP_plane.type = FieldProbe
+FP_plane.intervals = 200
+FP_plane.probe_geometry = Plane
+FP_plane.x_probe = 0.5
+FP_plane.y_probe = 0.5
+FP_plane.z_probe = 0.5
+FP_plane.target_normal_x = 0
+FP_plane.target_normal_y = 0
+FP_plane.target_normal_z = 1
+FP_plane.target_up_x = 0
+FP_plane.target_up_y = 1
+FP_plane.target_up_z = 0
+FP_plane.detector_radius = 0.25
+FP_plane.resolution = 10
MR.type = RhoMaximum
MR.intervals = 200
NP.type = ParticleNumber