Files
Aislo/resources/tester/test_62_2_b08_hydro_engine.py
T
eomsangdonandClaude Opus 5.5 5f056ec661 feat(b08): 4탭 홍수량 계산서 — 배수지점 측점 보조 탭 · 견본 모양 한 장 · 서버 계산(PLAN 62-2 · 62-3)
- 측점 보조 탭 = 저장된 pipe_points 측점만 읽음 · 입력은 이 탭 자기 기본값(B05/B06 · 배수유역 값과 안 이음)
- 1-1 합리식(Qd = Q × 할증) · 1-2 Kirpich 도달시간(최소 5분) · 1-3 rt = (R24/24)·(24/T)^0.557
- 2 단면검토 — 관 단면 그림 · 단면적 · 윤변 · 경심 · 경사 · n · Manning 유속 · Q = A·V · OK/NG 점선 상자 · 유출율
- 선택지(할증 2.0/1.5/1.2 · 만관/240°/유효 70 % · 관 종류별 n) · 기본값 한 파일(B08_Quantity_Hydro_Defaults.py)
- 계산 = 서버 단독(B08_Quantity_Engine_Hydro · /quantity/hydro · /quantity/hydro/calc · 최신 응답만) · 입력은 캐시만 · 어떤 파일에도 안 씀
- 흰 종이 계산서(입력 빨강 · 계산 파랑 · 주요 입력 노랑) · 쪽 표시 · 시험 test_62_2_b08_hydro_engine.py

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UoSr2sqvYtBf1dtQdus88s
2026-10-06 18:15:29 +09:00

74 lines
2.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""B08 4탭 홍수량 계산서 엔진 — 견본 입력 손계산 대조 (PLAN 62-2 · 62-3).
견본(울진 2공구 71+13) 입력: A 0.132 ㎢ · L 480 m · H 185 m · R24 305.9 · D 1,200 · S 1/20 ·
n 0.013 · 할증 1.5 · 만관. 도달시간만 Kirpich(사용자 결정).
"""
from __future__ import annotations
import math
import sys
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT))
from B08_Quantity.B08_Quantity_Engine_Hydro import compute # noqa: E402
SAMPLE = {
"factor": 1.5,
"runoff": 0.8,
"area_km2": 0.132,
"length_m": 480.0,
"height_m": 185.0,
"tc_min_minutes": 5.0,
"r24_mm": 305.9,
"region": "울진",
"return_period": 100,
"pipe_kind": "흄관",
"n": 0.013,
"diameter_mm": 1200.0,
"slope_denominator": 20.0,
"section": "full",
}
def test_견본_입력_손계산과_같다() -> None:
out = compute(SAMPLE)
# Kirpich: 0.0663 × 0.48^0.77 × (185/480)^-0.385 = 0.05439 hr(3.26 분) → 최소 5 분
assert out["tc_raw_hr"] * 60 == pytest.approx(3.2632, abs=1e-3)
assert out["tc_hr"] == pytest.approx(5 / 60) and out["tc_floored"]
# rt = 305.9/24 × (24 / (5/60))^0.557 = 12.7458 × 288^0.557
assert out["intensity"] == pytest.approx(298.71, abs=0.01)
assert out["flow"] == pytest.approx(0.8 * 298.71 * 0.132 / 3.6, rel=1e-4) # 8.762
assert out["design_flow"] == pytest.approx(1.5 * out["flow"])
# 만관 Ø1.2: A 1.1310 · P 3.7699 · R 0.3 · V = (1/0.013)·0.3^(2/3)·0.05^0.5 = 7.708
assert out["section_area"] == pytest.approx(1.13097, abs=1e-4)
assert out["radius"] == pytest.approx(0.3)
assert out["velocity"] == pytest.approx(7.708, abs=1e-3)
assert out["capacity"] == pytest.approx(8.718, abs=1e-3)
assert out["ok"] is False # 8.718 < Qd 13.14
assert out["ratio_pct"] == pytest.approx(8.718 / 13.143 * 100, abs=0.1)
def test_최소_도달시간을_끄면_Kirpich_값_그대로() -> None:
out = compute({**SAMPLE, "tc_min_minutes": 0})
assert out["tc_hr"] == out["tc_raw_hr"] and not out["tc_floored"]
def test_단면_가정과_관_종류() -> None:
d = 1.2
arc = compute({**SAMPLE, "section": "arc240"})
assert arc["section_area"] == pytest.approx(0.63185 * d * d, abs=1e-4)
assert arc["perimeter"] == pytest.approx(math.pi * d * 2 / 3)
eff = compute({**SAMPLE, "section": "eff70"})
assert eff["section_area"] == pytest.approx(0.7 * math.pi * d * d / 4)
assert eff["radius"] == pytest.approx(d / 4)
# n 비우면 관 종류 값(파형강관 0.024)
kind = compute({**SAMPLE, "n": None, "pipe_kind": "파형강관"})
assert kind["n"] == 0.024
# 할증 · 단면만 바꾸면 홍수량 쪽 Q 는 그대로
assert compute({**SAMPLE, "factor": 2.0})["flow"] == pytest.approx(arc["flow"])