cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Translate the entire conversation x

Insert a matrix into a larger matrix at certain positions Stiffness matrix

QS_10727930
4-Participant

Insert a matrix into a larger matrix at certain positions Stiffness matrix

Hello community!


I request your help with the following: I want to enter a matrix into a larger one.
I’m working on assembling a global stiffness matrix of a structure (truss)
I have defined the matrices of each element. The matrix of the element is 4x4, "i"= 1 to "n", n: number of elements

QS_10727930_0-1688132919627.png

I have an auxiliary matrix that defines in each row the degrees of freedom associated with each element. For example row 1 contains the degrees of freedom of element 1 and so on. I named this matrix GDL

 

QS_10727930_1-1688132985443.png

 

What I want is for Mathcad to grab the matrix of each element and place it in the global matrix at the positions corresponding to the columns and rows that indicate the row of the auxiliary matrix GDL. For example the stiffness matrix of element 3 must be placed in rows and columns numbers 1, 2,5 y 6 of the global matrix.

I understand that once the correct routine is created I would have to use a FOR cycle to do it for each element. But at the moment I’m trying to test with only one element

 

Very grateful in advance for your guidance

 

 

 

 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:QS_10727930)

Yes 4x4, not 2x2 as I accidentally wrote.

 

So I guess that this should do the job:

Werner_E_2-1688144520594.png

 

Werner_E_1-1688144294230.png

 

Prime 9 worksheet attached

 

 

View solution in original post

14 REPLIES 14
Werner_E
25-Diamond I
(To:QS_10727930)

Can you manually create as an example the desired matrix to show what you actually want to see as a result?

Whats the dimension of the resulting matrix? 8x8 as the matrix K or rather 32x32 as at every position of K there has to be placed one of the 4x4 k(i) matrices?

If yes, should it be a nested matrix the elements are 4x4 matrices or should it be rather a plain 32x32 matrix?

QS_10727930
4-Participant
(To:Werner_E)

For example the matrix of element 3 would have to be placed in columns and rows 1,2,5 and 6

It would look like this:

 

This is element stiffness matrix 3: QS_10727930_0-1688140380080.png

 

This is its position in the global matrix:

 

QS_10727930_1-1688140449306.png

 

At the end the global stiffness matrix should look like this:

QS_10727930_2-1688141205672.png

 

 

 

 

 

 

 

 

 

 

Werner_E
25-Diamond I
(To:QS_10727930)

OK, it gets clearer!

Just to be on the safe side - The matrix GDL is always a square matrix because the number elements (e) is always the same as the number of nodes (N), correct?

And the matrices k(i) are always just 2x2 matrices?

 

Basically I can think of two ways to write a program to do the job. Either running throug all columns and rows (both of K and the k(i)) with nested loops, or using the submatrix() function to split the large matrix into parts and reassemble it using stack() and augment().

I guess the first approach might be the most forward.

 

QS_10727930
4-Participant
(To:Werner_E)

The matrix of each element will always be 4x4

The matrix of degrees of freedom (GDL) will always be square is correct. Because each element has 4 degrees of freedom. In the matrix of degrees of freedom in each row appear the numbers of degrees of freedom associated with that element.

Werner_E
25-Diamond I
(To:QS_10727930)

Yes 4x4, not 2x2 as I accidentally wrote.

 

So I guess that this should do the job:

Werner_E_2-1688144520594.png

 

Werner_E_1-1688144294230.png

 

Prime 9 worksheet attached

 

 

QS_10727930
4-Participant
(To:Werner_E)

Thank you so much!!!

SFares
14-Alexandrite
(To:Werner_E)

Hello Werner,

I have attached the same sheet (P10) with the code you added. I ran a different truss example. I  see an issue with the stiffness matrix on page 3. On page 3 i asked my question and explained what the results should be. Do i need to post my question as a new post? Thank you for your assistance!

Regards,
Sam

Werner_E
25-Diamond I
(To:SFares)

I can't say why the algorithm  which seemed to have worked for the OP did not do so for you. I also have not compared your worksheet with the sheet of the OP to spot the differences.

I have experience in using Mathcad and also Prime, but I have no experience whatsoever in your field of work.

So it may be a good idea to open a new thread and explain in more detail and in simple math terms what you would like to achieve.

It was only after the OP posted the general algorithm showing how the desired matrix K should be created using the results of function k that I was able to provide a corresponding solution.

If it does not work for you it may be that you want to follow a different algorithm? Not sure, though.

SFares
14-Alexandrite
(To:Werner_E)

I will do. Thank you, Werner!

 

Sam

Hi

Check section 2.4 of enclosed sheet for assembly of stiffness matrix from elemental stiffnesses

 

Capture.JPG

Thank you!

SFares
14-Alexandrite
(To:terryhendicott)

Hello Terry,

 

Thank you for this sheet "220105-Truss Challenge". What does section 2.5 "Use Restrain Matrix to Add Large Value...." do or its purpose?

Regards,

Sam

Hi Sam

 

The explanation is long.

 

The structural stiffness matrix is singular until the reactions of the modelled structure are applied.  Section 2.5 along with the reaction definition matrix "r" in section 1.3 are used to apply the modelled structure reaction locations.

 

Each reaction of the structure corresponds to one row and column of the  stiffness matrix at the appropriate degree of freedom position.

There are two ways to apply the reactions to the stiffness matrix.  Each has its merits.

 

The method I don't use is to set the diagonal at the appropriate degree of freedom position to 1 and the remaining degree of freedom row and column values to zero.  And also set the force matrix row at the appropriate degree of freedom position to 0 also.

 

Method I do use is to simply set the diagonal at the appropriate degree of freedom position to a relatively really large value as if a strong spring stiffness is applied at the degree of freedom.  If the support is a spring this is also what you do add the spring stiffness on the diagonal.

 

Section 1.3

In the truss analysis example supports are applied at node 1 and 2 of the modelled structure.  Node 1 is fixed at x and y direction.  Node 2 is fixed at only the y direction.  Matrix "r" in section 1.3 sets the reactions.  0 is free and 1 is fixed.  So matrix "r" has two rows one for node 1 and one for node 2.  "r" matrix first row has 1 for x direction and 1 for y direction representing node 1 fixities. "r" matrix row two has node number 2 and 0 for x direction meaning free and 1 for y direction meaning fixed.  This is to set up for section 2.5 where the "r" matrix is used to apply these reactions to the overall stiffness matrix.

 

Section 2.5

First expression sets a relatively large spring constant "Re" at 10^10 times the largest value in the stiffness matrix.

The range variable "il" iterates over the rows of "r" matrix set in section 1.3.

The big expression adds the value "Re" the big really stiff spring to the diagonal of the stiffness matrix.  Note the index into Kg is identical row and column.  "Re" is multiplied by the appropriate value in "r".  If the value in "r" is a zero then "Re" by "r" element is zero and nothing is added.  This is like row 2 of "r" where the x direction is free (0).  If the "r" value is 1 then "Re" is added to the diagonal like both directions at node 1 and y direction at node 2.

The index into Kg depends on the node number of the reaction.  Nodes in the model are base 1 with first node being 1, so the -1 is to get zero based in memory.  The node number in the first column of "r" at zero based is multiplied by two for the two degrees of freedom per node.  The iterator "ii" defined in Section 2.4 is used to iterate over the rows of "r" representing the fixed or free codes.

 

Hope this detailed description helps.  Don't hesitate to ask any more questions.

 

Cheers

Terry

SFares
14-Alexandrite
(To:terryhendicott)

Thank you so much, Terry, for your reply! When i am solving it manually, i cross out the columns and rows where there is zero displacement. I like how you automated the process. I will study it more and get back to you if I have any questions.

Regards,

Sam

Announcements

Top Tags