Ryan Malloy ba649d2a6e Add stability, power, optimization, batch, and schematic generation tools
Phase 3 features bringing the server to 27 tools:
- Stepped/multi-run .raw file parsing (.step, .mc, .temp)
- Stability analysis (gain/phase margin from AC loop gain)
- Power analysis (average, RMS, efficiency, power factor)
- Safe waveform expression evaluator (recursive-descent parser)
- Component value optimizer (binary search + coordinate descent)
- Batch simulation: parameter sweep, temperature sweep, Monte Carlo
- .asc schematic generation from templates (RC filter, divider, inverting amp)
- Touchstone .s1p/.s2p/.snp S-parameter file parsing
- 7 new netlist templates (diff amp, common emitter, buck, LDO, oscillator, H-bridge)
- Full ruff lint and format compliance across all modules
2026-02-10 23:05:35 -07:00

42 lines
1.2 KiB
Python

"""Configuration for mcp-ltspice."""
import os
from pathlib import Path
# LTspice installation paths
LTSPICE_DIR = Path(
os.environ.get("LTSPICE_DIR", Path.home() / "claude" / "ltspice" / "extracted" / "ltspice")
)
LTSPICE_EXE = LTSPICE_DIR / "LTspice.exe"
LTSPICE_LIB = LTSPICE_DIR / "lib"
LTSPICE_EXAMPLES = LTSPICE_DIR / "examples"
# Wine configuration
WINE_PREFIX = LTSPICE_DIR / ".wine"
WINE_DEBUG = os.environ.get("WINE_DEBUG", "-all")
# Simulation defaults
DEFAULT_TIMEOUT = 300 # 5 minutes
MAX_RAW_FILE_SIZE = 500 * 1024 * 1024 # 500MB
def get_wine_env() -> dict[str, str]:
"""Get environment variables for Wine execution."""
env = os.environ.copy()
env["WINEPREFIX"] = str(WINE_PREFIX)
env["WINEARCH"] = "win64"
env["WINEDEBUG"] = WINE_DEBUG
return env
def validate_installation() -> tuple[bool, str]:
"""Check if LTspice is properly installed."""
if not LTSPICE_DIR.exists():
return False, f"LTspice directory not found: {LTSPICE_DIR}"
if not LTSPICE_EXE.exists():
return False, f"LTspice executable not found: {LTSPICE_EXE}"
if not WINE_PREFIX.exists():
return False, f"Wine prefix not found: {WINE_PREFIX}"
return True, "LTspice installation OK"