- Extract mass RIGHT AFTER geometry rebuild while part is work part
- Replace unreliable p173 expression lookup with MeasureManager
- Skip re-extraction if mass already captured during rebuild
- Relax displacement constraint to 20mm (DEC-HB-012, CEO approved)
Root cause: journal hardcoded M1_Blank for bracket, failed silently on Beam.prt
Fix by: NX Expert + Manager diagnosis
Bug 1 — Journal (solve_simulation.py simple workflow):
Expression lookup for p173 fails silently for derived/measurement
expressions, so _temp_mass.txt was never written. Added MeasureManager
fallback via extract_part_mass() (already used in assembly workflow).
Bug 2 — Extractor (extract_mass_from_expression.py):
Journal writes 'p173=<value>' format but extractor tried float() on
the whole content including 'p173='. Added key=value parsing.
Defense in depth — nx_interface.py:
Added stdout parsing fallback: if _temp_mass.txt still missing, parse
mass from journal output captured via solver.py stdout passthrough.
Files changed:
- optimization_engine/nx/solve_simulation.py — MeasureManager fallback
- optimization_engine/extractors/extract_mass_from_expression.py — key=value parse
- optimization_engine/nx/solver.py — include stdout in result dict
- projects/hydrotech-beam/studies/01_doe_landscape/nx_interface.py — stdout fallback
Tags: hydrotech-beam, mass-extraction
- Journal now extracts p173 mass expression and writes _temp_mass.txt
- history.get_study_summary() called before history.close()
- Optuna nan rejection: fallback to INFEASIBLE_MASS penalty
- pyNastran warning 'nx 2512 not supported' is harmless (reads fine)
Root cause: Path.absolute() on Windows does NOT resolve '..' components.
sim_file_path was reaching NX as '...\studies\01_doe_landscape\..\..\models\Beam_sim1.sim'
NX likely can't resolve referenced parts from a path with '..' in it.
Fixes:
- nx_interface.py: glob from self.model_dir (resolved) not model_dir (raw)
- solver.py: sim_file.resolve() instead of sim_file.absolute()
- solve_simulation.py: os.path.abspath(sim_file_path) at entry point
- Diagnostic logging still in place for next run
Need to see why Parts.Open returns None even from the master model folder.
Logs: basePart1 type/name/path, unloaded parts status, file existence checks.
NX .sim files store absolute internal references to .fem/.prt files.
Copying them to iteration folders breaks these references (Parts.Open
returns None). Instead:
1. Backup master model once at study start
2. Restore from backup before each trial (isolation)
3. Solve on master model in-place (NX references intact)
4. Archive solver outputs (OP2/F06) + params.exp to iterations/iterNNN/
5. params.exp in each iteration: import into NX to recreate any trial
iteration_manager.py kept for future use but not wired in.
- history.db: SQLite append-only, never deleted by --clean
- history.csv: Auto-exported after each trial (live updates)
- Logs: DVs, results, feasibility, status, solve time, iter path
- Cross-study queries: full lineage across all runs/phases
- --clean only resets Optuna DB, history preserved
- Each iteration gets full model files in iterations/iterNNN/ (openable in NX)
- Retention: keep last 10 + best 3 with full models, strip the rest
- Stripped iterations keep solver outputs (OP2, F06, params, results)
- All paths resolved to absolute before passing to NX (fixes reference issue)
- iteration_manager.py: reusable for future studies
- One-time backup of model files at study start (_model_backup/)
- Restore clean state before each trial (files stay in models/, NX refs intact)
- If a trial corrupts the model, next trial starts clean
- Best of both: NX reference integrity + trial isolation
- Each iteration gets: params.json, results.json, OP2, F06, mass files
- Model directory stays clean (no solver output buildup)
- Study folder is self-contained with full trial history
- solve_simulation.py: FEM finder now excludes idealized parts, falls back to loading .fem
- solve_simulation.py: hole_count written as [Constant] not [MilliMeter] in .exp
- run_doe.py: dual logging to console + results/doe_run.log
Complete the NXOpenSolver class in nx_interface.py with production-ready
evaluate() and close() methods, following proven patterns from
M1_Mirror/SAT3_Trajectory_V7.
Pipeline per trial:
1. NXSolver.create_iteration_folder() — HEEDS-style isolation with fresh
model copies + params.exp generation
2. NXSolver.run_simulation() — journal-based solve via run_journal.exe
(handles expression import, geometry rebuild, FEM update, SOL 101)
3. extract_displacement() — max displacement from OP2
4. extract_solid_stress() — max von Mises with auto-detect element type
(tries all solid types first, falls back to CQUAD4 shell)
5. extract_mass_from_expression() — reads _temp_mass.txt from journal,
with _temp_part_properties.json fallback
Key decisions:
- Auto-detect element type for stress (element_type=None) instead of
hardcoding CQUAD4 — the beam model may use solid or shell elements
- Lazy solver init on first evaluate() call for clean error handling
- OP2 fallback path: tries solver result first, then expected naming
convention (beam_sim1-solution_1.op2)
- Mass fallback: _temp_mass.txt -> _temp_part_properties.json
- LAC-compliant close(): only uses session_manager.cleanup_stale_locks(),
never kills NX processes directly
Expression mapping (confirmed from binary introspection):
- beam_half_core_thickness, beam_face_thickness, holes_diameter, hole_count
- Mass output: p173 (body_property147.mass, kg)
Refs: OP_09, OPTIMIZATION_STRATEGY.md §8.2