-
Notifications
You must be signed in to change notification settings - Fork 229
Implement PML for the outer RZ boundary with PSATD #2211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 35 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
7b98da7
Initial version of RZ PSATD PML BCs
dpgrote de5a72b
Cleaned up some bugs
dpgrote 30ca30c
Add support of do_pml_in_domain option
dpgrote 7bc35ac
Cleaned up stuff for building
dpgrote 5f5d4c3
Fix PMLPsatdAlgorithm macro
dpgrote 7f48397
Removed unneeded variable from SpectralSolverRZ
dpgrote 4d41190
Merge remote-tracking branch 'ECPwarpx/development' into RZ_psatd_pml
dpgrote 76cdfa3
Merge remote-tracking branch 'ECPwarpx/development' into RZ_psatd_pml
dpgrote 2519c7e
Merge remote-tracking branch 'ECPwarpx/development' into RZ_psatd_pml
dpgrote 1b1160f
Change length 3 arrays to length 2 (for 2D)
dpgrote 3ec7931
Merge remote-tracking branch 'ECPwarpx/development' into RZ_psatd_pml
dpgrote a86192d
Cleanup around DampPML
dpgrote fe3ae84
Added more checks of pml[lev]
dpgrote 1f54148
Added CI test for RZ PML
dpgrote 0b9105c
Added code to update the corner guard cells
dpgrote 47da308
Further updates
dpgrote 862e411
Added CI test
dpgrote 9e1cfd4
Fixed EOL space
dpgrote 2fa0bb1
Merge remote-tracking branch 'ECPwarpx/development' into RZ_psatd_pml
dpgrote 4747a29
Updated CI benchmarks, removing round off fields
dpgrote a30ba04
Changes to CI missed on previous commit
dpgrote 0497dfb
Merge remote-tracking branch 'ECPwarpx/development' into RZ_psatd_pml
dpgrote 80fbf99
Merge remote-tracking branch 'ECPwarpx/development' into RZ_psatd_pml
dpgrote d338b72
Various fixes for clean up
dpgrote 81a22c5
More fixes for clean up
dpgrote 7011f51
Further cleanup
dpgrote 0e55515
Updated benchmark
dpgrote 0f0c2c9
Fixed benchmarks file
dpgrote fccf166
Merge remote-tracking branch 'ECPwarpx/development' into RZ_psatd_pml
dpgrote 576b135
Minor cleanup
dpgrote 9c2adcc
Added round off benchmark values
dpgrote a736c35
Fixed testname in analysis_pml_psatd_rz.py
dpgrote 9c15106
Update comment in analysis file
dpgrote 693f903
Merge branch 'development' into RZ_psatd_pml
RemiLehe 47d762f
Put pml_rz code in RZ and PSATD macro blocks
dpgrote aae6a9c
Merge remote-tracking branch 'ECPwarpx/development' into RZ_psatd_pml
dpgrote 1824ae2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] edd8041
Add geometry.dims input to CI test input file, inputs_rz
dpgrote 76d85ea
Cleanup to match recent changes
dpgrote File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,53 @@ | ||
| #! /usr/bin/env python | ||
|
|
||
| # Copyright 2021 David Grote | ||
| # | ||
| # | ||
| # This file is part of WarpX. | ||
| # | ||
| # License: BSD-3-Clause-LBNL | ||
|
|
||
| """ | ||
| This script tests the absorption of fields in the PML in RZ geometry. | ||
|
|
||
| The input file inputs_particle_rz is used: it features an electron | ||
| moving radially that launches a pulse. This scripts runs until | ||
| most of the pulse escapes the radial boundary. If the PML fails, | ||
| the pulse will remain with in the domain. | ||
| """ | ||
| import sys | ||
| import os | ||
| import numpy as np | ||
| import yt | ||
| yt.funcs.mylog.setLevel(0) | ||
| sys.path.insert(1, '../../../../warpx/Regression/Checksum/') | ||
| import checksumAPI | ||
|
|
||
| # Open plotfile specified in command line | ||
| filename = sys.argv[1] | ||
| ds = yt.load( filename ) | ||
|
|
||
| # yt 4.0+ has rounding issues with our domain data: | ||
| # RuntimeError: yt attempted to read outside the boundaries | ||
| # of a non-periodic domain along dimension 0. | ||
| if 'force_periodicity' in dir(ds): ds.force_periodicity() | ||
|
|
||
| # Check that the field is low enough | ||
| ad0 = ds.covering_grid(level=0, left_edge=ds.domain_left_edge, dims=ds.domain_dimensions) | ||
| Ex_array = ad0['boxlib', 'Ex'].to_ndarray() | ||
| Ez_array = ad0['boxlib', 'Ez'].to_ndarray() | ||
| max_Ex = np.abs(Ex_array).max() | ||
| max_Ez = np.abs(Ez_array).max() | ||
| print( f'max Ex = {max_Ex}' ) | ||
| print( f'max Ez = {max_Ez}' ) | ||
| max_Efield = max(max_Ex, max_Ez) | ||
|
|
||
| # This tolerance was obtained empirically. As the simulation progresses, the field energy is leaking | ||
| # out through PML so that the max field diminishes with time. When the PML is working properly, | ||
| # the field level falls below 2 at the end of the simulation. | ||
| tolerance_abs = 2. | ||
| print('tolerance_abs: ' + str(tolerance_abs)) | ||
| assert max_Efield < tolerance_abs | ||
EZoni marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| test_name = os.path.split(os.getcwd())[1] | ||
| checksumAPI.evaluate_checksum(test_name, filename) | ||
This file contains hidden or 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,48 @@ | ||
| ################################# | ||
| ####### GENERAL PARAMETERS ###### | ||
| ################################# | ||
| max_step = 500 | ||
| amr.n_cell = 32 128 | ||
| amr.max_level = 0 | ||
| geometry.coord_sys = 1 # 1: Cylindrical | ||
| geometry.prob_lo = 0. -100.e-6 | ||
| geometry.prob_hi = 50.e-6 +100.e-6 | ||
|
|
||
| warpx.n_rz_azimuthal_modes = 2 | ||
|
|
||
| ################################# | ||
| ######## Boundary condition ##### | ||
| ################################# | ||
| boundary.field_lo = none periodic | ||
| boundary.field_hi = pml periodic | ||
|
|
||
| # PML | ||
| warpx.pml_ncell = 10 | ||
| warpx.do_pml_in_domain = 0 | ||
|
|
||
| ################################# | ||
| ############ NUMERICS ########### | ||
| ################################# | ||
| algo.maxwell_solver = psatd | ||
| warpx.use_filter = 0 | ||
| algo.particle_shape = 1 | ||
|
|
||
| ################################# | ||
| ############ PARTICLE ########### | ||
| ################################# | ||
| particles.species_names = electron | ||
|
|
||
| electron.charge = -q_e | ||
| electron.mass = m_e | ||
| electron.injection_style = "singleparticle" | ||
| electron.single_particle_pos = 0. 0. 0. | ||
| electron.single_particle_vel = 10. 0. 0. | ||
| electron.single_particle_weight = 1. | ||
|
|
||
| ################################# | ||
| ########## DIAGNOSTICS ########## | ||
| ################################# | ||
| diagnostics.diags_names = diag1 | ||
| diag1.intervals = 500 | ||
| diag1.fields_to_plot = Bx By Bz Ex Ey Ez jx jy jz rho | ||
| diag1.diag_type = Full |
This file contains hidden or 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,14 @@ | ||
| { | ||
| "lev=0": { | ||
| "Ex": 1317.2337418101674, | ||
| "Ey": 7.056477765087081e-12, | ||
| "Ez": 1156.1377910176022, | ||
| "Bx": 2.594232124519114e-20, | ||
| "By": 3.2688462949057505e-06, | ||
| "Bz": 4.292128402662449e-21, | ||
| "jx": 0.0, | ||
| "jy": 0.0, | ||
| "jz": 0.0, | ||
| "rho": 0.0 | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| CEXE_sources += PML.cpp WarpXEvolvePML.cpp | ||
| CEXE_sources += WarpXFieldBoundaries.cpp WarpX_PEC.cpp | ||
|
|
||
| ifeq ($(USE_RZ),TRUE) | ||
| CEXE_sources += PML_RZ.cpp | ||
RemiLehe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| endif | ||
|
|
||
| VPATH_LOCATIONS += $(WARPX_HOME)/Source/BoundaryConditions | ||
This file contains hidden or 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,75 @@ | ||
| /* Copyright 2021 David Grote | ||
| * | ||
| * | ||
| * This file is part of WarpX. | ||
| * | ||
| * License: BSD-3-Clause-LBNL | ||
| */ | ||
| #ifndef WARPX_PML_RZ_H_ | ||
| #define WARPX_PML_RZ_H_ | ||
|
|
||
| #include "PML_RZ_fwd.H" | ||
|
|
||
| #ifdef WARPX_USE_PSATD | ||
RemiLehe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # include "FieldSolver/SpectralSolver/SpectralSolverRZ.H" | ||
| #endif | ||
|
|
||
| #include <AMReX_MultiFab.H> | ||
| #include <AMReX_BoxArray.H> | ||
| #include <AMReX_Config.H> | ||
| #include <AMReX_REAL.H> | ||
|
|
||
| #include <AMReX_BaseFwd.H> | ||
|
|
||
| #include <array> | ||
| #include <string> | ||
|
|
||
| enum struct PatchType : int; | ||
|
|
||
| class PML_RZ | ||
| { | ||
| public: | ||
| PML_RZ (const int lev, const amrex::BoxArray& grid_ba, const amrex::DistributionMapping& grid_dm, | ||
| const amrex::Geometry* geom, const int ncell, const int do_pml_in_domain); | ||
|
|
||
| void ApplyDamping(amrex::MultiFab* Et_fp, amrex::MultiFab* Ez_fp, | ||
| amrex::MultiFab* Bt_fp, amrex::MultiFab* Bz_fp, | ||
| amrex::Real dt); | ||
|
|
||
| std::array<amrex::MultiFab*,2> GetE_fp (); | ||
| std::array<amrex::MultiFab*,2> GetB_fp (); | ||
|
|
||
| #ifdef WARPX_USE_PSATD | ||
| void PushPSATD (const int lev); | ||
| #endif | ||
|
|
||
| void FillBoundaryE (); | ||
| void FillBoundaryB (); | ||
| void FillBoundaryE (PatchType patch_type); | ||
| void FillBoundaryB (PatchType patch_type); | ||
|
|
||
| void CheckPoint (const std::string& dir) const; | ||
| void Restart (const std::string& dir); | ||
|
|
||
| ~PML_RZ () = default; | ||
|
|
||
| private: | ||
|
|
||
| const int m_ncell; | ||
| const int m_do_pml_in_domain; | ||
| const amrex::Geometry* m_geom; | ||
|
|
||
| // Only contains Er and Et, and Br and Bt | ||
| std::array<std::unique_ptr<amrex::MultiFab>,2> pml_E_fp; | ||
| std::array<std::unique_ptr<amrex::MultiFab>,2> pml_B_fp; | ||
|
|
||
| #ifdef WARPX_USE_PSATD | ||
| void PushPMLPSATDSinglePatchRZ ( const int lev, | ||
| SpectralSolverRZ& solver, | ||
| std::array<std::unique_ptr<amrex::MultiFab>,2>& pml_E, | ||
| std::array<std::unique_ptr<amrex::MultiFab>,2>& pml_B); | ||
| #endif | ||
|
|
||
| }; | ||
|
|
||
| #endif | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.