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 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
예제 #3
0
 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]
limit_branch_points = {
    "dR": limit_branch_point("UZ5"),
    "dH": limit_branch_point("UZ3"),
    "dP": limit_branch_point("UZ8")
}

fold_points = {
    "dR": fold_plot("UZ2"),
    "dH": fold_plot("UZ4"),
    "dP": fold_plot("UZ5")
}

execfile('dispersal_two_parameter_analyses.py')

dX_K_plot = auto.merge(dX_K_plot)
dX_dY_plot = auto.merge(dX_dY_plot)
start_point_analysis = auto.merge(start_point_analysis)

auto.rl(start_point_analysis)

#Plots to look at the raw bifurcation diagrams in python. Comment out these
#commands if you don't want plots. Not needed for making final diagrams
auto.plot(start_point_analysis,
          stability=True,
          use_labels=False,
          bifurcation_x=['K'],
          bifurcation_y=['MAX H_1'],
          coloring_method="type",
          use_symbols=False,
          grid=False)
limit_branch_points = {"dR":limit_branch_point("UZ5"),
                       "dH":limit_branch_point("UZ3"),
                       "dP":limit_branch_point("UZ8")
                       }

fold_points = {"dR":fold_plot("UZ2"),
                       "dH":fold_plot("UZ4"),
                       "dP":fold_plot("UZ5")
                       }


execfile('dispersal_two_parameter_analyses.py')


dX_K_plot =auto.merge(dX_K_plot)
dX_dY_plot =auto.merge(dX_dY_plot)
start_point_analysis = auto.merge(start_point_analysis)

auto.rl(start_point_analysis)

#Plots to look at the raw bifurcation diagrams in python. Comment out these 
#commands if you don't want plots. Not needed for making final diagrams
auto.plot(start_point_analysis, 
            stability=True,use_labels=False,
            bifurcation_x= ['K'],bifurcation_y= ['MAX H_1'],
            coloring_method = "type", use_symbols= False,
            grid = False)
auto.plot(dispersal_fixed_points, 
            stability=True,use_labels=False,
            bifurcation_x= ['dR'],bifurcation_y= ['H_1'],