---------- .. [1] Vinh, Nguyen X., Adolf Busemann, and Robert D. Culp. "Hypersonic and planetary entry flight mechanics." NASA STI/Recon Technical Report A 81 (1980). """ from math import * import beluga import logging import matplotlib.pyplot as plt ''' Begin the planar portion of the solution process. ''' ocp = beluga.Problem('planarHypersonic') # Define independent variables ocp.independent('t', 's') # Define equations of motion ocp.state('h', 'v*sin(gam)', 'm') \ .state('theta', 'v*cos(gam)/r', 'rad') \ .state('v', '-D/mass - mu*sin(gam)/r**2', 'm/s') \ .state('gam', 'L/(mass*v) + (v/r - mu/(v*r**2))*cos(gam)', 'rad') # Define quantities used in the problem ocp.quantity('rho', 'rho0*exp(-h/H)') ocp.quantity('Cl', '(1.5658*alfa + -0.0000)')
""" References ---------- .. [1] Buttazzo, Giuseppe, and Bernhard Kawohl. "On Newton’s problem of minimal resistance." The Mathematical Intelligencer 15.4 (1993): 7-12. """ import beluga import logging import matplotlib.pyplot as plt ocp = beluga.Problem() # Define independent variables ocp.independent('l', 'm') # Define equations of motion ocp.state('r', '-u', 'm') # Define controls ocp.control('u', 'm/s') # Define constants ocp.constant('r_0', 1, 'm') ocp.constant('eps1', 1, '1') # Define costs ocp.path_cost('4*r*u**3/(1+u**2)', 'm') # Define constraints ocp.initial_constraint('r - r_0', 'm')
import beluga import logging ocp = beluga.Problem('hanging_chain') ocp.independent('s', 'ft') ocp.state('x', 'cos(theta)', 'ft') ocp.state('y', 'sin(theta)', 'ft') ocp.control('theta', 'rad') ocp.constant('x_0', 0, 'ft') ocp.constant('y_0', 0, 'ft') ocp.constant('s_0', 0, 'ft') ocp.constant('x_f', 1, 'ft') ocp.constant('y_f', 0, 'ft') ocp.constant('s_f', 1.1, 'ft') ocp.path_cost('y', 'ft') ocp.initial_constraint('x - x_0', 'ft') ocp.initial_constraint('y - y_0', 'ft') ocp.initial_constraint('s', 'ft') ocp.terminal_constraint('x - x_f', 'ft') ocp.terminal_constraint('y - y_f', 'ft') ocp.terminal_constraint('s - s_f', 'ft') ocp.scale(ft='s', rad=1)
""" References ---------- .. [1] Ping Chen and Sardar M.N. Islam. "Optimal Control Models in Finance." Kluwer Academic Publishers. DOI: 10.1007/b101888. """ import beluga import numpy as np import logging ocp_indirect = beluga.Problem() # Define independent variables ocp_indirect.independent('t', 'nd') # Define equations of motion ocp_indirect.state('x1', 'T*x2', 'nd') ocp_indirect.state('x2', '-T*x1 + T*u - T**2*B*x2', 'nd') # 2*sin(u) # Define controls ocp_indirect.control('u', 'rad') # Define constants ocp_indirect.constant('T', 5, 'nd') ocp_indirect.constant('B', 0.2, 'nd') ocp_indirect.constant('x1_0', 3, 'nd') ocp_indirect.constant('x2_0', 5, 'nd') ocp_indirect.constant('epsilon1', 10, 'nd') # Define costs
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 """ Step 1 """ ocp = beluga.Problem(name='BFR') # Define independent variables ocp.independent('t', 's') # Define equations of motion ocp.state('x', 'v_x', 'm') ocp.state('y', 'v_y', 'm') ocp.state('v_x', 'Thrust/mass*cos(theta) - D/mass*v_x/sqrt(v_x**2 + v_y**2)', 'm/s') ocp.state('v_y', 'Thrust/mass*sin(theta) - D/mass*v_y/sqrt(v_x**2 + v_y**2) - g', 'm/s') ocp.state('mass', 'mass_flow*eps', 'kg') # Define controls
"""Bryson-Denham problem""" # TODO: Costate estimates seem to be off by a factor of -2. See Issue #143 import beluga import logging ocp = beluga.Problem('Bryson-Denham') # Define independent variables ocp.independent('t', 's') # Define equations of motion ocp.state('x', 'v', 'm') ocp.state('v', 'u', 'm/s') # Define controls ocp.control('u', 'rad') # Define constants ocp.constant('x_0', 0, 'm') ocp.constant('x_f', 0, 'm') ocp.constant('v_0', 1, 'm') ocp.constant('v_f', -1, 'm') ocp.constant('epsilon1', 10, 'rad**2') ocp.constant('x_max', 0.3, 'm') # Define costs ocp.path_cost('u**2', 'rad**2*s') # Define constraints ocp.initial_constraint('x - x_0', 'm')
""" References ---------- .. [1] Vinh, Nguyen X., Adolf Busemann, and Robert D. Culp. "Hypersonic and planetary entry flight mechanics." NASA STI/Recon Technical Report A 81 (1980). """ from math import * import beluga import logging ocp = beluga.Problem('planar_hypersonic') # Define independent variables ocp.independent('t', 's') # Define equations of motion ocp.state('h', 'v*sin(gam)', 'm') ocp.state('theta', 'v*cos(gam)/r', 'rad') ocp.state('v', '-D/mass - mu*sin(gam)/r**2', 'm/s') ocp.state('gam', 'L/(mass*v) + (v/r - mu/(v*r**2))*cos(gam)', 'rad') ocp.constant_of_motion('c1', 'lamTHETA', 'm**2/(s**2*rad)') # Define quantities used in the problem ocp.quantity('rho', 'rho0*exp(-h/H)') ocp.quantity('Cl', '(1.5658*alfa + -0.0000)') ocp.quantity('Cd', '(1.6537*alfa**2 + 0.0612)') ocp.quantity('D', '0.5*rho*v**2*Cd*Aref') ocp.quantity('L', '0.5*rho*v**2*Cl*Aref')