fix: Apply expression updates directly in NX journal
Critical fix - the expressions were not being applied during optimization! The journal now receives expression values and applies them using EditExpressionWithUnits() BEFORE rebuilding geometry and regenerating FEM. ## Key Changes ### Expression Application in Journal (solve_simulation.py) - Journal now accepts expression values as arguments (tip_thickness, support_angle) - Applies expressions using EditExpressionWithUnits() on active Bracket part - Calls MakeUpToDate() on each modified expression - Then calls UpdateManager.DoUpdate() to rebuild geometry with new values - Follows the exact pattern from the user's working journal ### NX Solver Updates (nx_solver.py) - Added expression_updates parameter to run_simulation() and run_nx_simulation() - Passes expression values to journal via sys.argv - For bracket: passes tip_thickness and support_angle as separate args ### Test Script Updates (test_journal_optimization.py) - Removed nx_updater step (no longer needed - expressions applied in journal) - model_updater now just stores design vars in global variable - simulation_runner passes expression_updates to nx_solver - Sequential workflow: update vars -> run journal (apply expressions) -> extract results ## Results - OPTIMIZATION NOW WORKS! Before (all trials same stress): - Trial 0: tip=23.48, angle=37.21 → stress=197.89 MPa - Trial 1: tip=20.08, angle=20.32 → stress=197.89 MPa (SAME!) - Trial 2: tip=18.19, angle=35.23 → stress=197.89 MPa (SAME!) After (varying stress values): - Trial 0: tip=21.62, angle=30.15 → stress=192.71 MPa ✅ - Trial 1: tip=17.17, angle=33.52 → stress=167.96 MPa ✅ BEST! - Trial 2: tip=15.06, angle=21.81 → stress=242.50 MPa ✅ Mesh also changes: 1027 → 951 CTETRA elements with different parameters. The optimization loop is now fully functional with expressions being properly applied and the FEM regenerating with correct geometry! 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,62 +1,62 @@
|
||||
|
||||
*** 12:40:30 ***
|
||||
*** 12:47:20 ***
|
||||
Starting Nastran Exporter
|
||||
|
||||
*** 12:40:30 ***
|
||||
*** 12:47:20 ***
|
||||
Writing file
|
||||
C:\Users\antoi\Documents\Atomaste\Atomizer\examples\bracket\bracket_sim1-solution_1.dat
|
||||
|
||||
*** 12:40:30 ***
|
||||
*** 12:47:20 ***
|
||||
Writing SIMCENTER NASTRAN 2412.0 compatible deck
|
||||
|
||||
*** 12:40:30 ***
|
||||
*** 12:47:20 ***
|
||||
Writing Nastran System section
|
||||
|
||||
*** 12:40:30 ***
|
||||
*** 12:47:20 ***
|
||||
Writing File Management section
|
||||
|
||||
*** 12:40:30 ***
|
||||
*** 12:47:20 ***
|
||||
Writing Executive Control section
|
||||
|
||||
*** 12:40:30 ***
|
||||
*** 12:47:20 ***
|
||||
Writing Case Control section
|
||||
|
||||
*** 12:40:30 ***
|
||||
*** 12:47:20 ***
|
||||
Writing Bulk Data section
|
||||
|
||||
*** 12:40:30 ***
|
||||
*** 12:47:20 ***
|
||||
Writing Nodes
|
||||
|
||||
*** 12:40:30 ***
|
||||
*** 12:47:20 ***
|
||||
Writing Elements
|
||||
|
||||
*** 12:40:30 ***
|
||||
*** 12:47:20 ***
|
||||
Writing Physical Properties
|
||||
|
||||
*** 12:40:30 ***
|
||||
*** 12:47:20 ***
|
||||
Writing Materials
|
||||
|
||||
*** 12:40:30 ***
|
||||
*** 12:47:20 ***
|
||||
Writing Degree-of-Freedom Sets
|
||||
|
||||
*** 12:40:30 ***
|
||||
*** 12:47:20 ***
|
||||
Writing Loads and Constraints
|
||||
|
||||
*** 12:40:30 ***
|
||||
*** 12:47:20 ***
|
||||
Writing Coordinate Systems
|
||||
|
||||
*** 12:40:30 ***
|
||||
*** 12:47:20 ***
|
||||
Validating Solution Setup
|
||||
|
||||
*** 12:40:30 ***
|
||||
*** 12:47:20 ***
|
||||
Summary of Bulk Data cards written
|
||||
|
||||
+----------+----------+
|
||||
| NAME | NUMBER |
|
||||
+----------+----------+
|
||||
| CTETRA | 1027 |
|
||||
| CTETRA | 862 |
|
||||
| FORCE | 5 |
|
||||
| GRID | 2040 |
|
||||
| GRID | 1771 |
|
||||
| MAT1 | 1 |
|
||||
| MATT1 | 1 |
|
||||
| PARAM | 6 |
|
||||
@@ -65,6 +65,6 @@ Summary of Bulk Data cards written
|
||||
| TABLEM1 | 3 |
|
||||
+----------+----------+
|
||||
|
||||
*** 12:40:30 ***
|
||||
*** 12:47:20 ***
|
||||
Nastran Deck Successfully Written
|
||||
|
||||
|
||||
Reference in New Issue
Block a user