Skip to content

Commit

Permalink
third major refactor; added low pass frequency filter for A
Browse files Browse the repository at this point in the history
Signed-off-by: roelof-groenewald <[email protected]>
  • Loading branch information
roelof-groenewald committed Sep 3, 2024
1 parent e56ee5c commit 2e8024b
Show file tree
Hide file tree
Showing 6 changed files with 250 additions and 104 deletions.
13 changes: 12 additions & 1 deletion Python/pywarpx/picmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1884,6 +1884,10 @@ class ElectrostaticSolver(picmistandard.PICMI_ElectrostaticSolver):
warpx_magnetostatic: bool, default=False
Whether to use the magnetostatic solver
warpx_magnetostatic_t_filtering_parameter: float, default=0.25
Low pass filter parameter for A-field used with the magnetostatic
solver.
warpx_semi_implicit: bool, default=False
Whether to use the semi-implicit Poisson solver
Expand All @@ -1897,6 +1901,9 @@ def init(self, kw):
self.absolute_tolerance = kw.pop("warpx_absolute_tolerance", None)
self.self_fields_verbosity = kw.pop("warpx_self_fields_verbosity", None)
self.magnetostatic = kw.pop("warpx_magnetostatic", False)
self.magnetostatic_t_filer_param = kw.pop(
"warpx_magnetostatic_t_filtering_parameter", None
)
self.semi_implicit = kw.pop("warpx_semi_implicit", False)
self.semi_implicit_factor = kw.pop("warpx_semi_implicit_factor", None)

Expand All @@ -1909,7 +1916,11 @@ def solver_initialize_inputs(self):
if self.relativistic:
pywarpx.warpx.do_electrostatic = "relativistic"
else:
pywarpx.warpx.do_magnetostatic = self.magnetostatic
if self.magnetostatic:
pywarpx.warpx.do_magnetostatic = self.magnetostatic
pywarpx.warpx.magnetostatic_t_filtering_parameter = (
self.magnetostatic_t_filer_param
)
if self.semi_implicit:
pywarpx.warpx.do_electrostatic = "labframe-semi-implicit"
pywarpx.warpx.semi_implicit_factor = self.semi_implicit_factor
Expand Down
18 changes: 17 additions & 1 deletion Source/FieldSolver/MagnetostaticSolver/MagnetostaticSolver.H
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,23 @@ public:

void InitData ();

/**
* Function that interpolates the A-field solution from the initial nodal
* field to the appropriate A-field staggering (matching the E-field).
*/
void InterpolateAfield (amrex::Array<std::unique_ptr<amrex::MultiFab>, 3>& Afield,
const int lev);

/**
* Function to calculate the time derivative of the vector potential and add
* it to the E-field (inductive term of the E-field).
*/
void UpdateEfromInductance (amrex::Array<std::unique_ptr<amrex::MultiFab>, 3>& Efield,
amrex::Array<std::unique_ptr<amrex::MultiFab>, 3> const& Afield,
Real dt, const int lev);

/** Boundary Handler for the Vector Potential Poisson Solver
/**
* Boundary Handler for the Vector Potential Poisson Solver
* This only will handle homogeneous Dirichlet boundary conditions on
* embedded boundaries, and homogeneous dirichlet/Neumann or periodic
* boundary conditions on domain boundaries.
Expand Down Expand Up @@ -162,6 +174,7 @@ public:
BoundaryHandler m_boundary_handler = BoundaryHandler();

// numerical parameters
amrex::Real t_filter_param = 0.25_rt;
amrex::Real required_precision = 1.e-11_rt;
amrex::Real absolute_tolerance = 0.0_rt;
int max_iters = 200;
Expand All @@ -171,5 +184,8 @@ public:
Vector<std::array< std::unique_ptr<MultiFab>, 3 > > Afield_fp_nodal;
Vector<std::array< std::unique_ptr<MultiFab>, 3 > > Afield_fp_old;
Vector<std::array< std::unique_ptr<MultiFab>, 3 > > current_fp_temp;

/** Array of Gpu Vectors with index type of the Ex, Ey and Ez multifabs */
std::array<amrex::GpuArray<int, 3>, 3> E_IndexType;
};
#endif //WARPX_MAGNETOSTATICSOLVER_H_
Loading

0 comments on commit 2e8024b

Please sign in to comment.