### Install eurocodepy using pip or uv Source: https://context7.com/pcachim/eurocodepy/llms.txt Installs the eurocodepy library using either pip or uv package managers. This is the first step to using the library for structural design calculations. ```bash pip install eurocodepy ``` ```bash uv add eurocodepy ``` -------------------------------- ### Python File Naming Convention Source: https://github.com/pcachim/eurocodepy/blob/master/mkdocs/docs/STYLE_GUIDE.md Provides examples of Python file naming conventions, which should use snake_case. ```text main_script.py user_profile.py ``` -------------------------------- ### Python Naming Conventions for Variables and Functions Source: https://github.com/pcachim/eurocodepy/blob/master/mkdocs/docs/STYLE_GUIDE.md Illustrates Python naming conventions for variables and functions, emphasizing descriptive names and the use of snake_case for both. ```python number_of_items = 5 total_price = 10.50 def calculate_total_price(quantity, price): return quantity * price ``` -------------------------------- ### Python Code Formatting and Comments Source: https://github.com/pcachim/eurocodepy/blob/master/mkdocs/docs/STYLE_GUIDE.md Demonstrates Python code formatting rules including indentation, inline comments, and separating logical sections with blank lines. Also shows the correct usage of inline and multi-line comments. ```python if x > 0: print('x is positive') else: print('x is non-positive') # This is an inline comment. def function_name(parameter): # Code inside function. # Add the value to the list. my_list.append(value) """ This function takes two parameters: - name: a string representing the name of the user - age: an integer representing the age of the user It returns a greeting message. """ def greet(name, age): # ... ``` -------------------------------- ### Python Naming Convention for Classes Source: https://github.com/pcachim/eurocodepy/blob/master/mkdocs/docs/STYLE_GUIDE.md Shows the Python naming convention for classes, which is to use PascalCase. ```python class User: # ... ``` -------------------------------- ### Python Miscellaneous Style Rules Source: https://github.com/pcachim/eurocodepy/blob/master/mkdocs/docs/STYLE_GUIDE.md Demonstrates miscellaneous Python style rules including string quoting, tuple packing/unpacking, comparison with None, and default function argument values. ```python message = "Hello, world!" print(message) a, b, c = (1, 2, 3) if x is None: # ... def my_function(arg1, arg2=None): # ... def my_other_function(arg1, arg2=[]): # This is bad. def my_good_function(arg1, arg2=None): if arg2 is None: arg2 = [] # ... ``` -------------------------------- ### Python Variable Naming Conventions (snake_case) Source: https://github.com/pcachim/eurocodepy/blob/master/STYLE_GUIDE.md Illustrates the use of descriptive, snake_case naming for Python variables, ensuring clarity and adherence to project standards. ```python number_of_items = 5 total_price = 10.50 ``` -------------------------------- ### Python Function Naming Conventions (snake_case) Source: https://github.com/pcachim/eurocodepy/blob/master/STYLE_GUIDE.md Shows the convention of using descriptive, snake_case names for Python functions, promoting readability and maintainability. ```python def calculate_total_price(quantity, price): return quantity * price ``` -------------------------------- ### Add Loads and Generate Combinations (Python) Source: https://context7.com/pcachim/eurocodepy/llms.txt Demonstrates how to add wind and snow loads to a 'loads' object and then generate ultimate limit state (ULS) and serviceability limit state (SLS) load combinations. This is useful for preliminary structural design checks. ```python from eurocodepy.loads import Load, LoadType # Assuming 'loads' is an initialized object # loads = ... # Add wind load loads.add(Load( name="W", load_type=LoadType.WIND, gamma_fav=0.0, gamma_unf=1.5, psi0=0.6, psi1=0.2, psi2=0.0 )) # Add snow load loads.add(Load( name="S", load_type=LoadType.SNOW, gamma_fav=0.0, gamma_unf=1.5, psi0=0.5, psi1=0.2, psi2=0.0 )) # Generate ULS combinations uls_combos = loads.get_ULS_combos() print("ULS Load Combinations:") for name, combo in list(uls_combos.items())[:3]: print(f" {combo.name}") for load_name, (load, factor) in combo.factors.items(): print(f" {load_name}: {factor}") # Generate SLS combinations sls_combos = loads.get_SLS_combos() print("\nSLS Load Combinations:") for name, combo in list(sls_combos.items())[:2]: print(f" {combo.name} ({combo.type})") for load_name, (load, factor) in combo.factors.items(): print(f" {load_name}: {factor}") ``` -------------------------------- ### Timber Material and Factor Calculations in Python Source: https://github.com/pcachim/eurocodepy/blob/master/mkdocs/docs/modules/ec5.md Demonstrates creating timber material objects (SolidTimber, Glulam) and accessing their properties like characteristic bending strength (fmk) and mean modulus of elasticity (E0mean). It also shows how to calculate modification factors (kmod) based on service class and load duration. ```python from eurocodepy.ec5.materials import Timber, SolidTimber, Glulam, ServiceClass, LoadDuration # Create a solid timber object (e.g., C24) timber = SolidTimber('C24') # Access characteristic bending strength fmk = timber.fmk # Get kmod for Service Class 1 and Medium load duration kmod = timber.k_mod(service_class=ServiceClass.SC1, load_duratiom=LoadDuration.Medium) # Create a glulam object (e.g., GL24h) glulam = Glulam('GL24h') E0mean = glulam.E0mean ``` -------------------------------- ### Access Concrete Material Properties (EC2) in Python Source: https://context7.com/pcachim/eurocodepy/llms.txt Demonstrates how to access concrete material properties according to Eurocode 2 using the eurocodepy library. It shows how to create concrete instances from standard grades or custom strengths and retrieve characteristic and design values for strength, modulus of elasticity, and strain parameters. ```python import eurocodepy as ec # Create concrete instance from standard grade concrete = ec.Concrete("C30/37") # Access properties print(f"Characteristic compressive strength: {concrete.fck} MPa") # 30 MPa print(f"Mean compressive strength: {concrete.fcm} MPa") # 38 MPa print(f"Mean tensile strength: {concrete.fctm} MPa") # 2.9 MPa print(f"Modulus of elasticity: {concrete.Ecm} MPa") # 32000 MPa print(f"Design compressive strength: {concrete.fcd} MPa") # 20.0 MPa print(f"Ultimate strain: {concrete.eps_cu2}") # 3.5 # Create concrete from characteristic strength concrete_custom = ec.Concrete.from_fck(35, name="C35_custom") print(f"Custom concrete fck: {concrete_custom.fck} MPa") # Available grades: C20/25, C25/30, C30/37, C35/45, C40/50, C45/55, # C50/60, C55/67, C60/75, C70/85, C80/95, C90/105 ``` -------------------------------- ### Access Steel Material Properties (EC3) in Python Source: https://context7.com/pcachim/eurocodepy/llms.txt Demonstrates how to access structural steel material properties according to Eurocode 3 using eurocodepy. It includes retrieving characteristic and design yield and ultimate strengths, modulus of elasticity, and partial safety factors for different steel grades. ```python import eurocodepy as ec # Create steel instance steel = ec.Steel("S355") # Access properties print(f"Characteristic yield strength: {steel.fyk} MPa") # 355 MPa print(f"Characteristic ultimate strength: {steel.fuk} MPa") # 470 MPa print(f"Design yield strength: {steel.fyd} MPa") # 355.0 MPa print(f"Modulus of elasticity: {steel.Es} MPa") # 210000 MPa print(f"Partial safety factor gamma_M0: {steel.gamma_M0}") # 1.0 print(f"Partial safety factor gamma_M1: {steel.gamma_M1}") # 1.0 print(f"Partial safety factor gamma_M2: {steel.gamma_M2}") # 1.25 # Available grades: S235, S275, S355, S460 ``` -------------------------------- ### Calculate Concrete Strength Development Over Time (Python) Source: https://context7.com/pcachim/eurocodepy/llms.txt Calculates the strength and modulus coefficients of concrete over a specified period using EurocodePy's beta functions. Assumes normal hardening cement. ```python t = 7 # days beta_c = beta_cc(t, s=0.25) # s=0.25 for normal hardening cement print(f"Strength coefficient at {t} days: {beta_c:.3f}") beta_e = beta_ce(t, s=0.25) print(f"Modulus coefficient at {t} days: {beta_e:.3f}") ``` -------------------------------- ### Access Eurocode Database for Material Properties (Python) Source: https://context7.com/pcachim/eurocodepy/llms.txt Demonstrates accessing EurocodePy's built-in database for concrete grades, steel profiles, bolt properties, and timber grades. Supports both dictionary and attribute-style access. ```python import eurocodepy as ec from eurocodepy import dbase # Dictionary access concrete_c30 = dbase.ConcreteGrades["C30_37"] print(f"C30/37 fck: {concrete_c30['fck']} MPa") print(f"C30/37 Ecm: {concrete_c30['Ecm']} MPa") # List available concrete grades print(f"Available concrete grades: {list(dbase.ConcreteGrades.keys())}") # Access steel profiles print(f"Available I-profiles: {len(dbase.SteelIProfiles)} sections") # Access bolt grades and diameters print(f"Bolt grades: {list(dbase.BoltGrades.keys())}") print(f"Bolt diameters: {list(dbase.BoltDiameters.keys())}") # Access timber grades print(f"Timber grades: {list(dbase.TimberGrades.keys())[:10]}...") # Attribute-style access using dbobj steel_params = dbase.dbobj.Materials.Steel.Parameters print(f"Steel gamma_M0: {steel_params.gamma_M0}") ``` -------------------------------- ### Access Steel I-Section Profiles (EC3) Properties in Python Source: https://context7.com/pcachim/eurocodepy/llms.txt Illustrates how to access geometric and mechanical properties of standard European steel I-section profiles (IPE, HEA, HEB, HEM) using eurocodepy for EC3 design. It shows how to retrieve section dimensions, area, section moduli, moment of inertia, and design resistances. ```python import eurocodepy as ec from eurocodepy.ec3.materials import ProfilesI, ProfilesI as profiles # Access IPE300 profile ipe300 = ProfilesI["IPE300"] # Geometric properties print(f"Section: {ipe300.Section}") # IPE300 print(f"Height: {ipe300.h} mm") # 300.0 mm print(f"Width: {ipe300.b} mm") # 150.0 mm print(f"Web thickness: {ipe300.tw} mm") # 7.1 mm print(f"Flange thickness: {ipe300.tf} mm") # 10.7 mm print(f"Cross-sectional area: {ipe300.A} cm2") # Section moduli print(f"Elastic section modulus y: {ipe300.Wel_y} cm3") print(f"Plastic section modulus y: {ipe300.Wpl_y} cm3") print(f"Moment of inertia Iy: {ipe300.Iy} cm4") # Design resistances (for S235) print(f"Plastic axial resistance: {ipe300.Npl_Rd} kN") print(f"Plastic moment resistance y: {ipe300.Mpl_Rd_y} kNm") print(f"Plastic shear resistance z: {ipe300.Vpl_Rd_z} kN") ``` -------------------------------- ### Calculate Rectangular Section Properties and Square Root of Sum of Squares (Python) Source: https://github.com/pcachim/eurocodepy/blob/master/mkdocs/docs/modules/utils.md Demonstrates how to use `calc_section_rectangular` to compute properties like area and moment of inertia for a rectangular section, and `sqrt_sum_of_squares` to find the square root of the sum of squares for a list of values. Requires the eurocodepy package. ```python from eurocodepy.utils import calc_section_rectangular, sqrt_sum_of_squares # Calculate properties of a rectangular section b = 300 # mm h = 500 # mm section = calc_section_rectangular(b, h) print("Area:", section['area']) print("Moment of inertia:", section['Iy']) # Calculate the square root of the sum of squares of a list values = [3, 4, 12] result = sqrt_sum_of_squares(values) print("sqrt(sum of squares):", result) ``` -------------------------------- ### Eurocode 1 - Actions on Structures Source: https://github.com/pcachim/eurocodepy/blob/master/reference.md Documentation for Eurocode 1, covering snow and wind actions on structures. ```APIDOC ## Eurocode 1 - Actions on Structures ### Description Provides functions and modules for calculating actions on structures according to Eurocode 1, including snow and wind loads. ### Modules - `eurocodepy.ec1.snow`: Functions related to snow load calculations. - `eurocodepy.ec1.wind.pressure`: Functions related to wind pressure calculations, including coefficients like `c_o`. ``` -------------------------------- ### Access Steel Reinforcement Properties (EC2) in Python Source: https://context7.com/pcachim/eurocodepy/llms.txt Shows how to retrieve steel reinforcement properties for concrete design (EC2) using eurocodepy. It covers accessing characteristic and design yield strength, tensile strength, modulus of elasticity, ultimate strain, and ductility class for various steel grades. ```python import eurocodepy as ec # Create reinforcement instance steel = ec.Reinforcement("B500B") # Access properties print(f"Characteristic yield strength: {steel.fyk} MPa") # 500 MPa print(f"Tensile strength: {steel.ftk} MPa") # 540 MPa print(f"Modulus of elasticity: {steel.Es} MPa") # 200000 MPa print(f"Ultimate strain: {steel.epsilon_uk} %") # 5.0% print(f"Ductility class: {steel.ClassType}") # 'B' print(f"Design yield strength: {steel.fyd} MPa") # 434.8 MPa # Available grades: B400A, B400B, B400C, B500A, B500B, B500C, B600A, B600B, B600C, B700A, B700B, B700C ``` -------------------------------- ### Calculate Active Earth Pressure and Soil Bearing Capacity with ec7 Source: https://github.com/pcachim/eurocodepy/blob/master/mkdocs/docs/modules/ec7.md Demonstrates the typical usage of the `ec7` module for performing active earth pressure calculations and soil bearing capacity analysis. It shows how to instantiate calculators, set input parameters (soil properties, geometry, loads), and retrieve results. This module relies on Eurocode 7 (EN 1997) standards for its calculations. ```python from eurocodepy.ec7 import pressure_coefficients, bearing_resistance # Example for Active Earth Pressure active_pressure_calculator = ActiveEarthPressure() active_pressure_calculator.set_soil_properties(...) active_pressure_calculator.set_wall_geometry(...) active_pressure_calculator.set_external_loads(...) active_pressure_calculator.calculate_active_pressure() results = active_pressure_calculator.get_results() # Example for Soil Bearing Capacity bearing_capacity_calculator = SoilBearingCapacity() bearing_capacity_calculator.set_soil_properties(...) bearing_capacity_calculator.set_foundation_geometry(...) bearing_capacity_calculator.set_loadings(...) bearing_capacity_calculator.calculate_bearing_capacity() results = bearing_capacity_calculator.get_results() ``` -------------------------------- ### Calculate Wind, Snow, and Imposed Loads using ec1 Module Source: https://github.com/pcachim/eurocodepy/blob/master/mkdocs/docs/modules/ec1.md Demonstrates how to use the `ec1` module to calculate wind, snow, and imposed loads. Requires importing specific functions from `eurocodepy.ec1`. Inputs include parameters like height, exposure, location, altitude, category, and area. ```python from eurocodepy.ec1 import wind_load, snow_load, imposed_load # Calculate wind load wind = wind_load(height=15, exposure='B', location='coastal') # Calculate snow load snow = snow_load(altitude=500, location='mountain') # Calculate imposed load for office imposed = imposed_load(category='B', area=50) ``` -------------------------------- ### Load Combinations Generation (EC0/EC1) Source: https://context7.com/pcachim/eurocodepy/llms.txt Generate ULS and SLS load combinations according to Eurocode 0/1. This involves creating a LoadCollection and adding individual Loads with their respective types, favorable/unfavorable factors, and combination coefficients (psi values). ```python import eurocodepy as ec from eurocodepy.ec1 import Load, LoadType, LoadCollection, CombinationType # Create load collection loads = LoadCollection() # Add permanent load loads.add(Load( name="G", load_type=LoadType.PERMANENT, gamma_fav=1.0, # Favorable factor gamma_unf=1.35, # Unfavorable factor psi0=1.0, psi1=1.0, psi2=1.0 )) # Add live load (office building) loads.add(Load( name="Q", load_type=LoadType.LIVE, gamma_fav=0.0, gamma_unf=1.5, psi0=0.7, psi1=0.5, psi2=0.3 )) ``` -------------------------------- ### Eurocode 5 - Design of Timber Structures Source: https://github.com/pcachim/eurocodepy/blob/master/reference.md Documentation for Eurocode 5, covering the design of timber structures. ```APIDOC ## Eurocode 5 - Design of Timber Structures ### Description Provides functions and modules for the design of timber structures according to Eurocode 5. This includes calculations for serviceability limit states such as deformation and vibration. ### Modules - `eurocodepy.ec5`: General modules for Eurocode 5. - `eurocodepy.ec5.sls`: Modules related to serviceability limit states. - `eurocodepy.ec5.sls.deformation`: Functions for calculating deformations. - `eurocodepy.ec5.sls.vibration`: Functions for calculating vibrations. ``` -------------------------------- ### Calculate Wind Pressure (EC1, Python) Source: https://context7.com/pcachim/eurocodepy/llms.txt Computes wind pressures based on Eurocode 1 principles. It calculates various factors including basic wind velocity, roughness factor, orography factor, mean wind velocity, turbulence intensity, and peak velocity pressure. ```python from eurocodepy.ec1.wind.pressure import ( v_b, c_r, c_o, v_m, v_p, q_p, I_v ) # Input parameters vb_0 = 27.0 # Fundamental basic wind velocity (m/s) z = 25.0 # Height above ground (m) z_0 = 0.05 # Roughness length (terrain category II) z_min = 2.0 # Minimum height z_0II = 0.05 # Reference roughness length (category II) # Calculate basic wind velocity vb = v_b(vb_0, c_season=1.0, c_dir=1.0) print(f"Basic wind velocity vb: {vb} m/s") # Calculate roughness factor cr = c_r(z, z_min, z_0, z_0II) print(f"Roughness factor cr(z): {cr:.3f}") # Calculate orography factor (flat terrain) co = c_o(z, x=0, H=0, Lu=10, Ld=1000) print(f"Orography factor co(z): {co:.3f}") # Calculate mean wind velocity vm = v_m(z, vb, cr, co) print(f"Mean wind velocity vm(z): {vm:.2f} m/s") # Calculate turbulence intensity Iv = I_v(z, z_min, z_0, co, k_I=1.0) print(f"Turbulence intensity Iv(z): {Iv:.3f}") # Calculate peak velocity pressure qp = q_p(z, vb, z_min, z_0, cr, co, rho=1.25) print(f"Peak velocity pressure qp(z): {qp:.2f} Pa") print(f"Peak velocity pressure qp(z): {qp/1000:.3f} kN/m2") ``` -------------------------------- ### Reinforcement Bar and Bundle Calculations (Python) Source: https://context7.com/pcachim/eurocodepy/llms.txt Performs calculations related to reinforcement bars and bundles using EurocodePy's EC2 module. Includes area calculations, equivalent diameters, and bar layout management. ```python from eurocodepy.ec2.materials import Bar, Bundle, BarLayout # Create bars by diameter bar_16 = Bar(diameter=16) print(f"Bar diameter: {bar_16.diameter} mm") print(f"Bar area: {bar_16.area} cm2") # Create bars from database bar_20 = Bar("D20", n=4) # 4 bars of 20mm print(f"Total area of 4xD20: {bar_20.total_area()} cm2") # Create bundle of bars (2-4 bars) bundle = Bundle([Bar(16), Bar(16)]) print(f"Bundle area: {bundle.area} cm2") print(f"Equivalent diameter: {bundle.equiv_diameter:.1f} mm") # Create bar layout for a section layout = BarLayout([]) layout.add_bar(Bar(20), n=3) # 3 bars of 20mm layout.add_bar(Bar(16), n=2) # 2 bars of 16mm print(f"Total reinforcement area: {layout.total_area:.2f} cm2") ``` -------------------------------- ### Eurocode 2 - Design of Concrete Structures Source: https://github.com/pcachim/eurocodepy/blob/master/reference.md Documentation for Eurocode 2, covering the design of concrete structures. ```APIDOC ## Eurocode 2 - Design of Concrete Structures ### Description Provides functions and modules for the design of concrete structures according to Eurocode 2. This includes calculations for cracking, material properties, and ultimate limit states for beams and shells. ### Modules - `eurocodepy.ec2`: General modules for Eurocode 2. - `eurocodepy.ec2.crack`: Functions for crack width calculations. - `eurocodepy.ec2.material`: Modules related to material properties of concrete. - `eurocodepy.ec2.uls.beam`: Functions for ultimate limit state design of beams. - `eurocodepy.ec2.uls.shell`: Functions for ultimate limit state design of shells. - `eurocodepy.ec2.uls.shear`: Functions for shear design calculations. ``` -------------------------------- ### Timber Material Properties and Design Values (EC5) Source: https://context7.com/pcachim/eurocodepy/llms.txt Access timber material properties according to Eurocode 5 for solid timber and glulam. This includes characteristic strengths and elastic moduli. It also demonstrates how to calculate modification factors (kmod) based on service class and load duration, and subsequently derive design values. ```python import eurocodepy as ec from eurocodepy.ec5.materials import Timber, SolidTimber, Glulam, ServiceClass, LoadDuration # Create solid timber instance (softwood) timber = SolidTimber("C24") # Access characteristic properties print(f"Bending strength: {timber.fmk} MPa") # 24 MPa print(f"Tension parallel: {timber.ft0k} MPa") # 14.5 MPa print(f"Compression parallel: {timber.fc0k} MPa") # 21 MPa print(f"Shear strength: {timber.fvk} MPa") # 4.0 MPa print(f"Modulus of elasticity: {timber.E0mean} MPa") # 11000 MPa print(f"Density: {timber.rhok} kg/m3") # 350 kg/m3 # Get modification factor for service class and load duration kmod = timber.k_mod(ServiceClass.SC1, LoadDuration.MediumDuration) print(f"kmod factor: {kmod}") # 0.8 # Calculate design values timber.design_values(ServiceClass.SC1, LoadDuration.MediumDuration) print(f"Design bending strength: {timber.fmd:.2f} MPa") print(f"Design compression: {timber.fc0d:.2f} MPa") # Glulam timber glulam = Glulam("GL24h") print(f"Glulam fmk: {glulam.fmk} MPa") print(f"Rolling shear: {glulam.frk} MPa") ``` -------------------------------- ### Define Concrete and Reinforcement Materials in Python Source: https://github.com/pcachim/eurocodepy/blob/master/mkdocs/docs/modules/ec2.md This snippet demonstrates how to define concrete and reinforcement materials using classes from the `eurocodepy.ec2` module. It initializes `Concrete` and `Reinforcement` objects with specified grades, which are fundamental for subsequent structural calculations. ```python from eurocodepy.ec2 import Concrete, Reinforcement # Define materials conc = Concrete('C30/37') reinf = Reinforcement('B500B') ``` -------------------------------- ### Eurocode 3 - Design of Steel Structures Source: https://github.com/pcachim/eurocodepy/blob/master/reference.md Documentation for Eurocode 3, covering the design of steel structures. ```APIDOC ## Eurocode 3 - Design of Steel Structures ### Description Provides functions and modules for the design of steel structures according to Eurocode 3. This section offers access to various design aspects and calculations for steel structures. ``` -------------------------------- ### Calculate Creep and Shrinkage (EC2, Python) Source: https://context7.com/pcachim/eurocodepy/llms.txt Provides functions to calculate time-dependent concrete properties according to Eurocode 2. This includes the creep coefficient and shrinkage strain, considering factors like age, humidity, concrete strength, and cement type. ```python from eurocodepy.ec2.materials import ( calc_creep_coef, CreepParams, calc_shrink_strain, ShrinkStrainParams, beta_cc, beta_ce ) # Creep coefficient calculation creep_params = CreepParams( t=10000, # Time in days h0=200, # Notional size (2*Ac/u) in mm rh=70, # Relative humidity (%) t0=28, # Age at loading (days) fck=30.0, # Concrete strength (MPa) cem=0.0 # Cement type factor (0=N, 1=R, -1=S) ) phi = calc_creep_coef(creep_params) print(f"Creep coefficient phi(t,t0): {phi:.2f}") # Shrinkage strain calculation shrink_params = ShrinkStrainParams( t=10000, # Time in days h0=200, # Notional size (mm) ts=3, # Age at start of drying (days) rh=70, # Relative humidity (%) fck=30.0, # Concrete strength (MPa) cem="Type N" # Cement type ("Type S", "Type N", "Type R") ) eps_cs = calc_shrink_strain(shrink_params) print(f"Total shrinkage strain: {eps_cs*1e6:.1f} microstrain") ``` -------------------------------- ### Generate Seismic Response Spectrum (EC8, Python) Source: https://context7.com/pcachim/eurocodepy/llms.txt Calculates seismic design response spectra according to Eurocode 8. It supports various national annexes, soil types, and importance classes. The function can return spectrum parameters or a full spectrum DataFrame. ```python import eurocodepy as ec from eurocodepy.ec8 import get_spec_params, get_spectrum_ec8, calc_spectrum, draw_spectrum_ec8 # Get spectrum parameters for Portugal s_val, a_g, t_b, t_c, t_d = get_spec_params( locale="PT", # Portugal code="PT-1", # Type 1 (far-field) class_imp="ii", # Importance class II soil="B", # Soil type B zone="1_3" # Seismic zone 1.3 ) print(f"Soil amplification factor S: {s_val}") print(f"Design ground acceleration a_g: {a_g} m/s2") print(f"T_B: {t_b} s, T_C: {t_c} s, T_D: {t_d} s") # Calculate spectrum value for specific period T = 0.5 # Period in seconds q = 3.0 # Behaviour factor spectrum_value = calc_spectrum(T, a_g, s_val, q, t_b, t_c, t_d) print(f"Spectrum value at T={T}s: {spectrum_value:.3f} m/s2") # Generate full spectrum DataFrame spectrum_df = get_spectrum_ec8( locale="PT", code="PT-1", imp_class="ii", soil="B", zone="1_3", behaviour=3.0 ) print(f"\nSpectrum attributes:") print(f" Name: {spectrum_df.attrs['name']}") print(f" S: {spectrum_df.attrs['S']}") print(f" a_g: {spectrum_df.attrs['a_g']}") # Display first few values print(f"\nFirst 5 spectrum points:") print(spectrum_df.head()) # Draw and save spectrum (uncomment to use) # draw_spectrum_ec8(spectrum_df, save=True, filename="spectrum_pt1.png") ``` -------------------------------- ### Python: Eurocode 3 Steel Member Analysis and Checks Source: https://github.com/pcachim/eurocodepy/blob/master/mkdocs/docs/modules/ec3.md Demonstrates typical usage of the ec3 module for defining steel materials and sections, calculating section properties, performing cross-section classification, and conducting member buckling checks. Requires the eurocodepy library. ```python from eurocodepy.ec3 import Steel, Section, member_buckling_check, cross_section_class # Define material and section steel = Steel('S355') section = Section('IPE300') # Section properties area = section.area Iy = section.Iy # Cross-section classification cls = cross_section_class(section, steel) # Member buckling check N_Ed = 500e3 # Applied axial force [N] L = 6.0 # Member length [m] buckling_ok = member_buckling_check(section, steel, N_Ed, L) ``` -------------------------------- ### Bolted Connections Design and Verification (EC3) Source: https://context7.com/pcachim/eurocodepy/llms.txt Design and verify bolted connections according to Eurocode 3. This includes checks for shear, bearing, tension, and combined loading. It utilizes classes for bolts, steel plates, and the connection itself, taking applied forces as input. ```python import eurocodepy as ec from eurocodepy.ec3.materials import Bolt, Steel, SteelPlate, BoltedConnection import numpy as np # Create bolt bolt = Bolt("M20", "8.8") print(f"Bolt diameter: {bolt.d} mm") print(f"Bolt area: {bolt.A} cm2") print(f"Thread area: {bolt.Athread} cm2") print(f"Ultimate strength: {bolt.fub} MPa") # 800 MPa print(f"Yield strength: {bolt.fyb} MPa") # 640 MPa # Create steel plates steel = Steel("S275") plate = SteelPlate(thickness=12.0, steel=steel, width=200.0) # Create bolted connection connection = BoltedConnection(bolt, plate) connection.e1 = 40.0 # End distance connection.e2 = 30.0 # Edge distance connection.p1 = 70.0 # Spacing parallel to load connection.p2 = 60.0 # Spacing perpendicular to load connection.n1 = 2 # Bolts in parallel connection.n2 = 3 # Bolts in series # Get design resistances print(f"Shear resistance: {connection.Fv_Rd()} kN") print(f"Bearing resistance: {connection.Fb_Rd()} kN") print(f"Tension resistance: {connection.Ft_Rd()} kN") print(f"Punching resistance: {connection.Bp_Rd()} kN") # Verify connection under loading Fv_Ed = np.array([50.0, 55.0, 48.0]) # Applied shear forces (kN) Ft_Ed = np.array([20.0, 25.0, 18.0]) # Applied tension forces (kN) results = connection.check(Fv_Ed, Ft_Ed) print(f"Shear ratio: {results['ShearRatio']}") print(f"Bearing ratio: {results['BearingRatio']}") print(f"Combined ratio: {results['CombinedRatio']}") print(f"Connection OK: {results['Check']}") ``` -------------------------------- ### Calculate Effective Reinforcement Ratio and Crack Spacing in Python Source: https://github.com/pcachim/eurocodepy/blob/master/mkdocs/docs/modules/ec2.md This Python code calculates the effective reinforcement ratio (`rho_p_eff`) and maximum crack spacing (`s_r_max`) using parameters like section dimensions, bar size, concrete cover, and effective area. It utilizes functions from the `eurocodepy.ec2` module for these calculations, essential for crack control analysis. ```python from eurocodepy.ec2 import crack_opening, sr_max # Section and reinforcement data b = 300 # mm h = 500 # mm phi = 16 # mm As = 4 * 201 # mm² (4 bars of 16 mm) c = 25 # mm (cover) # Calculate effective reinforcement ratio, crack spacing, and crack width Ac_eff = b * 100 # Example effective area in tension [mm²] rho_p_eff = As / Ac_eff s_r_max = sr_max(c, phi, rho_p_eff) # ... further calculations for crack width, etc. ``` -------------------------------- ### Generate and Visualize Eurocode 8 Spectrum (Python) Source: https://github.com/pcachim/eurocodepy/blob/master/mkdocs/docs/modules/ec8.md Generates an elastic response spectrum based on Eurocode 8 parameters for a specified location and seismic conditions. It then visualizes the generated spectrum using matplotlib and optionally exports it to a CSV file. ```python from eurocodepy.ec8.spectrum import get_spectrum_ec8, draw_spectrum_ec8, write_spectrum_ec8 # Generate a spectrum for Portugal, standard code, importance class II, soil C, zone 1_2, q=3.0 spec = get_spectrum_ec8( locale='PT', code='PT-1', imp_class='II', soil='C', zone='1_2', behaviour=3.0 ) # Plot the spectrum draw_spectrum_ec8(spec, show=True) # Export the spectrum to CSV write_spectrum_ec8(spec, filename='spectrum_PT1_II_C_1_2.csv') ``` -------------------------------- ### Fillet Weld Design (EC3) Source: https://context7.com/pcachim/eurocodepy/llms.txt Design fillet welds according to Eurocode 3 using the directional method. This involves creating a Weld object with specified dimensions and steel grade, then accessing its design strength and geometric properties. Multiple welds can be grouped in a WeldConnection. ```python import eurocodepy as ec from eurocodepy.ec3.materials import Weld, WeldConnection import numpy as np # Create a fillet weld weld = Weld( a=6.0, # Throat thickness (mm) length=200.0, # Weld length (mm) steel_grade="S355", # Steel grade x=0.0, # X coordinate (mm) y=0.0, # Y coordinate (mm) orientation=0.0 # Orientation angle (radians) ) # Access weld properties print(f"Design shear strength: {weld.fv_wd:.1f} MPa") print(f"Correlation factor beta_w: {weld.beta_w}") print(f"Weld area: {weld.area:.1f} mm2") print(f"Full strength throat (shear): a >= {weld.a_full_shear:.2f} * t") # Create weld connection with multiple welds connection = WeldConnection() connection.add(Weld(a=6.0, length=150.0, steel_grade="S355", x=0, y=0, orientation=0)) connection.add(Weld(a=6.0, length=150.0, steel_grade="S355", x=0, y=100, orientation=0)) print(f"Total weld length: {connection.total_length()} mm") print(f"Total throat area: {connection.area:.1f} mm2") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.