Assembling global stiffness matrix

59 ビュー (過去 30 日間)
wasabiwoman
wasabiwoman 2019 年 7 月 19 日
回答済み: Anil Makka 2021 年 3 月 21 日
I'm trying to assemble the global matrix, however, it gives me a few numbers at the end and the rest are zeros. There should be values along the diagonal of the matrix is what I'm trying to solve for. I've also attached my code.
%% Assembly
BIGK = zeros(NNODE*NDFPN,NNODE*NDFPN);
for I=1:NNPE % 4 nodes
for J=1:NNPE % 4 nodes
LRR = (I-1)*NDFPN; % 2
LRC = (J-1)*NDFPN;
GRR = (NODES(JE,I)-1)*NDFPN;
GRC = (NODES(JE,J)-1)*NDFPN;
for K=1:NDFPN
for L=1:NDFPN
BIGK(GRR+K,GRC+L) = BIGK(GRR+K,GRC+L)+EK(LRR+K,LRC+L);
end
end
end
end
  3 件のコメント
wasabiwoman
wasabiwoman 2019 年 7 月 19 日
The values of the diagonal elements are what I am trying to calculate.
dpb
dpb 2019 年 7 月 19 日
So, what's the basic formula for them from first principles, NOT from non-working code? How are we to know where it went wrong without a specification of what is right?

サインインしてコメントする。

回答 (2 件)

infinity
infinity 2019 年 7 月 19 日
Hello,
I have taken a look in your code, I relize that in each element there are four nodes and each node has two degree of freedom. Therefore, the element matrix of each element are 8x8.
To assemble element matrix to your global matrix, you should loop for each elment and just assemble its matrix to the global matrix.
The problem is that you have to find the approriate index to assembe emement matrix of each element. To do this, you can find the index according to the node of each element. For example, in your code the first element is
NODES(1,:)
ans =
1 22 23 2
therefore, the index of this element in the global matrix will be
[2*NODES(1,:)-1 2*NODES(1,:)]
ans =
1 43 45 3 2 44 46 4
when you have found this index, you just assembe to global matrix by
BIGK(INDEX,INDEX) = BIGK(INDEX,INDEX) + EK;
Summary, you could change your code to
%% Assembly
BIGK = zeros(NNODE*NDFPN,NNODE*NDFPN);
% for I=1:NNPE % 4 nodes
% for J=1:NNPE % 4 nodes
% LRR = (I-1)*NDFPN; % 2
% LRC = (J-1)*NDFPN;
% GRR = (NODES(JE,I)-1)*NDFPN;
% GRC = (NODES(JE,J)-1)*NDFPN;
% for K=1:NDFPN
% for L=1:NDFPN
% BIGK(GRR+K,GRC+L) = BIGK(GRR+K,GRC+L)+EK(LRR+K,LRC+L);
% end
% end
% end
% end
for I = 1:NELE
INDEX = [NODES(I,:)*2-1 NODES(I,:)*2];
BIGK(INDEX,INDEX) = BIGK(INDEX,INDEX) + EK;
end
Aslo, at the end of your code in Problem_2.m, you should change
%% Displacement
disp = (BIGK)/force;
to
%% Displacement
disp = (BIGK)\force;
since there is a different between / and \. You can refer more detail of "\" by this link
https://www.mathworks.com/help/matlab/ref/mldivide.html
  2 件のコメント
wasabiwoman
wasabiwoman 2019 年 7 月 20 日
Thank you! That was very illuminating and I appreciate it! However, it gives me a warning:
Warning: Matrix is close to singular or badly scaled. Results may be
inaccurate. RCOND = 3.597566e-20.
> In Problem_2 (line 234)
Where line 234 is
disp = (BIGK)\force;
And I do believe the displacement results are on the right track, but not quite correct.
infinity
infinity 2019 年 7 月 22 日
Hello,
This warning might come from the global matrix, which may be not invertible.
There are many possibilities of this behaviour. It could be boundary condition, also from the number of Gauss, and element stiffness matrix. To find out why do you have this behaviour, you could double check the code and the formulation.
I also can suggest you to increase number of elements to see does it increase the accuracy of the displacement.

サインインしてコメントする。


Anil Makka
Anil Makka 2021 年 3 月 21 日
k1=[1 2 3 4 5 6;1 2 3 4 5 6;1 2 3 4 5 6;1 2 3 4 5 6;1 2 3 4 5 6;1 2 3 4 5 6]; %stiffness matrix 1(local)
k2=[1 2 3 4 5 6;1 2 3 4 5 6;1 2 3 4 5 6;1 2 3 4 5 6;1 2 3 4 5 6;1 2 3 4 5 6]; %stiffness matrix 2(local)
how to create the global matrix using these two stiffness matrix

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by