-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1) LVD: Added total thrust constraint
2) Adjusted all altitude constraints to have an allowable lower bound of -Inf
- Loading branch information
Showing
4 changed files
with
151 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
..._designer/classes/Optimization/constraints/@TotalThrustConstraint/TotalThrustConstraint.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
classdef TotalThrustConstraint < AbstractConstraint | ||
%TotalThrustConstraint Summary of this class goes here | ||
% Detailed explanation goes here | ||
|
||
properties | ||
normFact = 1; | ||
event(1,:) LaunchVehicleEvent | ||
|
||
lb(1,1) double = 0; | ||
ub(1,1) double = 0; | ||
end | ||
|
||
methods | ||
function obj = TotalThrustConstraint(event, lb, ub) | ||
obj.event = event; | ||
obj.lb = lb; | ||
obj.ub = ub; | ||
|
||
obj.id = rand(); | ||
end | ||
|
||
function [lb, ub] = getBounds(obj) | ||
lb = obj.lb; | ||
ub = obj.ub; | ||
end | ||
|
||
function [c, ceq, value, lwrBnd, uprBnd, type, eventNum] = evalConstraint(obj, stateLog, celBodyData) | ||
type = obj.getConstraintType(); | ||
stateLogEntry = stateLog.getLastStateLogForEvent(obj.event); | ||
|
||
ut = stateLogEntry.time; | ||
rVect = stateLogEntry.position; | ||
vVect = stateLogEntry.velocity; | ||
|
||
bodyInfo = stateLogEntry.centralBody; | ||
tankStates = stateLogEntry.getAllActiveTankStates(); | ||
stageStates = stateLogEntry.stageStates; | ||
lvState = stateLogEntry.lvState; | ||
|
||
dryMass = stateLogEntry.getTotalVehicleDryMass(); | ||
tankStatesMasses = [tankStates.tankMass]'; | ||
|
||
throttleModel = stateLogEntry.throttleModel; | ||
steeringModel = stateLogEntry.steeringModel; | ||
|
||
altitude = norm(rVect) - bodyInfo.radius; | ||
pressure = getPressureAtAltitude(bodyInfo, altitude); | ||
|
||
throttle = throttleModel.getThrottleAtTime(ut, rVect, vVect, tankStatesMasses, dryMass, stageStates, lvState, tankStates, bodyInfo); | ||
|
||
[~, totalThrust, ~] = LaunchVehicleStateLogEntry.getTankMassFlowRatesDueToEngines(tankStates, tankStatesMasses, stageStates, throttle, lvState, pressure, ut, rVect, vVect, bodyInfo, steeringModel); | ||
|
||
value = totalThrust; | ||
|
||
if(obj.lb == obj.ub) | ||
c = []; | ||
ceq(1) = value - obj.ub; | ||
else | ||
c(1) = obj.lb - value; | ||
c(2) = value - obj.ub; | ||
ceq = []; | ||
end | ||
c = c/obj.normFact; | ||
ceq = ceq/obj.normFact; | ||
|
||
lwrBnd = obj.lb; | ||
uprBnd = obj.ub; | ||
|
||
eventNum = obj.event.getEventNum(); | ||
end | ||
|
||
function sF = getScaleFactor(obj) | ||
sF = obj.normFact; | ||
end | ||
|
||
function setScaleFactor(obj, sF) | ||
obj.normFact = sF; | ||
end | ||
|
||
function tf = usesStage(obj, stage) | ||
tf = false; | ||
end | ||
|
||
function tf = usesEngine(obj, engine) | ||
tf = false; | ||
end | ||
|
||
function tf = usesTank(obj, tank) | ||
tf = false; | ||
end | ||
|
||
function tf = usesEngineToTankConn(obj, engineToTank) | ||
tf = false; | ||
end | ||
|
||
function tf = usesEvent(obj, event) | ||
tf = obj.event == event; | ||
end | ||
|
||
function tf = usesStopwatch(obj, stopwatch) | ||
tf = false; | ||
end | ||
|
||
function event = getConstraintEvent(obj) | ||
event = obj.event; | ||
end | ||
|
||
function type = getConstraintType(obj) | ||
type = 'Total Thrust'; | ||
end | ||
|
||
function name = getName(obj) | ||
name = sprintf('%s - Event %i', obj.getConstraintType(), obj.event.getEventNum()); | ||
end | ||
|
||
function [unit, lbLim, ubLim, usesLbUb, usesCelBody, usesRefSc] = getConstraintStaticDetails(obj) | ||
unit = 'kN'; | ||
lbLim = 0; | ||
ubLim = Inf; | ||
usesLbUb = true; | ||
usesCelBody = false; | ||
usesRefSc = false; | ||
end | ||
|
||
function addConstraintTf = openEditConstraintUI(obj, lvdData) | ||
addConstraintTf = lvd_EditGenericMAConstraintGUI(obj, lvdData); | ||
end | ||
end | ||
|
||
methods(Static) | ||
function constraint = getDefaultConstraint(~) | ||
constraint = TotalThrustConstraint(LaunchVehicleEvent.empty(1,0),0,0); | ||
end | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
helper_methods/ksptot_ma/launch_vehicle_designer/misc/computeTWRatio.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
function twRatio = computeTWRatio(throttle, ut, rVect, vVect, tankMasses, dryMass, stgStates, lvState, tankStates, bodyInfo) | ||
altitude = norm(rVect) - bodyInfo.radius; | ||
presskPa = getPressureAtAltitude(bodyInfo, altitude); | ||
|
||
[~, totalThrust]= LaunchVehicleStateLogEntry.getTankMassFlowRatesDueToEngines(tankStates, tankMasses, stgStates, throttle, lvState, presskPa, ut, rVect, vVect, bodyInfo, []); | ||
|
||
totalMass = (dryMass + sum(tankMasses))*1000; %kg | ||
totalThrust = totalThrust * 1000; % N | ||
|
||
twRatio = computeSLThrustToWeight(bodyInfo, totalThrust, totalMass); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters