# let solution settle
    transient = fhn.compute('trans')
    fhn.set(ics=transient(10),
            tdata=[0,20])

    # More of your code here


# Your code here for the frequency plot



1/0  # comment this to apply phase plane picture to whatever
# are the current parameters of FHN model

## Optional code

fp_coord = pp.find_fixedpoints(fhn, n=25, eps=1e-6)[0]
fp = pp.fixedpoint_2D(fhn, Point(fp_coord), eps=1e-6)

nulls_x, nulls_y = pp.find_nullclines(fhn, 'x', 'y', n=3, eps=1e-6,
                                      max_step=0.1, fps=[fp_coord])
plt.figure(3)
pp.plot_PP_fps(fp)
plt.plot(nulls_x[:,0], nulls_x[:,1], 'b')
plt.plot(nulls_y[:,0], nulls_y[:,1], 'g')

plt.show()

Beispiel #2
0
    plot_PP_vf_custom(ode_sys, 'vf_data', scale_exp=-0.25)

plotter.arrangeFig([1,1], {'11': {'name': 'PP',
                                  'scale': DOI,
                                  'layers': ['fp_data', 'manifold_data', 'manifold_metadata'],
                                  'axes_vars': ['phi', 'nu']}
                           })

# find fixed points
fp_coords = pp.find_fixedpoints(ode_sys, eps=1e-6)

# 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 points found is also provided to help locate the nullclines.
if all_plots:
    nulls_x, nulls_y = pp.find_nullclines(ode_sys, 'phi', 'nu', n=3,
                                      eps=1e-6, max_step=0.1, fps=fp_coords)

# plot the nullclines
if all_plots:
    plt.plot(nulls_x[:,0], nulls_x[:,1], 'b')
    plt.plot(nulls_y[:,0], nulls_y[:,1], 'g')

# plot the fixed points
fps = []
for fp_coord in fp_coords:
    fps.append( pp.fixedpoint_2D(ode_sys, dst.Point(fp_coord)) )

saddle = fps[1]

plotter.set_active_layer('fp_data')
plot_PP_fp(saddle, 'fp_data', do_evecs=True, markersize=7)
# phase plane tools are in the Toolbox module aliased as 'pp'

# plot vector field, using a scale exponent to ensure arrows are well spaced
# and sized
plot_PP_vf_custom(ode_sys, 'phi', 'nu', scale_exp=-0.25)

# find fixed points
fp_coords = pp.find_fixedpoints(ode_sys, eps=1e-6)

# 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 points found is also provided to help locate the nullclines.
nulls_x, nulls_y = pp.find_nullclines(ode_sys,
                                      'phi',
                                      'nu',
                                      n=3,
                                      eps=1e-6,
                                      max_step=0.1,
                                      fps=fp_coords)

# plot the fixed points
fps = []
for fp_coord in fp_coords:
    fps.append(pp.fixedpoint_2D(ode_sys, dst.Point(fp_coord)))

for fp_obj in fps:
    plot_PP_fps_custom(fp_obj, do_evecs=True, markersize=7, flip_coords=True)

# plot the nullclines
plt.plot(nulls_x[:, 0], nulls_x[:, 1], 'b')
plt.plot(nulls_y[:, 0], nulls_y[:, 1], 'g')
Beispiel #4
0
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)

# plot the nullclines
plt.plot(nulls_x[:,0], nulls_x[:,1], 'b')
plt.plot(nulls_y[:,0], nulls_y[:,1], 'g')

# plot the trajectory
plt.plot(pts['x'], pts['y'], 'k-o', linewidth=2)

# plot the event points
plt.plot(evs['x'], evs['y'], 'rs')
Beispiel #5
0
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)
scope.update(new_fnspecs)
jac_fn = dst.expr2fun(jac, ensure_args=['t'],**scope)

# add fixed points to the phase portrait
for i in range(0,len(fp_coord)):
	fp = pp.fixedpoint_2D(dmModel, dst.Point(fp_coord[i]),
						jac = jac_fn, eps=1e-8)
# Your code here for the frequency plot
Is = linspace(0, 2, 100)
fs = []

for I in Is:
    fs.append(freq(I))

plt.figure(2)
plt.plot(Is, fs, 'k.')
plt.xlabel('I')
plt.ylabel('frequencies')

1/0  # comment this to apply phase plane picture to whatever
# are the current parameters of FHN model

## Optional code

fp_coord = pp.find_fixedpoints(fhn, n=25, eps=1e-6)[0]
fp = pp.fixedpoint_2D(fhn, Point(fp_coord), eps=1e-6)

nulls_x, nulls_y = pp.find_nullclines(fhn, 'x', 'y', n=3, eps=1e-6,
                                      max_step=0.1, fps=[fp_coord])
plt.figure(3)
pp.plot_PP_fps(fp)
plt.plot(nulls_x[:,0], nulls_x[:,1], 'b')
plt.plot(nulls_y[:,0], nulls_y[:,1], 'g')

plt.show()