Skip to content

Commit 1831cb2

Browse files
committed
fix CVODE defaults and set default tolerances to more sane levels
1 parent 9498a87 commit 1831cb2

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

pysces/PyscesModel.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3014,14 +3014,17 @@ def InitialiseModel(self):
30143014

30153015
# CVode options
30163016
self.mode_integrate_all_odes = False # only available with CVODE
3017-
self.__settings__["cvode_abstol"] = 1.0e-15 # absolute tolerance
3018-
# self.__settings__["cvode_abstol_max"] = 1.0e-3 # not used anymore
3019-
# self.__settings__["cvode_abstol_factor"] = 1.0e-6 # not used in Assimulo
3017+
self.__settings__["cvode_abstol"] = 1.0e-9 # absolute tolerance
30203018
self.__settings__["cvode_reltol"] = 1.0e-9 # relative tolerance
3021-
# self.__settings__["cvode_auto_tol_adjust"] = True # not used in Assimulo
3022-
self.__settings__["cvode_mxstep"] = 1000 # max step default
3019+
self.__settings__["cvode_mxstep"] = 5000 # max step default
30233020
# print some pretty stuff after a simulation
30243021
self.__settings__["cvode_stats"] = False
3022+
# the step size to be attempted on the first step.
3023+
self.__settings__["cvode_h0"] = 0.0
3024+
self.__settings__["cvode_hmax"] = 0.0 # the maximum absolute step size allowed.
3025+
self.__settings__["cvode_hmin"] = 0.0 # the minimum absolute step size allowed.
3026+
# maximum order to be used by the solver
3027+
self.__settings__["cvode_mxord"] = 5
30253028

30263029
if self.__HAS_PIECEWISE__ and self.__settings__["cvode_reltol"] <= 1.0e-9:
30273030
self.__settings__["cvode_reltol"] = 1.0e-6
@@ -3859,12 +3862,20 @@ def ffull(t, s):
38593862
sim = CVode(problem)
38603863
# for direct access to the solver class
38613864
self._solver = sim
3865+
3866+
# initialise CVODE settings
38623867
if self.__settings__["cvode_stats"]:
38633868
sim.verbosity = 10
38643869
else:
38653870
sim.verbosity = 40
38663871
sim.atol = self.__settings__["cvode_abstol"]
38673872
sim.rtol = self.__settings__["cvode_reltol"]
3873+
sim.maxsteps = self.__settings__["cvode_mxstep"]
3874+
sim.inith = self.__settings__["cvode_h0"]
3875+
sim.maxh = self.__settings__["cvode_hmax"]
3876+
sim.minh = self.__settings__["cvode_hmin"]
3877+
sim.maxord = self.__settings__["cvode_mxord"]
3878+
38683879
t, sim_res = sim.simulate(self.sim_end, ncp=0, ncp_list=self.sim_time)
38693880
# needed because CVode adds extra time points around discontinuity
38703881
t = numpy.array(t)

0 commit comments

Comments
 (0)