MoonStrMech

    Download zip
    Version
    0.1.1
    License
    Apache-2.0
    Last updated
    10 months ago
    Downloads
    42

    No dependencies

    #MoonStrMech - Structural Mechanics Calculation Library

    MoonStrMech is a comprehensive structural mechanics calculation library written in Moonbit, providing functions for structural analysis, beam theory, and civil engineering calculations.

    #Features

    #Support Reactions

    • Simply supported beams (point loads, uniform loads)
    • Cantilever beams (point loads, uniform loads)
    • Overhanging beams

    #Internal Forces

    • Shear force calculations
    • Bending moment calculations
    • Beam deflection analysis

    #Structural Analysis

    • Truss analysis (triangle trusses, joint analysis)
    • Stability analysis (Euler critical loads)
    • Dynamic analysis (natural frequencies, damping)
    • Continuous beam analysis

    #Mathematical Utilities

    • Linear algebra (matrix operations, determinants)
    • Vector operations (2D/3D calculations)
    • Geometric functions (polygon areas, distances)
    • Numerical methods (approximations, safe divisions)

    #Usage Examples

    #Support Reactions

    test "simply supported beam - point load" {
    // P=10kN at mid-span, L=4m
    let (ra, rb) = simply_supported_reactions_point(10.0, 2.0, 4.0)
    assert_eq(ra, 5.0)
    assert_eq(rb, 5.0)
    }

    test "simply supported beam - uniform load" {
    // q=5kN/m, L=6m
    let (ra, rb) = simply_supported_reactions_uniform(5.0, 6.0)
    assert_eq(ra, 15.0)
    assert_eq(rb, 15.0)
    }

    test "cantilever reactions" {
    // P=8kN at end, L=3m
    let (v, m) = cantilever_reactions_point(8.0, 3.0)
    assert_eq(v, 8.0)
    assert_eq(m, 24.0)

    // q=4kN/m, L=5m
    let (v2, m2) = cantilever_reactions_uniform(4.0, 5.0)
    assert_eq(v2, 20.0)
    assert_eq(m2, 50.0)
    }

    #Internal Forces and Deflection

    test "internal forces - simply supported" {
    // P=10kN at 2m from left, L=5m
    let v_left = simply_supported_shear_point(10.0, 2.0, 5.0, 1.0)
    assert_eq(v_left, 6.0)
    let v_right = simply_supported_shear_point(10.0, 2.0, 5.0, 3.0)
    assert_eq(v_right, -4.0)

    let m_at_load = simply_supported_moment_point(10.0, 2.0, 5.0, 2.0)
    assert_eq(m_at_load, 12.0)
    }

    test "section properties" {
    // Rectangular section: b=0.3m, h=0.5m
    let i_rect = rect_inertia(0.3, 0.5)
    assert_eq(approx_equal(i_rect, 0.003125, 0.000001), true)

    let w_rect = rect_section_modulus(0.3, 0.5)
    assert_eq(approx_equal(w_rect, 0.0125, 0.000001), true)
    }

    test "deflection calculations" {
    // Simply supported beam, point load at mid-span
    // δ = PL³/(48EI)
    let d1 = simply_supported_deflection_point_mid(10.0, 4.0, 200.0, 0.001)
    assert_eq(approx_equal(d1, 66.667, 0.01), true)
    }

    #Stability and Dynamics

    test "euler critical force" {
    // E=200GPa, I=0.0001m⁴, L=5m, μ=1 (both ends hinged)
    // Pcr = π²EI/(μL)² = 7.895 MN
    let pcr = euler_critical_force(200.0e9, 0.0001, 5.0, 1.0)
    assert_eq(approx_equal(pcr / 1.0e6, 7.895, 0.01), true)
    }

    test "stability factor - Q235 steel" {
    let phi = stability_factor_steel_q235(50.0)
    assert_eq(phi > 0.0, true)
    }

    test "dynamics" {
    // Natural frequency: k=1000N/m, m=10kg
    let omega = natural_frequency(1000.0, 10.0)
    assert_eq(omega, 10.0)

    // Damping ratio: c=40, k=1000, m=10
    let xi = damping_ratio(40.0, 1000.0, 10.0)
    assert_eq(approx_equal(xi, 0.2, 0.0001), true)
    }

    #Structural Analysis

    test "truss analysis" {
    // Triangle truss: L=4m, h=3m, P=10kN
    let (n_left, n_right, n_bottom) = truss_triangle(4.0, 3.0, 10.0)
    assert_eq(approx_equal(n_left, -6.010, 0.01), true)
    assert_eq(approx_equal(n_right, -6.010, 0.01), true)
    assert_eq(approx_equal(n_bottom, 3.336, 0.01), true)
    }

    test "rotational stiffness" {
    // Rotational stiffness (far end fixed)
    let s_fixed = rotational_stiffness(200.0, 0.001, 4.0, true)
    assert_eq(s_fixed, 0.2)

    // Rotational stiffness (far end hinged)
    let s_hinged = rotational_stiffness(200.0, 0.001, 4.0, false)
    assert_eq(s_hinged, 0.15)
    }

    test "three moment equation" {
    let coeffs = three_moment_coefficients(4.0, 6.0)
    assert_eq(coeffs.0, 4.0)
    }

    #Mathematical Utilities

    test "basic math tools" {
    assert_eq(square(3.0), 9.0)
    assert_eq(cube(2.0), 8.0)
    assert_eq(abs(-5.0), 5.0)
    assert_eq(max(3.0, 5.0), 5.0)
    assert_eq(min(3.0, 5.0), 3.0)
    }

    test "vector operations" {
    // Dot product
    assert_eq(dot2d(1.0, 0.0, 0.0, 1.0), 0.0)
    assert_eq(dot2d(1.0, 2.0, 3.0, 4.0), 11.0)

    // Cross product (2D)
    assert_eq(cross2d(1.0, 0.0, 0.0, 1.0), 1.0)

    // Distance
    assert_eq(distance2d(0.0, 0.0, 3.0, 4.0), 5.0)
    }

    test "determinants" {
    // 2x2 determinant
    assert_eq(det2x2(1.0, 2.0, 3.0, 4.0), -2.0)

    // 3x3 determinant
    assert_eq(det3x3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0), 1.0)
    }

    test "solve linear systems" {
    // 2x2 system: x + 2y = 5, 3x + 4y = 11
    let (x, y) = solve2x2(1.0, 2.0, 3.0, 4.0, 5.0, 11.0)
    assert_eq(approx_equal(x, 1.0, 0.0001), true)
    assert_eq(approx_equal(y, 2.0, 0.0001), true)
    }

    test "polygon area" {
    // Square 2x2
    let sq = [(0.0, 0.0), (2.0, 0.0), (2.0, 2.0), (0.0, 2.0)]
    assert_eq(polygon_area(sq), 4.0)

    // Triangle
    let tri = [(0.0, 0.0), (4.0, 0.0), (2.0, 3.0)]
    assert_eq(polygon_area(tri), 6.0)
    }

    #Force Method and Displacement Method

    test "force method" {
    // Single redundant: δ₁p = 5, δ₁₁ = 2
    let x1 = force_method_1_redundant(5.0, 2.0)
    assert_eq(x1, -2.5)

    // Two redundants
    let (x1, x2) = force_method_2_redundant(1.0, 0.0, 1.0, 5.0, 3.0)
    assert_eq(approx_equal(x1, -5.0, 0.001), true)
    assert_eq(approx_equal(x2, -3.0, 0.001), true)
    }

    test "displacement method" {
    // Rotational stiffness (far end fixed)
    let s_fixed = rotational_stiffness(200.0, 0.001, 4.0, true)
    assert_eq(s_fixed, 0.2)

    // Linear stiffness
    let s_linear = linear_stiffness(200.0, 0.001, 4.0)
    assert_eq(s_linear, 0.05)
    }

    #Influence Lines

    test "influence lines" {
    // Support reactions
    let eta_ra = influence_line_ra(2.0, 5.0)
    assert_eq(eta_ra, 0.6)

    let eta_rb = influence_line_rb(2.0, 5.0)
    assert_eq(eta_rb, 0.4)

    // Moment influence line (section at mid-span)
    let eta_m = influence_line_moment(4.0, 4.0, 10.0)
    assert_eq(eta_m, 2.4)
    }

    #Parameter Ranges

    #Valid Input Ranges

    • Forces: 0–10⁶ N (structural loads)
    • Lengths: 0.1–100 m (beam spans and dimensions)
    • Elastic Modulus: 10⁷–10¹¹ Pa (material stiffness)
    • Moments of Inertia: 10⁻⁸–10⁻² m⁴ (section properties)

    #Typical Engineering Values

    • Steel E: 200 GPa (Young's modulus)
    • Concrete E: 20–40 GPa (Young's modulus)
    • Wood E: 8–15 GPa (Young's modulus)
    • Standard Beam Loads: 1–100 kN/m (distributed loads)

    #Testing

    The project includes a comprehensive test suite covering all major functionalities:

    moon test

    #Test Coverage

    • Support reactions for various beam types
    • Internal force calculations (shear, moment)
    • Beam deflection analysis
    • Structural stability (Euler buckling)
    • Dynamic analysis (natural frequency, damping)
    • Mathematical utilities and geometric calculations
    • Truss and arch structure analysis
    • Force method and displacement method
    • Influence line calculations

    #Technical Details

    #Engineering Standards

    • Structural Analysis: Classical beam theory and structural mechanics
    • Euler Buckling: Critical load analysis for slender members
    • Beam Deflection: Integration methods for deflection calculations
    • SI Units: Consistent use of International System of Units

    #Applications

    • Civil Engineering: Building structures, bridges, and foundations
    • Structural Design: Beam analysis and design calculations
    • Educational Use: Structural mechanics teaching and learning
    • Research Applications: Structural analysis and simulation

    #Notes

    1. Units: All calculations use SI units (meters, kilograms, seconds, Newtons)
    2. Load Conventions: Positive shear and moment follow standard conventions
    3. Boundary Conditions: Standard support conditions assumed unless specified
    4. Material Properties: Linear elastic behavior assumed
    5. Geometric Assumptions: Euler-Bernoulli beam theory assumptions
    6. Validation: Results should be verified against established structural analysis methods

    #Version Information

    The current version (0.1.0) implements core structural mechanics calculation functions including:

    • Support reaction calculations for various beam types
    • Internal force analysis (shear forces, bending moments)
    • Beam deflection calculations using classical methods
    • Structural stability analysis (Euler critical loads)
    • Dynamic analysis (natural frequencies, damping)
    • Mathematical utilities for structural calculations
    • Truss and arch structure analysis
    • Force method and displacement method implementations
    • Influence line calculations for moving loads

    The library is actively developed and aims to provide comprehensive coverage of structural mechanics while being optimized for MoonBit.

    CARRYOVER_FIXED

    let CARRYOVER_FIXED : Double

    远端固定传递系数

    CARRYOVER_HINGED

    let CARRYOVER_HINGED : Double

    远端铰支传递系数

    EPSILON

    let EPSILON : Double

    浮点数比较精度

    E_ALUMINUM

    let E_ALUMINUM : Double

    铝合金弹性模量

    E_CONCRETE_C30

    let E_CONCRETE_C30 : Double

    混凝土弹性模量 (C30)

    E_CONCRETE_C40

    let E_CONCRETE_C40 : Double

    混凝土弹性模量 (C40)

    E_CONST

    let E_CONST : Double

    自然对数底数

    E_STEEL

    let E_STEEL : Double

    钢材弹性模量

    E_WOOD

    let E_WOOD : Double

    木材弹性模量

    GAMMA_RC

    let GAMMA_RC : Double

    钢筋混凝土容重

    GAMMA_SOIL

    let GAMMA_SOIL : Double

    土容重 (一般粘性土)

    GAMMA_STEEL

    let GAMMA_STEEL : Double

    钢材容重

    GAMMA_WATER

    let GAMMA_WATER : Double

    水容重

    GAMMA_WOOD

    let GAMMA_WOOD : Double

    木材容重

    GPA_TO_PA

    let GPA_TO_PA : Double

    GPa 转 Pa

    KAPPA_CIRCLE

    let KAPPA_CIRCLE : Double

    圆形截面剪切形状系数

    KAPPA_I_SECTION

    let KAPPA_I_SECTION : Double

    工字形截面剪切形状系数 (近似)

    KAPPA_RECT

    let KAPPA_RECT : Double

    矩形截面剪切形状系数

    KN_TO_N

    let KN_TO_N : Double

    kN 转 N

    MM_TO_M

    let MM_TO_M : Double

    mm 转 m

    MPA_TO_PA

    let MPA_TO_PA : Double

    MPa 转 Pa

    MU_FF

    let MU_FF : Double

    一端固定一端自由 (Fixed-Free) 悬臂

    MU_FH

    let MU_FH : Double

    一端固定一端铰支 (Fixed-Hinged)

    MU_FIXED

    let MU_FIXED : Double

    两端固定 (Fixed-Fixed)

    MU_HH

    let MU_HH : Double

    两端铰支 (Hinged-Hinged)

    M_TO_MM

    let M_TO_MM : Double

    m 转 mm

    NU_ALUMINUM

    let NU_ALUMINUM : Double

    NU_CONCRETE

    let NU_CONCRETE : Double

    NU_STEEL

    let NU_STEEL : Double

    NU_WOOD

    let NU_WOOD : Double

    let PI : Double

    圆周率

    RHO_ALUMINUM

    let RHO_ALUMINUM : Double

    RHO_CONCRETE

    let RHO_CONCRETE : Double

    RHO_STEEL

    let RHO_STEEL : Double

    RHO_WOOD

    let RHO_WOOD : Double

    abs

    fn abs(x : Double) -> Double

    计算绝对值

    approx_equal

    fn approx_equal(a : Double, b : Double, tolerance : Double) -> Bool

    判断两个浮点数是否近似相等

    array_max

    fn array_max(arr : Array[Double]) -> Double

    数组最大值

    array_mean

    fn array_mean(arr : Array[Double]) -> Double

    数组平均值

    array_min

    fn array_min(arr : Array[Double]) -> Double

    数组最小值

    array_sum

    fn array_sum(arr : Array[Double]) -> Double

    数组求和

    axial_strain_energy

    fn axial_strain_energy(n : Double, l : Double, e : Double, a : Double) -> Double

    轴向应变能 U = N²L / (2EA)

    beam_frequency_concentrated_mass

    fn beam_frequency_concentrated_mass(e : Double, i : Double, m : Double, l : Double) -> Double

    简支梁一阶自振频率 (集中质量在跨中) ω₁ = sqrt(48EI / (mL³))

    beam_frequency_distributed_mass

    fn beam_frequency_distributed_mass(e : Double, i : Double, rho_a : Double, l : Double) -> Double

    简支梁一阶自振频率 (均布质量) ω₁ = π²sqrt(EI / (ρAL⁴)) 其中 m_total = ρA*L

    bending_strain_energy

    fn bending_strain_energy(m : Double, l : Double, e : Double, i : Double) -> Double

    弯曲应变能 (均匀弯矩段) U = M²L / (2EI)

    cantilever_deflection_point_end

    fn cantilever_deflection_point_end(p : Double, l : Double, e : Double, i : Double) -> Double

    悬臂梁端部集中力作用下的自由端挠度 δ = PL³/(3EI)

    cantilever_deflection_uniform_end

    fn cantilever_deflection_uniform_end(q : Double, l : Double, e : Double, i : Double) -> Double

    悬臂梁均布荷载作用下的自由端挠度 δ = qL⁴/(8EI)

    cantilever_frequency_tip_mass

    fn cantilever_frequency_tip_mass(e : Double, i : Double, m : Double, l : Double) -> Double

    悬臂梁一阶自振频率 (端部集中质量) ω₁ = sqrt(3EI / (mL³))

    cantilever_moment_point

    fn cantilever_moment_point(p : Double, l : Double, x : Double) -> Double

    悬臂梁端部集中力作用下任意截面的弯矩 x 从固定端量起,弯矩为负(上部受拉)

    cantilever_moment_uniform

    fn cantilever_moment_uniform(q : Double, l : Double, x : Double) -> Double

    悬臂梁均布荷载作用下任意截面的弯矩

    cantilever_reactions_point

    fn cantilever_reactions_point(p : Double, l : Double) -> (Double, Double)

    悬臂梁在端部集中力作用下的固端反力 荷载 P 作用于自由端,梁长 L 返回 (固端剪力 V, 固端弯矩 M)

    cantilever_reactions_uniform

    fn cantilever_reactions_uniform(q : Double, l : Double) -> (Double, Double)

    悬臂梁在均布荷载作用下的固端反力 均布荷载 q,梁长 L 返回 (固端剪力 V, 固端弯矩 M)

    cantilever_shear_point

    fn cantilever_shear_point(p : Double, l : Double, x : Double) -> Double

    悬臂梁端部集中力作用下任意截面的剪力 x 从固定端量起

    cantilever_shear_uniform

    fn cantilever_shear_uniform(q : Double, l : Double, x : Double) -> Double

    悬臂梁均布荷载作用下任意截面的剪力

    cantilever_slope_point_end

    fn cantilever_slope_point_end(p : Double, l : Double, e : Double, i : Double) -> Double

    悬臂梁端部集中力作用下的自由端转角 θ = PL²/(2EI)

    carryover_factor

    fn carryover_factor(far_end_fixed : Bool) -> Double

    传递系数 远端固定: C = 0.5 远端铰接: C = 0

    carryover_moment

    fn carryover_moment(distributed : Double, carryover : Double) -> Double

    传递力矩计算 distributed: 分配的力矩 carryover: 传递系数 返回传递到远端的力矩

    castigliano_bending_contribution

    fn castigliano_bending_contribution(m : Double, dm_dp : Double, l : Double, e : Double, i : Double) -> Double

    卡氏第二定理 - 弹性体系位移 Δᵢ = ∂U/∂Pᵢ 这里计算单根杆件的应变能对某力的偏导贡献 弯矩: ∂U/∂P = ∫(M/EI)(∂M/∂P)dx

    circle_inertia

    fn circle_inertia(r : Double) -> Double

    圆形截面惯性矩 I = πr⁴/4

    circle_section_modulus

    fn circle_section_modulus(r : Double) -> Double

    圆形截面抗弯模量 W = πr³/4

    circular_arch_radius

    fn circular_arch_radius(l : Double, f : Double) -> Double

    圆弧拱的半径 R = (L²/4 + f²) / (2f)

    clamp

    fn clamp(value : Double, min_val : Double, max_val : Double) -> Double

    限制值在范围内

    column_lateral_stiffness

    fn column_lateral_stiffness(e : Double, i : Double, h : Double, mu : Double) -> Double

    刚架柱的抗侧刚度贡献 D = 12EI / (μ²h³) mu: 柱的计算长度系数

    continuous_beam_2span_uniform_mid_moment

    fn continuous_beam_2span_uniform_mid_moment(q : Double, l : Double) -> Double

    两跨连续梁支座弯矩 (两端简支,等跨等载) 中间支座弯矩 MB = -qL²/8

    continuous_beam_3span_uniform_support_moment

    fn continuous_beam_3span_uniform_support_moment(q : Double, l : Double) -> Double

    三跨连续梁支座弯矩 (两端简支,等跨等载) 简化公式: MB = MC = -qL²/10

    cos_approx

    fn cos_approx(x : Double) -> Double

    余弦函数近似 (泰勒级数)

    critical_slenderness

    fn critical_slenderness(e : Double, sigma_p : Double) -> Double

    临界长细比 (欧拉公式适用的最小长细比) λ_p = π * sqrt(E / σ_p) sigma_p: 比例极限

    cross2d

    fn cross2d(x1 : Double, y1 : Double, x2 : Double, y2 : Double) -> Double

    二维向量叉积 (返回标量,z分量)

    cube

    fn cube(x : Double) -> Double

    计算立方

    damped_frequency

    fn damped_frequency(omega : Double, xi : Double) -> Double

    有阻尼自振频率 ω_d = ω * sqrt(1 - ξ²)

    damping_ratio

    fn damping_ratio(c : Double, k : Double, m : Double) -> Double

    阻尼比 ξ = c / (2sqrt(km)) = c / (2mω)

    deg_to_rad

    fn deg_to_rad(deg : Double) -> Double

    角度转弧度

    det2x2

    fn det2x2(a : Double, b : Double, c : Double, d : Double) -> Double

    2x2矩阵行列式 | a b | | c d |

    det3x3

    fn det3x3(a : Double, b : Double, c : Double, d : Double, e : Double, f : Double, g : Double, h : Double, i : Double) -> Double

    3x3矩阵行列式 | a b c | | d e f | | g h i |

    distance2d

    fn distance2d(x1 : Double, y1 : Double, x2 : Double, y2 : Double) -> Double

    两点间距离

    distribute_moment

    fn distribute_moment(unbalanced_moment : Double, factors : Array[Double]) -> Array[Double]

    单节点力矩分配 - 一次分配 unbalanced_moment: 不平衡力矩 factors: 分配系数数组 返回各杆件分配的力矩

    distribution_factors

    fn distribution_factors(stiffnesses : Array[Double]) -> Array[Double]

    计算分配系数 给定节点各杆件的转动刚度,返回各杆件的分配系数

    dot2d

    fn dot2d(x1 : Double, y1 : Double, x2 : Double, y2 : Double) -> Double

    二维向量点积

    effect_from_influence_area

    fn effect_from_influence_area(q : Double, omega : Double) -> Double

    利用影响线计算均布荷载作用效应 影响线面积法: S = q * Ω omega: 影响线包围面积

    euler_critical_force

    fn euler_critical_force(e : Double, i : Double, l : Double, mu : Double) -> Double

    欧拉临界力 P_cr = π²EI / (μL)²

    euler_critical_stress

    fn euler_critical_stress(e : Double, lambda : Double) -> Double

    欧拉临界应力 σ_cr = π²E / λ²

    fixed_end_moment_point

    fn fixed_end_moment_point(p : Double, a : Double, l : Double) -> (Double, Double)

    固端弯矩 - 两端固定,集中力作用于距A端 a 处 M_AB = -Pab²/L², M_BA = Pa²b/L²

    fixed_end_moment_point_mid

    fn fixed_end_moment_point_mid(p : Double, l : Double) -> (Double, Double)

    固端弯矩 - 简支梁两端固定,中点集中力 M_AB = -PL/8, M_BA = PL/8

    fixed_end_moment_triangular

    fn fixed_end_moment_triangular(q_max : Double, l : Double) -> (Double, Double)

    固端弯矩 - 两端固定,三角形荷载 (从A端0增到B端q_max) M_AB = -qL²/30, M_BA = qL²/20

    fixed_end_moment_uniform

    fn fixed_end_moment_uniform(q : Double, l : Double) -> (Double, Double)

    固端弯矩 - 两端固定,均布荷载 M_AB = M_BA = -qL²/12

    force_method_1_redundant

    fn force_method_1_redundant(delta_1p : Double, delta_11 : Double) -> Double

    力法:一次超静定梁的多余力计算 delta_1p: 基本结构在荷载作用下沿多余约束方向的位移 delta_11: 基本结构在单位多余力作用下沿多余约束方向的位移 返回多余力 X1

    force_method_2_redundant

    fn force_method_2_redundant(d11 : Double, d12 : Double, d22 : Double, d1p : Double, d2p : Double) -> (Double, Double)

    力法:二次超静定结构的多余力计算 输入柔度矩阵元素和荷载位移 返回 (X1, X2)

    graph_multiply_para_tri

    fn graph_multiply_para_tri(m_para : Double, m_tri : Double, l : Double) -> Double

    计算图乘 - 抛物线与三角形 (简支梁均布弯矩与单位荷载三角形) 抛物线最大值 m_para (跨中),三角形最大值 m_tri,跨度 L 积分 = (1/3) * L * m_para * m_tri (当三角形顶点在跨中时) 一般情况: (2/3) * L * m_para * m_tri_mid (m_tri_mid是三角形在跨中的值)

    graph_multiply_rects

    fn graph_multiply_rects(m1 : Double, m2 : Double, l : Double) -> Double

    计算图乘 - 两个矩形 结果 = L * m1 * m2

    graph_multiply_tri_rect

    fn graph_multiply_tri_rect(m_tri : Double, m_rect : Double, l : Double) -> Double

    计算图乘 - 三角形与矩形 三角形最大值 m_tri,矩形高度 m_rect,跨度 L 结果 = (1/2) * L * m_tri * m_rect

    graph_multiply_triangles

    fn graph_multiply_triangles(m1 : Double, m2 : Double, l : Double) -> Double

    计算单位荷载图乘法积分 两个三角形分布的图乘 (共基边) M1: 最大值 m1,M2: 最大值 m2,跨度 L 结果 = (1/3) * L * m1 * m2

    hollow_circle_inertia

    fn hollow_circle_inertia(r_outer : Double, r_inner : Double) -> Double

    空心圆形截面惯性矩

    hollow_rect_inertia

    fn hollow_rect_inertia(b_outer : Double, h_outer : Double, b_inner : Double, h_inner : Double) -> Double

    空心矩形截面惯性矩 B, H - 外尺寸,b, h - 内空尺寸

    i_section_inertia

    fn i_section_inertia(b : Double, h : Double, tf : Double, tw : Double) -> Double

    工字形截面惯性矩 (简化) b - 翼缘宽度, h - 总高度, tf - 翼缘厚度, tw - 腹板厚度

    influence_area_triangle

    fn influence_area_triangle(base : Double, height : Double) -> Double

    三角形影响线面积

    influence_line_moment

    fn influence_line_moment(x : Double, a : Double, l : Double) -> Double

    简支梁某截面弯矩影响线纵标 截面位于距左端 a 处,荷载位于 x 处

    influence_line_ra

    fn influence_line_ra(x : Double, l : Double) -> Double

    简支梁支座反力影响线纵标 求 RA 在荷载位于 x 处时的影响线值 η_RA(x) = (L - x) / L

    influence_line_rb

    fn influence_line_rb(x : Double, l : Double) -> Double

    简支梁支座反力影响线纵标 求 RB 在荷载位于 x 处时的影响线值 η_RB(x) = x / L

    influence_line_shear

    fn influence_line_shear(x : Double, a : Double, l : Double) -> Double

    简支梁某截面剪力影响线纵标 截面位于距左端 a 处,荷载位于 x 处

    inv2x2

    fn inv2x2(a : Double, b : Double, c : Double, d : Double) -> (Double, Double, Double, Double)

    2x2矩阵求逆,返回 (a', b', c', d') 或全零表示奇异

    is_zero

    fn is_zero(x : Double) -> Bool

    判断浮点数是否接近零

    lerp

    fn lerp(a : Double, b : Double, t : Double) -> Double

    线性插值

    linear_stiffness

    fn linear_stiffness(e : Double, i : Double, l : Double) -> Double

    等截面直杆的线刚度 i_c = EI/L

    mat2x2_vec

    fn mat2x2_vec(a : Double, b : Double, c : Double, d : Double, x : Double, y : Double) -> (Double, Double)

    2x2矩阵乘向量 [a b; c d] * [x; y]

    max

    fn max(a : Double, b : Double) -> Double

    计算最大值

    min

    fn min(a : Double, b : Double) -> Double

    计算最小值

    natural_frequency

    fn natural_frequency(k : Double, m : Double) -> Double

    单自由度系统自振圆频率 ω = sqrt(k/m)

    natural_period

    fn natural_period(k : Double, m : Double) -> Double

    单自由度系统自振周期 T = 2π/ω = 2π*sqrt(m/k)

    overhanging_reactions_uniform

    fn overhanging_reactions_uniform(q : Double, l : Double, a : Double, b : Double) -> (Double, Double)

    外伸梁支座反力计算 梁总长 L,左悬臂长 a,右悬臂长 b,中间跨度 c = L - a - b 均布荷载 q 作用于全梁 返回 (左支座反力 RA, 右支座反力 RB)

    parabolic_arch_slope

    fn parabolic_arch_slope(x : Double, l : Double, f : Double) -> Double

    抛物线拱轴线斜率 dy/dx = 4f(L - 2x) / L²

    parabolic_arch_y

    fn parabolic_arch_y(x : Double, l : Double, f : Double) -> Double

    抛物线拱轴线方程 y = 4fx(L-x) / L²

    poly1_eval

    fn poly1_eval(a : Double, b : Double, x : Double) -> Double

    一次多项式求值 y = a*x + b

    poly2_eval

    fn poly2_eval(a : Double, b : Double, c : Double, x : Double) -> Double

    二次多项式求值 y = ax² + bx + c

    poly3_eval

    fn poly3_eval(a : Double, b : Double, c : Double, d : Double, x : Double) -> Double

    三次多项式求值 y = ax³ + bx² + c*x + d

    polygon_area

    fn polygon_area(coords : Array[(Double, Double)]) -> Double

    计算多边形面积 (顶点数组,顺或逆时针,Shoelace公式)

    polygon_centroid

    fn polygon_centroid(coords : Array[(Double, Double)]) -> (Double, Double)

    计算多边形形心 (顶点数组)

    portal_frame_lateral_stiffness_fixed

    fn portal_frame_lateral_stiffness_fixed(e : Double, i_c : Double, h : Double) -> Double

    门式刚架侧移刚度 (两端固定柱) K = 24EI_c / h³ i_c: 柱惯性矩, h: 柱高

    portal_frame_lateral_stiffness_hinged

    fn portal_frame_lateral_stiffness_hinged(e : Double, i_c : Double, h : Double) -> Double

    门式刚架侧移刚度 (底部铰接柱) K = 3EI_c / h³

    pow4

    fn pow4(x : Double) -> Double

    计算四次方

    rad_to_deg

    fn rad_to_deg(rad : Double) -> Double

    弧度转角度

    radius_of_gyration

    fn radius_of_gyration(inertia : Double, area : Double) -> Double

    回转半径 i = sqrt(I/A)

    rect_inertia

    fn rect_inertia(b : Double, h : Double) -> Double

    矩形截面惯性矩 Ix = bh³/12

    rect_section_modulus

    fn rect_section_modulus(b : Double, h : Double) -> Double

    矩形截面抗弯模量 Wx = bh²/6

    rotate2d

    fn rotate2d(x : Double, y : Double, angle_rad : Double) -> (Double, Double)

    二维旋转 (绕原点) 返回旋转后的坐标 (x', y') 使用泰勒级数近似 sin 和 cos

    rotational_stiffness

    fn rotational_stiffness(e : Double, i : Double, l : Double, far_end_fixed : Bool) -> Double

    等截面直杆的转动刚度 远端固定: S = 4EI/L 远端铰接: S = 3EI/L

    safe_div

    fn safe_div(num : Double, den : Double, fallback : Double) -> Double

    安全除法,分母为零时返回默认值

    shear_strain_energy

    fn shear_strain_energy(v : Double, l : Double, g : Double, a : Double, kappa : Double) -> Double

    剪切应变能 U = κV²L / (2GA)

    sign

    fn sign(x : Double) -> Double

    符号函数

    simply_supported_deflection_point_mid

    fn simply_supported_deflection_point_mid(p : Double, l : Double, e : Double, i : Double) -> Double

    简支梁中点集中力作用下的跨中挠度 δ = PL³/(48EI)

    simply_supported_deflection_uniform_mid

    fn simply_supported_deflection_uniform_mid(q : Double, l : Double, e : Double, i : Double) -> Double

    简支梁均布荷载作用下的跨中挠度 δ = 5qL⁴/(384EI)

    simply_supported_max_moment_uniform

    fn simply_supported_max_moment_uniform(q : Double, l : Double) -> Double

    简支梁均布荷载下的最大弯矩 (跨中)

    simply_supported_moment_point

    fn simply_supported_moment_point(p : Double, a : Double, l : Double, x : Double) -> Double

    简支梁集中力作用下任意截面的弯矩 P 作用于距左端 a 处,求距左端 x 处的弯矩

    simply_supported_moment_uniform

    fn simply_supported_moment_uniform(q : Double, l : Double, x : Double) -> Double

    简支梁均布荷载作用下任意截面的弯矩

    simply_supported_reactions_point

    fn simply_supported_reactions_point(p : Double, a : Double, l : Double) -> (Double, Double)

    简支梁在集中力作用下的支座反力 荷载 P 作用于距左支座 a 处,梁跨度 L 返回 (左支座反力 RA, 右支座反力 RB)

    simply_supported_reactions_triangular

    fn simply_supported_reactions_triangular(q_max : Double, l : Double) -> (Double, Double)

    简支梁在三角形荷载作用下的支座反力 荷载从左端 0 线性增加到右端 q_max 返回 (左支座反力 RA, 右支座反力 RB)

    simply_supported_reactions_uniform

    fn simply_supported_reactions_uniform(q : Double, l : Double) -> (Double, Double)

    简支梁在均布荷载作用下的支座反力 均布荷载 q (kN/m),跨度 L 返回 (左支座反力 RA, 右支座反力 RB)

    simply_supported_shear_point

    fn simply_supported_shear_point(p : Double, a : Double, l : Double, x : Double) -> Double

    简支梁集中力作用下任意截面的剪力 P 作用于距左端 a 处,求距左端 x 处的剪力

    simply_supported_shear_uniform

    fn simply_supported_shear_uniform(q : Double, l : Double, x : Double) -> Double

    简支梁均布荷载作用下任意截面的剪力

    simply_supported_slope_uniform_end

    fn simply_supported_slope_uniform_end(q : Double, l : Double, e : Double, i : Double) -> Double

    简支梁端部转角 (均布荷载) θ = qL³/(24EI)

    simpson_integral

    fn simpson_integral(fa : Double, fmid : Double, fb : Double, length : Double) -> Double

    辛普森积分 (单段) 积分 f 在 [a, b] 上的值,给定 f(a), f(mid), f(b)

    sin_approx

    fn sin_approx(x : Double) -> Double

    正弦函数近似 (泰勒级数)

    slenderness_ratio

    fn slenderness_ratio(length : Double, mu : Double, inertia : Double, area : Double) -> Double

    长细比 λ = μL/i

    solve2x2

    fn solve2x2(a : Double, b : Double, c : Double, d : Double, e : Double, f : Double) -> (Double, Double)

    求解2x2线性方程组 [a b; c d] * [x; y] = [e; f]

    solve3x3

    fn solve3x3(a11 : Double, a12 : Double, a13 : Double, a21 : Double, a22 : Double, a23 : Double, a31 : Double, a32 : Double, a33 : Double, b1 : Double, b2 : Double, b3 : Double) -> (Double, Double, Double)

    求解3x3线性方程组 (克莱姆法则) 返回 (x, y, z)

    square

    fn square(x : Double) -> Double

    计算平方

    stability_capacity

    fn stability_capacity(phi : Double, area : Double, f : Double) -> Double

    折减系数法计算稳定承载力 N = φ * A * f phi: 稳定系数, a: 截面积, f: 设计强度

    stability_factor_steel_q235

    fn stability_factor_steel_q235(lambda : Double) -> Double

    查表或计算稳定系数 (简化经验公式) 对于 Q235 钢,当 λ <= 100 时 φ ≈ 1 - 0.00668λ 当 100 < λ <= 150 时 φ ≈ 1.1 - 0.0107λ (近似)

    three_hinged_arch_thrust_point_mid

    fn three_hinged_arch_thrust_point_mid(p : Double, l : Double, f : Double) -> Double

    三铰拱的水平推力 (跨中集中力) H = PL / (4f)

    three_hinged_arch_thrust_uniform

    fn three_hinged_arch_thrust_uniform(q : Double, l : Double, f : Double) -> Double

    三铰拱的水平推力 (竖向均布荷载) H = qL² / (8f) f: 拱的矢高

    three_moment_coefficients

    fn three_moment_coefficients(l_left : Double, l_right : Double) -> (Double, Double, Double)

    三弯矩方程系数 对于等截面连续梁: M_{n-1}L_n + 2M_n*(L_n + L_{n+1}) + M_{n+1}L_{n+1} = -6Σ(荷载项) 返回系数 (a, b, c) 即 aM_{n-1} + bM_n + c*M_{n+1} = rhs

    three_moment_rhs_uniform

    fn three_moment_rhs_uniform(q_left : Double, l_left : Double, q_right : Double, l_right : Double) -> Double

    三弯矩方程右端项 - 均布荷载 左跨均布荷载 q_l,右跨均布荷载 q_r rhs = -6 * (q_lL_l³/24/L_l + q_rL_r³/24/L_r) = -(q_lL_l² + q_rL_r²)/4

    torsion_strain_energy

    fn torsion_strain_energy(t : Double, l : Double, g : Double, ip : Double) -> Double

    扭转应变能 U = T²L / (2GIp)

    transformed_area

    fn transformed_area(ac : Double, as_ : Double, alpha_e : Double) -> Double

    换算截面法 - 钢筋混凝土组合截面 换算面积 A₀ = Ac + αₑ*As alpha_e = Es/Ec

    transformed_inertia

    fn transformed_inertia(ic : Double, as_ : Double, alpha_e : Double, d : Double, x : Double) -> Double

    换算惯性矩 (近似,钢筋在受拉侧) I₀ = Ic + αₑAs(d-x)²

    translate2d

    fn translate2d(x : Double, y : Double, dx : Double, dy : Double) -> (Double, Double)

    二维平移

    trapezoid_integral

    fn trapezoid_integral(fa : Double, fb : Double, length : Double) -> Double

    梯形积分法 (单段) 积分 f 在 [a, b] 上的值,给定 f(a) 和 f(b)

    triangle_area_coords

    fn triangle_area_coords(x1 : Double, y1 : Double, x2 : Double, y2 : Double, x3 : Double, y3 : Double) -> Double

    计算三角形面积 (给定三点坐标)

    triangle_area_heron

    fn triangle_area_heron(a : Double, b : Double, c : Double) -> Double

    计算三角形面积 (给定三边长,海伦公式)

    truss_joint_2bars

    fn truss_joint_2bars(fx : Double, fy : Double, angle1_deg : Double, angle2_deg : Double) -> (Double, Double)

    计算桁架节点法 - 两杆交汇节点 给定两杆角度和外力,求两杆内力 角度相对于水平方向,逆时针为正 返回 (杆1内力, 杆2内力),正为拉力

    truss_triangle

    fn truss_triangle(l : Double, h : Double, p : Double) -> (Double, Double, Double)

    简单三角形桁架分析 三节点桁架,底边水平,顶点在上方 给定底边长度 L,高度 h,顶点荷载 P (向下为正) 返回 (左斜杆内力, 右斜杆内力, 底杆内力)

    vec2d_length

    fn vec2d_length(x : Double, y : Double) -> Double

    二维向量长度

    virtual_work_axial

    fn virtual_work_axial(n_actual : Double, n_virtual : Double, l : Double, e : Double, a : Double) -> Double

    单位荷载法求位移 - 轴力贡献 Δ_N = Σ(N * N̄ * L) / (E * A)

    virtual_work_bending

    fn virtual_work_bending(m_actual : Double, m_virtual : Double, l : Double, e : Double, i : Double) -> Double

    单位荷载法求位移 Δ = Σ(M * M̄ * L) / (E * I) 这里提供单段的贡献计算

    virtual_work_shear

    fn virtual_work_shear(v_actual : Double, v_virtual : Double, l : Double, g : Double, a : Double, kappa : Double) -> Double

    单位荷载法求位移 - 剪力贡献 Δ_V = Σ(κ * V * V̄ * L) / (G * A)