Skip to content

Commit 74263a2

Browse files
authored
Merge pull request #96 from tldr-group/feature-exit-after-iter_limit-reached
exit solve after iter_limit reached
2 parents 6345a78 + 5683782 commit 74263a2

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
# a list of builtin themes.
8585
#
8686
html_theme = 'sphinx_rtd_theme'
87+
html_theme_path = ["_themes", ]
8788

8889
# Theme options are theme-specific and customize the look and feel of a
8990
# theme further. For a list of options available for each theme, see the

docs/requirements.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ torch
33
scipy
44
matplotlib
55
tifffile
6-
myst_parser
6+
myst_parser
7+
sphinx==5.3.0
8+
sphinx_rtd_theme==1.1.1
9+
readthedocs-sphinx-search==0.1.1

taufactor/taufactor.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def solve(self, iter_limit=5000, verbose=True, conv_crit=2*10**-2):
137137

138138
with torch.no_grad():
139139
start = timer()
140-
while not self.converged:
140+
while not self.converged and self.iter < iter_limit:
141141
# find sum of all nearest neighbours
142142
out = self.conc[:, 2:, 1:-1, 1:-1] + \
143143
self.conc[:, :-2, 1:-1, 1:-1] + \
@@ -149,8 +149,7 @@ def solve(self, iter_limit=5000, verbose=True, conv_crit=2*10**-2):
149149
out /= self.nn
150150
# check convergence using criteria
151151
if self.iter % 100 == 0:
152-
self.converged = self.check_convergence(
153-
verbose, conv_crit, start, iter_limit)
152+
self.converged = self.check_convergence(verbose, conv_crit)
154153
# efficient way of adding flux to old conc with overrelaxation
155154
out -= self.crop(self.conc, 1)
156155
out *= self.cb[self.iter % 2]
@@ -161,7 +160,7 @@ def solve(self, iter_limit=5000, verbose=True, conv_crit=2*10**-2):
161160
self.end_simulation(iter_limit, verbose, start)
162161
return self.tau
163162

164-
def check_convergence(self, verbose, conv_crit, start, iter_limit):
163+
def check_convergence(self, verbose, conv_crit):
165164
# print progress
166165
self.semi_converged, self.new_fl, err = self.check_vertical_flux(
167166
conv_crit)
@@ -276,8 +275,7 @@ def solve(self, iter_limit=5000, verbose=True, conv_crit=2*10**-2, D_0=1):
276275
out = out[:, 2:-2]
277276
out /= self.nn
278277
if self.iter % 50 == 0:
279-
self.converged = self.check_convergence(
280-
verbose, conv_crit, start, iter_limit)
278+
self.converged = self.check_convergence(verbose, conv_crit)
281279
out -= self.conc[:, 2:-2]
282280
out *= self.cb[self.iter % 2]
283281
self.conc[:, 2:-2] += out
@@ -441,16 +439,15 @@ def solve(self, iter_limit=5000, verbose=True, conv_crit=2*10**-2):
441439
self.pre_factors[5][:, 1:-1, 1:-1, :-2]
442440
out /= self.nn
443441
if self.iter % 20 == 0:
444-
self.converged = self.check_convergence(
445-
verbose, conv_crit, start, iter_limit)
442+
self.converged = self.check_convergence(verbose, conv_crit)
446443
out -= self.crop(self.conc, 1)
447444
out *= self.cb[self.iter % 2]
448445
self.conc[:, 1:-1, 1:-1, 1:-1] += out
449446

450447
self.end_simulation(iter_limit, verbose, start)
451448
return self.tau
452449

453-
def check_convergence(self, verbose, conv_crit, start, iter_limit):
450+
def check_convergence(self, verbose, conv_crit):
454451
# print progress
455452
if self.iter % 100 == 0:
456453
self.semi_converged, self.new_fl, err = self.check_vertical_flux(

0 commit comments

Comments
 (0)