コード例 #1
0
# <codecell>

N=2
sim=Simulation()
sim.add_system(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]],  # initial conditions
           [[1,2],[1,2]],  # plot arguments
           )

sim.system_params(N,
            k=[8.0,40.0],
            m=[1,1.5],
            L=[0.5,1],
            b=[0.8,0.5],
            
            x_1=0,   # these are the boundary conditions on each side
            x_N=0,
            k_N=0,
            L_N=0,
        )

print "Here are the equations:"
print sim.equations()
sim.run(0,10) 

# <markdowncell>

# ### Now with $N=3$

# <codecell>
コード例 #2
0
N = 2
sim = Simulation()
sim.add_system(
    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]],  # initial conditions
    [[1, 2], [1, 2]],  # plot arguments
)

sim.system_params(
    N,
    k=[8.0, 40.0],
    m=[1, 1.5],
    L=[0.5, 1],
    b=[0.8, 0.5],
    x_1=0,  # these are the boundary conditions on each side
    x_N=0,
    k_N=0,
    L_N=0,
)

print("Here are the equations:")
print(sim.equations())
sim.run(0, 10)

# ### Now with $N=3$

# In[23]:

N = 3