0% found this document useful (0 votes)
2 views1 page

GRASP Python (60)

The document outlines a process for creating a reduced stiffness matrix (K_reduced) and a force vector (F) based on global stiffness and applied forces/moments. It includes loops for accumulating nodal forces and moments into the force vector, as well as creating a reduced force vector (F_reduced) for free degrees of freedom. Finally, it describes writing the reduced stiffness matrix to an Excel worksheet for further analysis.

Uploaded by

Le Fondateur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

GRASP Python (60)

The document outlines a process for creating a reduced stiffness matrix (K_reduced) and a force vector (F) based on global stiffness and applied forces/moments. It includes loops for accumulating nodal forces and moments into the force vector, as well as creating a reduced force vector (F_reduced) for free degrees of freedom. Finally, it describes writing the reduced stiffness matrix to an Excel worksheet for further analysis.

Uploaded by

Le Fondateur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

ReDim K_reduced(1 To free_count, 1 To free_count)

For i = 1 To free_count
For j = 1 To free_count
K_reduced(i, j) = K_global(free_dofs(i), free_dofs(j))
Next j
Next i

' Create force vector


Dim F(1 To totalDof) As Double

' Concentrated nodal forces


For nodeId = 1 To nodes.Count
On Error Resume Next
Dim f As Force
Set f = forces("F" & nodeId)
If Not f Is Nothing Then
F(3 * (nodeId - 1) + 1) = F(3 * (nodeId - 1) + 1) + f.fx ' Fx
F(3 * (nodeId - 1) + 2) = F(3 * (nodeId - 1) + 2) + f.fy ' Fy
End If
On Error GoTo 0
Next nodeId

' Concentrated nodal moments


For nodeId = 1 To nodes.Count
On Error Resume Next
Dim m As Moment
Set m = moments("M" & nodeId)
If Not m Is Nothing Then
F(3 * (nodeId - 1) + 3) = F(3 * (nodeId - 1) + 3) + m.mz ' Mz
End If
On Error GoTo 0
Next nodeId

' Create reduced force vector


Dim F_reduced() As Double
ReDim F_reduced(1 To free_count)

For i = 1 To free_count
F_reduced(i) = F(free_dofs(i))
Next i

' Solve for displacements


Dim displacements() As Double
ReDim displacements(1 To free_count)

' Use Excel's matrix functions to solve the system


Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets.Add

' Write K_reduced to worksheet


For i = 1 To free_count
For j = 1 To free_count
ws.Cells(i, j).Value = K_reduced(i, j)
Next j
Next i

P a g e 46 | 62

You might also like