Beispiel #1
0
def compute_phase_plane( ode, I, alpha, ax = None ):
    ode.set( pars = dict( I = I, alpha = alpha ) )
    ode.set( xdomain = dict( theta = [-2*math.pi,2*math.pi], w = [-math.pi, math.pi] ) )
    print( '| Computing for I=%f and alpha=%f' % (I,alpha) )
    if ax is None:
        return 

    # Find fixed-points and plot phase-plots.
    pp.plot_PP_vf( ode, 'theta', 'w', N = 20, scale_exp = -0.5, alpha=0.4 )
    fixedP, nullx, nully = pp.get_PP( ode, { 'theta' : 0, 'w' : 0 }, [ 'theta', 'w' ] )
    for p in fixedP:
        ax.plot( p['theta'], p['w'], 'o', color = 'black' )
        # Now compute some trajectories near fixed-points and draw them.
        trajs = compute_trajs_near( ode, p['theta'], p['w'], err = math.pi /2.0 )
        plot( trajs, ax )

    ax.plot( *nullx.T, '-.', color = 'blue' )
    ax.plot( *nully.T, '-.', color = 'red' )
    ax.set_title( r'I=%.2f, $\alpha=%.2f$' % (I, alpha), fontsize = 8 )
Beispiel #2
0
def compute_phase_plane(ode, I, alpha, ax=None):
    ode.set(pars=dict(I=I, alpha=alpha))
    ode.set(
        xdomain=dict(theta=[-2 * math.pi, 2 * math.pi], w=[-math.pi, math.pi]))
    print('| Computing for I=%f and alpha=%f' % (I, alpha))
    if ax is None:
        return

    # Find fixed-points and plot phase-plots.
    pp.plot_PP_vf(ode, 'theta', 'w', N=20, scale_exp=-0.5, alpha=0.4)
    fixedP, nullx, nully = pp.get_PP(ode, {'theta': 0, 'w': 0}, ['theta', 'w'])
    for p in fixedP:
        ax.plot(p['theta'], p['w'], 'o', color='black')
        # Now compute some trajectories near fixed-points and draw them.
        trajs = compute_trajs_near(ode, p['theta'], p['w'], err=math.pi / 2.0)
        plot(trajs, ax)

    ax.plot(*nullx.T, '-.', color='blue')
    ax.plot(*nully.T, '-.', color='red')
    ax.set_title(r'I=%.2f, $\alpha=%.2f$' % (I, alpha), fontsize=8)
Beispiel #3
0
traj = ode.compute('polarization')
pts = traj.sample(dt=0.01)

plt.plot(pts['t'], pts['x'])
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'
Beispiel #4
0
evs = traj.getEvents('event_x_a')


# figure 1 is the time evolution of the two variables
plt.figure(1)
plt.plot(pts['t'], pts['x'], 'b', linewidth=2)
plt.plot(pts['t'], pts['y'], 'r', linewidth=2)

# figure 2 is the phase plane
plt.figure(2)
# phase plane tools are in the Toolbox module
from PyDSTool.Toolbox import phaseplane as pp

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

# only one fixed point, hence [0] at end.
# n=4 uses three starting points in the domain to find any fixed points, to an
# accuracy of eps=1e-8.
fp_coord = pp.find_fixedpoints(vdp, n=4, eps=1e-8)[0]
fp = pp.fixedpoint_2D(vdp, dst.Point(fp_coord), eps=1e-8)

# n=3 uses three starting points in the domain to find nullcline parts, to an
# accuracy of eps=1e-8, and a maximum step for the solver of 0.1 units.
# The fixed point found is also provided to help locate the nullclines.
nulls_x, nulls_y = pp.find_nullclines(vdp, 'x', 'y', n=3, eps=1e-8,
                                      max_step=0.1, fps=[fp_coord])


# plot the fixed point
Beispiel #5
0
# initial conditions
DSargs.ics = {'s1': 0.06,
							's2': 0.06}

# set the range of integration
DSargs.tdomain = [0,30]

# variable domain for the phase plane analysis
DSargs.xdomain = {'s1': [0,1], 's2': [0,1]}

# create model object
dmModel = dst.Vode_ODEsystem(DSargs)

# plot vector field
pp.plot_PP_vf(dmModel, 's1', 's2', scale_exp=-1.5)

# find dixed points of the model
fp_coord = pp.find_fixedpoints(dmModel, n=4, eps=1e-8)

# plot the null-clines
nulls_x, nulls_y = pp.find_nullclines(dmModel, 's1', 's2', n=3, \
										eps=1e-8, max_step=0.01, fps=fp_coord)

plot(nulls_x[:,0], nulls_x[:,1], 'b')
plot(nulls_y[:,0], nulls_y[:,1], 'g')

# compute the jacobian matrix
jac, new_fnspecs = dst.prepJacobian(dmModel.funcspec._initargs['varspecs'],
			['s1','s2'],dmModel.funcspec._initargs['fnspecs'])
scope = dst.copy(dmModel.pars)
evs = traj.getEvents("event_x_a")


# figure 1 is the time evolution of the two variables
plt.figure(1)
plt.plot(pts["t"], pts["x"], "b", linewidth=2)
plt.plot(pts["t"], pts["y"], "r", linewidth=2)

# figure 2 is the phase plane
plt.figure(2)
# phase plane tools are in the Toolbox module
from PyDSTool.Toolbox import phaseplane as pp

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

# only one fixed point, hence [0] at end.
# n=4 uses three starting points in the domain to find any fixed points, to an
# accuracy of eps=1e-8.
fp_coord = pp.find_fixedpoints(vdp, n=4, eps=1e-8)[0]
fp = pp.fixedpoint_2D(vdp, dst.Point(fp_coord), eps=1e-8)

# n=3 uses three starting points in the domain to find nullcline parts, to an
# accuracy of eps=1e-8, and a maximum step for the solver of 0.1 units.
# The fixed point found is also provided to help locate the nullclines.
nulls_x, nulls_y = pp.find_nullclines(vdp, "x", "y", n=3, eps=1e-8, max_step=0.1, fps=[fp_coord])


# plot the fixed point
pp.plot_PP_fps(fp)