Skip to content

Commit

Permalink
Update picmi.ElectrostaticSolver child class in external Poisson so…
Browse files Browse the repository at this point in the history
…lver test (ECP-WarpX#4622)

* update `picmi.ElectrostaticSolver` child class in external Poisson solver test

* add checks that the external solvers were used
  • Loading branch information
roelof-groenewald authored Jan 23, 2024
1 parent d248490 commit c5377b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, grid, **kwargs):
required_precision=1, **kwargs
)

def initialize_inputs(self):
def solver_initialize_inputs(self):
"""Grab geometrical quantities from the grid. The boundary potentials
are also obtained from the grid using 'warpx_potential_zmin' for the
left_voltage and 'warpx_potential_zmax' for the right_voltage.
Expand All @@ -57,7 +57,7 @@ def initialize_inputs(self):
self.grid.potential_zmin = None
self.grid.potential_zmax = None

super(PoissonSolver1D, self).initialize_inputs()
super(PoissonSolver1D, self).solver_initialize_inputs()

self.nz = self.grid.number_of_cells[0]
self.dz = (self.grid.upper_bound[0] - self.grid.lower_bound[0]) / self.nz
Expand Down Expand Up @@ -421,6 +421,10 @@ def run_sim(self):

self.sim.step(self.diag_steps)

if self.pythonsolver:
# confirm that the external solver was run
assert hasattr(self.solver, 'phi')

if libwarpx.amr.ParallelDescriptor.MyProc() == 0:
np.save(f'ion_density_case_{self.n+1}.npy', self.ion_density_array)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(self, grid, **kwargs):
self.phi_wrapper = None
self.time_sum = 0.0

def initialize_inputs(self):
def solver_initialize_inputs(self):
"""Grab geometrical quantities from the grid.
"""
self.right_voltage = self.grid.potential_xmax
Expand All @@ -89,7 +89,7 @@ def initialize_inputs(self):
self.grid.potential_zmin = None
self.grid.potential_zmax = None

super(PoissonSolverPseudo1D, self).initialize_inputs()
super(PoissonSolverPseudo1D, self).solver_initialize_inputs()

self.nx = self.grid.number_of_cells[0]
self.nz = self.grid.number_of_cells[1]
Expand Down Expand Up @@ -359,3 +359,6 @@ def solve(self):
##########################

sim.step(max_steps)

# confirm that the external solver was run
assert hasattr(solver, 'phi')

0 comments on commit c5377b7

Please sign in to comment.