Internal ballistics optimization (2 variables)
    21 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
Good day guys,
I am from the Czech republic so I would like to apologize for any grammar errors in advance. I am a student of guns and ammunition at the University of Defence and am currently working on my school project, in which I am trying to solve an optimization problem in the field of internal ballistics.
I put all my efforts (the code) bellow as well as a further explenation of what is going on, the overall goal and where I am currently at. 
clc,clear,close
% PROBLEM DESCRIPTION
prob = optimproblem("Description",['Optimizing the mass of propellant charge ' ...
    'and thickness of powder grain']);
% VARIABLES
omega = optimvar('omega',1,'LowerBound',2.7e-3,'UpperBound',3.3e-3);
e1 = optimvar('e1',1,'LowerBound',0.21e-3,'UpperBound',0.26e-3);
% DEFINITION OF OBJECTIVE FUNCTION
f = fcn2optimexpr(@internal_ballistics,omega,e1);
p = f(1); 
v0 = f(2);
prob.Objective.first = p;
prob.ObjectiveSense = "min";
prob.Objective.second = v0;
prob.ObjectiveSense = "max";
% CONSTRAINTS
prob.Constraints.vazba1 = p<=300e6;
prob.Constraints.vazba2 = v0>=750;
prob.Constraints.vazba3 = omega<=5.72e-3;
% PROBLEM SOLUTION 
x0.omega = 2.71e-3;
x0.e1 = 0.21e-3;
[sol,optimval,exitflag,output] = solve(prob,x0);
% DISPLAY OF CALCULATION RESULTS
disp(strcat('Optimized mass of propellant charge omega=',num2str(sol.omega(1,1)),'kg'))
disp(strcat('Optimized thickness of powder grain e1=',num2str(sol.e1(1,1)),'m'))
disp(strcat('Resulting chamber pressure p=',num2str(optimval(1,1)*1e-6),'MPa'))
disp(strcat('Resulting velocity v0=',num2str(optimval(2,1)),'m/s'))
function f = internal_ballistics(omega,e1)
% Atmospheric conditions
pa = 1e5; % Ambient pressure [Pa]
Ta = 21+273.15; % Ambient temparature = temparature of propellant [K]
% Weapon parameters
d = 7.62e-3; % Calibre [m]
s = 4.73e-5; % Cross-section area of bore [m^2]
lu = 0.509; % Path of projectile inside the barrel [m]
% Cartridge parameters
% omega = 3.1e-3; % Mass of propellant charge [kg]
mq = 9.6e-3; % Mass of projectile [kg]
c0 = 3.521e-6; % Initial volume of combustion chamber [m^3]
kphi = 1.1; % Coefficient of passive resistance against shell motion [-]
del = omega/c0; % Loading density [kg/m^3]
phi = kphi+1/3*omega/mq; % Fictitious mass of projectile [-]
% Parameters of propellant charge
rho = 1627; % Density of powder mass (bulk density) [kg/m^3]
Tv = 3175; % Explosion temparature [K]
f = 0.73e6; % Specific energy of propellant [J/kg]
Lz = 1.79e-3; % Lenght of powder grain [m]
% e1 = 0.165e-3; % Thickness of powder grain [m]
k1 = 1+e1/Lz; % Coefficient of powder grain [-]
k2 =-e1/Lz; % Coefficient of powder grain [-]
k3 = 0; % Coefficient of powder grain [-]
Ik15 = 0.1702e6; % Pressure impuls of propellant gases [Pa.s]
ikt = 0.0016; % Temparature coefficient [-]
Tnpl = Ta; % Temparature of propellant [K]
Ik = Ik15*(1-ikt*(Tnpl-288.15));
% Thermodynamic parameters of propellant gases
alf = 0.906e-3; % Covolum [m^3/kg]
kappa = 1.2505; % Adiabatic exponent [-]
r = f/Tv; % Gas constant [J/kg/K]
theta = kappa-1; % Heat parameter of powder gas expansion [-]
cv = r/theta; % Specific heat at constant volume [J/kg/K]
% Other parameters
p0 = 4e7; % Ambient pressure [Pa]
%--------------------------------------------------------------------------
% Initial conditions
z0 = 0;                % Burnt thickness of powder grain
V0 = omega/rho;        % Volume of propellant charge 
m0 = pa*(c0-V0)/r/Ta;  % Mass of propellant gases (C0 = c0-V0)
xs0 = 0;               % Path of projectile 
vs0 = 0;               % Velocity of projectile
T0 = Ta;               % Temparature 
y0 = [z0 V0 m0 vs0 xs0 T0];
tspan = 0:2e-4:1;
options = odeset('RelTol',1e-6,'AbsTol',1e-6,'Event',@stopprogram);
[t,y]= ode45(@IntBal,tspan,y0,options);
zz = y(:,1);  % Instaneous burnt thickness of powder grain z = e/e1;
VV = y(:,2);  % [m^3]
mm = y(:,3);  % [kg]
v_s = y(:,4); % [m/s]
x_s = y(:,5); % [m]
TT = y(:,6);  % [K]
CC = c0-VV-alf*mm+x_s*s; % Instaneous change of volume in barrel [m^3]
pp = mm*r.*TT./CC; % Instaneous chamber pressure [Pa]
p_max = max(pp); % Maximum chamber pressure
v0 = max(v_s); % Maximum velocity of projectile
f = [p_max,v0];
save vnibal_7_62x59.mat
function dy = IntBal(~,y)
z = y(1);   
V = y(2);   
m = y(3);   
vs = y(4);  
xs = y(5);  
T = y(6);    
C = c0-V-alf*m+xs*s;
p = m*r*T/C; % (Equation of state)
% Additive constant "q" for determining f_p = q+p
% if p<20e6
%    q=35e6;
% elseif p>=20e6 && p<50e6
%        q=30e6;
% elseif p>=50e6 && p<100e6
%        q=25e6;
% elseif p>=100e6
%        q=20e6;
% end
f_p = p; % Refining pressure function
% Parameter "z" 
if z < 1
   c1 = 1;
else
   c1 = 0;
end
if p < p0 && vs==0
   c2 = 0;
else
   c2 = 1;
end
dzdt = c1*f_p/Ik;                               % Change of burnt thickness of powder grain
dVdt = -c1*V0*(k1 + 2*k2*z + 3*k3*z^2)*dzdt;    % Change of volume of propellant charge 
dmdt = -rho*dVdt;                               % Change of mass of propellant gases
dvsdt = c2*(p-pa)*s/(phi*mq);                   % Change of path of projectile
dxsdt = vs;                                     % Change of velocity of projectile
dCdt = -dVdt - dmdt*alf + s*vs;                 % Change of volume in barrel
dTdt = 1/(m*cv)*(dmdt*(cv*Tv-cv*T)-p*dCdt);     % Change of chamber pressure
dy(1) = dzdt;
dy(2) = dVdt;
dy(3) = dmdt;
dy(4) = dvsdt;
dy(5) = dxsdt;
dy(6) = dTdt;
dy = [dy(1);dy(2);dy(3);dy(4);dy(5);dy(6)];
end
function [value,isterminal,direction]=stopprogram(~,y) % stopping condition
    value = y(5) - lu;
    isterminal=1;
    direction=0;
end
end
Firstly, the code consists of internal ballistics model "function f = internal_ballistics(omega)", onto which is attached the optimization code done via optimization toolbox. 
The overall goal is to find optimal values for 2 variables, mass of the propellant charge "omega" and thickness of powder grain "e1", and ofcourse satisfy the enclosed constraints. The ultimate idea is to obtain solution for those 2 variables, which will ensure minimizing the maximum pressure in the barrel "p_max", while at the same time maximizing the maximum velocity of the projectile "v0" but to be honest, I am not sure, if I am able to achieve this by using the optimization toolbox so I would greatly apreciate your opinion on that. What I am focusing on right now is just to find the 2 varibles and minimize "p_max".
So far, the optimization only finds optimal solution for 1 variable, which is "omega" and I do not know, where to go from here (finding those two at the same time). 
I am open for discusion, I will appreciate any kind of help and I am open to provide additional information on the model itself if needed.
Thank you very much in advance and have great day
Ludvík Hladký 
7 Commenti
  Geoffrey Kolbe
 il 21 Mag 2023
				Hello Ludvik
If you want to maximise the velocity, the case must be full of powder and all the powder must burn in the barrel. So that is two constraints. 
You can alter the pressure by altering the grain thickness. The thicker the grain, the longer it takes to burn and so the lower the maximum pressure will be. However it the grain is too thick then the powder will not all be burnt when the bullet exits the barrel. So there is a maximum thickness to the grain so that all the powder burns before the bullet exits the barrel. That is the second contraint again.
However, the amount of powder you can fit in the case will depend on the dimensions of the grains. If rho in the program is the bulk density then what is the propellant density? You will need to know the propellant density so you know how much volume the powder takes up in the case at the start of the computation. You cannot get that from the bulk density. I think you need to check that again. 
Risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



