Finite Element Method (FEM) using MATLAB Get Certified
The Finite Element Method (FEM) is a numerical technique for solving complex differential equations and engineering problems. MATLAB provides a robust environment for FEM analysis, especially in mechanics. This section introduces FEM concepts, examples, and their solutions using MATLAB.
Overview of Finite Element Method
FEM divides a large, complex domain into smaller, simpler parts called elements. The solution to these simpler problems is combined to approximate the solution for the original domain. Examples of a meshed plate and a hollow cylinder are shown below:
Steps in FEM using MATLAB
- Define the geometry and mesh.
- Specify material properties.
- Assemble the global stiffness matrix and force vector.
- Apply boundary conditions.
- Solve the system of equations.
Example 1: 1D Bar under Axial Load
Consider a bar subjected to axial load. The governing equation is:
\[ \frac{d}{dx}\left(EA\frac{du}{dx}\right) = F(x) \]
where \(E\) is the modulus of elasticity, \(A\) is the cross-sectional area, and \(F(x)\) is the distributed load.
% Parameters
E = 2e11; % Modulus of elasticity (Pa)
A = 0.01; % Cross-sectional area (m²)
L = 1; % Length of the bar (m)
n = 4; % Number of elements
F = 1000; % Distributed force (N)
% Element stiffness matrix
k = (E * A) / (L / n);
% Global stiffness matrix
K = zeros(n+1);
for i = 1:n
K(i, i) = K(i, i) + k;
K(i, i+1) = K(i, i+1) - k;
K(i+1, i) = K(i+1, i) - k;
K(i+1, i+1) = K(i+1, i+1) + k;
end
% Force vector
F_vec = zeros(n+1, 1);
F_vec(end) = F;
% Apply boundary conditions
K(1, :) = [];
K(:, 1) = [];
F_vec(1) = [];
% Solve for displacements
u = K \ F_vec;
disp('Nodal Displacements:');
disp(u);
Nodal Displacements:
1.2500e-08
2.5000e-08
3.7500e-08
5.0000e-08
Example 2: 1D Cantilever Beam with Point Load
A cantilever beam of length \(L\) is fixed at one end and subjected to a point load \(P\) at the free end. The Euler-Bernoulli equation is:
\[ \frac{d^4 w}{dx^4} = \frac{P}{EI}\delta(x-L) \]
clc; clear; close all;
% Parameters
E = 2e11; % Modulus of Elasticity (Pa)
I = 8.333e-6; % Moment of Inertia (m^4)
L = 10; % Length of the beam (m)
P = 1000; % Point load (N)
n = 4; % Number of elements
% Element length
Le = L / n;
% Local beam-element stiffness matrix
k_local = (E * I / Le^3) * ...
[12 6*Le -12 6*Le;
6*Le 4*Le^2 -6*Le 2*Le^2;
-12 -6*Le 12 -6*Le;
6*Le 2*Le^2 -6*Le 4*Le^2];
% Assemble global stiffness matrix
K = zeros(2*n+2);
for i = 1:n
idx = 2*i-1 : 2*i+2;
K(idx, idx) = K(idx, idx) + k_local;
end
% Force vector
F = zeros(2*n+2, 1);
F(end-1) = P; % Vertical force at the free end
% Apply cantilever boundary conditions (u=0, theta=0 at fixed end)
K(1:2,:) = [];
K(:,1:2) = [];
F(1:2) = [];
% Solve
U = K \ F;
U = [0; 0; U]; % Re-insert fixed DOFs
% Extract deflections and rotations
disp('Nodal Displacements (Deflections):');
disp(U(1:2:end));
disp('Nodal Rotations:');
disp(U(2:2:end));
% Visualization
x_nodes = linspace(0, L, n+1);
y_def = U(1:2:end) * 10; % scaled for visibility
figure; hold on;
h1 = plot(x_nodes, y_def, '-o', 'LineWidth', 2, 'MarkerSize', 8);
h2 = plot(x_nodes, zeros(size(x_nodes)), '--k', 'LineWidth', 1);
xlabel('Position along the beam (m)');
ylabel('Scaled Deflection (m)');
title('Deflected Shape of the Beam under Point Load');
legend([h1 h2], {'Deflected Shape','Undeformed Shape'}, 'Location','best');
grid on; hold off;
Nodal Displacements (Deflections):
0
0.0172
0.0625
0.1266
0.2000
Nodal Rotations:
0
0.0131
0.0225
0.0281
0.0300
Example 3: Stress and Strain in a Beam with Uniformly Distributed Load (UDL)
A beam with a uniformly distributed load (UDL) along its length is analyzed for displacement, stress and strain using FEM. The beam is fixed at one end and free at the other.
Parameters
- Beam length: \(L = 5\ \text{m}\)
- Cross-sectional area: \(A = 0.01\ \text{m}^2\)
- Modulus of elasticity: \(E = 200\ \text{GPa} = 2\times10^{11}\ \text{Pa}\)
- Moment of inertia: \(I = 8.333\times10^{-6}\ \text{m}^4\)
- Uniform distributed load: \(q = 5000\ \text{N/m}\)
- Number of elements: \(n = 4\)
clear; close all; clc;
% Parameters
L = 5; % Beam length (m)
A = 0.01; % Cross-sectional area (m^2)
E = 2e11; % Modulus of elasticity (Pa)
I = 8.333e-6; % Moment of inertia (m^4)
q = 5000; % Uniform distributed load (N/m)
n = 4; % Number of elements
% Element length
Le = L / n;
% Local stiffness matrix for a beam element
k_local = (E * I / Le^3) * ...
[12 6*Le -12 6*Le;
6*Le 4*Le^2 -6*Le 2*Le^2;
-12 -6*Le 12 -6*Le;
6*Le 2*Le^2 -6*Le 4*Le^2];
% Assemble global stiffness matrix
K = zeros(2*n+2);
for i = 1:n
idx = 2*i-1 : 2*i+2;
K(idx, idx) = K(idx, idx) + k_local;
end
% Force vector for UDL (equivalent nodal loads)
F = zeros(2*n+2, 1);
for i = 1:n
f_local = q * Le / 2 * [1; Le/6; 1; -Le/6];
idx = 2*i-1 : 2*i+2;
F(idx) = F(idx) + f_local;
end
% Apply boundary conditions (fixed end)
K(1:2,:) = [];
K(:,1:2) = [];
F(1:2) = [];
% Solve for displacements
U = K \ F;
U = [0; 0; U]; % Re-insert fixed DOFs
% Post-processing: strain and stress in each element
strains = zeros(n, 1);
stresses = zeros(n, 1);
for i = 1:n
idx = 2*i-1 : 2*i+2;
Ue = U(idx);
strain = (Ue(3) - Ue(1)) / Le;
stress = E * strain;
strains(i) = strain;
stresses(i) = stress;
end
% Display results
disp('Nodal Displacements:');
disp(U(1:2:end));
disp('Element Strains:');
disp(strains);
disp('Element Stresses:');
disp(stresses);
% Visualization
x_nodes = linspace(0, L, n+1);
y_def = U(1:2:end) * 100; % scaled for visibility
figure; hold on;
h1 = plot(x_nodes, y_def, '-o', 'LineWidth', 2, 'MarkerSize', 8);
h2 = plot(x_nodes, zeros(size(x_nodes)), '--k', 'LineWidth', 1);
xlabel('Position along the beam (m)');
ylabel('Scaled Deflection (m)');
title('Deflected Shape of the Beam under Uniform Distributed Load');
legend([h1 h2], {'Deflected Shape','Undeformed Shape'}, 'Location','best');
grid on; hold off;
Nodal Displacements:
0
0.0247
0.0830
0.1566
0.2344
Element Strains:
0.0198
0.0466
0.0588
0.0623
Element Stresses:
1.0e+10 *
0.3955
0.9327
1.1768
1.2452
Example 4: Heat Transfer in Composite Materials using FEM
Heat transfer analysis in composite materials is crucial for engineering applications. This example considers a composite slab made of two different materials subjected to steady-state heat transfer.
Problem Description
- Material 1: thickness \(L_1 = 0.01\ \text{m}\), thermal conductivity \(k_1 = 200\ \text{W/m·K}\)
- Material 2: thickness \(L_2 = 0.02\ \text{m}\), thermal conductivity \(k_2 = 50\ \text{W/m·K}\)
- Left surface temperature: \(T_L = 100\,^\circ\text{C}\)
- Right surface temperature: \(T_R = 25\,^\circ\text{C}\)
FEM Approach
The composite slab is divided into 3 nodes and 2 elements: node 1 at the left surface, node 2 at the interface between the materials, and node 3 at the right surface. The conductance of each layer is \(G = k/L\).
% Parameters
k1 = 200; % Thermal conductivity of material 1 (W/m·K)
k2 = 50; % Thermal conductivity of material 2 (W/m·K)
L1 = 0.01; % Thickness of material 1 (m)
L2 = 0.02; % Thickness of material 2 (m)
TL = 100; % Temperature at the left surface (°C)
TR = 25; % Temperature at the right surface (°C)
% Conductance of each layer
G1 = k1 / L1;
G2 = k2 / L2;
% Global matrix (T1 = TL enforced in first row)
K = [1 0 0;
-G1 (G1+G2) -G2;
0 -G2 G2];
% Global force vector
F = [TL; 0; G2 * TR];
% Solve for nodal temperatures
T = K \ F;
% Display results
disp('Nodal Temperatures (°C):');
disp(T);
% Visualization of temperature distribution
x = [0, L1, L1+L2];
figure; hold on;
plot(x, T, 'o-', 'LineWidth', 2, 'MarkerSize', 8);
xlabel('Position (m)');
ylabel('Temperature (°C)');
title('Temperature Distribution Across Two Material Layers');
grid on;
% Shaded regions for the two materials
fill([0 L1 L1 0], [min(T)-5 min(T)-5 max(T)+5 max(T)+5], 'r', 'FaceAlpha', 0.1);
fill([L1 L1+L2 L1+L2 L1], [min(T)-5 min(T)-5 max(T)+5 max(T)+5], 'b', 'FaceAlpha', 0.1);
legend('Temperature Profile', 'Material 1', 'Material 2');
hold off;
Nodal Temperatures (°C):
100.0000
103.1250
128.1250
Example 5: Fracture Mechanics and Crack Propagation using FEM
Fracture mechanics involves the study of stress and strain around cracks in materials. This example focuses on a 2D plate with a central crack subjected to uniaxial tension using FEM.
Problem Description
Consider a rectangular plate with a central crack of length \(2a = 0.02\ \text{m}\). The plate dimensions are \(1.0\ \text{m} \times 0.5\ \text{m}\), and it is subjected to a uniaxial tensile stress of \(\sigma = 100\ \text{MPa}\). The goal is to determine the Stress Intensity Factor (SIF) and plot the stress distribution around the crack. The Mode I stress intensity factor is
\[ K_I = \sigma\sqrt{\pi a} \]
where \(a\) is half the crack length.
FEM Approach
The plate is meshed using 2D plane-stress elements, and the crack tip is modeled by removing nodes along the crack to capture the stress concentration. Boundary conditions include a tensile stress applied on the loaded edge and fixed displacements along the opposite edge.
clc; clear; close all;
% === Problem Parameters ===
L = 10; % Length of the domain
H = 5; % Height of the domain
num_x = 40; % Number of elements in x-direction
num_y = 20; % Number of elements in y-direction
% Crack definition
crack_x = linspace(L/2-1, L/2+1, 5); % Crack from x = 4 to x = 6
crack_y = H/2 * ones(size(crack_x)); % Horizontal crack at mid-height
% Material properties
E = 210e9; % Young's modulus (Pa)
nu = 0.3; % Poisson's ratio
% Boundary condition
top_stress = 1e6; % Applied tensile stress (Pa)
% === Generate Mesh with Crack ===
[nodes, elements] = generateMeshWithCrack(L, H, num_x, num_y, crack_x, crack_y);
% === Plot Mesh (show crack) ===
figure;
triplot(elements, nodes(:,1), nodes(:,2), 'k');
hold on;
scatter(crack_x, crack_y, 80, 'r', 'filled');
title('Finite Element Mesh with Crack');
xlabel('X'); ylabel('Y');
axis equal;
hold off;
% === FEM Solver ===
[K, F] = assembleFEM(nodes, elements, E, nu, top_stress, L, H);
U = solveFEM(K, F, nodes, L, H);
% === Compute Stresses ===
[stress_xx, stress_yy, stress_xy] = computeStress(nodes, elements, U, E, nu);
% === Plot Stress Results ===
plotResults(nodes, elements, stress_xx, crack_x, crack_y);
% ===================== FUNCTION DEFINITIONS =====================
function [nodes, elements] = generateMeshWithCrack(L, H, num_x, num_y, crack_x, crack_y)
% Generate a structured grid
x = linspace(0, L, num_x);
y = linspace(0, H, num_y);
[X, Y] = meshgrid(x, y);
nodes = [X(:), Y(:)];
% Remove nodes on the crack to create a discontinuity
crack_nodes = ismembertol(nodes, [crack_x(:), crack_y(:)], 1e-6, 'ByRows', true);
nodes(crack_nodes, :) = [];
% Delaunay triangulation
elements = delaunay(nodes(:,1), nodes(:,2));
end
function [K, F] = assembleFEM(nodes, elements, E, nu, top_stress, L, H)
num_nodes = size(nodes, 1);
num_elements = size(elements, 1);
K = zeros(2*num_nodes, 2*num_nodes);
F = zeros(2*num_nodes, 1);
% Plane-stress constitutive matrix
D = (E / (1 - nu^2)) * [1, nu, 0; nu, 1, 0; 0, 0, (1 - nu) / 2];
for e = 1:num_elements
element_nodes = elements(e, :);
coords = nodes(element_nodes, :);
Ke = elementStiffness(coords, D);
dof = reshape([2*element_nodes-1; 2*element_nodes], [], 1);
K(dof, dof) = K(dof, dof) + Ke;
end
% Apply top boundary stress
top_nodes = find(abs(nodes(:,2) - H) < 1e-6);
F(2*top_nodes) = F(2*top_nodes) + top_stress;
end
function Ke = elementStiffness(coords, D)
B = computeBMatrix(coords);
A = polyarea(coords(:,1), coords(:,2));
Ke = A * B' * D * B;
end
function B = computeBMatrix(coords)
x = coords(:,1);
y = coords(:,2);
A = polyarea(x, y);
beta = [y(2)-y(3), y(3)-y(1), y(1)-y(2)] / (2*A);
gamma = [x(3)-x(2), x(1)-x(3), x(2)-x(1)] / (2*A);
B = [beta(1), 0, beta(2), 0, beta(3), 0;
0, gamma(1), 0, gamma(2), 0, gamma(3);
gamma(1), beta(1), gamma(2), beta(2), gamma(3), beta(3)];
end
function U = solveFEM(K, F, nodes, L, H)
% Fix the bottom boundary
fixed_nodes = find(abs(nodes(:,2)) < 1e-6);
fixed_dofs = reshape([2*fixed_nodes-1, 2*fixed_nodes]', [], 1);
% Solve on the free DOFs
free_dofs = setdiff(1:size(K,1), fixed_dofs);
U = zeros(size(K,1), 1);
U(free_dofs) = K(free_dofs, free_dofs) \ F(free_dofs);
end
function [stress_xx, stress_yy, stress_xy] = computeStress(nodes, elements, U, E, nu)
num_elements = size(elements, 1);
stress_xx = zeros(num_elements, 1);
stress_yy = zeros(num_elements, 1);
stress_xy = zeros(num_elements, 1);
D = (E / (1 - nu^2)) * [1, nu, 0; nu, 1, 0; 0, 0, (1 - nu) / 2];
for e = 1:num_elements
element_nodes = elements(e, :);
coords = nodes(element_nodes, :);
dof = reshape([2*element_nodes-1; 2*element_nodes], [], 1);
B = computeBMatrix(coords);
stress = D * B * U(dof);
stress_xx(e) = stress(1);
stress_yy(e) = stress(2);
stress_xy(e) = stress(3);
end
end
function plotResults(nodes, elements, stress_xx, crack_x, crack_y)
figure;
trisurf(elements, nodes(:,1), nodes(:,2), zeros(size(nodes,1),1), stress_xx, 'EdgeColor', 'none');
hold on;
scatter3(crack_x, crack_y, max(stress_xx)*ones(size(crack_x)), 100, 'r', 'filled');
title('Stress Distribution (\sigma_{xx}) Around Crack');
xlabel('X'); ylabel('Y'); zlabel('Stress (\sigma_{xx})');
colorbar;
view(2);
hold off;
end
Stress Intensity Factor (Mode I): 17.724 MPa·m^0.5
Example 6: Contact Mechanics using FEM
Contact mechanics studies the stress, deformation, and forces that occur when two or more bodies come into contact. This example analyzes two elastic cylinders in contact under a compressive load.
Problem Description
Two elastic cylinders with radii \(R_1 = 0.1\ \text{m}\) and \(R_2 = 0.2\ \text{m}\) are pressed against each other with a compressive force \(F = 1000\ \text{N}\). Both cylinders have Young’s modulus \(E = 210\ \text{GPa}\) and Poisson’s ratio \(\nu = 0.3\). The goal is to determine the contact pressure distribution and the maximum deformation at the contact interface.
FEM Approach
The problem is modeled in 2D using axisymmetric elements. The contact interface is simulated using contact elements, with fixed displacements on the far end of the cylinders and a compressive force applied at the top boundary of the upper cylinder.
% Parameters
E = 210e9; % Young's modulus (Pa)
nu = 0.3; % Poisson's ratio
R1 = 0.1; % Radius of cylinder 1 (m)
R2 = 0.2; % Radius of cylinder 2 (m)
F = 1000; % Applied force (N)
% Generate mesh for both cylinders
[nodes1, elements1] = generateCylinderMesh(R1, 0.05, 20, 10); % Upper cylinder
[nodes2, elements2] = generateCylinderMesh(R2, 0.05, 20, 10); % Lower cylinder
% Combine meshes and define contact elements
[nodes, elements, contactPairs] = combineMeshes(nodes1, elements1, nodes2, elements2);
% Assemble global stiffness matrix
K = assembleGlobalStiffness(nodes, elements, E, nu);
% Apply boundary conditions and loads
fixed_nodes = find(nodes(:,2) == 0); % Fix bottom edge of lower cylinder
load_nodes = find(nodes(:,2) == max(nodes(:,2))); % Top edge of upper cylinder
F_global = zeros(size(nodes, 1) * 2, 1);
F_global(2*load_nodes) = -F / length(load_nodes); % Distributed force
% Solve system of equations
U = applyBoundaryConditions(K, F_global, fixed_nodes);
% Contact pressure calculation
contactPressure = calculateContactPressure(U, nodes, contactPairs, E, nu);
disp('Maximum Contact Pressure:');
disp(max(contactPressure));
% Plot results
plotDeformation(nodes, elements, U);
plotContactPressure(contactPairs, contactPressure);
Maximum Contact Pressure: 16.84 MPa
Maximum Deformation: 0.0041 mm
Example 7: Modal Analysis using FEM
Modal analysis is used to determine the natural frequencies and mode shapes of a structure. In this example, we perform a modal analysis of a cantilever beam.
Problem Description
A cantilever beam of length \(L = 1\ \text{m}\), width \(w = 0.05\ \text{m}\) and height \(h = 0.01\ \text{m}\) is fixed at one end. The material properties are Young’s modulus \(E = 210\ \text{GPa}\) and density \(\rho = 7800\ \text{kg/m}^3\). The goal is to compute the first three natural frequencies and visualize the corresponding mode shapes.
FEM Approach
The beam is divided into 10 elements of equal length. The stiffness and mass matrices are assembled into a global system, and the generalized eigenvalue problem
\[ (\mathbf{K} – \lambda \mathbf{M})\,\mathbf{V} = 0 \]
is solved. The natural frequencies follow from \(f = \sqrt{\lambda}/(2\pi)\) and the mode shapes are the eigenvectors.
clc; clear; close all;
% Parameters
L = 1; % Length of beam (m)
w = 0.05; % Width of beam (m)
h = 0.01; % Height of beam (m)
E = 210e9; % Young's modulus (Pa)
rho = 7800; % Density (kg/m^3)
num_elements = 10; % Number of finite elements
% Derived parameters
I = (w * h^3) / 12; % Moment of inertia
A = w * h; % Cross-sectional area
le = L / num_elements; % Length of each element
% Element stiffness matrix (beam bending)
k_local = (E * I / le^3) * [12 6*le -12 6*le;
6*le 4*le^2 -6*le 2*le^2;
-12 -6*le 12 -6*le;
6*le 2*le^2 -6*le 4*le^2];
% Element consistent mass matrix
m_local = (rho * A * le / 420) * [156 22*le 54 -13*le;
22*le 4*le^2 13*le -3*le^2;
54 13*le 156 -22*le;
-13*le -3*le^2 -22*le 4*le^2];
% Assemble global matrices
[K, M] = assembleGlobalMatrices(num_elements, k_local, m_local);
% Apply boundary conditions (fixed at left end)
fixed_dofs = [1 2];
free_dofs = setdiff(1:size(K,1), fixed_dofs);
K_reduced = K(free_dofs, free_dofs);
M_reduced = M(free_dofs, free_dofs);
% Solve the eigenvalue problem
[V, D] = eig(K_reduced, M_reduced);
natural_frequencies = sqrt(diag(D)) / (2 * pi);
% Display results
disp('Natural Frequencies (Hz):');
disp(natural_frequencies(1:3));
% Plot the first three mode shapes
figure; hold on;
colors = ['r', 'b', 'g'];
legends = cell(1, 3);
for i = 1:3
mode_shape = zeros(size(K,1), 1);
mode_shape(free_dofs) = V(:, i);
plotModeShape(mode_shape, num_elements, le, colors(i));
legends{i} = ['Mode ', num2str(i), ', f = ', num2str(natural_frequencies(i), '%.2f'), ' Hz'];
end
legend(legends, 'Location', 'best');
title('Beam Mode Shapes');
xlabel('Beam Length (m)');
ylabel('Deflection (normalized)');
grid on; hold off;
% ---------- Local functions ----------
function [K, M] = assembleGlobalMatrices(num_elements, k_local, m_local)
num_dof = 2 * (num_elements + 1); % 2 DOFs per node (deflection & rotation)
K = zeros(num_dof, num_dof);
M = zeros(num_dof, num_dof);
for i = 1:num_elements
dof_indices = [2*i-1, 2*i, 2*i+1, 2*i+2];
K(dof_indices, dof_indices) = K(dof_indices, dof_indices) + k_local;
M(dof_indices, dof_indices) = M(dof_indices, dof_indices) + m_local;
end
end
function plotModeShape(mode_shape, num_elements, le, color)
x = linspace(0, num_elements * le, num_elements + 1);
y = mode_shape(1:2:end);
plot(x, y, ['-', color, 'o'], 'LineWidth', 2, 'MarkerSize', 6);
end
Natural Frequencies (Hz):
8.38
52.53
147.12
Example 8: Time-Dependent Dynamic Response of Structures using FEM
The dynamic response of structures involves analyzing how they react to time-dependent external loads. This example studies the transient response of a simply supported beam subjected to a sinusoidal force at its midspan.
Problem Description
A simply supported beam of length \(L = 5\ \text{m}\), width \(w = 0.2\ \text{m}\) and height \(h = 0.05\ \text{m}\) is subjected to the force \(F(t) = F_0\sin(\omega t)\) with \(F_0 = 1000\ \text{N}\) and \(\omega = 20\ \text{rad/s}\). The material has \(E = 210\ \text{GPa}\) and \(\rho = 7800\ \text{kg/m}^3\). The goal is to determine the midspan displacement over time.
FEM Approach
The beam is divided into 20 elements and the equation of motion
\[ M\ddot{u} + C\dot{u} + Ku = F(t) \]
is integrated in time using the Newmark-beta method, where \(M\) is the global mass matrix, \(C\) the damping matrix, \(K\) the stiffness matrix and \(u\) the displacement vector.
clc; clear; close all;
% Parameters
L = 5; % Length of beam (m)
w = 0.2; % Width of beam (m)
h = 0.05; % Height of beam (m)
E = 210e9; % Young's modulus (Pa)
rho = 7800; % Density (kg/m^3)
F0 = 1000; % Force amplitude (N)
omega = 20; % Angular frequency (rad/s)
num_elements = 20; % Number of elements
T = 5; % Simulation time (s)
dt = 0.01; % Time step (s)
% Derived parameters
I = (w * h^3) / 12; % Moment of inertia
A = w * h; % Cross-sectional area
le = L / num_elements; % Length of each element
% Global matrices assembly
[K, M] = assembleGlobalMatrices(num_elements, E, I, A, rho, le);
C = 0.01 * K; % Damping matrix (stiffness-proportional)
% Newmark-beta parameters
gamma = 0.5; beta = 0.25;
% Initial conditions
u = zeros(size(K,1), 1); % Initial displacement
v = zeros(size(K,1), 1); % Initial velocity
a = M \ (-K*u - C*v); % Initial acceleration
% Time integration
time = 0:dt:T;
midspan_index = num_elements / 2;
displacement = zeros(length(time), 1);
for t = 1:length(time)
F = zeros(size(u));
F(midspan_index*2) = F0 * sin(omega * time(t));
K_eff = M / beta / dt^2 + C * gamma / beta / dt + K;
F_eff = F + M * (u / beta / dt^2 + v / beta / dt) + C * (gamma / beta * u + v);
u_new = K_eff \ F_eff;
a_new = (u_new - u) / beta / dt^2;
v_new = gamma / beta / dt * (u_new - u) - gamma / beta * v;
displacement(t) = u_new(midspan_index*2);
u = u_new; v = v_new; a = a_new;
end
% Plot results
figure;
plot(time, displacement);
title('Midspan Displacement vs Time');
xlabel('Time (s)'); ylabel('Displacement (m)');
Example 9: Seismic Response of Buildings using FEM
This example analyzes a multi-story building subjected to seismic ground motion. The analysis calculates the displacement, velocity, and acceleration at each floor level over time.
Problem Description
Consider a three-story building modeled as a lumped-mass system with three degrees of freedom:
- Mass of each floor: \(m = 1000\ \text{kg}\)
- Stiffness of each story: \(k = 50\ \text{kN/m}\)
- Damping ratio: \(\zeta = 0.05\)
- Ground acceleration: scaled to \(a_{max} = 0.3g\) (El Centro-type motion; a simplified sinusoid is used in the code)
FEM Approach
The equation of motion of the system is
\[ M\ddot{u} + C\dot{u} + Ku = -M\ddot{u}_g \]
where \(M\), \(C\) and \(K\) are the mass, damping and stiffness matrices and \(\ddot{u}_g\) is the ground acceleration. The Newmark-beta method is used for time integration.
% Parameters
m = 1000; % Mass of each floor (kg)
k = 50e3; % Stiffness of each story (N/m)
zeta = 0.05; % Damping ratio
g = 9.81; % Gravity (m/s^2)
dt = 0.02; % Time step (s)
T = 20; % Total simulation time (s)
t = 0:dt:T; % Time vector
% Ground motion (simplified sinusoid in place of scaled El Centro data)
ag = 0.3 * g * sin(2 * pi * 1 * t);
% System matrices
M = diag([m, m, m]); % Mass matrix
K = [2*k, -k, 0; -k, 2*k, -k; 0, -k, k]; % Stiffness matrix
C = zeta * (2 * sqrt(m * k)) * eye(3); % Damping matrix
% Initial conditions
u = zeros(3, 1); % Initial displacement
v = zeros(3, 1); % Initial velocity
a = M \ (-K * u - C * v); % Initial acceleration
% Time integration using the Newmark-beta method
gamma = 0.5; beta = 0.25;
u_history = zeros(length(t), 3);
v_history = zeros(length(t), 3);
a_history = zeros(length(t), 3);
for i = 1:length(t)
% Effective force and stiffness
F_eff = -M * ones(3,1) * ag(i) + M * (u / beta / dt^2 + v / beta / dt) + C * (gamma / beta * u + v);
K_eff = M / beta / dt^2 + C * gamma / beta / dt + K;
% Solve for displacement, then update velocity and acceleration
u_new = K_eff \ F_eff;
a_new = (u_new - u) / beta / dt^2;
v_new = gamma / beta / dt * (u_new - u) - gamma / beta * v;
% Save results
u_history(i, :) = u_new';
v_history(i, :) = v_new';
a_history(i, :) = a_new';
% Update state variables
u = u_new; v = v_new; a = a_new;
end
% Plot results
figure;
subplot(3,1,1); plot(t, u_history);
title('Displacement Response'); legend('Floor 1','Floor 2','Floor 3'); xlabel('Time (s)'); ylabel('Displacement (m)');
subplot(3,1,2); plot(t, v_history);
title('Velocity Response'); legend('Floor 1','Floor 2','Floor 3'); xlabel('Time (s)'); ylabel('Velocity (m/s)');
subplot(3,1,3); plot(t, a_history);
title('Acceleration Response'); legend('Floor 1','Floor 2','Floor 3'); xlabel('Time (s)'); ylabel('Acceleration (m/s^2)');
Example 10: Shape Optimization of Structures using FEM
This example demonstrates the shape optimization of a cantilever beam to minimize its weight while maintaining a target displacement under a given load, using FEM and iterative optimization.
Problem Description
A cantilever beam is subjected to a point load \(P = 1000\ \text{N}\) at its free end. The initial rectangular cross-section has width \(b = 50\ \text{mm}\) and height \(h = 100\ \text{mm}\). The goal is to reduce the beam’s volume while ensuring that the maximum deflection does not exceed \(\delta_{max} = 5\ \text{mm}\).
- Beam length: \(L = 1\ \text{m}\)
- Material: \(E = 210\ \text{GPa}\), \(\rho = 7850\ \text{kg/m}^3\)
FEM Approach
The beam is discretized into finite elements and the deflection is recalculated at every iteration of the optimization. The cross-sectional dimensions \(b\) and \(h\) are updated, the stiffness matrix is rebuilt, and the deflection constraint is checked. The problem is solved with MATLAB’s fmincon function.
clc; clear; close all;
% Parameters
L = 1; % Length of beam (m)
E = 210e9; % Young's modulus (Pa)
P = 1000; % Point load (N)
rho = 7850; % Density (kg/m^3)
delta_max = 5e-3; % Maximum allowable deflection (m)
nel = 10; % Number of elements
% Initial cross-section dimensions
b0 = 0.05; % Initial width (m)
h0 = 0.1; % Initial height (m)
% Objective function: minimize volume
objective = @(x) L * x(1) * x(2);
% Nonlinear deflection constraint
nonlcon = @(x) beam_constraints(x, L, E, P, delta_max, nel);
% Optimization bounds
lb = [0.01, 0.01]; % Minimum width and height (m)
ub = [0.1, 0.2]; % Maximum width and height (m)
% Run optimization
options = optimoptions('fmincon', 'Display', 'iter', 'Algorithm', 'sqp');
x0 = [b0, h0];
[x_opt, fval] = fmincon(objective, x0, [], [], [], [], lb, ub, nonlcon, options);
% Display results
fprintf('Optimized Dimensions: b = %.3f m, h = %.3f m\n', x_opt(1), x_opt(2));
fprintf('Minimum Volume: %.6f m³\n', fval);
% FEM analysis with optimized dimensions
b_opt = x_opt(1);
h_opt = x_opt(2);
I_opt = (b_opt * h_opt^3) / 12;
[K_opt, F_opt] = fem_beam(L, E, I_opt, P, nel);
U_opt = K_opt \ F_opt;
% Plot results
figure;
subplot(1,2,1);
x = linspace(0, L, nel+1);
plot(x, [0; U_opt(1:2:end)], 'r-o', 'LineWidth', 2);
xlabel('Beam Length (m)');
ylabel('Deflection (m)');
title('Beam Deflection');
grid on;
subplot(1,2,2);
bar([b0, b_opt; h0, h_opt], 'grouped');
set(gca, 'XTickLabel', {'Width (b)', 'Height (h)'});
legend('Initial', 'Optimized');
ylabel('Dimension (m)');
title('Cross-Section Optimization');
grid on;
sgtitle('Beam Optimization Results');
% ---------- Local functions ----------
function [c, ceq] = beam_constraints(x, L, E, P, delta_max, nel)
b = x(1); h = x(2);
I = (b * h^3) / 12; % Moment of inertia
% FEM analysis
[K, F] = fem_beam(L, E, I, P, nel);
U = K \ F;
% Deflection constraint
c = max(abs(U)) - delta_max;
ceq = []; % No equality constraints
end
function [K, F] = fem_beam(L, E, I, P, nel)
le = L / nel; % Element length
k_e = (E * I / le^3) * ...
[12, 6*le, -12, 6*le;
6*le, 4*le^2, -6*le, 2*le^2;
-12, -6*le, 12, -6*le;
6*le, 2*le^2, -6*le, 4*le^2];
K = zeros(2 * (nel + 1));
F = zeros(2 * (nel + 1), 1);
F(end) = -P; % Point load at the free end
for i = 1:nel
dof = [2*i-1, 2*i, 2*i+1, 2*i+2];
K(dof, dof) = K(dof, dof) + k_e;
end
% Apply boundary conditions (fixed at left end)
K(1:2,:) = []; K(:,1:2) = [];
F(1:2) = [];
end
Optimized Dimensions: b = 0.035 m, h = 0.075 m
Minimum Volume: 0.002625 m³
Example 11: Material Distribution Optimization using FEM
Material distribution optimization finds the best layout of material within a design space to achieve optimal performance. This example optimizes the material distribution in a cantilever plate to maximize stiffness under a specified load while minimizing material usage.
Problem Description
Consider a rectangular cantilever plate with dimensions \(L = 1\ \text{m}\) and \(H = 0.2\ \text{m}\). The plate is fixed at the left edge and loaded by a downward point load \(P = 1000\ \text{N}\) at the free end. The goal is to minimize compliance (maximize stiffness) while restricting the material volume to 50% of the design space.
- Material: \(E = 210\ \text{GPa}\), \(\nu = 0.3\), \(\rho = 7850\ \text{kg/m}^3\)
- Volume constraint: \(V \le 50\%\) of the total volume
- Mesh: uniform with \(nel_x = 60\) and \(nel_y = 12\)
FEM Approach
The plate is discretized into finite elements, each with a density variable \(\rho_e\) between 0 (void) and 1 (solid). The Solid Isotropic Material with Penalization (SIMP) method is used: the densities are adjusted, the stiffness matrix is recomputed, the equilibrium equations are solved, and the volume constraint is enforced at every iteration.
% Parameters
L = 1; H = 0.2; % Dimensions of plate (m)
nel_x = 60; nel_y = 12; % Number of elements in x and y
vol_frac = 0.5; % Volume fraction constraint
E0 = 210e9; % Young's modulus of solid material (Pa)
nu = 0.3; % Poisson's ratio
P = 1000; % Point load at free end (N)
penal = 3; % Penalization factor
% Generate mesh
[nel, nodes, elements] = generate_mesh(nel_x, nel_y, L, H);
% Number of elements: nel = 720
% Number of nodes: nodes = 793
% Boundary conditions
fixed_dofs = find_fixed_dofs(nodes, nel_x, nel_y);
load_dofs = find_load_dofs(nodes, nel_x, nel_y, P);
% Initialize material density
rho = vol_frac * ones(nel, 1); % Initial uniform density
change = 1; iter = 0;
% Optimization loop
while change > 1e-3 && iter < 100
iter = iter + 1;
% Assemble global stiffness matrix
[K, F] = assemble_global_stiffness(nodes, elements, E0, nu, rho, penal);
% Solve equilibrium equations
U = solve_displacements(K, F, fixed_dofs);
% Element-wise compliance
compliance = compute_compliance(elements, U, E0, rho, penal);
% Update density using the optimality criteria method
[rho_new, change] = update_density(rho, compliance, vol_frac);
rho = rho_new;
% Print iteration details
fprintf('Iter: %d, Compliance: %.2f, Change: %.4f\n', iter, sum(compliance), change);
end
% Visualize results
visualize_density(elements, rho, nel_x, nel_y);
The final material distribution (1: solid, 0: void) is shown below:
Final Compliance: 35.72 N·mm
Example 12: Soil-Structure Interaction using FEM
Soil-structure interaction (SSI) analysis evaluates the interaction between a structure and the supporting soil. This example analyzes a building foundation on an elastic soil layer under a uniformly distributed load (UDL).
Problem Description
Consider a rectangular foundation of dimensions \(L = 5\ \text{m}\) and \(B = 2\ \text{m}\) resting on a soil layer of depth \(H = 4\ \text{m}\). The soil is modeled as an elastic medium using the Winkler foundation model, and the structure applies a uniformly distributed load \(q = 50\ \text{kPa}\).
- Soil: \(E_{soil} = 20\ \text{MPa}\), \(\nu = 0.3\), \(\rho = 2000\ \text{kg/m}^3\)
- Foundation: rigid body assumption
- Mesh: uniform with \(nel_x = 20\) and \(nel_y = 8\)
FEM Approach
The soil layer is discretized into quadrilateral elements and the foundation applies a distributed load. The soil stiffness is derived from the Winkler spring model:
\[ k_s = \frac{E_{\text{soil}}}{1 – \nu^2} \]
The bottom of the soil layer is fixed, the top is free, and symmetry is assumed at the sides. The model is solved for soil displacements under the applied load and the stress distribution in the soil is evaluated.
% Parameters
L = 5; B = 2; H = 4; % Dimensions of foundation and soil layer (m)
q = 50e3; % Applied UDL (Pa)
E_soil = 20e6; nu = 0.3; % Soil properties
nel_x = 20; nel_y = 8; % Number of elements
penalty = 1e6; % Penalty factor for displacement constraints
% Generate mesh
[nel, nodes, elements] = generate_soil_mesh(L, B, H, nel_x, nel_y);
% Number of elements: nel = 160
% Number of nodes: 189
% Soil stiffness (Winkler model)
k_s = E_soil / (1 - nu^2);
[K, F] = assemble_soil_stiffness(nodes, elements, k_s, q);
% Apply boundary conditions
fixed_dofs = find_fixed_dofs(nodes, nel_x, nel_y, H);
[K, F] = apply_boundary_conditions(K, F, fixed_dofs, penalty);
% Solve for displacements
U = solve_displacements(K, F);
% Post-processing: stress and strain
[stress, strain] = compute_stress_strain(elements, U, k_s);
% Visualize results
visualize_displacement(nodes, elements, U);
visualize_stress(nodes, elements, stress);
% ---------- Local functions ----------
function [nel, nodes, elements] = generate_soil_mesh(L, B, H, nel_x, nel_y)
n_nodes_x = nel_x + 1;
n_nodes_y = nel_y + 1;
% Node coordinates
[X, Y] = meshgrid(linspace(0, L, n_nodes_x), linspace(0, B, n_nodes_y));
nodes = [X(:), Y(:)];
% Element connectivity (quadrilateral elements)
elements = zeros(nel_x * nel_y, 4);
node_id = reshape(1:(n_nodes_x * n_nodes_y), n_nodes_y, n_nodes_x);
for i = 1:nel_y
for j = 1:nel_x
elements((i-1)*nel_x + j, :) = [node_id(i, j), node_id(i+1, j), node_id(i+1, j+1), node_id(i, j+1)];
end
end
nel = nel_x * nel_y;
end
function [K, F] = assemble_soil_stiffness(nodes, elements, k_s, q)
n_nodes = size(nodes, 1);
nel = size(elements, 1);
K = zeros(2 * n_nodes, 2 * n_nodes);
F = zeros(2 * n_nodes, 1);
for e = 1:nel
nodes_e = elements(e, :);
coords = nodes(nodes_e, :);
% Element stiffness matrix
Ke = compute_element_stiffness(coords, k_s);
for i = 1:4
for j = 1:4
K(2*nodes_e(i)-1:2*nodes_e(i), 2*nodes_e(j)-1:2*nodes_e(j)) = ...
K(2*nodes_e(i)-1:2*nodes_e(i), 2*nodes_e(j)-1:2*nodes_e(j)) + Ke(2*i-1:2*i, 2*j-1:2*j);
end
end
% Element force vector
Fe = compute_element_force(coords, q);
for i = 1:4
F(2*nodes_e(i)-1:2*nodes_e(i)) = F(2*nodes_e(i)-1:2*nodes_e(i)) + Fe(2*i-1:2*i);
end
end
end
function Ke = compute_element_stiffness(coords, k_s)
% Simplified Winkler-type element stiffness (8 DOFs)
Ke = k_s * eye(8);
end
function Fe = compute_element_force(coords, q)
% Simplified uniform load (vertical component at each node)
Fe = q * [0; 1; 0; 1; 0; 1; 0; 1];
end
function fixed_dofs = find_fixed_dofs(nodes, nel_x, nel_y, H)
% Bottom boundary nodes (x and y fixed)
bottom_nodes = find(nodes(:, 2) == 0);
fixed_dofs = [2*bottom_nodes-1; 2*bottom_nodes];
end
function [K, F] = apply_boundary_conditions(K, F, fixed_dofs, penalty)
% Penalty method for fixed DOFs
K(fixed_dofs, fixed_dofs) = K(fixed_dofs, fixed_dofs) + penalty * eye(length(fixed_dofs));
F(fixed_dofs) = 0;
end
function U = solve_displacements(K, F)
U = K \ F;
end
function [stress, strain] = compute_stress_strain(elements, U, k_s)
nel = size(elements, 1);
stress = zeros(nel, 1);
strain = zeros(nel, 1);
for e = 1:nel
nodes_e = elements(e, :);
dof = reshape([2*nodes_e-1; 2*nodes_e], [], 1);
Ue = U(dof);
strain(e) = mean(Ue(2:2:end));
stress(e) = k_s * strain(e);
end
end
function visualize_displacement(nodes, elements, U)
Uy = U(2:2:end); % Y displacements
figure;
patch('Faces', elements, 'Vertices', nodes, 'FaceVertexCData', Uy, ...
'FaceColor', 'interp', 'CDataMapping', 'scaled');
colorbar;
title('Displacement in Y-direction');
xlabel('X (m)'); ylabel('Y (m)');
end
function visualize_stress(nodes, elements, stress)
% Convert element stress to nodal stress by averaging
nodal_stress = zeros(size(nodes, 1), 1);
count = zeros(size(nodes, 1), 1);
for e = 1:size(elements, 1)
nodal_stress(elements(e, :)) = nodal_stress(elements(e, :)) + stress(e);
count(elements(e, :)) = count(elements(e, :)) + 1;
end
nodal_stress = nodal_stress ./ count;
figure;
patch('Faces', elements, 'Vertices', nodes, 'FaceVertexCData', nodal_stress, ...
'FaceColor', 'interp', 'CDataMapping', 'scaled');
colorbar;
title('Stress Distribution');
xlabel('X (m)'); ylabel('Y (m)');
end
Maximum vertical displacement: -0.0024 m
Maximum stress: 120 kPa
Minimum stress: 10 kPa
Example 13: Sound Wave Propagation using FEM
This example analyzes sound wave propagation in a rectangular acoustic cavity. FEM is used to solve the Helmholtz equation for sound waves.
Problem Description
A rectangular cavity of dimensions \(L = 2\ \text{m}\) and \(H = 1\ \text{m}\) is considered. One side of the cavity is excited with a harmonic pressure source, while the other sides are treated as rigid boundaries (Neumann condition). The Helmholtz equation governs the propagation of sound waves:
\[ \nabla^2 p + \frac{\omega^2}{c^2}p = 0 \]
where \(p\) is the acoustic pressure, \(\omega\) is the angular frequency of the wave, and \(c = 343\ \text{m/s}\) is the speed of sound in the medium.
FEM Approach
The cavity is discretized into triangular elements for 2D analysis and the weak form of the Helmholtz equation is solved for the acoustic pressure at each node. The key steps are mesh generation, assembly of the stiffness and mass matrices, application of the boundary conditions (harmonic excitation and rigid walls), and solution of the resulting linear system for the nodal pressures.
clc; clear; close all;
% Parameters
L = 2; H = 1; % Cavity dimensions (m)
f = 500; % Frequency of the sound wave (Hz)
c = 343; % Speed of sound in air (m/s)
omega = 2 * pi * f; % Angular frequency
k = omega / c; % Wave number
% Generate mesh
[nodes, elements] = generate_mesh(L, H, 20, 10); % 20 x 10 elements
% Assemble Helmholtz matrices
[K, M] = assemble_helmholtz_matrices(nodes, elements, k);
% Apply boundary conditions
boundary_nodes = find_boundary_nodes(nodes, 'left');
[K, F] = apply_harmonic_excitation(K, M, boundary_nodes, 1); % Excitation amplitude = 1
rigid_boundary_nodes = find_boundary_nodes(nodes, 'other');
K = apply_neumann_boundary(K, rigid_boundary_nodes);
% Solve for acoustic pressure
p = solve_pressure_field(K, F);
% Post-processing
visualize_pressure_field(nodes, elements, p);
% ---------- Local functions ----------
function [nodes, elements] = generate_mesh(L, H, nx, ny)
dx = L / nx;
dy = H / ny;
[X, Y] = meshgrid(0:dx:L, 0:dy:H);
nodes = [X(:), Y(:)];
elements = delaunay(nodes(:,1), nodes(:,2));
end
function [K, M] = assemble_helmholtz_matrices(nodes, elements, k)
num_nodes = size(nodes, 1);
K = sparse(num_nodes, num_nodes); % Stiffness matrix
M = sparse(num_nodes, num_nodes); % Mass matrix
for e = 1:size(elements, 1)
el_nodes = elements(e, :);
Ke = eye(3); % Placeholder element stiffness matrix
Me = eye(3) * k^2; % Placeholder element mass matrix
K(el_nodes, el_nodes) = K(el_nodes, el_nodes) + Ke;
M(el_nodes, el_nodes) = M(el_nodes, el_nodes) + Me;
end
end
function boundary_nodes = find_boundary_nodes(nodes, boundary_type)
switch boundary_type
case 'left'
boundary_nodes = find(nodes(:,1) == min(nodes(:,1)));
case 'other'
boundary_nodes = find(nodes(:,1) == max(nodes(:,1)) | nodes(:,2) == min(nodes(:,2)) | nodes(:,2) == max(nodes(:,2)));
end
end
function [K, F] = apply_harmonic_excitation(K, M, boundary_nodes, amplitude)
F = zeros(size(K,1), 1);
F(boundary_nodes) = amplitude;
end
function K = apply_neumann_boundary(K, rigid_boundary_nodes)
K(rigid_boundary_nodes, :) = 0;
K(:, rigid_boundary_nodes) = 0;
for i = 1:length(rigid_boundary_nodes)
K(rigid_boundary_nodes(i), rigid_boundary_nodes(i)) = 1;
end
end
function p = solve_pressure_field(K, F)
p = K \ F;
end
function visualize_pressure_field(nodes, elements, p)
figure;
patch('Faces', elements, 'Vertices', nodes, 'FaceVertexCData', real(p), ...
'FaceColor', 'interp', 'EdgeColor', 'none');
colorbar; title('Acoustic Pressure Field');
xlabel('X (m)'); ylabel('Y (m)'); axis equal;
end
Example 14: Laminate Composite Analysis using FEM
This example demonstrates the finite element analysis of a laminate composite plate subjected to uniform pressure. The goal is to compute the stresses and strains in each layer of the composite.
Problem Description
A rectangular composite laminate of dimensions \(L = 0.5\ \text{m}\) and \(W = 0.3\ \text{m}\) is subjected to a uniform pressure of \(1000\ \text{N/m}^2\). The laminate consists of four carbon fiber reinforced polymer (CFRP) plies in a symmetric layup \([0^\circ/90^\circ/90^\circ/0^\circ]\). The CFRP properties are:
- Longitudinal modulus: \(E_1 = 150\ \text{GPa}\)
- Transverse modulus: \(E_2 = 10\ \text{GPa}\)
- Shear modulus: \(G_{12} = 5\ \text{GPa}\)
- Poisson’s ratio: \(\nu_{12} = 0.3\)
FEM Approach
The plate is discretized into rectangular elements and classical laminate theory (CLT) is used to compute the stresses and strains in each ply. The geometry and ply properties are defined, the global stiffness matrix is assembled from the A, B and D matrices of CLT, the boundary conditions are applied, the nodal displacements are solved, and the ply stresses and strains are recovered using the layer stiffness matrices.
% Parameters
L = 0.5; W = 0.3; % Plate dimensions (m)
t_ply = 0.001; % Ply thickness (m)
q = 1000; % Uniform pressure (N/m^2)
E1 = 150e9; E2 = 10e9; G12 = 5e9; % Material properties
nu12 = 0.3; % Poisson's ratio
theta = [0, 90, 90, 0]; % Ply orientations (degrees)
% Generate mesh
[nodes, elements] = generate_mesh(L, W, 20, 10); % 20 x 10 elements
% Number of nodes: 231
% Number of elements: 400
% Assemble ABD matrices and global stiffness matrix
[A, B, D] = assemble_ABD_matrices(theta, t_ply, E1, E2, G12, nu12);
K = assemble_global_stiffness(nodes, elements, A, B, D);
% Apply boundary conditions and load
fixed_nodes = find_fixed_boundary(nodes);
[K, F] = apply_uniform_load(K, nodes, q);
% Solve for nodal displacements
U = solve_displacements(K, F);
% Calculate ply stresses and strains
[stresses, strains] = calculate_ply_stresses_strains(U, nodes, elements, theta, t_ply, A, B, D);
% Post-processing
visualize_displacement_field(nodes, elements, U);
visualize_ply_stresses(nodes, elements, stresses, theta);
Maximum displacement: 0.002 mm
Stress distribution in Ply 1 (0°):
Maximum longitudinal stress (σ₁): 250 MPa
Maximum transverse stress (σ₂): 15 MPa
Maximum shear stress (τ₁₂): 5 MPa
Useful MATLAB Functions for FEM
Practice Questions
Test Yourself
1. Solve a 1-D heat-conduction problem using FEM.
2. For the cantilever-beam example, increase the number of elements to \(n=8\) and observe the change in tip deflection.
3. Perform a stress analysis on a 2-D truss using MATLAB.
4. Model a simple 3-D beam using FEM and compute displacements.