vT = np.array([U[9:12]])
    vL = np.array([U[12:15]])
    vSat = np.array([U[15:18]])
    v = np.concatenate((vT, vL, vSat), axis=None)

    aT = -muL / np.linalg.norm(rTL)**3 * rTL
    aL = -aT * MT / ML
    aSat = -muT / np.linalg.norm(rSatT)**3 * rSatT - muL / np.linalg.norm(
        rSatL)**3 * rSatL
    a = np.concatenate((aT, aL, aSat), axis=None)

    return np.concatenate((v, a), axis=None)


[U, t] = R4(F, t0, U0, T, dt)  #Integrador Runge Kutta 4
#[U,t] = Euler(F,t0, U0, T, dt)      #Integrador Euler

[xT, yT, zT, xL, yL, zL, xSat, ySat, zSat] = U[0:9]

N = int(T / dt / 1000)  #Se pintan 1000 puntos

xT = xT[0:-1:N]
yT = yT[0:-1:N]
zT = zT[0:-1:N]

xL = xL[0:-1:N]
yL = yL[0:-1:N]
zL = zL[0:-1:N]

xSat = xSat[0:-1:N]
Exemplo n.º 2
0
t0 = 0.0  #Instante inicial
U0 = np.array([1, 0, 0, 1])  #Condiciones iniciales
T = 10 * 2 * np.pi  #Tiempo de simulación (10 vueltas)
dt = 0.1  #Paso temporal

mu = 1.0  #Parámetro gravitacional


def F(t, U):
    return np.array([
        U[2], U[3], -mu / (np.linalg.norm(U[0:2])**3) * U[0],
        -mu / (np.linalg.norm(U[0:2])**3) * U[1]
    ])


[[x, y, vx, vy], t] = R4(F, t0, U0, T, dt)  #Integrador Runge Kutta 4
#[[x,y,vx,vy],t] = Euler(F,t0, U0, T, dt) #Integrador Euler

#Plot
fig1, ax = plt.subplots(figsize=(8, 8))
plt.grid()
plt.xticks(fontsize=14)
plt.yticks(fontsize=14)
plt.xlabel("x", fontsize=18)
plt.ylabel("y", fontsize=18)
plt.plot(x[:], y[:])
plt.plot(x[0], y[0], 'o',
         color='r')  #Solución analítca de la posición en el instante final
plt.plot(x[-1], y[-1], 'o',
         color='g')  #Solución numérica de la posición en el instante final
Exemplo n.º 3
0
from matplotlib import pyplot as plt


t0 = 0.0                     #Instante inicial
U0 =np.array([1,0])   #Condiciones iniciales
T=100                #Tiempo de simulación 
dt=0.01                    #Paso temporal 

epsilon0 = 1e-9      #Perturbación inicial

def F(t,U):
    v = U[1]
    x = U[0]
    return  np.array([v,-x])

[U1,t] = R4(F,t0, U0, T, dt)         #Integrador Runge Kutta 4
[U2,t] = R4(F,t0, U0, T, dt/2)
q = 4
#[U1,t] = Euler(F,t0, U0, T, dt)      #Integrador Euler
#[U2,t] = Euler(F,t0, U0, T, dt/2)
# q = 1


k = np.linalg.norm(U2[:,-1] - U1[:,-1])/(dt**q*(1-0.5**q))
E1 = dt**q*k
E2 = (dt/2)**q*k

Lyapunov_coef = np.log(E1/epsilon0)/T

t = np.linspace(0,10*T,1000,endpoint = True)
E = np.zeros(len(t))
Exemplo n.º 4
0
    vT = np.array([U[4:6]])
    vL = np.array([U[6:8]])
    v = np.concatenate((vT, vL), axis=None)

    aT = np.array([
        -muL / (np.linalg.norm(rTL)**3) * rTL[0],
        -muL / (np.linalg.norm(rTL)**3) * rTL[1]
    ])
    aL = -aT * MT / ML
    a = np.concatenate((aT, aL))

    return np.concatenate((v, a), axis=None)


[[xT, yT, xL, yL, vxT, vyT, vxL, vyL], t] = R4(F, t0, U0, T,
                                               dt)  #Integrador Runge Kutta 4
#[[xT,yT,xL,yL,vxT,vyT,vxL,vyL],t] = Euler(F,t0, U0, T, dt)   #Integrador Euler

#Plot

fig1, ax = plt.subplots(figsize=(8, 8))
plt.grid()
plt.xticks(fontsize=14)
plt.yticks(fontsize=14)
plt.xlabel("x", fontsize=18)
plt.ylabel("y", fontsize=18)
plt.plot(xT[:], yT[:], color='b')
plt.plot(xL[:], yL[:], color='r')

#Save
plt.savefig('Órbita_Luna_Tierra.jpg', dpi=300)