Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

% Input parameters

E = 30e6; % Young's modulus (Pa)


nu = 0.3; % Poisson's ratio
G = E/(2*(1+nu)); % Shear modulus (Pa)
rho = 2400; % Density (kg/m^3)
phi = 30; % Friction angle (deg)
c = 10e3; % Cohesion (Pa)
gamma = 9.81*rho; % Unit weight (N/m^3)
D = 1.2; % Pile diameter (m)
L = 25; % Pile length (m)
N = 10; % Number of piles
dx = 1.5*D; % Horizontal spacing between piles (m)
dy = 1.5*D; % Vertical spacing between piles (m)

% Mesh generation
nx = 30; % Number of elements in x-direction
ny = 10; % Number of elements in y-direction
dx_elem = L/nx; % Element size in x-direction (m)
dy_elem = D/ny; % Element size in y-direction (m)
x_nodes = linspace(0,L,nx+1); % Node locations in x-direction (m)
y_nodes = linspace(0,D,ny+1); % Node locations in y-direction (m)
[X,Y] = meshgrid(x_nodes,y_nodes); % Meshgrid of node locations
node_nums = reshape(1:(nx+1)*(ny+1),nx+1,ny+1); % Reshape node numbers
elem_nums = reshape(1:nx*ny,nx,ny); % Reshape element numbers

% Element stiffness matrices


C = [1 nu 0; nu 1 0; 0 0 (1-nu)/2];
S = [2/G -nu/G 0; -nu/G 2/G 0; 0 0 1/E];
K_elem = zeros(6,6,nx,ny);
for i = 1:nx
for j = 1:ny
Ke = zeros(6,6);
Ke([1 3 5],[1 3 5]) = C*gamma*D*dx_elem*dy_elem;
Ke([2 4 6],[2 4 6]) = S*gamma*D*dx_elem*dy_elem;
K_elem(:,:,i,j) = Ke;
end
end

% Assemble global stiffness matrix


K = zeros((nx+1)*(ny+1)*2);
for i = 1:nx
for j = 1:ny
nodes = node_nums(i:i+1,j:j+1);
indices = [nodes(1,1)*2-1 nodes(1,1)*2 nodes(2,1)*2-1 nodes(2,1)*2 ...
nodes(2,2)*2-1 nodes(2,2)*2 nodes(1,2)*2-1 nodes(1,2)*2];
K(indices,indices) = K(indices,indices) + reshape(K_elem(:,:,i,j),8,8);
end
end

% Apply boundary conditions


fixed_nodes = [node_nums(1,:) node_nums(nx+1,:) node_nums(:,1)'
node_nums(:,ny+1)'];

You might also like