t,
                                               rtol=tol,
                                               atol=tol,
                                               args=({
                                                   'constants': {},
                                                   'alpha': 1e2,
                                                   'beta': 1e1
                                               }, ))

lambda1_n = numpy.array([lambda1(tt, ss) for tt, ss in zip(t, states)])
plt.figure()
plt.plot(t, lambda1_n)

# =============================================================================
KE = system.get_KE()
PE = system.getPEGravity(0 * N.x) - system.getPESprings()
energy = Output([KE - PE])
energy.calc(states, t)
energy.plot_time()
# =============================================================================
points_list = [p1, p2]
#points_list = [item2 for item in points_list for item2 in [item.dot(N.x),item.dot(N.y)]]
#points = Output(points_list)
#y = points.calc(states,t)
#y = y.reshape((-1,2,2))

#plt.figure()
#plt.plot(y[:,1,0],y[:,1,1])
#plt.axis('equal')

states2 = Output([x, q])
Esempio n. 2
0
#integrator = DoPri(func,ini,t)
#states = integrator.run()
states = pynamics.integration.integrate_odeint(func,
                                               ini,
                                               t,
                                               rtol=1e-12,
                                               atol=1e-12,
                                               hmin=1e-14,
                                               args=({
                                                   'constants':
                                                   system.constant_values
                                               }, ))

KE = system.get_KE()
PE = system.getPEGravity(
    pNA) - system.getPESprings() - 1 / 2 * k * (stretch)**2

output = Output([x1, y1, q, KE - PE], system)
y = output.calc(states)

plt.figure(1)
plt.plot(y[:, 0], y[:, 1])
plt.axis('equal')

plt.figure(2)
plt.plot(y[:, 3])

#plt.figure(3)
#plt.plot(t,y[:,0])
#plt.show()
stretched2 = -(-stretch+abs(-stretch))/2

#system.add_spring_force1(k,(stretched1)*N.y,vAcm) 
system.add_spring_force1(k,(stretched2)*N.y,vAcm) 

system.addforcegravity(-g*N.y)

x1 = ParticleA.pCM.dot(N.x)
y1 = ParticleA.pCM.dot(N.y)
    
f,ma = system.getdynamics()
func1 = system.state_space_post_invert(f,ma)
states=pynamics.integration.integrate_odeint(func1,ini,t,rtol=1e-12,atol=1e-12,hmin=1e-14, args=({'constants':system.constant_values},))

KE = system.get_KE()
PE = system.getPEGravity(pNA)-system.getPESprings()

output = Output([x1,y1,KE-PE,x,y],system)
y = output.calc(states)

plt.figure(1)
plt.plot(y[:,0],y[:,1])
plt.axis('equal')

plt.figure(2)
plt.plot(y[:,2])

plt.figure(3)
plt.plot(t,y[:,4])
plt.show()
Esempio n. 4
0
                                               rtol=error,
                                               atol=error,
                                               args=({
                                                   'alpha':
                                                   alpha,
                                                   'beta':
                                                   beta,
                                                   'constants':
                                                   system.constant_values
                                               }, ),
                                               full_output=1,
                                               mxstep=int(1e5))
states = states[0]

KE = system.get_KE()
PE = system.getPEGravity(pOrigin) - system.getPESprings()

output = Output([x1, x2, l, KE - PE], system)
y = output.calc(states)

plt.figure(0)
plt.plot(t, y[:, 0])
plt.plot(t, y[:, 1])
plt.axis('equal')

plt.figure(1)
plt.plot(t, y[:, 2])
plt.axis('equal')

plt.figure(2)
plt.plot(t, y[:, 3])