Code covered by the BSD License  

Highlights from
New Approaches to Constrained Optimization in MATLAB

image thumbnail

New Approaches to Constrained Optimization in MATLAB

by

 

07 Dec 2005 (Updated )

M-files accompanying the webinar held on November 05, 2005

springConstraints(x,Fo,Fc,delta,G,Nf,a,rho)
function [c,ceq] = springConstraints(x,Fo,Fc,delta,G,Nf,a,rho)
% Nonlinear constraint function for helical spring optimization
% The surge frequency of the spring must be above the operating frequency
% of the valve. The spring must not buckle either under compression load or
% fatigue load (factor of safety constraints). The spring operates between
% a small (known) permanent compressive force (Fc) and an operating load
% (Fo). We will also assume that the spring compression (delta) is known in
% this application. Thus, we know the spring stiffness k = (Fo - Fc)/delta.
% Number of coils selected should be greater than a minimum number. The
% spring index C (=D/d) be between specified lower and upper limits. The
% length at maximum load should be less than the critical length (to avoid
% buckling) and the coil should be within the specified inner and outer
% diameter. The factor of safety must be at least 1.44
%

ceq = [];
D = x(1);  d = x(2);
% Lower limit of numebr of coils
Nl = 3;
% Upper limit on coil diameter; D + d
OD = 1.5;
% Lower limit on coil diameter; D - d
ID = 0.75;
% Length at maximum load
Lmf = 1.25;
% Weight limit
Wlimit = 0.18;

% Spring stiffness
k = (Fo-Fc)/delta;
% Unitless constant
a = 0.4;

% Limits on spring index, c
c(1) = D - 12*d; % <= 0
c(2) = 6*d - D;   % <= 0
% Limits on coil diameter
c(3) = D + d - OD; % <= 0
c(4) = ID + d - D; % <=0

% Number of turns >=Nl
N = G*d^4/(8*D^3*k);
c(5) = Nl - N; % <=0
% Minimum active working length
L = N*d*(1+a);
% Critical length to avoid buckling; L <= Lcr
Lcr = (11.15*k*(D/2)^2)/Fo;
c(6) = L - Lcr; % <=0

% Lower surge frequency
Flower = 150;
% Surge frequency; fn >= Flower
fn = 14100*d/(D*N);
c(7) = Flower - fn; % <=0

% Spring index
si = D/d;
% Wahl's stress concentration factor
Kw = (4*si +2)/(4*si - 3);
% shear stress constant
Ks = (2*si + 1)/(2*si);
% Fa
Fa = (Fo + Fc)/2;
% Fm
Fm = (Fo - Fc)/2;
% Shear stress
tauA = 8*Fa*D*Kw/(pi*d^3);
% Mean stress
tauM = 8*Fm*D*Ks/(pi*d^3);
% Endurance limit in shear as a function of cycles to failures
Sa = 587000*d^(-0.16)*Nf^(-0.2136);
% Ultimate strength in shear
Sm = 148800*d^(-0.16);
% Yield strength
Sy = 80700*d^(-0.16);

% Factor of safety
SFa = (Sa*Sm)/(tauA*Sm + tauM*Sa);
SFy = Sy/(tauA + tauM);
c(8) = 1.44 - min(SFa,SFy);

Contact us