def f_q_vlm(x, velocity, airplane): ap = vlm3( airplane=airplane, op_point=OperatingPoint( velocity=velocity, alpha=0, beta=0, p=0, q=x, r=0, ), ) ap.run() return {"CL": check_if_nan(ap.CL), "CD": check_if_nan(ap.CDi), "CY": check_if_nan(ap.CY), "Cm": check_if_nan(ap.Cm), "Cn": check_if_nan(ap.Cn),"Cl":check_if_nan(ap.Cl)}
def f_p(x, velocity): airplane = create_aircraft() try: airplane.set_spanwise_paneling_everywhere( 8) # Set the resolution of your analysis opti = cas.Opti() ap = Casll1( # Set up the AeroProblem airplane=airplane, op_point=OperatingPoint( density=1.225, # kg/m^3 viscosity=1.81e-5, # kg/m-s velocity=velocity, # m/s070 mach=0, # Freestream mach number alpha=0, # In degrees beta=0, # In degrees p=x, # About the body x-axis, in rad/sec q=0, # About the body y-axis, in rad/sec r=0, # About the body z-axis, in rad/sec ), opti=opti # Pass it an optimization environment to work in ) p_opts = {} s_opts = {} s_opts["mu_strategy"] = "adaptive" opti.solver('ipopt', p_opts, s_opts) try: sol = opti.solve() except RuntimeError: sol = opti.debug ap_sol = copy.deepcopy(ap) ap_sol.substitute_solution(sol) values = { "CL": check_if_nan(ap_sol.CL), "CD": check_if_nan(ap_sol.CD), "CY": check_if_nan(ap_sol.CY), "Cl": check_if_nan(ap_sol.Cl), "Cm": check_if_nan(ap_sol.Cm), "Cn": check_if_nan(ap_sol.Cn) } except: values = f_p_vlm(x, velocity, airplane) return values