Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 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
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
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ CI(`.github/workflows/build.yml`)가 Windows/macOS/Linux에서 테스트 → PyI
- **단위계**: 내부는 mm·N·MPa·tonne·s 고정. 밀도 t/mm³(재료 JSON은 kg/m³로 저장하고 로드 시 변환), 열량 1 W = 1000 N·mm/s, 대류 h[W/m²K]×1e-3. 변환은 `standards/__init__.py`와 `fem/thermal.py`에만 있다.
- **면 식별(FaceRef)**: `geometry.faces_of(shape)`의 리스트 인덱스가 `FaceRef.face_index`. Netgen의 면 번호도 같은 순서임이 테스트로 보장된다. 뷰어 삼각형의 `cell_data["face_id"]`, 메시 경계 삼각형의 `FEMesh.tri_face`가 모두 이 인덱스라서 클릭 → 고정/하중 → 메시 절점이 연결된다. 면 순서를 바꾸는 형상 처리를 하면 기존 FaceRef가 깨진다.
- **Netgen**은 자체 OCCT 사본을 쓰므로 부품을 STEP 임시 파일로 넘긴다(`fem/mesh.py`). `mesh.Coordinates()`는 Netgen 메모리 뷰라 반드시 복사할 것(안 하면 다음 부품 메싱 때 좌표가 깨짐).
- **솔버는 자체 구현**(원래 GPL 회피 목적이었으나 2026-11-18 사내용으로 정해져 GPL 의존성도 허용했으나, 2026-11-19 저장소를 공개(MinaryHub로 이전)하기로 해서 **새 GPL 의존성은 추가 전에 라이선스 재검토**): `fem/tet10.py`가 요소 수식, `fem/assembly.py`가 조립·선형해(작으면 SuperLU, 크면 pyamg CG). SuperLU는 반드시 `MMD_AT_PLUS_A` + `SymmetricMode` + `DiagPivotThresh=0`(SPD라 대각 피벗 안전). 기본 부분 피벗은 페널티 tie가 있으면 채움이 30배로 폭증한다. 여러 우변은 `make_solver`로 한 번 분해 후 재사용. **큰 정적 해석**(자유 DOF ≥ `static.ITERATIVE_MIN_DOF` 3만, 접촉 없음)은 `fem/multigrid.py`의 p-멀티그리드 CG를 쓴다: TET10의 꼭짓점 절점(TET4) 문제를 직접 풀어 보정 + Gauss-Seidel 1회씩. 반복 수가 메시와 무관(22~26회)해서 85k DOF 15 s → 2.6 s, 245k DOF 8 s. 페널티 행이 있으면 수렴하지 않으므로 `Constraints.elimination()`으로 구속을 소거한 K̂ = TᵀKT를 풀고(tie는 슬레이브 DOF, 핀·경사 미끄럼은 절점별 작은 블록), 이때 구속 반력은 `multiplier_forces`(라그랑주 승수)로 구한다(`_Stiffness.exact`). 소거 불가(tie 사슬)·특이(안 붙잡힌 부품)·미수렴이면 기존 분해 경로로 넘어가 그쪽이 진단한다. 접촉·모달·좌굴은 계속 분해를 쓴다(행렬이 바뀌거나 우변이 수십 개). 경계조건(`fem/constraints.py`)은 축 정렬 구속은 DOF 제거, 경사 미끄럼/핀/부품 간 접합(tie)은 페널티 방정식. 반력은 각 고정이 실제로 구속한 DOF/방정식만 합산한다(모서리 공유 DOF 이중 집계 방지).
- **솔버는 자체 구현**(원래 GPL 회피 목적이었으나 2026-11-18 사내용으로 정해져 GPL 의존성도 허용했으나, 2026-11-19 저장소를 공개(MinaryHub로 이전)하기로 해서 **새 GPL 의존성은 추가 전에 라이선스 재검토**): `fem/tet10.py`가 요소 수식, `fem/assembly.py`가 조립·선형해. **직접 분해는 PARDISO 우선**(`fem/pardiso.py`, MKL을 ctypes로; Windows/Linux x86-64, `mkl` 의존성): 2천~30만 DOF에서 `make_solver`가 먼저 쓰고, MKL이 없거나(macOS) 분해 실패(부정치) 또는 상대 피벗 < 1e-12(특이: 안 붙잡힌 부품)면 None → 기존 SuperLU/AMG가 이전과 똑같이 진단한다. 같은 행렬에서 85k DOF 분해 16.2 s → 0.9 s, 볼트 접촉 73k 52 s → 1.2 s(차이 1e-11). SPD(mtype 2)만, METIS 병렬 순서(`iparm[1]=3`), 같은 희소 패턴의 순서는 캐시(`_ORDERINGS`, 순서가 분해의 ~75 %), `MKL_CBWR_Set(COMPATIBLE)`로 **실행마다 비트 단위 동일**(마찰이 반올림 경로에 민감). 대체 경로는 `KSTRUCT_NO_PARDISO=1`로 강제할 수 있고 `tests/test_fem_pardiso.py`가 두 경로 일치를 확인한다. 설치 파일에는 PARDISO가 실제로 여는 MKL 라이브러리만 넣는다(`kstruct.spec`의 `MKL_KEEP`; GPU·MPI·ScaLAPACK 제외), 배포본 selftest는 Windows/Linux에서 PARDISO가 없으면 실패. 그 밖(작은 행렬·macOS)은 SuperLU, 큰 것은 pyamg CG. SuperLU는 반드시 `MMD_AT_PLUS_A` + `SymmetricMode` + `DiagPivotThresh=0`(SPD라 대각 피벗 안전). 기본 부분 피벗은 페널티 tie가 있으면 채움이 30배로 폭증한다. 여러 우변은 `make_solver`로 한 번 분해 후 재사용. **큰 정적 해석**(자유 DOF ≥ `static.ITERATIVE_MIN_DOF` 3만, 접촉 없음)은 `fem/multigrid.py`의 p-멀티그리드 CG를 쓴다: TET10의 꼭짓점 절점(TET4) 문제를 직접 풀어 보정 + Gauss-Seidel 1회씩. 반복 수가 메시와 무관(22~26회)해서 85k DOF 15 s → 2.6 s, 245k DOF 8 s. 페널티 행이 있으면 수렴하지 않으므로 `Constraints.elimination()`으로 구속을 소거한 K̂ = TᵀKT를 풀고(tie는 슬레이브 DOF, 핀·경사 미끄럼은 절점별 작은 블록), 이때 구속 반력은 `multiplier_forces`(라그랑주 승수)로 구한다(`_Stiffness.exact`). 소거 불가(tie 사슬)·특이(안 붙잡힌 부품)·미수렴이면 기존 분해 경로로 넘어가 그쪽이 진단한다. 접촉·모달·좌굴은 계속 분해를 쓴다(행렬이 바뀌거나 우변이 수십 개). 경계조건(`fem/constraints.py`)은 축 정렬 구속은 DOF 제거, 경사 미끄럼/핀/부품 간 접합(tie)은 페널티 방정식. 반력은 각 고정이 실제로 구속한 DOF/방정식만 합산한다(모서리 공유 DOF 이중 집계 방지).
- **열 해석**(`fem/thermal.py`): 정상 상태 전도. 복사(`LoadKind.RADIATION`, magnitude = 방사율, `ambient` = 주변 온도)는 등가 대류 계수 εσ(T²+T∞²)(T+T∞)로, 온도 의존 열전도율(`Material.conductivity_table`, 재료 JSON `k_table`)은 요소 평균 온도 보간으로 넣고 둘 중 하나라도 있으면 `MAX_ITERATIONS`까지 고정점 반복(변화 < 범위의 1e-4). 복사는 Newton 접선 선형화(`radiation_tangent`: h = 4εσT³, 기준 온도 T − q/h)를 쓴다 — 할선 계수(`radiation_coefficient`)의 고정점 반복은 몇 W만 넘어도 발산했다. 온도 기준(`TEMPERATURE_REFERENCES`: 고정 온도·대류·복사)은 **연결된 부품 묶음마다** 있어야 하고 없으면 부품 이름을 넣은 `SolverError`(예전엔 그 부품이 말없이 0 °C). `heat_in`/`heat_out`은 들어온 열과 나간 열을 따로 합한다(상쇄하지 않음). **과도 해석**: `Project.thermal_duration` > 0이면 `_march`가 처음 온도(`initial_temperature`)에서 후진 오일러 `TRANSIENT_STEPS`(60)단계로 (K + C/Δt)Tₙ₊₁ = f + C/Δt·Tₙ을 푼다(C = ρc∫NNᵀ 일관 행렬 `capacity_matrix`, 선형이면 분해 1회, 복사·k(T)는 직전 단계 온도로 선형화). 온도 기준 없이도 풀리고(열 입력만으로 데워짐), 비열·밀도가 없으면 `SolverError`. `ThermalResult.times/history`(`TRANSIENT_FRAMES` 20 + 시작)를 결과 패널의 '시각'(모드 선택 상자 재사용)으로 고르고 색 범위는 전 시간 공통. 판정은 전 시간 최고 온도(`peak`), 강도 해석의 열응력은 마지막 시점 온도. 이론해 테스트 `tests/test_fem_transient.py`(한쪽 끝 가열 막대의 푸리에 급수, 긴 시간 → 정상 상태, 에너지 보존).
- **열응력**: 정적해석에 열 조건(`THERMAL_LOADS`)이 있으면 먼저 `solve_thermal`로 온도장을 구하고 `reference_temperature` 대비 ΔT로 열하중을 만든다. 피로(`fem/fatigue.py`)는 정적 결과를 반복 하중의 최대값으로 보고 `report.summary.summarize`에서 계산된다. 피로 한도 보정은 `FatigueSettings`(표면 `SURFACE_FACTORS`, 신뢰도 `RELIABILITY_FACTORS`, 크기 0.85)로 하고 `Project.fatigue_surface/fatigue_reliability`에 저장; settings 없이 부르면 옛 상수 `MARIN_FACTOR`(0.7).
- **접촉**(`fem/contact.py`, `ContactSolver`): 마찰 없는 node-to-surface 페널티(`CONTACT_PENALTY_FACTOR` 1e3, 접합 tie의 1e6보다 무름) + 능동 집합 반복. 해제 판정은 틈이 아니라 **평형 잔차 K u − f의 슬레이브 절점 성분**(= 스프링 힘; α·틈은 반올림을 α배 증폭하므로 쓰지 말 것)으로 하고, 임계값은 최대 접촉 압력의 0.1 %. 결합은 요소 크기·변위 크기 기준 관통. 쌍마다 상태 변경을 `MAX_FLIPS`회로 제한하고 상태가 순환하면 멈춘다(채터링 방지). 분해는 한 번 하고 능동 집합이 같으면 재사용, 바뀐 쌍이 적으면 Woodbury 저랭크 갱신(재분해와의 선택은 `make_solver`가 붙이는 `solve.breakeven` = 0.25·nnz(LU)/n 기준. **벽시계 시간으로 고르지 말 것**: 반올림 경로가 실행마다 달라져 마찰 결과가 195~1500 N으로 흔들렸다). K_c의 잔차는 페널티 행이 반올림을 증폭해 정확도 지표로 쓸 수 없다. Woodbury 갱신만으로는 cond(S)·eps(겹침 이음에서 8e-7, Windows CI에서 1e-6 초과)라서 같은 연산자로 반복 개선 1회를 하고(1.5e-9), 보정이 해의 1e-3을 넘으면 버린다. 접촉으로만 붙은 부품을 위해 1e-9 크기 안정화 스프링을 쓰고, 그 부품이 미끄러지면 `SolverError("contact unstable")`. 진동·좌굴·열 해석에서는 접촉을 접합으로 취급. **마찰**(`Connection.friction`, 쿨롱): 닫힌 쌍은 항상 접선 스프링 2개(α_t = `TANGENT_PENALTY_FACTOR` 1e-3 × 법선 α)를 갖고, 마찰은 스프링 기준점(anchor)을 옮기는 **return mapping**으로 푼다: 증분 시작 때 확정된 기준점(`base`)에서 잰 시험력 −α_t(s − base)를 마찰원 |F| ≤ μN으로 잘라 그 힘을 내도록 기준점을 다시 잡는다. 행렬이 안 바뀌어 반복 1회 = 역대입 1회(Aitken 가속, 상한 `MAX_FRICTION_SWEEPS`)이고, 마찰은 저항만 한다. 닫힌 쌍의 90 % 이상이 마찰원 위이고 마찰력 합력이 μΣN의 98 %에 이르면 **면 전체 미끄럼**(`gross`): 그 면의 접선 스프링을 빼고 합력 방향으로 μN을 외력으로 건다(받쳐 주는 것이 없으면 "contact unstable"). 하중은 `solve_path`가 예압 → 나머지 하중 `FRICTION_INCREMENTS`(4) 증분으로 건다(마찰은 경로 의존; 면 전체 미끄럼은 다음 증분으로 이어짐). 하지 말 것: 미끄럼 쌍의 스프링을 빼고 방향을 고정한 μN 외력(예압 판이 볼트 축으로 돌거나 마찰이 판을 되밀어 수렴 안 함), α_t를 법선 α와 같게(고착 범위 μN/α가 반올림보다 작아 판정이 흔들림), 시험력 크기의 합으로 면 전체 미끄럼 판정(예압 뒤엔 모든 쌍이 반지름 방향 마찰원 위라 거짓 발동). `StaticResult.contact`는 (닫힘, 전체, 미끄럼)이고 미끄럼 = 닫힘 × 미끄럼 쌍이 받는 법선력 비율(`ContactSet.slip_share`; TRI6 꼭짓점 절점은 균일 압력에서 법선력이 0이라 개수로 세면 아무 데서나 "미끄럼"). 반복 상한을 다 쓰면 `contact_converged=False`가 되고 요약 첫 메모로 경고한다.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<p align="center"><img src="docs/logo.png" width="128" alt="KStruct"></p>

# KStruct — 부품 강도 해석

CAD 모델을 불러와 재료·고정·하중을 지정하면, 부품이 안전한지 색과 쉬운 말로 알려주는
Expand Down
Binary file added docs/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/1920x1080/01_welcome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/1920x1080/02_setup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/1920x1080/03_stress.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/1920x1080/04_safety.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/1920x1080/05_bolts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/1920x1080/06_modal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/1920x1080/07_thermal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/1920x1080/08_nonlinear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/1920x1080/09_dark_theme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/2880x1800/01_welcome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/2880x1800/02_setup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/2880x1800/03_stress.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/2880x1800/04_safety.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/2880x1800/05_bolts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/2880x1800/06_modal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/2880x1800/07_thermal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/2880x1800/08_nonlinear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/2880x1800/09_dark_theme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 27 additions & 1 deletion packaging/kstruct.spec
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ for f in occt.files or []:
if f.suffix.lower() in (".dll", ".so", ".dylib") or ".so." in f.name:
binaries.append((str(f.locate().resolve()), "."))

# MKL for the PARDISO solver (Windows/Linux x86-64; fem/pardiso.py loads it with ctypes,
# so PyInstaller cannot see it). Only what PARDISO loads: the runtime, core, LP64
# interface and OpenMP threading layers, every CPU-specific kernel (MKL picks one at run
# time), OpenMP and tbbmalloc. The wheels hold ~1 GB more (MPI, ScaLAPACK, GPU offload).
import re

MKL_KEEP = re.compile(
r"^(lib)?(mkl_(rt|core|intel_lp64|intel_thread|sequential|def|mc3|avx\d*|vml_\w+)"
r"|iomp5(md)?|tbbmalloc)[.\d]*\.(dll|so[.\d]*|dylib)$",
re.IGNORECASE,
)
for dist in ("mkl", "intel-openmp", "tbb"):
try:
files = distribution(dist).files or []
except Exception: # not installed on this platform (macOS)
continue
for f in files:
if MKL_KEEP.match(f.name) and "_db" not in f.name:
binaries.append((str(f.locate().resolve()), "."))

a = Analysis(
[str(ROOT / "src" / "kstruct" / "app.py")],
pathex=[str(ROOT / "src")],
Expand Down Expand Up @@ -69,8 +89,14 @@ exe = EXE(
name="KStruct",
console=False,
disable_windowed_traceback=False,
icon=str(ROOT / "packaging" / "windows" / "kstruct.ico") if sys.platform == "win32" else None,
)
coll = COLLECT(exe, a.binaries, a.datas, name="KStruct")

if sys.platform == "darwin":
app = BUNDLE(coll, name="KStruct.app", bundle_identifier="kr.smic.kstruct")
app = BUNDLE(
coll,
name="KStruct.app",
icon=str(ROOT / "packaging" / "macos" / "kstruct.icns"),
bundle_identifier="kr.smic.kstruct",
)
Binary file added packaging/macos/kstruct.icns
Binary file not shown.
59 changes: 59 additions & 0 deletions packaging/make_icons.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""Render the logo (src/kstruct/resources/icons/kstruct.svg) to every icon file:

uv run python packaging/make_icons.py

- src/kstruct/resources/icons/kstruct_<size>.png window / taskbar icon, header logo
- packaging/windows/kstruct.ico KStruct.exe and the installer
- packaging/macos/kstruct.icns KStruct.app
- docs/logo.png README

Rendered with Qt's SVG renderer (SVG Tiny: no clipPath, filters or CSS), so the SVG
must stay within that subset; the PNGs are committed so builds need no SVG support.
"""

import io
import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]
SVG = ROOT / "src" / "kstruct" / "resources" / "icons" / "kstruct.svg"
SIZES = (16, 24, 32, 48, 64, 128, 256, 512)


def main() -> None:
from PIL import Image
from PySide6.QtCore import QBuffer, QIODevice, QRectF
from PySide6.QtGui import QGuiApplication, QImage, QPainter
from PySide6.QtSvg import QSvgRenderer

app = QGuiApplication(sys.argv) # noqa: F841
renderer = QSvgRenderer(str(SVG))
if not renderer.isValid():
raise SystemExit(f"cannot read {SVG}")

images = {}
for size in (*SIZES, 1024):
img = QImage(size, size, QImage.Format_ARGB32)
img.fill(0)
p = QPainter(img)
p.setRenderHint(QPainter.Antialiasing)
p.setRenderHint(QPainter.SmoothPixmapTransform)
renderer.render(p, QRectF(0, 0, size, size))
p.end()
buf = QBuffer()
buf.open(QIODevice.WriteOnly)
img.save(buf, "PNG")
images[size] = Image.open(io.BytesIO(bytes(buf.data()))).convert("RGBA")

out = SVG.parent
for size in SIZES:
images[size].save(out / f"kstruct_{size}.png", optimize=True)
ico_sizes = [(s, s) for s in (16, 24, 32, 48, 64, 128, 256)]
images[256].save(ROOT / "packaging" / "windows" / "kstruct.ico", sizes=ico_sizes)
images[1024].save(ROOT / "packaging" / "macos" / "kstruct.icns")
images[512].save(ROOT / "docs" / "logo.png", optimize=True)
print("icons written")


if __name__ == "__main__":
main()
Binary file added packaging/windows/kstruct.ico
Binary file not shown.
2 changes: 2 additions & 0 deletions packaging/windows/kstruct.iss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ SolidCompression=yes
ArchitecturesAllowed=x64compatible
ArchitecturesInstallIn64BitMode=x64compatible
WizardStyle=modern
SetupIconFile=kstruct.ico
UninstallDisplayIcon={app}\KStruct.exe
LicenseFile=..\..\THIRD_PARTY_NOTICES.md

[Languages]
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ requires-python = ">=3.12,<3.13"
dependencies = [
"cadquery-ocp>=8.0.1.1.0",
"lxml>=6.1.3",
# PARDISO sparse solver (fem/pardiso.py); not built for macOS, which keeps SuperLU
"mkl>=2024.2; (sys_platform == 'win32' or sys_platform == 'linux') and (platform_machine == 'x86_64' or platform_machine == 'AMD64')",
"netgen-mesher>=6.2.2608",
"networkx>=3.7",
"numpy>=2.5.3",
Expand Down
24 changes: 23 additions & 1 deletion src/kstruct/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import platform
import sys
from pathlib import Path

Expand All @@ -23,7 +24,21 @@ def selftest() -> int:
result = solve_static(project, mesh, {0: standards.materials()["s235"]})
peak = float(result.von_mises.max())
ok = 80 < peak < 200 and abs(result.reactions[0][2] - 2000) < 1e-3
print(f"selftest: elements={len(mesh.tets)} peak_vm={peak:.1f} MPa -> {'OK' if ok else 'FAIL'}")
# a frozen build for Windows/Linux x86-64 must carry MKL; without it every analysis
# silently runs on the 18-55x slower SuperLU
from kstruct.fem import pardiso

wants_mkl = sys.platform in ("win32", "linux") and platform.machine().lower() in (
"x86_64",
"amd64",
)
solver = "PARDISO" if pardiso.available() else "SuperLU"
if getattr(sys, "frozen", False) and wants_mkl and not pardiso.available():
ok = False
print(
f"selftest: elements={len(mesh.tets)} peak_vm={peak:.1f} MPa solver={solver} "
f"-> {'OK' if ok else 'FAIL'}"
)
return 0 if ok else 1


Expand Down Expand Up @@ -80,6 +95,13 @@ def main() -> None:

setup_logging()
install_excepthook()
if sys.platform == "win32": # own taskbar entry and icon, not python.exe's
import ctypes

try:
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("MinaryHub.KStruct")
except (AttributeError, OSError):
pass
if "--version" in sys.argv:
from kstruct import build_info

Expand Down
Loading
Loading