### Install specific version of RSPileScripting Source: https://www.rocscience.com/help/rspile/tutorials/tutorial-overview/19-getting-started-with-rspile-python-scripting Use this command to install a specific version of the library that matches your installed RSPile software version. ```bash pip install "RSPileScripting==3.031" ``` -------------------------------- ### Install additional Python libraries Source: https://www.rocscience.com/help/rspile/tutorials/tutorial-overview/19-getting-started-with-rspile-python-scripting Use this command in the RocScript WinPython Command Prompt to install external Python libraries. ```bash pip install [library name] ``` -------------------------------- ### Start RSPILE Modeler with startApplication Source: https://www.rocscience.com/help/rspile/documentation/scripting/scripting-tools Initiates the RSPile application and connects a server on the specified port, bypassing manual dialog configuration. ```python # Start RSPILE Modeler RSPILEModeler.startApplication(port=60044) ``` -------------------------------- ### Install RSPileScripting library via pip Source: https://www.rocscience.com/help/rspile/tutorials/tutorial-overview/19-getting-started-with-rspile-python-scripting Use this command in the VSCode terminal to install the latest version of the RSPile Python API library. ```bash pip install RSPileScripting ``` -------------------------------- ### Install required libraries with pip Source: https://www.rocscience.com/help/rspile/tutorials/tutorial-overview/20-lateral-pile-analysis-optimization Installs the required Python libraries (including the RSPile API, Pandas, and Matplotlib) from the requirements.txt file. This is only needed for advanced users running the script in their own Python environment; the RocScript Editor already includes these libraries. ```text Pip install -r requirements.txt ``` -------------------------------- ### List installed Python libraries Source: https://www.rocscience.com/help/rspile/tutorials/tutorial-overview/19-getting-started-with-rspile-python-scripting Use this command in the RocScript WinPython Command Prompt to verify currently installed libraries, including the RSPile Python API, Pandas, and Matplotlib. ```bash pip list ``` -------------------------------- ### Get First Pile Type Source: https://www.rocscience.com/help/rspile/tutorials/tutorial-overview/20-lateral-pile-analysis-optimization Obtains the first pile type from the model. ```python pile_type_1 = model.getPileTypes()[0] ``` -------------------------------- ### Get First Pile Section Source: https://www.rocscience.com/help/rspile/tutorials/tutorial-overview/20-lateral-pile-analysis-optimization Obtains the first pile section from the model. ```python pile_section_1 = model.getPileSections()[0] ``` -------------------------------- ### Set Up Directories Source: https://www.rocscience.com/help/rspile/tutorials/tutorial-overview/20-lateral-pile-analysis-optimization Defines the current directory and creates an output directory to store results. ```python current_dir = os.path.dirname(os.path.abspath(__file__)) output_dir = rf"{current_dir}\results" os.makedirs(output_dir, exist_ok=True) ``` -------------------------------- ### Load the Tutorial Model Source: https://www.rocscience.com/help/rspile/tutorials/tutorial-overview/20-lateral-pile-analysis-optimization Opens the initial RSPile model, saves it to the output directory, closes it, and reopens the saved file for further modifications. ```python model = rspile_modeler.openFile(rf"{current_dir}\Lateral Pile Analysis Optimization (Initial).rspile2") model.save(rf"{output_dir}\Lateral Pile Analysis Optimization (Final).rspile2") model.close() model = rspile_modeler.openFile(rf"{output_dir}\Lateral Pile Analysis Optimization (Final).rspile2") ``` -------------------------------- ### Optimization Loop for Pile Diameter Deflection Analysis Source: https://www.rocscience.com/help/rspile/tutorials/tutorial-overview/20-lateral-pile-analysis-optimization These steps form the optimization loop that iterates over pile diameters, computes deflections with and without rebar/casing, and stores results. The loop uses the RSPile API to set the pile section, add/remove reinforcement patterns, toggle casing, save and compute the model, and retrieve the maximum X-displacement. The loop increments the pile diameter until it reaches the maximum diameter. ```python # Initialize variables allowable_deflection = 0.01 m_to_mm = 1000 pile_diameter = 0.6 pile_diameter_increment = 0.2 max_diameter = 1.6 number_of_bars = 5 cover_depth_to_diameter_ratio = 1/5*m_to_mm diameters = [] without_rebar = [] with_rebar = [] ``` ```python while pile_diameter < max_diameter: #set diameter pile_section_1.PileAnalysis.ReinforcedConcrete.CrossSection.Circular.setDiameter(pile_diameter) diameters.append(pile_diameter) ``` ```python for has_rebar, deflection_list in zip([True, False], [with_rebar, without_rebar]): if(has_rebar): pile_section_1.PileAnalysis.ReinforcedConcrete.CrossSection.ConcreteDesigner.Reinforcement.addReinforcementPattern("test pattern") pile_section_1.PileAnalysis.ReinforcedConcrete.CrossSection.ConcreteDesigner.Casing.setUseCasing(False) #setup reinforcement pattern reinforcement_pattern_1 = pile_section_1.PileAnalysis.ReinforcedConcrete.CrossSection.ConcreteDesigner.Reinforcement.getReinforcementPatterns()[0] reinforcement_pattern_1.Radial.setRebarLocationRefPoint(RebarReferencePointMethod.COVER_DEPTH) ``` ```python cover_depth = pile_diameter*cover_depth_to_diameter_ratio reinforcement_pattern_1.Radial.setCoverDepth(cover_depth) ``` ```python if (pile_diameter % 0.4 == 0): number_of_bars += 1 reinforcement_pattern_1.Radial.setNumberOfBars(number_of_bars) else: pile_section_1.PileAnalysis.ReinforcedConcrete.CrossSection.ConcreteDesigner.Casing.setUseCasing(True) pile_section_1.PileAnalysis.ReinforcedConcrete.CrossSection.ConcreteDesigner.Reinforcement.removeReinforcementPattern("test pattern") ``` ```python model.save() model.compute() ``` ```python modeling_results = model.getPileResultsTables() pile_name, displacement = modeling_results.getMaximumValue(GraphingOptions.DISPLACEMENT_X) deflection_list.append(displacement) ``` ```python pile_diameter += pile_diameter_increment ``` -------------------------------- ### Import Required Modules Source: https://www.rocscience.com/help/rspile/tutorials/tutorial-overview/20-lateral-pile-analysis-optimization Imports the required modules from the RSPile API Library and matplotlib. This is the first step in the script. ```python import matplotlib.pyplot as plt from RSPileScripting.RSPileModeler import RSPileModeler from RSPileScripting.enums import * import os ``` -------------------------------- ### Plot Deflection vs. Diameter Results Source: https://www.rocscience.com/help/rspile/tutorials/tutorial-overview/20-lateral-pile-analysis-optimization These plotting commands visualize the deflection results from the optimization loop. The first plot shows deflection vs. diameter for the case with rebar reinforcement, and the second for the case with 50mm casing. Both include the allowable deflection line (1% of pile diameter) and use matplotlib to display the figures. ```python # Plot for casing plt.figure(figsize=(8, 6)) plt.plot(diameters, with_rebar, marker='o', linestyle='-', label='With Rebar Reinforcement') #plot "allowable deflection" vs deflection plt.plot(diameters, [allowable_deflection * d * m_to_mm for d in diameters], 'r--', label='Allowable Deflection (1% of Pile Diameter)') plt.xlabel('Pile Diameter (m)') plt.ylabel('Deflection (mm)') plt.title('Deflection vs. Diameter (With Rebar Reinforcement)') plt.ylim(0, 17.5) plt.legend() plt.grid() plt.show() ``` ```python plt.figure(figsize=(8, 6)) plt.plot(diameters, without_rebar, marker='s', linestyle='-', label='With 50mm Casing') #plot "allowable deflection" vs deflection plt.plot(diameters, [allowable_deflection * d * m_to_mm for d in diameters], 'r--', label='Allowable Deflection (1% of Pile Diameter)') plt.xlabel('Pile Diameter (m)') plt.ylabel('Deflection (mm)') plt.title('Deflection vs. Diameter (With 50mm Casing)') plt.ylim(0, 25) plt.legend() plt.grid() plt.show() ``` -------------------------------- ### Define Soil Properties Source: https://www.rocscience.com/help/rspile/tutorials/tutorial-overview/20-lateral-pile-analysis-optimization Retrieves the soil properties from the model and assigns them to variables. The soil names are then set to Sand, Clay, and Residual. ```python soil_properties = model.getSoilProperties() sand = soil_properties[0] clay = soil_properties[1] residual = soil_properties[2] Setting Soil Names sand.setName("Sand") clay.setName("Clay") residual.setName("Residual") ``` -------------------------------- ### Set Sand Properties Source: https://www.rocscience.com/help/rspile/tutorials/tutorial-overview/20-lateral-pile-analysis-optimization Sets the lateral properties for the Sand soil: API_SAND lateral type, friction angle of 30 degrees, and initial modulus of subgrade reaction of 5000. ```python sand.LateralProperties.setLateralType(LateralType.API_SAND) sand.LateralProperties.APISand.setFrictionAngle(30) sand.LateralProperties.APISand.setInitialModulusOfSubgradeReaction(5000) ``` -------------------------------- ### Set Clay Properties Source: https://www.rocscience.com/help/rspile/tutorials/tutorial-overview/20-lateral-pile-analysis-optimization Sets the lateral properties for the Clay soil: SOFT_CLAY lateral type, undrained shear strength of 50, and strain factor of 0.02. ```python clay.LateralProperties.setLateralType(LateralType.SOFT_CLAY) clay.LateralProperties.SoftClay.setUndrainedShearStrength(50) clay.LateralProperties.SoftClay.setStrainFactor(0.02) ``` -------------------------------- ### Set Pile Section Properties Source: https://www.rocscience.com/help/rspile/tutorials/tutorial-overview/20-lateral-pile-analysis-optimization Sets the pile section properties: reinforced concrete section type, circular cross-section, compressive strength of 32, and casing thickness of 50. ```python pile_section_1.PileAnalysis.setSectionType(SectionType.REINFORCED_CONCRETE) pile_section_1.PileAnalysis.ReinforcedConcrete.setCrossSectionType(ReinforcedConcreteCrossSectionType.CIRCULAR) pile_section_1.PileAnalysis.ReinforcedConcrete.setCompressiveStrength(32) pile_section_1.PileAnalysis.ReinforcedConcrete.CrossSection.ConcreteDesigner.Casing.setCasingThickness(50) ``` -------------------------------- ### Define Pile Type Source: https://www.rocscience.com/help/rspile/tutorials/tutorial-overview/20-lateral-pile-analysis-optimization Sets Pile Type 1 to be composed of a single 20m segment of Pile Section 1. The pile head is set to 1m above ground surface. ```python pile_type_1.PileAnalysis.Sections.setPileSegmentsByLength(1, [[pile_section_1.getName(), 20]]) ``` -------------------------------- ### Set Residual Soil Properties Source: https://www.rocscience.com/help/rspile/tutorials/tutorial-overview/20-lateral-pile-analysis-optimization Sets the lateral properties for the Residual Soil: PIEDMONT_RESIDUAL_SOILS lateral type, SPT blow count analysis type, and a standard penetration blow count of 100. ```python residual.LateralProperties.setLateralType(LateralType.PIEDMONT_RESIDUAL_SOILS) residual.LateralProperties.PiedmontResidual.setPiedmontAnalysisType(PiedmontTestValueType.SPT_BLOW_COUNT) residual.LateralProperties.PiedmontResidual.setStandardPenetrationBlowCount(100) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.