Skip to content

Commit 80ece6a

Browse files
committed
1) LVD: Added total thrust constraint
2) Adjusted all altitude constraints to have an allowable lower bound of -Inf
1 parent d2fd9e9 commit 80ece6a

4 files changed

Lines changed: 151 additions & 3 deletions

File tree

helper_methods/ksptot_ma/launch_vehicle_designer/classes/Optimization/constraints/@ConstraintEnum/ConstraintEnum.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
InertialBankAngle('Inertial Bank Angle','InertialBankAngleConstraint',[]);
6565
InertialSideSlipAngle('Inertial Side Slip Angle','InertialSideSlipAngleConstraint',[]);
6666

67+
TotalThrust('Total Thrust','TotalThrustConstraint',[]);
68+
6769
StopwatchValue('Stopwatch Value','StopwatchValueConstraint',[]);
6870
end
6971

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
classdef TotalThrustConstraint < AbstractConstraint
2+
%TotalThrustConstraint Summary of this class goes here
3+
% Detailed explanation goes here
4+
5+
properties
6+
normFact = 1;
7+
event(1,:) LaunchVehicleEvent
8+
9+
lb(1,1) double = 0;
10+
ub(1,1) double = 0;
11+
end
12+
13+
methods
14+
function obj = TotalThrustConstraint(event, lb, ub)
15+
obj.event = event;
16+
obj.lb = lb;
17+
obj.ub = ub;
18+
19+
obj.id = rand();
20+
end
21+
22+
function [lb, ub] = getBounds(obj)
23+
lb = obj.lb;
24+
ub = obj.ub;
25+
end
26+
27+
function [c, ceq, value, lwrBnd, uprBnd, type, eventNum] = evalConstraint(obj, stateLog, celBodyData)
28+
type = obj.getConstraintType();
29+
stateLogEntry = stateLog.getLastStateLogForEvent(obj.event);
30+
31+
ut = stateLogEntry.time;
32+
rVect = stateLogEntry.position;
33+
vVect = stateLogEntry.velocity;
34+
35+
bodyInfo = stateLogEntry.centralBody;
36+
tankStates = stateLogEntry.getAllActiveTankStates();
37+
stageStates = stateLogEntry.stageStates;
38+
lvState = stateLogEntry.lvState;
39+
40+
dryMass = stateLogEntry.getTotalVehicleDryMass();
41+
tankStatesMasses = [tankStates.tankMass]';
42+
43+
throttleModel = stateLogEntry.throttleModel;
44+
steeringModel = stateLogEntry.steeringModel;
45+
46+
altitude = norm(rVect) - bodyInfo.radius;
47+
pressure = getPressureAtAltitude(bodyInfo, altitude);
48+
49+
throttle = throttleModel.getThrottleAtTime(ut, rVect, vVect, tankStatesMasses, dryMass, stageStates, lvState, tankStates, bodyInfo);
50+
51+
[~, totalThrust, ~] = LaunchVehicleStateLogEntry.getTankMassFlowRatesDueToEngines(tankStates, tankStatesMasses, stageStates, throttle, lvState, pressure, ut, rVect, vVect, bodyInfo, steeringModel);
52+
53+
value = totalThrust;
54+
55+
if(obj.lb == obj.ub)
56+
c = [];
57+
ceq(1) = value - obj.ub;
58+
else
59+
c(1) = obj.lb - value;
60+
c(2) = value - obj.ub;
61+
ceq = [];
62+
end
63+
c = c/obj.normFact;
64+
ceq = ceq/obj.normFact;
65+
66+
lwrBnd = obj.lb;
67+
uprBnd = obj.ub;
68+
69+
eventNum = obj.event.getEventNum();
70+
end
71+
72+
function sF = getScaleFactor(obj)
73+
sF = obj.normFact;
74+
end
75+
76+
function setScaleFactor(obj, sF)
77+
obj.normFact = sF;
78+
end
79+
80+
function tf = usesStage(obj, stage)
81+
tf = false;
82+
end
83+
84+
function tf = usesEngine(obj, engine)
85+
tf = false;
86+
end
87+
88+
function tf = usesTank(obj, tank)
89+
tf = false;
90+
end
91+
92+
function tf = usesEngineToTankConn(obj, engineToTank)
93+
tf = false;
94+
end
95+
96+
function tf = usesEvent(obj, event)
97+
tf = obj.event == event;
98+
end
99+
100+
function tf = usesStopwatch(obj, stopwatch)
101+
tf = false;
102+
end
103+
104+
function event = getConstraintEvent(obj)
105+
event = obj.event;
106+
end
107+
108+
function type = getConstraintType(obj)
109+
type = 'Total Thrust';
110+
end
111+
112+
function name = getName(obj)
113+
name = sprintf('%s - Event %i', obj.getConstraintType(), obj.event.getEventNum());
114+
end
115+
116+
function [unit, lbLim, ubLim, usesLbUb, usesCelBody, usesRefSc] = getConstraintStaticDetails(obj)
117+
unit = 'kN';
118+
lbLim = 0;
119+
ubLim = Inf;
120+
usesLbUb = true;
121+
usesCelBody = false;
122+
usesRefSc = false;
123+
end
124+
125+
function addConstraintTf = openEditConstraintUI(obj, lvdData)
126+
addConstraintTf = lvd_EditGenericMAConstraintGUI(obj, lvdData);
127+
end
128+
end
129+
130+
methods(Static)
131+
function constraint = getDefaultConstraint(~)
132+
constraint = TotalThrustConstraint(LaunchVehicleEvent.empty(1,0),0,0);
133+
end
134+
end
135+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function twRatio = computeTWRatio(throttle, ut, rVect, vVect, tankMasses, dryMass, stgStates, lvState, tankStates, bodyInfo)
2+
altitude = norm(rVect) - bodyInfo.radius;
3+
presskPa = getPressureAtAltitude(bodyInfo, altitude);
4+
5+
[~, totalThrust]= LaunchVehicleStateLogEntry.getTankMassFlowRatesDueToEngines(tankStates, tankMasses, stgStates, throttle, lvState, presskPa, ut, rVect, vVect, bodyInfo, []);
6+
7+
totalMass = (dryMass + sum(tankMasses))*1000; %kg
8+
totalThrust = totalThrust * 1000; % N
9+
10+
twRatio = computeSLThrustToWeight(bodyInfo, totalThrust, totalMass);
11+
end

helper_methods/ksptot_ma/optimization/ma_getConstraintStaticDetails.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@
233233
usesRefSc = false;
234234
case 'Altitude of Apoapsis'
235235
unit = 'km';
236-
lbLim = 0;
236+
lbLim = -Inf;
237237
ubLim = Inf;
238238
lbVal = 0;
239239
ubVal = 0;
@@ -245,7 +245,7 @@
245245
usesRefSc = false;
246246
case 'Altitude of Periapsis'
247247
unit = 'km';
248-
lbLim = 0;
248+
lbLim = -Inf;
249249
ubLim = Inf;
250250
lbVal = 0;
251251
ubVal = 0;
@@ -553,7 +553,7 @@
553553
usesRefSc = false;
554554
case 'Altitude'
555555
unit = 'km';
556-
lbLim = 0;
556+
lbLim = -Inf;
557557
ubLim = Inf;
558558
lbVal = 0;
559559
ubVal = 0;

0 commit comments

Comments
 (0)