Add fermionic-to-bosonic Hamiltonian mapper#159
Open
Hugh-888 wants to merge 7 commits into
Open
Conversation
…um into dev_fermion_map_boson
sansiro77
reviewed
May 25, 2026
| return sort_samples | ||
|
|
||
|
|
||
| class FermionMapBoson: |
Contributor
There was a problem hiding this comment.
这个类的职责是量子化学/费米到玻色映射,不是 photonic ansatz;放在 photonic/ansatz.py 会让模块边界混乱。
| self.m = 2 * len(self.active_indices) | ||
|
|
||
| def construct_h_fermion(self): | ||
| from openfermion import get_fermion_operator |
Contributor
There was a problem hiding this comment.
这里依赖 OpenFermion/PySCF,但 PR 没有新增对应的 optional dependency,用户无法通过安装 extras 获得完整功能。
| return sort_samples | ||
|
|
||
|
|
||
| class FermionMapBoson: |
Contributor
There was a problem hiding this comment.
FermionMapBoson 这个命名不够清晰,建议改成更符合语义的 FermionToBosonMapper。
| These form the primary Hilbert space for VQE. | ||
| """ | ||
|
|
||
| def __init__(self, config: dict = None) -> None: |
Contributor
There was a problem hiding this comment.
这个类作为用户主接口,当前用裸 dict 初始化且缺少参数校验,接口稳定性和可读性都不够。
| def fci_energy(self): | ||
| return self.molecule.fci_energy | ||
|
|
||
| @staticmethod |
Contributor
There was a problem hiding this comment.
这些 staticmethod 不依赖类状态,更像底层 helper;放在主接口类里会扩大公开 API,建议重新组织到类外或内部私有实现中。
| else: | ||
| return 0.0 | ||
|
|
||
| @staticmethod |
Contributor
There was a problem hiding this comment.
当前实现隐含了重要边界:常数项不在矩阵里、复系数会被丢弃、输入默认是 normal-ordered 分子哈密顿量;这些限制需要在接口说明中明确。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add class
FermionMapBosonfor mapping the fermionic Hamiltonian to the bosonic Hamiltonian in Fock basis.Example: