function lagrange = nma_rocket_getLagrangeMultiplier(deltaV,Ve,epsilon) %Solves equation 5.57 in book orbital mechanices page 96, by Prussing and Conway %function nma_rocket_getLagrangeMultiplier(deltaV,Ve,epsilon) % %Solves equation 5.57 in the book orbital mechanices page 96, by %Prussing and Conway % %Finds the lagrange multipler to optimize fuel distribution for a %multistage rocket. % %Input: % deltaV: The total velosity increment for the rocket. in km/sec % % Ve: A vector whose elements are the effective exhaust velosity in km/sec. % Ve = Isp*g % Watch out. Ve must be in km/sec. % so for an Isp=300 seconds, Ve= 300*9.8066/1000 % % epsilon: A vector whose elements are the epsilon for each rocket stage. % This is the structural mass ratio defined as (ms/(mp+ms)) where % ms=structural mass, mp=fuel mass % %OUTPUT: % the lagrange multiplier value. % Use this to find the Z's as per equation 5.56 in the above book % %Author: Nasser Abbasi %June 1, 2003 lagrange = 0.5; tol = 0.0001; g = 9.8066; OVER = 1; UNDER = 0; TRUE = 1; FALSE = 0; maxIter = 1000; delta = 0.05; % by how much to start adjustment to lagrange each time lastCheck = OVER; lastLagrange = lagrange; firstTime = TRUE; iterCounter=0; while(1) lastLagrange = lagrange; % lagrange iterCounter=iterCounter+1; if(iterCounter>maxIter) error('Failer to find lagrange multiplier'); end sum = 0; for(i=1:length(Ve)) c = Ve(i); Z = (lagrange*c - 1)/(lagrange*c*epsilon(i)) ; if(Z<0) error('Complex result for log. Check data, unable to solve'); end sum = sum + c * log(Z); end % sum % deltaV if(abs(sum-deltaV)