% ============== ASSUMING HOMOGENOUS PROPERTIES =================
% GENERATE ELEMENT MATRICES AND ASSYMBLE INTO SYSTEM
% Assemble n_d by n_d square matrix terms from n_e by n_e
for j = 1:n_e ; % loop over elements ====>> ====>> ====>> ====>>
S_e = zeros (n_i, n_i) ; M_e = zeros (n_i, n_i) ; % sys arrays
C_p = zeros (n_i, 1) ; C_e = zeros (n_i, 1) ; % sys arrays
s_L = zeros (n_i, n_i) ; m_L = zeros (n_i, n_i) ; % loc arrays
t_L = zeros (n_i, n_i) ; c_L = zeros (n_i, 1) ; % loc arrays
e_nodes = nodes (j, 1:n_n) ; % coectivity
% SET ELEMENT PROPERTIES & GEOMETRY
Option = 1 ; % select analysis case
[A, E, Line_e, Rho] = set_2D_truss_properties (n_n, Option) ;
%--> find member length and direction cosines
dx = x(e_nodes(2)) - x(e_nodes(1)) ; % x length
dy = y(e_nodes(2)) - y(e_nodes(1)) ; % y length
L_e = sqrt (dx * dx + dy * dy) ; % total length
cx = dx / L_e ; cy = dy / L_e ; % direction cosines
% ELEMENT CONDUCTION AND INTERNAL SOURCE MATRICES
% for q = 1:n_q ; % Loop over quadrature points ----> ---->
% Linear axial bar and cubic bending. DOF = u, v, u, v
% Form arrays in local axes, transform. 1 2 3 4
% stiffness
s_L = [ 1, 0, -1, 0 ;
0, 0, 0, 0 ;
-1, 0, 1, 0 ;
0, 0, 0, 0 ] * E * A / L_e ;
% Map line load to node forces ONLY
if ( any (Line_e) ) ; % then form forcing vector
fprintf ('WARNING: line loads not yet active. n')
end % if for set up line load nodal resultants
% Optional local mass matrix
if ( Rho > 0 )
m_L = [140, 0, 70, 0 ;
0, 0, 0, 0 ;
70, 0, 140, 0 ;
0, 0, 0, 0 ] * Rho * A * L_e ;
end % if mass requested
% end % for loop over n_q element quadrature points
% Define local to system DOF transformation matrix
t_L = [ cx cy 0 0 ; % (inverse t_L = transpose t_L)
-cy cx 0 0 ;
0 0 cx cy ; % joint 2
0 0 -cy cx ] ;
% Transform from local to system
S_e = t_L' * s_L * t_L ; M_e = t_L' * m_L * t_L ;
C_e = t_L' * c_L ;
% SCATTER TO (ASSEMBLE INTO) SYSTEM ARRAYS
% Insert completed element matrices into system matrices
[rows] = get_element_index (n_g, n_n, e_nodes); % eq numbers
S (rows, rows) = S (rows, rows) + S_e ; % add to system sq
C (rows) = C (rows) + C_e ; % add to sys column
end % for each j element in mesh
% ALLOCATE STORAGE FOR OPTIONAL REACTION RECOVERY
if ( EBC_count > 0 ) ; % reactions occur
برچسب:
نویسنده: رادین پورعلی