From 7648536786d0654898735d797f1854d69b9deef3 Mon Sep 17 00:00:00 2001 From: Laurent Soucasse <135331272+lsoucasse@users.noreply.github.com> Date: Mon, 18 Nov 2024 14:08:40 +0100 Subject: [PATCH] Cap to a smaller maximum time step of 50 Myr. --- src/mors/parameters.py | 4 ++-- src/mors/rotevo.py | 4 +++- tests/test_spada_RB.py | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/mors/parameters.py b/src/mors/parameters.py index 9bbdafa..a2001f4 100644 --- a/src/mors/parameters.py +++ b/src/mors/parameters.py @@ -18,7 +18,7 @@ def SetDefaultParameters(paramsDefault): """Sets up the default parameters.""" # Time integration solver parameters - paramsDefault['TimeIntegrationMethod'] = 'RosenbrockFixed' # options are 'ForwardEuler', 'RungeKutta4', 'RungeKuttaFehlberg', 'Rosenbrock' + paramsDefault['TimeIntegrationMethod'] = 'RosenbrockFixed'# options are 'ForwardEuler', 'RungeKutta4', 'RungeKuttaFehlberg', 'Rosenbrock' and 'RosenbrockFixed' paramsDefault['nStepMax'] = 10**6 # maximum number of timesteps to allow before error paramsDefault['DeltaDesired'] = 1.0e-5 # desired Delta value to use in numerical solvers such as Runge-Kutta-Fehlberg and Rosenbrock paramsDefault['AgeMinDefault'] = 1.0 # Myr - default age to start evolutionary tracks @@ -26,7 +26,7 @@ def SetDefaultParameters(paramsDefault): paramsDefault['deltaJac'] = 1.0e-5 # pertubation to use when calculating Jacobian for Rosenbrock solver paramsDefault['CoefficientsRB'] = _CoefficientsRB() # all coefficents needed for the Rosenbrock solver paramsDefault['dAgeMin'] = 1.0e-5 # Myr - minimum timestep to allow - paramsDefault['dAgeMax'] = 5000.0 # Myr - maximum timestep to allow + paramsDefault['dAgeMax'] = 50.0 # Myr - maximum timestep to allow # Physical processes to include paramsDefault['CoreEnvelopeDecoupling'] = True # should core envelope decoupling be included diff --git a/src/mors/rotevo.py b/src/mors/rotevo.py index bcb7fc8..adb5c2c 100644 --- a/src/mors/rotevo.py +++ b/src/mors/rotevo.py @@ -600,7 +600,9 @@ def _EvolveRotationStepRBFixed(Mstar=None,Age=None,OmegaEnv=None,OmegaCore=None, CoefficientsRB = params['CoefficientsRB'] # Get time step - dAge = min(0.1 * np.power(Age, 0.75), dAgeMax) + dAge = 0.1 * np.power(Age, 0.75) + dAge = min( dAge , dAgeMax ) + dAge = min( dAge , params['dAgeMax'] ) dAgeNew = dAge # Setup array to hold integration values diff --git a/tests/test_spada_RB.py b/tests/test_spada_RB.py index ea68a10..ff25adc 100644 --- a/tests/test_spada_RB.py +++ b/tests/test_spada_RB.py @@ -5,8 +5,8 @@ TEST_DATA = ( ((0.128, 45.2, 8.5e1),(0.21264087, 1.68629162e+31, 1.74475018e+28)), ((1.113, 17.7, 3.2e3),(1.16581971, 6.81767904e+33, 7.94621466e+28)), - ((0.995, 1.005, 1.0e4),(1.48938741e+00, 7.80623475e+33, 3.11812348e+28)), - ((1.000, 1.00, 1.0e4),(1.52623102e+00, 8.13153012e+33, 3.23080690e+28)), + ((0.995, 1.005, 1.0e4),(1.48910765e+00, 7.80659378e+33, 3.16581356e+28)), + ((1.000, 1.00, 1.0e4),(1.52588718e+00, 8.13197065e+33, 3.29155751e+28)), ) @pytest.mark.parametrize("inp,expected", TEST_DATA)