Skip to content

Commit

Permalink
updated the ts-fft solver with the new grid.to
Browse files Browse the repository at this point in the history
Also added a new shape-solver argument (to make pyamg-shape obsolete).
We could easily imagine that other solvers will be available.

Signed-off-by: Nick Papior <nickpapior@gmail.com>
  • Loading branch information
zerothi committed Nov 15, 2023
1 parent 950dd41 commit ca353fb
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/sisl_toolbox/transiesta/poisson/fftpoisson_fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
--help). There are a few important flags you should know about:
--tolerance [tol] specify the tolerance of the solution, the tighter the longer solution time
--pyamg-shape [nx ny nz] shape for which the solution is calculated (impacts speed)
--shape [nx ny nz] final shape of the solution, if pyamg-shape is not the same the solution will be interpolated (order=2)
--shape-solver [nx ny nz] shape for which the solution is calculated (impacts speed)
--shape [nx ny nz] final shape of the solution, if shape-solver is not the same the solution will be interpolated (order=2)
--dtype [f|d] the data-type used to solve the Poisson equation
--out [file] any sisl compatible grid file, please at least do --out V.TSV.nc which is compatible with TranSiesta.
Expand Down Expand Up @@ -192,8 +192,8 @@ def _create_shape_tree(xyz, A, B=None):

return AA | BB

# Create grid
geometry.set_boundary_condition(bc)
# Create grid and specify boundary conditions
geometry.lattice.set_boundary_condition(bc)
grid = si.Grid(shape, geometry=geometry, dtype=dtype)

class _fake:
Expand All @@ -209,7 +209,7 @@ def dtype(self):
grid.grid = _fake()

# Construct matrices we need to specify the boundary conditions on
A, b = grid.topyamg()
A, b = grid.to.pyamg()

# Short-hand notation
xyz = geometry.xyz
Expand Down Expand Up @@ -268,8 +268,8 @@ def dtype(self):
for i in (0, 1, 2):
if periodic[i]:
bc[i, :] = BC.PERIODIC
grid.set_bc(bc)
A, b = grid.topyamg()
grid.lattice.set_boundary_condition(bc)
A, b = grid.to.pyamg()

# Solve only for the boundary fixed
def sl2idx(grid, sl):
Expand Down Expand Up @@ -400,6 +400,8 @@ def fftpoisson_fix_cli(subp=None):
)

p.add_argument(
"--shape-solver",
"-ss",
"--pyamg-shape",
"-ps",
nargs=3,
Expand Down Expand Up @@ -475,7 +477,7 @@ def fftpoisson_fix_cli(subp=None):
action="store_false",
dest="boundary_fft",
default=True,
help="Once the electrode boundary conditions are solved we perform a second solution with boundaries fixed. Using this flag disables this second solution.",
help="Disable the 2nd solution with the boundaries fixed. Generally, this solver will first solve for the electrode boundary conditions, then for the fixed box boundary conditains (gotten from the first solution).",
)

if _DEBUG:
Expand Down Expand Up @@ -534,10 +536,10 @@ def fftpoisson_fix_run(args):
dtype = np.float64

# Now we can solve Poisson
if args.pyamg_shape is None:
if args.shape_solver is None:
shape = args.shape
else:
shape = args.pyamg_shape
shape = args.shape_solver

# Create the boundary conditions
boundary = []
Expand Down

0 comments on commit ca353fb

Please sign in to comment.