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

GRASP Python (61)

The document outlines a procedure for calculating displacements and reactions in a structural analysis using Excel VBA. It includes steps for writing reduced forces to a worksheet, inverting a stiffness matrix, and computing displacements and reactions based on global stiffness. Finally, it formats and displays the results for node displacements.

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 (61)

The document outlines a procedure for calculating displacements and reactions in a structural analysis using Excel VBA. It includes steps for writing reduced forces to a worksheet, inverting a stiffness matrix, and computing displacements and reactions based on global stiffness. Finally, it formats and displays the results for node displacements.

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

' Write F_reduced to worksheet

For i = 1 To free_count
ws.Cells(i, free_count + 1).Value = F_reduced(i)
Next i

' Solve using MINVERSE and MMULT


Dim K_inv() As Variant
K_inv = WorksheetFunction.MInverse(ws.Range(ws.Cells(1, 1),
ws.Cells(free_count, free_count)).Value

Dim disp_vector As Variant


disp_vector = WorksheetFunction.MMult(K_inv, ws.Range(ws.Cells(1,
free_count + 1), ws.Cells(free_count, free_count + 1)).Value

' Get displacements back into array


For i = 1 To free_count
displacements(i) = disp_vector(i, 1)
Next i

' Clean up
Application.DisplayAlerts = False
ws.Delete
Application.DisplayAlerts = True

' Create full displacement vector


Dim U(1 To totalDof) As Double

For i = 1 To free_count
U(free_dofs(i)) = displacements(i)
Next i

' Calculate reactions


Dim reactions() As Double
ReDim reactions(1 To totalDof)

For i = 1 To totalDof
reactions(i) = 0
For j = 1 To totalDof
reactions(i) = reactions(i) + K_global(i, j) * U(j)
Next j
Next i

' Display results


Dim results As String
results = "Analysis Results:" & vbCrLf & vbCrLf
results = results & "Node Displacements:" & vbCrLf

For nodeId = 1 To nodes.Count


Dim ux As Double, uy As Double, theta As Double
ux = U(3 * (nodeId - 1) + 1)
uy = U(3 * (nodeId - 1) + 2)
theta = U(3 * (nodeId - 1) + 3)

results = results & "Node " & nodeId & ": ux = " & Format(ux,
"0.000E+00") & " m, " & _
"uy = " & Format(uy, "0.000E+00") & " m, "
& _

P a g e 47 | 62

You might also like