Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
45 changes: 36 additions & 9 deletions hypnotoad/cases/tokamak.py
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,7 @@ def Bt_axis(self):
return self.fpol(self.psi_axis) / self.o_point.R


def read_geqdsk(filehandle, options={}, **kwargs):
def just_read_geqdsk(filehandle, options=None, **kwargs):
"""
Read geqdsk formatted data from a file object, returning
a TokamakEquilibrium object
Expand All @@ -1472,6 +1472,9 @@ def read_geqdsk(filehandle, options={}, **kwargs):

from ..geqdsk._geqdsk import read as geq_read

if options is None:
options = {}

data = geq_read(filehandle)

# Range of psi normalises psi derivatives
Expand Down Expand Up @@ -1525,14 +1528,38 @@ def read_geqdsk(filehandle, options={}, **kwargs):
# fpol constant in SOL
fpol = np.concatenate([fpol, np.full(psiSOL.shape, fpol[-1])])

return TokamakEquilibrium(
R1D,
Z1D,
psi2D,
psi1D,
fpol,
return dict(
R1D=R1D,
Z1D=Z1D,
psi2D=psi2D,
psi1D=psi1D,
fpol1D=fpol,
pressure=pressure,
wall=wall,
options=options,
**kwargs,
)


def read_geqdsk(filehandle, options=None, **kwargs):
"""
Read geqdsk formatted data from a file object, returning
a TokamakEquilibrium object

Inputs
------
filehandle A file handle to read
options Options|dict passed to TokamakEquilibrium
kwargs Other keywords passed to TokamakEquilibrim
These override values in options.

Options
-------
reverse_current = bool Changes the sign of poloidal flux psi
extrapolate_profiles = bool Extrapolate pressure using exponential
"""

if options is None:
options = {}

return TokamakEquilibrium(
**just_read_geqdsk(filehandle), options=options, **kwargs,
)
Loading