Matlab and finite element

In summary, the conversation is discussing a problem involving a beam subjected to a horizontal distributed load. The conversation includes the relevant MATLAB solution and modifications made to it, as well as the calculation of the global stiffness matrix and force vector. The conversation ends with a desire to change the point load to a distributed load in the solution.
  • #1
Sadeq
107
0

Homework Statement


The problem picture is attached(file 1),its a beam subjected to horizonatal ditributed load


2. Relevant examples
the MATLAB solution for rectangular shape with vertical load on the upper right corner is like follow, i try to modify it according to the new picture, but i struggle in the load

clear all
close all
clc

%% Constants
L = 2;
D = 0.4;
t = 0.005;
E = 200e9;
nu = 0.3;
P = 10000;
n_x = 2;
n_y = 2;
C = E/(1-nu^2)*[1 nu,0;nu,1,0;0,0,(1-nu)/2];
K_G=zeros(2*(n_x+1)*(n_y+1),2*(n_x+1)*(n_y+1)); % The global stiffness matrix

%% Gauss-Legendre sampling points and weights
alpha = [1,1];
r = [-0.57735026919,0.57735026919];
s = [-0.57735026919,0.57735026919];

%% Calculate the global stiffness matrix
for i=1:n_x
for j=1:n_y

K_local = zeros(8,8);

%Note that the nested loop here is essentially cycling through the
%summation required for the numerical integration
for p=1:2
for q=1:2

x=[i*L/n_x,(i-1)*L/n_x,(i-1)*L/n_x,i*L/n_x]; %Global x-coordinate
y=[j*D/n_y,j*D/n_y,(j-1)*D/n_y,(j-1)*D/n_y]; %Global y-coordinate

dxdr=1/4*(1+s(1,q))*x(1,1)-1/4*(1+s(1,q))*x(1,2)-1/4*(1- s(1,q))*x(1,3)+1/4*(1-s(1,q))*x(1,4);
dxds=1/4*(1+r(1,p))*x(1,1)+1/4*(1-r(1,p))*x(1,2)-1/4*(1-r(1,p))*x(1,3)-1/4*(1+r(1,p))*x(1,4);
dydr=1/4*(1+s(1,q))*y(1,1)-1/4*(1+s(1,q))*y(1,2)-1/4*(1-s(1,q))*y(1,3)+1/4*(1-s(1,q))*y(1,4);
dyds=1/4*(1+r(1,p))*y(1,1)+1/4*(1-r(1,p))*y(1,2)-1/4*(1-r(1,p))*y(1,3)-1/4*(1+r(1,p))*y(1,4);
J=[dxdr,dydr;dxds,dyds];
invJ=inv(J);
detJ=det(J);

I1=.25*[1+s(1,q),0,-1-s(1,q),0,-1+s(1,q),0,1-s(1,q),0;1+r(1,p),0,1-r(1,p),0,-1+r(1,p),0,-1-r(1,p),0];
I2=.25*[0,1+s(1,q),0,-1-s(1,q),0,-1+s(1,q),0,1-s(1,q);0,1+r(1,p),0,1-r(1,p),0,-1+r(1,p),0,-1-r(1,p)];

B=[1,0;0,0;0,1]*invJ*I1+[0,0;0,1;1,0]*invJ*I2;

%Note here that we're adding to the previous value calculated for K_local (Gauss-Legendre scheme)
K_local=K_local+alpha(1,p)*alpha(1,q)*B.'*C*B*t*detJ;
end
end

nb=1+2*(i-1)+2*(j-1)*(n_x+1); %The bottom left global DoF number for element i,j
nt=1+2*(i-1)+2*j*(n_x+1); %The top left global DoF number for element i,j

%Assign the elements of the local stiffness matrix to the relevant location in the global stiffness matrix
K_G([[nb:1:nb+3],[nt:1:nt+3]],[[nb:1:nb+3],[nt:1:nt+3]])=K_G([[nb:1:nb+3],[nt:1:nt+3]],[[nb:1:nb+3],[nt:1:nt+3]])+K_local([5,6,7,8,3,4,1,2],[5,6,7,8,3,4,1,2]);
end
end

%% Construct the force vector

F=zeros(2*(n_x+1)*(n_y+1),1); %Construct the global force vector (zeros only)
F(2*(n_x+1)*(n_y+1),1)=-P[/COLOR];(how can i put the distributed load here) %Add the applied load to the global force vector

dof=[1:2*(n_x+1)*(n_y+1)]; %Construct a vector of DoF numbers

%Note
%C = setdiff(A,B) for vectors A and B, returns the values in A that are not in B with no repetitions.

dof=setdiff(dof,[1:2*(n_x+1):2*(n_x+1)*(n_y+1)]); %Extract/elimiate the horizontal DoF at the support
dof=setdiff(dof,[2:2*(n_x+1):2*(n_x+1)*(n_y+1)]); %Eliminate the vertical DoF at the support, leaving only the 'active' DoF
F2=F(dof,1); %Determine the reduced force matrix
K_G2=K_G(dof,dof); %Determine the reduced stiffness matrix
d2=inv(K_G2)*F2; %Calculate the vector of displacements
d=zeros(2*(n_x+1)*(n_y+1),1); %Produce a vector of zeros corresponding to the number of DoF
d(dof,1)=d2; %Add the calculated displacements to the previous vector
uy1=d;
 

Attachments

  • s.PNG
    s.PNG
    12.2 KB · Views: 442
Physics news on Phys.org
  • #2
so i want to change this from point load to distributed load
 

1. What is Matlab and how is it used in finite element analysis?

Matlab is a high-level programming language and interactive environment commonly used in scientific computing. It allows users to perform various mathematical and numerical operations, making it well-suited for finite element analysis. In this context, Matlab is used to solve complex equations and perform simulations to analyze the behavior of structures and materials under different conditions.

2. Can Matlab be used to create and manipulate finite element models?

Yes, Matlab has built-in functions and toolboxes specifically designed for finite element analysis. These tools can be used to create, manipulate, and visualize finite element models, making the process more efficient and accurate. Additionally, Matlab allows for the integration of user-defined functions, providing flexibility in modeling and analyzing complex systems.

3. What are the advantages of using Matlab for finite element analysis?

One of the main advantages of using Matlab for finite element analysis is its extensive library of built-in functions and toolboxes. These tools allow for efficient and accurate modeling and analysis of complex systems. Additionally, Matlab's user-friendly interface and programming language make it accessible to a wide range of users, from beginners to experienced scientists and engineers.

4. What are some common applications of Matlab in finite element analysis?

Matlab is commonly used in various fields, including mechanical engineering, civil engineering, and materials science, for finite element analysis. Some common applications include structural analysis, heat transfer analysis, and fluid dynamics analysis. It is also used in the design and optimization of products and processes.

5. Is Matlab the only software used for finite element analysis?

No, there are several other software programs available for finite element analysis, such as ANSYS, Abaqus, and COMSOL. Each of these programs has its own strengths and limitations, and the choice of software often depends on the specific needs and preferences of the user. However, Matlab's versatility and extensive capabilities make it a popular choice for many researchers and engineers.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
7
Views
734
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
18
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
888
  • Engineering and Comp Sci Homework Help
Replies
15
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Atomic and Condensed Matter
Replies
4
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Introductory Physics Homework Help
Replies
11
Views
2K
Back
Top