Programming as a Geotechnical Engineer

Oasys developers have recently released the COM interface into Frew, Alp and Greta and are planning to roll it out to our other Geotechnical programs.

Following our recent COM webinar, Application Specialist, Zeena Farook, started some scripting to see what she could achieve; “As a Geotechnical Engineer, I am more familiar with pen and paper calculations than coding but I was empowered to give it a try by the presentation.”

Why don’t you take a look at Zeena’s script below? It will set up an Excel Macro to output displacements for all stages for each node. This could be expanded to vary input phi values or wall stiffness’s to run sensitivity analysis. Alternatively, similar code can be written to outputs results for bending moments or shear forces in the wall. The code could also be expanded to plot outputs for all stages in one graph.

Zeena elaborates on her first foray into programming this way; “Having just started on my programming journey, I can see how using this interface can save a lot of analysis time. I look forward to hearing about what you would like to do with the COM interface and if you have any additional suggestions for COM instructions in Frew. You can download the user guide, so get coding!”

Zeena’s Script:

Sub MacroDisplacement()
'
' Macro1 Macro
'
'
Dim FrewObj                     'declare FrewCom object
Dim iRet As Integer                 'declare integers for return variables
Dim iNumNodes As Integer
Dim iNumStages As Integer
Dim sFilePath As String                 'declare a string for the file path

Dim i, j As Integer

Dim i1 As Double
Dim i2 As Integer
Dim delevation As Double
Dim ielevation As Integer

Set FrewObj = CreateObject("frew.FrewCom")      'Set FrewObj as FrewCom interface and link
sFilePath = "C:\Program Files (x86)\Oasys\Frew 19.3\Samples\FREWman.fwd"         'Set the relevant file path
FrewObj.Open sFilePath, iRet            'Call the function to open the file
FrewObj.GetNumNodes iNumNodes   'Call the function to get number of nodes
FrewObj.GetNumStages iNumStages 'Call the function to get number of stages
FrewObj.Analyse iNumStages, iRet

Cells(2, 2) = iNumNodes
Cells(3, 2) = iNumStages

For i = 0 To iNumNodes - 1
    Cells(5 + i, 2) = i + 1
    FrewObj.GetNodeLevel i, delevation, ielevation
    Cells(5 + i, 3) = delevation
    For j = 1 To iNumStages - 1
        FrewObj.GetNodeDisp i, j, i1, i2
        Cells(5 + i, 3 + j) = i1
    Next j

Next i

End Sub

This entry was posted in Geotechnical Software, programming, Tips & Tricks. Bookmark the permalink.