syms E A I L theta_t theta_b Fy6 real
beam_config = [1, 3, pi/2+theta_t
2, 3, pi/2-theta_t
3, 4, pi
3, 5, 0
4, 6, 0
5, 6, pi
6, 7, pi
6, 8, 0
7, 9, 0
8, 9, pi
9, 10, -pi/2-theta_b
9, 11, -pi/2+theta_b];
K_actual = assemble_stiffness(11, beam_config, E, A, I, L);
constrained_nodes = [1, 2, 10, 11];
constrained_dofs = [];
for node = constrained_nodes
constrained_dofs = [constrained_dofs, 3*node-2, 3*node-1, 3*node];
end
all_dofs = 1:size(K_actual, 1);
free_dofs = setdiff(all_dofs, constrained_dofs);
F = sym(zeros(33, 1));
F(17) = Fy6;
K_reduced = K_actual(free_dofs, free_dofs)
F_reduced = F(free_dofs);
x_reduced = K_reduced \ F_reduced;
x_full = zeros(size(K_actual, 1), 1);
x_full(free_dofs) = x_reduced;
K_eff = simplify(Fy6 / x_full(17));
disp('Effective stiffness:');
disp(K_eff);
clear; clc;
syms ka kb kc kd ke F5
K = [ka+kc -ka -kc 0 0
-ka ka+kb 0 -kb 0
-kc 0 kc+kd -kd 0
0 -kb -kd kb+kd+ke -ke
0 0 0 -ke ke]
F = [0; 0; 0; 0; F5];
C = [1 0 0 0 0];
N_c = size(C,1)
A = [K, C.'; C, zeros(N_c, N_c)]
b = [F; zeros(N_c,1)];
x = A \ b;
x5 = x(5);
K_eff = simplify(F5 / x5);
disp('Effective stiffness K_eff:');
disp(K_eff);
K_test = inv(inv(inv(inv(ka)+inv(kb))+inv(inv(kc)+inv(kd)))+inv(ke))
isAlways(K_eff== K_test)
function K_global = assemble_stiffness(num_nodes, beam_data, E, A, I, L)
K_global = sym(zeros(3 * num_nodes));
for i = 1:size(beam_data, 1)
node1 = beam_data(i, 1);
node2 = beam_data(i, 2);
angle = beam_data(i, 3);
K_local = beam_stiffness_matrix(E, A, I, L);
R = rotation_matrix(angle);
K_global_beam = R' * K_local * R;
dof_indices = [3*node1-2, 3*node1-1, 3*node1, 3*node2-2, 3*node2-1, 3*node2];
for ii = 1:6
for jj = 1:6
K_global(dof_indices(ii), dof_indices(jj)) = ...
K_global(dof_indices(ii), dof_indices(jj)) + K_global_beam(ii, jj);
end
end
end
end
function K_local = beam_stiffness_matrix(E, A, I, L)
K_local = sym([
E*A/L, 0, 0, -E*A/L, 0, 0;
0, 12*E*I/L^3, 6*E*I/L^2, 0, -12*E*I/L^3, 6*E*I/L^2;
0, 6*E*I/L^2, 4*E*I/L, 0, -6*E*I/L^2, 2*E*I/L;
-E*A/L, 0, 0, E*A/L, 0, 0;
0, -12*E*I/L^3, -6*E*I/L^2, 0, 12*E*I/L^3, -6*E*I/L^2;
0, 6*E*I/L^2, 2*E*I/L, 0, -6*E*I/L^2, 4*E*I/L;
]);
end
function R = rotation_matrix(angle)
c = cos(angle);
s = sin(angle);
R = [
c, s, 0, 0, 0, 0;
-s, c, 0, 0, 0, 0;
0, 0, 1, 0, 0, 0;
0, 0, 0, c, s, 0;
0, 0, 0, -s, c, 0;
0, 0, 0, 0, 0, 1;
];
end