Path: blob/devel/fem/tests/BatteryDischarge/Timefun.F90
5247 views
FUNCTION TimeFun(Model, n, tind) RESULT(dt)1USE DefUtils2IMPLICIT None3TYPE(Model_t) :: Model4INTEGER :: n5REAL(KIND=dp) :: tind, dt67LOGICAL :: Visited = .FALSE.,maxReached=.FALSE.8REAL(KIND=dp) :: dtmax, dt0, q910SAVE Visited, MaxReached, dtmax, dt0, q1112IF(.NOT. Visited ) THEN13dtmax = ListGetConstReal( Model % Simulation,'Max Timestep')14dt0 = ListGetConstReal( Model % Simulation,'First Timestep')15q = ListGetConstReal( Model % Simulation,'Timestep Ratio')16END IF1718! Since q^(tind-1) minght be huge we use constant timestep after reaching the max19IF( maxReached ) THEN20dt = dtmax21RETURN22END IF2324! Timestep growing exponetially25dt = dt0 * q**(tind-1.0_dp)2627! Until max timestep is reached28IF( dt > dtmax ) THEN29dt = dtmax30maxReached = .TRUE.31END IF3233END FUNCTION TimeFun343536