In [1]:
import sympy as sm
# make the math look pretty
sm.init_printing()
In [33]:
# define all the symbols we will be using
#env parameters
g = sm.Symbol("g")
rho = sm.Symbol("rho")
#wind parameters
#thermals modelled with vertical airflows only
# vehicle parameters
e = sm.Symbol("e")
alph0 = sm.Symbol("alpha_0")
AR = sm.Symbol("AR")
m = sm.Symbol("m")
l = sm.Symbol("l")
Vh = sm.Symbol("V_H")
Vv = sm.Symbol("V_V")
Rf = sm.Symbol("V_F")
CLmin = sm.Symbol("C_{L_{min}}")
Cd0 = sm.Symbol("C_{D_0}")
Cdf = sm.Symbol("C_{D_f}")
CdL = sm.Symbol("C_{d_L}")
Cde = sm.Symbol("C_{d_e}")
Cdt = sm.Symbol("C_{d_t}")
a0 = sm.Symbol("a_0")
#variables
alpha = sm.Symbol("alpha")
alphaw = sm.Symbol("alpha_w")
beta = sm.Symbol("beta")
betaw = sm.Symbol("beta_w")
x = sm.Symbol("x")
y = sm.Symbol("y")
h = sm.Symbol("h")
chi = sm.Symbol("chi")
gamma = sm.Symbol("gamma")
sigma = sm.Symbol("sigma")
chiw = sm.Symbol("chi_w")
gammaw = sm.Symbol("gamma_w")
sigmaw = sm.Symbol("sigma_w")
V = sm.Symbol("V")
Vw = sm.Symbol("V_w")
D = sm.Symbol("D")
L = sm.Symbol("L")
C = sm.Symbol("C")
In [39]:
# relations
q = 1./2.*rho*(V**2)
qw = 1./2.*rho*(Vw**2)
S = (l**2)/AR
cbar = 1.03*l/AR
lt = 0.28*l
lf = 0.5*l
S = l**2/AR
St = Vh*cbar*S/lt
Sv = Vv*l*S/lt
Sf = 2.0*sm.pi*Rf*l*lf
ARv = 0.5*AR
Rvi = sm.Matrix([[sm.cos(chi),-sm.sin(chi),0.],[sm.sin(chi),sm.cos(chi),0.],[0.,0.,1.]])*sm.Matrix([[sm.cos(gamma),0.,sm.sin(gamma)],[0.,1.,0.],[-sm.sin(gamma),0.,sm.cos(gamma)]])*sm.Matrix([[1.,0.,0.],[0.,sm.cos(sigma),-sm.sin(sigma)],[0.,sm.sin(sigma),sm.cos(sigma)]])
Rbv = sm.Matrix([[sm.cos(alpha),0.,sm.sin(alpha)],[0.,1.,0.],[-sm.sin(alpha),0.,sm.cos(alpha)]])*sm.Matrix([[sm.cos(beta),sm.sin(beta),0.],[-sm.sin(beta),sm.cos(beta),0.],[0.,0.,1.]])
Tiv = Rvi
Rwi = Rvi.subs(chi,chiw).subs(gamma,gammaw).subs(sigma,sigmaw)
Rbw = Rbv.subs(alpha,alphaw).subs(beta,betaw)
#aerodynamics
#lift
CLa = a0 / (1.0+a0/(sm.pi*e*AR))
#drag
CD0 = Cdf*Sf/S + Cdt*(St + Sv)/S + Cde + Cd0
Rwi
Out[39]:
In [28]:
# forces
#lift
CL = CLa*(alphaw - alph0)
Lw = qw*S*CL
#side
CC = CLa*Sv/S*betaw
Cw = qw*S*CC
#drag
CD = CD0 + CdL*((CL - CLmin)**2) + (CL**2)/(sm.pi*e*AR) + (Cw**2)/(sm.pi*e*AR)*(S/Sv)
Dw = qw*S*CD
In [24]:
# Dynamics
z = -h
dh = V*sm.sin(gamma)
dz = -dh
dx = V*sm.cos(chi)*sm.cos(gamma)
dy = V*sm.sin(chi)*sm.cos(gamma)
dV = -D/m-g*sm.sin(gamma)
dgamma = 1.0/(m*V)*(L*sm.cos(sigma) + C*sm.sin(sigma))-g/V*sm.cos(gamma)
dchi = 1.0/(m*V*sm.cos(gamma))*(L*sm.sin(sigma) - C*sm.cos(sigma))
f = sm.Matrix([[dh],[dx],[dy],[dV],[dgamma],[dchi]])
Vvec = sm.Matrix([[dx],[dy],[dz]])
f
Out[24]:
In [85]:
sm.Matrix([f.diff(chi).transpose(), f.diff(gamma).transpose()]).transpose()
Out[85]:
In [ ]: