pyEPR

zlatko-minev活跃维护

用能量参与比方法自动分析和设计量子微波芯片与器件,把超导量子电路的设计流程从手工仿真变成脚本化计算。

Powerful, automated analysis and design of quantum microwave chips & devices [Energy-Participation Ratio and more]

1.0.2发布于 2026-09-28 01:26 UTC212star277fork同步于 2026-11-11 00:02 UTC

怎么上手

由 README 提炼,执行前请确认
pip install pyEPR-quantum
pip install "pyEPR-quantum[pyaedt]"
硬件要求按 README 说明

README 未说明显存或 GPU 要求;纯数值对角化可在普通 CPU 上运行,HFSS 仿真部分需本机或远程 Windows 上的 Ansys HFSS 及相应许可。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用能量参与比方法把 HFSS 电磁仿真结果自动转成量子比特哈密顿量,省去手工推导

用能量参与比方法自动分析和设计量子微波芯片与器件,把超导量子电路的设计流程从手工仿真变成脚本化计算。

核心能力

  • 从 HFSS 本征模仿真提取能量参与比 p_mj 与零点相位涨落
  • 数值对角化哈密顿量,输出缀饰频率、非谐性与色散位移矩阵 χ
  • 支持任意模式数与结数,可处理通量子等强非谐电路
  • 提供纯数值工作流,无需 HFSS 许可即可算 transmon 非谐性
  • 新增基于 PyAEDT 的 gRPC 后端,可在 Linux 和 macOS 上连接 AEDT

容易踩的坑

HFSS 工作流需 Ansys 许可,且经典 COM 后端基本只能在 Windows 上使用;用 gRPC 后端要额外安装 pyaedt 可选依赖;HFSS 中每个约瑟夫森结需手动建矩形 Lumped RLC 边界和折线,参数扫描还需开启 Save Fields。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本1.0.2
  1. 1.0.2最新正式版2026-09-28 · 2026-09-28 01:26 UTC

    NumPy 2 and pandas 3 compatibility fixes.

    Bug fixes

    • NumPy 2: print_matrix, df_interpolate_value and df_find_index raised AttributeError. They used np.mat and np.NaN, which NumPy 2.0 removed. print_matrix runs at the end of every QuantumAnalysis.analyze_variation() with print_result=True, the default, so a default EPR analysis stopped at its report under NumPy 2. print_matrix now uses a 2-D array (not numpy.matrix, which NumPy is deprecating) and the other two use np.nan; both work with NumPy 1.x too. A new test (tests/test_numpy2_compat.py) runs the three helpers and fails if any removed NumPy name appears in the package source.
    • pandas 3: reading a Q3D matrix export raised TypeError. AnsysQ3DSetup.load_q3d_matrix (through _readin_Q3D_matrix) called pd.read_csv(delim_whitespace=True), deprecated in pandas 2.2 and removed in 3.0. It now uses sep=r"\s+", the same parsing. Tested on the sample export from the docstring (tests/test_q3d_matrix_reader.py), with pandas 2.3 and 3.0.
    • df_find_index compared the target with the index, not the values. It finds the index (e.g. Lj) that gives a target value (e.g. a frequency), but chose between interpolating and extrapolating by checking the target against the index range, so a target inside the value range could be extrapolated (with a degree-2 fit through the points) instead of interpolated.

    Documentation

    • The docs build with 0 warnings: conf.py assigned exclude_patterns a second time (empty), which discarded the first; README notes beside the tutorial notebooks are now excluded.

    Full changelog: https://github.com/zlatko-minev/pyEPR/blob/master/CHANGELOG.md

  2. 1.0.12026-07-17 · 2026-07-17 18:24 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/zlatko-minev/pyEPR/compare/1.0.0...1.0.1

  3. 1.0.0PyEPR v1!2026-06-27 · 2026-06-27 16:38 UTC
    查看更新说明

    What's new in 1.0.0

    First major release — marking a decade of use in quantum hardware labs and the first release with cross-platform HFSS access.

    New features

    • PyAEDT / gRPC backend (pyEPR.ansys_pyaedt.PyaedtDistributedAnalysis) — runs the full EPR field extraction through Ansys's official PyAEDT library entirely over gRPC. No COM, no pywin32. Works on Linux, macOS, and Windows. Contributed by Joey Yaker. Validated digit-for-digit against the COM path (p_mj = 0.9755, pyaedt 1.1.0 + AEDT 2026.1). Install: pip install "pyEPR-quantum[pyaedt]"

    • Tutorial 7 — end-to-end PyAEDT workflow notebook.

    • Docs — new pyaedt_backend page, updated landing page and README featuring both backends.

    No breaking changes

    All existing COM workflows (DistributedAnalysis, QuantumAnalysis, ProjectInfo) and deprecated aliases are unchanged. The [pyaedt] extra is strictly optional — import pyEPR never requires it.

    Upgrading from 0.9.x

    Drop-in. No call-site changes needed. Optionally install the gRPC backend with pip install "pyEPR-quantum[pyaedt]"

    What's Changed

    New Contributors

    Full Changelog: https://github.com/zlatko-minev/pyEPR/compare/0.9.6...1.0.0

  4. 0.9.6pyEPR v0.9.6 — Documentation & CI overhaul2026-05-17 · 2026-05-17 13:57 UTC
    查看更新说明

    pyEPR v0.9.6 — Documentation & CI overhaul

    Documentation

    • New theme — migrated from sphinx-rtd-theme to PyData Sphinx Theme (same theme as NumPy, SciPy, pandas, QuTiP). Landing page now has a feature-card hero, install tabs, and a five-line quickstart.
    • sphinx-design components — hero image, three feature cards (Simulate / Extract / Diagonalize), pip/conda/uv install tabs, and HFSS-required / no-HFSS-required badges throughout.
    • myst-nb replaces nbsphinx for rendering tutorial notebooks (pre-executed outputs, no kernel needed).
    • Tutorials page — all six tutorial notebooks shown in order (1–6) as clickable cards with consistent titles. Tutorials 3, 5, 6 marked No HFSS required; 1, 2, 4 marked Ansys HFSS required.
    • Zero-warning Sphinx build — down from 177 warnings. Fixed header levels, duplicate object descriptions, dead substitution references, broken code-block directives, and RST markup errors across ansys.py, calcs/, toolbox/, and core_*.py.
    • About page — replaced dead badge image URLs (frapsoft.com, rawgit.com) with sphinx-design inline badges.
    • Key Classes reference — slimmed to narrative-only with cross-reference links; moved up in TOC as onboarding material.
    • README — absolute raw.githubusercontent.com image URLs so the hero image and xmon GIF render correctly on PyPI.

    CI / Build

    • RTD pre-build step — _tutorial_notebooks/ is copied into docs/source/ before Sphinx runs (Sphinx does not follow symlinks outside the source root).
    • CI test_docs job — same notebook copy step added so the docs build is consistent between RTD and GitHub Actions.
    • CI matrix — Python 3.10 + 3.12 on Ubuntu and macOS (dropped Python 3.9).
    • pandoc added as an RTD apt package (required by myst-nb for some notebook outputs).

    Dependencies

    • Added: pydata-sphinx-theme, sphinx-design, myst-nb
    • Removed: sphinx-rtd-theme, sphinx-tabs, nbsphinx

    What's Changed

    Full Changelog: https://github.com/zlatko-minev/pyEPR/compare/0.9.5...0.9.6

  5. 0.9.5pyEPR 0.9.5 — Exact cosine diagonalization, generic junction potential, documentation refresh2026-05-17 · 2026-05-17 04:15 UTC
    查看更新说明

    What's new in 0.9.5

    New features

    Exact cosine diagonalization (use_full_cos=True) For strongly anharmonic circuits such as fluxonium (φ_zpf ≳ 1) the truncated Taylor series diverges. Pass use_full_cos=True to epr_numerical_diagonalization or analyze_variation to evaluate cos(φ) − 1 + φ²/2 exactly via matrix exponential. See MatrixOps.cos_full_correction and arXiv:2411.15039.

    Generic junction potential (make_nonlinear_potential) Convert any scalar Python function V(φ) — flux-biased junctions, asymmetric SQUIDs, exotic elements — into the EPR-compatible operator-valued correction, automatically expanding around the bias minimum.

    from pyEPR.calcs import make_nonlinear_potential
    nl = make_nonlinear_potential(lambda phi: -np.cos(phi - phi_ext))
    
    

    Public Q3D convergence plot API pyEPR.reports.plot_q3d_convergence_main and plot_q3d_convergence_chi_f are now public documented functions. Old underscore names remain as aliases. Tutorial 5 — Generic junction potential and fluxonium EPR Tutorial 6 — EPR without HFSS — purely numerical workflow Improvements • Numeric sort for >9 variations (fixes “10” sorting before “2”) • Float sweep variable sort fixed for small floats (e.g. Lj = 1.4e-8) • DeprecationWarning on Project_Info, pyEPR_HFSSAnalysis, pyEPR_Analysis • Logger replaces print in DistributedAnalysis and QuantumAnalysis • NumPy-style docstrings on all major classes and functions • All 6 tutorials refreshed with EPR physics, derivations, and references Upgrading from 0.9.4 No breaking changes. All existing call signatures are unchanged. If you use Project_Info, pyEPR_HFSSAnalysis, or pyEPR_Analysis you will see a DeprecationWarning — update to ProjectInfo, DistributedAnalysis, QuantumAnalysis at your convenience. Full changelog See CHANGELOG.md.

    What's Changed

    Full Changelog: https://github.com/zlatko-minev/pyEPR/compare/0.9.4...0.9.5

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    pyEPR — Energy-Participation-Ratio Framework

    Automated Python module for the design and quantization of Josephson quantum circuits

    PyPI version CI DOI Binder Open Source

    pyEPR bridges classical EM simulation and quantum circuit theory via the energy-participation ratio (EPR) method. Given a 3-D HFSS eigenmode simulation — or your own frequencies and inductances — it extracts the full quantum Hamiltonian in minutes:

    1. Simulate the linearized circuit in Ansys HFSS to get eigenmode frequencies and field distributions.
    2. Extract energy participation ratios $p_{mj}$ and zero-point phase fluctuations $\varphi_\mathrm{zpf}^{(mj)}$ for each junction and mode.
    3. Diagonalize $H = \sum_m \omega_m a_m^\dagger a_m - \sum_j E_J[\cos\hat\varphi_j - 1 + \hat\varphi_j^2/2]$ numerically to get dressed frequencies, anharmonicities, and the dispersive-shift matrix $\chi$.

    Works for any number of modes and junctions. Handles strongly anharmonic circuits (fluxonium, $\varphi_\mathrm{zpf}\gtrsim 1$). No manual circuit diagram — only the 3-D geometry.

    No HFSS licence? The Hamiltonian diagonalization (steps 2–3) works with any frequencies and inductances. Start with Tutorial 6 on Binder — runs in your browser, no install.


    Install

    pip install pyEPR-quantum
    

    Requires Python 3.9–3.12. All dependencies (numpy, qutip, matplotlib, …) are installed automatically.

    conda:

    conda install -c conda-forge pyepr-quantum
    

    development install:

    git clone https://github.com/zlatko-minev/pyEPR.git && cd pyEPR
    pip install -e ".[test]" && pytest
    

    New in v0.9.6 — cross-platform gRPC backend (Linux · macOS · Windows)

    pyEPR now ships a second HFSS transport that runs entirely over gRPC through Ansys's official PyAEDT library — no COM, no pywin32, and no Windows requirement.

    Classic COM backendPyAEDT / gRPC backend
    Installpip install pyEPR-quantumpip install "pyEPR-quantum[pyaedt]"
    ClassDistributedAnalysisPyaedtDistributedAnalysis
    PlatformWindows onlyLinux · macOS · Windows
    TransportCOM / pywin32gRPC (Ansys official API)
    Session attachnew COM sessionattaches to running AEDT via .aedt.lock
    from pyEPR.ansys_pyaedt import PyaedtDistributedAnalysis
    
    eprd = PyaedtDistributedAnalysis(pinfo, aedt_version="2026.1")
    eprd.do_EPR_analysis()   # pure gRPC — no COM, works on Linux/macOS
    f_ND, chi_ND = eprd.analyze()
    

    The physics is identical — participations, eigenfrequencies, and the full diagonalization feed pyEPR's own QuantumAnalysis unchanged, validated digit-for-digit against the COM path. The gRPC backend also resolves the stale-session and project-locked errors that have long been the main pain point with COM.

    Many thanks to Joey Yaker for designing and contributing this backend. See the PyAEDT backend docs for full details and Tutorial 7.

    Quickstart — no Ansys required

    Compute the transmon anharmonicity from first principles, no HFSS needed:

    import numpy as np
    from pyEPR.calcs.back_box_numeric import epr_numerical_diagonalization
    
    # Standard transmon: E_J/h = 20 GHz, E_C/h = 300 MHz
    # Plasma frequency f_p = sqrt(8 E_J E_C)/h ≈ 6.93 GHz
    freqs   = np.array([6.928])     # GHz  (linearised plasma frequency)
    Ljs     = np.array([8.2e-9])    # H    (Josephson inductance L_J = (Phi_0/2pi)^2 / E_J)
    phi_zpf = np.array([[0.416]])   # dimensionless  (n_modes x n_junctions)
    
    # Diagonalize — returns dressed frequencies in Hz and chi matrix in MHz
    f_dressed, chi_matrix = epr_numerical_diagonalization(
        freqs, Ljs, phi_zpf, cos_trunc=8, fock_trunc=15
    )
    print(f"Qubit frequency : {f_dressed[0].real / 1e9:.3f} GHz")
    print(f"Anharmonicity   : {chi_matrix[0,0].real:.0f} MHz")
    # -> Qubit frequency : 6.615 GHz
    # -> Anharmonicity   : 335 MHz
    

    For multi-mode systems, fluxonium, or custom potentials: Tutorial 6.

    Full HFSS workflow

    import pyEPR as epr
    
    # 1. Connect to Ansys HFSS
    pinfo = epr.ProjectInfo(project_path=r'C:\sim_folder',
                            project_name=r'cavity_with_two_qubits',
                            design_name=r'Alice_Bob')
    
    # 2. Specify Josephson junctions
    pinfo.junctions['jAlice'] = {'Lj_variable':'Lj_alice', 'rect':'rect_alice',
                                  'line': 'line_alice', 'Cj_variable':'Cj_alice'}
    pinfo.junctions['jBob']   = {'Lj_variable':'Lj_bob',   'rect':'rect_bob',
                                  'line': 'line_bob',   'Cj_variable':'Cj_bob'}
    pinfo.validate_junction_info()
    
    # 3. Extract EPR participation ratios
    eprd = epr.DistributedAnalysis(pinfo)
    eprd.do_EPR_analysis()
    
    # 4. Quantum Hamiltonian — dressed frequencies and chi matrix
    epra = epr.QuantumAnalysis(eprd.data_filename)
    epra.analyze_all_variations(cos_trunc=8, fock_trunc=15)
    epra.plot_hamiltonian_results(swp_variable='Lj_alice')
    

    Documentation

    Full docs, API reference, and guides: pyepr-docs.readthedocs.io

    Tutorial Notebooks

    The tutorials are Jupyter notebooks in _tutorial_notebooks/.

    #TitleHFSS?Topics
    1Startup exampleYesEnd-to-end workflow: HFSS → EPR → χ matrix
    2Dielectric loss EPRYesDielectric energy participation, loss rates, HFSS fields calculator
    3Circuit QED parametersNoE_J, E_C, L_J, I_c conversions; transmon model
    4Parametric sweepsYesHFSS Optimetrics: linear, log, file-based sweeps
    5Generic junction potential & fluxoniumNoExact cosine for fluxonium; custom V(phi); asymmetric SQUIDs
    6EPR without HFSSNoNumerical workflow: supply freqs, Ljs, phi_zpf directly

    Tutorials 3, 5, and 6 require only pip install pyEPR-quantum — no Ansys licence.

    Video Tutorials

    Who uses pyEPR?

    pyEPR is used by superconducting qubit research groups worldwide, including:

    Platform support

    FeatureWindowsmacOSLinux
    EPR / quantum analysisYesYesYes
    Ansys HFSS COM interfaceYeslimitedlimited

    The HFSS COM interface uses pythoncom/win32com (Windows). On macOS/Linux you can connect to a remote Windows HFSS instance via network COM.

    PyAEDT is Ansys's official cross-platform AEDT scripting library. pyEPR and PyAEDT are complementary — use PyAEDT for geometry/mesh/solve automation, pyEPR for EPR quantization.

    HFSS Project Setup

    Eigenmode Design — Junction setup

    The EPR method requires each Josephson junction to be modelled as a lumped RLC boundary on a rectangle in HFSS, together with a polyline defining the current direction. Steps:

    1. Create a rectangle for each junction (e.g., rect_alice). Assign a Lumped RLC boundary with inductance variable Lj_alice.
    2. Draw a polyline spanning the junction rectangle to define current flow (e.g., line_alice).
    3. The linearised Josephson inductance used in HFSS is $L_J = (\Phi_0/2\pi)^2/E_J$. The full cosine potential is restored in the quantum Hamiltonian step.
    4. Enable Save Fields for each variation if running parametric sweeps (Tutorial 4).
    5. Use Mixed Order solutions for best accuracy.

    For a full walkthrough, see Tutorial 1 and the HFSS setup guide in the docs.

    Troubleshooting

    See the troubleshooting guide in the docs.

    Common issues:

    • pint error system='mks' unknown — upgrade pint: pip install pint --upgrade
    • QuTiP not found — it is installed automatically with pyEPR-quantum; for manual install: pip install qutip
    • COM Error on opening HFSS — check file path (no apostrophes/special chars); check HFSS hasn't popped an error dialog
    • Parametric sweep missing field solutions — enable "Save Fields and Mesh" in ParametricSetup → Properties → Options (see Tutorial 4)
    • ValueError: cannot set WRITEABLE flag — upgrade numpy

    Citation

    If you use pyEPR in your research, please cite:

    EPR method (primary reference):

    Z. K. Minev, Z. Leghtas, S. O. Mundhada, L. Christakis, I. M. Pop, M. H. Devoret, Energy-participation quantization of Josephson circuits, npj Quantum Information 7, 131 (2021) · arXiv:2010.00620

    Software (Zenodo DOI for the specific version):

    DOI

    BibTeX for both: pyEPR.bib

    Related:

    • Z. K. Minev, Ph.D. Dissertation, Yale (2018), Ch. 4 — arXiv:1902.10355
    • A. Petrescu, C. T. Hann, Z. K. Minev et al., EPR for very anharmonic circuits — arXiv:2411.15039

    Authors and Contributors

    Community contributions

    Joey Yaker — PyAEDT gRPC backend (pyEPR.ansys_pyaedt, v0.9.6). Designed and implemented PyaedtDistributedAnalysis: a complete alternative HFSS transport layer that drives the EPR field extraction entirely over gRPC via Ansys's official PyAEDT API, with no COM / pywin32. Includes the key insight that CalculatorWrite (write to a .fld file) must replace the stateful ClcEval/GetTopEntryValue round-trip for results to survive gRPC — validated digit-for-digit against the COM path. Makes pyEPR fully cross-platform for users with PyAEDT installed.

    Maintenance