clear all; close all; clc;

%quantity definition
%hexagonal bar, material 1.4301
F_common=9500; %N axial vacuum force
n=0.65; %mode of strut load, hier A, clamped - clamped.
a=19; %mm
l=150; %mm
E=2*10^5; %N/mm^2
sigma_u=190;%N/mm^2
sigma_crit=210;%N/mm^2
sigma_k=205;%N/mm^2
k=2; %safety coeficient
kk=2; %safety coeficient for resilient material
%force to one strut:
disp('force to one strut')
F=F_common/4

%calculation of a minimal characteristic dimension a according to Euler(a_E) or Tetmajer (a_T)
disp('calculation of a minimal characteristic dimension "a" according to Euler(a_E) or Tetmajer (a_T)')
%Limit slenderness ratio:
lambda_lim=((n*pi()^2*E)/sigma_u)^(1/2)

%calculation of the characteristic dimension a of the hexagonal bar according to Euler’s formula 
a_E=((144*k*F*l^2)/(5*3^(1/2)*n*pi()^2*E))^(1/4)

%Primary check of applicability of Euler’s formula according to stress
sigma_crit_E=(k*F)/(a_E^2*3^(1/2)/2)

if(sigma_crit_E<=sigma_crit)
    disp('primary check for Euler fulfilled')
else
    disp('primary check for Euler unfulfilled')
end
    
%b)	Secondary check of applicability of Euler’s formula according to slenderness ratio
lambda_E=((480*10^(1/2))/a_E)

if(lambda_E>=lambda_lim)
    disp('secondary check for Euler fulfilled')
else
    disp('secondary check for Euler unfulfilled')
end
    
%calculation of a maximal permitted load for the set dimension a=19mm
disp('calculation of a maximal permitted load for the set dimension a=19mm')

%second moment of area J_y=J_min (area moment of inertia) of a regular hexagon with a characteristic dimension of a
J_min=(5*3^(1/2)*a^4)/144

%Area of a hexagonal cross-section A:
A=(a^2*3^(1/2))/2

%Quadratic radius of the cross-section: i_min
i_min=(J_min/A)^(1/2)

%slenderness ratio of the hexagonal bar with a=19mm:
lambda=l/i_min

if(lambda>=lambda_lim)
    disp('check for Euler in calculation of a maximal permitted load fulfilled')
    F_crit_E=(n*pi()^2*E*J_min)/(l^2)
    F_max_per=F_crit_E/k
else
    disp('check for Euler in calculation of a maximal permitted load unfulfilled')
    if(lambda>30)
    disp('check for Tetmajer in calculation of a maximal permitted load fulfilled')
    sigma_crit_T=(sigma_crit-((sigma_crit-sigma_u)/lambda_lim)*lambda)
    F_crit_T=sigma_crit_T*A
    F_max_per=F_crit_T/k
    else
    disp('check for Tetmajer in calculation of a maximal permitted load unfulfilled, it is simple compressive stress')    
    sigma_crit_compression=sigma_k/kk
    F_crit_compression=sigma_crit_compression*A
    F_max_per=F_crit_compression/k
    end
end