-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Poisson-dev and support for BTD and Overlap Matrix in NEGF #105
base: main
Are you sure you want to change the base?
Conversation
self.hd, self.sd, _, _, _, _ = self.hamiltonian.get_hs_device(kpoint, self.V, block_tridiagonal) | ||
self.kpoint = torch.tensor(kpoint) | ||
|
||
self.oldV = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这块判断old_V 的逻辑其实有点冗余,初始化的时候设置一个self.V,然后每次和输入的V做对比看看要不要更新就行了
|
||
|
||
if not self.useBloch: | ||
if not hasattr(self, "HL") or abs(self.voltage_old-self.voltage)>1e-6 or max(abs(self.kpoint-torch.tensor(kpoint)))>1e-6: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
voltage_old 同理 old_V
@@ -45,6 +45,8 @@ def __init__( | |||
self.node_field = node_field | |||
self.out_field = out_field | |||
|
|||
self.atom_norbs = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个OrbitalMapper里有的
edge_field=AtomicDataDict.EDGE_FEATURES_KEY, | ||
node_field=AtomicDataDict.NODE_FEATURES_KEY, | ||
out_field=AtomicDataDict.HAMILTONIAN_KEY, | ||
dtype= model.dtype, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好奇如果这边model是32的,生成出来的哈密顿量是不是后面还要align一下dtype
alldata = AtomicData.to_AtomicDataDict(alldata.to(self.torch_device)) | ||
self.alldata = self.model.idp(alldata) | ||
self.alldata[AtomicDataDict.KPOINT_KEY] = \ | ||
torch.nested.as_nested_tensor([torch.as_tensor(HS_device["kpoints"], dtype=self.model.dtype, device=self.torch_device)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在可以不用nested了
dptb/negf/negf_hamiltonian_init.py
Outdated
|
||
structure_leads = {} | ||
structure_device = self.structase[self.device_id[0]:self.device_id[1]] | ||
structure_device.pbc = self.pbc_negf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这块会不会有可能出现pbc_negf设错的情况
dptb/negf/negf_hamiltonian_init.py
Outdated
|
||
l_start = int(np.sum(self.h2k.atom_norbs[:lead_id[0]])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个用OrbitalMapper里的atom_norbs替换掉吧
subblocks = [0]+subblocks | ||
|
||
|
||
for ik in range(HK.shape[0]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
后面的时候或许需要把k axis cat到一块,方便RGF直接vmap GPU并行,现在可以不管
@@ -251,8 +624,262 @@ def device_norbs(self): | |||
""" | |||
return the number of atoms in the device Hamiltonian | |||
""" | |||
return self.atom_norbs[self.device_id[0]:self.device_id[1]] | |||
return self.h2k.atom_norbs[self.device_id[0]:self.device_id[1]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上,可以用OrbitalMapper的替换
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR merges the poisson‑dev branch into main and adds support for Bloch unfolding in NEGF, improvements in TBtrans input file generation, and updates to various NEGF‐related modules. Key changes include updates to convergence thresholds and energy shifts in Green’s function calculations, modifications in lead self‑energy handling, and additions to the TBtrans input processing pipeline.
Reviewed Changes
File | Description |
---|---|
dptb/negf/surface_green.py | Adjusts convergence criteria for recursive surface Green’s function computation. |
dptb/negf/lead_property.py | Updates the self‑energy to Gamma conversion sign and extends the self‑energy handling. |
dptb/negf/recursive_green_cal.py | Revises the energy shift (using +1j*eta) in matrix blocks and adds an extra gr_lc output. |
dptb/nn/hr2hk.py | Appends atom orbital counts to an internal list during Hamiltonian block construction. |
dptb/postprocess/tbtrans_init.py | Cleans up extraneous commented code and revises structure‐reading routines. |
Copilot reviewed 50 out of 50 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (4)
dptb/negf/lead_property.py:235
- The function 'sigmaLR2Gamma' now returns 1j*(se-se.conj().T) instead of the previous -1j*(se-se.conj().T). Confirm that the sign change is consistent with the theoretical formulation and downstream usage.
return 1j * (se - se.conj().T)
dptb/negf/recursive_green_cal.py:165
- Changing the shift from (energy - 1jeta) to (energy + 1jeta) affects all matrix blocks; ensure that this modification is consistent with the retarded Green's function formalism used elsewhere in the code.
mat_d_list[jj] = mat_d_list[jj] + (energy + 1j * eta) * sd[jj]
dptb/nn/hr2hk.py:132
- [nitpick] Ensure that 'atom_norbs' is consistently maintained as it is critical for mapping orbital indices; consider adding documentation or assertions to verify its expected length relative to the input data.
self.atom_norbs.append(masked_oblock.shape[0])
dptb/postprocess/tbtrans_init.py:239
- [nitpick] Residual commented-out code (e.g., supercell settings) remains in the file; it is advisable to remove or relocate unused code to improve clarity and maintainability.
##redefine the Lattice vector of Lead L/R
@@ -59,7 +60,7 @@ def forward(ctx, H, h01, S, s01, ee, method='Lopez-Sancho'): | |||
|
|||
test = ee * S - H - torch.mm(ee * s01 - h01, gs.mm(ee * s10 - h10)) | |||
myConvTest = torch.max((test.mm(gs) - torch.eye(H.shape[0], dtype=h01.dtype)).abs()) | |||
if myConvTest < 1.0e-6: | |||
if myConvTest < 3.0e-5: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convergence threshold was increased from 1.0e-6 to 3.0e-5. Verify that this change does not compromise the accuracy of the surface Green's function and is aligned with the intended numerical tolerances.
if myConvTest < 3.0e-5: | |
if myConvTest < 1.0e-6: |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
try to merge poisson-dev to main