88 lines
3.0 KiB
Python
Executable File
88 lines
3.0 KiB
Python
Executable File
"""Quick pre-flight check — run this before run_optimization.py."""
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[4]))
|
|
|
|
STUDY_DIR = Path(__file__).parent
|
|
MODEL_DIR = STUDY_DIR / "1_setup" / "model"
|
|
DATA_DIR = MODEL_DIR / "adaptive_isogrid_data"
|
|
NX_VERSION = "2512" # DesigncenterNX2512 (production)
|
|
|
|
required = [
|
|
(MODEL_DIR / "ACS_Stack_Main_Plate_Iso_Project.prt", "Geometry part"),
|
|
(MODEL_DIR / "ACS_Stack_Main_Plate_Iso_project_fem2_i.prt", "Idealized part (CRITICAL)"),
|
|
(MODEL_DIR / "ACS_Stack_Main_Plate_Iso_project_fem2.fem", "FEM file"),
|
|
(MODEL_DIR / "ACS_Stack_Main_Plate_Iso_project_sim2.sim", "Simulation file"),
|
|
(DATA_DIR / "geometry_sandbox_1.json", "Sandbox 1 geometry"),
|
|
(DATA_DIR / "geometry_sandbox_2.json", "Sandbox 2 geometry"),
|
|
]
|
|
|
|
nx_candidates = [
|
|
Path(f"C:/Program Files/Siemens/DesigncenterNX{NX_VERSION}/NXBIN/run_journal.exe"),
|
|
Path(f"C:/Program Files/Siemens/Simcenter3D_{NX_VERSION}/NXBIN/run_journal.exe"),
|
|
]
|
|
|
|
print("Pre-flight checks")
|
|
print("=" * 60)
|
|
|
|
all_ok = True
|
|
|
|
# Model files
|
|
print("\nModel files:")
|
|
for path, label in required:
|
|
if path.exists():
|
|
mb = round(path.stat().st_size / 1_048_576, 1)
|
|
print(f" [OK] {label} ({mb} MB)")
|
|
else:
|
|
print(f" [MISSING] {label}")
|
|
print(f" -> {path}")
|
|
all_ok = False
|
|
|
|
# run_journal.exe
|
|
print("\nNX:")
|
|
rj_found = None
|
|
for c in nx_candidates:
|
|
if c.exists():
|
|
rj_found = c
|
|
break
|
|
if rj_found:
|
|
print(f" [OK] run_journal.exe: {rj_found}")
|
|
else:
|
|
print(f" [MISSING] run_journal.exe — NX {NX_VERSION} not found")
|
|
print(f" Checked: {[str(c) for c in nx_candidates]}")
|
|
all_ok = False
|
|
|
|
# Python Brain imports
|
|
print("\nPython Brain:")
|
|
try:
|
|
from optimization_engine.isogrid import (
|
|
generate_triangulation, generate_pockets,
|
|
assemble_profile, profile_to_json, validate_profile,
|
|
normalize_geometry_schema,
|
|
)
|
|
from optimization_engine.isogrid.study import PARAM_SPACE, MATERIAL
|
|
print(" [OK] optimization_engine.isogrid")
|
|
print(f" Material: {MATERIAL['name']} sigma_allow={MATERIAL['sigma_allow_MPa']:.1f} MPa")
|
|
except ImportError as e:
|
|
print(f" [FAIL] Brain import: {e}")
|
|
all_ok = False
|
|
|
|
# Extractor imports
|
|
print("\nExtractors:")
|
|
try:
|
|
from optimization_engine.extractors.extract_part_mass_material import extract_part_mass_material
|
|
from optimization_engine.extractors.extract_von_mises_stress import extract_solid_stress
|
|
print(" [OK] extract_part_mass_material + extract_solid_stress")
|
|
except ImportError as e:
|
|
print(f" [FAIL] Extractor import: {e}")
|
|
all_ok = False
|
|
|
|
print("\n" + "=" * 60)
|
|
if all_ok:
|
|
print("All checks PASSED — ready to run run_optimization.py")
|
|
else:
|
|
print("FAILED — fix the issues above before running")
|
|
|
|
sys.exit(0 if all_ok else 1)
|