Skip to content
Draft

ADI #153

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
340628b
Run base case and add vis
rzhangbq Jul 9, 2026
9876a9b
adjust vis
rzhangbq Jul 11, 2026
8faad9e
adjust inputs
rzhangbq Jul 11, 2026
0928cd6
Implement EM case
rzhangbq Jul 14, 2026
db33445
adjust inputs
rzhangbq Jul 14, 2026
d6f1ebd
adjust excitation
rzhangbq Jul 14, 2026
4e01679
add new case and add pec mask support for ADI
rzhangbq Jul 15, 2026
e435db1
add assertion
rzhangbq Jul 15, 2026
904c958
add remasking
rzhangbq Jul 15, 2026
3fa92cb
efficiency improvement
rzhangbq Jul 15, 2026
cc8fdf5
bug fix for cuda
rzhangbq Jul 16, 2026
ce69872
bug fix GPU
rzhangbq Jul 17, 2026
6dc9873
adjust gitignore
rzhangbq Jul 17, 2026
536c97d
adjust vis
rzhangbq Jul 17, 2026
52d610e
add vis compare
rzhangbq Jul 17, 2026
a64adf2
adjust again
rzhangbq Jul 17, 2026
36797d4
adjust for gpu performance
rzhangbq Jul 17, 2026
16619e0
add scrip update plot
rzhangbq Jul 24, 2026
cdd163b
update inputs for script
rzhangbq Jul 25, 2026
bffe4ac
remove inductor output
rzhangbq Jul 25, 2026
9d4c164
add external field update at rhs
rzhangbq Jul 25, 2026
8f1518c
update script
rzhangbq Jul 25, 2026
9e16317
improve vis script for efficiency
rzhangbq Jul 26, 2026
ccd5b36
add script for spectrum
rzhangbq Jul 26, 2026
5d9fdd4
adjust plotting files
rzhangbq Jul 27, 2026
b4f1de2
add lumped j support for adi
rzhangbq Jul 27, 2026
2f3708b
add option to do fft pad
rzhangbq Jul 27, 2026
09ac37a
add eob plotting
rzhangbq Jul 29, 2026
1e5732c
update script
rzhangbq Jul 29, 2026
2dca9f8
add eob plotting
rzhangbq Jul 29, 2026
ee5f76c
update plotting scripts
rzhangbq Jul 30, 2026
316ad19
update plotting scripts
rzhangbq Jul 30, 2026
968e3fc
improve spectrum plot
rzhangbq Aug 6, 2026
7c085b6
add a conv test
rzhangbq Aug 8, 2026
ff9079c
fix bug
rzhangbq Aug 8, 2026
b67bff9
conv test in all directions
rzhangbq Aug 8, 2026
d4539f7
add code to mark peak freq
rzhangbq Aug 10, 2026
dcab9d3
add option to turn off guardcells
rzhangbq Aug 10, 2026
897f805
add dispersion analysis
rzhangbq Aug 25, 2026
97209c8
add analysis code
rzhangbq Aug 25, 2026
35b55cb
fix excitation small error
rzhangbq Aug 26, 2026
3b44900
changing the cases
rzhangbq Aug 26, 2026
1fa49cb
improve numerical test acc
rzhangbq Sep 1, 2026
d021028
add 3d. adjust cases.
rzhangbq Sep 1, 2026
8f62203
adjust plots
rzhangbq Sep 1, 2026
202ff8a
add comparison between different excitation freq
rzhangbq Sep 1, 2026
83d84fd
add ref
rzhangbq Sep 1, 2026
0ecd151
update how excitation is added
rzhangbq Sep 8, 2026
a576e0d
fix source term
rzhangbq Sep 10, 2026
70a043d
change how excitation is added for H
rzhangbq Sep 10, 2026
461b9d9
update again
rzhangbq Sep 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Match GNU Make flags for Bin/main3d.gnu.TPROF.MTMPI.ex (see `make -n …MacroscopicEvolveADI.o`).
# Relative -I paths need compile_commands.json so clangd uses artemis/ as the
# compile working directory (otherwise -I is resolved from each source file dir).
CompileFlags:
CompilationDatabase: .
Add:
- -I.
- -I./Source
- -I./Source/Particles/Filter
- -Itmp_build_dir/s/3d.gnu.TPROF.MTMPI.EXE
- -I../amrex/Src/Base
- -I../amrex/Src/Base/Parser
- -I../amrex/Src/Particle
- -I../amrex/Src/Boundary
- -I../amrex/Src/AmrCore
- -I../amrex/Src/LinearSolvers/MLMG
- -I../amrex/Tools/C_scripts
- -I/usr/local/Cellar/open-mpi/5.0.8/include
- -DAMREX_EXPORT_DYNAMIC
- -DAMREX_TINY_PROFILING
- -DBL_USE_MPI
- -DAMREX_USE_MPI
- -DAMREX_MPI_THREAD_MULTIPLE
- -DBL_NO_FORT
- -DAMREX_GPU_MAX_THREADS=0
- -DBL_SPACEDIM=3
- -DAMREX_SPACEDIM=3
- -DBL_FORT_USE_UNDERSCORE
- -DAMREX_FORT_USE_UNDERSCORE
- -DBL_Darwin
- -DAMREX_Darwin
- -DAMREX_PARTICLES
- -DNDEBUG
- -DOMPI_SKIP_MPICXX
- -DWARPX_DIM_3D
- -DWARPX_ZINDEX=2
- -DPICSAR_NO_ASSUMED_ALIGNMENT
- -DWARPX

---
If:
PathMatch: .*\.(cpp|cc|cxx|hpp|ipp|hh|hxx|H)$
CompileFlags:
Add:
- -xc++
- -std=c++20
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ AMReX_buildInfo.cpp
Backtrace.*
*.vth
*.sw[opqrs]
warpx_used_inputs
diag*/
wave_freespace_run/
*_run/
*.mp4
*.mov
*.avi
*.gif

####################
# AMReX data files #
Expand Down Expand Up @@ -70,3 +78,5 @@ cmake-build-*/
.DS_Store
.AppleDouble
.LSOverride

.cache
20 changes: 12 additions & 8 deletions Examples/Tests/circuits/inputs_wave_freespace
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
################################
####### GENERAL PARAMETERS ######
#################################
# 3D mesh, 1D pulse along z (fine direction)
max_step = 250
amr.n_cell = 32 32 32
amr.max_grid_size = 32
amr.blocking_factor = 32
amr.n_cell = 8 8 1024
amr.max_grid_size = 1024
amr.blocking_factor = 8
geometry.dims = 3
geometry.prob_lo = -4.e-6 -4.e-6 -4.e-6
geometry.prob_hi = 4.e-6 4.e-6 4.e-6
Expand All @@ -15,12 +16,14 @@ boundary.field_hi = periodic periodic periodic
#################################
############ NUMERICS ###########
#################################
warpx.verbose = 1
warpx.verbose = 0
warpx.use_filter = 0
warpx.cfl = 0.9
warpx.cfl = 50

algo.em_solver_medium = macroscopic # vacuum/macroscopic

algo.time_stepping_scheme = adi # fdtd or adi

algo.macroscopic_sigma_method = laxwendroff # laxwendroff or backwardeuler

macroscopic.sigma_function(x,y,z) = "sigma_0"
Expand All @@ -42,15 +45,16 @@ my_constants.sigma_0 = 0.0
my_constants.epsilon_0 = 8.8541878128e-12
my_constants.mu_0 = 1.25663706212e-06

# Ex / By packet propagating along +z
warpx.E_ext_grid_init_style = parse_E_ext_grid_function
warpx.Ex_external_grid_function(x,y,z) = "1.e5*exp(-(y)**2/(L/32)**2)*cos(2*pi*(y)/wavelength)"
warpx.Ex_external_grid_function(x,y,z) = "1.e5*exp(-(z)**2/(L/32)**2)*cos(2*pi*(z)/wavelength)"
warpx.Ey_external_grid_function(x,y,z) = "0."
warpx.Ez_external_grid_function(x,y,z) = "0."

warpx.B_ext_grid_init_style = parse_B_ext_grid_function
warpx.Bx_external_grid_function(x,y,z) = "0."
warpx.By_external_grid_function(x,y,z) = "0."
warpx.Bz_external_grid_function(x,y,z) = "(-1.e5*exp(-(y)**2/(L/32)**2)*cos(2*pi*(y)/wavelength)/c)"
warpx.By_external_grid_function(x,y,z) = "(1.e5*exp(-(z)**2/(L/32)**2)*cos(2*pi*(z)/wavelength)/c)"
warpx.Bz_external_grid_function(x,y,z) = "0."

warpx.E_excitation_on_grid_style = parse_E_excitation_grid_function

Expand Down
27 changes: 18 additions & 9 deletions Examples/Tests/pec/inputs_field_PEC_3d
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# standing wave.

# max step
max_step = 125
max_step = 1000

# number of grid points
amr.n_cell = 32 32 256
amr.n_cell = 4 4 1024

# Maximum allowable size of each subdomain
amr.max_grid_size = 1024
amr.blocking_factor = 32
amr.blocking_factor = 4

amr.max_level = 0

Expand All @@ -26,12 +26,21 @@ boundary.field_hi = periodic periodic pec
warpx.serialize_initial_conditions = 1

# Verbosity
warpx.verbose = 1
warpx.verbose = 0

# Algorithms
algo.current_deposition = esirkepov
algo.em_solver_medium = macroscopic
algo.time_stepping_scheme = adi
algo.macroscopic_sigma_method = laxwendroff

# Vacuum material properties for the macroscopic ADI field solve
macroscopic.sigma_function(x,y,z) = "0.0"
macroscopic.epsilon_function(x,y,z) = "8.8541878128e-12"
macroscopic.mu_function(x,y,z) = "1.25663706212e-06"

# CFL
warpx.cfl = 0.9
warpx.cfl = 2


my_constants.z1 = -2.e-6
Expand All @@ -48,7 +57,7 @@ warpx.By_external_grid_function(x,y,z)= "0."
warpx.Bz_external_grid_function(x,y,z) = "0."

# Diagnostics
diagnostics.diags_names = diag1
diag1.intervals = 125
diag1.diag_type = Full
diag1.fields_to_plot = Ey Bx
diagnostics.diags_names = plt
plt.intervals = 10
plt.diag_type = Full
plt.fields_to_plot = Ex Ey Ez Bx By Bz
19 changes: 15 additions & 4 deletions Source/Evolve/WarpXEvolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ WarpX::Evolve (int numsteps)
m_london->EvolveLondonJ(-0.5_rt*dt[0]); // J^(n) to J^(n-1/2) using E^(n)
FillBoundaryJ(guard_cells.ng_alloc_EB);
}
if (use_lumped_inductor) {
if (use_lumped_inductor &&
macroscopic_time_integrator_algo != MacroscopicTimeSteppingScheme::ADI) {
m_inductor->EvolveInductorJ(-0.5_rt*dt[0]); // J^(n) to J^(n-1/2) using E^(n)
FillBoundaryJ(guard_cells.ng_alloc_EB);
}
Expand Down Expand Up @@ -427,7 +428,8 @@ WarpX::OneStep_nosub (Real cur_time)
// fill boundary here
}
#endif
if (use_lumped_inductor == 1) {
if (use_lumped_inductor == 1 &&
macroscopic_time_integrator_algo != MacroscopicTimeSteppingScheme::ADI) {
m_inductor->EvolveInductorJ(dt[0]); // J^(n-1/2) to J^(n+1/2) using E^(n)
FillBoundaryJ(guard_cells.ng_alloc_EB);
}
Expand Down Expand Up @@ -486,11 +488,19 @@ WarpX::OneStep_nosub (Real cur_time)
EvolveG(0.5_rt * dt[0], DtType::FirstHalf);
FillBoundaryF(guard_cells.ng_FieldSolverF);
FillBoundaryG(guard_cells.ng_FieldSolverG);
if (WarpX::em_solver_medium == MediumForEM::Macroscopic &&
WarpX::macroscopic_time_integrator_algo == MacroscopicTimeSteppingScheme::ADI) {
#ifdef WARPX_MAG_LLG
WARPX_ABORT_WITH_MESSAGE("Macroscopic ADI is not implemented with WARPX_MAG_LLG.");
#else
MacroscopicEvolveADI(dt[0]); // We now have E^{n+1} and B^{n+1}
#endif
} else {
#ifndef WARPX_MAG_LLG
EvolveB(0.5_rt * dt[0], DtType::FirstHalf); // We now have B^{n+1/2}
FillBoundaryB(guard_cells.ng_FieldSolver, WarpX::sync_nodal_points);
// ApplyExternalFieldExcitation
ApplyExternalFieldExcitationOnGrid(ExternalFieldType::BfieldExternal, DtType::FirstHalf); // apply B external excitation; soft source to be fixed
ApplyExternalFieldExcitationOnGrid(ExternalFieldType::BfieldExternal, DtType::FirstHalf); // B soft/hard at t^{n+1/2}
#endif

#ifdef WARPX_MAG_LLG
Expand Down Expand Up @@ -550,8 +560,9 @@ WarpX::OneStep_nosub (Real cur_time)
#ifndef WARPX_MAG_LLG
EvolveB(0.5_rt * dt[0], DtType::SecondHalf); // We now have B^{n+1}
// ApplyExternalFieldExcitation
ApplyExternalFieldExcitationOnGrid(ExternalFieldType::BfieldExternal, DtType::SecondHalf); // redundant for hs; need to fix the way to increment ss
ApplyExternalFieldExcitationOnGrid(ExternalFieldType::BfieldExternal, DtType::SecondHalf); // B soft/hard at t^{n+1}
#endif
}

#ifdef WARPX_MAG_LLG
#ifndef WARPX_DIM_RZ
Expand Down
1 change: 1 addition & 0 deletions Source/FieldSolver/FiniteDifferenceSolver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ target_sources(WarpX
EvolveG.cpp
EvolveECTRho.cpp
FiniteDifferenceSolver.cpp
MacroscopicEvolveADI.cpp
MacroscopicEvolveE.cpp
MacroscopicEvolveEPML.cpp
ApplySilverMuellerBoundary.cpp
Expand Down
16 changes: 16 additions & 0 deletions Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceSolver.H
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <AMReX_REAL.H>

#include <AMReX_BaseFwd.H>
#include <AMReX_Periodicity.H>

#include <array>
#include <memory>
Expand Down Expand Up @@ -127,6 +128,21 @@ class FiniteDifferenceSolver
amrex::Real const dt,
std::unique_ptr<MacroscopicProperties> const& macroscopic_properties);
#ifndef WARPX_DIM_RZ
#ifndef WARPX_MAG_LLG
/**
* \brief Periodic-only ADI update for macroscopic freespace cases.
*/
void MacroscopicEvolveADI ( std::array< std::unique_ptr<amrex::MultiFab>, 3>& Efield,
std::array< std::unique_ptr<amrex::MultiFab>, 3>& Bfield,
std::array< std::array<std::unique_ptr<amrex::MultiFab>, 3>, 3>& Efield_adi,
std::array< std::array<std::unique_ptr<amrex::MultiFab>, 3>, 3>& Bfield_adi,
std::array< std::array<std::unique_ptr<amrex::MultiFab>, 3>, 3> const& PEC_adi,
amrex::Real const dt,
amrex::Periodicity const& periodicity,
std::unique_ptr<MacroscopicProperties> const& macroscopic_properties);
#endif
#endif
#ifndef WARPX_DIM_RZ
#ifdef WARPX_MAG_LLG
/**
* \brief Macroscopic M-update, H-update and B=mu_o(H+M) computation for non-vacuum medium using finite-difference algorithm
Expand Down
Loading