Mass optimization for two stage gearbox.
Research Project : Simulator for selecting optimum teeths and module for two stage gearbox.
Aim : 1) To create mathematical model for mass of powertrain of two stage gearbox.
2) To Construct genetic algorithm to minimise the mass of the powertrain.
3) To Check the Convergence of solution of genetic algorithm and tune it in order to find best optimum
solution.
Motivation :
Two gearbox is widely used for ATVs in BAJA competitions.teams of various engineering colleges work hard to build light weight and durable all terrain vehicle(ATV).Transmission system contributes to the measure part of weight of ATV.Thus designing of lightweight gearbox can help in reducing weight of ATVs.If mathematical model of mass of powertrain is created and solved for minimisation.we can obtain set of best possible modules, and teeths to get exact overall reduction required.
physical model of powertrain :
Mathematical model :
From the figure shown above for calculation of volume of gear,they can be assumed to be cylinder having diameter equal to pitch circle diameter of gears and width equal to facewidth of gears.and since volume of shafts will remain constant for each iterations they can be neglected in optimization. mathematical equations of mass can be given as-
`f(mass)=ρ*Π/4*b*(dp1^2+dg1^2+dp2^2+dg2^2 )`'.......(1)
where,
`ρ` is density of material of gear`
`b` is facewidth of gear.
`dp1` is pitch circle diameter of stage1 pinion`
`dg1` is pitch circle diameter of stage1 gear`
`dp2` is pitch circle diamete of stage 2 pinion
`dg2` is pitch circle diameter of stage 2 gear
`dp=m*zp`........(2)`
`8≤b/m≤12`.......(3)`
for simplicity of calculation assume that b/m ratio is equal to 10 always.hence from equation 1,2 and 3 we get
`f(mass)=ρ*Π/4*10*(m1^3*zp1^2+m1^3*zg1^2+m2^3*zp2^2+m2^3*zg2^2)`
where,
`m1` module for first stage pair`
`m2` module for second stage pair`
`zp1` number of teeths of first stage pinion`
`zg1` number of teeths of first stage gear`
`zp2` number of teeths of second stage pinion`
`zg2` number of teeths of second stage gear`
so the optimization problem can be fomulated as
function to minimise -`f(mass)=ρ*Π/4*10*(m1^3*zp1^2+m1^3*zg1^2+m2^3*zp2^2+m2^3*zg2^2)`
subjected to - `R=(zg1)/(zp1)*(zg2)/(zp2)`........required overall reduction`
`18≤zp1≤100 ,zp1 ϵ I`......... teeths values must be integer and interference should be avoided `
`18≤zp2≤100 ,zp2 ϵ I`
`18≤zg1≤100 ,zg1 ϵ I`
`18≤zg2≤100 ,zg2 ϵ I`
`m1=∛((60*10^6)/Π*(kw*cs*fs)/(zp1^2*np1*cv*Q1*k*(b/m) ))`........wear strength equation`
`m2=∛((60*10^6)/Π*(kw*cs*fs)/(zp2^2*np2*cv*Q2*k*(b/m) ))`
where ,
R is total reduction,kw is power in kilowatt,cs is service factor, fs is factor of safety,np1 is pinion rpm.,cv -velocity factor,Q is ratio factor,K is load stress factor.
we have assumed that same material is used for pinion and gear. hence bending strength will be always greater than wear strength.hence wear strength is our design criteria.steel is used for gears.
Code Structure -
1.Main code
%code to select optimised number of teeths for two stage gearbox
clear all
close all
clc
%input
R = input('total reduction ratio = ');
zp1 =(18:1:100);
zg1 =(18:1:100);
zp2 = (18:1:100);
zg2 =(18:1:100);
[zp11 zg11] = meshgrid(zp1,zg1);
[zp22 zg22] = meshgrid(zp2,zg2);
for i = 1:length(zp11)
for j =1:length(zg11)
for k =1:length(zp22)
for p =1:length(zg22)
input(1) = zp11(i,j);
input(2) = zg11(i,j);
input(3) = zp22(k,p);
input(4) = zg22(k,p);
v(i,j,k,p) = volume(input);
end
end
end
end
nonlcon = @constraints;
options = optimoptions('ga');
IntCon =[1,2,3,4];
options =optimoptions(options,'MaxStallGenerations',50,'populationsize',20000,'MaxGenerations',400,'ConstraintTolerance',0.001,'CrossoverFraction',0.8);
num_cases = 50;
for t =1:num_cases
[inputs fval(t)] = ga(@volume,4,[],[],[],[],[18 18 18 18],[100 100 100 100],nonlcon,IntCon,options);
fprintf('iteration = %d \n',t)
end
plot(fval);
xlabel('Iterations');
ylabel('Total mass of gears(kg)');
title('weight optimization for two stage gearbox')
zp1_opt = inputs(1);
zg1_opt = inputs(2);
zp2_opt = inputs(3);
zg2_opt = inputs(4);
module_stage1 = module(zp1_opt,zg1_opt);
module_stage2 = module2(zp1_opt,zg1_opt,zp2_opt,zg2_opt);
%preparing the results
fprintf(' Results \n')
fprintf('Number of teeths of stage one pinion = %d \n',zp1_opt);
fprintf('Number of teeths of stage one gear = %d \n',zg1_opt);
fprintf('Number of teeths of stage two pinion = %d \n',zp2_opt);
fprintf('Number of teeths of stage two pinion = %d \n',zg2_opt);
fprintf('stage one module is %f \n',module_stage1);
fprintf('stage two module is %f \n ',module_stage2);
2.volume function code
function t =volume(input)
zp1 = input(1);
zg1 = input(2);
zp2 = input(3);
zg2 = input(4);
kw = 4.5; %power in kw
cs = 3.8; %service factor
cv = 0.3750;
fs = 1.5; %factor of safety
zp = 18; %no of teeths of pinion
np1 = 4500;%input rpm
bhn = 450; %brinel hardness
rho = 7800*10^(-9) ;%density
Q1 = 2.*zg1./(zp1+zg1);
Q2 = 2.*zg2./(zp2+zg2);
k = 0.16*(bhn/100)^2;
m1 = ((60*10^6/pi)*((kw*cs*fs)./((zp1.*zp1.*np1*cv*Q1*k).*10))).^(1/3);
np2 =(zg1.*np1./zg2);
m2 = ((60*10^6/pi)*((kw*cs*fs)./((zp2.*zp2.*np2*cv*Q2*k).*10))).^(1/3);
t =(7.8*10^(-6)).*(pi/4)*10*(m1.^3.*zp1.*zp1+m1.^3.*zg1.*zg1+m2.^3.*zp2.*zp2+m2.^3.*zg2.*zg2);
end
3.nonlinear constraint function code
function[c ceq] =constraints(input)
zp1 = input(1);
zg1 =input(2);
zp2 =input(3);
zg2 =input(4);
%note 10.76 here is value of overall reduction in case of different
%reduction change the value
conf = 10.76 - ((zg1./zp1).*(zg2./zp2));
%tol = 0.0001;
c = [conf,-conf];
%ceq = total red minus term
ceq = [];
end
4.module function code-
function m1 = module(zp1_opt,zg1_opt)
kw = 4.5; %power in kw
cs = 3.8; %service factor
cv = 0.3750;
fs = 1.5; %factor of safety
np1 = 4500;%input rpm
bhn = 450; %brinel hardness
rho = 7800*10^(-9) ;%density
Q = 2.*zg1_opt./(zp1_opt+zg1_opt);
k = 0.16*(bhn/100)^2;
m1 = ((60*10^6/pi)*((kw*cs*fs)./((zp1_opt.*zp1_opt.*np1*cv*Q*k).*10))).^(1/3);
end
5. module2 function code -
function m2 = module2(zp1_opt,zg1_opt,zp2_opt,zg2_opt)
kw = 4.5; %power in kw
cs = 3.8; %service factor
cv = 0.3750;
fs = 1.5; %factor of safety
np1 = 4500; %first stage rpm
bhn = 450; %brinel hardness
rho = 7800*10^(-9) ;%density
Q = 2.*zg2_opt./(zp2_opt+zg2_opt);
k = 0.16*(bhn/100)^2;
np2 =zg1_opt.*np1./zp1_opt;
m2 = ((60*10^6/pi)*((kw*cs*fs)./((zp2_opt.*zp2_opt.*np2*cv*Q*k).*10))).^(1/3);
end
Explaination of code -
input to get value of overall reduction from user
meshgrid to create 2d array.
for loop to calculate volume function for every point .
nonlcon to provide nonlinear condtaints to ga.
IntCon to set integer contraints to ga.(note during mixed integer ga you have to provide eqality constaints interms of inequality.
options to set best options for ga to achieve desired convergence.
plot to plot function value obtaint in each iteration.
fprintf to print the output.
mass function is built such it will accept pair of teeths first calculate module based on them and the calculates the mass.supply of teeth pairs are constrained such they will satisfy criteria for total reduction.based on final value of teeth pairs module is calculated again and shown on the screen.
Output -
total reduction ratio = 10.76
options =
ga options:
Set properties:
ConstraintTolerance: 1.0000e-03
CrossoverFraction: 0.8000
MaxGenerations: 400
MaxStallGenerations: 50
PopulationSize: 20000
Default properties:
CreationFcn: @gacreationuniform
CrossoverFcn: @crossoverscattered
Display: 'final'
EliteCount: '0.05*PopulationSize'
FitnessLimit: -Inf
FitnessScalingFcn: @fitscalingrank
FunctionTolerance: 1.0000e-06
HybridFcn: []
InitialPopulationMatrix: []
InitialPopulationRange: []
InitialScoresMatrix: []
MaxStallTime: Inf
MaxTime: Inf
MutationFcn: {@mutationgaussian [1] [1]}
NonlinearConstraintAlgorithm: 'auglag'
OutputFcn: []
PlotFcn: []
PopulationType: 'doubleVector'
SelectionFcn: @selectionstochunif
UseParallel: 0
UseVectorized: 0
Optimization terminated: average change in the penalty fitness value less than options.FunctionTolerance
and constraint violation is less than options.ConstraintTolerance.
iteration = 50
Results
Number of teeths of stage one pinion = 27
Number of teeths of stage one gear = 92
Number of teeths of stage two pinion = 19
Number of teeths of stage two pinion = 60
stage one module is 1.995724
stage two module is 1.686313
convergence check -
Conclusion -
Form this we can conclude that optimum module for first stage is 1.9957 and stage 2 is 1.686.
teeth pairs are(27,92) and(19,60)
`reduction =92/27*60/19`
`reduction = 10.7602`
hence our constarints are satisfied and we got optimum results.
References -
https://www.mathworks.in/help/gads/mixed-integer-optimization.html