convexengineering / gplibrary

Useful subsystem models
MIT License
10 stars 11 forks source link

Splitting markdown files into sections #66

Closed mjburton11 closed 8 years ago

mjburton11 commented 8 years ago

@bqpd, @whoburg: essentially what I want my pdf to look like is:

Weight Model: Assumptions List of all my assumptions Variables List of all my variables Constraints List of all my constraints

Aero Model: Same thing

Then the solution table.

Any idea on how to do this? You can look at my latest commit in 1682master to see my md file.


SOLAR HIGH ALTITUDE LONG ENDURANCE AIRCRAFT

#inPDF: skip

from gpkit import Variable, Model, units
import numpy as np
import matplotlib.pyplot as plt

class SolarHALE(Model):
    """High altitude long endurance solar UAV"""
    def __init__(self, **kwargs):
        """Setup method should return objective, list of constraints"""
        constraints = []

Steady level flight variables

#inPDF: replace with slfvars.generated.tex
        CD = Variable('C_D', '-', 'Drag coefficient')
        CL = Variable('C_L', '-', 'Lift coefficient')
        P_shaft = Variable('P_{shaft}', 'W', 'Shaft power')
        S = Variable('S', 'm^2', 'Wing reference area')
        V = Variable('V', 'm/s', 'Cruise velocity')
        W = Variable('W', 'lbf', 'Aircraft weight')

        eta_prop = Variable(r'\eta_{prop}', 0.7, '-', 'Propulsive efficiency')
        rho = Variable(r'\rho', 'kg/m^3')
#inPDF: replace with slfcnstrs.generated.tex

        constraints.extend([P_shaft >= V*W*CD/CL/eta_prop,   # eta*P = D*V
                            W == 0.5*rho*V**2*CL*S])

Aerodynamics model

#inPDF: replace with aerovars.generated.tex

        Cd0 = Variable('C_{d0}', 0.002, '-', "non-wing drag coefficient")
        cdp = Variable("c_{dp}", "-", "wing profile drag coeff")
        CLmax = Variable('C_{L-max}', 1.5, '-', 'maximum lift coefficient')
        e = Variable('e', 0.9, '-', "spanwise efficiency")
        AR = Variable('AR', 27, '-', "aspect ratio")
        b = Variable('b', 'ft', 'span')
        mu = Variable(r'\mu', 1.5e-5, 'N*s/m^2', "dynamic viscosity")
        Re = Variable("Re", '-', "Reynolds number")
        Re_ref = Variable("Re_{ref}", 3e5, "-", "Reference Re for cdp")
        Cf = Variable("C_f", "-", "wing skin friction coefficient")
        Kwing = Variable("K_{wing}", 1.3, "-", "wing form factor")
#inPDF: replace with aerocnstrs.generated.tex

        constraints.extend([
            CD >= (Cd0 + cdp + CL**2/(np.pi*e*AR))*1.3,
            cdp >= ((0.006 + 0.005*CL**2 + 0.00012*CL**10)*(Re/Re_ref)**-0.3),
            b**2 == S*AR,
            CL <= CLmax,
            Re == rho*V/mu*(S/AR)**0.5,
            ])

Weight model

#inPDF: replace with weightvars.generated.tex
        W_batt = Variable('W_{batt}', 'lbf', 'Battery weight')
        W_airframe = Variable('W_{airframe}', 'lbf', 'Airframe weight')
        W_solar = Variable('W_{solar}', 'lbf', 'Solar panel weight')
        W_pay = Variable(r'W_{pay}', 4, 'lbf', 'Aircraft weight')

        E_batt = Variable('E_{batt}', 'J', 'Battery energy')
        rho_solar = Variable(r'\rho_{solar}', 1.2, 'kg/m^2',
                             'Solar cell area density')
        f_airframe = Variable('f_{airframe}', 0.20, '-',
                              'Airframe weight fraction')
        h_batt = Variable('h_{batt}', 250, 'W*hr/kg', 'Battery energy density')
        g = Variable('g', 9.81, 'm/s^2', 'Gravitational acceleration')
#inPDF: replace with weightcnstrs.generated.tex

        constraints.extend([W_airframe >= W*f_airframe,
                            W_batt >= E_batt/h_batt*g,
                            W_solar >= rho_solar*g*S,
                            W >= W_pay + W_solar + W_airframe + W_batt])
mjburton11 commented 8 years ago

@bqpd, I don't have class today so if it would help to meet up to talk about what I'm envisioning then let me know.

whoburg commented 8 years ago

was this resolved by using individual ConstraintSets?

mjburton11 commented 8 years ago

Yes it was.