Message Boards Message Boards

GROUPS:

Stiffness matrix should be symmetric

Posted 7 years ago
4339 Views
|
0 Replies
|
0 Total Likes
|

Hi,

I can't understand why the matrix KKt is not symmetric, and I can't see where I'm doing wrong. A second point is, if it's possible, to write KKt in a better and faster way.

Thanks!

 Coordinate := 
     Import["C:\\Users\\Riccardo\\Desktop\\Pannello \
    Muratura\\dati\\coordinate.txt", "Data"]
    Coordinate = Coordinate[[1 ;; Length[Coordinate]]];

Elementi := 
 Import["C:\\Users\\Riccardo\\Desktop\\Pannello \
Muratura\\dati\\elementi.txt", "Data"]
Elementi = Elementi[[1 ;; Length[Elementi]]];

Materiali := 
 Import["C:\\Users\\Riccardo\\Desktop\\Pannello \
Muratura\\dati\\materiali.txt", "Data"]
Materiali = Materiali[[1 ;; Length[Materiali]]];

nc := 2(*Gradi di libertà*)
nge := 3*nc(*gradi di libertà per elemento*)
nd := Length[Coordinate]
nn := nc*nd
KKg := Table[0, {i, nd}, {j, nd}]
ne := Length[Elementi]
f := Table[0, {i, nn}]

Table[{
   nod1[i] = Elementi[[i, 1]];
   nod2[i] = Elementi[[i, 2]];
   nod3[i] = Elementi[[i, 3]];
   xx1[i] = Coordinate[[nod1[i], 1]];
   xx2[i] = Coordinate[[nod2[i], 1]];
   xx3[i] = Coordinate[[nod3[i], 1]];
   yy1[i] = Coordinate[[nod1[i], 2]];
   yy2[i] = Coordinate[[nod2[i], 2]];
   yy3[i] = Coordinate[[nod3[i], 2]]}, {i, 1, ne}];

triangolo[
  i_] := {{xx1[i], yy1[i]}, {xx2[i], yy2[i]}, {xx3[i], 
   yy3[i]}, {xx1[i], yy1[i]}}

ListLinePlot[Table[triangolo[i], {i, 1, ne}], Frame -> True, 
 Axes -> False, PlotStyle -> {Blue}, AspectRatio -> 1/1]

EE = ReadList[StringToStream[Materiali[[1]]]][[1]]

ni = ReadList[StringToStream[Materiali[[2]]]][[1]]

tt = ReadList[StringToStream[Materiali[[3]]]][[1]]

bx = ReadList[StringToStream[Materiali[[4]]]][[1]]

by = ReadList[StringToStream[Materiali[[5]]]][[1]]

CC = EE/(1 - ni^2)*{{1, ni, 0}, {ni, 1, 0}, {0, 0, (1 - ni)/2}}

triangle[i_] := {{xx1[i], yy1[i], 1}, {xx2[i], yy2[i], 1}, {xx3[i], 
   yy3[i], 1}}

Table[{
   A[i] = Det[triangle[i]],
   a1[i] = yy2[i] - yy3[i],
   a2[i] = yy3[i] - yy1[i],
   a3[i] = yy1[i] - yy2[i],
   b1[i] = xx3[i] - xx2[i],
   b2[i] = xx1[i] - xx3[i],
   b3[i] = xx2[i] - xx1[i],
   c1[i] = xx2[i]*yy3[i] - xx3[i]*yy2[i],
   c2[i] = xx3[i]*yy1[i] - xx1[i]*yy3[i],
   c3[i] = xx1[i]*yy2[i] - xx2[i]*yy1[i],
   B[i] = 1/(2*A[i]) {{a1[i], 0, a2[i], 0, a3[i], 0},
      {0, b1[i], 0, b2[i], 0, b3[i]},
      {b1[i], a1[i], b2[i], a2[i], b3[i], a3[i]}},
   KKe[i] = (Transpose[B[i]].CC.B[i])*(tt*A[i]),
   gb1[i] = (nod1[i] - 1)*nc + 1,
   gb2[i] = (nod1[i] - 1)*nc + 2,
   gb3[i] = (nod2[i] - 1)*nc + 1,
   gb4[i] = (nod2[i] - 1)*nc + 2,
   gb5[i] = (nod3[i] - 1)*nc + 1,
   gb6[i] = (nod3[i] - 1)*nc + 2,
   ZZe[i] = 
    SparseArray[{{1, gb1[i]}, {2, gb2[i]}, {3, gb3[i]}, {4, 
        gb4[i]}, {5, gb5[i]}, {6, gb6[i]}} -> 1, {nge, nn}]}
  , {i, 1, ne}];

divisor = 100
SPart = FractionalPart[N[ne/divisor]]*divisor
nparts = IntegerPart[(ne - SPart)/divisor]
(*CHECK*)divisor*nparts + SPart - ne

For[i = 1, i <= nparts, i++, 
  KK[i] = Sum[
    Transpose[ZZe[j]].KKe[j].ZZe[j], {j, 1 + (i - 1)*divisor, 
     i*divisor}]];
KK[nparts + 1] = 
  Sum[Transpose[ZZe[j]].KKe[j].ZZe[j], {j, 
    1 + ((nparts + 1) - 1)*divisor, ne}];

Table[MatrixPlot[KK[i]], {i, 1, nparts + 1}]

KKt = Sum[KK[i], {i, 1, nparts + 1}];

MatrixPlot[KKt, 
 PlotLabel -> {{"Symmetric Matrix -> "} {SymmetricMatrixQ[KKt]}}]
Attachments:
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract