Exemplo n.º 1
0
from beluga.utils import load
import matplotlib.pyplot as plt

sol_set = load('indirect_data.json')
sol_indirect = sol_set[-1][-1]

# data = load('direct_data.blg')
# sol_set = data['solutions']
# sol_direct = sol_set[-1][-1]

plt.figure()
plt.plot(sol_indirect.t,
         sol_indirect.y[:, 0],
         color='b',
         linewidth=2,
         label='Indirect')
plt.plot(sol_indirect.t, -sol_indirect.y[:, 0], color='b', linewidth=2)
# plt.plot(sol_direct.t, sol_direct.y[:, 0], color='r', label='Direct')
# plt.plot(sol_direct.t, -sol_direct.y[:, 0], color='r')
plt.xlabel('$x$ [m]')
plt.ylabel('$r$ [m]')
plt.title('Vehicle Shape')
plt.legend()
plt.grid(True)

plt.figure()
plt.plot(sol_indirect.t, sol_indirect.u[:, 0], color='b', label='Indirect')
# plt.plot(sol_direct.t, sol_direct.u[:, 0], color='r', label='Direct')
plt.xlabel('$x$ [m]')
plt.ylabel('$u$ [m/s]')
plt.legend()
from beluga.utils import load
import matplotlib.pyplot as plt

data = load('data.beluga')
sol_set = data['solutions']
traj = sol_set[-1][-1]

continuation = sol_set[-1]
L = len(continuation)

plt.figure()
for ind, sol in enumerate(continuation):
    plt.plot(sol.t, sol.y[:, 0], color=(1 * (ind / L), 1 * (L - ind) / L, 0))
    plt.plot(sol.t, sol.y[:, 1], color=(0, 1 * (L - ind) / L, 1 * (ind / L)))
plt.xlabel('Time [s]')
plt.ylabel('State Variables')
plt.grid(True)

plt.figure()
for ind, sol in enumerate(continuation):
    plt.plot(sol.y[:, 0],
             sol.y[:, 1],
             color=(0, 1 * (L - ind) / L, 1 * (ind / L)))
plt.xlabel('$y_1$')
plt.ylabel('$y_2$')
plt.grid(True)

plt.figure()
for ind, sol in enumerate(continuation):
    plt.plot(sol.t, sol.u[:, 0], color=(0, 1 * (L - ind) / L, 1 * (ind / L)))
Exemplo n.º 3
0
from beluga.utils import load
import matplotlib.pyplot as plt

data = load('data.blg')
sol_set = data['solutions']

sol = sol_set[-1][-1]

plt.figure()
plt.plot(sol.t, sol.y[:, 0], color='b', label='$\omega_1$')
plt.plot(sol.t, sol.y[:, 1], color='r', label='$\omega_2$')
plt.plot(sol.t, sol.y[:, 2], color='g', label='$\omega_3$')
plt.title('Rotation Rates')
plt.ylabel('Angular Rates [rad/s]')
plt.xlabel('Time [s]')
plt.legend()
plt.grid(True)

plt.figure()
plt.plot([sol.t[0], sol.t[-1]], [1, 1], color='k', linestyle='--', linewidth=3)
plt.plot([sol.t[0], sol.t[-1]], [-1, -1],
         color='k',
         linestyle='--',
         linewidth=3)
plt.plot(sol.t, sol.u[:, 0], color='b', label='$u_1$')
plt.plot(sol.t, sol.u[:, 1], color='r', label='$u_2$')
plt.plot(sol.t, sol.u[:, 2], color='g', label='$u_3$')
plt.title('Control History')
plt.ylabel('Control [rad/s^2]')
plt.xlabel('Time [s]')
plt.legend()
Exemplo n.º 4
0
from beluga.utils import load
import matplotlib.pyplot as plt

sol_set = load('chain.json')

for sol in sol_set[-1]:
    plt.plot(sol.y[:, 0], sol.y[:, 1])

plt.show()
Exemplo n.º 5
0
from beluga.utils import load
import matplotlib.pyplot as plt

sol_set = load('data.json')
traj = sol_set[-1][-1]

continuation = sol_set[-1]
L = len(continuation)

plt.figure()
for ind, sol in enumerate(continuation):
    plt.plot(sol.t, sol.y[:, 0], color=(1 * (ind / L), 1 * (L - ind) / L, 0))
    plt.plot(sol.t, sol.y[:, 1], color=(0, 1 * (L - ind) / L, 1 * (ind / L)))
plt.xlabel('Time [s]')
plt.ylabel('State Variables')
plt.grid(True)

plt.figure()
for ind, sol in enumerate(continuation):
    plt.plot(sol.y[:, 0],
             sol.y[:, 1],
             color=(0, 1 * (L - ind) / L, 1 * (ind / L)))
plt.xlabel('$y_1$')
plt.ylabel('$y_2$')
plt.grid(True)

plt.figure()
for ind, sol in enumerate(continuation):
    plt.plot(sol.t, sol.u[:, 0], color=(0, 1 * (L - ind) / L, 1 * (ind / L)))

plt.plot(traj.t, -traj.y[:, 0] / 6, color='k', linestyle='--')
Exemplo n.º 6
0
from beluga.utils import load
import matplotlib.pyplot as plt

data = load('indirect_data.blg')
sol_set = data['solutions']
sol_indirect = sol_set[-1][-1]

data = load('direct_data.blg')
sol_set = data['solutions']
sol_direct = sol_set[-1][-1]

plt.figure()
plt.plot(sol_indirect.t,
         sol_indirect.y[:, 0],
         color='b',
         linewidth=2,
         label='Indirect')
plt.plot(sol_indirect.t, -sol_indirect.y[:, 0], color='b', linewidth=2)
plt.plot(sol_direct.t, sol_direct.y[:, 0], color='r', label='Direct')
plt.plot(sol_direct.t, -sol_direct.y[:, 0], color='r')
plt.xlabel('$x$ [m]')
plt.ylabel('$r$ [m]')
plt.title('Vehicle Shape')
plt.legend()
plt.grid(True)

plt.figure()
plt.plot(sol_indirect.t, sol_indirect.u[:, 0], color='b', label='Indirect')
plt.plot(sol_direct.t, sol_direct.u[:, 0], color='r', label='Direct')
plt.xlabel('$x$ [m]')
plt.ylabel('$u$ [m/s]')
Exemplo n.º 7
0
from beluga.utils import load
import matplotlib.pyplot as plt

sol_set = load('chain.beluga')['solutions']

for sol in sol_set[-1]:
    plt.plot(sol.y[:, 0], sol.y[:, 1])

plt.show()
from beluga.utils import load
import matplotlib.pyplot as plt
import numpy as np

sol_set_shooting = load('highthrust_shooting_data.json')
sol_set_collocation = load('highthrust_collocation_data.json')

sol_c = sol_set_collocation[-1][-1]
sol_s = sol_set_shooting[-1][-1]

anom = np.linspace(0, 2 * np.pi, num=1000)

plt.figure()
plt.plot(0, 0, marker='*')
plt.plot(np.cos(sol_s.y[:, 1]) * sol_s.y[:, 0],
         np.sin(sol_s.y[:, 1]) * sol_s.y[:, 0],
         color='b',
         linestyle='-',
         linewidth=2,
         label='Shooting')
plt.plot(np.cos(sol_c.y[:, 1]) * sol_c.y[:, 0],
         np.sin(sol_c.y[:, 1]) * sol_c.y[:, 0],
         color='r',
         linestyle='--',
         marker='.',
         label='Collocation')
plt.plot(np.cos(anom) * sol_s.y[0, 0],
         np.sin(anom) * sol_s.y[0, 0],
         color='k',
         linestyle='--')
plt.plot(np.cos(anom) * sol_s.y[-1, 0],
from beluga.utils import load
import matplotlib.pyplot as plt
import numpy as np

data = load('highthrust_shooting_data.blg')
sol_set_shooting = data['solutions']
data = load('highthrust_collocation_data.blg')
sol_set_collocation = data['solutions']

sol_c = sol_set_collocation[-1][-1]
sol_s = sol_set_shooting[-1][-1]

anom = np.linspace(0, 2 * np.pi, num=1000)

plt.figure()
plt.plot(0, 0, marker='*')
plt.plot(np.cos(sol_s.y[:, 1]) * sol_s.y[:, 0],
         np.sin(sol_s.y[:, 1]) * sol_s.y[:, 0],
         color='b',
         linestyle='-',
         linewidth=2,
         label='Shooting')
plt.plot(np.cos(sol_c.y[:, 1]) * sol_c.y[:, 0],
         np.sin(sol_c.y[:, 1]) * sol_c.y[:, 0],
         color='r',
         linestyle='--',
         marker='.',
         label='Collocation')
plt.plot(np.cos(anom) * sol_s.y[0, 0],
         np.sin(anom) * sol_s.y[0, 0],
         color='k',
Exemplo n.º 10
0
from beluga.utils import load
import matplotlib.pyplot as plt
import numpy as np

data = load('space_shuttle.beluga')
sol_set = data['solutions']

sol = sol_set[-1][-1]

plt.figure()
plt.plot(sol.t, sol.y[:,0])
plt.ylabel('Altitude [m]')
plt.xlabel('Time [s]')
plt.grid(True)

plt.figure()
plt.plot(sol.t, sol.y[:,1]*180/np.pi)
plt.ylabel('Longitude [deg]')
plt.xlabel('Time [s]')
plt.grid(True)

plt.figure()
plt.plot(sol.t, sol.y[:,2]*180/np.pi)
plt.ylabel('Latitude [deg]')
plt.xlabel('Time [s]')
plt.grid(True)

plt.figure()
plt.plot(sol.t, sol.y[:,3])
plt.ylabel('Velocity [m/s]')
plt.xlabel('Time [s]')
from beluga.utils import load
import matplotlib.pyplot as plt

data = load('indirect_data.beluga')
sol_set = data['solutions']
sol_indirect = sol_set[-1][-1]

# data = load('direct_data.blg')
# sol_set = data['solutions']
# sol_direct = sol_set[-1][-1]

plt.figure()
plt.plot(sol_indirect.t, sol_indirect.y[:, 0], color='b', linewidth=2, label='Indirect')
plt.plot(sol_indirect.t, -sol_indirect.y[:, 0], color='b', linewidth=2)
# plt.plot(sol_direct.t, sol_direct.y[:, 0], color='r', label='Direct')
# plt.plot(sol_direct.t, -sol_direct.y[:, 0], color='r')
plt.xlabel('$x$ [m]')
plt.ylabel('$r$ [m]')
plt.title('Vehicle Shape')
plt.legend()
plt.grid(True)

plt.figure()
plt.plot(sol_indirect.t, sol_indirect.u[:, 0], color='b', label='Indirect')
# plt.plot(sol_direct.t, sol_direct.u[:, 0], color='r', label='Direct')
plt.xlabel('$x$ [m]')
plt.ylabel('$u$ [m/s]')
plt.legend()
plt.grid(True)
plt.show()
from beluga.utils import load
import matplotlib.pyplot as plt
import numpy as np

data = load('lowthrust_shooting_data.beluga')
sol_set_shooting = data['solutions']
data = load('lowthrust_collocation_data.beluga')
sol_set_collocation = data['solutions']

sol_c = sol_set_collocation[-1][-1]
sol_s = sol_set_shooting[-1][-1]

anom = np.linspace(0, 2 * np.pi, num=1000)

plt.figure()
plt.plot(0, 0, marker='*')
plt.plot(np.cos(sol_s.y[:, 1]) * sol_s.y[:, 0],
         np.sin(sol_s.y[:, 1]) * sol_s.y[:, 0],
         color='b',
         linestyle='-',
         linewidth=2,
         label='Shooting')
plt.plot(np.cos(sol_c.y[:, 1]) * sol_c.y[:, 0],
         np.sin(sol_c.y[:, 1]) * sol_c.y[:, 0],
         color='r',
         linestyle='--',
         marker='.',
         label='Collocation')
plt.plot(np.cos(anom) * sol_s.y[0, 0],
         np.sin(anom) * sol_s.y[0, 0],
         color='k',
import matplotlib.pyplot as plt
from matplotlib import rcParams
from matplotlib.gridspec import GridSpec
from beluga.utils import load
from matplotlib.colors import LinearSegmentedColormap

re = 6.3781e6

rad2deg = 180 / 3.141592653589793

file = 'hyper_example.beluga'

data = load(file)
sols = data['solutions'][-1][::2]

fig1 = plt.figure()
fig1.suptitle('Continuation of Hypersonic Vechicle')

gs = GridSpec(2, 2, figure=fig1)

ax1 = fig1.add_subplot(gs[0, 0])
ax2 = fig1.add_subplot(gs[0, 1])
ax3 = fig1.add_subplot(gs[1, 0])
ax4 = fig1.add_subplot(gs[1, 1])

colors = LinearSegmentedColormap.from_list('simple', ["C0", "C9"],
                                           N=len(sols))(list(range(len(sols))))


def plot_sol(_sol, _color='C0', linewidth=1):
    t = _sol.t
Exemplo n.º 14
0
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import rcParams
from matplotlib.gridspec import GridSpec
from beluga.utils import load

rad2deg = 180 / 3.141592653589793

rcParams['font.family'] = 'serif'
rcParams['font.size'] = 12
rcParams['mathtext.fontset'] = 'stix'

sols = load('space_shuttle_xi.json')[-1]

fig = plt.figure(figsize=(6.5, 5))
# fig.suptitle('Space Shuttle Reachability', fontsize=10)

# gs = GridSpec(1, 1, figure=fig)

ax11 = fig.add_subplot(111, projection='3d')

footprint_theta = []
footprint_phi = []
footprint_h = []
for sol in sols[::5]:
    h = sol.y[:, 0] / 1000
    theta = sol.y[:, 1] * rad2deg
    phi = sol.y[:, 2] * rad2deg

    ax11.plot(theta, phi, h, color='C0')
    ax11.plot(theta, -phi, h, color='C0')
Exemplo n.º 15
0
Hscale = 8.44e3

bfr_thrust0_sea = 1.993e6 * 31
bfr_thrust0_vac = 2.295e6 * 31
bfr_thrust1_sea = 1.993e6 * 7
bfr_thrust1_vac = 2.295e6 * 7

bfr_mass0 = 4400e3
bfr_mass0f = 1335e3
bfr_mass1 = 1335e3
bfr_mass1f = 85e3

bfr_massflow0 = -615.8468 * 31
bfr_massflow1 = -615.8468 * 7

sol_set = load('BFR.npz')

sol = sol_set[-1][-1]

plt.figure()
plt.plot(sol.y[:, 0] / 1000, sol.y[:, 1] / 1000)
plt.xlabel('Downrange [km]')
plt.ylabel('Altitude [km]')
plt.title('Time Optimal Launch of a BFR Trajectory')
plt.grid(True)

plt.figure()
plt.plot(sol.t, sol.y[:, 2] / 1000, label='Horizontal Velocity')
plt.plot(sol.t, sol.y[:, 3] / 1000, label='Vertical Velocity')
plt.xlabel('Time [s]')
plt.ylabel('Velocity [km/s]')
Exemplo n.º 16
0
from beluga.utils import load
import matplotlib.pyplot as plt
import numpy as np

sol_set = load('space_shuttle.json')

sol = sol_set[-1][-1]

plt.figure()
plt.plot(sol.t, sol.y[:, 0])
plt.ylabel('Altitude [m]')
plt.xlabel('Time [s]')
plt.grid(True)

plt.figure()
plt.plot(sol.t, sol.y[:, 1] * 180 / np.pi)
plt.ylabel('Longitude [deg]')
plt.xlabel('Time [s]')
plt.grid(True)

plt.figure()
plt.plot(sol.t, sol.y[:, 2] * 180 / np.pi)
plt.ylabel('Latitude [deg]')
plt.xlabel('Time [s]')
plt.grid(True)

plt.figure()
plt.plot(sol.t, sol.y[:, 3])
plt.ylabel('Velocity [m/s]')
plt.xlabel('Time [s]')
plt.grid(True)