Esempio n. 1
0
# Initialize 1-jetlet
q = np.zeros([N, DIM])
p = np.zeros([N, DIM])
mu = np.zeros([N, DIM, DIM])
q1 = np.zeros([N, DIM, DIM])
for i in range(0, N):
    q1[i] = np.eye(DIM)

# Initial 1-momentum of jetlets
mu[0] = -0.84 * jpf.spin + 0.89 * jpf.stretch

T = 15.0

Ei = jpf.Hamiltonian(q, p, mu)
pi = jpf.lin_momentum(q, p, mu)
Li = jpf.ang_momentum(q, p, mu)
print 'initial energy: %.3f' % Ei
print 'initial momentum: %.3f,%.3f  %.3f' % (pi[0], pi[1], Li[0][1])

print 'initial J_R^1 momenta:'
Ki = np.zeros([N, DIM, DIM])
for i in range(0, N):
    Ki[i] = jpf.Jr1_momentum(q, p, mu, q1, particles=[i])
    print Ki[i]

state = jpf.weinstein_darboux_to_state(q, p, mu, q1)
step_max = 200
t_span = np.linspace(0., T, step_max)
y_span = odeint(jpf.ode_function, state, t_span, rtol=0.0000001)
np.save('state_data', y_span)
Esempio n. 2
0
import matplotlib.pyplot as plt
import numpy as np
import sys

N = jpf.N
DIM = jpf.DIM
SIGMA = jpf.SIGMA

y_data = np.load('./state_data.npy')
times = np.load('./time_data.npy')

N_timestep = y_data.shape[0]

momenta = np.zeros([N, 3, N_timestep])

for i in range(N_timestep):
    q, p, mu, q1 = jpf.state_to_weinstein_darboux(y_data[i])

    for j in range(N):
        tmp = jpf.lin_momentum(q, p, mu, [j])
        momenta[j][0][i] = tmp[0]
        momenta[j][1][i] = tmp[1]
        momenta[j][2][i] = jpf.ang_momentum(q, p, mu, [j])[0][1]

plt.figure()
plt.xlabel('t')
plt.plot(times, momenta[0][2], 'b-', times, momenta[1][2], 'r-', times,
         momenta[2][2], 'g-')
#plt.axis([0,times[N_timestep-1],0,1])
plt.show()
    p[2][0] = 0.7
#    mu[2] = 0.2*jpf.spin

T = 30.45

#print 'testing various functions'
#print  jpf.test_functions(1)

print 'parameters:'
print 'r0 = %.2f' % r0
print 'p0 = %.2f' % p0
print 'd  = %.2f' % d
print 'omega = %.2f' % omega

Ei = jpf.Hamiltonian(q,p,mu)
pi = jpf.lin_momentum(q,p,mu)
Li = jpf.ang_momentum(q,p,mu)
print 'initial energy: %.3f' % Ei
print 'initial momentum: %.3f,%.3f  %.3f' % ( pi[0], pi[1], Li[0][1] )

print 'initial J_R^1 momenta:'
Ki = np.zeros([N,DIM,DIM])
for i in range(0,N):
    Ki[i] = jpf.Jr1_momentum(q,p,mu,q1,particles=[i])
    print Ki[i]

state =  jpf.weinstein_darboux_to_state( q , p , mu , q1 )
step_max = 406
t_span = np.linspace( 0. , T , step_max )
y_span = odeint( jpf.ode_function , state , t_span , rtol=0.0000001 )
np.save('state_data',y_span)
import numpy as np
import sys

N = jpf.N
DIM = jpf.DIM
SIGMA = jpf.SIGMA

y_data = np.load('./state_data.npy')
times  = np.load('./time_data.npy')

N_timestep = y_data.shape[0]

momenta = np.zeros([N,3,N_timestep])

for i in range(N_timestep):
    q,p,mu,q1 = jpf.state_to_weinstein_darboux( y_data[i] )

    for j in range(N):
        tmp = jpf.lin_momentum(q,p,mu,[j])
        momenta[j][0][i] = tmp[0]
        momenta[j][1][i] = tmp[1]
        momenta[j][2][i] = jpf.ang_momentum(q,p,mu,[j])[0][1]

plt.figure()
plt.xlabel('t')
plt.plot(times,momenta[0][2],'b-',
         times,momenta[1][2],'r-',
         times,momenta[2][2],'g-')
#plt.axis([0,times[N_timestep-1],0,1])
plt.show()