Skip to content

Commit

Permalink
Asserts required variables can be found
Browse files Browse the repository at this point in the history
- Tries to access nx, ny locally
  - If not found, accesse them from com
- Adds ixpt1, ixpt2, iysptrx to Class
- Asserts itroub has the necessary dictionary to store data
  • Loading branch information
holm10 committed Oct 27, 2023
1 parent 85d5133 commit 1d7fce6
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions pyscripts/rundt.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ def __init__(self, *args, n_stor = False, **kwargs):
# TODO: Add restore/recover from timeslice
# TODO: Add plot timeslice directly
# NOTE: No -> Utilize direct I/O from file instead
self.numvar = bbb.numvar
try:
self.nx
except:
self.nx = com.nx
try:
self.ny
except:
self.ny = com.ny
self.ixpt1 = com.ixpt1[0]
self.ixpt2 = com.ixpt2[0]
self.iysptrx = com.iysptrx
self.equationkey = array([b'te', b'ti', b'phi', b'up', b'ni', b'ng',
b'tg'])

Expand Down Expand Up @@ -49,7 +61,15 @@ def itroub(self):
bbb.idxu, bbb.idxn, bbb.idxg, bbb.idxtg]
equationsdescription = [ 'Electron energy', 'Ion energy', 'Potential',
'Ion momentum', 'Ion density', 'Gas density', 'Gas temperature']

# Assert required dict is present
try:
self.classvars
except:
self.classvars = {}
for cvar in ['itrouble', 'troubleeq', 'internaleq',
'internalspecies', 'troubleindex', 'dtrealfail',
'ylfail', 'yldotsfscalfail']:
self.classvars[cvar] = []
# Find the fortran index of the troublemaking equation
self.classvars['itrouble'].append(deepcopy(argmax(abs(bbb.yldot*\
bbb.sfscal)[:bbb.neq])+1))
Expand Down Expand Up @@ -400,7 +420,6 @@ def converge(self, dtreal=2e-9, ii1max=5000, ii2max=5, itermx=7, ftol=1e-5,
tsnapshot=None, savedir='../solutions', ii2increase=0, savefname=None,
message=None):


''' Converges the case by increasing dt
dtreal : float [1e-9]
Original time-step size
Expand Down Expand Up @@ -711,9 +730,7 @@ def calc_fnrm():
if (bbb.iterm == 1):
bbb.ftol = max(min(ftol, 0.01*self.fnrm_old),ftol_min)
# Take timestep and see if abort requested

self.message("Inner iteration #{}".format(ii2+1), nseparator=0,

separator='')
if message is not None:
print(message)
Expand Down Expand Up @@ -1143,6 +1160,9 @@ def dtsolve(dtdeltafac):
bbb.ftol = ftol
bbb.incpset = incpset
bbb.itermx = itermx
# TODO: Resolve how to run continuation solver w/ mmaxu
# TODO: Add coding for autodetecting when avg nfe approx mmaxu
# and upate jacobian then
# bbb.ismmaxuc = 0
# bbb.mmaxu = 70
if (bbb.iterm == 1) and (bbb.ijactot > 0):
Expand Down

0 comments on commit 1d7fce6

Please sign in to comment.