www.pudn.com > WebsiteCode.zip > springmass.m, change:2008-07-24,size:1891b

```function mass = springmass(design)
% mass = springmass(design)
%
% Calculates the weight of a helical compression spring
% defined by the design variable vector design
%
%
% This program is free software: you can redistribute it and/or modify  it
% the Free Software Foundation, either version 3 of the License, or any
% later version.
%
% This program is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
% General Public License for more details.
%
% You should have received a copy of the GNU General Public License and GNU
% Lesser General Public License along with this program. If not, see

% ********* DESIGN VARIABLES ********
% Wire diameter
d = 0.5 + 6.5*design(1);

% Spring index
i = 4 + 12*design(2);

% Inter-coil distance coefficient
kdelta = 0.1 + design(3);

% ******** PROBLEM DEFINITION *******

% Wire steel density [kg/mm^3]
rho = 7.87e-6;

% Rigidity modulus
G = 0.78e5;

Fmin = 40; Fmax = 500;

% Stroke (working range) [mm]
h = 50;

% Stiffness
c = (Fmax-Fmin)/h;

% Maximum / minimum deflection [mm]
fmax = Fmax/c;

% Spring mean diameter
Dm = i*d;

% Number of active coils
n = (G*d^4)/(8*c*Dm^3);

% Number of end coils
if n<=7
nr = 1.5;
else
nr = 2;
end

% Total number of spring coils
nt = n + nr;

% Pitch of unloaded spring [mm]
t = d + fmax/n + kdelta*d;