def inequality(prob, obj): r = prob.states_all_section(0) vr = prob.states_all_section(1) vt = prob.states_all_section(2) ur1 = prob.controls_all_section(0) ur2 = prob.controls_all_section(1) ut1 = prob.controls_all_section(2) ut2 = prob.controls_all_section(3) tf = prob.time_final(-1) result = Condition() # lower bounds result.lower_bound(r, obj.r0) result.lower_bound(ur1, 0.0) result.lower_bound(ut1, 0.0) result.lower_bound(ur2, 0.0) result.lower_bound(ut2, 0.0) result.lower_bound(tf, 0.0) # upper bounds result.upper_bound(r, obj.rf) result.upper_bound(ur1, obj.u_max) result.upper_bound(ut1, obj.u_max) result.upper_bound(ur2, obj.u_max) result.upper_bound(ut2, obj.u_max) result.upper_bound(tf, obj.tf_max) return result()
def inequality(prob, obj): u = prob.states_all_section(0) v = prob.states_all_section(1) x = prob.states_all_section(2) y = prob.states_all_section(3) beta = prob.controls_all_section(0) tf = prob.time_final(-1) result = Condition() # lower bounds result.lower_bound(beta, -np.pi / 2) # upper bounds result.upper_bound(beta, np.pi / 2) return result()
def inequality(prob, obj): x = prob.states_all_section(0) y = prob.states_all_section(1) v = prob.states_all_section(2) theta = prob.controls_all_section(0) tf = prob.time_final(-1) result = Condition() # lower bounds result.lower_bound(x, 0) result.lower_bound(y, 0) result.lower_bound(theta, 0) # upper bounds result.upper_bound(theta, np.pi) result.upper_bound(x, obj.l) return result()
def inequality(prob, obj): h = prob.states_all_section(0) v = prob.states_all_section(1) m = prob.states_all_section(2) T = prob.controls_all_section(0) tf = prob.time_final(-1) result = Condition() # lower bounds result.lower_bound(h, obj.H0) result.lower_bound(v, 0.0) result.lower_bound(m, obj.Mf) result.lower_bound(T, 0.0) result.lower_bound(tf, 0.1) # upper bounds result.upper_bound(m, obj.M0) result.upper_bound(T, obj.T_max) return result()
def inequality(prob, obj): R = prob.states_all_section(0) v = prob.states_all_section(1) m = prob.states_all_section(2) T = prob.controls_all_section(0) tf = prob.time_final(-1) result = Condition() # lower bounds result.lower_bound(R, obj.Re) result.lower_bound(v, 0.0) result.lower_bound(m, obj.M0 * obj.Mc) result.lower_bound(T, 0.0) result.lower_bound(tf, 10) # upper bounds result.upper_bound(m, obj.M0) result.upper_bound(T, obj.max_thrust * obj.M0 * obj.g0) return result()
def _og_inequality(self, prob, obj): """ define inequality conditions """ s = [prob.states_all_section(i) for i in range(5)] result = Condition() u_m = prob.controls(0, 0) u_a = prob.controls(1, 0) result.lower_bound(u_m, 0) result.upper_bound(u_m, 1) result.lower_bound(u_a, (-np.pi/2)) #thrust force to the left result.upper_bound(u_a, (+np.pi/2)) #thrust force to the right #bound states for i in range(5): result.lower_bound(s[i], obj.ranges[i][0]) result.upper_bound(s[i], obj.ranges[i][1]) #cone constraint result.lower_bound(s[1], 1.*s[0]) # z > (1/tan(th)) * x return result()
def inequality(prob, obj): R = prob.states_all_section(0) theta = prob.states_all_section(1) Vr = prob.states_all_section(2) Vt = prob.states_all_section(3) m = prob.states_all_section(4) Tr = prob.controls_all_section(0) Tt = prob.controls_all_section(1) tf = prob.time_final(-1) rho = obj.air_density(R - obj.Re) Dr = 0.5 * rho * Vr * np.sqrt(Vr**2 + Vt**2) \ * obj.Cd * obj.A # [N] Dt = 0.5 * rho * Vt * np.sqrt(Vr**2 + Vt**2) \ * obj.Cd * obj.A # [N] g = obj.g0 * (obj.Re / R)**2 # [m/s2] # dynamic pressure q = 0.5 * rho * (Vr**2 + Vt**2) # [Pa] # accelaration a_r = (Tr - Dr) / m a_t = (Tt - Dt) / m a_mag = np.sqrt(a_r**2 + a_t**2) # [m/s2] # Thrust T = np.sqrt(Tr**2 + Tt**2) result = Condition() # lower bounds result.lower_bound(R, obj.Re, unit=prob.unit_states[0][0]) # result.lower_bound(Vr, 0.0, unit=prob.unit_states[0][2]) # result.lower_bound(Vt, 0.0, unit=prob.unit_states[0][3]) result.lower_bound(m[1:], (obj.M0 - obj.Mp), unit=prob.unit_states[0][4]) result.lower_bound(Tr, 0.0, unit=prob.unit_controls[0][0]) # result.lower_bound(Tt, obj.Tmax / obj.unit_T, unit=prob.unit_controls[0][0]) result.lower_bound(Tt, 0.0, unit=prob.unit_controls[0][0]) # upper bounds result.upper_bound(m, obj.M0, unit=prob.unit_states[0][4]) result.upper_bound(Tr, obj.Tmax, unit=prob.unit_controls[0][0]) result.upper_bound(Tt, obj.Tmax, unit=prob.unit_controls[0][0]) result.upper_bound(T, obj.Tmax, unit=prob.unit_controls[0][0]) # result.upper_bound(q, obj.MaxQ, unit = prob.unit_states[0][0]) result.upper_bound(a_mag, obj.MaxG * obj.g0) return result()
def inequality(prob, obj): R = prob.states_all_section(0) theta = prob.states_all_section(1) Vr = prob.states_all_section(2) Vt = prob.states_all_section(3) m = prob.states_all_section(4) Tr = prob.controls_all_section(0) Tt = prob.controls_all_section(1) tf = prob.time_final(-1) R0 = prob.states(0, 0) R1 = prob.states(0, 1) theta0 = prob.states(1, 0) theta1 = prob.states(1, 1) Vr0 = prob.states(2, 0) Vr1 = prob.states(2, 1) Vt0 = prob.states(3, 0) Vt1 = prob.states(3, 1) m0 = prob.states(4, 0) m1 = prob.states(4, 1) Tr0 = prob.controls(0, 0) Tr1 = prob.controls(0, 1) Tt0 = prob.controls(1, 0) Tt1 = prob.controls(1, 1) rho = obj.airDensity(R - obj.Re) Mach = np.sqrt(Vr**2 + Vt**2) / obj.airSound(R - obj.Re) Cd = obj.Cd(Mach) Dr0 = 0.5 * rho * Vr * np.sqrt(Vr**2 + Vt**2) * Cd * obj.A[0] # [N] Dt0 = 0.5 * rho * Vt * np.sqrt(Vr**2 + Vt**2) * Cd * obj.A[0] # [N] Dr1 = 0.5 * rho * Vr * np.sqrt(Vr**2 + Vt**2) * Cd * obj.A[1] # [N] Dt1 = 0.5 * rho * Vt * np.sqrt(Vr**2 + Vt**2) * Cd * obj.A[1] # [N] g = obj.g0 * (obj.Re / R)**2 # [m/s2] # dynamic pressure q = 0.5 * rho * (Vr**2 + Vt**2) # [Pa] # accelaration a_r0 = (Tr - Dr0) / m a_t0 = (Tt - Dt0) / m a_mag0 = np.sqrt(a_r0**2 + a_t0**2) # [m/s2] a_r1 = (Tr - Dr1) / m a_t1 = (Tt - Dt1) / m a_mag1 = np.sqrt(a_r1**2 + a_t1**2) # [m/s2] # Thrust T0 = np.sqrt(Tr0**2 + Tt0**2) T1 = np.sqrt(Tr1**2 + Tt1**2) dThrust0 = (obj.airPressure(obj.H0) - obj.airPressure(R0 - obj.Re)) * obj.Ae[0] dThrust1 = obj.airPressure(R1 - obj.Re) * obj.Ae[1] result = Condition() # lower bounds result.lower_bound(R, obj.Re, unit=prob.unit_states[0][0]) # 地表以下 result.lower_bound(m0, obj.Mdry[0] + obj.M0[1], unit=prob.unit_states[0][4]) # 乾燥質量以下 result.lower_bound(m1, obj.Mdry[1], unit=prob.unit_states[0][4]) result.lower_bound(Tr, -obj.ThrustMax[1], unit=prob.unit_controls[0][0]) result.lower_bound(Tt, -obj.ThrustMax[1], unit=prob.unit_controls[0][0]) # upper bounds result.upper_bound(m0, obj.Minit, unit=prob.unit_states[0][4]) # 初期質量以上 result.upper_bound(m1, obj.M0[1], unit=prob.unit_states[0][4]) result.upper_bound(Tr0, obj.ThrustMax[0] + dThrust0, unit=prob.unit_controls[0][0]) result.upper_bound(Tt0, obj.ThrustMax[0] + dThrust0, unit=prob.unit_controls[0][0]) result.upper_bound(T0, obj.ThrustMax[0] + dThrust0, unit=prob.unit_controls[0][0]) result.upper_bound(Tr1, obj.ThrustMax[1] + dThrust1, unit=prob.unit_controls[0][0]) result.upper_bound(Tt1, obj.ThrustMax[1] + dThrust1, unit=prob.unit_controls[0][0]) result.upper_bound(T1, obj.ThrustMax[1] + dThrust1, unit=prob.unit_controls[0][0]) result.upper_bound(q, obj.MaxQ, unit=prob.unit_states[0][0]) result.upper_bound(a_mag0, obj.MaxG * obj.g0) result.upper_bound(a_mag1, obj.MaxG * obj.g0) return result()