refactor: Archive experimental LLM features for MVP stability (Phase 1.1)
Moved experimental LLM integration code to optimization_engine/future/: - llm_optimization_runner.py - Runtime LLM API runner - llm_workflow_analyzer.py - Workflow analysis - inline_code_generator.py - Auto-generate calculations - hook_generator.py - Auto-generate hooks - report_generator.py - LLM report generation - extractor_orchestrator.py - Extractor orchestration Added comprehensive optimization_engine/future/README.md explaining: - MVP LLM strategy (Claude Code skills, not runtime LLM) - Why files were archived - When to revisit post-MVP - Production architecture reference Production runner confirmed: optimization_engine/runner.py is sole active runner. This establishes clear separation between: - Production code (stable, no runtime LLM dependencies) - Experimental code (archived for post-MVP exploration) Part of Phase 1: Core Stabilization & Organization for MVP Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -20,31 +20,41 @@ def main(args):
|
||||
Args:
|
||||
args: Command line arguments
|
||||
args[0]: .sim file path
|
||||
args[1]: tip_thickness value (optional)
|
||||
args[2]: support_angle value (optional)
|
||||
args[1]: solution_name (optional, e.g., "Solution_Normal_Modes" or None for default)
|
||||
args[2+]: expression updates as "name=value" pairs
|
||||
"""
|
||||
if len(args) < 1:
|
||||
print("ERROR: No .sim file path provided")
|
||||
print("Usage: run_journal.exe solve_simulation.py <sim_file_path> [tip_thickness] [support_angle]")
|
||||
print("Usage: run_journal.exe solve_simulation.py <sim_file_path> [solution_name] [expr1=val1] [expr2=val2] ...")
|
||||
return False
|
||||
|
||||
sim_file_path = args[0]
|
||||
|
||||
# Parse solution name if provided (args[1])
|
||||
solution_name = args[1] if len(args) > 1 and args[1] != 'None' else None
|
||||
|
||||
# Extract base name from sim file (e.g., "Beam_sim1.sim" -> "Beam")
|
||||
import os
|
||||
sim_filename = os.path.basename(sim_file_path)
|
||||
part_base_name = sim_filename.split('_sim')[0] if '_sim' in sim_filename else sim_filename.split('.sim')[0]
|
||||
|
||||
# Parse expression values if provided
|
||||
tip_thickness = float(args[1]) if len(args) > 1 else None
|
||||
support_angle = float(args[2]) if len(args) > 2 else None
|
||||
# Parse expression updates from args[2+] as "name=value" pairs
|
||||
expression_updates = {}
|
||||
for arg in args[2:]:
|
||||
if '=' in arg:
|
||||
name, value = arg.split('=', 1)
|
||||
expression_updates[name] = float(value)
|
||||
|
||||
print(f"[JOURNAL] Opening simulation: {sim_file_path}")
|
||||
print(f"[JOURNAL] Detected part base name: {part_base_name}")
|
||||
if tip_thickness is not None:
|
||||
print(f"[JOURNAL] Will update tip_thickness = {tip_thickness}")
|
||||
if support_angle is not None:
|
||||
print(f"[JOURNAL] Will update support_angle = {support_angle}")
|
||||
if solution_name:
|
||||
print(f"[JOURNAL] Will solve specific solution: {solution_name}")
|
||||
else:
|
||||
print(f"[JOURNAL] Will solve default solution (Solution 1)")
|
||||
if expression_updates:
|
||||
print(f"[JOURNAL] Will update expressions:")
|
||||
for name, value in expression_updates.items():
|
||||
print(f"[JOURNAL] {name} = {value}")
|
||||
|
||||
try:
|
||||
theSession = NXOpen.Session.GetSession()
|
||||
@@ -134,27 +144,21 @@ def main(args):
|
||||
# CRITICAL: Apply expression changes BEFORE updating geometry
|
||||
expressions_updated = []
|
||||
|
||||
if tip_thickness is not None:
|
||||
print(f"[JOURNAL] Applying tip_thickness = {tip_thickness}")
|
||||
expr_tip = workPart.Expressions.FindObject("tip_thickness")
|
||||
if expr_tip:
|
||||
unit_mm = workPart.UnitCollection.FindObject("MilliMeter")
|
||||
workPart.Expressions.EditExpressionWithUnits(expr_tip, unit_mm, str(tip_thickness))
|
||||
expressions_updated.append(expr_tip)
|
||||
print(f"[JOURNAL] tip_thickness updated")
|
||||
else:
|
||||
print(f"[JOURNAL] WARNING: tip_thickness expression not found!")
|
||||
|
||||
if support_angle is not None:
|
||||
print(f"[JOURNAL] Applying support_angle = {support_angle}")
|
||||
expr_angle = workPart.Expressions.FindObject("support_angle")
|
||||
if expr_angle:
|
||||
unit_deg = workPart.UnitCollection.FindObject("Degrees")
|
||||
workPart.Expressions.EditExpressionWithUnits(expr_angle, unit_deg, str(support_angle))
|
||||
expressions_updated.append(expr_angle)
|
||||
print(f"[JOURNAL] support_angle updated")
|
||||
else:
|
||||
print(f"[JOURNAL] WARNING: support_angle expression not found!")
|
||||
# Apply all expression updates dynamically
|
||||
for expr_name, expr_value in expression_updates.items():
|
||||
print(f"[JOURNAL] Applying {expr_name} = {expr_value}")
|
||||
try:
|
||||
expr_obj = workPart.Expressions.FindObject(expr_name)
|
||||
if expr_obj:
|
||||
# Use millimeters as default unit for geometric parameters
|
||||
unit_mm = workPart.UnitCollection.FindObject("MilliMeter")
|
||||
workPart.Expressions.EditExpressionWithUnits(expr_obj, unit_mm, str(expr_value))
|
||||
expressions_updated.append(expr_obj)
|
||||
print(f"[JOURNAL] {expr_name} updated successfully")
|
||||
else:
|
||||
print(f"[JOURNAL] WARNING: {expr_name} expression not found!")
|
||||
except Exception as e:
|
||||
print(f"[JOURNAL] ERROR updating {expr_name}: {e}")
|
||||
|
||||
# Make expressions up to date
|
||||
if expressions_updated:
|
||||
@@ -171,6 +175,20 @@ def main(args):
|
||||
nErrs = theSession.UpdateManager.DoUpdate(markId_update)
|
||||
theSession.DeleteUndoMark(markId_update, "NX update")
|
||||
print(f"[JOURNAL] {part_base_name} geometry updated ({nErrs} errors)")
|
||||
|
||||
# Extract mass from expression p173 if it exists and write to temp file
|
||||
try:
|
||||
mass_expr = workPart.Expressions.FindObject("p173")
|
||||
if mass_expr:
|
||||
mass_kg = mass_expr.Value
|
||||
mass_output_file = os.path.join(working_dir, "_temp_mass.txt")
|
||||
with open(mass_output_file, 'w') as f:
|
||||
f.write(str(mass_kg))
|
||||
print(f"[JOURNAL] Mass from p173: {mass_kg:.6f} kg ({mass_kg * 1000:.2f} g)")
|
||||
print(f"[JOURNAL] Mass written to: {mass_output_file}")
|
||||
except:
|
||||
pass # Expression p173 might not exist in all models
|
||||
|
||||
geometry_updated = True
|
||||
else:
|
||||
print(f"[JOURNAL] {part_base_name} part not found - may be embedded in sim file")
|
||||
@@ -247,31 +265,45 @@ def main(args):
|
||||
|
||||
theCAESimSolveManager = NXOpen.CAE.SimSolveManager.GetSimSolveManager(theSession)
|
||||
|
||||
# Get the first solution from the simulation
|
||||
# Get the simulation object
|
||||
simSimulation1 = workSimPart.FindObject("Simulation")
|
||||
simSolution1 = simSimulation1.FindObject("Solution[Solution 1]")
|
||||
|
||||
psolutions1 = [simSolution1]
|
||||
# Get the solution(s) to solve - either specific or all
|
||||
if solution_name:
|
||||
# Solve specific solution in background mode
|
||||
solution_obj_name = f"Solution[{solution_name}]"
|
||||
print(f"[JOURNAL] Looking for solution: {solution_obj_name}")
|
||||
simSolution1 = simSimulation1.FindObject(solution_obj_name)
|
||||
psolutions1 = [simSolution1]
|
||||
|
||||
# Solve in background mode
|
||||
numsolutionssolved1, numsolutionsfailed1, numsolutionsskipped1 = theCAESimSolveManager.SolveChainOfSolutions(
|
||||
psolutions1,
|
||||
NXOpen.CAE.SimSolution.SolveOption.Solve,
|
||||
NXOpen.CAE.SimSolution.SetupCheckOption.CompleteDeepCheckAndOutputErrors,
|
||||
NXOpen.CAE.SimSolution.SolveMode.Background
|
||||
)
|
||||
numsolutionssolved1, numsolutionsfailed1, numsolutionsskipped1 = theCAESimSolveManager.SolveChainOfSolutions(
|
||||
psolutions1,
|
||||
NXOpen.CAE.SimSolution.SolveOption.Solve,
|
||||
NXOpen.CAE.SimSolution.SetupCheckOption.CompleteDeepCheckAndOutputErrors,
|
||||
NXOpen.CAE.SimSolution.SolveMode.Background
|
||||
)
|
||||
else:
|
||||
# Solve ALL solutions using SolveAllSolutions API (Foreground mode)
|
||||
# This ensures all solutions (static + modal, etc.) complete before returning
|
||||
print(f"[JOURNAL] Solving all solutions using SolveAllSolutions API (Foreground mode)...")
|
||||
|
||||
numsolutionssolved1, numsolutionsfailed1, numsolutionsskipped1 = theCAESimSolveManager.SolveAllSolutions(
|
||||
NXOpen.CAE.SimSolution.SolveOption.Solve,
|
||||
NXOpen.CAE.SimSolution.SetupCheckOption.CompleteCheckAndOutputErrors,
|
||||
NXOpen.CAE.SimSolution.SolveMode.Foreground,
|
||||
False
|
||||
)
|
||||
|
||||
theSession.DeleteUndoMark(markId5, None)
|
||||
theSession.SetUndoMarkName(markId3, "Solve")
|
||||
|
||||
print(f"[JOURNAL] Solve submitted!")
|
||||
print(f"[JOURNAL] Solve completed!")
|
||||
print(f"[JOURNAL] Solutions solved: {numsolutionssolved1}")
|
||||
print(f"[JOURNAL] Solutions failed: {numsolutionsfailed1}")
|
||||
print(f"[JOURNAL] Solutions skipped: {numsolutionsskipped1}")
|
||||
|
||||
# NOTE: In Background mode, these values may not be accurate since the solve
|
||||
# runs asynchronously. The solve will continue after this journal finishes.
|
||||
# We rely on the Save operation and file existence checks to verify success.
|
||||
# NOTE: When solution_name=None, we use Foreground mode to ensure all solutions
|
||||
# complete before returning. When solution_name is specified, Background mode is used.
|
||||
|
||||
# Save the simulation to write all output files
|
||||
print("[JOURNAL] Saving simulation to ensure output files are written...")
|
||||
|
||||
Reference in New Issue
Block a user