/[escript]/trunk/escript/py_src/modelframe.py
ViewVC logotype

Diff of /trunk/escript/py_src/modelframe.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 835 by gross, Thu Aug 31 01:31:15 2006 UTC revision 836 by gross, Mon Sep 4 22:37:25 2006 UTC
# Line 693  class Simulation(Model): Line 693  class Simulation(Model):
693            
694      FAILED_TIME_STEPS_MAX=20      FAILED_TIME_STEPS_MAX=20
695      MAX_ITER_STEPS=50      MAX_ITER_STEPS=50
696        MAX_CHANGE_OF_DT=2.
697            
698      def __init__(self, models=[], **kwargs):      def __init__(self, models=[], **kwargs):
699          """          """
# Line 879  class Simulation(Model): Line 880  class Simulation(Model):
880          while not self.finalize():          while not self.finalize():
881              step_fail_counter=0              step_fail_counter=0
882              iteration_fail_counter=0              iteration_fail_counter=0
883              dt_new=self.getSafeTimeStepSize(dt)              if self.n==0:
884                    dt_new=self.getSafeTimeStepSize(dt)
885                else:
886                    dt_new=min(max(self.getSafeTimeStepSize(dt),dt*self.MAX_CHANGE_OF_DT),dt*self.MAX_CHANGE_OF_DT)
887              self.trace("%d. time step %e (step size %e.)" % (self.n+1,self.tn+dt_new,dt_new))              self.trace("%d. time step %e (step size %e.)" % (self.n+1,self.tn+dt_new,dt_new))
888              end_of_step=False              end_of_step=False
889              while not end_of_step:              while not end_of_step:
# Line 895  class Simulation(Model): Line 899  class Simulation(Model):
899                    end_of_step=False                    end_of_step=False
900                    iteration_fail_counter+=1                    iteration_fail_counter+=1
901                    if iteration_fail_counter>self.FAILED_TIME_STEPS_MAX:                    if iteration_fail_counter>self.FAILED_TIME_STEPS_MAX:
902                             raise SimulationBreakDownError("reduction of time step to achieve convergence failed.")                             raise SimulationBreakDownError("reduction of time step to achieve convergence failed after %s steps."%self.FAILED_TIME_STEPS_MAX)
903                    self.trace("iteration fails. time step is repeated with new step size.")                    self.trace("Iteration failed. Time step is repeated with new step size %s."%dt_new)
904                 except FailedTimeStepError:                 except FailedTimeStepError:
905                    dt_new=self.getSafeTimeStepSize(dt)                    dt_new=self.getSafeTimeStepSize(dt)
906                    end_of_step=False                    end_of_step=False
907                    step_fail_counter+=1                    step_fail_counter+=1
908                    self.trace("time step is repeated.")                    self.trace("Time step is repeated with new time step size %s."%dt_new)
909                    if step_fail_counter>self.FAILED_TIME_STEPS_MAX:                    if step_fail_counter>self.FAILED_TIME_STEPS_MAX:
910                          raise SimulationBreakDownError("time integration is given up after %d attempts."%step_fail_counter)                          raise SimulationBreakDownError("Time integration is given up after %d attempts."%step_fail_counter)
911              dt=dt_new              dt=dt_new
912              if not check_point==None:              if not check_point==None:
913                  if n%check_point==0:                  if n%check_point==0:

Legend:
Removed from v.835  
changed lines
  Added in v.836

  ViewVC Help
Powered by ViewVC 1.1.26