Find an approximate solution(s) to a multivariable equation set with a minizer and solver
2 views (last 30 days)
Show older comments
Hey everybody I'm having a bit of trouble with solving a problem in matlab. I'm decent with matlab but certainly no genius and was wondering of some of the geniusses here could help me.
I have a set of 4 equations, with 3 of them having to be solved and the last has to minimized.
My code is the following
%%%Theory
%%%Constants
L = 50e-3; %length spokes [m]
F_vert= 4707; %Vertical load [N]
F_long = 2931; %Longitudinal load [N]
F_lat = 3293; %lateral force [N]
E = 68.98e9; %modulus of elasticity [Pa]
sigma_vm=140e6 ; %max von mises stress
syms y_c x_c t t_w
%%%situation 1
P = F_vert;
W = F_long;
%GEOMETRIES
%%%I-beam
d=2*(y_c -t);
b=2*x_c;
A = 2*b*t + t_w*d;
I_x = (b*(d+2*t)^3) /12 - ((b-t_w)*d^3)/12;
I_y = (b^3 * t)/6 + (t_w^3*d)/12;
%%%U-beam
%A = t*b + 2*t_w*d;
%y_c = (b*t^2 + 2*t_w*d*(2*t+d))/(2*(t*b+2*t_w*d));
%x_c = b/2;
%I_x = (b/3)*(d+t)^3 - ((d^3)/3)*(b-2t_w) - A*(d+t-y_c)^2;
%I_y = ((d+t)*b^3)/12 - (d*(b-2*t_w)^3/12;
%calculation of the stresses
k = sqrt(P/(E*I_y)) ;
M1 = (-W*tan(k*L))/k; %moment of vertical and longitudinal forces
M2 = F_lat*L;
sigma1 = (-M1*x_c)/I_y;
sigma2 = (-M2*y_c)/I_x;
sigma3 = P/A;
sigma_vm_1 = sqrt((sigma1-sigma2)^2+(sigma2-sigma3)^2+(sigma3-sigma1)^2);
%amount of spokes
for n = 3:9; %amount of spokes
alpha = 360/(2*n); %half the angle between two spokes
%%%Situation 2
P_2 = F_vert*sin(alpha)+F_long*cos(alpha);
W_2 = F_vert*cos(alpha)+F_long*sin(alpha);
%calculation of the stresses
k_2 = sqrt(P_2/(E*I_y)) ;
M1_2 = (-W_2*tan(k_2*L))/k_2; %moment of vertical and longitudinal forces
M2_2 = F_lat*L;
sigma1_2 = (-M1_2*x_c)/I_y;
sigma2_2 = (-M2_2*y_c)/I_x;
sigma3_2 = P_2/A;
sigma_vm_2 = sqrt((sigma1_2-sigma2_2)^2+(sigma2_2-sigma3_2)^2+(sigma3_2-sigma1_2)^2);
end
Here in sigma_vm_2 should equal sigma_vm_1, sigma_vm_1 should equal sigma_vm and sigma3 should equal sigma1. Lastly A should be minimized within the boundaries of this equation system.
The real conditions are actually (also in order of most important on top) sigma_vm_1 and sigma_vm_2 may not exceed sigma_vm sigma_vm_2 should more or less equal sigma_vm_1 A should be minimized sigma_vm_1 and sigma_vm_2 should be minimized sigma_vm sigma3 should more or less equal sigma1
Futhermore all values should be Real and positive. (y_c and x_c should be around 0.05, t and t_w around 0.005)
Also I have matlab R2013a
For the theory behind this and why I want to solve this you can check the link below: http://www.speedyshare.com/UCdRV/SSA3-bob-rene.pdf
0 Comments
Answers (1)
Matt J
on 7 Jun 2013
You could use FMINCON if you've got it, but it is a non-symbolic solver.
2 Comments
Matt J
on 8 Jun 2013
Edited: Matt J
on 9 Jun 2013
From the documentation, you have
x = fmincon(fun,x0,[],[],[],[],[0;0;0;0], [] ,nonlcon)
Here x and x0 would contain your unknowns as a 4x1 vector. Since you are minimizing A, 'fun' would be a handle to a function which computes A (numerically, not symbolically) for a given x . Similarly, nonlcon would be a handle to a function in the format described here which computes the various sigma quantities and returns the outputs
c=[];
ceq(1)=sigma_vm_2 - sigma_vm_1;
ceq(2)=sigma_vm - sigma_vm_1;
ceq(3)=sigma3 - sigma_1;
This indicates which sigma quantities you want constrained equal. However, you should get rid of the SQRT's in the definitions of all the sigma_vm's. They are unnecessary and make the problem non-differentiable:
sigma_vm_1 = (sigma1-sigma2)^2+(sigma2-sigma3)^2+(sigma3-sigma1)^2;
sigma_vm_2 = (sigma1_2-sigma2_2)^2+(sigma2_2-sigma3_2)^2+(sigma3_2-sigma1_2)^2;
sigma_vm=140e12 ;
BTW, it looks like you are measuring things in troublesomely small units seeing as you have things like 140e6 or 140e12. You should convert them to something that let's you work with smaller numbers. Otherwise, you will have to mess with a number of the FMINCON options settings, like TolCon and TolFun.
See Also
Categories
Find more on Equation Solving in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!