本文整理汇总了Python中PyDSTool.args方法的典型用法代码示例。如果您正苦于以下问题:Python PyDSTool.args方法的具体用法?Python PyDSTool.args怎么用?Python PyDSTool.args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyDSTool
的用法示例。
在下文中一共展示了PyDSTool.args方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: model
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import args [as 别名]
def model():
K = 0.4
E = 7.0
M = 10.5
N = 15
Lambda = 0.9
Gamma = 12
R = 0.7
PP = 20
lamb_p = (K*Gamma)/M
eta_p = E*K
p_p = (Lambda*PP)/(K*Gamma*M)
nu_p = N/M
rho_p = R
# Declare names and initial values for (symbolic) parameters
lamb = dst.Par(lamb_p, 'lamb')
eta = dst.Par(eta_p, 'eta')
p = dst.Par(p_p, 'p')
nu = dst.Par(nu_p, 'nu')
rho = dst.Par(rho_p, 'rho')
# Compute nontrivial boundary equilibrium initial condition from parameters (see reference)
b_0 = 0.0
w_0 = p_p/nu_p
# Declare symbolic variables
b = dst.Var('b')
w = dst.Var('w')
t = dst.Var('t')
# Create Symbolic Quantity objects for definitions
brhs = dst.Fun(lamb*w*b*((1+eta*b)**2)*(1-b) - b,[b,w],'brhs')
wrhs = dst.Fun(p - nu*w*(1-rho*b) - lamb*w*b*((1+eta*b)**2),[b,w],'wrhs')
F = dst.Fun([brhs(b,w),wrhs(b,w)], [b,w], 'F')
jac = dst.Fun(dst.Diff(F,[b,w]), [t,b,w], 'Jacobian')
# Build Generator
DSargs = dst.args(name='fairy_circles_ode')
DSargs.fnspecs = [jac, brhs,wrhs]
DSargs.varspecs = {b:brhs(b,w) ,
w:wrhs(b,w)}
DSargs.pars = [lamb,eta,p,nu,rho]
# Use eval method to get a float value from the symbolic definitions given in
# terms of parameter values
DSargs.ics = dst.args(b=b_0, w=w_0)
return DSargs
示例2: simulate
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import args [as 别名]
def simulate(args):
modelname,ptargs,tdomain,captcnt,captincr,icdict,pardict,vardict,varspecdict,fnspecdict = args
dsargs = pdt.args()
dsargs.name = modelname
dsargs.ics = icdict
dsargs.pars = pardict
dsargs.tdata = tdomain
#dsargs.vars = vardict
dsargs.varspecs = varspecdict
#dsargs.fnspecs = fnspecdict
dsargs.algparams = {
'init_step':captincr/10.0,
'atol':0.1,
}
dsys = pdt.Generator.Vode_ODEsystem(dsargs)
#dsys = pdt.Generator.Radau_ODEsystem(dsargs)
traj = dsys.compute('demo')
pts = traj.sample()
rshape = (len(ptargs),captcnt)
result = numpy.zeros(shape = rshape,dtype = numpy.float)
result[0,:] = numpy.arange(tdomain[0],tdomain[1]+0.000000001,captincr)
for timedx in range(result.shape[1]):
itraj = traj(result[0,timedx])
for targdx in range(1,result.shape[0]):
result[targdx,timedx] = itraj[ptargs[targdx]]
return result
示例3: test_goal
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import args [as 别名]
def test_goal(mesh_pts, goal_tol=L2_tol):
errors_array = error_pts(mesh_pts)
max_error = np.max(errors_array)
result = condition(max_error, goal_tol)
return dst.args(result=result,
errors=errors_array,
max_error=max_error)
示例4: construct_system
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import args [as 别名]
def construct_system( I, alpha, init=(0,0), T = 10 ):
theta0, w0 = init
args = pd.args( name = 'Pendulum' )
args.pars = { 'alpha' : alpha, 'I' : I }
args.varspecs = { 'theta' : 'w', 'w' : 'I - sin(theta) - alpha * w' }
args.ics = { 'theta' : theta0, 'w' : w0 }
args.tdomain = [-T, T ]
ode = pd.Generator.Vode_ODEsystem( args )
return ode
示例5: make_shooter
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import args [as 别名]
def make_shooter():
# no friction
# cos(atan(x)) = 1/(sqrt(1+x^2))
Fx_str = '0' # '-speed_fn()*cos(atan2(vy,vx))'
Fy_str = '-10'
DSargs = dst.args()
DSargs.varspecs = {'vx': Fx_str, 'x': 'vx',
'vy': Fy_str, 'y': 'vy',
'Fx_out': 'Fx(x,y)', 'Fy_out': 'Fy(x,y)',
'speed': 'speed_fn(vx, vy)',
'bearing': '90-180*atan2(vy,vx)/pi'}
auxfndict = {'Fx': (['x', 'y'], Fx_str),
'Fy': (['x', 'y'], Fy_str),
'speed_fn': (['vx', 'vy'], 'sqrt(vx*vx+vy*vy)'),
}
DSargs.auxvars = ['Fx_out', 'Fy_out', 'speed', 'bearing']
DSargs.fnspecs = auxfndict
DSargs.algparams = {'init_step':0.001,
'max_step': 0.1,
'max_pts': 20000,
'maxevtpts': 2,
'refine': 5}
ground_event = dst.Events.makeZeroCrossEvent('y', -1,
{'name': 'ground',
'eventtol': 1e-3,
'precise': True,
'term': True},
varnames=['y'],
targetlang='python')
peak_event = dst.Events.makeZeroCrossEvent('vy', -1,
{'name': 'peak',
'eventtol': 1e-3,
'precise': True,
'term': False},
varnames=['vy'],
targetlang='python')
DSargs.events = [ground_event, peak_event]
DSargs.checklevel = 2
DSargs.ics = {'x': 0, 'y': 0,
'vx': 0, 'vy': 0}
DSargs.ics.update(make_vel_ics(5,20))
DSargs.name = 'cannon'
DSargs.tdomain = [0, 100000]
DSargs.tdata = [0, 10]
return dst.embed(dst.Generator.Vode_ODEsystem(DSargs))
示例6: create_model
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import args [as 别名]
def create_model():
pars = {'g': 9.8}#, 'pi': np.pi}
#ODE
ode_def = {
'x': 'vx',
'y': 'vy',
'vx': '-(pi**2)*x',
'vy': '-g',
'tt': '1.0',
}
event_bounce = dst.makeZeroCrossEvent(
'x-y', 1,
{'name': 'bounce',
'eventtol': 1e-3,
'term': True,
'active': True,
'eventinterval': 1,
'eventdelay': 1e-2,
'starttime': 0,
'precise': True
},
varnames=['x', 'y'],
targetlang='python') # targetlang is redundant (defaults to python)
DSargs = dst.args(name='bball_sin') # struct-like data
DSargs.events = [event_bounce]
#DSargs.pars = pars
#DSargs.tdata = [0, 10]
#DSargs.algparams = {'max_pts': 3000, 'stiff': False}
DSargs.algparams = {'stiff': False, 'init_step': 0.01}
DSargs.varspecs = ode_def
DSargs.pars = pars
#DSargs.xdomain = {'y': [0, 100]}
DS_fall = dst.embed(dst.Generator.Vode_ODEsystem(DSargs))
DS_fall_MI = dst.intModelInterface(DS_fall)
# Reset
ev_map = dst.EvMapping({'y': 'x+0.001', 'vy': '0.9*(vx-vy)'}, model=DS_fall)
#ev_map = dst.EvMapping({'y': '10', 'x': '20'}, model=DS_fall)
DS_BBall = dst.makeModelInfoEntry(DS_fall_MI, ['bball_sin'],
[('bounce', ('bball_sin', ev_map))])
modelInfoDict = dst.makeModelInfo([DS_BBall])
bball_sin_model = dst.Model.HybridModel(
{'name': 'Bouncing_Ball_Sinusiodal', 'modelInfo': modelInfoDict})
return bball_sin_model
示例7: args
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import args [as 别名]
def args():
"""
This function creates a PyDSTool 'args' object for the
'MorrisLecar' vector field.
"""
DSargs = PyDSTool.args()
DSargs.name = 'MorrisLecar'
DSargs.pars = {'gca':5.5000000000000000e+00, 'gk':8.0000000000000000e+00, 'gl':2.0000000000000000e+00, 'vca':1.1500000000000000e+02, 'vk':-8.4000000000000000e+01, 'vl':-5.5000000000000000e+01, 'c':2.0000000000000000e+01, 'phi':2.2000000000000000e-01, 'ic':9.0000000000000000e+01, 'v1':-1.2000000000000000e+00, 'v2':1.8000000000000000e+01, 'v3':2.0000000000000000e+00, 'v4':3.0000000000000000e+01}
DSargs.varspecs = {'v':'-(1.0/2.0)*1.0/c*( 2.0*( v-vl)*gl-( vca-v)*gca*( tanh(-1.0/v2*( v1-v))+1.0)+-2.0*ic+-2.0*( vk-v)*gk*w)', 'w':'(1.0/2.0)*cosh(-(1.0/2.0)*( v3-v)/v4)*phi*( tanh(-( v3-v)/v4)+-2.0*w+1.0)'}
DSargs.fnspecs = {'Jacobian': (['t', 'v', 'w'],
"""[[-(1.0/2.0)*1.0/c*( 2.0*gk*w+gca*( tanh(-1.0/v2*( v1-v))+1.0)+( vca-v)*gca/v2*( pow(tanh(-1.0/v2*( v1-v)),2.0)-1.0)+2.0*gl), 1.0/c*( vk-v)*gk],
[-cosh(-(1.0/2.0)*( v3-v)/v4)*phi*( pow(tanh(-( v3-v)/v4),2.0)-1.0)/v4/2.0+sinh(-(1.0/2.0)*( v3-v)/v4)*phi*( tanh(-( v3-v)/v4)+-2.0*w+1.0)/v4/4.0, -cosh(-(1.0/2.0)*( v3-v)/v4)*phi]]""")}
DSargs.ics = {'v':0.0, 'w':0.0}
DSargs.tdomain = [0,10]
return DSargs
示例8: args
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import args [as 别名]
def args():
"""
This function creates a PyDSTool 'args' object for the
'vanderpol' vector field.
"""
DSargs = PyDSTool.args()
DSargs.name = 'vanderpol'
DSargs.pars = {'epsilon':2.0000000000000001e-01}
DSargs.varspecs = {'x':'( x+y+-3.3333333333333331e-01*(x*x*x))/epsilon', 'y':'-x'}
DSargs.fnspecs = {'Jacobian': (['t', 'x', 'y'],
"""[[(-(x*x)+1.0)/epsilon, 1.0/(epsilon)],
[-1.0, 0.0]]""")}
DSargs.ics = {'x':1.0000000000000000e-02, 'y':0.0}
DSargs.tdomain = [0,10]
return DSargs
示例9: build_lin
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import args [as 别名]
def build_lin():
# make local linear system spec
if can_cache:
print("I'm not building this model twice!")
DSargs = dst.args(name='lin')
xfn_str = '(x0+yfx*y - x)/taux'
yfn_str = '(y0+xfy*x - y)/tauy'
DSargs.varspecs = {'x': xfn_str, 'y': yfn_str}
DSargs.xdomain = {'x': xdom, 'y': ydom}
DSargs.pars = {'x0': xdom_half, 'y0': ydom_half,
'xfy': 1, 'yfx': 1,
'taux': 1, 'tauy': 1}
DSargs.algparams = {'init_step':0.001,
'max_step': 0.001,
'max_pts': 10000}
DSargs.checklevel = 0
DSargs.tdata = [0, 10]
DSargs.ics = {'x': xdom_half*1.1, 'y': ydom_half*1.1}
DSargs.fnspecs = {'Jacobian': (['t', 'x', 'y'],
"""[[-1/taux, yfx/taux],
[xfy/tauy, -1/tauy]]""")}
return dst.embed(dst.Generator.Vode_ODEsystem(DSargs))
示例10: create_model
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import args [as 别名]
def create_model():
pars = {'g': 1}
icdict = {'y': 5, 'vy': 0}
y_str = 'vy'
vy_str = '-g'
event_bounce = dst.makeZeroCrossEvent('y', 0,
{'name': 'bounce',
'eventtol': 1e-3,
'term': True,
'active': True},
varnames=['y'],
parnames=['g'],
targetlang='python') # targetlang is redundant (defaults to python)
DSargs = dst.args(name='bball') # struct-like data
DSargs.events = [event_bounce]
#DSargs.pars = pars
#DSargs.tdata = [0, 10]
#DSargs.algparams = {'max_pts': 3000, 'stiff': False}
DSargs.algparams = {'stiff': False}
DSargs.varspecs = {'y': y_str, 'vy': vy_str}
DSargs.pars = pars
#DSargs.xdomain = {'y': [0, 100], 'vy': [-100, 100]}
DSargs.ics = icdict
DS_fall = dst.embed(dst.Generator.Vode_ODEsystem(DSargs))
DS_fall_MI = dst.intModelInterface(DS_fall)
ev_map = dst.EvMapping({'y': 0, 'vy': '-0.75*vy'}, model=DS_fall)
DS_BBall = dst.makeModelInfoEntry(DS_fall_MI, ['bball'],
[('bounce', ('bball', ev_map))])
modelInfoDict = dst.makeModelInfo([DS_BBall])
bball_model = dst.Model.HybridModel({'name': 'Bouncing_Ball', 'modelInfo': modelInfoDict})
return bball_model
示例11: cont
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import args [as 别名]
def cont(model, maxnum=450,maxstep=2.0,minstep=1e-5,stepsize=2e-2,direction="forward"):
ode = dst.Generator.Vode_ODEsystem(model)
# Prepare the system to start close to a steady state
# ode.set(pars = {'p': 0.078} ) # Lower bound of the control parameter 'i'
# ode.set(ics = {'b': 0.0, 'w': 0.0} ) # 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 = ['p'] # control parameter(s) (it should be among those specified in DSargs.pars)
PCargs.MaxNumPoints = maxnum # The following 3 parameters are set after trial-and-error
PCargs.MaxStepSize = maxstep
PCargs.MinStepSize = minstep
PCargs.StepSize = stepsize
PCargs.LocBifPoints = 'LP' # detect limit points / saddle-node bifurcations
PCargs.SaveEigen = True
PC.newCurve(PCargs)
if direction == "forward":
PC['EQ1'].forward()
elif direction=="backward":
PC['EQ1'].backward()
PC.display(['p','b'], stability=True, figure=3) # stable and unstable branches as solid and dashed curves, resp.
return PC
示例12: build_sys
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import args [as 别名]
def build_sys():
# we must give a name
DSargs = dst.args(name='M345_A3_Bead_on_a_rotating_hoop')
# parameters
DSargs.pars = {'g': 0,
'd': 0.3}
# rhs of the differential equation
DSargs.varspecs = {'phi': 'nu',
'nu': '-d*nu + g*sin(phi)*cos(phi) - sin(phi)'}
# initial conditions
DSargs.ics = {'phi': 0, 'nu': 0}
# set the domain of integration.
# (increased domain size to explore around phi=-pi saddle)
DSargs.xdomain = {'phi': [-2*np.pi, 2*np.pi], 'nu': [-4, 4]}
# allow tdomain to be infinite, set default tdata here
DSargs.tdata = [0, 50]
# to avoid typos / bugs, use built-in Symbolic differentation!
f = [DSargs.varspecs['phi'], DSargs.varspecs['nu']]
Df=dst.Diff(f, ['phi', 'nu'])
DSargs.fnspecs = {'Jacobian': (['t','phi','nu'],
str(Df.renderForCode()))}
# yields """[[0, 1], [g*cos(phi)*cos(phi) - g*sin(phi)*sin(phi) - cos(phi), -d]]""")}
print("Jacobian computed as:\n" + str(Df.renderForCode()))
# Make auxiliary functions to define event lines near saddle
res = pp.make_distance_to_line_auxfn('Gamma_out_plus',
'Gamma_out_plus_fn',
('phi','nu'), True)
man_pars = res['pars']
man_auxfns = res['auxfn']
res = pp.make_distance_to_line_auxfn('Gamma_out_minus',
'Gamma_out_minus_fn',
('phi','nu'), True)
man_pars.extend(res['pars'])
man_auxfns.update(res['auxfn'])
# update param values with defaults (0)
for p in man_pars:
DSargs.pars[p] = 0
if gentype in [dst.Generator.Vode_ODEsystem, dst.Generator.Euler_ODEsystem]:
targetlang = 'python'
else:
targetlang = 'c'
DSargs.fnspecs.update(man_auxfns)
ev_plus = dst.Events.makeZeroCrossEvent(expr='Gamma_out_plus_fn(%s,%s)'%('phi','nu'),
dircode=0,
argDict={'name': 'Gamma_out_plus',
'eventtol': 1e-5,
'eventdelay': 1e-3,
'starttime': 0,
'precise': False,
'active': False,
'term': True},
targetlang=targetlang,
varnames=['phi','nu'],
fnspecs=man_auxfns,
parnames=man_pars
)
ev_minus = dst.Events.makeZeroCrossEvent(expr='Gamma_out_minus_fn(%s,%s)'%('phi','nu'),
dircode=0,
argDict={'name': 'Gamma_out_minus',
'eventtol': 1e-5,
'eventdelay': 1e-3,
'starttime': 0,
'precise': False,
'active': False,
'term': True},
targetlang=targetlang,
varnames=['phi','nu'],
fnspecs=man_auxfns,
parnames=man_pars
)
DSargs.events = [ev_plus, ev_minus]
# an instance of the 'Generator' class.
print("Initializing generator...")
return gentype(DSargs)
示例13: function
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import args [as 别名]
'''
Created on Jul 18, 2016
@author: andrewkennedy
'''
import PyDSTool as dst
import numpy as np
from matplotlib import pyplot as plt
# we must give a name
DSargs = dst.args(name='Calcium channel model')
# parameters
DSargs.pars = { 'vl': -60,
'vca': 120,
'i': 0,
'gl': 2,
'gca': 4,
'c': 20,
'v1': -1.2,
'v2': 18 }
# auxiliary helper function(s) -- function name: ([func signature], definition)
DSargs.fnspecs = {'minf': (['v'], '0.5 * (1 + tanh( (v-v1)/v2 ))') }
# rhs of the differential equation, including dummy variable w
DSargs.varspecs = {'v': '( i + gl * (vl - v) - gca * minf(v) * (v-vca) )/c',
'w': 'v-w' }
# initial conditions
DSargs.ics = {'v': 0, 'w': 0 }
DSargs.tdomain = [0,30] # set the range of integration.
ode = dst.Generator.Vode_ODEsystem(DSargs) # an instance of the 'Generator' class.
traj = ode.compute('polarization') # integrate ODE
示例14: to
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import args [as 别名]
import MorrisLecar
# Use the function created by VFGEN to define the 'args' object for
# the Morris-Lecar system.
ds = MorrisLecar.args()
# Set ics to (1.5,0). This is not an equilibrium point, but
# with these values, the PyCont code will find one.
ds.ics = {'v': 1.5, 'w': 0.0}
ode = PyDSTool.Generator.Vode_ODEsystem(ds)
cont = PyDSTool.ContClass(ode)
print "Setting up for one parameter continuation of an equilibrium point."
PCargs = PyDSTool.args(name='EQ1', type='EP-C')
PCargs.freepars = ['ic']
PCargs.StepSize = 1e-3
PCargs.MaxNumPoints = 200
PCargs.MaxStepSize = 0.2
PCargs.LocBifPoints = ['LP', 'H', 'BP']
print "Computing the curve."
cont.newCurve(PCargs)
cont['EQ1'].forward()
print "Setting up for two parameter continuation of the Hopf point."
PCargs = PyDSTool.args(name='Hopf', type='H-C2')
PCargs.initpoint = 'EQ1:H1'
PCargs.freepars = ['ic', 'gca']
PCargs.MaxStepSize = 1.0
示例15: pow
# 需要导入模块: import PyDSTool [as 别名]
# 或者: from PyDSTool import args [as 别名]
import PyDSTool as pd
#########################################################################
# Test Models
#########################################################################
# Fitzhugh Nagumo Model
fhn_ds_args = pd.args()
fhn_ds_args.name = 'Fitzhugh_Nagumo'
fhn_ds_args.fnspecs = {'Jacobian': (['t', 'V', 'R'],
"""[[c*(V + pow(V, 2.)), c],
[-1/c, -b/c]]"""),
'Vdot': (['V', 'R'], "c*(V - pow(V, 3.)/3. + R)"),
'Rdot': (['V', 'R'], "-(V + a - b*R)/c")}
fhn_ds_args.varspecs = {'V': 'Vdot(V, R)',
'R': 'Rdot(V, R)'}
fhn_ds_args.ics = {'V': -1., 'R': 1.}
fhn_ds_args.pars = {'a': 0.2, 'b': 0.2, 'c': 3.0}
fhn_ds_args.algparams = {'max_pts': 1000000}
fhn_ds_args.tdata = [0., 20.]
# Goodwin Oscillator (3 components)
goodwin3_args = pd.args()
goodwin3_args.name = 'Goodwin Oscillator (3 Components)'
goodwin3_args.fnspecs = {'Jacobian': (['t', 'X1', 'X2', 'X3'],
"""[[ , , ]
[ , , ]
[ , , ]]"""),
'X1dot': (['X1', 'X2', 'X3'], "v0/(1 + pow(X3/Km, p) - k1*X1"),