Application | PLAXIS 2D |
Version | PLAXIS 2D 2018 |
Date created | 03 March 2016 |
Date modified | 03 March 2016 |
In the PLAXIS Output program, the active load value can be used to generate a load-displacement curve for a load-controlled analysis. See the related article How to get a load - displacement curve using SumMstage
In this article, we will show how to use the HTTP REST API / Remote Scripting feature in order to retrieve the necessary values and save them in a text file so that this data can be used in any spreadsheet software to generate a load-displacement curve. This will be done with the help of the ΣMstage - displacement curve.
First, we will need to make sure that the current running PLAXIS Input and PLAXIS Output program are accessible as Remote Scripting server. This can be achieved by activating the Remote scripting server via the Expert menu in both Input and Output programs.
See also: Using PLAXIS Remote scripting with the Python wrapper in order to correctly set up the reference to Plaxis Input (s_i, g_i) and Output (s_o, g_o) using the boilerplate code.
In order to construct the actual load-displacement curve the following quantities are needed for each step:
The steps to achieve in generating a load-displacement curve can be summarised in the following points:
Note in this code example we will use Tutorial Lesson 1 Case B: Flexible footing's case to illustrate the behaviour.
To begin with, we will need to retrieve the values for qphase_start and qphase_end for a specified phase, for which the load is active and applied. For this, the command that retrieves the load value for a specific phase can be used. For instance:
g_i.LineLoad_1_1.qy_start[g_i.Phase_1]
In order to make the defined script reusable in other conditions, we will write a function that takes the line load name and the phase name as an input, and returns the load object for that phase:
# creating the function that will retrieve # the values later in the script def getphasevalue (plxobject, phase): return plxobject[phase].value
In order to calculate the value of qactive we will need the ΣMstage values from the Output results. Next to that, the displacements of a pre-selected node (A) should be retrieved, too. In the following example, we will create a table with these columns:
# qphase_start is start load value in phase, equal to # the final load value in the preceding phase: the PreviousPhase # qphase_end is the defined final load value for this phase import math def create_phases_name_map(phases): result = {} for phase in phases[:]: result[phase.Name.value] = phase return result def get_table_qactive_vs_displacement(filename, phases_i): # initial data for eventual table columns col_step = ["Step"] col_sum_mstage = ["SumMStage"] col_phases = ["Phase"] col_utot = ["Utot"] col_qactive = ["qactive [kN/m2]"] col_load = ["Load [kN]"] # load for axisymmetric models radius = 1 area = math.pi * radius**2 phasesmap_o = create_phases_name_map(g_o.Phases) # look into all phases, all steps: loadfeature_i = g_i.LineLoad_1_1 for phase_i in phases_i: qphase_end = getphasevalue(loadfeature_i.qy_start, phase_i) # check if previous phase has a Line Load # that is deactivated (then load=0) if loadfeature_i.Active[phase_i.PreviousPhase]: qphase_start = loadfeature_i.qy_start[phase_i.PreviousPhase] else: qphase_start = 0 phase_o = phasesmap_o[phase_i.Name.value] for step in phase_o.Steps: sumMstage = step.Reached.SumMstage.value col_phases.append(phase_o.Name.value) col_step.append(int(step.Name.value.replace("Step_", ""))) col_utot.append(g_o.getcurveresults(g_o.Nodes[0], step, g_o.ResultTypes.Soil.Utot)) col_sum_mstage.append(sumMstage) col_qactive.append(-qphase_start + sumMstage * (-qphase_end + qphase_start)) col_load.append(col_qactive[-1] * area)
After retrieving the tables of the results, a filename will be created that will be saved as a normal text file (*.txt). The specified path should be given below:
if filename is not None: with open(filename,"w") as file: for results in zip(col_phases, col_step, col_utot, col_qactive, col_load): print('\t'.join(["{}".format(i) for i in results]), file=file)
Now we can make a call to this function in order to save a table with these results for Phase_1 to the text file.
get_table_qactive_vs_displacement(filename = r'C:\dataload_displ_data.txt', phases_i = [ g_i.Phase_1 ] )
The assumptions made in the script are that the project should have the following:
When executing this Python code on Tutorial Lesson 1 (Settlement of a circular footing on a sand - Case B: Flexible footing [link]) the described script will result in the following data table:
Figure 1. Text file generated for Lesson 1B
By opening the text file in spreadsheet program (e.g. Microsoft Excel) we can further process the data to generate the following curve:
Figure 2. Load - displacement curve from spreadsheet data
At the end of this example, the option to create a quick plot is provided using the matplotlib plotting library, which allows for a quick check of the Load-Displacement curve. This will appear in a separate window. Note that the following code should be used within the previous script, before the command which runs the function.
# Make a quick plot of the Load-Displacement curve import matplotlib.pyplot as plt plt.plot(col_utot[1:], col_load[1:] ) plt.xlabel('Displacements (m)') plt.ylabel('Load (kN)') plt.title('Load-Displacement curve') plt.grid(True) # plt.savefig("load_displ_curve.png") if filename: plt.savefig(filename.replace(".txt", ".png")) plt.show()
Figure 3. Example of a load - displacement curve generated by matplotlib's plt.show()
This script has been made for PLAXIS 2D 2018.00 using Python 3.4.x