def testHC(r, cc = .99): b3 = auto.run(start((2,2,2,2,2), (3,.99, r), 1)) periodic = auto.run(b3('HB1'),IPS=2,ICP=[11, 1,2],NMX=200,DS=0.001,DSMAX=0.01,UZR={-11:35}) homoclinicR =auto.run(periodic,IPS=9,ICP=[1,2,3],NPR=60,DS=.01, NMX=800, STOP=['BP1', 'RG1', "LP1"],ISTART=4) homoclinicL =auto.run(periodic,IPS=9,ICP=[1,2,3],NPR=60,DS=-.01,NMX=800,STOP=['BP1', 'RG1'],ISTART=4) return (reduce(__add__, [homoclinicR, homoclinicL], b3), periodic)
def continue_equilibrium(init, params=None, **kwargs): """Continue equilibrium forwards and backwards in I from init point.""" kwargs.setdefault('PAR', add_default_params(params, exclude=['I'])) equilibrium = auto.run(init, c='equilibrium', **kwargs) equilibrium += auto.run(init, c='equilibrium', DS='-', **kwargs) equilibrium = auto.relabel(auto.merge(equilibrium)) # get single curve with unique labels return equilibrium
def contR1(): ic = (2,2,2,2,2) b = auto.run(start(ic, (3, 2.0, 200), 1), ICP=[1,2]) l1 = auto.run(auto.load(b('LP1'), ISP=2, SP=["HB"], ISW=2, ICP=[2,1], DS=-.001, UZSTOP={1:[0,4], 2:[.001,4]})) l2 = auto.run(auto.load(b('LP2'), ISP=2, SP=["HB"], ISW=2, ICP=[2,1], DS=-.001, UZSTOP={1:[0,4], 2:[.001,4]})) hb = auto.run(auto.load(b('HB1'), ISP=2, SP=["LP2"], ISW=2, DS=.001, UZSTOP={1:[0,4], 2:[.001,4]})) return (b, l1, l2, hb)
def run_time(self, conf): ts = None print self.figure, conf ax = self.figure[self.gen_figname(conf['icp'])].add_subplot(111) figname = self.name + '_' + self.gen_figname(conf['icp']) + '.png' aconf, conf = self.split_config(conf) name = conf['name'] for k in xrange(conf.get('n_start_repeat', 50)): #Compute time-series print 'Start ts integration %d' % k self.start_log() if ts: ts = auto.run(ts, c = self.name + conf.get('sc')) else: ts = auto.run(ts, e = self.e, c = self.name + conf.get('sc')) ts = auto.rl(ts) ts = ts(len(ts.getLabels())) self.stop_log() savefname = get_time() + '_' + self.name + '_' + conf.get('name') aconf['c'] = self.name + conf.get('c') aconf['sv'] = savefname branch = xauto.xbranch(ax = ax, figname = figname) branch.run(aconf, ts, nmx = conf['nmx']) if branch.len == 1 and branch.get_last_point()['TY'] == 'MX': branch.rm() del branch continue self.branch[name] = branch break
def obtain_Turing_prec_to_chi(chi, beta=1.0, a=0, omegaf=1.0, HBnum=1, NMX=2000, NPR=1000, DSMAX=0.0151, DS=0.0002, pmax=10.0, model='bwh_to_EQK', parset='bwh_set4'): """ Loads parameters from parset hdf5 dictionary file, save in parameters txt file and perform continuation """ p = loadparset(parset) p['chi'] = chi p['a'] = a p['omegaf'] = omegaf p['beta'] = beta a = conv_dict_to_parset_array(p) save_parset_to_txt_file(a) st0 = run(e=model, c=model, NMX=NMX, NPR=NPR, DS=DS, DSMAX=DSMAX, IPS=1, ISP=2) ind = 1 while (len(st0("HB")) < HBnum) and (ind < 100): if ind % 2: print 'at %d!' % ind st0 = run(e=model, c=model, NMX=NMX, NPR=NPR, DS=DS, DSMAX=DSMAX / (1 + ind / 20.), IPS=1, ISP=2) else: print 'neg' st0 = run(e=model, c=model, NMX=NMX, NPR=NPR, DS=-DS, DSMAX=DSMAX / (1 + ind / 20.), IPS=1, ISP=2) ind += 1 if st0("HB"): p = st0("HB1")['p'] else: p = None return p
def GetTuring(name, step=100, HBnum=1, ICP1=['P', 'dummy', 'L', 'k'], DSMAX1=0.0173, NMX1=3000, UZZ=[]): st0 = run(e=name, c=name, NMX=NMX1, NPR=1000, DS=0.000001, DSMAX=DSMAX1, IPS=1, ISP=2, UZR=UZZ, ICP=ICP1) ind = 1 while (len(st0("HB")) < HBnum) and (ind < 100): if ind % 2: print 'at %d!' % ind st0 = run(e=name, c=name, NMX=NMX1, NPR=1000, DS=0.000133, DSMAX=DSMAX1 / (1 + ind / 20.), IPS=1, ISP=2, UZR=UZZ, ICP=ICP1) else: print 'neg' st0 = run(e=name, c=name, NMX=NMX1, NPR=1000, DS=-0.000133, DSMAX=DSMAX1 / (1 + ind / 20.), IPS=1, ISP=2, UZR=UZZ, ICP=ICP1) ind += 1 if st0("HB"): st1 = run(st0('HB%d' % min(HBnum, len(st0("HB")))), ISP=1, IPS=2, ICP=ICP1, NMX=step, NPR=1000, DSMAX=DSMAX1, DS=0.00001) else: st1 = [] return st0, st1
def continue_bifurcation(init, continuation_param, continuation_param_uzstop=None, params=None, **kwargs): """Continue bifurcation point in init for changing continuation_param. """ kwargs.setdefault('PAR', add_default_params(params, exclude=['I', continuation_param])) kwargs.setdefault('ICP', ['I', continuation_param, 'PERIOD']) if continuation_param_uzstop is not None: kwargs.setdefault('UZSTOP', {'I': [-20, 100], continuation_param: continuation_param_uzstop}) bifurcation_point = auto.run(init, c='2par', **kwargs) bifurcation_point += auto.run(init, c='2par', DS='-', **kwargs) bifurcation_point = auto.relabel(auto.merge(bifurcation_point)) return bifurcation_point
def runCMD(): if RESTART == 1: print "开始重新编译打包..." removeCMD() else: print "开始打包..." print "代码重新整合中..." auto.run() #执行打包命令 print "项目打包中..." return _runCMD()
def hbs(r): b = auto.run(start((2,2,2,2,2), (3,.05,r), 1)) hbl = _2parFB(b('HB1')) hbl = np.row_stack( [np.column_stack([hbl[0]['PAR(1)'], hbl[0]['PAR(2)']])[::-1,:], np.column_stack([hbl[1]['PAR(1)'], hbl[1]['PAR(2)']])]) b = auto.run(start((2,2,2,2,2), (3,2.5,r), 1)) hbh = _2parFB(b('HB1')) hbh = np.row_stack( [np.column_stack([hbh[0]['PAR(1)'], hbh[0]['PAR(2)']])[::-1,:], np.column_stack([hbh[1]['PAR(1)'], hbh[1]['PAR(2)']])]) return (hbl, hbh)
def runCMD (): if RESTART == 1: print "开始重新编译打包..." removeCMD() else: print "开始打包..." cmd = "rm -r -f "+PROJDIR+PROJNAME+"/assets" os.system(cmd) print "代码重新整合中..." auto.run() #执行打包命令 print "项目打包中..." return _runCMD()
def scanforHB(er = (2,0, -.1), r = 2000): ic = (2,2,2,2,2) hbs = [] hbis = [] hb1 = None for e in apply(np.arange, er): b = auto.run(start(ic, (3, e, r), 1), ICP=[1,2]) h = b("HB") if h: hbs.append( (h[0].PAR['PAR(1)'], e) ) if not hb1: hb1 = h[0] hbis.append(h) hbc = auto.run(auto.load(hb1, ISW=2, DS=.001, UZSTOP={1:[0,4], 2:[.001,4]})) return (np.array(hbs), hbc, hbis)
def integrate(ic, p, chi=0.0, a=0, omegaf=1.0, NMX=10000, NPR=100, DSMAX=0.0113, DS=0.0002, Tmax=10000.0, model='tlm', parset='tlm_set10'): p = loadparset(parset) p['chi'] = chi p['a'] = a p['omegaf'] = omegaf a = conv_dict_to_parset_array(p) save_parset_to_txt_file(a) result = run(e=model, c=model, NMX=NMX, NPR=NPR, DSMAX=DSMAX, DS=DS, RL1=Tmax, ICP=[14], IPS=-2, U={ 'b': ic[0], 's1': ic[1], 's2': ic[2] }) return result, ps
def auto_orbit(self): self.model.createAutoCode(self.autoname + '.c', period=self.period) solution = auto.run(self.autoname)(2) # the last label self.period = solution["p"](11) # save new period tX = np.array(solution.toArray()) phase = tl.PI2 * tX[:, 0] X = tX[:, 1:] # save new solution return phase, np.transpose(X)
def auto_orbit(self): self.model.createAutoCode(self.autoname+'.c', period=self.period) solution = auto.run(self.autoname)(2) # the last label self.period = solution["p"](11) # save new period tX = np.array(solution.toArray()) phase = tl.PI2*tX[:, 0] X = tX[:, 1:] # save new solution return phase, np.transpose(X)
def twoDimension_Hopf(self, startState, continuationParams, stopDictList = [{'gL':10, 'Cm':50, 'I':400}, {'gL':0.1, 'Cm':10, 'I':0.1}]): global relevantHopf # locus continuation of the interesting points, requires then two parameters for continuation self.bifpar['I'] = startState['I'] numberOfIterations = 20 numberOfPlots = 1 directionList = [1, -1] r = [0 for item in directionList] direction = 1 r[0] = auto.run(startState, e='nak', c='nak', parnames= self.pnames, unames=self.unames, ICP=continuationParams, ISP=2,ILP=1, #SP=['LP','HB','BP'], # ISP: Bifurcation detection; 0=off, 1=BP(FP), 3=BP(PO,BVP), 2=all | ILP: Fold detection; 1=on, 0=off ISW=2, # ISW: Branch switching; 1=normal, -1=switch branch (BP, HB, PD), 2=switch to two-parameter continuation (LP, BP, HB, TR), 3=switch to three-parameter continuation (BP) ITNW=17, NWTN=13, NMX=numberOfIterations, NPR= 1,#int(numberOfIterations/numberOfPlots),PAR=self.bifpar, DS=direction*1e-1, DSMAX=1e-1, #STOP=[''],#STOP=['HB1'], UZSTOP= {}#stopDictList[i] # e.g. UZSTOP_criterium={'gNa':15, 'gK':1, 'gK':12, 'V3':-10, 'V3':30, 'V1':-10, 'V1':30} ) ipdb.set_trace() if True: print "Limit direction in twoDimension_Hopf" # this can give trouble when running into the BT, then it does not stop direction = -1 numberOfIterations =2000 numberOfPlots = 1 DSMAX = 1.5e-1 # adapt this, smaller to find GH, larger to prevent that the continuation gets into an infinite loop at the BT #if self.get_parameter('gL')>=0.2: DSMAX = 5e-1 # adapt this, smaller to find GH, larger to prevent that the continuation gets into an infinite loop at the BT r[1] = auto.run(startState, e='nak', c='nak', parnames= self.pnames, unames=self.unames, ICP=continuationParams, ISP=2,ILP=1, #SP=['LP','HB','BP'], # ISP: Bifurcation detection; 0=off, 1=BP(FP), 3=BP(PO,BVP), 2=all | ILP: Fold detection; 1=on, 0=off ISW=2, # ISW: Branch switching; 1=normal, -1=switch branch (BP, HB, PD), 2=switch to two-parameter continuation (LP, BP, HB, TR), 3=switch to three-parameter continuation (BP) PAR=self.bifpar, ITNW=7, NWTN=3, NMX=numberOfIterations, NPR=int(numberOfIterations/numberOfPlots), DS=direction*1e-1, DSMAX=DSMAX, #STOP=[''],#STOP=['HB1'], UZSTOP= {}#stopDictList[i] # e.g. UZSTOP_criterium={'gNa':15, 'gK':1, 'gK':12, 'V3':-10, 'V3':30, 'V1':-10, 'V1':30} #UZSTOP= {'Cm':0.08}continue_hopf ) relevantHopf = r[1].getLabel(r[1].getLabels()[-1])[-1] #relevantHopf = r1.getLabel('UZ')[0] self.plottingBranches.append(auto.merge(r[0]+r[1])) self.r_eval = r else: self.plottingBranches.append(r[0]) self.r_eval = [r[0]] self.params = continuationParams return self.plottingBranches[-1]
def full2DbdRNA_RM(r_m): b1 = auto.run(start((2,2,2,2,2), (3,.05,1.0, r_m), 1, tt=800)) td = _2parFB(b1('LP1')) td.extend(_2parFB(b1('LP2'))) if r_m >200: npts = 10000 else: npts = 2000 td.extend(_2parFB(b1('HB1'), npts)) b2 = auto.run(start((2,2,2,2,2), (3,2.5,1.0, r_m), 1)) tp = _2parFB(b2('HB1'), npts) td.extend( [tp[0][:1], tp[1][:1]]) sp = mpt(td[-2][0]) a = sp['data'][td[-1][0].keys().index('PAR(2)')] a = .89 b3 = auto.run(start((2,2,2,2,2), (3,a+.1, 1.0, r_m), 1)) periodic = auto.run(b3('HB1'), IPS=2, ICP=[1, 11], NMX=200, DS=-0.001, DSMAX=0.01, UZR={-11:35}) homoclinicR =auto.run(periodic, IPS=9, ICP=[1,2], NPR=60, NMX=800, STOP=['BP1', 'RG1', "LP1"], ISTART=4) homoclinicL =auto.run(periodic, IPS=9, ICP=[1,2], NPR=60, DS=-.01, NMX=800, STOP=['BP1', 'RG1'], ISTART=4) td.extend([homoclinicR, homoclinicL]) #return td #so far these are MXing. td = reduce(__add__, td[1:], td[0]) td = auto.relabel(td) return td
def continue_fixPoint(self, I = 0.1, UZSTOP_criterium = {'I':200}, direction = 1, tmax=300): numberOfIterations = 5000 numberOfPlots = 1 dsmax = 1e0 self.init_FP_continuation(I) # start continuation at I =3 to prevent problems that may arise at I=0. restingstate = self.get_fixpoint_initiation(tmax) print "restingstate = ", restingstate, self.simfile r1= auto.run(restingstate, e='nak', c='nak', parnames= self.pnames, unames=self.unames, ICP=self.continuationParams, ISP=1,ILP=1, #SP=['LP','HB','BP'], # ISP: Bifurcation detection; 0=off, 1=BP(FP), 3=BP(PO,BVP), 2=all | ILP: Fold detection; 1=on, 0=off ISW=1, # ISW: Branch switching; 1=normal, -1=switch branch (BP, HB, PD), 2=switch to two-parameter continuation (LP, BP, HB, TR), 3=switch to three-parameter continuation (BP) PAR=self.bifpar, ITNW=17, NWTN=13, NMX=numberOfIterations, NPR=int(numberOfIterations/numberOfPlots), DS=direction*1e-1, DSMAX=dsmax, #STOP=[''],#STOP=['HB1'], UZSTOP= UZSTOP_criterium # e.g. UZSTOP_criterium={'gNa':15, 'gK':1, 'gK':12, 'V3':-10, 'V3':30, 'V1':-10, 'V1':30} ) self.FP_continuation = r1 self.r_eval = [r1] return r1
def full2DbdYK(): b1 = auto.run(start((2,2,2), (3,.05))) td = _2parFB(b1('LP1')) td.extend(_2parFB(b1('LP2'))) td.extend(_2parFB(b1('HB1'))) b2 = auto.run(start((2,2,2), (3,2.5))) td.extend( _2parFB(b2('HB1'))) b3 = auto.run(start((2,2,2), (3,.99))) periodic = auto.run(b3("HB1"),IPS=2,ICP=[1,11],NMX=200,DS=0.01,DSMAX=0.01,UZR={-11:35}) homoclinicR =auto.run(periodic,IPS=9,ICP=[1,2],NPR=60,STOP=['BP1'],ISTART=4) homoclinicL =auto.run(periodic,IPS=9,ICP=[1,2],NPR=60,DS=-.01,NMX=800,STOP=['BP1'],ISTART=4) td.extend([homoclinicR, homoclinicL]) td = reduce(__add__, td[1:], td[0]) td = auto.relabel(td) return td
def scanBif(chi=0.0, a=0, omegaf=1.0, beta=1.0, NMX=2000, NPR=1000, DSMAX=0.0113, DS=0.0002, pmax=10.0, model='bwh_to_EQK', parset='bwh_set4'): """ Loads parameters from parset hdf5 dictionary file, save in parameters txt file and perform continuation """ p = loadparset(parset) p['chi'] = chi p['a'] = a p['omegaf'] = omegaf p['beta'] = beta a = conv_dict_to_parset_array(p) save_parset_to_txt_file(a) bif = run(e=model, c=model, NMX=NMX, NPR=NPR, DSMAX=DSMAX, DS=DS, RL1=pmax) return bif, p
def run(self, aconf, init, startbranch = None, nmx = 100000): k = 0 if startbranch: init = startbranch.get_point(init) aconf['NMX'] = nmx savebase = aconf['sv'] while True: aconf['sv'] = savebase + '_%05d' % k k += 1 self.files.append(aconf['sv']) self.start_log() branch = auto.run(init, **aconf) branch = auto.rl(branch) self.stop_log() self.fort7parser.parse('b.' + aconf['sv']) n = len(branch.getLabels()) if n == 0: break self.len += n init = branch(branch.getLabels()[-1]) if n > 0 and init['TY'] != 'MX': self.draw(self.ax, aconf) stop = init['TY'] not in ['EP', 'RG'] if stop: break aconf['DS'] = self.get_step(branch, aconf)
def full2DbdRNA_smallr(r): #still not quite right - the periodic orbit stop #conditions need to be improved b1 = auto.run(start((2,2,2,2,2), (3,.05,r), 1)) td = _2parFB(b1('LP1')) td.extend(_2parFB(b1('LP2'))) td.extend(_2parFB(b1('HB1'))) b2 = auto.run(start((2,2,2,2,2), (3,2.5,r), 1)) td.extend( _2parFB(b2('HB1'))) hi = scanforHB(r=r)[2] p = auto.run(hi[-1][0], IPS=2, ICP=[1,2,11], NMX=1000, UZSTOP={1:2.35}, DS=-.001, DSMAX=0.01) p2 = auto.run(p, IPS=2, ICP=[2,11], NMX=100, DS=-.001, STOP=['MX1']) homoclinicR = auto.run(p2, IPS=9, ICP=[1,2], NPR=60, DS=-.01, NMX=800, ISTART=4) homoclinicL = auto.run(p2, IPS=9, ICP=[1,2], NPR=60, DS=.01, NMX=280, ISTART=4) td.extend([homoclinicR, homoclinicL]) #return td #so far these are MXing. td = reduce(__add__, td[1:], td[0]) td = auto.relabel(td) return td
def cont_WB_temperature_f(hb_continuation, outputname, gK, gNa): #Input parameters: # hb_continuation: What do we want to do? # 0: Cont Hopf in Cm # 1: Cont Hopf in T # 2: Cont Hopf in gK # 3: Cont Hopf in gK, followed by several conts in gNa # 4: Cont Hopf in gNa # outputname: Name of resultfiles that will be written import matplotlib import ipdb #matplotlib.use("Agg") import pylab, brian2, brianutils, os, json, sympy, scipy, sys, \ datetime, shelve, autoutils, auto, contextlib, inibrian from sympy import S ########### Get initial condition through brian ########### bifpar = { "I": ["0.0* uA/cm2"], "Cm": [ "1.0*uF/cm2", "1.1*uF/cm2", "1.4*uF/cm2", "1.41*uF/cm2", "1.42*uF/cm2" ], "dT": ["0. * kelvin"], "gK": [str(gK) + " * msiemens/cm2"], "gNa": [str(gNa) + " * msiemens/cm2"] #, #"q_gk": ["1.2 * kelvin/kelvin"] } unames, pnames, ini, autobifpar = inibrian.find_ini_brian( 'wangBuzsaki_brian_temperature.json', 'model2', bifpar, 'wbtemp') autobifpar['Cm'] = 1 autobifpar['gK'] = gK autobifpar['gNa'] = gNa ################# CONT FP & LC ############################ calc_period = 0 #do we want to calculate orbits? refine_hb = 0 #do we want to get the HB position even more exactly? (Not needed and also not really working :)) directionlist = [1, -1] r1_fwd = auto.run( ini, e='wbtemp', c='wbtemp', parnames=pnames, unames=unames, ICP=['I'], ISP=1, ILP=1, SP=['LP', 'HB', 'BP'], PAR=autobifpar, ITNW=17, NWTN=13, NMX=100000, NPR=100000, #NMX=113500, NPR=5000, DS=directionlist[0] * 1e-3, DSMAX=directionlist[0] * 1e-2, STOP=['HB1'], UZSTOP={}) r1_bwd = auto.run( ini, e='wbtemp', c='wbtemp', parnames=pnames, unames=unames, ICP=['I'], ISP=1, ILP=1, SP=['LP', 'HB', 'BP'], PAR=autobifpar, ITNW=17, NWTN=13, NMX=3000, NPR=3000, #NMX=113500, NPR=5000, DS=directionlist[1] * 1e-3, DSMAX=directionlist[1] * 1e-2, STOP=['HB1'], UZSTOP={}) r1 = r1_fwd + r1_bwd s1HB = r1_fwd.getLabel('HB')[0] #s1LP = r1.getLabel('LP')[0] #s1UZ = r1.getLabel('EP')[0] ################# Optional: continue orbit ####################### if calc_period: r1_period = auto.run(s1HB, e='wbtemp', c='wbtemp', parnames=pnames, unames=unames, ICP=['I', 'period'], ILP=1, ISW=1, IPS=2, ITNW=7, NWTN=3, NMX=1000, NPR=1000, DS=1e-3, DSMAX=1e-2, NTST=300, SP=['BT', 'LP', 'HB', 'BP', 'CP'], UZSTOP={}) r1_withperiod = r1 + r1_period s1HB = r1_withperiod.getLabel('HB')[0] ################# Optional: refine HB ############################ if refine_hb: try: r21 = auto.run(s1HB, e='wbtemp', c='wbtemp', parnames=pnames, unames=unames, ICP=['I', 'Cm', 'period'], ISP=1, ILP=1, SP=['LP', 'HB', 'BP'], ITNW=17, NWTN=13, NMX=10000, NPR=10000, DS=-1e-5, DSMAX=-1e-4, STOP=['HB1'], IID=3) r22 = auto.run(s1HB, e='wbtemp', c='wbtemp', parnames=pnames, unames=unames, ICP=['I', 'Cm', 'period'], ISP=1, ILP=1, SP=['LP', 'HB', 'BP'], ITNW=17, NWTN=13, NMX=10000, NPR=10000, DS=1e-5, DSMAX=1e-4, STOP=['HB1'], IID=3) r2 = r21 + r22 s2HB = r2.getLabel('HB')[0] r31 = auto.run(s2HB, e='wbtemp', c='wbtemp', parnames=pnames, unames=unames, ICP=['I', 'Cm', 'period'], ISP=1, ILP=1, SP=['LP', 'HB', 'BP'], ITNW=17, NWTN=13, NMX=10000, NPR=10000, DS=-1e-5, DSMAX=-1e-4, STOP=['HB1'], IID=3) r32 = auto.run(s2HB, e='wbtemp', c='wbtemp', parnames=pnames, unames=unames, ICP=['I', 'Cm', 'period'], ISP=1, ILP=1, SP=['LP', 'HB', 'BP'], ITNW=17, NWTN=13, NMX=10000, NPR=10000, DS=1e-5, DSMAX=1e-4, STOP=['HB1'], IID=3) r3 = r31 + r32 s3HB = r3.getLabel('HB')[0] s1HB = s3HB except: print( "Could not refine position: Bifurcation point not found. Continuing with unrefined HB." ) ################# CONT HB ############################ if (hb_continuation == 0): runHB = [0 for item in directionlist] for counter, direction in enumerate(directionlist): runHB[counter] = auto.run( s1HB, e='wbtemp', c='wbtemp', parnames=pnames, unames=unames, ICP=['Cm', 'I'], #IPS = 1 ISP=2, ILP= 1, # SP=['LP','HB','BP'], # ISP: Bifurcation detection; 0=off, 1=BP(FP), 3=BP(PO,BVP), 2=all | ILP: Fold detection; 1=on, 0=off ISW= 2, # ISW: Branch switching; 1=normal, -1=switch branch (BP, HB, PD), 2=switch to two-parameter continuation (LP, BP, HB, TR), 3=switch to three-parameter continuation (BP) ITNW=17, NWTN=13, NMX=10000, NPR=1000, #Not sure if needed: PAR=autobifpar, DS=direction * 1e-2, DSMAX=direction * 1e-1, #IID = 5, RL1=0.58, EPSL = 1e+1, EPSU = 1e+1, EPSS = 10, NTST = 500, UZSTOP={}) elif (hb_continuation == 1): runHB = [0 for item in directionlist] for counter, direction in enumerate(directionlist): runHB[counter] = auto.run( s1HB, e='wbtemp', c='wbtemp', parnames=pnames, unames=unames, ICP=['dT', 'I'], #IPS = 1 ISP=2, ILP= 1, # SP=['LP','HB','BP'], # ISP: Bifurcation detection; 0=off, 1=BP(FP), 3=BP(PO,BVP), 2=all | ILP: Fold detection; 1=on, 0=off ISW= 2, # ISW: Branch switching; 1=normal, -1=switch branch (BP, HB, PD), 2=switch to two-parameter continuation (LP, BP, HB, TR), 3=switch to three-parameter continuation (BP) ITNW=17, NWTN=13, NMX=10000, NPR=1000, #Not sure if needed: PAR=autobifpar, DS=direction * 1e-2, DSMAX=direction * 1e-1, #IID = 5, RL1=0.58, EPSL = 1e+1, EPSU = 1e+1, EPSS = 10, NTST = 500, UZSTOP={'dT': direction * 90}) runHB_fwdbwd = runHB[0] + runHB[1] elif (hb_continuation == 2): runHB = [0 for item in directionlist] for counter, direction in enumerate(directionlist): runHB[counter] = auto.run( s1HB, e='wbtemp', c='wbtemp', parnames=pnames, unames=unames, ICP=['gK', 'I'], #IPS = 1 ISP=2, ILP= 1, # SP=['LP','HB','BP'], # ISP: Bifurcation detection; 0=off, 1=BP(FP), 3=BP(PO,BVP), 2=all | ILP: Fold detection; 1=on, 0=off ISW= 2, # ISW: Branch switching; 1=normal, -1=switch branch (BP, HB, PD), 2=switch to two-parameter continuation (LP, BP, HB, TR), 3=switch to three-parameter continuation (BP) ITNW=17, NWTN=13, NMX=1000, NPR=100, #Not sure if needed: PAR=autobifpar, DS=direction * 1e-2, DSMAX=direction * 1e-1, #IID = 5, RL1=0.58, EPSL = 1e+1, EPSU = 1e+1, EPSS = 10, NTST = 500, UZSTOP={}) runHB_fwdbwd = runHB[0] + runHB[1] elif (hb_continuation == 3): runHB_gk = [0 for item in directionlist] runHB_gna = [0 for item in directionlist] #continue in gk for counter, direction in enumerate(directionlist): runHB_gk[counter] = auto.run( s1HB, e='wbtemp', c='wbtemp', parnames=pnames, unames=unames, ICP=['gK', 'I', 'gNa'], #IPS = 1 ISP=2, ILP= 1, # SP=['LP','HB','BP'], # ISP: Bifurcation detection; 0=off, 1=BP(FP), 3=BP(PO,BVP), 2=all | ILP: Fold detection; 1=on, 0=off ISW= 2, # ISW: Branch switching; 1=normal, -1=switch branch (BP, HB, PD), 2=switch to two-parameter continuation (LP, BP, HB, TR), 3=switch to three-parameter continuation (BP) ITNW=17, NWTN=13, NMX=1000, NPR=100, #Not sure if needed: PAR=autobifpar, DS=direction * 1e-2, DSMAX=direction * 1e-1, #IID = 5, RL1=0.58, EPSL = 1e+1, EPSU = 1e+1, EPSS = 10, NTST = 500, UZSTOP={'gK': direction * 75}) runHB_gna[counter] = auto.run( s1HB, e='wbtemp', c='wbtemp', parnames=pnames, unames=unames, ICP=['gNa', 'I', 'gK'], #IPS = 1 ISP=2, ILP= 1, # SP=['LP','HB','BP'], # ISP: Bifurcation detection; 0=off, 1=BP(FP), 3=BP(PO,BVP), 2=all | ILP: Fold detection; 1=on, 0=off ISW= 2, # ISW: Branch switching; 1=normal, -1=switch branch (BP, HB, PD), 2=switch to two-parameter continuation (LP, BP, HB, TR), 3=switch to three-parameter continuation (BP) ITNW=17, NWTN=13, NMX=1000, NPR=100, #Not sure if needed: PAR=autobifpar, DS=direction * 1e-2, DSMAX=direction * 1e-1, #IID = 5, RL1=0.58, EPSL = 1e+1, EPSU = 1e+1, EPSS = 10, NTST = 500, UZSTOP={'gNa': direction * 75}) #take every gk point and continue it in gN runHB_fwdbwd_gk = runHB_gk[0] + runHB_gk[1] runHB_fwdbwd_gk = auto.relabel(runHB_fwdbwd_gk) start_idxs = runHB_fwdbwd_gk.getLabels() for pointcounter, startpoint in enumerate(start_idxs): for listcounter, direction in enumerate(directionlist): runHB_fwdbwd_gk += auto.run( runHB_fwdbwd_gk.getLabel(startpoint), e='wbtemp', c='wbtemp', parnames=pnames, unames=unames, ICP=['gNa', 'I', 'gK'], #IPS = 1 ISP=2, ILP= 1, # SP=['LP','HB','BP'], # ISP: Bifurcation detection; 0=off, 1=BP(FP), 3=BP(PO,BVP), 2=all | ILP: Fold detection; 1=on, 0=off ISW= 2, # ISW: Branch switching; 1=normal, -1=switch branch (BP, HB, PD), 2=switch to two-parameter continuation (LP, BP, HB, TR), 3=switch to three-parameter continuation (BP) ITNW=17, NWTN=13, NMX=1000, NPR=100, #Not sure if needed: PAR=autobifpar, DS=direction * 1e-2, DSMAX=direction * 1e-1, #IID = 5, RL1=0.58, EPSL = 1e+1, EPSU = 1e+1, EPSS = 10, NTST = 500, UZSTOP={'gK': 0.1}) #oppsite: take every gna point and cont it in gK runHB_fwdbwd_gna = runHB_gna[0] + runHB_gna[1] runHB_fwdbwd_gna = auto.relabel(runHB_fwdbwd_gna) start_idxs = runHB_fwdbwd_gna.getLabels() #run_gkna = [0 for i in range(len(start_idxs)*2)] for pointcounter, startpoint in enumerate(start_idxs): for listcounter, direction in enumerate(directionlist): runHB_fwdbwd_gna += auto.run( runHB_fwdbwd_gna.getLabel(startpoint), e='wbtemp', c='wbtemp', parnames=pnames, unames=unames, ICP=['gK', 'I', 'gNa'], #IPS = 1 ISP=2, ILP= 1, # SP=['LP','HB','BP'], # ISP: Bifurcation detection; 0=off, 1=BP(FP), 3=BP(PO,BVP), 2=all | ILP: Fold detection; 1=on, 0=off ISW= 2, # ISW: Branch switching; 1=normal, -1=switch branch (BP, HB, PD), 2=switch to two-parameter continuation (LP, BP, HB, TR), 3=switch to three-parameter continuation (BP) ITNW=17, NWTN=13, NMX=1000, NPR=100, #Not sure if needed: PAR=autobifpar, DS=direction * 1e-2, DSMAX=direction * 1e-1, #IID = 5, RL1=0.58, EPSL = 1e+1, EPSU = 1e+1, EPSS = 10, NTST = 500, UZSTOP={'gK': 0.1}) runHB_fwdbwd = runHB_fwdbwd_gk + runHB_fwdbwd_gna test0 = runHB_fwdbwd['I'] test1 = runHB_fwdbwd['gNa'] runHB_fwdbwd = auto.klb(runHB_fwdbwd) runHB_fwdbwd = auto.dlb(runHB_fwdbwd) #take every gna point and continue it in gK elif (hb_continuation == 4): runHB = [0 for item in directionlist] #continue in gk for counter, direction in enumerate(directionlist): runHB[counter] = auto.run( s1HB, e='wbtemp', c='wbtemp', parnames=pnames, unames=unames, ICP=['gNa', 'I', 'gK'], #IPS = 1 ISP=2, ILP= 1, # SP=['LP','HB','BP'], # ISP: Bifurcation detection; 0=off, 1=BP(FP), 3=BP(PO,BVP), 2=all | ILP: Fold detection; 1=on, 0=off ISW= 2, # ISW: Branch switching; 1=normal, -1=switch branch (BP, HB, PD), 2=switch to two-parameter continuation (LP, BP, HB, TR), 3=switch to three-parameter continuation (BP) ITNW=17, NWTN=13, NMX=1000, NPR=100, #Not sure if needed: PAR=autobifpar, DS=direction * 1e-2, DSMAX=direction * 1e-1, #IID = 5, RL1=0.58, EPSL = 1e+1, EPSU = 1e+1, EPSS = 10, NTST = 500, UZSTOP={'gNa': direction * 75}) runHB_fwdbwd = runHB[0] + runHB[1] else: print("Please specify HB cont mode!") rhbt = runHB_fwdbwd + r1 auto.save(rhbt, outputname) #for "Run HB temperature" ipdb.set_trace()
def integrate_to_equilibrium(params=None, **kwargs): """Integrate the system using Euler's algorithm and return the last point.""" kwargs.setdefault('PAR', add_default_params(params)) integration = auto.run(e='drosophila', c='integration', **kwargs) return integration()[-1] # last point
f2 = -y + p1 * p2 * (1 - x) * sympy.exp(y) - p3 * y return f1, f2 # continue in par 2 start = auto.run(e='ab', c='ab.1', unames={ 1: 'x', 2: 'y' }, parnames={ 1: 'p1', 2: 'p2', 3: 'p3' }, U={ 'x': 0, 'y': 0 }, PAR={ 'p1': 0, 'p2': 8, 'p3': 3 }, ICP=['p2'], RL1=14) ab = auto.run(start('EP2'), c='ab.2') ab = auto.rl(ab) auto.sv(ab, 'ab')
def stptsRNA(): b1 = auto.run(start((2,2,2,2,2), (3,.05,2000), 1)) b2 = auto.run(start((2,2,2,2,2), (3,2.5, 2000), 1)) return (b1('LP1'), b1('LP2'), b1('HB1'), b2('HB1'))
def _2parFB(pt, npts=2000): fw = auto.run(auto.load(pt, ISW=2, DS=.001, UZSTOP={1:[0,4], 2:[.001,4]}, NMX=npts)) bw = auto.run(auto.load(pt, ISW=2, DS=-.001, UZSTOP={1:[0,4], 2:[.001,4]}, NMX=npts)) return [fw, bw]
pdb.set_trace() ###Ab hier wirds interessant!#### ################# CONT FP & LC ############################ #autobifpar['Cm'] = 0.015 r1_fwd = auto.run( [float(getattr(states, j)[0][-1]) for j in var], e='nak', c='nak', parnames=pnames, unames=unames, ICP=['I', 'Cm', 'period'], ISP=1, ILP=1, SP=['LP', 'HB', 'BP'], ITNW=17, NWTN=13, NMX=13000, NPR=1300, #NMX=113500, NPR=5000, DS=1e-6, DSMAX=1e-5, #STOP=['HB1'], IID=3, UZSTOP={}) r1_fwd = auto.run( [float(getattr(states, j)[0][-1]) for j in var], e='nak', c='nak', parnames=pnames, unames=unames,
def continue_limit_cycle(init, params=None, **kwargs): """Continue limit cycle in I from init point (for example a Hopf bifurcation).""" kwargs.setdefault('PAR', add_default_params(params, exclude=['I'])) return auto.run(init, c='tube', **kwargs)
################# CONT FP & LC ############################ calc_period = 0 #do we want to calculate the orbits? refine_hb = 0 #do we want to get the HB position even more exactly? (Not needed and also not really working :)) directionlist = [1, -1] r1_fwd = auto.run( ini, e='tm_new', c='tm_new', parnames=pnames, unames=unames, ICP=['I', 'Cm'], ISP=1, ILP=1, SP=['LP', 'HB', 'BP'], PAR=autobifpar, ITNW=17, NWTN=13, NMX=200000, NPR=200000, #NMX=113500, NPR=5000, DS=directionlist[0] * 1e-3, DSMAX=directionlist[0] * 1e-2, STOP=['HB1'], UZSTOP={}) r1_bwd = auto.run( ini, e='tm_new', c='tm_new', parnames=pnames,