Exemple #1
0
def figure4b1_continuation():
    """Actual continuation analysis for 4B1. Contains commands to pyDSTool.

    Performs some formatting and continuation.
    Plotting commands are contained with continuation commands to keep pycont objects together

    :return: None
    """
    # Set parameters and convert to symbolic representation
    parameters = default_parameters(i_app=0 * uA_PER_CM2)
    striped_parameters = {k: strip_dimension(v) for k, v in parameters.items()}

    v, h, i_app = symbols("v h i_app")
    striped_parameters["i_app"] = i_app
    dydt = ode_2d([v, h], 0, striped_parameters, exp=exp)

    DSargs_1 = PyDSTool.args(name="bifn_1")
    DSargs_1.pars = {"i_app": 0}
    DSargs_1.varspecs = {
        "v": PyDSTool.convertPowers(str(dydt[0])),
        "h": PyDSTool.convertPowers(str(dydt[1])),
    }
    DSargs_1.ics = {"v": 0, "h": 0}

    ode_1 = PyDSTool.Generator.Vode_ODEsystem(DSargs_1)
    ode_1.set(pars={"i_app": 0})
    ode_1.set(ics={"v": -49, "h": 0.4})
    PyCont_1 = PyDSTool.ContClass(ode_1)

    PCargs_1 = PyDSTool.args(name="EQ1_1", type="EP-C")
    PCargs_1.freepars = ["i_app"]
    PCargs_1.MaxNumPoints = 500
    PCargs_1.MaxStepSize = 0.05
    PCargs_1.MinStepSize = 1e-5
    PCargs_1.StepSize = 1e-2
    PCargs_1.LocBifPoints = "all"
    PCargs_1.SaveEigen = True
    PyCont_1.newCurve(PCargs_1)
    PyCont_1["EQ1_1"].backward()
    PyCont_1["EQ1_1"].forward()
    PyCont_1["EQ1_1"].backward()

    PyCont_1["EQ1_1"].display(["i_app", "v"], stability=True, figure=1)

    PCargs_1.name = "LC1_1"
    PCargs_1.type = "LC-C"
    PCargs_1.initpoint = "EQ1_1:H1"
    PCargs_1.freepars = ["i_app"]
    PCargs_1.MaxNumPoints = 500
    PCargs_1.MaxStepSize = 0.1
    PCargs_1.LocBifPoints = "all"
    PCargs_1.SaveEigen = True
    PyCont_1.newCurve(PCargs_1)
    PyCont_1["LC1_1"].backward()
    PyCont_1["LC1_1"].display(("i_app", "v_min"), stability=True, figure=1)
    PyCont_1["LC1_1"].display(("i_app", "v_max"), stability=True, figure=1)

    PyCont_1.plot.toggleLabels(visible="off", bytype=["P", "RG", "LP"])
    PyCont_1.plot.togglePoints(visible="off", bytype=["P", "RG", "LP"])
    plt.gca().set_title("")
Exemple #2
0
def get_pycont(param_dict):
    DSargs = dst.args(name='Whi5_Sbf_module')
    # parameters
    DSargs.pars = {
        "kasSW": 1.67,
        "kdisSW": 1.67e-4,
        "kPhWhi5": 1e-3,
        "kDphWhi5": 5e-4,
        "fac": 58,
        "kdCln12": 0.0015,
        "Sbft": 1.1,
        "Whi50": 65,
        "V": 20,
        "Cln3": 1.0
    }

    DSargs.varspecs = {
        'Cln12': 'kdCln12*fac*Sbf/Sbft - kdCln12*Cln12',
        'Sbf':
        '-kasSW*(Whi50/V+Sbf-Sbft-Whi5P)*Sbf + (kdisSW + kPhWhi5*(Cln12+Cln3))*(Sbft-Sbf)',
        'Whi5P': '(kPhWhi5*(Cln12+Cln3))*(Whi50/V-Whi5P) - kDphWhi5*Whi5P',
    }

    set_params_from_dict(DSargs.pars, param_dict)
    DSargs.ics = get_steady_states(param_dict)
    ode = dst.Generator.Vode_ODEsystem(DSargs)

    return dst.ContClass(ode)
Exemple #3
0
def __figure4b1_continuation__():
    parameters = default_parameters(i_app=0)
    v, h, i_app = symbols('v h i_app')
    parameters[0] = i_app
    dydt = ode_2d([v, h], 0, parameters, exp=exp)

    DSargs_1 = PyDSTool.args(name='bifn_1')
    DSargs_1.pars = {'i_app': 0}
    DSargs_1.varspecs = {
        'v': PyDSTool.convertPowers(str(dydt[0])),
        'h': PyDSTool.convertPowers(str(dydt[1]))
    }
    DSargs_1.ics = {'v': 0, 'h': 0}

    ode_1 = PyDSTool.Generator.Vode_ODEsystem(DSargs_1)
    ode_1.set(pars={'i_app': 0})
    ode_1.set(ics={'v': -49, "h": 0.4})
    PyCont_1 = PyDSTool.ContClass(ode_1)

    PCargs_1 = PyDSTool.args(name='EQ1_1', type='EP-C')
    PCargs_1.freepars = ['i_app']
    PCargs_1.MaxNumPoints = 500
    PCargs_1.MaxStepSize = 0.05
    PCargs_1.MinStepSize = 1e-5
    PCargs_1.StepSize = 1e-2
    PCargs_1.LocBifPoints = 'all'
    PCargs_1.SaveEigen = True
    PyCont_1.newCurve(PCargs_1)
    PyCont_1['EQ1_1'].backward()
    PyCont_1['EQ1_1'].forward()
    PyCont_1['EQ1_1'].backward()

    PyCont_1['EQ1_1'].display(['i_app', 'v'], stability=True, figure=1)

    PCargs_1.name = 'LC1_1'
    PCargs_1.type = 'LC-C'
    PCargs_1.initpoint = 'EQ1_1:H1'
    PCargs_1.freepars = ['i_app']
    PCargs_1.MaxNumPoints = 500
    PCargs_1.MaxStepSize = 0.1
    PCargs_1.LocBifPoints = 'all'
    PCargs_1.SaveEigen = True
    PyCont_1.newCurve(PCargs_1)
    PyCont_1['LC1_1'].backward()
    PyCont_1['LC1_1'].display(('i_app', 'v_min'), stability=True, figure=1)
    PyCont_1['LC1_1'].display(('i_app', 'v_max'), stability=True, figure=1)

    PyCont_1.plot.toggleLabels(visible='off', bytype=['P', 'RG'])
    PyCont_1.plot.togglePoints(visible='off', bytype=['P', 'RG'])
    plt.gca().set_title('')
Exemple #4
0
def __figure4b2_continuation__():
    parameters = default_parameters(i_app=-0.1)
    v, h, h_s, i_app = symbols('v h h_s i_app')
    parameters[0] = i_app
    dydt = ode_3d([v, h, h_s], 0, parameters, exp=exp)

    DSargs_2 = PyDSTool.args(name='bifn_2')
    DSargs_2.pars = {'i_app': 0}
    DSargs_2.varspecs = {
        'v': PyDSTool.convertPowers(str(dydt[0])),
        'h': PyDSTool.convertPowers(str(dydt[1])),
        'h_s': PyDSTool.convertPowers(str(dydt[2]))
    }
    DSargs_2.ics = {'v': 0, 'h': 0, 'h_s': 0}

    ode_2 = PyDSTool.Generator.Vode_ODEsystem(DSargs_2)
    ode_2.set(pars={'i_app': -0.1})
    ode_2.set(ics={'v': -67, "h": 0.77, "h_s": 1})
    PyCont_2 = PyDSTool.ContClass(ode_2)

    PCargs_2 = PyDSTool.args(name='EQ1_2', type='EP-C')
    PCargs_2.freepars = ['i_app']
    PCargs_2.MaxNumPoints = 300
    PCargs_2.MaxStepSize = 0.1
    PCargs_2.MinStepSize = 1e-5
    PCargs_2.StepSize = 1e-2
    PCargs_2.LocBifPoints = 'all'
    PCargs_2.SaveEigen = True
    PyCont_2.newCurve(PCargs_2)
    PyCont_2['EQ1_2'].backward()

    PyCont_2['EQ1_2'].display(['i_app', 'v'], stability=True, figure=1)

    PCargs_2.name = 'LC1_2'
    PCargs_2.type = 'LC-C'
    PCargs_2.initpoint = 'EQ1_2:H2'
    PCargs_2.freepars = ['i_app']
    PCargs_2.MaxNumPoints = 400
    PCargs_2.MaxStepSize = 0.1
    PCargs_2.StepSize = 1e-2
    PCargs_2.LocBifPoints = 'all'
    PCargs_2.SaveEigen = True
    PyCont_2.newCurve(PCargs_2)
    PyCont_2['LC1_2'].forward()
    PyCont_2['LC1_2'].display(('i_app', 'v_min'), stability=True, figure=1)
    PyCont_2['LC1_2'].display(('i_app', 'v_max'), stability=True, figure=1)

    PyCont_2.plot.toggleLabels(visible='off', bytype=['P', 'RG'])
    PyCont_2.plot.togglePoints(visible='off', bytype=['P', 'RG'])
    plt.gca().set_title('')
Exemple #5
0
def __figure3c_continuation__():
    parameters = default_parameters(i_app=0.16)
    v, h, h_s = symbols('v h h_s')
    dydt = hs_clamp([v, h, h_s], 0, parameters)

    DSargs_3 = PyDSTool.args(name='bifn_3')
    DSargs_3.pars = {'h_s': 0}
    DSargs_3.varspecs = {
        'v': PyDSTool.convertPowers(str(dydt[0])),
        'h': PyDSTool.convertPowers(str(dydt[1]))
    }
    DSargs_3.ics = {'v': 0, 'h': 0}

    ode_3 = PyDSTool.Generator.Vode_ODEsystem(DSargs_3)
    ode_3.set(pars={'h_s': 0})
    ode_3.set(ics={'v': -49, "h": 0.4})
    PyCont_3 = PyDSTool.ContClass(ode_3)

    PCargs_3 = PyDSTool.args(name='EQ1_3', type='EP-C')
    PCargs_3.freepars = ['h_s']
    PCargs_3.MaxNumPoints = 350
    PCargs_3.MaxStepSize = 0.1
    PCargs_3.MinStepSize = 1e-5
    PCargs_3.StepSize = 1e-2
    PCargs_3.LocBifPoints = 'all'
    PCargs_3.SaveEigen = True
    PyCont_3.newCurve(PCargs_3)
    PyCont_3['EQ1_3'].backward()

    PyCont_3['EQ1_3'].display(['h_s', 'v'], stability=True, figure=1)

    PCargs_3.name = 'LC1_3'
    PCargs_3.type = 'LC-C'
    PCargs_3.initpoint = 'EQ1_3:H2'
    PCargs_3.freepars = ['h_s']
    PCargs_3.MaxNumPoints = 500
    PCargs_3.MaxStepSize = 0.1
    PCargs_3.LocBifPoints = 'all'
    PCargs_3.SaveEigen = True
    PyCont_3.newCurve(PCargs_3)
    PyCont_3['LC1_3'].backward()
    PyCont_3['LC1_3'].display(('h_s', 'v_min'), stability=True, figure=1)
    PyCont_3['LC1_3'].display(('h_s', 'v_max'), stability=True, figure=1)

    PyCont_3.plot.toggleLabels(visible='off', bytype=['P', 'RG'])
    PyCont_3.plot.togglePoints(visible='off', bytype=['P', 'RG'])
    plt.gca().set_title('')
Exemple #6
0
print "\n"
print "STEADY-STATES (NUMERICAL)"
print ss

#---Bifurcation Diagram

DSargs.ics = {
    'xC': ss[1][xC],
    'xB': ss[1][xB],
    'xT': ss[1][xT],
    'xW': ss[1][xW]
}

ode = PyDSTool.Generator.Vode_ODEsystem(DSargs)

PyCont = PyDSTool.ContClass(ode)

bifPar = 'aT'

PCargs = PyDSTool.args(name='EQ1', type='EP-C')
PCargs.freepars = [bifPar]
PCargs.StepSize = 1e0
PCargs.MaxNumPoints = 200
PCargs.MaxStepSize = 1e0
PCargs.LocBifPoints = 'all'
PCargs.SaveEigen = True

print("Calculating EQ1 curve ...")
PyCont.newCurve(PCargs)
PyCont['EQ1'].forward()
PyCont['EQ1'].backward()
Exemple #7
0
import PyDSTool
#from numpy import (sin, cos, pi)
#from PyDSTool.Toolbox import phaseplane as pp
#import numpy as np
import matplotlib.pyplot as plt
from rhc_cont import Ode
import pickle
from bmk import Bmk
#from ode import Ode
from rhc_cont import RhcCont

bmk = Bmk({'ox': 0, 'oy': 0})
ode = bmk.get_ode()

#Setting Continuation class
PC = PyDSTool.ContClass(ode)


##########################################################
#
#
#
##########################################################
def inner_outer_init(PC):
    print("Initialising boundary")
    PCargs = PyDSTool.args(name='EQ1', type='EP-C')
    PCargs.freepars = ['ox']
    PCargs.MaxNumPoints = 200
    PCargs.MaxStepSize = 0.001
    PCargs.LocBifPoints = 'LP'
for i, v0 in enumerate(np.linspace(-80, 80, 20)):
    ode.set(ics={'v': v0})  # Initial condition
    # Trajectories are called pol0, pol1, ...
    # sample them on the fly to create Pointset tmp
    tmp = ode.compute('pol%3i' % i).sample()
    plt.plot(tmp['t'], tmp['v'])
plt.xlabel('time')
plt.ylabel('voltage')
plt.title(ode.name + ' multi ICs')

# Prepare the system to start close to a steady state
ode.set(pars={'i': -220})  # Lower bound of the control parameter 'i'
ode.set(ics={'v':
             -170})  # Close to one of the steady states present for i=-220

PC = dst.ContClass(ode)  # Set up continuation class

PCargs = dst.args(
    name='EQ1', type='EP-C'
)  # 'EP-C' stands for Equilibrium Point Curve. The branch will be labeled 'EQ1'.
PCargs.freepars = [
    'i'
]  # control parameter(s) (it should be among those specified in DSargs.pars)
PCargs.MaxNumPoints = 450  # The following 3 parameters are set after trial-and-error
PCargs.MaxStepSize = 2
PCargs.MinStepSize = 1e-5
PCargs.StepSize = 2e-2
PCargs.LocBifPoints = 'LP'  # detect limit points / saddle-node bifurcations
PCargs.SaveEigen = True  # to tell unstable from stable branches

PC.newCurve(PCargs)
Exemple #9
0
def SPoCK_bifurcation(alt_ics_dict):
    pardict, fndict, vardict, icsdict = init_SPoCK()

    DSargs = dst.args()
    DSargs.pars = pardict
    DSargs.varspecs = vardict
    DSargs.fnspecs = fndict
    DSargs.ics = alt_ics_dict

    DSargs.name = 'SPoCK'
    DSargs.tdata = [0, 10000]
    DSargs.xdomain = {
        'X': [0, 10**9],
        'Y': [0, 10**9],
        'A': [0, 10**9],
        'B': [0, 10**9],
    }

    spock_ode = dst.Vode_ODEsystem(DSargs)
    #spock_ode.set(pars = {'w': 1} )                    # Lower bound of the control parameter 'i'
    #traj = spock_ode.compute('test_trj')  # integrate ODE

    # setup continuation class
    PC = dst.ContClass(spock_ode)

    PCargs = dst.args(name='EQ1', type='EP-C')
    PCargs.freepars = ['A_c']
    PCargs.StepSize = 10
    PCargs.MaxNumPoints = 10000
    PCargs.MaxStepSize = 20
    PCargs.MinStepSize = 10
    PCargs.MaxTestIters = 10000
    PCargs.LocBifPoints = 'all'
    PCargs.SaveEigen = True
    PCargs.verbosity = 2
    PC.newCurve(PCargs)

    PC['EQ1'].backward()

    print(PC['EQ1'].info())

    PCargs = dst.args(name='EQ2', type='EP-C')
    PCargs.initpoint = 'EQ1:H1'
    PCargs.freepars = ['A_c']
    PCargs.StopAtPoints = ['BP']
    PCargs.MaxNumPoints = 10
    PCargs.MaxStepSize = 20
    PCargs.MinStepSize = 10
    PCargs.StepSize = 10
    PCargs.LocBifPoints = 'all'
    PCargs.SaveEigen = True
    PC.newCurve(PCargs)

    PC['EQ2'].forward()

    plot_out_path = "/Users/behzakarkaria/Documents/UCL/Barnes Lab/PhD Project/research_code/SPoCK_model/parameter_csv/fixedpoint_plots/"

    with PdfPages(plot_out_path + "bifurcation_Ac_X" + ".pdf") as pdf:
        fig1 = plt.figure(1)
        ax = fig1.add_subplot(figsize=(18, 12.5))
        #ax.set_xlim(10**0, 10**9)
        #ax.set_ylim(10**0, 10**9)
        #ax.set_xscale('symlog', basex=10)
        #ax.set_yscale('symlog', basey=10)
        PC.display(('A_c', 'X'), stability=True)
        pdf.savefig(fig1)

    with PdfPages(plot_out_path + "bifurcation_Ac_Y" + ".pdf") as pdf:
        fig2 = plt.figure(2)
        fig2.add_subplot(figsize=(18, 12.5))
        ax2 = plt.gca()
        #ax2.set_xlim(0, 10**9)
        #ax2.set_ylim(0, 10**9)
        #ax2.set_xscale('symlog', basex=10)
        #ax2.set_yscale('symlog', basey=10)
        PC.display(('A_c', 'X'), stability=True, figure=fig2)
        pdf.savefig(ax2.get_figure())
Exemple #10
0
plt.xlabel('time')  # Axes labels
plt.ylabel('x')
plt.show()

plt.plot(pts['x'], pts['y'])
plt.xlabel('x')  # Axes labels
plt.ylabel('y')
plt.show()

# plot vector field, using a scale exponent to ensure arrows are well spaced
# and sized
pp.plot_PP_vf(ode, 'x', 'y', scale_exp=-1, N=50)

plt.show()

PyCont = dst.ContClass(ode)

PCargs = dst.args(name='EQ1', type='EP-C')
PCargs.freepars = ['mu']
PCargs.StepSize = 0.1
PCargs.MaxNumPoints = 50
PCargs.MaxStepSize = 2
PCargs.MinStepSize = 1e-5
PCargs.LocBifPoints = ['all']
PCargs.verbosity = 2
PCargs.SaveEigen = True
#PCargs.StopAtPoints = 'B'
PyCont.newCurve(PCargs)

print('Computing curve...')
start = dst.clock()
def figure3c_continuation():
    """Continuation analysis for 3C. Contains commands to pyDSTool.

    Performs some formatting and continuation
    Plotting commands are contained with continuation commands to keep pycont objects together

    :return: None
    """
    # Set parameters and convert to symbolic representation
    parameters = default_parameters(i_app=0.16 * uA_PER_CM2)
    striped_parameters = {k: strip_dimension(v) for k, v in parameters.items()}

    v, h, h_s = symbols("v h h_s")
    dydt = hs_clamp(
        [v, h, h_s], 0, striped_parameters
    )  # returns a symbolic expression since variables are symbolic

    DSargs_3 = PyDSTool.args(name="bifn_3")
    DSargs_3.pars = {"h_s": 0}
    DSargs_3.varspecs = {
        "v": PyDSTool.convertPowers(str(dydt[0])),
        "h": PyDSTool.convertPowers(str(dydt[1])),
    }  # convert **2 to ^2
    DSargs_3.ics = {"v": 0, "h": 0}

    ode_3 = PyDSTool.Generator.Vode_ODEsystem(DSargs_3)
    ode_3.set(pars={"h_s": 0})
    ode_3.set(ics={"v": -49, "h": 0.4})
    PyCont_3 = PyDSTool.ContClass(ode_3)

    PCargs_3 = PyDSTool.args(name="EQ1_3", type="EP-C")
    PCargs_3.freepars = ["h_s"]
    PCargs_3.MaxNumPoints = 350
    PCargs_3.MaxStepSize = 0.1
    PCargs_3.MinStepSize = 1e-5
    PCargs_3.StepSize = 1e-2
    PCargs_3.LocBifPoints = "all"
    PCargs_3.SaveEigen = True
    PyCont_3.newCurve(PCargs_3)
    PyCont_3["EQ1_3"].backward()

    PyCont_3["EQ1_3"].display(["h_s", "v"], stability=True, figure=1)

    PCargs_3.name = "LC1_3"
    PCargs_3.type = "LC-C"
    PCargs_3.initpoint = "EQ1_3:H2"
    PCargs_3.freepars = ["h_s"]
    PCargs_3.MaxNumPoints = 500
    PCargs_3.MaxStepSize = 0.1
    PCargs_3.LocBifPoints = "all"
    PCargs_3.SaveEigen = True
    PyCont_3.newCurve(PCargs_3)
    PyCont_3["LC1_3"].backward()
    PyCont_3["LC1_3"].display(("h_s", "v_min"), stability=True, figure=1)
    PyCont_3["LC1_3"].display(("h_s", "v_max"), stability=True, figure=1)

    PyCont_3.plot.toggleLabels(
        visible="off", bytype=["P", "RG", "LPC"]
    )  # remove unused labels
    PyCont_3.plot.togglePoints(
        visible="off", bytype=["P", "RG", "LPC"]
    )  # remove unused points

    # hopefully remove rightmost hopf point - this may not always be H1?
    PyCont_3.plot.toggleLabels(visible="off", byname="H1")

    plt.gca().set_title("")
Exemple #12
0
#     # sample them on the fly to create Pointset tmp
#     trajIC = DS.compute('trajIC%i' %i).sample()    # or specify dt option to sample to sub-sample
#     pl.plot(trajIC['t'], trajIC['N'])
# pl.xlabel('time')
# pl.ylabel('N')
# pl.title(DS.name + ' multi ICs')
# pl.show()

#Analise de bifurcacao
#DS.set(pars = {'b': 0} )       # Lower bound of the control parameter
DS.set(ics={
    'N': pointSet['N'][-1],
    'P': pointSet['P'][-1]
})  # Close to one of the steady states -- pointSet['N'][-1] foi definido acima

PC = dst.ContClass(DS)  # Set up continuation class

PCargs = dst.args(
)  # 'EP-C' stands for Equilibrium Point Curve. The branch will be labeled 'EQ1'.
PCargs.name = 'EQ1'
PCargs.type = 'EP-C'
PCargs.freepars = [
    'c'
]  # control parameter(s) (it should be among those specified in DSargs.pars)
PCargs.MaxNumPoints = 100  # The following 3 parameters are set after trial-and-error
PCargs.MaxStepSize = 1
PCargs.MinStepSize = 1E-5
PCargs.StepSize = 2E-2
PCargs.LocBifPoints = 'all'  # detect limit points / saddle-node bifurcations
PCargs.verbosity = 2
PCargs.SaveEigen = True  # to tell unstable from stable branches
def compute_period(vkd=0.28, vk=1.0):
    """
    Compute period of oscillations as a function of yrel for given value of O_K

    Return dictionary: {'yrel': ndarray, 'T': ndarray}
    """
    # First check / Default set
    po_data = svu.loaddata('../data/fit_po.pkl')[0]
    lr_data = svu.loaddata('../data/fit_lra.pkl')[0]
    chi_data = svu.loaddata('../data/chi_fit_0_bee.pkl')[0]

    # yrel = 1.45
    # yrel = 1.4715  # vk=0.5
    # yrel = 1.448     # vk=0.2
    # yrel   = 2.0
    yrel = 1.3
    c0 = 5.0
    rc = 0.8 * lr_data[0]
    ver = lr_data[1]
    vbeta = 1.0
    vdelta = chi_data[1]
    v3k = 1.4 * chi_data[2]
    r5p = chi_data[3]

    # DAG metabolism parameters
    OmegaKD = 0.33
    vd = 0.45
    OmegaD = 0.26
    pars = gchidp_pars(d1=po_data[0],
                       d2=po_data[1],
                       d3=po_data[0],
                       d5=po_data[2],
                       a2=po_data[3],
                       c1=0.5,
                       rl=0.01,
                       KER=0.1,
                       rc=rc,
                       ver=ver,
                       Kkc=0.5,
                       Kkd=0.1,
                       Kdd=0.1,
                       c0=c0,
                       yrel=yrel,
                       vbeta=vbeta,
                       vdelta=vdelta,
                       v3k=v3k,
                       r5p=r5p,
                       vkd=vkd,
                       vk=vk,
                       OmegaKD=OmegaKD,
                       vd=vd,
                       OmegaD=OmegaD)
    # Generate ODE system
    DSargs = gchidp_model(pars)
    DSargs.tdomain = [0, 20]  # set the range of integration
    ode = dst.Generator.Vode_ODEsystem(
        DSargs)  # an instance of the 'Generator' class
    traj = ode.compute('steady')  # Integrate ODE
    sol = traj.sample()  # Retrieve solution
    # Intermediate plotting
    # plt.plot(sol['t'],sol['gammaa'],'k-')
    # plt.plot(sol['t'],sol['ca'],'k-')
    # plt.plot(sol['t'],sol['dag'],'r-')
    # plt.plot(sol['t'],sol['pkc'],'b-')

    # Prepare the system to start close to a steady state
    p0 = traj(DSargs.tdomain[1])
    ode.set(pars={'yrel': yrel})  # Lower bound of the control parameter 'i'
    ode.set(ics=p0)  # Start from steady-state

    # Generate PyCont object
    PC = dst.ContClass(ode)  # Set up continuation class
    # EP-C
    PCargs = dst.args(
        name='EQ1', type='EP-C', force=True
    )  # 'EP-C' stands for Equilibrium Point Curve. The branch will be labeled 'EQ1'.
    PCargs.freepars = [
        'yrel'
    ]  # control parameter(s) (it should be among those specified in DSargs.pars)
    PCargs.MaxNumPoints = 300  # The following 3 parameters are set after trial-and-error
    PCargs.MaxStepSize = 0.01
    PCargs.MinStepSize = 1e-4
    PCargs.StepSize = 1e-3
    PCargs.VarTol = 1e-5
    PCargs.FuncTol = 1e-5
    PCargs.TestTol = 1e-5
    PCargs.LocBifPoints = 'all'  # detect limit points / saddle-node bifurcations
    PCargs.SaveEigen = True  # to tell unstable from stable branches
    PC.newCurve(PCargs)
    # Compute equilibria
    print "Computing EQ-C"
    PC['EQ1'].forward()
    # PC['EQ1'].backward()
    print "done!"

    svu.savedata([PC], 'tmp_cont.pkl')
    PC = svu.loaddata('tmp_cont.pkl')[0]

    # LC-C
    PCargs = dst.args(name='LC1', type='LC-C', force=True)
    PCargs.initpoint = 'EQ1:H1'
    PCargs.freepars = ['yrel']
    PCargs.MaxNumPoints = 200
    PCargs.MaxStepSize = 0.05
    PCargs.MinStepSize = 0.01
    PCargs.StepSize = 1e-3
    # PCargs.VarTol       = 1e-6
    # PCargs.FuncTol      = 1e-4
    # PCargs.TestTol      = 1e-5
    PCargs.LocBifPoints = 'all'

    #PCargs.NumSPOut = 50;
    #PCargs.SolutionMeasures = ['max','min']
    PCargs.SolutionMeasures = 'all'
    PCargs.SaveEigen = True
    PC.newCurve(PCargs)
    # Compute Orbits
    print "Computing LC-C"
    PC['LC1'].forward()
    # PC['LC1'].backward()
    print "done!"

    # Retrieve solution
    T = PC['LC1'].sol['_T']
    yrel = PC['LC1'].sol['yrel']
    # Retrieve stabled and unstable branches
    idx = np.asarray([
        PC['LC1'].sol.labels['LC'][i]['stab']
        for i in PC['LC1'].sol.labels['LC']
    ], 'S')
    plt.plot(yrel[idx == 'S'], T[idx == 'S'], 'ko')
    plt.show()
    return {'yrel': yrel[idx == 'S'], 'T': T[idx == 'S']}
Exemple #14
0
traj = net.compute('test')
pts = traj.sample()

display(pts)
plt.show()

origin = pt.Point({"x1": 0, "x2": 0, "x3": 0, "x4": 0})

fp = ptppfixedpoint_nD(net, origin)

print(fp.evals)
print(fp.stability)

## Continuation to explore stability
PC = pt.ContClass(net)

PCargs = args()
PCargs.name = "EQ1"
PCargs.type = "EP-C"
PCargs.freepars = ["g"]
PCargs.StepSize = 1e-3
PCargs.MaxNumPoints = 100
PCargs.MaxStepSize = 1e-1
PCargs.LocBifPoints = "all"
PCargs.verbosity = 1
PCargs.SaveEigen = True
PCargs.Corrector = "Natural"
PC.newCurve(PCargs)

PC["EQ1"].forward()