import subprocess ## 0. setting constants plx_input_path = r"C:\Program Files\Seequent\PLAXIS 2D\Plaxis2DXInput.exe" plx_input_port = 10000 plx_password = r'YOUR_PASSWORD' ## 1. launch PLAXIS Input; note the port and password plx_process = subprocess.Popen([plx_input_path, "--AppServerPort={}".format(plx_input_port), "--AppServerPassword={}".format(plx_password)]) ## 2. Boilerplate for PLAXIS Input program from plxscripting.easy import * s_i, g_i = new_server('localhost', plx_input_port, password=plx_password) ## 3. Start new project # In this example we begin with a new project s_i.new() # When loading an existing PLAXIS project, use the following syntax # s_i.open(r'D:\PLAXIS_examples\Dry excavation using a tie back wall.p2dx') # Project properties g_i.SoilContour.initializerectangular(0, 0, 5, 4) g_i.setproperties("Title", "Settlement of a circular footing on sand", "ModelType", "Axisymmetry") # Soil mode g_i.gotosoil() # Borehole information borehole_g = g_i.borehole(0) g_i.soillayer(0) g_i.Soillayer_1.Zones[0].Top = 4 borehole_g.Head = 2 # or borehole_g.Head.set(2) sand = g_i.soilmat("Identification", "Sand", "SoilModel", "Mohr-Coulomb", "Colour", 15262369, "gammaSat", 20, "gammaUnsat", 17, "nu", 0.3, "Eref", 13000, "cRef", 1, "phi", 30) g_i.Soillayer_1.Soil.Material = sand # or g_i.set(g_i.BoreholePolygon_1.Soil.Material, sand) # Structures mode g_i.gotostructures() # Footing linedisplacement_g = g_i.linedispl((0, 4), (1, 4))[-1] linedisplacement_g.uy_start = -0.05 linedisplacement_g.Displacement_x = "Fixed" # Mesh mode g_i.gotomesh() g_i.mesh(0.06) # Staged construction definition g_i.gotostages() phase0_s = g_i.InitialPhase # the phase_0_s variable stores the phase object for InitialPhase in Staged construction mode # Phase_1 phase1_s = g_i.phase(phase0_s) g_i.setcurrentphase(phase1_s) phase1_s.Identification = "Footing - Indentation" g_i.activate(g_i.Lines[-1].LineDisplacement, phase1_s) # Calculation g_i.calculate() ## 4. Launch PLAXIS Output project output_port = g_i.view(phase1_s) # or g_i.view(g_i.Phases[-1]) s_o, g_o = new_server('localhost', output_port, password=plx_password) ## 5. commands in PLAXIS Output program phase1_o = g_o.Phases[-1] value_o = g_o.getsingleresult(phase1_o, g_o.ResultTypes.Soil.Utot, 0, 4) print(f'Total displacement at the footing is: {value_o} m') ## 6. Close PLAXIS Output program g_o.close() # s_o.close() # to close current session and s_o.open(r'D:\Plaxis_examples\Dry excavation using a tie back wall.p2dx') to open another project ## 7. Close current session in PLAXIS Input program s_i.close() ## 8. Terminate the PLAXIS application plx_process.terminate()