Files
Atomizer/tests/audit_v10_fix.py
Anto01 f13563d7ab feat: Major update - Physics docs, Zernike OPD, insights, NX journals, tools
Documentation:
- Add docs/06_PHYSICS/ with Zernike fundamentals and OPD method docs
- Add docs/guides/CMA-ES_EXPLAINED.md optimization guide
- Update CLAUDE.md and ATOMIZER_CONTEXT.md with current architecture
- Update OP_01_CREATE_STUDY protocol

Planning:
- Add DYNAMIC_RESPONSE plans for random vibration/PSD support
- Add OPTIMIZATION_ENGINE_MIGRATION_PLAN for code reorganization

Insights System:
- Update design_space, modal_analysis, stress_field, thermal_field insights
- Improve error handling and data validation

NX Journals:
- Add analyze_wfe_zernike.py for Zernike WFE analysis
- Add capture_study_images.py for automated screenshots
- Add extract_expressions.py and introspect_part.py utilities
- Add user_generated_journals/journal_top_view_image_taking.py

Tests & Tools:
- Add comprehensive Zernike OPD test suite
- Add audit_v10 tests for WFE validation
- Add tools for Pareto graphs and mirror data extraction
- Add migrate_studies_to_topics.py utility

Knowledge Base:
- Initialize LAC (Learning Atomizer Core) with failure/success patterns

Dashboard:
- Update Setup.tsx and launch_dashboard.py
- Add restart-dev.bat helper script

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 19:47:37 -05:00

75 lines
3.3 KiB
Python

"""Verify the V10 fix - compare Standard extract_relative vs OPD extract_relative."""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
from optimization_engine.extractors import ZernikeExtractor, ZernikeOPDExtractor
op2 = Path('studies/M1_Mirror/m1_mirror_cost_reduction_V10/2_iterations/iter1/assy_m1_assyfem1_sim1-solution_1.op2')
print("="*70)
print("VERIFICATION: ZernikeOPDExtractor.extract_relative() vs Standard")
print("="*70)
print()
# Standard extractor
extractor_std = ZernikeExtractor(op2, n_modes=50, filter_orders=4)
# OPD extractor (with XY lateral correction)
extractor_opd = ZernikeOPDExtractor(op2, n_modes=50, filter_orders=4)
print("Standard ZernikeExtractor.extract_relative():")
rel_40_std = extractor_std.extract_relative('3', '2')
rel_60_std = extractor_std.extract_relative('4', '2')
rel_90_std = extractor_std.extract_relative('1', '2')
print(f" 40-20: {rel_40_std['relative_filtered_rms_nm']:.2f} nm")
print(f" 60-20: {rel_60_std['relative_filtered_rms_nm']:.2f} nm")
print(f" 90-20 (j1to3): {rel_90_std['relative_rms_filter_j1to3']:.2f} nm")
print()
print("NEW ZernikeOPDExtractor.extract_relative() (with XY lateral correction):")
rel_40_opd = extractor_opd.extract_relative('3', '2')
rel_60_opd = extractor_opd.extract_relative('4', '2')
rel_90_opd = extractor_opd.extract_relative('1', '2')
print(f" 40-20: {rel_40_opd['relative_filtered_rms_nm']:.2f} nm")
print(f" 60-20: {rel_60_opd['relative_filtered_rms_nm']:.2f} nm")
print(f" 90-20 (j1to3): {rel_90_opd['relative_rms_filter_j1to3']:.2f} nm")
print()
print("Lateral displacement diagnostics (OPD method):")
print(f" Max lateral: {rel_40_opd['max_lateral_displacement_um']:.3f} um")
print(f" RMS lateral: {rel_40_opd['rms_lateral_displacement_um']:.3f} um")
print()
print("="*70)
print("COMPARISON")
print("="*70)
print()
print(f"{'Metric':<20} | {'Standard':<12} | {'OPD':<12} | {'Diff %':<10}")
print("-"*60)
def pct_diff(a, b):
return 100.0 * (b - a) / a if a > 0 else 0
print(f"{'40-20 (nm)':<20} | {rel_40_std['relative_filtered_rms_nm']:>12.2f} | {rel_40_opd['relative_filtered_rms_nm']:>12.2f} | {pct_diff(rel_40_std['relative_filtered_rms_nm'], rel_40_opd['relative_filtered_rms_nm']):>+10.1f}%")
print(f"{'60-20 (nm)':<20} | {rel_60_std['relative_filtered_rms_nm']:>12.2f} | {rel_60_opd['relative_filtered_rms_nm']:>12.2f} | {pct_diff(rel_60_std['relative_filtered_rms_nm'], rel_60_opd['relative_filtered_rms_nm']):>+10.1f}%")
print(f"{'90-20 j1to3 (nm)':<20} | {rel_90_std['relative_rms_filter_j1to3']:>12.2f} | {rel_90_opd['relative_rms_filter_j1to3']:>12.2f} | {pct_diff(rel_90_std['relative_rms_filter_j1to3'], rel_90_opd['relative_rms_filter_j1to3']):>+10.1f}%")
print()
print("="*70)
print("WHAT V9 REPORTED (for comparison)")
print("="*70)
print(" 40-20: 6.10 nm (from DB)")
print(" 60-20: 12.76 nm (from DB)")
print()
print("V10 SHOULD NOW REPORT (using OPD extract_relative):")
print(f" 40-20: {rel_40_opd['relative_filtered_rms_nm']:.2f} nm")
print(f" 60-20: {rel_60_opd['relative_filtered_rms_nm']:.2f} nm")
print(f" 90-20: {rel_90_opd['relative_rms_filter_j1to3']:.2f} nm")
print()
print("V10 OLD WRONG VALUES WERE:")
print(" 40-20: 1.99 nm (WRONG - was computing abs(RMS_target - RMS_ref))")
print(" 60-20: 6.82 nm (WRONG)")
print()
print("FIX VERIFIED: OPD extract_relative() correctly computes RMS of (WFE_target - WFE_ref)")