@@ -137,7 +137,7 @@ def solve(self, iter_limit=5000, verbose=True, conv_crit=2*10**-2):
137
137
138
138
with torch .no_grad ():
139
139
start = timer ()
140
- while not self .converged :
140
+ while not self .converged and self . iter < iter_limit :
141
141
# find sum of all nearest neighbours
142
142
out = self .conc [:, 2 :, 1 :- 1 , 1 :- 1 ] + \
143
143
self .conc [:, :- 2 , 1 :- 1 , 1 :- 1 ] + \
@@ -149,8 +149,7 @@ def solve(self, iter_limit=5000, verbose=True, conv_crit=2*10**-2):
149
149
out /= self .nn
150
150
# check convergence using criteria
151
151
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 )
154
153
# efficient way of adding flux to old conc with overrelaxation
155
154
out -= self .crop (self .conc , 1 )
156
155
out *= self .cb [self .iter % 2 ]
@@ -161,7 +160,7 @@ def solve(self, iter_limit=5000, verbose=True, conv_crit=2*10**-2):
161
160
self .end_simulation (iter_limit , verbose , start )
162
161
return self .tau
163
162
164
- def check_convergence (self , verbose , conv_crit , start , iter_limit ):
163
+ def check_convergence (self , verbose , conv_crit ):
165
164
# print progress
166
165
self .semi_converged , self .new_fl , err = self .check_vertical_flux (
167
166
conv_crit )
@@ -276,8 +275,7 @@ def solve(self, iter_limit=5000, verbose=True, conv_crit=2*10**-2, D_0=1):
276
275
out = out [:, 2 :- 2 ]
277
276
out /= self .nn
278
277
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 )
281
279
out -= self .conc [:, 2 :- 2 ]
282
280
out *= self .cb [self .iter % 2 ]
283
281
self .conc [:, 2 :- 2 ] += out
@@ -441,16 +439,15 @@ def solve(self, iter_limit=5000, verbose=True, conv_crit=2*10**-2):
441
439
self .pre_factors [5 ][:, 1 :- 1 , 1 :- 1 , :- 2 ]
442
440
out /= self .nn
443
441
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 )
446
443
out -= self .crop (self .conc , 1 )
447
444
out *= self .cb [self .iter % 2 ]
448
445
self .conc [:, 1 :- 1 , 1 :- 1 , 1 :- 1 ] += out
449
446
450
447
self .end_simulation (iter_limit , verbose , start )
451
448
return self .tau
452
449
453
- def check_convergence (self , verbose , conv_crit , start , iter_limit ):
450
+ def check_convergence (self , verbose , conv_crit ):
454
451
# print progress
455
452
if self .iter % 100 == 0 :
456
453
self .semi_converged , self .new_fl , err = self .check_vertical_flux (
0 commit comments