Skip to content

Commit

Permalink
exit solve after iter_limit reached
Browse files Browse the repository at this point in the history
  • Loading branch information
amirDahari1 committed Nov 13, 2023
1 parent 6345a78 commit 9c3c3c1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions taufactor/taufactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def solve(self, iter_limit=5000, verbose=True, conv_crit=2*10**-2):

with torch.no_grad():
start = timer()
while not self.converged:
while not self.converged and self.iter < iter_limit:
# find sum of all nearest neighbours
out = self.conc[:, 2:, 1:-1, 1:-1] + \
self.conc[:, :-2, 1:-1, 1:-1] + \
Expand All @@ -149,8 +149,7 @@ def solve(self, iter_limit=5000, verbose=True, conv_crit=2*10**-2):
out /= self.nn
# check convergence using criteria
if self.iter % 100 == 0:
self.converged = self.check_convergence(
verbose, conv_crit, start, iter_limit)
self.converged = self.check_convergence(verbose, conv_crit)
# efficient way of adding flux to old conc with overrelaxation
out -= self.crop(self.conc, 1)
out *= self.cb[self.iter % 2]
Expand All @@ -161,7 +160,7 @@ def solve(self, iter_limit=5000, verbose=True, conv_crit=2*10**-2):
self.end_simulation(iter_limit, verbose, start)
return self.tau

def check_convergence(self, verbose, conv_crit, start, iter_limit):
def check_convergence(self, verbose, conv_crit):
# print progress
self.semi_converged, self.new_fl, err = self.check_vertical_flux(
conv_crit)
Expand Down

0 comments on commit 9c3c3c1

Please sign in to comment.