% Angel L. Carrion
% AIAA Landing Gear Design

clear

% General variables
wto = 60000;              % Take off weight, lbs
cgaft = 25.6;             % Aft CG limit, ft
cgfwd = 25.2;             % Forward CG limit, ft

% For strut loads (all dims in feet)
nosexpos = 6;             % nose strut posn, ft
mainxpos = 27.75;         % main strut posn, ft
J = 6.5;                  % vertical CG position
F = mainxpos - nosexpos;  % dist from nose strut to main strut
N = cgaft - nosexpos;     % dist betw aft CG and nose strut
M = F - N;                % dist betw aft CG and main strut
L = cgfwd - nosexpos;     % dist betw fwd CG and nose strut

%  getting strut loads:
maxstatmain = wto*(F-M)/(2*F);  % Max static load on main struts
maxstatnose = wto*(F-L)/F;      % Max static load on nose strut
minstatnose = wto*(F-N)/F;      % Min static load on nose strut
noseloadperc = minstatnose/wto * 100; % Min Nose load to Wto ratio 
maxbraknose = maxstatnose + 10*J*wto/(32.2*F); % Max braking load on nose

fprintf('\nLoads on struts (lbs): \n\n')
fprintf(' Take-off weight : %34i\n',wto)
fprintf(' Maximum static load on main strut (per strut): %5.2f\n',maxstatmain)
fprintf(' Maximum static load on nose strut: %20.2f\n',maxstatnose)
fprintf(' Minimum static load on nose strut: %20.2f\n',minstatnose)
fprintf(' Ratio between Wto and min nose load (percent): %8.2f\n',noseloadperc)
fprintf(' Maximum load on nose strut during braking: %12.2f\n\n',maxbraknose)


% **********************************************************************
% For lateral location of main gear (all dims in feet) and turnover angle 
latpos = 7.0;  % lateral position of main strut
B = F;         % dist from nose strut to main strut
D = N;         % dist from adverse CG to nose strut
E = J;         % vertical CG position
C = 0.8;       % dist from middle of nose strut to middle of nose wheel
alpha = atan((latpos - C)/B) * 180/pi;
x = C/tan(alpha*pi/180);

% turnover angle should be less than 64 degrees
tovangle = atan(E/((D+x)*sin(alpha*pi/180))) * 180/pi;
fprintf('\nLateral Position and turnover angle:\n\n')
fprintf(' Lateral pos of main strut (ft): %4.2f\n',latpos)
fprintf(' Turnover angle, (< 64 deg): %8.2f\n',tovangle);

% **********************************************************************
% For MAIN shock strut dimensions
%  piston area and diameter
pstat = 1500; % shock pressure at static deflection, psi
pareaM = maxstatmain/pstat;   % piston area at static deflection, in^2
pdiamM = 2 * sqrt(pareaM/pi) % piston diam at static deflection, in

%  stroke:
vsink = 15;   % sink speed, ft/sec
tdefl = 0.33; % tire deflection, ft
teff  = 0.47; % tire efficiency
seff  = 0.8;  % stut efficiency
Nreact = 3;   % reaction factor
g = 9.8*3.28; % gravity, ft/sec^2
%  shock stroke is rounded to next integer to give it a safety margin
strokeM = ceil(12 * (vsink^2/(2*g*Nreact) - teff*tdefl)/seff)

%  total length (extended):
permolM = 2.75 * pdiamM;         % minimum permissible overlap (Currey, p.111)
smaxlengthM = permolM + strokeM  % maximum main shock lengt (extended)
% **********************************************************************
