Skip to content

Commit

Permalink
1) LVD: Added total thrust constraint
Browse files Browse the repository at this point in the history
2) Adjusted all altitude constraints to have an allowable lower bound of -Inf
  • Loading branch information
Arrowstar committed Jan 6, 2019
1 parent d2fd9e9 commit 80ece6a
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
InertialBankAngle('Inertial Bank Angle','InertialBankAngleConstraint',[]);
InertialSideSlipAngle('Inertial Side Slip Angle','InertialSideSlipAngleConstraint',[]);

TotalThrust('Total Thrust','TotalThrustConstraint',[]);

StopwatchValue('Stopwatch Value','StopwatchValueConstraint',[]);
end

Expand Down
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
usesRefSc = false;
case 'Altitude of Apoapsis'
unit = 'km';
lbLim = 0;
lbLim = -Inf;
ubLim = Inf;
lbVal = 0;
ubVal = 0;
Expand All @@ -245,7 +245,7 @@
usesRefSc = false;
case 'Altitude of Periapsis'
unit = 'km';
lbLim = 0;
lbLim = -Inf;
ubLim = Inf;
lbVal = 0;
ubVal = 0;
Expand Down Expand Up @@ -553,7 +553,7 @@
usesRefSc = false;
case 'Altitude'
unit = 'km';
lbLim = 0;
lbLim = -Inf;
ubLim = Inf;
lbVal = 0;
ubVal = 0;
Expand Down

0 comments on commit 80ece6a

Please sign in to comment.