You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

356 lines
20 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# -*- coding: utf-8 -*-
"""
Проверка модуля calc/gost34233_shells.py (обычные assert'ы, без pytest).
Запуск:
tools/freecad/squashfs-root/usr/bin/python calc/tests/test_gost34233_shells.py
(или python3 ...)
Числовых примеров расчёта в ГОСТ 34233.1/.2/.3/.4-2017 и ГОСТ Р 54522-2011 нет
(поиск по тексту стандартов: «Пример» — только описательные упоминания). Поэтому:
(1) воспроизводятся табличные значения стандартов (табл. А.3, Б.7, Г.1 и т. п.);
(2) формулы проверяются ручным счётом на простых числах (арифметика — в комментариях);
(3) формулы K6 (79), K7 (83) сверяются с точками графиков рис. 19, 20 ГОСТ 34233.2 (p032).
"""
import math
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
import gost34233_shells as G # noqa: E402
N_PASS = 0
def close(a, b, rel=1e-6, abs_=1e-9, msg=""):
global N_PASS
assert a is not None and abs(a - b) <= max(abs_, rel * abs(b)), f"{msg}: {a!r} != {b!r}"
N_PASS += 1
def true(x, msg=""):
global N_PASS
assert x, msg
N_PASS += 1
# ---------------------------------------------------------------------------
# 1. Допускаемые напряжения ГОСТ 34233.1 — воспроизведение табл. А.3 и правил
# ---------------------------------------------------------------------------
def test_allowable_table_A3():
s = lambda *a, **k: G.allowable_stress(*a, **k)["result"]["sigma"]
# табл. А.3 (p022), графа 12Х18Н10Т: 20 °C -> 184, 100 -> 174, 200 -> 160
close(s("12Х18Н10Т", 20), 184.0, msg="А.3 20°C")
close(s("12Х18Н10Т", 100), 174.0, msg="А.3 100°C")
close(s("12Х18Н10Т", 200), 160.0, msg="А.3 200°C")
# графа 08Х18Н10Т: 200 °C -> 140; 430 °C -> 100.5
close(s("08Х18Н10Т", 200), 140.0, msg="А.3 08Х18Н10Т 200")
close(s("08Х18Н10Т", 430), 100.5, msg="А.3 08Х18Н10Т 430")
# латинские буквы в марке -> нормализация
close(s("12X18H10T", 200), 160.0, msg="латиница")
# прим. 1 к табл. А.3: t < 20 °C -> как при 20 °C
close(s("12Х18Н10Т", -60), 184.0, msg="t<20")
# прим. 2: интерполяция с округлением до 0.5 МПа вниз:
# t = 110: 174 + (168 − 174)·10/50 = 172.8 -> 172.5
close(s("12Х18Н10Т", 110), 172.5, msg="интерп. 110")
# t = 125: 174 − 6·25/50 = 171.0 -> 171.0 (уже кратно 0.5)
close(s("12Х18Н10Т", 125), 171.0, msg="интерп. 125")
# прим. 3: поковки 12Х18Н10Т ×0.83: 160·0.83 = 132.8; 184·0.83 = 152.72
close(s("12Х18Н10Т", 200, "forging"), 132.8, msg="поковка 200")
close(s("12Х18Н10Т", 20, "forging"), 152.72, msg="поковка 20")
# прим. 5: поковки 08Х18Н10Т ×0.95: 168·0.95 = 159.6
close(s("08Х18Н10Т", 20, "forging"), 159.6, msg="поковка 08Х18Н10Т")
# прим. 4: сорт 12Х18Н10Т × Rp0.2*/240; при Rp0.2* = 240 множитель 1
close(s("12Х18Н10Т", 200, "bar", Rp02_bar_20=240.0), 160.0, msg="сорт")
# выше 520 °C — зависит от ресурса -> ошибка
try:
s("12Х18Н10Т", 550)
raise AssertionError("ожидалась ошибка t > 520")
except ValueError:
pass
def test_allowable_test_conditions():
s = lambda *a, **k: G.allowable_stress(*a, **k)["result"]["sigma"]
# ф. (6): [σ]_и = Rp1.0/20 / n_т; лист: 276/1.1 = 250.909; 276/1.2 = 230.0
close(s("12Х18Н10Т", 200, "wrought", "test_hydro"), 276 / 1.1, msg="гидро лист")
close(s("12Х18Н10Т", 200, "wrought", "test_pneumatic"), 230.0, msg="пневмо лист")
# поковка: Rp1.0/20 = 276/1.2 = 230 (прим. к табл. Б.7); 230/1.1 = 209.0909
close(s("12Х18Н10Т", 20, "forging", "test_hydro"), 230 / 1.1, msg="гидро поковка")
def test_allowable_casting():
r = G.allowable_stress("12Х18Н9ТЛ", 200, "casting", "work", individual_ndt=True)
v = r["values"]
# СТ ЦКБА 005.2 табл. 13.14.3 (p237): 200 °C σ0.2 = 167, σв = 383
close(v["Rp02_t"], 167.0); close(v["Rm_t"], 383.0)
# ф. (2) с Rp0.2: min(167/1.5 = 111.333; 383/3.0 = 127.667) = 111.333; ×η 0.8 = 89.0667
close(r["result"]["sigma"], 0.8 * 167 / 1.5, msg="отливка 200 η=0.8")
# η = 0.7 (без индивидуального НК): 0.7·111.333 = 77.933
close(G.allowable_stress("12Х18Н9ТЛ", 200, "casting")["result"]["sigma"], 0.7 * 167 / 1.5)
# 20 °C: min(196/1.5 = 130.667; 441/3 = 147) = 130.667 ×0.8 = 104.533
close(G.allowable_stress("12Х18Н9ТЛ", 20, casting_factor=0.8)["result"]["sigma"], 0.8 * 196 / 1.5)
# 100 °C: min(196/1.5; 412/3 = 137.33) = 130.667 ×0.8
close(G.allowable_stress("12Х18Н9ТЛ", 100, casting_factor=0.8)["result"]["sigma"], 0.8 * 196 / 1.5)
# испытание (6), Rp1.0 нет -> Rp0.2: 0.8·196/1.1 = 142.545
close(G.allowable_stress("12Х18Н9ТЛ", 200, "casting", "test_hydro", 0.8)["result"]["sigma"], 0.8 * 196 / 1.1)
# допускаемый n_т = 1.3 при расчёте по Rp0.2: 200 °C min(167/1.3 = 128.46; 127.67) = 127.67 ×0.8 = 102.13
close(G.allowable_stress("12Х18Н9ТЛ", 200, casting_factor=0.8, nT_rp02=1.3)["result"]["sigma"], 0.8 * 383 / 3)
true(any(f.startswith("ASSUMPTION") for f in r["flags"]), "флаг допущения по п. 8.6")
def test_allowable_not_in_annex():
# 14Х17Н2 при 20 °C — ф. (1): min(539/1.5 = 359.33; 686/2.4 = 285.83) = 285.83 (ГОСТ 25054 p003)
close(G.allowable_stress("14Х17Н2", 20, "forging")["result"]["sigma"], 686 / 2.4)
# при 200 °C данных нет -> None и флаг UNVERIFIED
r = G.allowable_stress("20Х13", 200, "forging")
true(r["result"]["sigma"] is None and any("UNVERIFIED" in f for f in r["flags"]), "нет данных 20Х13")
# с пользовательскими свойствами (п. 8.6): min(400/1.5; 600/2.4 = 250) = 250
r = G.allowable_stress("20Х13", 200, "forging", props={"Rp02_t": 400, "Rm_t": 600, "class": "chromium"})
close(r["result"]["sigma"], 250.0)
def test_E_alpha():
r = G.allowable_stress("12Х18Н10Т", 200)
close(r["values"]["E"], 1.97e5, msg="табл. В.1") # p032
close(r["values"]["alpha_1e6"], 17.0, msg="табл. Г.1") # p033, 20–200
close(G.allowable_stress("12Х18Н10Т", 100)["values"]["alpha_1e6"], 16.6)
def test_test_calc_needed():
# п. 8.4: 1.35·184/160 = 1.5525; p = 10 -> предел 15.525 МПа
r = G.test_calc_needed(10.0, 15.0, 184.0, 160.0)
close(r["values"]["p_test_limit"], 15.525)
true(r["result"]["test_calc_required"] is False)
true(G.test_calc_needed(10.0, 16.0, 184.0, 160.0)["result"]["test_calc_required"] is True)
# ---------------------------------------------------------------------------
# 2. Болты: ГОСТ 34233.4 прил. Г
# ---------------------------------------------------------------------------
def test_bolts():
b = lambda *a, **k: G.bolt_allowable(*a, **k)["result"]["sigma_b"]
# табл. Г.1 (p032) 14Х17Н2: 20 °C 232, 200 °C 220
# рабочие (Г.4): 1.0·1.1·1.0·220 = 242; затяжка (Г.3): 1.2·1.0·1.1·1.0·232 = 306.24;
# испытание (Г.4, K_у.р = 1.35): 1.35·1.1·1.0·232 = 344.52
close(b("14Х17Н2", 200, "work", K_uz=1.1), 242.0)
close(b("14Х17Н2", 200, "assembly", K_uz=1.1), 306.24)
close(b("14Х17Н2", 200, "test", K_uz=1.1), 344.52)
# табл. Г.1 (p031) 12Х18Н10Т: 20 -> 110; 150 °C (интерп. 100–200): (105 + 98)/2 = 101.5
close(b("12Х18Н10Т", 20), 110.0)
close(b("12Х18Н10Т", 150), 101.5)
close(b("45Х14Н14В2М", 200), 150.0)
close(b("40Х", 300), 222.0)
close(b("35", 100), 126.0)
close(b("ХН35ВТ", 450), 186.0)
close(b("07Х16Н6", 350), 307.0)
# в табл. Г.1 нет 08Х18Н10Т, 10Х11Н23Т3МР
true(b("08Х18Н10Т", 20) is None and b("10Х11Н23Т3МР", 20) is None)
# ---------------------------------------------------------------------------
# 3. Обечайки и днища: ГОСТ 34233.2
# ---------------------------------------------------------------------------
def test_cyl_internal():
# D = 100, s = 6, c = 1, p = 10, [σ] = 150, φ = 1:
# s_p = 10·100/(2·150 − 10) = 1000/290 = 3.448276 (2)
# [p] = 2·150·5/(100 + 5) = 1500/105 = 14.285714 (3)
r = G.cyl_internal(100, 6, 1, 10, 150)
close(r["result"]["s_p"], 1000 / 290)
close(r["result"]["p_allow"], 1500 / 105)
true(r["ok"])
# при s = 4: s_p + c = 4.448 > 4 -> не выполнено
true(not G.cyl_internal(100, 4, 1, 10, 150)["ok"])
# D ≥ 200: (s−c)/D = 25/250 = 0.1 — на границе; 26/250 > 0.1 -> неприменимо
true(not G.cyl_internal(250, 27, 1, 10, 150)["checks"][2]["ok"])
def test_cyl_axial_bending():
# D = 100, s = 6, c = 1, [σ] = 150, E = 2e5, n_y = 2.4
# [F]_раст = π·(100 + 5)·5·150 = π·78750 = 247400.4 Н (13)
# [F]_E1 = 31e-5·2e5/2.4·100²·(100·5/100)^2.5 = 25.8333·1e4·55.9017 = 14 441 272 Н (16)
# [F]_сж = 247400.4/√(1 + (247400.4/14441272)²) (14)
# [M]_п = π/4·100·105·5·150 = 6 185 010 Н·мм (22); [M]_E = 8.9e-5·2e5/2.4·1e6·55.9017 = 4.14604e8 (23)
r = G.cyl_axial_bending(100, 6, 1, 150, 2e5, F_tension=1e5, M=2e6)
v = r["values"]
Ft = math.pi * 105 * 5 * 150
close(v["F_t_allow"], Ft)
FE1 = 31e-5 * 2e5 / 2.4 * 1e4 * 5 ** 2.5
close(v["F_E1"], FE1)
close(v["F_c_allow"], Ft / math.sqrt(1 + (Ft / FE1) ** 2))
Mp = math.pi / 4 * 100 * 105 * 5 * 150
ME = 8.9e-5 * 2e5 / 2.4 * 1e6 * 5 ** 2.5
close(v["M_p"], Mp); close(v["M_E"], ME)
Ma = Mp / math.sqrt(1 + (Mp / ME) ** 2)
close(v["M_allow"], Ma)
# линейное взаимодействие 1e5/247400 + 2e6/6.1847e6 = 0.4042 + 0.3234 = 0.7276
close(r["checks"][1]["value"], 1e5 / Ft + 2e6 / Ma)
# (23): стандарт приводит и вторую запись [M]_E = (D/3.5)·[F]_E1; она приближённая:
# 8.9/31 = 0.28710 против 1/3.5 = 0.28571 (расхождение 0.48 %) -> проверка с допуском 1 %
close(v["M_E"], 100 / 3.5 * FE1, rel=1e-2)
def test_ellip_head():
# D = 100, H = 25 -> R = 100² /(4·25) = 100 (45)
# s1p = 10·100/(2·150 − 0.5·10) = 1000/295 = 3.389831 (43)
# [p] = 2·150·5/(100 + 2.5) = 1500/102.5 = 14.634146 (44)
r = G.ellip_head(100, 6, 1, 10, 150)
close(r["values"]["R"], 100.0)
close(r["result"]["s1p"], 1000 / 295)
close(r["result"]["p_allow"], 1500 / 102.5)
true(r["ok"])
def test_cone():
# α = 0 -> коническая = цилиндрическая при D_k = D: (101) = (3)
r = G.cone_internal(100, 6, 1, 10, 150, 0.0, D_k=100)
close(r["result"]["p_allow_smooth"], 1500 / 105)
# α = 30°, D_k = 100 задан: s_к.p = 10·100/(300 − 10)/cos30° = 3.448276/0.866025 = 3.981729
r = G.cone_internal(100, 6, 1, 10, 150, 30.0, D_k=100)
close(r["result"]["s_kp"], 1000 / 290 / math.cos(math.radians(30)))
# (114): D = 1000, s1−c = s2−c = 10, α = 30°, χ1 = 1:
# 0.4·√100·tg30° = 4·0.577350 = 2.309401; √((1 + 1)/(2·0.866025)·1) = √1.154701 = 1.074570
# β = 2.309401/(1 + 1.074570) − 0.25 = 1.113215 − 0.25 = 0.863215
close(G._beta_114(1000, 10, 10, math.radians(30), 1.0), 2.309401 / 2.074570 - 0.25, rel=1e-5)
def test_flat_cover():
# D_R = 100, K = 0.41, K0 = 1, p = 6.3, [σ] = 132.8:
# s1p = 0.41·100·√(6.3/132.8) = 41·0.2178069 = 8.930083 (72)
# s1 = 20, c = 1: (s1−c)/D_p = 0.19 > 0.11 -> K_p = 2.2/(1 + √(1 + 1.14²)) = 2.2/2.516436 = 0.874255 (70)
# [p] = (19/41)²·132.8 = 0.2147531·132.8 = 28.5192 (75); K_p·[p] = 24.9330
r = G.flat_cover(100, 20, 1, 6.3, 132.8, 0.41)
close(r["result"]["s1p"], 41 * math.sqrt(6.3 / 132.8))
close(r["values"]["K_p"], 2.2 / (1 + math.sqrt(1 + 1.14 ** 2)))
close(r["values"]["p_allow_75"], (19 / 41) ** 2 * 132.8)
close(r["result"]["p_allow"], (19 / 41) ** 2 * 132.8 * 2.2 / (1 + math.sqrt(1 + 1.14 ** 2)))
# табл. 4: тип 12 -> 0.41; тип 11 -> 0.40; тип 3 при (s−c)/(s1−c) = 0.2 -> 0.45
true(G.flat_K(12)[0] == 0.41 and G.flat_K(11)[0] == 0.40 and G.flat_K(3, 5, 21, 1)[0] == 0.45)
# (73): d/D_p = 0.2 -> √(1 + 0.2 + 0.04) = √1.24 = 1.113553
close(G.K0_single(20, 100), math.sqrt(1.24))
# (74): Σd/D_p = 0.2 -> √((1 − 0.008)/(1 − 0.2)) = √1.24 = 1.113553 (совпадает с (73) для одного)
close(G.K0_multi(20, 100), math.sqrt(1.24))
def test_flat_cover_edge_moment():
# (79) при D3/D_с.п = 1 -> K6 = 0.41 (начало графика рис. 19, p032)
r = G.flat_cover_edge_moment(100, 100, 20, 1, 6.3, 132.8, 1.0 * 0.785 * 6.3 * 100 ** 2)
close(r["result"]["K6"], 0.41)
# рис. 19: ψ1 = 1.0, D3/D_с.п = 1.5 -> по графику ≈ 0.53; по (79): 0.41·√((1 + 1.5)/1.5) = 0.529312
Qd = 0.785 * 6.3 * 100 ** 2
r = G.flat_cover_edge_moment(100, 150, 20, 1, 6.3, 132.8, 1.0 * Qd)
close(r["result"]["K6"], 0.41 * math.sqrt(2.5 / 1.5))
true(abs(r["result"]["K6"] - 0.53) < 0.005, "K6 vs рис. 19 (ψ1 = 1.0)")
# рис. 19: ψ1 = 3.5, 1.5 -> ≈ 0.84; (79): 0.41·√((1 + 3·3.5·0.5)/1.5) = 0.41·√4.1667 = 0.836905
r = G.flat_cover_edge_moment(100, 150, 20, 1, 6.3, 132.8, 3.5 * Qd)
true(abs(r["result"]["K6"] - 0.84) < 0.01, "K6 vs рис. 19 (ψ1 = 3.5)")
# рис. 20: K7 при 1.5 ≈ 0.56; (83): 0.8·√0.5 = 0.565685
close(r["values"]["K7"], 0.8 * math.sqrt(0.5))
# (82): Φ = 80000/132.8 = 602.41 мм²; s2 ≥ max(0.565685·√602.41; 0.6·602.41/100) + 1 = 13.884 + 1
r = G.flat_cover_edge_moment(100, 150, 20, 1, 6.3, 132.8, 80000)
Phi = 80000 / 132.8
close(r["result"]["s2_req"], max(0.8 * math.sqrt(0.5) * math.sqrt(Phi), 0.6 * Phi / 100) + 1)
# ---------------------------------------------------------------------------
# 4. ГОСТ Р 54522-2011
# ---------------------------------------------------------------------------
def test_54522():
# [σ] 12Х18Н10Т при 200 °C: min(172/1.5 = 114.667; 470/2.4 = 195.8) = 114.667 (табл. А.1, p025; ф. (1))
sa = G.allowable_stress_54522("12Х18Н10Т", 200)
close(sa["result"]["sigma"], 172 / 1.5)
# гидроиспытание: 196/1.1 = 178.18
close(G.allowable_stress_54522("12Х18Н10Т", 20, "test_hydro")["result"]["sigma"], 196 / 1.1)
# D = 30, S = 8, c = 1, p = 25, [σ] = 114.667:
# β_R = exp(25/114.667) = exp(0.218023) = 1.243628; S_R = 0.5·30·0.243628 = 3.65442 (6), (7)
# β = (30 + 14)/30 = 1.466667; ln β = 0.382992; [p] = 114.667·0.382992 = 43.9164 (8), (9)
r = G.thick_cyl_54522(30, 8, 1, 25, 200, "12Х18Н10Т")
close(r["values"]["beta_R"], math.exp(25 / (172 / 1.5)))
close(r["result"]["S_R"], 15 * (math.exp(25 / (172 / 1.5)) - 1))
close(r["result"]["p_allow"], 172 / 1.5 * math.log(44 / 30))
true(r["ok"])
# Предельный переход к тонкостенной формуле: (s−c)/D -> 0 => ln β ≈ 2(s−c)/D,
# [p]_54522 / [p]_34233.2(3) -> 1. D = 1000, s − c = 1: отношение = 1 + O(1e-6)
p1 = G.thick_cyl_54522(1000, 2, 1, 0.1, sigma=100.0)["result"]["p_allow"]
p2 = G.cyl_internal(1000, 2, 1, 0.1, 100.0)["result"]["p_allow"]
close(p1 / p2, 1.0, rel=1e-5)
# отливка через 54522 (вне области применения): η·min(167/1.5; 383/2.4) = 0.8·111.333
r = G.thick_cyl_54522(30, 8, 1, 25, 200, "12Х18Н9ТЛ", individual_ndt=True)
close(r["result"]["sigma"], 0.8 * 167 / 1.5)
true(any("ASSUMPTION" in f for f in r["flags"]))
# кованое плоское днище (21), (25): D = 100, r = 0, S1 = 20, c = 1, [σ] = 100, p = 10
# (S1−c)/D_R = 0.19 > 0.11 -> K_p = 0.874255 (22); S1R = 0.45·100·√(10/(100·0.874255)) = 15.2193
r = G.flat_head_forged_54522(100, 20, 1, 10, 100.0)
Kp = 2.2 / (1 + math.sqrt(1 + 1.14 ** 2))
close(r["result"]["S1R"], 45 * math.sqrt(10 / (100 * Kp)))
close(r["result"]["p_allow"], (19 / 45) ** 2 * 100 * Kp)
# крышка ВД (60): F_S/F_Q = 1, D3 = D_R -> числитель D_R; D4 − 2d6 − Σd = 140 − 40 − 0 = D_R;
# H3 = 12, c = 1: (H3 − c)/D4 = 11/140 = 0.079 ≤ 0.11 -> K_p = 1 => H3p = 0.41·D_R·√(p/[σ]) = 12.9653
r = G.flat_cover_hp_54522(10, 100, 100, 100, 140, 20, 1.0, 1.0, 0, 12, 1)
close(r["result"]["H3p"], 0.41 * 100 * math.sqrt(10 / 100))
# ---------------------------------------------------------------------------
# 5. Укрепление отверстий: ГОСТ 34233.3
# ---------------------------------------------------------------------------
def test_openings():
# D = 100, s = 6, c = 1, p = 10, [σ] = 150, d = 20, c_s = 0:
# s_p = 1000/290 = 3.448276; √(D_p(s−c)) = √500 = 22.36068
# d0p = 0.4·22.36068 = 8.944272 (24)
# d0 = min(2·(5/3.448276 − 0.8)·22.36068; 100) = 2·(1.45 − 0.8)·22.36068 = 29.06888 (26)
r = G.opening_no_reinforcement(100, 6, 1, 20, 10, 150)
close(r["values"]["d0p"], 0.4 * math.sqrt(500))
close(r["result"]["d0"], 1.3 * math.sqrt(500))
true(r["result"]["no_reinforcement_needed"])
# d = 40 > 29.07 -> укрепление нужно
true(not G.opening_no_reinforcement(100, 6, 1, 40, 10, 150)["result"]["no_reinforcement_needed"])
# V по (32), штуцер s1 = 4, l1 = 50, d = 50, без кольца и внутренней части:
# l1p = min(50; 1.25·√(50·4)) = 1.25·14.142136 = 17.677670 (17); L0 = l_p = 22.36068 (19), (20)
# числитель = 1 + 17.67767·4/(22.36068·5) = 1 + 70.71068/111.8034 = 1.632456
# знаменатель = 1 + 0.5·(50 − 8.944272)/22.36068 + 1·(50/100)·(17.67767/22.36068)
# = 1 + 0.918034 + 0.395285 = 2.313319
# V = 1.632456/2.313319 = 0.705678; [p] = 2·1·1·150·5·0.705678/(100 + 5·0.705678) = 10.2244 (31)
r = G.opening_allowable_pressure(100, 6, 1, 50, 150, p=10, s1=4, l1=50)
num = 1 + 1.25 * math.sqrt(200) * 4 / (math.sqrt(500) * 5)
den = 1 + 0.5 * (50 - 0.4 * math.sqrt(500)) / math.sqrt(500) + 0.5 * 1.25 * math.sqrt(200) / math.sqrt(500)
V = num / den
close(r["result"]["V"], V)
close(r["result"]["p_allow"], 2 * 150 * 5 * V / (100 + 5 * V))
# малое отверстие d = 20: V = min(1; 1.0392) = 1 -> [p] = [p] гладкой обечайки (3) = 14.2857
r = G.opening_allowable_pressure(100, 6, 1, 20, 150, p=10, s1=4, l1=50)
close(r["result"]["V"], 1.0)
close(r["result"]["p_allow"], 1500 / 105)
# ---------------------------------------------------------------------------
# 6. Критерии МКЭ (п. 8.10 ГОСТ 34233.1)
# ---------------------------------------------------------------------------
def test_fea():
c = G.fea_criteria(100.0)["criteria"]
# (12): [σ]; [σ]_м = 1.5[σ]; [σ]_R = 3[σ]; (14) 0.5[σ]; (15) 0.8[σ]
close(c["sigma_m"]["allow"], 100); close(c["sigma_m_or_mL_plus_b"]["allow"], 150)
close(c["total"]["allow"], 300); close(c["tau_avg"]["allow"], 50); close(c["tau_max"]["allow"], 80)
# (13): [σ]_м = [σ]; [σ]_R = 1.4[σ]
c = G.fea_criteria(100.0, creep=True)["criteria"]
close(c["sigma_m_or_mL_plus_b"]["allow"], 100); close(c["total"]["allow"], 140)
r = G.assess_linearized(90, 140, 149, 310, 100.0, tau_avg=40, tau_max=85)
oks = [ch["ok"] for ch in r["checks"]]
# 90 ≤ 100 ок; 140 ≤ 150 ок; 149 ≤ 150 ок; 310 > 300 нет; 40 ≤ 50 ок; 85 > 80 нет
true(oks == [True, True, True, False, True, False], f"assess {oks}")
r = G.assess_linearized(None, None, None, None, 100.0, creep=True, membrane=60, bending=50, rest=40)
# 60 + 0.8·50 = 100 ≤ 100 ок; 60 + 0.8·(50 + 40) = 132 ≤ 140 ок
true([ch["ok"] for ch in r["checks"]] == [True, True])
def test_report():
md = G.report_md([G.cyl_internal(100, 6, 1, 10, 150), G.fea_criteria(100.0)])
true("ф. (3)" in md and "п. 8.10" in md and "| Проверка |" in md)
if __name__ == "__main__":
tests = [v for k, v in sorted(globals().items()) if k.startswith("test_") and callable(v)]
for t in tests:
t()
print(f"OK {t.__name__}")
print(f"\nВсего тестов: {len(tests)}, утверждений: {N_PASS} — все пройдены")

Powered by TurnKey Linux.