Files
Atomizer/tests/test_timestamp_verification.py

71 lines
2.2 KiB
Python
Raw Permalink Normal View History

feat: Add substudy system with live history tracking and workflow fixes Major Features: - Hierarchical substudy system (like NX Solutions/Subcases) * Shared model files across all substudies * Independent configuration per substudy * Continuation support from previous substudies * Real-time incremental history updates - Live history tracking with optimization_history_incremental.json - Complete bracket_displacement_maximizing study with substudy examples Core Fixes: - Fixed expression update workflow to pass design_vars through simulation_runner * Restored working NX journal expression update mechanism * OP2 timestamp verification instead of file deletion * Resolved issue where all trials returned identical objective values - Fixed LLMOptimizationRunner to pass design variables to simulation runner - Enhanced NXSolver with timestamp-based file regeneration verification New Components: - optimization_engine/llm_optimization_runner.py - LLM-driven optimization runner - optimization_engine/optimization_setup_wizard.py - Phase 3.3 setup wizard - studies/bracket_displacement_maximizing/ - Complete substudy example * run_substudy.py - Substudy runner with continuation * run_optimization.py - Standalone optimization runner * config/substudy_template.json - Template for new substudies * substudies/coarse_exploration/ - 20-trial coarse search * substudies/fine_tuning/ - 50-trial refinement (continuation example) * SUBSTUDIES_README.md - Complete substudy documentation Technical Improvements: - Incremental history saving after each trial (optimization_history_incremental.json) - Expression update workflow: .prt update → NX journal receives values → geometry update → FEM update → solve - Trial indexing fix in substudy result saving - Updated README with substudy system documentation Testing: - Successfully ran 20-trial coarse_exploration substudy - Verified different objective values across trials (workflow fix validated) - Confirmed live history updates in real-time - Tested shared model file usage across substudies 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 21:29:54 -05:00
"""
Test: Verify NX regenerates .dat and .op2 files with new timestamps
This test verifies the fix for OP2 caching by checking file timestamps.
"""
from pathlib import Path
import sys
import time
sys.path.insert(0, str(Path(__file__).parent.parent))
from optimization_engine.nx.solver import NXSolver
feat: Add substudy system with live history tracking and workflow fixes Major Features: - Hierarchical substudy system (like NX Solutions/Subcases) * Shared model files across all substudies * Independent configuration per substudy * Continuation support from previous substudies * Real-time incremental history updates - Live history tracking with optimization_history_incremental.json - Complete bracket_displacement_maximizing study with substudy examples Core Fixes: - Fixed expression update workflow to pass design_vars through simulation_runner * Restored working NX journal expression update mechanism * OP2 timestamp verification instead of file deletion * Resolved issue where all trials returned identical objective values - Fixed LLMOptimizationRunner to pass design variables to simulation runner - Enhanced NXSolver with timestamp-based file regeneration verification New Components: - optimization_engine/llm_optimization_runner.py - LLM-driven optimization runner - optimization_engine/optimization_setup_wizard.py - Phase 3.3 setup wizard - studies/bracket_displacement_maximizing/ - Complete substudy example * run_substudy.py - Substudy runner with continuation * run_optimization.py - Standalone optimization runner * config/substudy_template.json - Template for new substudies * substudies/coarse_exploration/ - 20-trial coarse search * substudies/fine_tuning/ - 50-trial refinement (continuation example) * SUBSTUDIES_README.md - Complete substudy documentation Technical Improvements: - Incremental history saving after each trial (optimization_history_incremental.json) - Expression update workflow: .prt update → NX journal receives values → geometry update → FEM update → solve - Trial indexing fix in substudy result saving - Updated README with substudy system documentation Testing: - Successfully ran 20-trial coarse_exploration substudy - Verified different objective values across trials (workflow fix validated) - Confirmed live history updates in real-time - Tested shared model file usage across substudies 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-16 21:29:54 -05:00
print("=" * 60)
print("Testing timestamp verification fix")
print("=" * 60)
sim_file = Path('studies/bracket_displacement_maximizing/model/Bracket_sim1.sim')
if not sim_file.exists():
print(f"ERROR: Simulation file not found: {sim_file}")
sys.exit(1)
# Check current timestamps
dat_file = sim_file.parent / "bracket_sim1-solution_1.dat"
op2_file = sim_file.parent / "bracket_sim1-solution_1.op2"
print(f"\nSimulation file: {sim_file}")
print(f"Working directory: {sim_file.parent}")
if dat_file.exists():
old_dat_time = dat_file.stat().st_mtime
print(f"\nBefore solve:")
print(f" .dat modified: {time.ctime(old_dat_time)}")
if op2_file.exists():
old_op2_time = op2_file.stat().st_mtime
print(f" .op2 modified: {time.ctime(old_op2_time)}")
# Run solve with timestamp verification
print(f"\nRunning solve with timestamp verification...")
solver = NXSolver(nastran_version='2412', use_journal=True)
result = solver.run_simulation(sim_file)
print(f"\nSolve result: {'SUCCESS' if result['success'] else 'FAILED'}")
# Check new timestamps
if op2_file.exists():
new_op2_time = op2_file.stat().st_mtime
print(f"\nAfter solve:")
print(f" .op2 modified: {time.ctime(new_op2_time)}")
if 'old_op2_time' in locals():
if new_op2_time > old_op2_time:
print(f"\n ✓ SUCCESS! .op2 file was regenerated!")
print(f" Time difference: {new_op2_time - old_op2_time:.1f} seconds")
else:
print(f"\n ✗ FAILED! .op2 file was NOT updated")
print(f" This means NX did not regenerate the file")
else:
print(f"\n ✓ New .op2 file created")
if dat_file.exists():
new_dat_time = dat_file.stat().st_mtime
print(f" .dat modified: {time.ctime(new_dat_time)}")
if 'old_dat_time' in locals():
if new_dat_time > old_dat_time:
print(f"\n ✓ .dat file was also regenerated")