Quantcast
Channel: PLAXIS - Knowledge Base - PLAXIS 2D
Viewing all articles
Browse latest Browse all 43

Output scripting example: create curve data

$
0
0
Application:

Since PLAXIS 2D 2015 and PLAXIS 3D AE, the Output program can also be accessed via REST Http / Remote Scripting in order to retrieve calculation result data via a scripting interface.

Retrieving curve data is one of the possible options for the data retrieval. In this example, we will retrieve the results and store these in a text file.

First, we will need to make sure that the current open PLAXIS Output program is accessible as Remote Scripting server. This can be achieved by activating the Remote scripting server via the Expert menu in the Output program.

Next, we will need to tell the Python script where it can access this Remote scripting server.
This can be done with e.g. this script code:

import imp

plaxis_path =r'C:\PLAXIS'#your PLAXIS installation path
found_module = imp.find_module('plxscripting', [plaxis_path])
plxscripting = imp.load_module('plxscripting', *found_module)
from plxscripting.easy import*

outputport = 10001
s_output,g_output=new_server('localhost', outputport)

Now we can retrieve the data. For this we will use the command getcurveresults(). Since this command will only return one result value, the script will need to access each step id of the desired phases.

In the example below, the Python script stores a table in a file, and it will store the following columns, using the phase order as specified in the parameter phaseorder:

  • phase name
  • step number
  • time
  • u_y for Node A ( g_output.Nodes[0] )
  • u_y for Node B ( g_output.Nodes[1] )

Note: You will need to store all steps during your calculation, otherwise it will not be possible to retrieve the time value for any of the unsaved steps.

defgettable_time_vs_uy(filename=None, phaseorder=None):
    #init data for lists
    stepids = [ ]
    uyAs = []
    uyBs = []
    times = []
    phasenames= []

    #look into all phases, all steps:for phase in phaseorder:
        for step in phase.Steps.value:
            phasenames.append( phase.Name.value )
            stepids.append( int(step.Name.value.replace("Step_","")) )
            uyAs.append( g_output.getcurveresults( g_output.Nodes[0],
                                                   step,
                                                   g_output.Soil.Uy)
                         )
            uyBs.append( g_output.getcurveresults( g_output.Nodes[1],
                                                   step,
                                                   g_output.Soil.Uy)
                         )
            #make sure step info on time is available, then add it:ifhasattr(g_output.Phases[-1].Steps.value[-1].Info,
                       'EstimatedEndTime'):
                times.append( step.Info.EstimatedEndTime.value )
            else:
                times.append( None )
            
    if filename:
        withopen(fname,"w") asfile:
            file.writelines( [ "{}\t{}\t{}\t{}\t{}\n".format( ph,nr,t,uyA,uyB )
                               for ph,nr,t,uyA,uyB inzip( phasenames,
                                                           stepids,
                                                           times,
                                                           uyAs,
                                                           uyBs )
                           ]
                         )

Now we can make a call to this function in order to save a text file with this data for phases Phase_1 and Phase_2:

gettable_time_vs_uy( filename=r'c:\data\project_curvedata.txt',
                     phaseorder = [ g_output.Phase_1, g_output.Phase_2 ] )

This data can then easily be used in spreadsheet programs to easily create charts or do other sorts of post processing.

Notes

  • To retrieve ΣMstage, use step.Info.SumMStage.value
  • To retrieve Force Fx, Fy or Fz (for 3D), use step.Info.ReachedForceX.value, step.Info.ReachedForceY.value or step.Info.ReachedForceZ.value respectively
  • Time value parameters are currently named as following:
    • In order to retrieve the end time for a phase or step, use phase.Info.EstimatedEndTime.value or step.Info.EstimatedEndTime.value respectively
    • When retrieving the total Dynamic time (in seconds), use phase.Info.ReachedTime.value or step.Info.ReachedTime.value

To get this data per step, use step. To get the phase final value, use phase.


Viewing all articles
Browse latest Browse all 43

Trending Articles