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
0 commit comments