Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 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
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
38 changes: 38 additions & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: bench

# Weekly performance and result check of every analysis (packaging/bench.py).
# The result numbers must match packaging/bench_baseline.json on any machine; the times
# are compared with packaging/bench_baseline_ci.json once that file exists (CI runners
# are slower than a desktop: record it from this job's artifact first).
on:
schedule:
- cron: "17 3 * * 1" # Mondays 03:17 UTC
workflow_dispatch:

jobs:
bench:
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v5
with:
python-version: "3.12"

- name: Install
run: uv sync --locked

- name: Benchmark
run: |
if [ -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
fi

- uses: actions/upload-artifact@v4
if: always()
with:
name: bench
path: bench.json
14 changes: 8 additions & 6 deletions CLAUDE.md

Large diffs are not rendered by default.

111 changes: 110 additions & 1 deletion docs/ROADMAP.md

Large diffs are not rendered by default.

280 changes: 280 additions & 0 deletions packaging/bench.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
"""Performance benchmark of every analysis on the built-in sample models.

uv run python packaging/bench.py # all cases, table on screen
uv run python packaging/bench.py friction transient # some cases
uv run python packaging/bench.py --json out.json # also write the numbers
uv run python packaging/bench.py --check packaging/bench_baseline.json # fail if slower
uv run python packaging/bench.py friction --profile # where the time goes

Each case runs in its own process (no caches shared between cases). Besides the times it
records a few result numbers ("fingerprint"): a speed-up must leave them unchanged, and
--check fails when one moves by more than its tolerance.
"""

from __future__ import annotations

import argparse
import json
import os
import subprocess
import sys
import tempfile
import time
from pathlib import Path

# case -> mesh grade (the bracket cases use fine meshes, the assemblies normal ones)
CASES = {
"static": "fine",
"modal": "fine",
"buckling": "fine",
"thermal": "fine",
"transient": "fine",
"nonlinear": "normal",
"bolted": "normal",
"friction": "normal",
}
RESULT_TOLERANCE = 1e-6 # relative change of a fingerprint number still called "the same"
# friction iterates to a tolerance (contact.FRICTION_TOL): another machine's BLAS can stop
# it at a slightly different point
CASE_TOLERANCE = {"friction": 1e-3}


def _bracket(case: str):
from kstruct.geometry.face_info import face_at
from kstruct.geometry.samples import l_bracket, write_step
from kstruct.geometry.step_import import load_cad
from kstruct.model import AnalysisKind, FaceRef, Fixture, FixtureKind, Load, LoadKind

project = load_cad(write_step(l_bracket(), Path(tempfile.mkdtemp()) / "bracket.step"))
s = project.parts[0].shape
back, top = FaceRef(0, face_at(s, (0, 30, 40))), FaceRef(0, face_at(s, (90, 30, 8)))
project.parts[0].material_id = "s355"
project.fixtures = [Fixture(FixtureKind.FIXED, [back])]
project.loads = [Load(LoadKind.FORCE, [top], vector=(0, 0, -3000.0))]
if case == "modal":
project.analysis = AnalysisKind.MODAL
elif case == "buckling":
project.analysis = AnalysisKind.BUCKLING
project.loads = [Load(LoadKind.FORCE, [top], vector=(-30000.0, 0, 0))]
elif case in ("thermal", "transient"):
project.analysis = AnalysisKind.THERMAL
project.fixtures = []
project.loads = [
Load(LoadKind.HEAT_FLOW, [top], magnitude=15.0),
Load(LoadKind.CONVECTION, [back], magnitude=50.0),
Load(
LoadKind.RADIATION,
[FaceRef(0, face_at(s, (50, 30, 16)))],
magnitude=0.9,
ambient=20.0,
),
]
if case == "transient":
project.thermal_duration = 600.0
project.initial_temperature = 20.0
elif case == "nonlinear":
project.plasticity = True
project.loads = [Load(LoadKind.FORCE, [top], vector=(0, 0, -9000.0))]
return project


def _bolted(case: str):
from kstruct.fem.bolts import hole_axis, recommended_preload, suggest_size
from kstruct.geometry.contacts import find_touching_faces
from kstruct.geometry.face_info import face_at
from kstruct.geometry.samples import bolted_plates, write_step
from kstruct.geometry.step_import import load_cad
from kstruct.model import (
Bolt,
ConnectionKind,
FaceRef,
Fixture,
FixtureKind,
Load,
LoadKind,
)

project = load_cad(write_step(bolted_plates(), Path(tempfile.mkdtemp()) / "bolted.step"))
lower, upper = (p.shape for p in project.parts)
for p in project.parts:
p.material_id = "s355"
project.connections = find_touching_faces(project)
project.connections[0].kind = ConnectionKind.CONTACT
if case == "friction":
project.connections[0].friction = 0.2
for n, (x, y) in enumerate(((10, 10), (70, 10), (40, 50)), start=1):
a = FaceRef(0, face_at(lower, (x + 5.5, y, 2.5)))
b = FaceRef(1, face_at(upper, (x + 5.5, y, 7.5)))
size = suggest_size(min(hole_axis(project, r)[2] for r in (a, b)))
project.bolts.append(Bolt(a, b, size, "8.8", recommended_preload(size, "8.8"), f"bolt {n}"))
project.fixtures = [Fixture(FixtureKind.FIXED, [FaceRef(0, face_at(lower, (40, 30, 0)))])]
load = (1500.0, 0, 0) if case == "friction" else (0, 0, 3000.0)
project.loads = [Load(LoadKind.FORCE, [FaceRef(1, face_at(upper, (40, 30, 10)))], vector=load)]
return project


def _fingerprint(case: str, result) -> dict[str, float]:
"""A few numbers that a speed-up must not change."""
import numpy as np

if case == "modal":
return {f"f{i + 1}_Hz": float(f) for i, f in enumerate(result.frequencies[:3])}
if case == "buckling":
return {"factor1": float(result.factors[0])}
if case in ("thermal", "transient"):
out = {"T_max": float(result.temperature.max()), "heat_out_W": float(result.heat_out)}
if result.history is not None:
out["T_peak"] = float(np.max(result.history))
return out
r = result[0]
out = {
"u_max": float(np.linalg.norm(r.displacement, axis=1).max()),
"reaction_sum": float(np.linalg.norm(np.sum(r.reactions, axis=0))),
}
if r.bolts:
out.update({f"bolt{i + 1}_N": float(b.axial) for i, b in enumerate(r.bolts)})
if r.nonlinear is not None:
out["load_factor"] = float(r.nonlinear.load_factor)
out["plastic_max"] = float(r.nonlinear.plastic_strain.max())
return out


def run_case(case: str, grade: str, profile: bool = False) -> dict:
os.environ.setdefault("KSTRUCT_DATA_DIR", tempfile.mkdtemp())
from kstruct import standards
from kstruct.fem import generate_mesh
from kstruct.fem.buckling import solve_buckling
from kstruct.fem.modal import solve_modal
from kstruct.fem.static import solve_cases
from kstruct.fem.thermal import solve_thermal
from kstruct.model import active_project

project = active_project(_bolted(case) if case in ("bolted", "friction") else _bracket(case))
project.mesh_quality = grade
mats = standards.project_materials(project)
materials = {p.id: mats[p.material_id] for p in project.parts}

t0 = time.perf_counter()
mesh = generate_mesh(project, grade)
t_mesh = time.perf_counter() - t0

def solve():
if case == "modal":
return solve_modal(project, mesh, materials, 6)
if case == "buckling":
return solve_buckling(project, mesh, materials, 4)
if case in ("thermal", "transient"):
return solve_thermal(project, mesh, materials)
return solve_cases(project, mesh, materials)

prof = None
if profile:
import cProfile

prof = cProfile.Profile()
prof.enable()
t0 = time.perf_counter()
result = solve()
t_solve = time.perf_counter() - t0
out = {
"case": case,
"grade": grade,
"dof": int(mesh.n_nodes * 3),
"mesh_s": round(t_mesh, 2),
"solve_s": round(t_solve, 2),
"result": _fingerprint(case, result),
}
if prof is not None:
import pstats

prof.disable()
stats = pstats.Stats(prof)
rows = sorted(
(
(tt, ct, nc, f"{fn.split('site-packages/')[-1].split('src/')[-1]}:{ln}:{func}")
for (fn, ln, func), (_, nc, tt, ct, _) in stats.stats.items()
),
reverse=True,
)
out["top_own"] = [(round(t, 2), round(c, 2), n, f) for t, c, n, f in rows[:15]]
return out


def _child(case: str, grade: str, profile: bool) -> dict:
cmd = [sys.executable, __file__, "--one", case, "--grade", grade]
if profile:
cmd.append("--profile")
done = subprocess.run(cmd, capture_output=True, text=True, check=False)
lines = [ln for ln in done.stdout.splitlines() if ln.startswith("{")]
if done.returncode != 0 or not lines:
raise RuntimeError(f"{case} failed:\n{done.stderr[-3000:]}")
return json.loads(lines[-1])


def check(rows: list[dict], baseline: dict, tolerance: float, times: bool = True) -> list[str]:
"""Slower than tolerance × baseline, or a fingerprint number that moved."""
problems = []
for row in rows:
base = baseline.get(row["case"])
if base is None:
continue
if times and row["solve_s"] > tolerance * base["solve_s"] + 0.5:
problems.append(
f"{row['case']}: solve {row['solve_s']} s > {tolerance} × {base['solve_s']} s"
)
for key, value in base.get("result", {}).items():
new = row["result"].get(key)
tol = CASE_TOLERANCE.get(row["case"], RESULT_TOLERANCE)
if new is None or abs(new - value) > tol * max(abs(value), 1e-12):
problems.append(f"{row['case']}: {key} {value!r} -> {new!r}")
return problems


def main() -> int:
parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])
parser.add_argument("cases", nargs="*", help=f"some of: {' '.join(CASES)} (default: all)")
parser.add_argument("--grade", help="mesh grade for every case (default: per case)")
parser.add_argument("--profile", action="store_true", help="top functions by own time")
parser.add_argument("--json", type=Path, help="write the rows to this file")
parser.add_argument("--check", type=Path, help="baseline JSON to compare with")
parser.add_argument("--tolerance", type=float, default=1.5, help="allowed slow-down")
parser.add_argument(
"--results-only", action="store_true", help="--check the results, not the times"
)
parser.add_argument("--one", help=argparse.SUPPRESS) # child process
args = parser.parse_args()

if args.one:
print(json.dumps(run_case(args.one, args.grade or CASES[args.one], args.profile)))
return 0

unknown = set(args.cases) - set(CASES)
if unknown:
parser.error(f"unknown case(s): {', '.join(sorted(unknown))}")
rows = []
print(f"{'case':10} {'grade':7} {'DOF':>8} {'mesh s':>7} {'solve s':>8} result")
for case in args.cases or list(CASES):
row = _child(case, args.grade or CASES[case], args.profile)
rows.append(row)
numbers = ", ".join(f"{k}={v:.6g}" for k, v in row["result"].items())
print(
f"{case:10} {row['grade']:7} {row['dof']:8d} {row['mesh_s']:7.2f} "
f"{row['solve_s']:8.2f} {numbers}",
flush=True,
)
for t, c, n, f in row.get("top_own", []):
print(f" own {t:7.2f} cum {c:7.2f} x{n:<6} {f}")
if args.json:
args.json.write_text(json.dumps({r["case"]: r for r in rows}, indent=1) + "\n")
if args.check:
problems = check(
rows, json.loads(args.check.read_text()), args.tolerance, not args.results_only
)
for p in problems:
print("FAIL", p)
return 1 if problems else 0
return 0


if __name__ == "__main__":
sys.exit(main())
Loading
Loading