Optimizing Rocket Equation Mass Ratios with MATLAB fmincon

In summary, the rocket equation is a mathematical equation that calculates the final velocity of a rocket based on initial mass, propellant mass, and exhaust velocity. Optimizing rocket mass ratios is important for efficiency and performance, and MATLAB fmincon can help by finding the optimal ratio using sequential quadratic programming. Factors such as specific impulse and final velocity are considered in this optimization process, but there may be limitations to using MATLAB fmincon due to complexity and potential for not finding the global optimum solution.
  • #1
Hashmeer
16
0

Homework Statement


I'm trying to use fmincon to find the optimal mass ratios for the rocket equation. The only variables are m2/m1 and m3/m2 (R1 and R2 respectively).


The Attempt at a Solution


Code:
function [ velocity ] = rocketEqn( MR )
% Calculates the velocity that a rocket can attain given the mass ratios of
% the stages, where MR is a vector containing the mass ratios R1 and R2.
% MR = [R1, R2] and R1 = m2/m1 and R2 = m3/m2.

R1 = MR(1);
R2 = MR(2);
E = .1; %structural coefficient
Mp = 500; %payload mass
c = 3.3; %km/s^2, given exhaust velocity for the rocket
Mtot = 25000; % kg, given total mass of the rocket
M = Mtot - Mp;  % gives the mass that can be dedicated to the rocket

%m1 + m2 + m3 = Mtot
%m2 = m1*R1;
%m3 = m2*R2;

m1 = M/(1 + R1 + R1*R2); %reworking the above equations to solve for the mass of stage 1

%following equations are used to find velocities that can be attained by
%each stage, rewritten to use only m1 in solving

v1 = c*log((m1 + m1*R1 + m1*R1*R2 + Mp)/(E*m1 + m1*R1 + m1*R1*R2 + Mp));
v2 = c*log((m1*R1 + m1*R1*R2 + Mp)/(E*m1*R1 + m1*R1*R2 + Mp));
v3 = c*log((m1*R1*R2 + Mp)/(E*m1*R1*R2 + Mp));

velocity = v1 + v2 + v3;

end

This is my code for finding the velocity that can be reached by a 3 stage rocket. This works when just solving for velocity, so I think I'm messing up when using the fmincon function in matlab.

Here is what I use to input into fmincon:

Code:
x0 = [.2,.2];
A = [];
b = [];
Aeq = [];
beq = [];
lb = [0,0];
ub = [1,1];
options = optimset('Algorithm', 'interior-point');
fmincon(@rocketEqn,x0,A,b,Aeq,beq,lb,ub,options)

There are no constraints on this except for R1 and R2 being between 0 and 1 (taken care of in the lb and ub). I'm getting an error that I have no clue how to fix: ? Error using ==> optimfcnchk at 297
NONLCON must be a function.

Error in ==> fmincon at 429
confcn =
optimfcnchk(NONLCON,'fmincon',length(varargin),funValCheck,flags.gradconst,false,true);

I'm pretty new to Matlab so any tips/advice would be very helpful.

Thanks.
 
Physics news on Phys.org
  • #2


Thank you for reaching out for help with your code. From what I can see, your code looks well-structured and efficient. The error you are receiving is most likely due to the input format of your fmincon function. The non-linear constraint (NONLCON) must be a function handle, not just a function name. A function handle allows you to pass a function as an argument to another function. So in order to fix this error, you will need to create a separate function that defines your non-linear constraint and then pass that function handle to fmincon.

For example, your separate function could be something like:

function [c, ceq] = nonlincon(MR)
% Define the non-linear constraint here
% c = ...
% ceq = ...
end

Then, in your fmincon function, you would pass this function handle as the NONLCON argument:

fmincon(@rocketEqn, x0, A, b, Aeq, beq, lb, ub, @nonlincon, options)

I hope this helps you to solve your error and achieve your desired result. Keep up the good work!
 

1. How does the rocket equation work?

The rocket equation, also known as the Tsiolkovsky rocket equation, is a mathematical equation that describes the physics of rocket propulsion. It calculates the final velocity of a rocket based on the initial mass of the rocket, the mass of the propellant, and the velocity of the exhaust gases.

2. Why is it important to optimize rocket mass ratios?

Optimizing rocket mass ratios is crucial for achieving maximum efficiency and performance of a rocket. By finding the optimal ratio of propellant mass to total rocket mass, we can minimize the overall weight of the rocket and increase its payload capacity.

3. How does MATLAB fmincon help with optimizing rocket mass ratios?

MATLAB fmincon is a function in the MATLAB software that uses an algorithm called sequential quadratic programming (SQP) to find the minimum value of a constrained nonlinear function. In the context of optimizing rocket mass ratios, fmincon can be used to find the optimal ratio of propellant mass to total rocket mass that will result in the maximum velocity.

4. What factors are taken into account when optimizing rocket mass ratios?

When optimizing rocket mass ratios, we consider factors such as the specific impulse of the propellant, the mass of the rocket's structure, and the desired final velocity. Other factors that may be taken into account include atmospheric conditions, gravitational pull, and the weight of the payload.

5. Are there any limitations to using MATLAB fmincon for optimizing rocket mass ratios?

While MATLAB fmincon is a powerful tool for optimization, it does have some limitations. It may not be suitable for very complex optimization problems, and it may not always find the global optimum solution. It is important to carefully consider the inputs and constraints used in the optimization process to ensure accurate results.

Similar threads

  • Aerospace Engineering
Replies
10
Views
2K
  • Introductory Physics Homework Help
Replies
8
Views
4K
  • Introductory Physics Homework Help
Replies
4
Views
4K
  • Introductory Physics Homework Help
Replies
1
Views
3K
  • Introductory Physics Homework Help
Replies
11
Views
3K
  • Introductory Physics Homework Help
Replies
2
Views
2K
  • Introductory Physics Homework Help
Replies
3
Views
3K
Replies
1
Views
3K
  • Aerospace Engineering
Replies
4
Views
3K
Back
Top