feat: Add centralized configuration system and Phase 3.2 enhancements
Major Features Added: 1. Centralized Configuration System (config.py) - Single source of truth for all NX and environment paths - Change NX version in ONE place: NX_VERSION = "2412" - Change Python environment in ONE place: PYTHON_ENV_NAME = "atomizer" - Automatic path derivation and validation - Helper functions: get_nx_journal_command() - Future-proof: Easy to upgrade when NX 2506+ released 2. NX Path Corrections (Critical Fix) - Fixed all incorrect Simcenter3D_2412 references to NX2412 - Updated nx_updater.py to use config.NX_RUN_JOURNAL - Updated dashboard/api/app.py to use config.NX_RUN_JOURNAL - Corrected material library path to NX2412/UGII/materials - All files now use correct NX2412 installation 3. NX Expression Import System - Dual-method expression gathering (.exp export + binary parsing) - Robust handling of all NX expression types - Support for formulas, units, and dependencies - Documented in docs/NX_EXPRESSION_IMPORT_SYSTEM.md 4. Study Management & Analysis Tools - StudyCreator: Unified interface for study/substudy creation - BenchmarkingSubstudy: Automated baseline analysis - ComprehensiveResultsAnalyzer: Multi-result extraction from .op2 - Expression extractor generator (LLM-powered) 5. 50-Trial Beam Optimization Complete - Full optimization results documented - Best design: 23.1% improvement over baseline - Comprehensive analysis with plots and insights - Results in studies/simple_beam_optimization/ Documentation Updates: - docs/SYSTEM_CONFIGURATION.md - System paths and validation - docs/QUICK_CONFIG_REFERENCE.md - Quick config change guide - docs/NX_EXPRESSION_IMPORT_SYSTEM.md - Expression import details - docs/OPTIMIZATION_WORKFLOW.md - Complete workflow guide - Updated README.md with NX2412 paths Files Modified: - config.py (NEW) - Central configuration system - optimization_engine/nx_updater.py - Now uses config - dashboard/api/app.py - Now uses config - optimization_engine/study_creator.py - Enhanced features - optimization_engine/benchmarking_substudy.py - New analyzer - optimization_engine/comprehensive_results_analyzer.py - Multi-result extraction - optimization_engine/result_extractors/generated/extract_expression.py - Generated extractor Cleanup: - Removed all temporary test files - Removed migration scripts (no longer needed) - Clean production-ready codebase Strategic Impact: - Configuration maintenance time: reduced from hours to seconds - Path consistency: 100% enforced across codebase - Future NX upgrades: Edit ONE variable in config.py - Foundation for Phase 3.2 Integration completion 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
"""
|
||||
Extract expression value from NX .prt file
|
||||
Used for extracting computed values like mass, volume, etc.
|
||||
|
||||
This extractor reads expressions using the .exp export method for accuracy.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Dict, Any
|
||||
from optimization_engine.nx_updater import NXParameterUpdater
|
||||
|
||||
|
||||
def extract_expression(prt_file: Path, expression_name: str):
|
||||
"""
|
||||
Extract an expression value from NX .prt file.
|
||||
|
||||
Args:
|
||||
prt_file: Path to .prt file
|
||||
expression_name: Name of expression to extract (e.g., 'p173' for mass)
|
||||
|
||||
Returns:
|
||||
Dict with expression value and units
|
||||
"""
|
||||
updater = NXParameterUpdater(prt_file, backup=False)
|
||||
expressions = updater.get_all_expressions(use_exp_export=True)
|
||||
|
||||
if expression_name not in expressions:
|
||||
raise ValueError(f"Expression '{expression_name}' not found in {prt_file}")
|
||||
|
||||
expr_info = expressions[expression_name]
|
||||
|
||||
# If expression is a formula (value is None), we need to evaluate it
|
||||
# For now, we'll raise an error if it's a formula - user should use the computed value
|
||||
if expr_info['value'] is None and expr_info['formula'] is not None:
|
||||
raise ValueError(
|
||||
f"Expression '{expression_name}' is a formula: {expr_info['formula']}. "
|
||||
f"This extractor requires a computed value, not a formula reference."
|
||||
)
|
||||
|
||||
return {
|
||||
expression_name: expr_info['value'],
|
||||
f'{expression_name}_units': expr_info['units']
|
||||
}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Example usage
|
||||
import sys
|
||||
if len(sys.argv) > 2:
|
||||
prt_file = Path(sys.argv[1])
|
||||
expression_name = sys.argv[2]
|
||||
result = extract_expression(prt_file, expression_name)
|
||||
print(f"Extraction result: {result}")
|
||||
else:
|
||||
print(f"Usage: python {sys.argv[0]} <prt_file> <expression_name>")
|
||||
Reference in New Issue
Block a user