def setup(self, static, state): Pshaft = Variable("P_{shaft}", "hp", "Shaft power") bsfc = Variable("BSFC", "kg/kW/hr", "Brake specific fuel consumption") Pavn = Variable("P_{avn}", 40, "watts", "Avionics power") Ptotal = Variable("P_{total}", "hp", "Total power, avionics included") eta_alternator = Variable("\\eta_{alternator}", 0.8, "-", "alternator efficiency") href = Variable("h_{ref}", 1000, "ft", "reference altitude") h_vals = state.substitutions("h") if len(href) == 1: h_vals = [h_vals] lfac = [-0.035*(v/hr.value) + 1.0 for v, hr in zip(h_vals, href)] Leng = Variable("L_{eng}", lfac, "-", "shaft power loss factor") Pshaftmax = Variable("P_{shaft-max}", "hp", "Max shaft power at altitude") mfac = Variable("m_{fac}", 1.0, "-", "BSFC margin factor") path = os.path.dirname(__file__) df = pd.read_csv(path + os.sep + "powerBSFCfit.csv").to_dict( orient="records")[0] constraints = [ FitCS(df, bsfc/mfac/static["BSFC_{min}"], [Ptotal/Pshaftmax]), Pshaftmax/static["P_{sl-max}"] == Leng, Pshaftmax >= Ptotal, Ptotal >= Pshaft + Pavn/eta_alternator ] return constraints
def setup(self, aircraft, sp=False): fs = FlightState() A = Variable("A", "m/s**2", "log fit equation helper 1") B = Variable("B", "1/m", "log fit equation helper 2") g = Variable("g", 9.81, "m/s**2", "gravitational constant") mu = Variable("\\mu_b", 0.025, "-", "coefficient of friction") T = Variable("T", "lbf", "take off thrust") cda = Variable("CDA", 0.024, "-", "parasite drag coefficient") CLg = Variable("C_{L_g}", "-", "ground lift coefficient") CDg = Variable("C_{D_g}", "-", "grag ground coefficient") cdp = Variable("c_{d_{p_{stall}}}", 0.025, "-", "profile drag at Vstallx1.2") Kg = Variable("K_g", 0.04, "-", "ground-effect induced drag parameter") CLto = Variable("C_{L_{TO}}", 3.5, "-", "max lift coefficient") Vstall = Variable("V_{stall}", "knots", "stall velocity") e = Variable("e", 0.8, "-", "span efficiency") zsto = Variable("z_{S_{TO}}", "-", "take off distance helper variable") Sto = Variable("S_{TO}", "ft", "take off distance") Sground = Variable("S_{ground}", "ft", "ground roll") etaprop = Variable("\\eta_{prop}", 0.8, "-", "propellor efficiency") msafety = Variable("m_{fac}", 1.4, "-", "safety margin") path = os.path.dirname(os.path.abspath(__file__)) df = pd.read_csv(path + os.sep + "logfit.csv") fd = df.to_dict(orient="records")[0] constraints = [ T / aircraft.topvar("W") >= A / g + mu, T <= aircraft["P_{shaft-max}"] * etaprop / fs["V"], CDg >= 0.024 + cdp + CLto**2 / pi / aircraft["AR"] / e, Vstall == (2 * aircraft.topvar("W") / fs["\\rho"] / aircraft.wing["S"] / CLto)**0.5, fs["V"] == 1.3 * Vstall, FitCS(fd, zsto, [A / g, B * fs["V"]**2 / g]), Sground >= 1.0 / 2.0 / B * zsto, Sto / msafety >= Sground ] if sp: with SignomialsEnabled(): constraints.extend([ (B * aircraft.topvar("W") / g + 0.5 * fs["\\rho"] * aircraft.wing["S"] * mu * CLto >= 0.5 * fs["\\rho"] * aircraft.wing["S"] * CDg) ]) else: constraints.extend([ B >= (g / aircraft.topvar("W") * 0.5 * fs["\\rho"] * aircraft.wing["S"] * CDg) ]) return constraints, fs
def setup(self, aircraft): fs = FlightState() A = Variable("A", "m/s**2", "log fit equation helper 1") B = Variable("B", "1/m", "log fit equation helper 2") g = Variable("g", 9.81, "m/s**2", "gravitational constant") mu = Variable("\\mu", 0.5, "-", "Braking coefficient of friction") T_rev = Variable("T", "N", "Reverse thrust") cda = Variable("CDA", 0.024, "-", "parasite drag coefficient") CLg = Variable("C_{L_g}", "-", "ground lift coefficient") CDg = Variable("C_{D_g}", "-", "grag ground coefficient") Vstall = Variable("V_{stall}", "knots", "stall velocity") Sgr = Variable("S_{gr}", "ft", "landing ground roll") Slnd = Variable("S_{land}", "ft", "landing distance") etaprop = Variable("\\eta_{prop}", 0.05, "-", "propellor efficiency") msafety = Variable("m_{fac}", 1.4, "-", "Landing safety margin") CLland = Variable("C_{L_{land}}", 3.5, "-", "landing CL") cdp = Variable("c_{d_{p_{stall}}}", 0.025, "-", "profile drag at Vstallx1.2") V_ref = Variable("V_{ref}", "kts", "Approach reference speed") f_ref = Variable("f_{ref}", 1.3, "-", "Approach reference speed margin above stall") path = os.path.dirname(os.path.abspath(__file__)) df = pd.read_csv(path + os.sep + "logfit.csv") fd = df.to_dict(orient="records")[0] constraints = [ T_rev == aircraft["P_{shaft-max}"] * etaprop / fs["V"], Vstall == (2. * aircraft.topvar("W") / fs["\\rho"] / aircraft["S"] / CLland)**0.5, fs["V"] >= f_ref * Vstall, V_ref == fs["V"], Slnd >= msafety * Sgr, FitCS(fd, Sgr * 2 * B, [A / g, B * fs["V"]**2 / g]), ] with SignomialsEnabled(): constraints.extend([ TCS([(B * aircraft.topvar("W") / g + 0.5 * fs["\\rho"] * aircraft["S"] * CDg >= 0.5 * fs["\\rho"] * aircraft["S"] * mu * CLland)]), TCS([A / g <= T_rev / aircraft.topvar("W") + mu]), CDg <= cda + cdp + CLland**2 / pi / aircraft["AR"] / aircraft["e"], ]) return constraints, fs
def setup(self, wing, state, out=False): exec parse_variables(GustL.__doc__) self.load = SparLoading.setup(self, wing, state, out=out) cbar = self.wing.planform.cbar W = self.W # from SparLoading q = self.q N = self.N b = self.b path = os.path.dirname(os.path.abspath(__file__)) df = pd.read_csv(path + os.sep + "arctan_fit.csv").to_dict( orient="records")[0] constraints = [ # fit for arctan from 0 to 1, RMS = 0.044 FitCS(df, agust, [cosminus1*vgust/v]), q >= W*N/b*cbar*(1 + 2*pi*agust/cl*(1+Ww/W)), ] return self.load, constraints
def setup(self, wing): exec parse_variables(GustL.__doc__) self.load = SparLoading.setup(self, wing) self.b = self.wing.planform.b self.I = self.wing.spar.I self.Sy = self.wing.spar.Sy self.cave = self.wing.planform.cave self.tshear = self.wing.spar.tshear path = os.path.dirname(os.path.abspath(__file__)) df = pd.read_csv(path + os.sep + "arctan_fit.csv").to_dict(orient="records")[0] constraints = [ # fit for arctan from 0 to 1, RMS = 0.044 FitCS(df, agust, [cosminus1 * vgust / v]), self.beam["\\bar{q}"] >= self.wing.planform.cbar * (1 + 2 * pi * agust / cl * (1 + Ww / self.W)), ] return self.load, constraints
def setup(self, DF70=False): self.DF70 = DF70 W = Variable("W", "lbf", "Installed/Total engine weight") mfac = Variable("m_{fac}", 1.0, "-", "Engine weight margin factor") bsfc_min = Variable("BSFC_{min}", 0.3162, "kg/kW/hr", "minimum BSFC") Pref = Variable("P_{ref}", 10.0, "hp", "Reference shaft power") Wengref = Variable("W_{eng-ref}", 10.0, "lbf", "Reference engine weight") Weng = Variable("W_{eng}", "lbf", "engine weight") Pslmax = Variable("P_{sl-max}", "hp", "Max shaft power at sea level") path = os.path.dirname(__file__) df = pd.read_csv(path + os.sep + "power_lawfit.csv").to_dict( orient="records")[0] constraints = [ FitCS(df, Weng/Wengref, [Pslmax/Pref]), W/mfac >= 2.572*Weng**0.922*units("lbf")**0.078] return constraints