Currently it is not possible to directly plot the active load qactive in a curve to generate load-displacement curves 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..
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 setup 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:
- qactive , equation to determine qactive:
qactive = qphase_start + ΣMstage * ( qphase_end - qphase_start) - displacements (specified node)
The steps to achieve in generating a load-displacement curve can be summarize in the following points:
- create a function that will retrieve the load value
- create a function that will retrieve the results required for the equation to determine qactive and for the load-displacement curve and add them in tables
- create a file that will store these information by means of a text file
- make a quick plot (using matplotlib package)
- call the function that will execute all above operations
Note in this code example we will use Tutorial Lesson 1 Case B: Flexible footing's case to illustrate the behaviour.
Retrieve load value
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 scriptdefgetphasevalue (plxobject, phase): return plxobject[phase]
Required results for equation and curve
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:
- step number
- phase name
- ΣMstage value
- displacement of node A (total): |u|
- qactive-value
# 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 phaseimport math defcreate_phases_name_map(phases): result = {} for phase in phases[:]: result[phase.Name.value] = phase return result defget_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.Info.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)
---------------------------------------------------------------------------------
Text file with required information
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 isnotNone: withopen(filename,"w") asfile: for results inzip(col_phases, col_step, col_utot, col_qactive, col_load): print('\t'.join(["{}".format(i) for i in results]), file=file)
Run the function
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:\data\load_displ_data.txt', phases_i = [ g_i.Phase_1 ] )
Note that in order to use mathematical functions and constants (e.g. math.pi) a specific module needs to be imported. To import the math module, the following line is included at the beginning of the script:
import math
The assumptions made in the script are that the project should have the following:
- all steps are stored during calculation to retrieve the results for each step
- a pre-selected node to check the displacements is selected
- a single vertical line load is applied
Example
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
Quick plot for Load-Displacement curve [matplotlib]
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 curveimport 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()