Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
177 commits
Select commit Hold shift + click to select a range
ebc92c7
Update dpnegf as an isolated package (#2)
AsymmetryChou May 8, 2025
896df3d
Merge branch 'main' into update_main
AsymmetryChou May 19, 2025
ce752b9
refactor: 移除未使用的导入以清理代码
AsymmetryChou May 19, 2025
3a7db81
clone argcheck from dptb
AsymmetryChou May 19, 2025
b10dfb7
refactor: 更新化学势变量,保证电压一致性和代码清晰度
AsymmetryChou May 19, 2025
fdf8d35
feature: add Ef calculation in NEGF.py
AsymmetryChou May 19, 2025
6a659fd
feature: add Fermi level calculation for Lead_L/R in NEGF.py
AsymmetryChou May 20, 2025
f8bfced
feature: 更新电极HR以考虑掺杂引起的电压偏移
AsymmetryChou May 20, 2025
96484fe
refactor: 更新Fiori类中的断言和错误消息以增强可读性
AsymmetryChou May 21, 2025
9796c5e
refactor: rescale energy reference point as E_ref in Green Func cal a…
AsymmetryChou May 21, 2025
097d052
feature: 添加ElecStruCal类以计算电子结构属性和费米能级
AsymmetryChou May 22, 2025
3cbfdf8
feature: 更新get_fermi_level方法以支持电压偏置参数Vbias
AsymmetryChou May 23, 2025
9b23a2b
删除电压偏移的相关代码注释
AsymmetryChou May 23, 2025
eed2136
refactor: 更新能量参考点E_ref,增强电压偏置支持,合理化Poisson自洽求解
AsymmetryChou May 23, 2025
c42926b
refactor: 统一e_fermi和chemiPot变量名,符合其物理意义
AsymmetryChou May 23, 2025
40952fe
refactor: 移除get_fermi_level方法中的Vbias参数及相关逻辑,简化函数接口
AsymmetryChou May 23, 2025
a4764f7
refactor: 更新注释以提高代码可读性,修正错误信息提示
AsymmetryChou May 24, 2025
92bf10f
refactor: 更新get_nel_atom_lead方法,及部分注释
AsymmetryChou May 24, 2025
053d331
refactor: 优化电化学势和参考能量的计算逻辑,增强对不同边界条件的支持
AsymmetryChou May 26, 2025
d9577f9
refactor: 更新Fiori类中的density_integrate_Fiori方法,使用E_ref作为NEGF-Poisson计算…
AsymmetryChou May 26, 2025
9c9c3f0
refactor: 增强电压一致性检查,确保在SCF计算中电压参数的正确设置
AsymmetryChou May 27, 2025
ddc5719
refactor: 更新torch.load方法,添加weights_only参数以优化NEGF计算结果加载
AsymmetryChou May 27, 2025
58b95e4
test: 添加Fermi能级计算测试,包含不同的平滑方法
AsymmetryChou May 27, 2025
84f9c79
refactor: for with_Dirichlet_leads case, self-energy calculation is m…
AsymmetryChou May 28, 2025
2848c62
feat: 添加版本信息获取功能,记录DPNEGF和DeePTB的版本信息
AsymmetryChou May 28, 2025
dc52a83
docs: 更新README.md
AsymmetryChou May 28, 2025
2985070
fix: 更新DeePTB版本要求为≥2.1.1,优化版本信息日志格式
AsymmetryChou May 28, 2025
e00516e
test: 调整Fermi能级计算的精度要求,更新断言容差
AsymmetryChou May 29, 2025
b175eb6
Merge branch 'main' into pr/floatingCatty/1
AsymmetryChou May 29, 2025
0dff580
Merge pull request #1 from floatingCatty/create-data-module
AsymmetryChou May 29, 2025
8c72523
Merge branch 'main' into poisson-dev_leadphi
AsymmetryChou May 29, 2025
fd11df8
fix: 修正导入路径以确保正确引用anglrMId常量
AsymmetryChou May 29, 2025
91521a5
fix: 修正Fermi能级计算中fixed_charge正负和掺杂类型的关系
AsymmetryChou Jun 4, 2025
45a2c26
feat: 添加get_block_tridiagonal docstring
AsymmetryChou Jun 8, 2025
b44f96e
fix: 修正lead_property中自能计算的形状,以匹配块对角化结果
AsymmetryChou Jun 8, 2025
65a7764
feat: add comand line function
AsymmetryChou Jun 9, 2025
dedf9df
Add examples for dpnegf in API and CLI cases
AsymmetryChou Jun 9, 2025
93a2e8e
feat(SCF): add PDIIS and Broyden' 2nd method
AsymmetryChou Jun 10, 2025
0986f9f
feat(SCF): add BroydenFirstMixer
AsymmetryChou Jun 10, 2025
f3fed46
feat(SCF): update BroydenFirstMixer for efficiency
AsymmetryChou Jun 10, 2025
44a617b
feat(SCF): optimize Broyden's First Method for improved performance a…
AsymmetryChou Jun 10, 2025
c92501c
feat(SCF): update BroydenFirstMixer in correct form
AsymmetryChou Jun 12, 2025
bb74d47
feat(SCF): enhance convergence checks in Poisson-NEGF iteration
AsymmetryChou Jun 12, 2025
1d8ea52
feat(SCF): update BroydenFirstMixer
AsymmetryChou Jun 12, 2025
3914f02
feat(example): update nel_atom values for lead electrons in run noteb…
AsymmetryChou Jun 13, 2025
1620003
update json file in API example
AsymmetryChou Jun 13, 2025
6524c9e
feat(SCF): implement Block Broyden's first mixer for back up
AsymmetryChou Jun 13, 2025
d9b1495
feat(SCF): add Anderson acceleration method
AsymmetryChou Jun 14, 2025
7fe76fd
feat(SCF): add docstring for AndersonMixer
AsymmetryChou Jun 14, 2025
cee6e73
fix(SCF): update variable names for clarity and adjust AndersonMixer …
AsymmetryChou Jun 14, 2025
663133b
feat(SCF): enhance AndersonMixer to include history info of linear w…
AsymmetryChou Jun 15, 2025
4fdb06d
refactor(SCF): update BroydenSecondMixer
AsymmetryChou Jun 16, 2025
3f1f06d
doc(SCF): enhance BroydenFirstMixer with detailed docstrings
AsymmetryChou Jun 16, 2025
fe04656
feat(SCF): add DIIS
AsymmetryChou Jun 16, 2025
061776b
refactor(NEGF): refactor PDIIS mixing method selection and initializa…
AsymmetryChou Jun 16, 2025
f51aea5
feat(PDIISMixer): enhance initialization and update methods, improve …
AsymmetryChou Jun 16, 2025
5c6bae9
test(AndersonMixer): add unit tests for linear mixing behavior, switc…
AsymmetryChou Jun 16, 2025
73f3107
test(BroydenSecondMixer): add tests for linear mixing, second step up…
AsymmetryChou Jun 16, 2025
721b2ba
test(BroydenFirstMixer): add tests for linear mixing, switching to Br…
AsymmetryChou Jun 16, 2025
79629c0
test(DIISMixer): add tests for linear mixing behavior, switching to D…
AsymmetryChou Jun 16, 2025
a40e573
test(PDIISMixer): add tests for linear mixing behavior, switching to …
AsymmetryChou Jun 16, 2025
98f673a
refactor: update mixer classes to inherit from object and improve doc…
AsymmetryChou Jun 17, 2025
2b32580
test: add unit tests for Grid class properties and methods
AsymmetryChou Jun 17, 2025
311d4c2
test: add tests for region and Dirichlet/Dielectric classes
AsymmetryChou Jun 17, 2025
f08df5d
test: add tests for Interface3D initialization, boundary points, and …
AsymmetryChou Jun 17, 2025
d8de986
Merge pull request #4 from AsymmetryChou/poisson-dev_leadphi
AsymmetryChou Jun 17, 2025
8156db7
feat: add eps_average_mode parameter to Interface3D for flexible diel…
AsymmetryChou Jun 20, 2025
da6906a
fix: correct type annotation for properties and fix typo in compute_c…
AsymmetryChou Jul 2, 2025
50f76e8
Merge pull request #5 from AsymmetryChou/average_eps
AsymmetryChou Jul 2, 2025
9fc9bc4
feat: make gate parameters optional and add left/right gates in pyamg…
AsymmetryChou Jul 7, 2025
06add41
Merge pull request #8 from AsymmetryChou/add_gates
AsymmetryChou Jul 7, 2025
3de5820
Refactor: tighten the translational equivalence check on lead structure
kirk0830 Jul 7, 2025
db1d3fd
correct translational symmetry error calculation in NEGFHamiltonianInit
AsymmetryChou Jul 7, 2025
4fb8452
improve error message for lead principal layers translational equival…
AsymmetryChou Jul 7, 2025
3dd5e28
change hard-coded threshold to 1e-10
AsymmetryChou Jul 7, 2025
766cc7e
improve error info
AsymmetryChou Jul 7, 2025
7509bc7
check natom is even
AsymmetryChou Jul 7, 2025
1745221
Merge pull request #9 from kirk0830/transymm-error-check
AsymmetryChou Jul 7, 2025
3b848d0
Refactor: extract the translational equivalence check from get_lead_s…
kirk0830 Jul 7, 2025
f69adbd
Fix the typo 'substracting' in the docstring to 'subtracting'.
AsymmetryChou Jul 8, 2025
b8cf2dc
refactor: update some info in cal_principal_layers_disp_vec
AsymmetryChou Jul 8, 2025
b499082
feat: add additional dielectric_region parameters for enhanced config…
AsymmetryChou Jul 8, 2025
1606a80
feat: add dielectric_region4 parameter for enhanced dielectric config…
AsymmetryChou Jul 8, 2025
ef90ff4
feat: add dielectric_region5 parameter for enhanced dielectric config…
AsymmetryChou Jul 8, 2025
0c94a4b
Merge branch 'main' into add_diel
AsymmetryChou Jul 8, 2025
d971cca
feat: refactor dielectric_region arguments for improved readability a…
AsymmetryChou Jul 8, 2025
412e740
Merge pull request #12 from AsymmetryChou/add_diel
AsymmetryChou Jul 8, 2025
fda3dd2
change to check the symmerr for each atom-pair and add unittest
kirk0830 Jul 8, 2025
deb822f
modify errmsg stdout
kirk0830 Jul 8, 2025
d982128
move unittest
kirk0830 Jul 8, 2025
9a907a4
remove unused unittest
AsymmetryChou Jul 8, 2025
a517c66
Merge pull request #10 from kirk0830/refactor-transymm-check
AsymmetryChou Jul 8, 2025
c97fd29
refactor(test_get_fermi): update root directory format
AsymmetryChou Jul 8, 2025
b41c42c
Merge pull request #13 from AsymmetryChou/update_testroot
AsymmetryChou Jul 8, 2025
2bd7e02
feat(NEGF): add support for AtomicData_options extraction from model
AsymmetryChou Jul 11, 2025
914a60d
feat(NEGF): add JSON logging for AtomicData_options and adjust parame…
AsymmetryChou Jul 12, 2025
d007baf
Update dpnegf/runner/NEGF.py
AsymmetryChou Jul 12, 2025
ef8dc10
fix(NEGF): adjust indentation for logging AtomicData_options
AsymmetryChou Jul 12, 2025
028c1ea
Merge pull request #16 from AsymmetryChou/radius_from_model
AsymmetryChou Jul 12, 2025
4929c02
backup torch-based surface_green and create numpy-based one
AsymmetryChou Aug 5, 2025
c2e5990
feat(surface_green): rewrite selfEnergy and surface_green functions t…
AsymmetryChou Aug 5, 2025
e6af112
feat(surface_green): add Numba JIT compilation for surface Green's fu…
AsymmetryChou Aug 5, 2025
81bcc92
feat(surface_green): enhance selfEnergy and surface_green functions w…
AsymmetryChou Aug 5, 2025
1826ba8
fix(negf_hamiltonian): prevent NaN values in translational equivalenc…
AsymmetryChou Aug 5, 2025
4ea294b
feat(surface_green): update NumPy-based surface Green's function impl…
AsymmetryChou Aug 6, 2025
b89cdc2
Merge pull request #18 from AsymmetryChou/jit_surface_green
AsymmetryChou Aug 6, 2025
a6f10b1
enable lead H/S in memory when calculating self energy
AsymmetryChou Aug 6, 2025
8d633ed
feat(pyproject): add numba as a dependency
AsymmetryChou Aug 6, 2025
02b829f
multiprocessing.Pool implementation
AsymmetryChou Aug 6, 2025
5266f7b
feat(NEGF): refactor self-energy computation to use joblib for parall…
AsymmetryChou Aug 6, 2025
bf24031
feat(pyproject): add joblib as a dependency
AsymmetryChou Aug 6, 2025
8e09236
Update output dir for test_run
AsymmetryChou Aug 6, 2025
e2a429a
refactor(NEGF): simplify loop by removing unnecessary enumeration of …
AsymmetryChou Aug 6, 2025
7d268ae
Merge pull request #20 from AsymmetryChou/parallel_selfen
AsymmetryChou Aug 6, 2025
e7b5c41
fix(run): set default log_level to 20 in run function signature
AsymmetryChou Aug 7, 2025
cc98b45
refactor (self_energy): move compute_all_self_energy in lead_property.py
AsymmetryChou Aug 7, 2025
f2ac0e3
feat(self_energy): enhance self-energy computation with HDF5 support …
AsymmetryChou Aug 7, 2025
39f53b7
fix(test_negf): update emin and emax values in negf_chain_new.json fo…
AsymmetryChou Aug 7, 2025
64f1d95
refactor(lead_property): each worker outputs self energy in a public …
AsymmetryChou Aug 8, 2025
923a87d
refactor(lead_property): streamline self-energy computation in all h5…
AsymmetryChou Aug 8, 2025
188fc44
refactor(lead_property, NEGF): swap group and dataset names in HDF5
AsymmetryChou Aug 8, 2025
86a5328
refactor(lead_property): remove unused imports and clean up code
AsymmetryChou Aug 8, 2025
3b6e5bd
update log message
AsymmetryChou Aug 8, 2025
5621a9c
remove unnecessary code
AsymmetryChou Aug 8, 2025
6638a0f
Merge pull request #21 from AsymmetryChou/selfen_parser
AsymmetryChou Aug 8, 2025
e48a561
add cnt example notebook
AsymmetryChou Sep 1, 2025
09d84e0
Merge pull request #22 from AsymmetryChou/cnt-example
AsymmetryChou Sep 1, 2025
aa3c596
fix(run.ipynb): update execution counts and clean up output messages
AsymmetryChou Sep 1, 2025
25e1c37
Merge branch 'main' into cnt-example
AsymmetryChou Sep 1, 2025
c57ebe5
Merge pull request #24 from AsymmetryChou/cnt-example
AsymmetryChou Sep 1, 2025
9385ad9
Add workflow (#25)
QG-phy Sep 3, 2025
af295b9
Rename workflow from DeePTB-UniSK to DPNEGF Tests
QG-phy Sep 3, 2025
17a122a
Add joblib dependency to pyproject.toml
QG-phy Sep 3, 2025
889702b
Add docs (#26)
QG-phy Sep 3, 2025
767400c
更新工作流名称并添加 DeepTB 标志文件 (#27)
QG-phy Sep 3, 2025
6e3d4fb
update doc index.rst
AsymmetryChou Sep 5, 2025
63df228
update install doc
AsymmetryChou Sep 5, 2025
86faa84
Merge pull request #29 from AsymmetryChou/doc_update
AsymmetryChou Sep 5, 2025
598e9ec
add license
AsymmetryChou Sep 8, 2025
da71df7
add tutorial1
AsymmetryChou Sep 8, 2025
f7fddec
add citation
AsymmetryChou Sep 8, 2025
7c2e5e5
update citations
AsymmetryChou Sep 8, 2025
e376ca5
更新贡献指南中的项目名称为DPNEGF,并调整目录结构以提高可读性
AsymmetryChou Sep 8, 2025
81d08e1
update contributing
AsymmetryChou Sep 8, 2025
0016370
add license (#30)
AsymmetryChou Sep 14, 2025
e9926e1
build(deps): bump actions/checkout from 4 to 5 (#28)
dependabot[bot] Sep 14, 2025
db00bab
build(deps): bump actions/setup-python from 5 to 6 (#32)
dependabot[bot] Sep 14, 2025
6acecd7
update tutorial
AsymmetryChou Sep 15, 2025
d286c95
Merge branch 'main' into add_docs
AsymmetryChou Sep 15, 2025
d73fb9c
Update docs/CONTRIBUTING.md
AsymmetryChou Sep 15, 2025
ffb2421
Merge pull request #34 from AsymmetryChou/add_docs
AsymmetryChou Sep 15, 2025
64c202a
update index.rst
AsymmetryChou Sep 15, 2025
c676a48
Merge branch 'add_docs' of https://github.com/AsymmetryChou/dpnegf in…
AsymmetryChou Sep 15, 2025
68358d5
Merge pull request #35 from AsymmetryChou/add_docs
AsymmetryChou Sep 15, 2025
02fba70
Update tutorial1 (#36)
AsymmetryChou Sep 16, 2025
3ea46fa
Fix wrong cell outputs in tutorial notebook (#37)
AsymmetryChou Sep 16, 2025
86c2e1e
add example graphene
AsymmetryChou Sep 21, 2025
1cdd531
add esk input.json
AsymmetryChou Sep 21, 2025
c9ff0b5
add example hBN
AsymmetryChou Sep 21, 2025
1974d1e
update graphene data
AsymmetryChou Sep 21, 2025
27f2c38
refactor lead_property
AsymmetryChou Sep 21, 2025
ddddca3
remove self_energy_save as it must be saved
AsymmetryChou Sep 21, 2025
f575722
add use_saved_se (default: False)
AsymmetryChou Sep 21, 2025
ae87436
add log info for self_energy
AsymmetryChou Sep 21, 2025
38d9cb4
fix types in self_energy file name
AsymmetryChou Sep 21, 2025
97f27e0
add _has_saved_self_energy check and module prepare_self_energy func
AsymmetryChou Sep 22, 2025
16b05ed
add docs
AsymmetryChou Sep 22, 2025
f7c3855
rename extr_baseline as extra_baseline
AsymmetryChou Sep 23, 2025
3fe0d13
fix spds as spd
AsymmetryChou Sep 23, 2025
b7d1ad3
add extraction of system-specific model
AsymmetryChou Sep 23, 2025
d105cc5
add update_atomicdata_options
AsymmetryChou Sep 23, 2025
047880d
add fig and PL instructions
AsymmetryChou Sep 23, 2025
73e309a
graphene is done
AsymmetryChou Sep 23, 2025
10b846d
update related files
AsymmetryChou Sep 23, 2025
e540e47
remove hbn train_out
AsymmetryChou Sep 23, 2025
cd99532
ignore self-energy
AsymmetryChou Sep 23, 2025
d289d85
Merge branch 'main' into tutor2_new
AsymmetryChou Sep 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ dpnegf/data/try_test.ipynb
dpnegf/negf/check.ipynb
dpnegf/tests/data/test_negf/show.ipynb
dpnegf/tests/data/test_tbtrans/show.ipynb
# tutorial files
dpnegf/examples/graphene/negf_output_k20/self_energy/self_energy_leadL.h5
dpnegf/examples/graphene/negf_output_k20/self_energy/self_energy_leadR.h5

run_config.json
dpnegf/nnet/__pycache__/
dpnegf/sktb/__pycache__/
Expand Down
Binary file added docs/hands_on/stru_negf_PL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,006 changes: 1,006 additions & 0 deletions docs/hands_on/tutorial2_2d_mat.ipynb

Large diffs are not rendered by default.

293 changes: 233 additions & 60 deletions dpnegf/negf/lead_property.py

Large diffs are not rendered by default.

142 changes: 93 additions & 49 deletions dpnegf/runner/NEGF.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from dpnegf.utils.elec_struc_cal import ElecStruCal
from dpnegf.negf.density import Ozaki,Fiori
from dpnegf.negf.device_property import DeviceProperty
from dpnegf.negf.lead_property import LeadProperty, compute_all_self_energy
from dpnegf.negf.lead_property import LeadProperty, compute_all_self_energy, _has_saved_self_energy
from dpnegf.negf.negf_utils import is_fully_covered
import ase
from dpnegf.utils.constants import Boltzmann, eV2J
Expand All @@ -21,7 +21,6 @@
from pyinstrument import Profiler
import os


log = logging.getLogger(__name__)


Expand Down Expand Up @@ -49,7 +48,7 @@ def __init__(self,
sgf_solver: str,
e_fermi: float=None,
use_saved_HS: bool=False, saved_HS_path: str=None,
self_energy_save: bool=False, self_energy_save_path: str=None, se_info_display: bool=False,
use_saved_se: bool=False, self_energy_save_path: str=None, se_info_display: bool=False,
out_tc: bool=False,out_dos: bool=False,out_density: bool=False,out_potential: bool=False,
out_current: bool=False,out_current_nscf: bool=False,out_ldos: bool=False,out_lcurrent: bool=False,
results_path: Optional[str]=None,
Expand Down Expand Up @@ -80,9 +79,9 @@ def __init__(self,
self.saved_HS_path = saved_HS_path

self.sgf_solver = sgf_solver
self.self_energy_save = self_energy_save
self.self_energy_save_path = self_energy_save_path
self.se_info_display = se_info_display
self.use_saved_se = use_saved_se # whether to use the saved self-energy or not
self.self_energy_save_path = self_energy_save_path # The directory to save the self-energy or for saved self-energy
self.se_info_display = se_info_display # whether to display the self-energy information after calculation
self.pbc = self.stru_options["pbc"]

if self.stru_options["lead_L"]["useBloch"] or self.stru_options["lead_R"]["useBloch"]:
Expand Down Expand Up @@ -133,18 +132,8 @@ def __init__(self,
else:
assert self.stru_options[lead_tag]["voltage"] == 0, f"{lead_tag} voltage should be 0 in non-scf calculation"

if AtomicData_options is None:
from dptb.utils.argcheck import get_cutoffs_from_model_options
# get the cutoffs from model options
r_max, er_max, oer_max = get_cutoffs_from_model_options(model.model_options)
AtomicData_options = {'r_max': r_max, 'er_max': er_max, 'oer_max': oer_max}
else:
log.warning(msg="AtomicData_options is extracted from input file. " \
"This may be not consistent with the model options. " \
"Please be careful and check the cutoffs.")
formatted = json.dumps(AtomicData_options, indent=4)
indented = '\n'.join(' ' * 15 + line for line in formatted.splitlines())
log.info("The AtomicData_options is:\n%s", indented)
# preparing AtomicData_options, including cutoffs
AtomicData_options = self.update_atomicdata_options(model,AtomicData_options)

# computing the hamiltonian
self.negf_hamiltonian = NEGFHamiltonianInit(model=model,
Expand Down Expand Up @@ -403,13 +392,13 @@ def compute(self):
self.negf_compute(scf_require=False,Vbias=self.potential_at_orb)

else:
# profiler = Profiler()
# profiler.start()
profiler = Profiler()
profiler.start()
self.negf_compute(scf_require=False,Vbias=None)
# profiler.stop()
# output_path = os.path.join(self.results_path, "profile_report.html")
# with open(output_path, 'w') as report_file:
# report_file.write(profiler.output_html())
profiler.stop()
output_path = os.path.join(self.results_path, "profile_report.html")
with open(output_path, 'w') as report_file:
report_file.write(profiler.output_html())

def poisson_negf_scf(self,interface_poisson,atom_gridpoint_index,err=1e-6,max_iter=1000,
mix_method:str='linear', mix_rate:float=0.3, tolerance:float=1e-7,Gaussian_sigma:float=3.0):
Expand Down Expand Up @@ -513,35 +502,57 @@ def poisson_negf_scf(self,interface_poisson,atom_gridpoint_index,err=1e-6,max_it
# if iter_count <= max_iter:
# profiler.stop()
# with open('profile_report.html', 'w') as report_file:
# report_file.write(profiler.output_html())

# report_file.write(profiler.output_html())、

def prepare_self_energy(self, scf_require: bool) -> None:
"""
Prepares the self-energy for the NEGF calculation.

Depending on the calculation settings, this method either loads previously saved self-energy data
or computes and saves new self-energy values for the device leads. The computation method varies
based on whether self-consistent field (SCF) calculations are required and whether Dirichlet boundary
conditions are applied to the leads.

Parameters:
----------
scf_require (bool): Indicates whether SCF calculations are required.
"""
# self energy calculation
log.info(msg="------Self-energy calculation------")
if self.self_energy_save_path is None:
self.self_energy_save_path = os.path.join(self.results_path, "self_energy")
os.makedirs(self.self_energy_save_path, exist_ok=True)

if self.use_saved_se:
assert _has_saved_self_energy(self.self_energy_save_path), "No saved self-energy found in {}".format(self.self_energy_save_path)
log.info(msg="Using saved self-energy from {}".format(self.self_energy_save_path))
log.info(msg="Ensure the saved self-energy is consistent with the current calculation setting!")
else:
log.info(msg="Calculating self-energy and saving to {}".format(self.self_energy_save_path))
if scf_require and self.poisson_options["with_Dirichlet_leads"]:
# For the Dirichlet leads, the self-energy of the leads is only calculated once and saved.
# In each iteration, the self-energy of the leads is not updated.
# for ik, k in enumerate(self.kpoints):
# for e in self.density.integrate_range:
# self.deviceprop.lead_L.self_energy(kpoint=k, energy=e, eta_lead=self.eta_lead, save=True)
# self.deviceprop.lead_R.self_energy(kpoint=k, energy=e, eta_lead=self.eta_lead, save=True)
compute_all_self_energy(self.eta_lead, self.deviceprop.lead_L, self.deviceprop.lead_R,
self.kpoints, self.density.integrate_range, self.self_energy_save_path)
elif not self.scf:
# In non-scf case, the self-energy of the leads is calculated for each energy point in the energy grid.
compute_all_self_energy(self.eta_lead, self.deviceprop.lead_L, self.deviceprop.lead_R,
self.kpoints, self.uni_grid, self.self_energy_save_path)
log.info(msg="-----------------------------------\n")



def negf_compute(self,scf_require=False,Vbias=None):

assert scf_require is not None, "scf_require should be set to True or False"
self.out['k']=[];self.out['wk']=[]
if hasattr(self, "uni_grid"): self.out["uni_grid"] = self.uni_grid

# self energy calculation
log.info(msg="------Self-energy calculation------")
selfen_parent_dir = os.path.join(self.results_path,"self_energy")
if not os.path.exists(selfen_parent_dir):
os.makedirs(selfen_parent_dir)
if scf_require and self.poisson_options["with_Dirichlet_leads"]:
# For the Dirichlet leads, the self-energy of the leads is only calculated once and saved.
# In each iteration, the self-energy of the leads is not updated.
# for ik, k in enumerate(self.kpoints):
# for e in self.density.integrate_range:
# self.deviceprop.lead_L.self_energy(kpoint=k, energy=e, eta_lead=self.eta_lead, save=True)
# self.deviceprop.lead_R.self_energy(kpoint=k, energy=e, eta_lead=self.eta_lead, save=True)
compute_all_self_energy(self.eta_lead, self.deviceprop.lead_L, self.deviceprop.lead_R,
self.kpoints, self.density.integrate_range)
elif not self.scf:
# In non-scf case, the self-energy of the leads is calculated for each energy point in the energy grid.
compute_all_self_energy(self.eta_lead, self.deviceprop.lead_L, self.deviceprop.lead_R,
self.kpoints, self.uni_grid)
log.info(msg="-----------------------------------\n")

self.prepare_self_energy(scf_require)

for ik, k in enumerate(self.kpoints):

Expand Down Expand Up @@ -627,7 +638,6 @@ def negf_compute(self,scf_require=False,Vbias=None):
kpoint=k,
eta_lead=self.eta_lead,
method=self.sgf_solver,
save=self.self_energy_save,
save_path=self.self_energy_save_path,
se_info_display=self.se_info_display
)
Expand All @@ -641,7 +651,6 @@ def negf_compute(self,scf_require=False,Vbias=None):
kpoint=k,
eta_lead=self.eta_lead,
method=self.sgf_solver,
save=self.self_energy_save,
save_path=self.self_energy_save_path,
se_info_display=self.se_info_display
)
Expand Down Expand Up @@ -736,7 +745,6 @@ def negf_compute(self,scf_require=False,Vbias=None):
kpoint=k,
eta_lead=self.eta_lead,
method=self.sgf_solver,
save=self.self_energy_save,
save_path=self.self_energy_save_path,
se_info_display=self.se_info_display
)
Expand Down Expand Up @@ -815,6 +823,42 @@ def get_nel_atom_lead(self, struct_leads, charge:float=None):
nel_atom_lead[lead_tag] = {elem: nel_atom_lead[lead_tag][elem] + charge[lead_tag] for elem in nel_atom_lead[lead_tag]}

return nel_atom_lead

@staticmethod
def update_atomicdata_options(model,AtomicData_options: dict=None) -> dict:
"""
Updates or initializes the AtomicData_options dictionary based on the provided model.

If AtomicData_options is not provided, it extracts cutoff values from the model's options
using `get_cutoffs_from_model_options` and constructs the dictionary. If AtomicData_options
is provided, a warning is logged to indicate potential inconsistency with the model options.

The function logs the resulting AtomicData_options in a formatted and indented manner.

Parameters:
----------
model: The model object containing model_options used to extract cutoff values.
AtomicData_options (dict, optional): Dictionary of atomic data options. If None, it will be generated.

Returns:
-------
dict: The updated or initialized AtomicData_options dictionary.
"""
if AtomicData_options is None:
from dptb.utils.argcheck import get_cutoffs_from_model_options
# get the cutoffs from model options
r_max, er_max, oer_max = get_cutoffs_from_model_options(model.model_options)
AtomicData_options = {'r_max': r_max, 'er_max': er_max, 'oer_max': oer_max}
else:
log.warning(msg="AtomicData_options is extracted from NEGF input file. " \
"This may be not consistent with the model options. " \
"Please be careful and check the cutoffs.")
formatted = json.dumps(AtomicData_options, indent=4)
indented = '\n'.join(' ' * 15 + line for line in formatted.splitlines())
log.info("The AtomicData_options is:\n%s", indented)

return AtomicData_options


def fermi_dirac(self, x) -> torch.Tensor:
return 1 / (1 + torch.exp(x / self.kBT))
Expand Down
3 changes: 1 addition & 2 deletions dpnegf/tests/test_negf_negf_hamiltonian_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ def test_negf_Hamiltonian(root_directory):
energy=e,
kpoint=kpoints[0],
eta_lead=negf_json['task_options']["eta_lead"],
method=negf_json['task_options']["sgf_solver"],
save=False
method=negf_json['task_options']["sgf_solver"]
)
print("lead_L self energy:",deviceprop.lead_L.se)
print("lead_R self energy:",deviceprop.lead_R.se)
Expand Down
4 changes: 2 additions & 2 deletions dpnegf/utils/argcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,8 +1047,8 @@ def negf():
Argument("stru_options", dict, optional=False, sub_fields=stru_options(), doc=doc_stru_options),
Argument("poisson_options", dict, optional=True, default={}, sub_fields=[], sub_variants=[poisson_options()], doc=doc_poisson_options),
Argument("sgf_solver", str, optional=True, default="Sancho-Rubio", doc=doc_sgf_solver),
Argument("self_energy_save", bool, optional=True, default=False, doc="whether to save the self energy"),
Argument("self_energy_save_path", str, optional=True, default=None, doc="the path to save the self energy"),
Argument("use_saved_se", bool, optional=True, default=False, doc="whether to use saved self energy"),
Argument("self_energy_save_path", str, optional=True, default=None, doc="the directory to save the self energy or load the self energy"),
Argument("se_info_display", bool, optional=True, default=False, doc="whether to display the self energy information"),
Argument("espacing", [int, float], optional=False, doc=doc_espacing),
Argument("emin", [int, float], optional=False, doc=doc_emin),
Expand Down
18 changes: 18 additions & 0 deletions examples/graphene/band.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"structure":"train/data/POSCAR",
"task_options": {
"task": "band",
"kline_type":"abacus",
"kpath":[
[0, 0, 0, 50],
[0.5, 0, 0, 50],
[0.3333333, 0.3333333, 0, 50],
[0, 0, 0, 1]
],
"nkpoints":151,
"klabels":["G", "M", "K", "G"],
"emin":-20,
"emax":20,
"nel_atom":{"C":4}
}
}
11 changes: 11 additions & 0 deletions examples/graphene/extra_baseline/c_spd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"common_options": {
"basis": {
"C": [
"2s",
"2p",
"d*"
]
}
}
}
Loading