forked from ECP-WarpX/WarpX
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement stair-case Yee solver with EB in RZ geometry (ECP-WarpX#2707)
* Allow compilation with RZ EB * Do not push cells for RZ Yee solver, when covered with EB * Fix compilation errors * Fix additional compilation errors * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix additional compilation errors * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add automated test * Add automated test * Fix path in tests * Enable parser in RZ * Update example script * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Clean-up PR * Initialize EB quantities * Modified EM field initialization in 2D with EB * Typo fix * Typo fix * Ignoring unused variables correctly * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Correct condition for updating E * Correct update of B * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update B push * Update input script * Revert "Update input script" This reverts commit 5087485. * Update initialization * Updated test * Move test to a different folder * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add test for WarpX-test.ini * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix path for tests * Update test description * Update test metadata * Add checksum file * Revert changes * Revert changes * Change lx to lr * Revert "Change lx to lr" This reverts commit be3039a. * Change lx to lr --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: lgiacome <[email protected]>
- Loading branch information
1 parent
ebbe634
commit e38acc4
Showing
9 changed files
with
144 additions
and
22 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
Examples/Tests/embedded_boundary_diffraction/analysis_fields.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python3 | ||
""" | ||
This test checks the implementation of the embedded boundary in cylindrical geometry, | ||
by checking the diffraction of a laser by an embedded boundary here. | ||
We then check that the first minimum of the diffracted intensity pattern | ||
occurs along the angle given by the theoretical Airy pattern, i.e. | ||
theta_diffraction = 1.22 * lambda / d | ||
""" | ||
import os | ||
import sys | ||
|
||
import numpy as np | ||
from openpmd_viewer import OpenPMDTimeSeries | ||
from scipy.ndimage import gaussian_filter1d | ||
|
||
sys.path.insert(1, '../../../../warpx/Regression/Checksum/') | ||
import checksumAPI | ||
|
||
ts = OpenPMDTimeSeries('./EmbeddedBoundaryDiffraction_plt/') | ||
|
||
# Extract the intensity as a function of r and z | ||
Ex, info = ts.get_field('E', 'x', iteration=300) | ||
I = gaussian_filter1d(Ex**2, sigma=5, axis=0) # Extract intensity by averaging E^2 over wavelength | ||
irmax = np.argmax( I, axis=-1) | ||
|
||
# Find the radius of the first minimum, as a function of z | ||
def r_first_minimum(iz): | ||
ir = len(info.r)//2 | ||
while I[iz, ir+1] < I[iz, ir]: | ||
ir += 1 | ||
return info.r[ir] | ||
r = np.array([ r_first_minimum(iz) for iz in range(len(info.z)) ]) | ||
|
||
# Check that this corresponds to the prediction from the Airy pattern | ||
theta_diffraction = np.arcsin(1.22*0.1/0.4)/2 | ||
assert np.all( abs(r[50:] - theta_diffraction*info.z[50:]) < 0.03 ) | ||
|
||
# Open the right plot file | ||
filename = sys.argv[1] | ||
test_name = os.path.split(os.getcwd())[1] | ||
checksumAPI.evaluate_checksum(test_name, filename, output_format='openpmd') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# This script tests the diffraction of a laser by | ||
# a cylindrical object, represented by an embedded boundary here | ||
|
||
max_step = 300 | ||
amr.n_cell = 128 256 | ||
amr.max_grid_size = 256 | ||
amr.max_level = 0 | ||
|
||
geometry.dims = RZ | ||
geometry.prob_lo = 0. -0.2 | ||
geometry.prob_hi = 2 1.4 | ||
warpx.cfl = 0.99 | ||
algo.particle_shape = 1 | ||
|
||
boundary.field_lo = none absorbing_silver_mueller | ||
boundary.field_hi = pec absorbing_silver_mueller | ||
|
||
# Make the cylindrical object that the laser will diffract on | ||
my_constants.aperture_l = 0.01 | ||
my_constants.aperture_r = 0.2 | ||
warpx.eb_implicit_function = "if( (abs(z)<0.5*aperture_l) and (x<aperture_r), 1, -1 )" | ||
|
||
warpx.n_rz_azimuthal_modes = 2 | ||
|
||
# Laser | ||
lasers.names = laser1 | ||
laser1.profile = Gaussian | ||
laser1.position = 0. 0. -0.1 | ||
laser1.direction = 0. 0. 1. | ||
laser1.polarization = 1. 0. 0. | ||
laser1.profile_waist = 1. | ||
laser1.profile_duration = 100 | ||
laser1.profile_t_peak = 0 | ||
laser1.profile_focal_distance = 0 | ||
laser1.e_max = 1. | ||
laser1.wavelength = 0.1 | ||
|
||
diagnostics.diags_names = diag1 | ||
diag1.intervals = 100 | ||
diag1.diag_type = Full | ||
diag1.fields_to_plot = Er Et Ez Br Bt Bz | ||
diag1.format = openpmd |
10 changes: 10 additions & 0 deletions
10
Regression/Checksum/benchmarks_json/EmbeddedBoundaryDiffraction.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"lev=0": { | ||
"Br": 6.821267675779345e-19, | ||
"Bt": 5.564905732478707e-05, | ||
"Bz": 2.368259586613272e-19, | ||
"Er": 16503.98082446463, | ||
"Et": 1.5299584682447838e-10, | ||
"Ez": 1466.854467399728 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters