-
Notifications
You must be signed in to change notification settings - Fork 1
/
master.jl
142 lines (126 loc) · 4.11 KB
/
master.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
module RocketlandDefns
using StaticArrays
using Interpolations
using MathOptInterface
using LinearAlgebra
abstract type AerodynamicInfo end
struct ExoatmosphericData <: AerodynamicInfo end
struct AtmosphericData{T} <: AerodynamicInfo
drag_itrp :: T
lift_itrp :: T
trq_itrp :: T
force_scalar :: Float64
length_scalar :: Float64
end
struct DescentProblem{T<:AerodynamicInfo}
g::Float64
mdry::Float64
mwet::Float64
Tmin::Float64
Tmax::Float64
deltaMax::Float64
thetaMax::Float64
gammaGs::Float64
omMax::Float64
dpMax::Float64 # max dynamic pressure Pa
jB::Array{Float64,2}
alpha::Float64
rho::Float64 # atmospheric density kg/m^3
sos::Float64 # speed of sound m/s
rTB::Array{Float64,1}
rFB::Array{Float64,1}
rIi::Array{Float64,1}
rIf::Array{Float64,1}
vIi::Array{Float64,1}
vIf::Array{Float64,1}
qBIi::Array{Float64,1}
qBIf::Array{Float64,1}
wBi::Array{Float64,1}
wBf::Array{Float64,1}
aero::T
K::Int64
imax::Int64
wNu::Float64
wID::Float64
wDS::Float64
wCst::Float64
wTviol::Float64
nuTol::Float64
delTol::Float64
tf_guess::Float64
ri::Float64
rh0::Float64
rh1::Float64
rh2::Float64
alph::Float64
bet::Float64
DescentProblem(;g=1.0,mdry=1.0,mwet=2.0,Tmin=0.3,Tmax=5.0,deltaMax=20.0,thetaMax=90.0,gammaGs=20.0,dpMax=50000,omMax=60.0,
jB=diagm(0=>[1e-2,1e-2,1e-2]), alpha=0.01, rho=1.225,rTB=[-1e-2,0,0],rFB=[1e-2,0,0],rIi=[4.0,4.0,0.0],rIf=[0.0,0.0,0.0],
vIi=[0,-2,2],vIf=[-0.1,0.0,0.0],qBIi=[1.0,0,0,0],qBIf=[1.0,0,0,0],wBi=[0.0,0.0,0.0], aero = ExoatmosphericData(),
wBf=[0.0,0,0],K=50,imax=15,wNu=1e5,wID=1e-3, wDS=1e-1, wCst=10.0, wTviol=100.0, nuTol=1e-10, delTol = 1e-3, tf_guess=1.0, ri=1.0, rh0=0.0, rh1=0.25, rh2=0.90, alph=2.0, bet=3.2, sos=5.0) =
new{typeof(aero)}(g,mdry,mwet,Tmin,Tmax,deltaMax,thetaMax,gammaGs,omMax,dpMax,jB,alpha,rho,sos,rTB,rFB,rIi,rIf,vIi,vIf,
qBIi,qBIf,wBi,wBf,aero,K,imax,wNu,wID,wDS,wCst,wTviol,nuTol,delTol,tf_guess,ri,rh0,rh1,rh2, alph, bet)
end
struct ProbInfo{T<:AerodynamicInfo}
a::Float64
g0::Float64
sos::Float64
jB::SArray{Tuple{3,3},Float64,2,9}
jBi::SArray{Tuple{3,3},Float64,2,9}
rTB::SArray{Tuple{3}, Float64, 1, 3}
rFB::SArray{Tuple{3}, Float64, 1, 3}
aero::T
ProbInfo(from::DescentProblem{T}) where T = new{T}(from.alpha, from.g, from.sos, SMatrix{3,3}(from.jB), SMatrix{3,3}(inv(from.jB)), SVector{3}(from.rTB), SVector{3}(from.rFB), from.aero)
end
struct LinPoint
state::Array{Float64, 1} # SArray{Tuple{14}, Float64, 1, 14}
control::Array{Float64, 1} # SArray{Tuple{3}, Float64, 1, 3}
end
struct LinRes
endpoint::Array{Float64, 1}#SArray{Tuple{14},Float64,1,14}
derivative::Array{Float64, 2}#SArray{Tuple{14,21},Float64,2,294}
end
const MOI=MathOptInterface
struct ProblemModel
socp_model::MOI.ModelLike
xv::Array{MOI.VariableIndex,2}
uv::Array{MOI.VariableIndex,2}
dxv::Array{MOI.VariableIndex,2}
duv::Array{MOI.VariableIndex,2}
dsv::MOI.VariableIndex
nuv::Array{MOI.VariableIndex,2}
rk::MOI.VariableIndex
state_base::MOI.ConstraintIndex
control_base::MOI.ConstraintIndex
dynamic_constraints::Vector{MOI.ConstraintIndex}
thrust_lb_constraint::MOI.ConstraintIndex
rkc::MOI.ConstraintIndex
debug
end
mutable struct IntegratorCache
sim_prob::Any
sense_prob::Any
sim_int::Any
sense_int::Any
params::Any
info::ProbInfo
end
struct ProblemIteration
problem::DescentProblem
cache::IntegratorCache
sigma::Float64
about::Array{LinPoint,1}
dynam::Array{LinRes,1}
model::ProblemModel
iter::Int64
rk::Float64
cost::Float64
end
export DescentProblem, ProbInfo, LinPoint, LinRes, ProblemIteration, ProblemModel, AerodynamicInfo, AtmosphericData, ExoatmosphericData, IntegratorCache
end
include("aerodynamics.jl")
include("symbolic_diff.jl")
include("dynamics.jl")
include("initial_solve.jl")
include("rocketland.jl")
include("sample_problems.jl")