0% found this document useful (0 votes)
253 views18 pages

Automate Soil Profile in PLAXIS Using Python

Uploaded by

EDEN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
253 views18 pages

Automate Soil Profile in PLAXIS Using Python

Uploaded by

EDEN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
28125, 9227 PM ‘Automate Sol Protein PLAXIS Using Python | by Pip Tsang |TDS Archive | Medium This member-only story is on us. Upgrade to access all of Medium. + Member-only story PLAXIS AUTOMATION SERIES Automate Soil Profile in PLAXIS Using Python Step-by-step guide toward automation @ Philip Tsang » Follow CQO Padsisnecin TOs Archive 40 minread + Jan 4,2023 © tisten ("Share * More bitpssimecium comtowards-data-sciencelbullé-sol-profle-inplaxis-using-python-a8c8706283c7 15 218125, 9227 PM Automate Sol Protein PLAXIS Using Python | by Philip Tsang |TDS Archive | Medium ig —— Photo by Kevin Ku on Unspl As a Geotechnical Engineer, one of the most important PLAXIS workflows is to build soil profile and assign correct soil properties. Although the interface for soil input is user-friendly, this process can be time-consuming. There are potential rooms for improvement: 1. Create multiple boreholes in a single table. 2. Assign soil properties to each layer automatically. 3. Capability to use repeated soil properties. Of course this can also be achieved with PLAXIS built-in “matXdb” to store material database. However, Excel format allows more flexibility to change material properties as per project, as ‘well as having the possibility to link to another master spreadsheet. This tutorial aims to extend the lesson learnt from the 4th tutorial. We will further develop our Excel interface to define soil profile and assign soil properties in PLAXIS. bitpssimecium comtowards-data-sciencelbullé-sol-profle-inplaxis-using-python-a8c8706283c7 2128 218126, 827 PM ‘Automate Sol Protein PLAXIS Using Python | by Pip Tsang |TDS Archive | Medium 1, Read values from Excel using Pandas 2. Input soil depth with Excel and create soil profile 3, Input soil properties with Excel and assign material As before, this tutorial requires the readers have VS Code and PLAXIS environment installed. Follow the instructions from the article below if you're new to this page. Start Using Python to Automate PLAXIS Step-by-step guide toward automation [Link] ‘Also, we will also need pandas installed to the PLAXIS environment. Follow the instructions below to install external modules if you haven't done so. PLAXIS Output Visualisation Using Python Step-by-step guide toward automation [Link] Excel Input Interface Similar to the 4th tutorial, we want to create an Excel input template and create soil profile in PLAXIS. We will create an empty excel spreadsheet, call it “Soil_input”. The interface contains two worksheets: * OHE Ground Profile * Soil properties ntps:[Link]-data-scionce/bulé-slkprofle-n-plaxis-using-pythor-a8c8706253c7 3128 211825, 3:27 PM ‘Automate Soll Profle in PLAXIS Using Python [by Philip Tsang | TDS Archive | Medium OHEGround Profile | Soil properties | @) Screenshot from Excel by the author When you create the worksheets, ensure they follow the same names as shown above as the naming is case-sensitive. OHE Ground Profile The purpose of the “OHE Ground Profile” worksheet is to define the name and depth of soil units, These values will be used to create corresponding boreholes in PLAXIS. It involves four input values as shown below: 1. Name: specify the name of each borehole. This row will not be extracted in Python but it's a good tracker of which boreholes we are working on. For example, column B contains all the input values for “BHI”. 2. x coord: define the x coordinate of each borehole. 3. Top: define the y coordinate at the top of each borehole. In other words, the top R.L. in terms of geotechnical engineering. 4, Soil unit name & layer coordinates: starting from row 4, we will first define the name of soil unit name in column A. Then we input the bottom y coordinate of each unit under each borehole. It should be emphasised that this template is designed to input the bottom coordinate of each unit, Another important note is that we should input all the units across all the boreholes in column A. Similar to the logic of PLAXIS interface, if we encounter a unit which doesn't exist in a borehole, we put the same y coordinate as the previous unit. Take “BH1” as an example, we put 4 m for both “SSIV” and “SSIII”, which means “SSIII” doesn't exist in “BH1”. bitpssimecium comtowards-data-sciencelbullé-sol-profle-inplaxis-using-python-a8c8706283c7 4128 218126, 827 PM ‘Automate Sol Profle in PLAXIS Using Python | by Pip Tsang |TDS Archive | Medium A 8 @ ° E iiName BH HZ BSH 2. x coord 7 5 ° 4 3 Top 8 8 8 9 4 [sz 6 6 5 5 5 ssiv 4 4 3 3 6 |ssill 4 4 1 a 7 |ssi 2 2 ° ° 8 ssi ° a3 Ei =| 9 |ssiv 2 =| 2 =| ‘Screenshot from Excel by the author Soil properties The purpose of this worksheet is to define the soil properties of each unit. This contains the following columns: * Name * Material * Unit weight (kN/m3) * Young's Modulus, E’ (kPa) * Poisson ratio, v (nu) () * Cohesion, c’ (kPa) « Friction angle, phi (degree) « Tensile strength (kPa) « Interface strength () * KO auto?: T/F which determines if KO is calculated automatically in PLAXIS « KOx = Koy?: 1/F to determine if Kx is equivalent to Koy © KOx () + Koy 0) Screenshot from Excel by the author ntps:[Link]-data-scionce/bulé-slkprofle-n-plaxis-using-pythor-a8c8706253c7 artes, 927 PM ‘Automate So Protein PLANS Using Pthon |by Pip Teang [DS Archive | Medium These are typical material properties for Mohr-Coulomb model in PLAXIS 2D, just to ensure all input properties are in the correct unit. It should also be noted that this, template is only designed for Drained condition. Make sure you have created the excel spreadsheet with the worksheets and values as outlined above. Once the input file is created, we are ready to move to the next step. Step 1: Read Values from Excel Using Pandas The main goal of Step 1 is to set the soil contour and read the excel input template. First, we create an empty python file and call it “soil_geometry.py”. Import Modules and Start Server Similar to previous tutorial, we will start off by importing relevant modules and start server. from [Link] import * ‘import subprocess, time import pandas as pd ROHRUMHAERHA HORA RAMA RUM AA BORA AI A BA PLAXIS_PATH = r'C:\Program Files\Bentley\Geotechnical\PLAXIS 2D CONNECT Editior PORT_i = 10000 # Define a port number. PORT_o = 10001 PASSWORD = 'SxDBR0: InterfaceStrength = ‘Manual! -ntps:medlum,comfowards-data-scionce/bulé-slkprofle-n-plaxis-using-pythor-a8c8706253c7 1105 28125, 9227 PM ‘Automate Sol Protein PLAXIS Using Python | by Pip Tsang |TDS Archive | Medium Rinter=df_soilmat. iloc[i,9] else: InterfaceStrength = 'Rigid' + Last component of the soil properties is the K0 condition. We need to decide if the KO determination is “Manual” or “Automatic”. In PLAXIS-Python environment, “Automatic” and “Manual” are represented by 0 and 1 respectively. + We will also need to check if KOx = K0y based on user input. The checked and unchecked box of “KOx = Koy” are represented by True and False in Python respectively. if df_soilmat. ilocli,16] KoDetermination=1. if df_soilmat.ilocli,11] == 'T': KoPr-imaryTskoSecondary=True KoPrimary=df_soilmat.4loc[i,12] KoSecondary=df_soilmat.iloc[i,12] else: KoPrimaryIskoSecondary=False KoPrimary=df_soilmat. iloc[i,12] KaSecondary=df_soitmat.ilocli,13] else: KoDetermination=0 + Then, use PLAXIS command ‘setproperties()’ to set material properties, similar to the 4th tutorial. material = g_i.soilmat() [Link]( "Identification" name, "Soi Model" mater ialmodel, "gammaUnsat", gammaUnsat, "gammaSat", genmaSat, "Eref",Eref, "nu", nu, "cref", cref, “phi", phi, "TensileStrength", TensileStrength, "InterfaceStrengthDetermination" ,InterfaceStrength, "Rinter" Rinter, -ntps:medlum,comfowards-data-scionce/bulé-slkprofle-n-plaxis-using-pythor-a8c8706253c7 12128 2118125, 927 PM ‘Automate Soll Profle in PLAXIS Using Python | by Philip Tsang | TDS Archive | Medium "KoDetermination" ,KoDetermination, "KoPrimaryIsk0Secondary" ,KOPrimaryIsk@Secondary, "KoPrimary" ,KOPrimary, "KoSecondary" ,KeSecondary * After that, we store the soil material as objects to ‘soilmat’. soilmat=[mat for mat in g_i-Materials[:] if [Link] == 'SoilMat'] + Last step is to set material to the soil layer according to the “Name” column (i.e. column A) in the “OHE Ground Profile” worksheet. We will need to use if to check the material name provided in the table. If the name of the material matches the existing material object, assign that material to the soil layer using ‘[Link]()’. for j in range(df_soil.count() [@]-2) : for i in range(len(soilmat)) : if df_soil.iloc[j+2,0] == soilmat[i] Name: g_i.Soils[j].setmaterial(soilmat[i]) The final script is shown below: soilmatshee d¥_soilmat ‘Soil properties" pd.read_excel(file, sheet_name soilmatsheet, engin lopenpyx1") for i in range(df_soilmat.count()[0]): name = df_soilmat.iloc[i,1] if df_soilmat.ilocli,2] materialmodel=2 MMC: ganmaUnsat=df_soilmat. ilocli,3] ganmaSat=df_soilmat.ilocli,3] if_soilmat.iloc[ 4,4] f_soilmat. ilocli,5] -ntps:[Link]-data-scionce/bulé-slk profle-n-plaxis-using-pythor-a8c8706253c7 13128 2118125, 927 PM ‘Automate Soll Profle in PLAXIS Using Python | by Philip Tsang | TDS Archive | Medium cref=df_soilmat.ilocli,6] phi= df_soilmat.iloc[i,7] TensileStrength=df_soilmat.iloc[ 4,8] if df_soilmat.ilocli,9] >0: InterfaceStrength = ‘Manual’ Rinter-df_soilmat.iloc[i,9] else: InterfaceStrength = 'Rigid' if df_soilmat.ilocli,10] = KoDetermination=1. if df_soilmat.iloc[i,12] == 'T': KoPrimaryIskOSecondary=True KoPrimary=df_soilmat.ilocli,12] koSecondary=df_soilmat. ilocli, 12] else: KoPrimaryIskoSecondary=False KoPrimary=df_soilmat.iloc[i,12] KoSecondary=df_soilmat.ilocli, 13] else: KoDetermination=0 material = g_i.soilmat() [Link]( "Identification" ,name, "Soi Wodel" ,materialmodel, "gammaUnsat", gammaUnsat, "gammaSat", ganmaSat, "Eref" ref, "nu", nu, "cref", cref, "phi", phi, "TensileStrength" , TensileStrength, "InterfaceStrengthDetermination" ,InterfaceStrength, "Rinter" ,Rinter, "KoDetermination" ,KoDetermination, "KoPrimaryIsk0Secondary" ,KOPrimaryIsk@Secondary, "KoPrimary" ,KOPrimary, "KaSecondary" ,KoSecondary soilmat=[mat for mat in [Link][:] if [Link] == 'SoilMat'] for j in range(df_soil.count() [0]-2) : for i in range(len(soilmat) ): if df_soil. iloc[j+2,0] == soilmat[i] Name: g_i.Soils[j] .setmaterial (soilmat[4]) ntps:[Link]-data-scionce/bulé-slkprofle-n-plaxis-using-pythor-a8c8706253c7 14125 218125, 9227 PM Automate Sol Protein PLAXIS Using Python | by Philip Tsang |TDS Archive | Medium Screenshot from VS Code by the author Run the script with the following. (PLAXIS) C:\Users\phtsang\Desktop\PLAXIS_V22\Python_autonation>python soil_geom You should see the following is created in PLAXIS 2D. As you see from the soil windows, all boreholes have been created according the inputs from Excel. bitpssimecium comtowards-data-sciencelbullé-sol-profle-inplaxis-using-python-a8c8706283c7 15125 28125, 9227 PM Automate Sol Protein PLAXIS Using Python | by Philip Tsang |TDS Archive | Medium Screenshot from PLAXIS by the author Screenshot from PLAXIS by the author In terms of soil properties, all soil units have been created with the properties we specified in the input table. hitpsiimadium comtowarde-data-sclence/bullé-sol profes plaxis-using-pytnon-a8c870025367 16125 218126, 827 PM ‘Automate Sol Profle in PLAXIS Using Python | by Philip Tsang |TDS Archive | Medium Brilliant! We have just created a soil profile with material definition using a user interface for PLAXIS 2D. Conclusion That's all for the fifth tutorial on creating soil profile including material definitions using Python. After this tutorial, you should be able to obtain soil input from excel and create profile, as well as assign soil properties in PLAXIS. If you enjoy reading this type of content, feel free to follow my page. I will keep posting this series of tutorials on automating PLAXIS with Python. Apart from that, Tm also keen to share knowledge on how to use Python to automate workflow in engineering. Join Medium with my referral link - Philip Tsang Read every story from Philip Tsang (and thousands of other writers on Medium). Your membership fee directly supports... [Link] Python Python Programming Geotechnical Engineering ntps:[Link]-data-scionce/bulé-slkprofle-n-plaxis-using-pythor-a8c8706253c7 7128 218126, 827 PM ‘Automate Sol Protein PLAXIS Using Python | by Pip Tsang |TDS Archive | Medium @) Published in TDS Archive 804K Followers - Last published Feb 3, 2025 Anarchive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication. te Goer) Written by Philip Tsang 568 Followers - 889 Following 600K+ Impressions on Linkedin Automating PLAXIS with Python Engineering workflow automation with Python® No responses yet 9 More from Philip Tsang and TDS Archive ntps:[Link]-data-scionce/bulé-slkprofle-n-plaxis-using-pythor-a8c8706253c7 18125

You might also like