コード例 #1
0
ファイル: Rossler.py プロジェクト: breecummins/StateSpace
def solveDiamondRotatedInteralMult(init,T,dt=0.025,mu=4.0,beta=1.2,A=2.0,a=0.2,b=0.2,c=5.7,d=0.25,B=1.25):
    times = np.arange(0,T,dt)
    x = np.zeros((len(times),len(init)))
    x[0,:] = init
    for k,t in enumerate(times[:-1]):
        x[k+1,:] = rk4.solverp(t,x[k,:],dt,diamondRotatedInternalMult,mu=mu,beta=beta,A=A,a=a,b=b,c=c,d=d,B=B)
    return x
コード例 #2
0
def solvePendulum(init,
                  T,
                  dt=0.05,
                  mu=4.0,
                  beta=2.0,
                  gamma=3.5,
                  delta=2.0,
                  A=2.0,
                  B=4.0,
                  C=1.0,
                  D=1.0):
    times = np.arange(0, T, dt)
    x = np.zeros((len(times), len(init)))
    x[0, :] = init
    for k, t in enumerate(times[:-1]):
        x[k + 1, :] = rk4.solverp(t,
                                  x[k, :],
                                  dt,
                                  triplePendulum,
                                  mu=mu,
                                  beta=beta,
                                  gamma=gamma,
                                  delta=delta,
                                  A=A,
                                  B=B,
                                  C=C,
                                  D=D)
    return x
コード例 #3
0
ファイル: Rossler.py プロジェクト: breecummins/StateSpace
def solveRotatedRossler(init,T,dt=0.01,a=0.2,b=0.2,c=5.7):
    times = np.arange(0,T,dt)
    x = np.zeros((len(times),len(init)))
    x[0,:] = init
    for k,t in enumerate(times[:-1]):
        x[k+1,:] = rk4.solverp(t,x[k,:],dt,rotatedRossler,a=a,b=b,c=c)
    return x
コード例 #4
0
def solveRotatedLorenz(init,finaltime,dt=0.025,sigma=10.,rho=28.,beta=8/3.):
    '''
    init = [x[0],y[0],z[0]] are the initial conditions
    dt is the time step
    last three args are Lorenz parameters
    '''
    times = np.arange(0,finaltime,dt)
    timeseries = np.zeros((len(times),len(init)))
    timeseries[0,:] = init
    for k,ti in enumerate(times[:-1]):
        timeseries[k+1,:] = rk4.solverp(ti,timeseries[k,:],dt,rotatedLorenz,sigma=sigma,rho=rho,beta=beta)
    return timeseries
コード例 #5
0
def solvePendulum(init, T, dt=0.1, mu=4.0, beta=1.2, A=2.0):
    times = np.arange(0, T, dt)
    x = np.zeros((len(times), len(init)))
    x[0, :] = init
    for k, t in enumerate(times[:-1]):
        x[k + 1, :] = rk4.solverp(t,
                                  x[k, :],
                                  dt,
                                  doublePendulum,
                                  mu=mu,
                                  beta=beta,
                                  A=A)
    return x
コード例 #6
0
def solveDiamond(init, T, dt=0.1, mu=4.0, beta=2.0, A=2.0, gamma=10.0, B=1.25):
    times = np.arange(0, T, dt)
    x = np.zeros((len(times), len(init)))
    x[0, :] = init
    for k, t in enumerate(times[:-1]):
        x[k + 1, :] = rk4.solverp(t,
                                  x[k, :],
                                  dt,
                                  doublePendulumDiamond,
                                  mu=mu,
                                  beta=beta,
                                  A=A,
                                  gamma=gamma,
                                  B=B)
    return x
コード例 #7
0
ファイル: SingleCycle.py プロジェクト: breecummins/StateSpace
def solveCycle(init, finaltime, dt=0.1, a=2.0, b=2.0, c=2.0):
    '''
    init = [x[0],y[0],z[0]] are the initial conditions
    dt is the time step
    finaltime is the length of time to solve for

    '''
    times = np.arange(0, finaltime, dt)
    timeseries = np.zeros((len(times), len(init)))
    timeseries[0, :] = init
    for k, ti in enumerate(times[:-1]):
        timeseries[k + 1, :] = rk4.solverp(ti,
                                           timeseries[k, :],
                                           dt,
                                           singlecycle,
                                           a=a,
                                           b=b,
                                           c=c)
    return timeseries
コード例 #8
0
def solvePendulum(init,
                  T,
                  func=doublePendulumForm1,
                  dt=0.1,
                  mu=4.0,
                  beta=2.0,
                  A=2.0,
                  gamma=10.0):
    times = np.arange(0, T, dt)
    x = np.zeros((len(times), len(init)))
    x[0, :] = init
    for k, t in enumerate(times[:-1]):
        x[k + 1, :] = rk4.solverp(t,
                                  x[k, :],
                                  dt,
                                  func,
                                  mu=mu,
                                  beta=beta,
                                  A=A,
                                  gamma=gamma)
    return x
コード例 #9
0
ファイル: predprey.py プロジェクト: breecummins/StateSpace
def solvePredPrey(init,
                  finaltime,
                  dt=0.025,
                  odes=complotkavolterra4D,
                  kwargs={
                      'A': 1,
                      'B': 1,
                      'C': 1,
                      'D': 1
                  }):
    '''
    init = [x[0],y[0]] are the initial conditions
    finaltime is length of simulation, dt is the time step
    odes is the function handle to be integrated
    kwargs dict contains parameters for odes function
    '''
    times = np.arange(0, finaltime, dt)
    timeseries = np.zeros((len(times), len(init)))
    timeseries[0, :] = init
    for k, ti in enumerate(times[:-1]):
        timeseries[k + 1, :] = rk4.solverp(ti, timeseries[k, :], dt, odes,
                                           **kwargs)
    return timeseries