@@ -450,7 +450,7 @@ def equilibrium_search(self,
450450 diff = np .linalg .norm (y [- 1 ]- y0 , ord = norm )
451451 else :
452452 diff = np .linalg .norm (y [- 1 ]- y [- 2 ], ord = norm )
453- tol = abs_tol_eq + rel_tol_eq * np . linalg . norm ( y [ - 1 ], ord = norm )
453+ tol = abs_tol_eq + rel_tol_eq * diff
454454 iters += 1
455455
456456 if show_conv_metrics :
@@ -691,7 +691,8 @@ def set_dcdt(self,
691691 flow : bool = False ,
692692 t_c : float = 0.0 ,
693693 t_l : float = 0.0 ,
694- force_steady_state : bool = False ):
694+ force_steady_state : bool = False ,
695+ max_delay : float = 1e10 ):
695696 """
696697 Set the rate of change of precursor concentration.
697698
@@ -725,11 +726,12 @@ def set_dcdt(self,
725726 source = n * beta / Lambda
726727 decay = lam * self .y ()
727728 if flow :
729+ t_l = sp .Min (max_delay , t_l )
728730 outflow = self .y () / t_c
729731 if force_steady_state :
730- inflow = self .y () * np .exp (- lam * t_l ) / t_c
732+ inflow = self .y () * sp .exp (- lam * t_l ) / t_c
731733 else :
732- inflow = self .y (t - t_l ) * np .exp (- lam * t_l ) / t_c
734+ inflow = self .y (t - t_l ) * sp .exp (- lam * t_l ) / t_c
733735 else :
734736 inflow , outflow = 0.0 , 0.0
735737 self .dcdt = source - decay - outflow + inflow
0 commit comments