Skip to content

Commit

Permalink
log update of bns upon convergence/picard fail
Browse files Browse the repository at this point in the history
  • Loading branch information
smiet committed Feb 1, 2024
1 parent 21ce8d3 commit 79e8d91
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/simsopt/mhd/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,18 +1113,26 @@ def run(self, update_guess: bool = True):
if self.results.output.ForceErr > self.tolerance:
# re-set the boundary field guess before failing, so the next run does not start unconverged.
if self.freebound:
logger.info(f"Group {self.mpi.group}: Force balance unconverged, re-setting boundary field guess and raising ObjectiveFailure")
si.bns, si.bnc = initial_bns, initial_bnc
raise ObjectiveFailure(
'SPEC could not find force balance'
)
# TODO: add check for picard convergence once SPEC is updated
# if self.results.output.<bnsERR> > self.inputlist.gbntol
# if self.freebound:
# si.bns, si.bnc = initial_bns, initial_bnc
# raise ObjectiveFailure(
# 'SPEC could not find force balance'
# )


# check for picard convergence once SPEC is updated
if self.freebound:
try:
if self.results.output.BnsErr > self.inputlist.gbntol:
if self.mpi.proc0_groups:
logger.info(f"Group {self.mpi.group}: Picard iteration unconverged, re-setting boundary field guess and raising ObjectiveFailure")
si.bns, si.bnc = initial_bns, initial_bnc
raise ObjectiveFailure(
'Picard iteration failed to reach convergence, increase mfreeits or gbntol'
)
except AttributeError:
logger.info('Picard convergence not checked, please update SPEC version 3.22 or higher')
print("Picard convergence not checked, please update SPEC version 3.22 or higher")

# Save geometry as initial guess for next iterations
if update_guess:
new_guess = None
Expand Down

0 comments on commit 79e8d91

Please sign in to comment.