コード例 #1
0
           [[1,2],[1,2]],  # plot arguments
           )

add_system_params(sim,N,
            k=[8.0,40.0],
            m=[1,1.5],
            L=[0.5,1],
            b=[0.8,0.5],
            
            x_1=0,
            x_N=0,
            k_N=0,
            L_N=0,
        )

print sim.equations()
sim.run(0,10) 

# <codecell>

N=3
sim=Simulation()
add_system(sim,N,"x[i]''=(-b[i] * x[i]' - k[i] * (x[i] -x[i-1] -L[i]) + k[i+1] * (x[i+1] - x[i] - L[i+1])) / m[i]",
           [[0.5,0.0],[2.25,0.0],[4.0,0.0]],  # initial conditions
           [[1,2],[1,2],[1,2]],  # plot arguments
           )

add_system_params(sim,N,
            k=[8.0,40.0,10.0],
            m=[1,1.5,1.0],
            L=[0.5,1,2.0],
コード例 #2
0
# In[8]:

sim=Simulation()
sim.figsize=(20,5)

sim.add("deer' = r*deer*(1-deer/K)-c*deer*wolf",
                initial_value=350,
                plot=True)

sim.add("wolf' = -Wd*wolf+D*deer*wolf",
                initial_value=50,
                plot=True)

sim.params(r=0.25,D=0.001,c=0.005,Wd=0.3,K=1e500)

print(sim.equations())
sim.run(0,500)

# fig=sim.figures[0]
# fig.savefig('predprey_dynamics1.pdf')
# fig.savefig('predprey_dynamics1.png')

# fig=sim.figures[1]
# fig.savefig('predprey_dynamics2.pdf')
# fig.savefig('predprey_dynamics2.png')


# In[9]:

from pyndamics import phase_plot
phase_plot(sim,'deer','wolf')
コード例 #3
0
)

add_system_params(
    sim,
    N,
    k=[8.0, 40.0],
    m=[1, 1.5],
    L=[0.5, 1],
    b=[0.8, 0.5],
    x_1=0,
    x_N=0,
    k_N=0,
    L_N=0,
)

print sim.equations()
sim.run(0, 10)

# <codecell>

N = 3
sim = Simulation()
add_system(
    sim,
    N,
    "x[i]''=(-b[i] * x[i]' - k[i] * (x[i] -x[i-1] -L[i]) + k[i+1] * (x[i+1] - x[i] - L[i+1])) / m[i]",
    [[0.5, 0.0], [2.25, 0.0], [4.0, 0.0]],  # initial conditions
    [[1, 2], [1, 2], [1, 2]],  # plot arguments
)

add_system_params(
コード例 #4
0
ylabel('Number of Mice')

# ## Predator-Prey Dynamics

# In[8]:

sim = Simulation()
sim.figsize = (20, 5)

sim.add("deer' = r*deer*(1-deer/K)-c*deer*wolf", initial_value=350, plot=True)

sim.add("wolf' = -Wd*wolf+D*deer*wolf", initial_value=50, plot=True)

sim.params(r=0.25, D=0.001, c=0.005, Wd=0.3, K=1e500)

print(sim.equations())
sim.run(0, 500)

# fig=sim.figures[0]
# fig.savefig('predprey_dynamics1.pdf')
# fig.savefig('predprey_dynamics1.png')

# fig=sim.figures[1]
# fig.savefig('predprey_dynamics2.pdf')
# fig.savefig('predprey_dynamics2.png')

# In[9]:

from pyndamics import phase_plot
phase_plot(sim, 'deer', 'wolf')