Skip to content

exit solve after iter_limit reached #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme_path = ["_themes", ]

# Theme options are theme-specific and customize the look and feel of a
# theme further. For a list of options available for each theme, see the
Expand Down
5 changes: 4 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ torch
scipy
matplotlib
tifffile
myst_parser
myst_parser
sphinx==5.3.0
sphinx_rtd_theme==1.1.1
readthedocs-sphinx-search==0.1.1
15 changes: 6 additions & 9 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 Expand Up @@ -276,8 +275,7 @@ def solve(self, iter_limit=5000, verbose=True, conv_crit=2*10**-2, D_0=1):
out = out[:, 2:-2]
out /= self.nn
if self.iter % 50 == 0:
self.converged = self.check_convergence(
verbose, conv_crit, start, iter_limit)
self.converged = self.check_convergence(verbose, conv_crit)
out -= self.conc[:, 2:-2]
out *= self.cb[self.iter % 2]
self.conc[:, 2:-2] += out
Expand Down Expand Up @@ -441,16 +439,15 @@ def solve(self, iter_limit=5000, verbose=True, conv_crit=2*10**-2):
self.pre_factors[5][:, 1:-1, 1:-1, :-2]
out /= self.nn
if self.iter % 20 == 0:
self.converged = self.check_convergence(
verbose, conv_crit, start, iter_limit)
self.converged = self.check_convergence(verbose, conv_crit)
out -= self.crop(self.conc, 1)
out *= self.cb[self.iter % 2]
self.conc[:, 1:-1, 1:-1, 1:-1] += out

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
if self.iter % 100 == 0:
self.semi_converged, self.new_fl, err = self.check_vertical_flux(
Expand Down