Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
cbe2187
Release 0.2.0
claude Nov 20, 2026
d191dc2
Fix the CI test run and let a release go out without macOS; release 0…
claude Nov 20, 2026
d670ed4
Merge the already-squashed 0.2.0 branch tip (no content change)
claude Nov 20, 2026
f4efd69
Publish a release from "Run workflow" when a tag cannot be pushed
claude Nov 20, 2026
71fe29b
Merge the already-squashed branch tip (no content change)
claude Nov 20, 2026
6064007
Refine the contact low-rank update; release only with Windows and Lin…
claude Nov 20, 2026
282d58c
Merge the already-squashed branch tip (no content change)
claude Nov 20, 2026
3238296
i18n core: tr() with a Korean-keyed English catalog, language setting…
claude Nov 20, 2026
fb2940d
English UI check and a script for all store screenshots per language
claude Nov 20, 2026
8276c58
Merge the already-squashed branch tip (no content change)
claude Nov 20, 2026
db735d2
English help topics; fix three outdated Korean help texts
claude Nov 20, 2026
e788314
English for the PDF report, update/about/problem-report/material dialogs
claude Nov 20, 2026
4f014d1
WIP: English translation in progress (steps, main window, summary, so…
claude Nov 20, 2026
ef64a47
English for the seven step panels (ui/steps.py)
claude Nov 20, 2026
b5be2ad
English for verdicts and descriptions; unify shared translations; doc…
claude Nov 20, 2026
bff34df
English labels that fit the side panel; US spelling; steps are at the…
claude Nov 20, 2026
911f9a1
English store screenshots (docs/screenshots/en), labels that fit them
claude Nov 20, 2026
d19c7cc
Release 0.3.0 (English UI)
claude Nov 20, 2026
fec19fb
Merge the already-squashed branch tip (no content change)
claude Nov 20, 2026
412bf3e
Store screenshots in English (replace the Korean set)
claude Nov 20, 2026
379c8b3
Merge the already-squashed branch tip (no content change)
claude Nov 20, 2026
96341ba
Merge the already-squashed branch tip (no content change)
claude Nov 21, 2026
ab988c8
PARDISO (MKL) direct solver with SuperLU fallback; faster transient h…
claude Nov 21, 2026
a11e5d9
Tests for the PARDISO path: agreement with SuperLU, singular/indefini…
claude Nov 21, 2026
ff3aeff
Reuse PARDISO orderings by pattern, parallel METIS; nonlinear tangent…
claude Nov 21, 2026
7345eb9
KStruct logo: the letter K as a truss
claude Nov 21, 2026
bc4b581
Store screenshots with the logo in the header bar
claude Nov 21, 2026
9e86918
Release 0.3.1 (PARDISO solver, logo)
claude Nov 23, 2026
bf9324f
Contact menu: bug reports to GitHub Issues, questions and ideas to Gi…
claude Nov 24, 2026
c171310
Merge the already-squashed branch tip (no content change)
claude Nov 24, 2026
d7f9adc
Release 0.3.2 (contact menu: GitHub Issues and Discussions)
claude Nov 24, 2026
b0de890
docs: 다음 개선 계획(성능·기능·UI·조작성) 추가
claude Nov 29, 2026
8afa259
Merge branch 'ccr-da6cba6f-qulklh' of https://github.com/MinaryHub/KS…
claude Nov 29, 2026
dbd5706
조작성 묶음(v0.4): 표준 보기·면 선택 도우미·부품 단독 보기·단축키·끌어다 놓기·오류 부품 표시
claude Nov 29, 2026
42e09cd
성능(v0.5): 벤치마크 저장소화, 마찰 접촉 121 s → 56 s와 예압 마찰 미수렴 수정
claude Nov 29, 2026
cd5e910
성능(v0.5): 과도 열 10.1 s → 6.4 s (복사·k(T)는 이전 분해를 전처리로 쓰는 PCG)
claude Nov 29, 2026
1f15441
성능(v0.5): 메싱 작업 프로세스 예열·재사용, 좌굴 20 → 16 s, 비선형 15 → 11 s
claude Nov 29, 2026
b1e515c
CI: 주간 벤치마크 작업(결과 지문 확인, 사례별 허용오차)
claude Nov 29, 2026
c17b9ab
패키징(v0.5): 안 쓰는 VTK 모듈 제외·VTK strip(Linux 609 → 560 MB), GUI selftest…
claude Nov 29, 2026
ff60dfb
3D 뷰: 영역 선택 직전에 렌더링(반투명을 켰다 끈 뒤 가려진 면이 잡히던 문제)
claude Nov 29, 2026
2775f91
버전 0.5.0
claude Nov 29, 2026
995c983
Merge remote-tracking branch 'origin/ccr-da6cba6f-qulklh' into ccr-da…
claude Nov 29, 2026
1fb632c
툴바: '화면 맞춤'을 3D 뷰 보기 막대로 옮김(1280 px 여유 115 → 233 px), 잘림 검사는 화면이 작으면 건너뜀
claude Nov 29, 2026
7783ab9
Merge remote-tracking branch 'origin/ccr-da6cba6f-qulklh' into ccr-da…
claude Nov 29, 2026
6eee44b
결과 묶음(v0.6): 최대·최소 표시·배율·색 범위, 재료 바꿔 보기, 케이스 포락, 메시 확인, 둘러보기
claude Nov 29, 2026
1d85967
테스트: 케이스 상자에 포락 항목이 더해진 것을 반영
claude Nov 29, 2026
338e40c
버전 0.6.0
claude Nov 29, 2026
7f3dd85
Merge remote-tracking branch 'origin/ccr-da6cba6f-qulklh' into ccr-da…
claude Nov 29, 2026
4378975
테스트: 테스트마다 남은 창의 GL 자원 해제(Xvfb/Mesa 세그폴트 완화)
claude Nov 29, 2026
af1dcea
진동 응답(주파수 응답) 해석 추가 (FT-4)
claude Nov 29, 2026
1d9abf6
설계 조언: 판정 위치별 개선 방법과 선형 비례 수치 (FT-6)
claude Nov 29, 2026
b642117
비선형 해석에 접촉(마찰 없음)·볼트 (FT-5), 단위·수식 입력 (UX-9), macOS CI 선택 사항 (UI-5)
claude Nov 29, 2026
0c8bd74
3D 뷰 측정 도구: 면적·구멍 지름·축, 두 점 거리 (UX-3)
claude Nov 29, 2026
e230977
결과 비교: 기준 결과 고정, 나란히 숫자 비교, 같은 메시의 차이 색 지도 (UX-8)
claude Nov 29, 2026
0768ded
조건 묶음(템플릿)과 대칭면 도우미 (UX-7)
claude Nov 29, 2026
c51388c
v0.7.0: 적용 범위 묶음 (진동 응답, 설계 조언, 비선형+접촉·볼트, 측정·조건 묶음·결과 비교·단위 입력)
claude Nov 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ on:
- cron: "17 3 * * 1" # Mondays 03:17 UTC
workflow_dispatch:

# The macOS leg has no MKL: it measures the SuperLU / AMG path (results must still match;
# its times are only recorded) and never fails the run while macOS runners are scarce.
jobs:
bench:
runs-on: ubuntu-22.04
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, macos-14]
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.os == 'macos-14' }}
timeout-minutes: 90
steps:
- uses: actions/checkout@v4

Expand All @@ -25,7 +32,9 @@ jobs:

- name: Benchmark
run: |
if [ -f packaging/bench_baseline_ci.json ]; then
if [ "$RUNNER_OS" = "macOS" ]; then
uv run python packaging/bench.py --json bench.json --check packaging/bench_baseline.json --results-only
elif [ -f packaging/bench_baseline_ci.json ]; then
uv run python packaging/bench.py --json bench.json --check packaging/bench_baseline_ci.json
else
uv run python packaging/bench.py --json bench.json --check packaging/bench_baseline.json --results-only
Expand All @@ -34,5 +43,5 @@ jobs:
- uses: actions/upload-artifact@v4
if: always()
with:
name: bench
name: bench-${{ matrix.os }}
path: bench.json
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, macos-14, ubuntu-22.04]
include:
# macOS (arm64, no MKL: SuperLU / AMG path) is built when a runner is assigned,
# but its failure or cancellation never holds back the Windows/Linux release
- os: macos-14
optional: true
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.optional == true }}
timeout-minutes: 120
steps:
- uses: actions/checkout@v4

Expand Down
12 changes: 8 additions & 4 deletions CLAUDE.md

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions docs/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,15 @@ OS별 설치 절차(서명 전이면 SmartScreen/Gatekeeper 우회 안내도 필
| | UI-4 결과 패널 정리 | ✅ 표시 설정 접기(판정·근거 먼저) |
| | UX-5 첫 사용 안내 | ✅ 둘러보기(5장, 시작 화면·정보 메뉴), 단계별 '다음에 할 일' |

| v0.7 적용 범위 | FT-4 진동 응답(주파수 응답) | ✅ `fem/harmonic.py` — 모드 중첩 + 잔류 정적 보정, 감쇠비·진동수 범위, 응답 곡선(클릭으로 진동수 선택), 가장 불리한 진동수에서 강도·양방향 피로 판정, 보고서 표·곡선. 축 진동 봉의 파동해와 변위 오차 < 0.2 %, 감쇠 공진 < 0.5 % |
| | FT-6 설계 조언 | ✅ `report/advice.py` — 판정 위치(오목 모서리·구멍·필렛·얇은 벽)별 조언 + 선형 비례 수치(하중 배수·두께 범위·필요 강도와 재료 후보). 하중 배수로 다시 풀면 권장 안전율과 1e-6 안에서 같음 |
| | FT-5 비선형 + 접촉(마찰 없음)·볼트 | ✅ `fem/nonlinear.py` — 뉴턴 반복 안의 능동 집합 접촉, 볼트 예압 = 첫 하중 단계(정확히 P로 잠금). 항복 전엔 선형 접촉 해석과 변위 차 3e-12, 접촉으로 쌓은 블록 = 한 봉(신장·붕괴). 마찰은 아직 ✘ |
| | UX-9 단위 붙여 입력·수식 | ✅ `kstruct/unitparse.py`, `ui/unit_spin.UnitSpinBox` |
| | UX-3 측정 도구 | ✅ 3D 뷰 '측정'(M): 면적·구멍 지름·축·법선, 두 점 거리 |
| | UI-5 macOS 빌드 | ⚠ CI에서 선택 사항으로 분리(실패·취소가 릴리스를 막지 않음), 주간 벤치마크에 macOS(SuperLU 경로) 추가. dmg 산출은 러너가 배정돼야 확인 가능 |
| | UX-8 결과 비교 | ✅ 기준 결과 고정 → 나란히 숫자 비교, 같은 메시면 차이 색 지도(같은 실행 두 번 = 차이 0 표시), 기준 결과 번갈아 보기 |
| | UX-7 조건 묶음·대칭면 | ✅ `kstruct/templates.py` — 면 종류(구멍 반지름·평면 방향과 면적)로 매칭해 다른 모델에 적용, '자중' 내장. 대칭면 = 미끄럼 지지 + 결과 안내 |

v0.5 측정(같은 4코어 PC, `packaging/bench.py`, 해석 시간): 정적 3.5 → 2.7 s, 모달 6.2 → 5.7 s, 좌굴 20.4 → 14.3 s, 과도 열 10.1 → 5.4 s, 비선형 14.8 → 8.7 s, 볼트 12.9 → 11.8 s, 마찰 120.8 → 55.4 s. 결과 지문은 마찰(수렴 수정으로 변위 +0.5 %)을 빼고 모두 1e-6 안에서 같음.

### 8.7 진행 순서 제안
Expand Down
4 changes: 2 additions & 2 deletions packaging/windows/kstruct.iss
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
; Inno Setup script: builds KStruct-Setup-<version>.exe from dist\KStruct
; Build: iscc /DAppVersion=0.6.0 packaging\windows\kstruct.iss
; Build: iscc /DAppVersion=0.7.0 packaging\windows\kstruct.iss

#ifndef AppVersion
#define AppVersion "0.6.0"
#define AppVersion "0.7.0"
#endif

[Setup]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "kstruct"
version = "0.6.0"
version = "0.7.0"
description = "Mechanical part FEA for non-experts"
readme = "README.md"
authors = [
Expand Down
2 changes: 1 addition & 1 deletion src/kstruct/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""KStruct: mechanical part FEA for non-experts."""

RELEASE_VERSION = "0.6.0" # keep in sync with pyproject.toml (tests check)
RELEASE_VERSION = "0.7.0" # keep in sync with pyproject.toml (tests check)

# The build number is stamped into kstruct/_build.py by packaging/build.py (and by the CI
# workflow) right before freezing, so every build gets a higher version:
Expand Down
6 changes: 5 additions & 1 deletion src/kstruct/fem/estimate.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ def solve_estimate(project: Project, mesh: FEMesh) -> tuple[str, bool]:
nonlinear = project.analysis == AnalysisKind.STATIC and (
project.plasticity or project.large_deformation
)
heavy = contact or nonlinear or project.analysis in (AnalysisKind.MODAL, AnalysisKind.BUCKLING)
heavy = (
contact
or nonlinear
or project.analysis in (AnalysisKind.MODAL, AnalysisKind.BUCKLING, AnalysisKind.HARMONIC)
)
if project.analysis == AnalysisKind.THERMAL:
dof //= 3 # one unknown per node
limits = _FACTORIZED if heavy else _PLAIN_STATIC
Expand Down
275 changes: 275 additions & 0 deletions src/kstruct/fem/harmonic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
"""Harmonic (frequency) response: the loads of the active case vary as F·cos(ωt) and the
part answers with u(ω) = Σ φⱼ qⱼ, by mode superposition with modal damping ζ:

qⱼ = φⱼᵀf / (ωⱼ² − ω² + 2iζωⱼω)

plus the static share of the modes left out (residual vector r = K⁻¹f − Σ φⱼ φⱼᵀf / ωⱼ²),
so that 0 Hz gives the static answer exactly and the truncation error well below the
highest mode used is small. The modes are taken up to well above the sweep's upper end.

For a complex response the worst instant differs from node to node. For a quadratic
measure Q (|u|², von Mises²) of x(t) = A cos ωt + B sin ωt the largest value over a
period is (a+b)/2 + √(((a−b)/2)² + c²) with a = Q(A), b = Q(B), c = Q(A, B), reached at
θ = ½·atan2(2c, a − b) — so the worst stress state of every node is found exactly, and the
verdict uses those states (a conservative envelope over the period).

Thermal loads, bolt preload and imposed displacements are not vibrating loads and are
left out (a displacement support holds still); contacts act bonded, as in the modal
analysis.
"""

from __future__ import annotations

from collections.abc import Callable
from dataclasses import dataclass, field

import numpy as np

from kstruct.fem.assembly import SolverError, make_solver, rigid_body_modes
from kstruct.fem.mesh import FEMesh
from kstruct.fem.modal import RIGID_HZ, eigenmodes, modal_system
from kstruct.fem.static import StaticResult, _load_vector, recover_stress
from kstruct.i18n import tr
from kstruct.model import Material, Project

Progress = Callable[[float, str], None]

SWEEP_POINTS = 240 # evenly spaced frequencies, plus points packed around each resonance
MIN_MODES = 12 # modes taken at least for the superposition
MAX_MODES = 80
MODE_MARGIN = 1.5 # modes are taken up to this times the sweep's upper end
AUTO_MARGIN = 1.2 # without an upper end: sweep to this times the n-th natural frequency
CHUNK = 32 # frequencies evaluated at once (memory: 3N x CHUNK doubles, twice)
# offsets around each natural frequency, in half-power bandwidths (ζ·fⱼ)
PEAK_OFFSETS = np.array([-6, -3, -2, -1.5, -1, -0.5, -0.25, 0, 0.25, 0.5, 1, 1.5, 2, 3, 6])


def _worst_over_period(a: np.ndarray, b: np.ndarray, c: np.ndarray):
"""Largest value of a·cos²θ + 2c·sinθcosθ + b·sin²θ and the θ where it occurs."""
half = (a - b) / 2
peak = (a + b) / 2 + np.sqrt(half**2 + c**2)
return peak, 0.5 * np.arctan2(2 * c, a - b)


def _vm_form(s: np.ndarray, t: np.ndarray) -> np.ndarray:
"""Bilinear form of von Mises² for two stress states (…, 6), so vm² = form(s, s)."""
d = lambda x, i, j: x[..., i] - x[..., j] # noqa: E731
return 0.5 * (
d(s, 0, 1) * d(t, 0, 1) + d(s, 1, 2) * d(t, 1, 2) + d(s, 2, 0) * d(t, 2, 0)
) + 3 * (s[..., 3] * t[..., 3] + s[..., 4] * t[..., 4] + s[..., 5] * t[..., 5])


@dataclass
class HarmonicResult:
mesh: FEMesh
materials: dict[int, Material]
damping: float # modal damping ratio ζ
natural: np.ndarray # (m,) Hz, the modes used
frequencies: np.ndarray # (F,) Hz, the sweep
displacement: np.ndarray # (F,) largest displacement amplitude in the model, mm
stress: np.ndarray # (F,) largest von Mises amplitude, MPa
utilisation: np.ndarray # (F,) largest von Mises / strength (picks the worst frequency)
governing: float # Hz, the frequency the verdict is taken at
static_displacement: float # largest displacement under the loads held still, mm
# superposition data: basis vectors (modes, then the residual) and their stresses
_omega2: np.ndarray = field(repr=False, default=None)
_p: np.ndarray = field(repr=False, default=None)
_basis: np.ndarray = field(repr=False, default=None) # (3N, m+1)
_stress: np.ndarray = field(repr=False, default=None) # (6N, m+1)
_system: object = field(repr=False, default=None)
_force: np.ndarray = field(repr=False, default=None)

@property
def range(self) -> tuple[float, float]:
return float(self.frequencies[0]), float(self.frequencies[-1])

def coefficients(self, freq) -> np.ndarray:
"""(m+1,) or (m+1, F) complex weights of the basis vectors at freq (Hz)."""
w = 2 * np.pi * np.atleast_1d(np.asarray(freq, dtype=float))
wj = np.sqrt(self._omega2)[:, None]
q = self._p[:, None] / (self._omega2[:, None] - w**2 + 2j * self.damping * wj * w)
q = np.vstack([q, np.ones((1, len(w)))])
return q[:, 0] if np.ndim(freq) == 0 else q

def amplification(self, freq: float) -> float:
"""Largest displacement amplitude at freq over the static one (dynamic factor)."""
if self.static_displacement <= 0:
return 0.0
return float(np.interp(freq, self.frequencies, self.displacement)) / (
self.static_displacement
)

def peaks(self) -> list[float]:
"""Natural frequencies inside the sweep (where the response peaks)."""
lo, hi = self.range
return [float(f) for f in self.natural if lo <= f <= hi]

def state(self, freq: float) -> StaticResult:
"""The response at freq as a static result. Displacement: one instant, the one
at which the node that moves most is furthest out (a consistent deformed shape;
near resonance the motion is a quarter period behind the load, and taking every
node at its own worst instant flipped neighbours' signs). Stress: every node at
its own worst instant (largest von Mises over the period), the sign chosen so the
larger principal stress is tensile (a reversed load reaches both). Reactions are
the amplitudes of the support forces per axis."""
q = self.coefficients(float(freq))
n = self.mesh.n_nodes
u = (self._basis @ q).reshape(n, 3)
ur, ui = u.real, -u.imag # x(t) = Re(u e^{iωt}) = ur cos ωt + ui sin ωt
amp, theta = _worst_over_period(
np.einsum("ij,ij->i", ur, ur),
np.einsum("ij,ij->i", ui, ui),
np.einsum("ij,ij->i", ur, ui),
)
t = theta[int(np.argmax(amp))]
disp = ur * np.cos(t) + ui * np.sin(t)
s = (self._stress @ q).reshape(n, 6)
sr, si = s.real, -s.imag
_, theta = _worst_over_period(_vm_form(sr, sr), _vm_form(si, si), _vm_form(sr, si))
stress = sr * np.cos(theta)[:, None] + si * np.sin(theta)[:, None]
T = stress[:, [0, 3, 5, 3, 1, 4, 5, 4, 2]].reshape(n, 3, 3)
principal = np.linalg.eigvalsh(T)
stress[principal[:, 0] + principal[:, 2] < 0] *= -1
result = StaticResult(
mesh=self.mesh,
materials=self.materials,
displacement=disp,
stress=stress,
reactions=self._reactions(u.ravel(), float(freq)),
applied_load=np.abs(self._force.reshape(-1, 3).sum(axis=0)),
)
result.harmonic = self
result.harmonic_frequency = float(freq)
return result

def _reactions(self, u: np.ndarray, freq: float) -> list[np.ndarray]:
"""Amplitude of each support's force per axis: what the constrained DOFs need
to stay in balance with the elastic and inertia forces, (K − ω²M)u − f."""
sysm = self._system
c = sysm.constraints
w2 = (2 * np.pi * freq) ** 2
residual = sysm.K @ u - w2 * (sysm.M @ u) - self._force
out = []
for dofs, equations in zip(c.fixture_dofs, c.fixture_equations, strict=True):
r = np.zeros(3, dtype=complex)
np.add.at(r, dofs % 3, residual[dofs])
if len(equations):
r += c.penalty_forces(u.real, equations, sysm.scale)
r += 1j * c.penalty_forces(u.imag, equations, sysm.scale)
out.append(np.abs(r))
for i, Ks in c.springs:
out[i] = np.abs((Ks @ u).reshape(-1, 3).sum(axis=0))
return out


def sweep(f_lo: float, f_hi: float, natural: np.ndarray, damping: float, extra=()) -> np.ndarray:
"""Evenly spaced frequencies plus points packed around each resonance inside."""
points = [np.linspace(f_lo, f_hi, SWEEP_POINTS)]
width = max(damping, 1e-3)
for f in natural:
points.append(f * (1 + width * PEAK_OFFSETS))
points.append(np.asarray(extra, dtype=float))
f = np.unique(np.concatenate(points))
return f[(f >= f_lo) & (f <= f_hi)]


def solve_harmonic(
project: Project,
mesh: FEMesh,
materials: dict[int, Material],
progress: Progress | None = None,
) -> StaticResult:
"""The worst state over the sweep; the whole response is in `result.harmonic`."""
report = progress or (lambda frac, msg: None)
if not project.fixtures:
raise SolverError("unstable")
zeta = float(project.damping_ratio)
f_lo, f_hi = (float(v) for v in project.harmonic_range)

report(0.05, tr("강성·질량 행렬 조립 중"))
system = modal_system(project, mesh, materials)
free = system.free
f = _load_vector(project, mesh, materials)
if not np.any(f):
raise SolverError(tr("진동시킬 하중이 없습니다. 5단계에서 하중을 넣어 주세요."))

report(0.15, tr("정적 변형 계산 중"))
solve = make_solver(system.Kf.tocsr(), rigid_body_modes(mesh.nodes)[free])
u_static = np.zeros(len(f))
u_static[free] = solve(f[free])
size = np.ptp(mesh.nodes, axis=0).max()
if np.abs(u_static).max() > 1e3 * size:
raise SolverError("unstable")

report(0.3, tr("고유진동수 계산 중"))
k = max(MIN_MODES, project.n_modes)
while True:
omega2, phi = eigenmodes(system, mesh, k)
natural = np.sqrt(np.clip(omega2, 0, None)) / (2 * np.pi)
if np.any(natural <= RIGID_HZ):
raise SolverError("unstable")
top = f_hi if f_hi > 0 else AUTO_MARGIN * natural[min(project.n_modes, len(natural)) - 1]
if natural[-1] >= MODE_MARGIN * top or k >= MAX_MODES or len(natural) < k:
break
k = min(2 * k, MAX_MODES)
if f_hi <= 0:
f_hi = top
if f_hi <= f_lo:
raise SolverError(tr("진동수 범위가 잘못되었습니다. 최대가 최소보다 커야 합니다."))

report(0.55, tr("응답 합성 중"))
n_dof = len(f)
m = len(omega2)
basis = np.zeros((n_dof, m + 1))
basis[free, :m] = phi
p = phi.T @ f[free]
basis[:, m] = u_static - basis[:, :m] @ (p / omega2) # static share of the other modes
stress = np.empty((mesh.n_nodes * 6, m + 1))
for j in range(m + 1):
stress[:, j] = recover_stress(mesh, materials, basis[:, j]).ravel()
report(0.55 + 0.25 * (j + 1) / (m + 1), tr("응답 합성 중"))

extra = [project.operating_frequency] if project.operating_frequency > 0 else []
freqs = sweep(f_lo, f_hi, natural, zeta, extra)
result = HarmonicResult(
mesh=mesh,
materials=materials,
damping=zeta,
natural=natural,
frequencies=freqs,
displacement=np.zeros(len(freqs)),
stress=np.zeros(len(freqs)),
utilisation=np.zeros(len(freqs)),
governing=0.0,
static_displacement=float(np.linalg.norm(u_static.reshape(-1, 3), axis=1).max()),
_omega2=omega2,
_p=p,
_basis=basis,
_stress=stress,
_system=system,
_force=f,
)

report(0.85, tr("진동수별 응답 계산 중"))
capacity = np.ones(mesh.n_nodes)
for pid, mat in materials.items():
capacity[mesh.part_nodes(pid)] = mat.yield_strength if mat.ductile else mat.tensile_strength
n = mesh.n_nodes
for start in range(0, len(freqs), CHUNK):
q = result.coefficients(freqs[start : start + CHUNK])
u = basis @ q # (3N, F)
ur, ui = u.real.reshape(n, 3, -1), u.imag.reshape(n, 3, -1)
amp, _ = _worst_over_period((ur * ur).sum(1), (ui * ui).sum(1), (ur * ui).sum(1))
s = stress @ q
sr = np.moveaxis(s.real.reshape(n, 6, -1), 1, -1)
si = np.moveaxis(s.imag.reshape(n, 6, -1), 1, -1)
vm2, _ = _worst_over_period(_vm_form(sr, sr), _vm_form(si, si), _vm_form(sr, si))
vm = np.sqrt(np.maximum(vm2, 0))
sl = slice(start, start + q.shape[1])
result.displacement[sl] = np.sqrt(amp.max(axis=0))
result.stress[sl] = vm.max(axis=0)
result.utilisation[sl] = (vm / capacity[:, None]).max(axis=0)
result.governing = float(freqs[int(np.argmax(result.utilisation))])

report(1.0, tr("완료"))
return result.state(result.governing)
Loading
Loading