I want to get the q、ε、Pexcess after soil test ,but got the following error when the Python script ran.
code:
from plxscripting.easy import*s_t, g_t = new_server('localhost', 10001, password='19961217')def triaxial(cellpressure,E50,Eoed,Eur): g_t.Triaxial.CellPressure = cellpressure g_t.Material.E50ref = E50 g_t.Material.EoedRef =Eoed g_t.Material.EurRef = Eur g_t.calculate(g_t.Triaxial)triaxial(100, 5000, 5000,15000) q = g_t.Triaxial.Results.DeviatoricStressprint(q)print(type(q))
error:
Traceback (most recent call last): File "4.py", line 8, in <module> q = g_t.Triaxial.Results.DeviatoricStress[-1].value File "C:\ProgramData\Bentley\Geotechnical\PLAXIS Python Distribution\01.00\python\lib\site-packages\plxscripting\plxproxy.py", line 229, in __getattr__ "Requested attribute '{}' is not present".format(attr_name))AttributeError: Requested attribute 'DeviatoricStress' is not present>Exit code: 1
I would appreciate if anyone can help
thanks
Dear Jianshu,
The Soiltest results are stored inside the .Results per step, and then for each step we can retrieve all these values, meaning that if you would like to get a specific result, you would need to ask for this:
g_t.Triaxial.Results[step].DeviatoricStress.value
where we need to fill in the step number (integer) here. And to get all values, we can just loop look over all steps in the g_t.Triaxial.Results
To make it work for your case, you could adopt the Python script like this, and notice how to retrieve q, ε_1 and P_excess :
from plxscripting.easy import* port_soiltest = 10000 pasword = r'YOURPASSWORD' s_t, g_t = new_server('localhost', port, password=pw) def triaxial(cellpressure, E50, Eoed, Eur): """ runs a triaxial test and returns some basic results """ g_t.Triaxial.CellPressure = cellpressure g_t.Material.E50ref = E50 g_t.Material.EoedRef = Eoed g_t.Material.EurRef = Eur g_t.calculate(g_t.Triaxial) q = [i.DeviatoricStress.value for i in g_t.Triaxial.Results] eps_1 = [i.Eps1.value for i in g_t.Triaxial.Results] p_excess = [i.PExcess.value for i in g_t.Triaxial.Results] return q, eps_1, p_excess q, eps_1, p_excess = triaxial(100, 5000, 5000,15000)
After this, you could for instance use those lists with the results to generate a graph:
import matplotlib.pyplot as plt def plot_q_eps1(q, eps1): """ generate a basic graph """ fig, ax = plt.subplots() abs_eps = [i for i in eps1] ax.plot(abs_eps, q) ax.set(xlabel='$\epsilon_1$', ylabel='q (kPa)', title='Triaxial test result') """ compression is negative in PLAXIS, so inverse the axis for a nicer look """ ax.invert_xaxis() ax.grid() plt.show() plot_q_eps1(q, eps_1)
This would then generate this:
More details on automation was shown in one of our Coffee Corners: Optimizing Undrained Parameters for Undrained Soft Soils
Answer Verified By: jianshu liu
Dear Micha van der Sloot
Your answer perfectly solved my question! Thank you very much! :)
Sincerely!
Dear Micha Van Der Sloot,
Your answer was useful, thank you. However, I get this error when I write your code:
>C:\ProgramData\Seequent\PLAXIS Python Distribution V2\python\pythonw.exe -u "triaxial_undrained.py"Traceback (most recent call last): File "C:\ProgramData\Seequent\PLAXIS Python Distribution V2\python\lib\site-packages\plxscripting\plxproxy.py", line 179, in __getattr__ return self._getattr(attr_name) File "C:\ProgramData\Seequent\PLAXIS Python Distribution V2\python\lib\site-packages\plxscripting\plxproxy.py", line 116, in _getattr raise AttributeError("Requested attribute '{}' is not present".format(attr_name))AttributeError: Requested attribute 'Triaxial' is not present
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "triaxial_undrained.py", line 22, in <module> q, eps_1, p_excess = triaxial(100, 5000, 5000,15000) File "triaxial_undrained.py", line 10, in triaxial g_t.Triaxial.CellPressure = cellpressure File "C:\ProgramData\Seequent\PLAXIS Python Distribution V2\python\lib\site-packages\plxscripting\plxproxy.py", line 182, in __getattr__ return self._getattr(attr_name) File "C:\ProgramData\Seequent\PLAXIS Python Distribution V2\python\lib\site-packages\plxscripting\plxproxy.py", line 116, in _getattr raise AttributeError("Requested attribute '{}' is not present".format(attr_name))AttributeError: Requested attribute 'Triaxial' is not present>Exit code: 1