初步修改hubbard为free_fermion - #63
Merged
Merged
Conversation
hzhangxyz
requested changes
Jul 17, 2025
| @@ -0,0 +1,222 @@ | |||
| """ | |||
| This file offers an interface for defining Hubbard models on a two-dimensional lattice. | |||
| import dataclasses | ||
| import torch | ||
| import tyro | ||
| from .mlp import WaveFunctionElectronUpDown as MlpWaveFunction |
Member
There was a problem hiding this comment.
这两个应该是 WaveFunctionNormal, 适用于没有自旋的系统
| electron_number: typing.Annotated[int, tyro.conf.arg(aliases=["-e"])] | ||
|
|
||
| # The coefficient of t | ||
| t: typing.Annotated[float, tyro.conf.arg(aliases=["-t"])] = 1 |
| if self.m <= 0 or self.n <= 0: | ||
| raise ValueError("The dimensions of the Hubbard model must be positive integers.") | ||
|
|
||
| if self.electron_number < 0 or self.electron_number > 2 * self.m * self.n: |
| hamiltonian_dict: dict[tuple[tuple[int, int], ...], complex] = self._prepare_hamiltonian(args) | ||
| logging.info("Hamiltonian initialization complete") | ||
|
|
||
| self.ref_energy: float = self._calc_ref_energy(args) |
|
|
||
| def show_config(self, config: torch.Tensor) -> str: | ||
| string = "".join(f"{i:08b}"[::-1] for i in config.cpu().numpy()) | ||
| return "[" + ".".join("".join(self._show_config_site(string[(i + j * self.m):(i + j * self.m) + 1]) for i in range(self.m)) for j in range(self.n)) + "]" |
Member
There was a problem hiding this comment.
这个地方之前独立出一个函数,是因为他是两个bit,四个情况变成一个字符,对于目前这个情况,你可以直接inline地写,参考 ising.py:229
| double_sites=model.m * model.n, | ||
| physical_dim=2, | ||
| is_complex=True, | ||
| spin_up=model.electron_number // 2, |
Member
|
才发现,我网络那边,目前只有同时限制两类粒子的(spin up/down) 和没有任何限制的。在我更新那边之前,你可以使用之前那个up down都限制的网络,然后up设置electron number,down设置0。 目前的版本,从功能上,应该只是粒子数有点问题。 比如 你如果将粒子数设置为本来就能量最低的那个值,就能算对了。 我看看代码怎么样啊。 |
hzhangxyz
force-pushed
the
dev/add_free_fermion
branch
from
September 16, 2025 14:03
c5cc7b7 to
7a2c956
Compare
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.
Description
Closes: #45
Checklist: