Skip to content

Commit

Permalink
Adds switches for grid morphing functions
Browse files Browse the repository at this point in the history
- Adds switches and conditionals used by UETOOLS to interpolate between grids
  • Loading branch information
holm10 committed Feb 21, 2024
1 parent 40eaf31 commit 5c6e012
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions bbb/geometry.m
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,8 @@ call s2copy (nx+2,ny+2,psi(0,0,ij),1,nx+2,psig(0,0,ij),1,nx+2)

if (ndomain .gt. 1) goto 13 # domain decomp.; rm,zm already passed

if (manualgrid == 0) then

if(mhdgeo .eq. 1) then
if (ismmon.ne.0 .and. isnonog.eq.0) then
call remark('*** WARNING: ismmon.ne.0 BUT isnonog=0 ****')
Expand Down Expand Up @@ -725,6 +727,8 @@ call readgrid(fname, runid)
if (iprint*(1-isgriduehdf5) .ne. 0) write(*,*)
endif

endif # End test on manualgrid

c... Reset separatrix index if nyomitmx > 0
if (nyomitmx >= nysol(1)+nyout(1)) then
do jx = 1, nxpt
Expand Down
2 changes: 2 additions & 0 deletions bbb/odesetup.m
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,14 @@ ccc call gallot("Jacobian_part",0)

* -- Allocation of the different common blocks
if (newgeo .eq. 1) then
if (manualgrid == 0) then
call gallot("Comgeo",0)
call gallot("Noggeo",0)
call gallot("RZ_grid_info",0)
call gallot("RZ_cell_info",0)
call gallot("Bfield",0)
call gallot("Linkbbb",0)
endif
endif
if (isddcon .eq. 1) call gallot("Indices_domain_dcl",0)
if (isallloc .eq. 0) then
Expand Down
15 changes: 13 additions & 2 deletions pyscripts/rundt.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,8 @@ def continuation_solve(self,
dtlim=1e4,
ii1max=150,
saveres=7,
newgeo=False,
commands = [],
**kwargs):
""" Solves var up to target using continuation method
var - string for variable, or nested dict of variables and targets
Expand Down Expand Up @@ -833,6 +835,7 @@ def continuation_solve(self,
dtlim - Cutoff on (target-var)/delta for which a time-dependent run is triggered
ii1max - maximum number of dt iterations to take
saveres - how many successful iterations are allowed between saves are dumped
newgeo - UEDGE re-evaluates the grid if newgeo is True
kwargs passed to rundt
"""
from uedge import bbb
Expand All @@ -847,9 +850,11 @@ def continuation_solve(self,

self.tstart = time()
# ==== HELPERS ====
def changevar():
def changevar(commands=[]):
""" Changes var by delta """
setvar(min(self.lastsuccess + self.delta, 1))
for command in self.contsolvecommands:
exec(command)

def setvar(value):
""" Sets var to value """
Expand Down Expand Up @@ -1093,6 +1098,7 @@ def dtsolve(dtdeltafac):
self.isave = saveres
self.saveres = saveres
self.delta = 1/initres
self.contsolvecommands = commands
self.lastsuccess = 0

# Set up dictionary with variables and targets
Expand Down Expand Up @@ -1149,7 +1155,7 @@ def dtsolve(dtdeltafac):
# Record original solver settings
self.orig = {}
for ovar in ['itermx', 'dtreal', 'icntnunk', 'ftol', 'incpset',
'ismmaxuc', 'mmaxu'
'ismmaxuc', 'mmaxu', 'newgeo'
]:
self.orig[ovar] = deepcopy(getattr(bbb, ovar))
# Take the initial time-step
Expand Down Expand Up @@ -1186,6 +1192,11 @@ def dtsolve(dtdeltafac):
're-execute command', seppad='*')
return
# Start outer loop

if newgeo is False:
bbb.newgeo = False

changevar()
while True:
# Ensure we don't exceed the target value
# Re-eval preconditioner: omit first step
Expand Down

0 comments on commit 5c6e012

Please sign in to comment.