From a4efb10f0e54bf317e06b97c5fdbf7d8fb4009aa Mon Sep 17 00:00:00 2001 From: Michael Hines Date: Sun, 5 Jan 2025 13:57:52 -0500 Subject: [PATCH] cvode and condition_order args --- args.py | 13 +++++++++++++ ringtest.py | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/args.py b/args.py index 0c43683..cec9c97 100644 --- a/args.py +++ b/args.py @@ -42,6 +42,19 @@ type=float, default=100.) +parser.add_argument("-method", + dest='method', + metavar='N', + help="0-fixed, 1-global cvode, 2-local cvode", + type=int, + default=0) + +parser.add_argument("-2nd_order_thresh", + dest='thresh_order2', + action='store_true', + help="2nd order correct threshold detection (cvode only)", + default=False) + parser.add_argument("-gran", metavar='N', help="global Random123 index (default 0)", diff --git a/ringtest.py b/ringtest.py index 00345ca..ebd5141 100644 --- a/ringtest.py +++ b/ringtest.py @@ -24,6 +24,12 @@ # stop time of simulation tstop = args.tstop +# Which integration method to use +method = args.method + +# Cvode threshold detection --- first or second order +condition_order = 2 if args.thresh_order2 is True else 1 + # whether to randomize cell parameters randomize_parameters = args.rparm @@ -76,6 +82,9 @@ print ("%s %s" % (str(nbranch), str(ncompart))) print ("nring=%d\ncell per ring=%d\nncell_per_type=%d" % (nring, ncell, ncell_per_type)) print ("ntype=%d" % ntype) + methname=["fixed", "global vardt, ", "local vardt, "] + co = "condition_order="+str(condition_order) if method else "" + print ("method = %s %s" % (methname[method], co)) #from cell import BallStick h.load_file("cell.hoc") @@ -195,6 +204,11 @@ def create_rings(): ## Initialize ## + if method > 0: + h.cvode.condition_order(condition_order) + h.cvode.active(1) + if (method == 2): + h.cvode.use_local_dt(1) pc.set_maxstep(10) h.stdinit() timeit("initialized", settings.rank)