Output scripting example: create curve data

06 May 2015

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

Retrieving curve data is one of the possible options for 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.

For more information on how to do this follow the article about:
Using PLAXIS Remote scripting with the Python wrapper

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_o.Nodes[0] )
  • u_y for Node B ( g_o.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.

def gettable_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_o.getcurveresults(g_o.Nodes[0],
                                            step,
                                            g_o.ResultTypes.Soil.Uy))
            uyBs.append(g_o.getcurveresults(g_o.Nodes[1],
                                            step,
                                            g_o.ResultTypes.Soil.Uy))
            # make sure step info on time is available, then add it:
            timevalue = "-"
            if hasattr(step, 'Reached'):
                if hasattr(step.Reached, 'Time'):
                    timevalue = step.Reached.Time.value

            times.append(timevalue)

    if filename:
        with open(filename, "w") as file:
            file.writelines(["{}\t{}\t{}\t{}\t{}\n".format(ph, nr, t, uyA, uyB)
                             for ph, nr, t, uyA, uyB in zip(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_o.Phase_1, g_o.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.Reached.SumMstage.value
  • To retrieve Force Fx, Fy or Fz (for 3D), use step.Reached.ForceX.value, step.Reached.ForceY.value or step.Reached.ForceZ.value respectively
  • Time value parameters are named as following (see compatibility notes since 2D 2016):
    • time interval for last step [in project time unit], use phase.InputSettings.TimeInterval.value or step.InputSettings.TimeInterval.value, respectively
    • reached total end time of phase or step [in project time unit], use phase.Reached.Time.value or step.Reached.Time.value, respectively
    • reached total dynamic time in seconds [dynamics only], use phase.Reached.DynamicTime.value or step.Reached.DynamicTime.value, respectively
  • To get this data per step, use step. To get the phase final value, use phase.

Version

This Python script runs with PLAXIS 2D CONNECT Edition v20 using Python 3.7.x.
The script was originally written for PLAXIS 2D 2017.00 using Python 3.4.x.

Related posts

Privacy Preference Center

Necessary

The Cookies are necessary for the site to function

CONSENT, NID, _cfduid, wp-settings-time-16, wp-setting-16, wordpress_test_cookie, gdpr[allowed_cookies], gdpr[consent_types], wp_woocommerce_session, wordpress_logged_in, wordpress_sec, PHPSESSID

Advertising

These Cookies are used to provide you with useful information based on recent browser data

_gads
UserMatchHistory, lang, BizoID
IDE
fr
NID
lidc, bcookie

Analytics

These are used to track user interaction and detect potential problems. These help us improve our services by providing analytical data on how users use this site

_ga, _gid

Other