From 503d7f8c6c5d0de759f458b883117f75434bc629 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Tue, 2 Jul 2024 04:07:20 -0400 Subject: [PATCH] sync .pre-commit-config.yaml with devel Signed-off-by: Jinzhe Zeng --- .pre-commit-config.yaml | 25 +- CITATIONS.bib | 611 +++++++++++++---------- backend/read_env.py | 2 +- data/raw/copy_raw.py | 2 +- deepmd/cluster/local.py | 2 +- deepmd/descriptor/descriptor.py | 12 +- deepmd/descriptor/loc_frame.py | 8 +- deepmd/descriptor/se.py | 8 +- deepmd/descriptor/se_a.py | 12 +- deepmd/descriptor/se_atten.py | 8 +- deepmd/descriptor/se_r.py | 8 +- deepmd/descriptor/se_t.py | 8 +- deepmd/entrypoints/compress.py | 11 +- deepmd/entrypoints/freeze.py | 4 +- deepmd/entrypoints/neighbor_stat.py | 4 +- deepmd/entrypoints/test.py | 11 +- deepmd/fit/dos.py | 10 +- deepmd/fit/ener.py | 10 +- deepmd/fit/fitting.py | 3 +- deepmd/infer/deep_pot.py | 8 +- deepmd/model/dos.py | 2 +- deepmd/model/ener.py | 2 +- deepmd/model/model.py | 6 +- deepmd/model/tensor.py | 2 +- deepmd/nvnmd/entrypoints/train.py | 2 +- deepmd/nvnmd/entrypoints/wrap.py | 2 +- deepmd/nvnmd/utils/fio.py | 2 +- deepmd/train/trainer.py | 21 +- deepmd/utils/convert.py | 3 +- deepmd/utils/finetune.py | 3 +- deepmd/utils/multi_init.py | 3 +- deepmd/utils/neighbor_stat.py | 7 +- deepmd_utils/entrypoints/doc.py | 2 +- deepmd_utils/env.py | 4 +- deepmd_utils/main.py | 2 +- deepmd_utils/utils/data.py | 4 +- deepmd_utils/utils/data_system.py | 2 +- deepmd_utils/utils/path.py | 2 +- doc/conf.py | 2 +- source/api_c/include/deepmd.hpp | 12 +- source/api_c/tests/test_deeppot_a_hpp.cc | 2 +- source/api_cc/include/DataModifier.h | 4 +- source/api_cc/include/DeepPot.h | 4 +- source/api_cc/include/DeepTensor.h | 4 +- source/api_cc/include/common.h | 4 +- source/api_cc/src/DataModifier.cc | 2 +- source/api_cc/tests/test_deeppot_a.cc | 2 +- source/api_cc/tests/test_deeppot_r.cc | 2 +- source/install/build_tf.py | 9 +- source/lib/include/errors.h | 8 +- source/lib/include/neighbor_list.h | 6 +- source/lmp/pppm_dplr.h | 2 +- source/md/include/Integrator.h | 2 +- source/md/include/Tabulated.h | 2 +- source/md/include/Trajectory.h | 4 +- source/md/include/UnitManager.h | 2 +- source/op/add_flt_nvnmd.cc | 2 +- source/op/copy_flt_nvnmd.cc | 2 +- source/op/dotmul_flt_nvnmd.cc | 2 +- source/op/flt_nvnmd.cc | 2 +- source/op/mul_flt_nvnmd.cc | 2 +- source/tests/common.py | 10 +- 62 files changed, 489 insertions(+), 442 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7e0b0a4a76..9b3f099acb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: trailing-whitespace exclude: "^.+\\.pbtxt$" @@ -29,7 +29,7 @@ repos: exclude: ^source/3rdparty - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.3.5 + rev: v0.4.10 hooks: - id: ruff args: ["--fix"] @@ -52,7 +52,7 @@ repos: - id: blacken-docs # C++ - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v18.1.2 + rev: v18.1.7 hooks: - id: clang-format exclude: ^source/3rdparty|source/lib/src/gpu/cudart/.+\.inc @@ -75,6 +75,25 @@ repos: hooks: - id: cmake-format #- id: cmake-lint + - repo: https://github.com/njzjz/mirrors-bibtex-tidy + rev: v1.13.0 + hooks: + - id: bibtex-tidy + args: + - --curly + - --numeric + - --align=13 + - --blank-lines + # disable sort: the order of keys and fields has explict meanings + #- --sort=key + - --duplicates=key,doi,citation,abstract + - --merge=combine + #- --sort-fields + #- --strip-comments + - --trailing-commas + - --encode-urls + - --remove-empty-fields + - --wrap=80 # license header - repo: https://github.com/Lucas-C/pre-commit-hooks rev: v1.5.5 diff --git a/CITATIONS.bib b/CITATIONS.bib index ac682b28f7..a456e16bf4 100644 --- a/CITATIONS.bib +++ b/CITATIONS.bib @@ -1,272 +1,339 @@ -The proposed feature of each article is described in the "annote" field. -Please cite a article if any feature is used - -@article{Wang_ComputPhysCommun_2018_v228_p178, - annote = {general purpose}, - author = {Wang, Han and Zhang, Linfeng and Han, Jiequn and E, Weinan}, - doi = {10.1016/j.cpc.2018.03.016}, - year = 2018, - month = {jul}, - publisher = {Elsevier {BV}}, - volume = 228, - journal = {Comput. Phys. Comm.}, - title = {{DeePMD-kit: A deep learning package for many-body potential - energy representation and molecular dynamics}}, - pages = {178--184}, -} - -@Article{Zeng_JChemPhys_2023_v159_p054801, - annote = {general purpose}, - title = {{DeePMD-kit v2: A software package for deep potential models}}, - author = {Jinzhe Zeng and Duo Zhang and Denghui Lu and Pinghui Mo and Zeyu Li - and Yixiao Chen and Mari{\'a}n Rynik and Li'ang Huang and Ziyao Li and - Shaochen Shi and Yingze Wang and Haotian Ye and Ping Tuo and Jiabin - Yang and Ye Ding and Yifan Li and Davide Tisi and Qiyu Zeng and Han - Bao and Yu Xia and Jiameng Huang and Koki Muraoka and Yibo Wang and - Junhan Chang and Fengbo Yuan and Sigbj{\o}rn L{\o}land Bore and Chun - Cai and Yinnian Lin and Bo Wang and Jiayan Xu and Jia-Xin Zhu and - Chenxing Luo and Yuzhi Zhang and Rhys E A Goodall and Wenshuo Liang - and Anurag Kumar Singh and Sikai Yao and Jingchao Zhang and Renata - Wentzcovitch and Jiequn Han and Jie Liu and Weile Jia and Darrin M - York and Weinan E and Roberto Car and Linfeng Zhang and Han Wang}, - journal = {J. Chem. Phys.}, - volume = 159, - issue = 5, - year = 2023, - pages = 054801, - doi = {10.1063/5.0155600}, -} - - -@article{Lu_CompPhysCommun_2021_v259_p107624, - annote = {GPU support}, - title={{86 PFLOPS Deep Potential Molecular Dynamics simulation of 100 million - atoms with ab initio accuracy}}, - author={Lu, Denghui and Wang, Han and Chen, Mohan and Lin, Lin and Car, Roberto - and E, Weinan and Jia, Weile and Zhang, Linfeng}, - journal={Comput. Phys. Comm.}, - volume={259}, - pages={107624}, - year={2021}, - publisher={Elsevier}, - doi={10.1016/j.cpc.2020.107624}, -} - -@article{Zhang_PhysRevLett_2018_v120_p143001, - annote = {local frame (loc_frame)}, - author = {Linfeng Zhang and Jiequn Han and Han Wang and - Roberto Car and Weinan E}, - journal = {Phys. Rev. Lett.}, - number = {14}, - pages = {143001}, - publisher = {APS}, - title = {{Deep potential molecular dynamics: a scalable model - with the accuracy of quantum mechanics}}, - volume = {120}, - year = {2018}, - doi = {10.1103/PhysRevLett.120.143001} -} - -@incollection{Zhang_BookChap_NIPS_2018_v31_p4436, - annote = {DeepPot-SE (se_e2_a, se_e2_r, se_e3, se_atten)}, - title = {{End-to-end Symmetry Preserving Inter-atomic Potential Energy Model - for Finite and Extended Systems}}, - author = {Zhang, Linfeng and Han, Jiequn and Wang, Han and Saidi, Wissam and - Car, Roberto and E, Weinan}, - booktitle = {Advances in Neural Information Processing Systems 31}, - editor = {S. Bengio and H. Wallach and H. Larochelle and K. Grauman and N. - Cesa-Bianchi and R. Garnett}, - pages = {4436--4446}, - year = {2018}, - publisher = {Curran Associates, Inc.}, - url = {https://dl.acm.org/doi/10.5555/3327345.3327356} -} - -@Article{Wang_NuclFusion_2022_v62_p126013, - annote = {three-body embedding DeepPot-SE (se_e3)}, - author = {Xiaoyang Wang and Yinan Wang and Linfeng Zhang and Fuzhi Dai and Han - Wang}, - title = {{A tungsten deep neural-network potential for simulating mechanical - property degradation under fusion service environment}}, - journal = {Nucl. Fusion}, - year = 2022, - volume = 62, - issue = 12, - pages = 126013, - doi = {10.1088/1741-4326/ac888b}, -} - -@misc{Zhang_2022_DPA1, - annote = {attention-based descriptor}, - author = {Zhang, Duo and Bi, Hangrui and Dai, Fu-Zhi and Jiang, Wanrun and Zhang, Linfeng and Wang, Han}, - title = {{DPA-1: Pretraining of Attention-based Deep Potential Model for Molecular Simulation}}, - publisher = {arXiv}, - year = {2022}, - doi = {10.48550/arXiv.2208.08236}, -} - -@article{Zhang_PhysPlasmas_2020_v27_p122704, - annote = {frame-specific parameters (e.g. electronic temperature)}, - author = {Zhang, Yuzhi and Gao, Chang and Liu, Qianrui and Zhang, Linfeng and Wang, Han and Chen, Mohan}, - title = {{Warm dense matter simulation via electron temperature dependent deep potential molecular dynamics}}, - journal = {Phys. Plasmas}, - volume = {27}, - number = {12}, - pages = {122704}, - year = {2020}, - month = {12}, - doi = {10.1063/5.0023265}, -} - -@misc{Zeng_2023_TTMDPMD, - annote = {atom-specific parameter (e.g. electron temperature) }, - author = {Zeng, Qiyu and Chen, Bo and Zhang, Shen and Kang, Dongdong and Wang, Han and Yu, Xiaoxiang and Dai, Jiayu}, - title = {{Full-scale ab initio simulations of laser-driven atomistic dynamics}}, - publisher = {arXiv}, - year = {2023}, - doi = {10.48550/arXiv.2308.13863}, -} - -@article{Zhang_PhysRevB_2020_v102_p41121, - annote = {fit dipole}, - title={{Deep neural network for the dielectric response of insulators}}, - author={Zhang, Linfeng and Chen, Mohan and Wu, Xifan and Wang, Han and E, Weinan and Car, Roberto}, - journal={Phys. Rev. B}, - volume={102}, - number={4}, - pages={041121}, - year={2020}, - publisher={APS}, - doi={10.1103/PhysRevB.102.041121} -} - -@article{Sommers_PhysChemChemPhys_2020_v22_p10592, - annote = {fit polarizability}, - title={{Raman spectrum and polarizability of liquid water from deep neural networks}}, - author={Sommers, Grace M and Andrade, Marcos F Calegari and Zhang, Linfeng and Wang, Han and Car, Roberto}, - journal={Phys. Chem. Chem. Phys.}, - volume={22}, - number={19}, - pages={10592--10602}, - year={2020}, - publisher={Royal Society of Chemistry}, - doi={10.1039/D0CP01893G} -} - -@Article{Zeng_JChemTheoryComput_2023_v19_p1261, - annote = {fit relative energies}, - author = {Jinzhe Zeng and Yujun Tao and Timothy J Giese and Darrin M York}, - title = {{QD{\pi}: A Quantum Deep Potential Interaction Model for - Drug Discovery}}, - journal = {J. Chem. Theory Comput.}, - year = 2023, - volume = 19, - issue = 4, - pages = {1261--1275}, - doi = {10.1021/acs.jctc.2c01172}, -} - -@Article{Zeng_PhysRevB_2022_v105_p174109, - annote = {fit density of states}, - author = {Qiyu Zeng and Bo Chen and Xiaoxiang Yu and Shen Zhang and Dongdong - Kang and Han Wang and Jiayu Dai}, - title = {{Towards large-scale and spatiotemporally resolved diagnosis of - electronic density of states by deep learning}}, - journal = {Phys. Rev. B}, - year = 2022, - volume = 105, - issue = 17, - pages = 174109, - doi = {10.1103/PhysRevB.105.174109}, -} - -@Article{Zhang_JChemPhys_2022_v156_p124107, - annote = {DPLR, se_e2_r, hybrid descriptor}, - author = {Linfeng Zhang and Han Wang and Maria Carolina Muniz and Athanassios Z - Panagiotopoulos and Roberto Car and Weinan E}, - title = {{A deep potential model with long-range electrostatic interactions}}, - journal = {J. Chem. Phys.}, - year = 2022, - volume = 156, - issue = 12, - pages = 124107, - doi = {10.1063/5.0083669}, -} - -@article{Zeng_JChemTheoryComput_2021_v17_p6993, - annote= {DPRc}, - title={{Development of Range-Corrected Deep Learning Potentials for Fast, Accurate Quantum Mechanical/molecular Mechanical Simulations of Chemical Reactions in Solution}}, - author={Zeng, Jinzhe and Giese, Timothy J and Ekesan, {\c{S}}{\"o}len and York, Darrin M}, - journal={J. Chem. Theory Comput.}, - year=2021, - volume=17, - issue=11, - pages={6993-7009}, - doi = {10.1021/acs.jctc.1c00201}, -} - -@article{Wang_ApplPhysLett_2019_v114_p244101, - annote = {Interpolation with a pair-wise potential}, - title={{Deep learning inter-atomic potential model for accurate irradiation damage simulations}}, - author={Wang, Hao and Guo, Xun and Zhang, Linfeng and Wang, Han and Xue, Jianming}, - journal={Appl. Phys. Lett.}, - volume={114}, - number={24}, - pages={244101}, - year={2019}, - publisher={AIP Publishing LLC}, - doi={10.1063/1.5098061}, -} - -@article{Zhang_PhysRevMater_2019_v3_p23804, - annote = {model deviation}, - title = {{Active learning of uniformly accurate interatomic potentials for materials simulation}}, - author = {Linfeng Zhang and De-Ye Lin and Han Wang and Roberto Car and Weinan E}, - journal = {Phys. Rev. Mater.}, - volume = 3, - issue = 2, - pages = 23804, - year = 2019, - publisher = {American Physical Society}, - doi = {10.1103/PhysRevMaterials.3.023804}, -} - -@article{Lu_JChemTheoryComput_2022_v18_p5555, - annote = {DP Compress}, - author = {Denghui Lu and Wanrun Jiang and Yixiao Chen and Linfeng Zhang and - Weile Jia and Han Wang and Mohan Chen}, - title = {{DP Compress: A Model Compression Scheme for Generating Efficient Deep - Potential Models}}, - journal = {J. Chem. Theory Comput.}, - year = 2022, - volume=18, - issue=9, - pages={5555--5567}, - doi = {10.1021/acs.jctc.2c00102}, -} - -@article{Mo_npjComputMater_2022_v8_p107, - annote = {NVNMD}, - author = {Pinghui Mo and Chang Li and Dan Zhao and Yujia Zhang and Mengchao Shi - and Junhua Li and Jie Liu}, - title = {{Accurate and efficient molecular dynamics based on machine learning - and non von Neumann architecture}}, - journal = {npj Comput. Mater.}, - year = 2022, - volume = 8, - issue = 1, - pages = 107, - doi = {10.1038/s41524-022-00773-z}, -} - -@article{Zeng_EnergyFuels_2021_v35_p762, - annote = {relative or atomic model deviation}, - author = {Jinzhe Zeng and Linfeng Zhang and Han Wang and Tong Zhu}, - title = {{Exploring the Chemical Space of Linear Alkane Pyrolysis via Deep Potential GENerator}}, - journal = {Energy \& Fuels}, - volume = 35, - number = 1, - pages = {762--769}, - year = 2021, - doi = {10.1021/acs.energyfuels.0c03211}, -} +The proposed feature of each article is described in the "annote" field. +Please cite a article if any feature is used +@article{Wang_ComputPhysCommun_2018_v228_p178, + annote = {general purpose}, + author = {Wang, Han and Zhang, Linfeng and Han, Jiequn and E, Weinan}, + doi = {10.1016/j.cpc.2018.03.016}, + year = 2018, + month = {jul}, + publisher = {Elsevier {BV}}, + volume = 228, + journal = {Comput. Phys. Comm.}, + title = { + {DeePMD-kit: A deep learning package for many-body potential energy + representation and molecular dynamics} + }, + pages = {178--184}, +} + +@article{Zeng_JChemPhys_2023_v159_p054801, + annote = {general purpose}, + title = {{DeePMD-kit v2: A software package for deep potential models}}, + author = { + Jinzhe Zeng and Duo Zhang and Denghui Lu and Pinghui Mo and Zeyu Li and + Yixiao Chen and Mari{\'a}n Rynik and Li'ang Huang and Ziyao Li and Shaochen + Shi and Yingze Wang and Haotian Ye and Ping Tuo and Jiabin Yang and Ye Ding + and Yifan Li and Davide Tisi and Qiyu Zeng and Han Bao and Yu Xia and + Jiameng Huang and Koki Muraoka and Yibo Wang and Junhan Chang and Fengbo + Yuan and Sigbj{\o}rn L{\o}land Bore and Chun Cai and Yinnian Lin and Bo + Wang and Jiayan Xu and Jia-Xin Zhu and Chenxing Luo and Yuzhi Zhang and + Rhys E A Goodall and Wenshuo Liang and Anurag Kumar Singh and Sikai Yao and + Jingchao Zhang and Renata Wentzcovitch and Jiequn Han and Jie Liu and Weile + Jia and Darrin M York and Weinan E and Roberto Car and Linfeng Zhang and + Han Wang + }, + journal = {J. Chem. Phys.}, + volume = 159, + issue = 5, + year = 2023, + pages = 054801, + doi = {10.1063/5.0155600}, +} + +@article{Lu_CompPhysCommun_2021_v259_p107624, + annote = {GPU support}, + title = { + {86 PFLOPS Deep Potential Molecular Dynamics simulation of 100 million + atoms with ab initio accuracy} + }, + author = { + Lu, Denghui and Wang, Han and Chen, Mohan and Lin, Lin and Car, Roberto and + E, Weinan and Jia, Weile and Zhang, Linfeng + }, + journal = {Comput. Phys. Comm.}, + volume = 259, + pages = 107624, + year = 2021, + publisher = {Elsevier}, + doi = {10.1016/j.cpc.2020.107624}, +} + +@article{Zhang_PhysRevLett_2018_v120_p143001, + annote = {local frame (loc\_frame)}, + author = {Linfeng Zhang and Jiequn Han and Han Wang and Roberto Car and Weinan E}, + journal = {Phys. Rev. Lett.}, + number = 14, + pages = 143001, + publisher = {APS}, + title = { + {Deep potential molecular dynamics: a scalable model with the accuracy of + quantum mechanics} + }, + volume = 120, + year = 2018, + doi = {10.1103/PhysRevLett.120.143001}, +} + +@incollection{Zhang_BookChap_NIPS_2018_v31_p4436, + annote = {DeepPot-SE (se\_e2\_a, se\_e2\_r, se\_e3, se\_atten)}, + title = { + {End-to-end Symmetry Preserving Inter-atomic Potential Energy Model for + Finite and Extended Systems} + }, + author = { + Zhang, Linfeng and Han, Jiequn and Wang, Han and Saidi, Wissam and Car, + Roberto and E, Weinan + }, + booktitle = {Advances in Neural Information Processing Systems 31}, + editor = { + S. Bengio and H. Wallach and H. Larochelle and K. Grauman and N. + Cesa-Bianchi and R. Garnett + }, + pages = {4436--4446}, + year = 2018, + publisher = {Curran Associates, Inc.}, + url = {https://dl.acm.org/doi/10.5555/3327345.3327356}, +} + +@article{Wang_NuclFusion_2022_v62_p126013, + annote = {three-body embedding DeepPot-SE (se\_e3)}, + author = {Xiaoyang Wang and Yinan Wang and Linfeng Zhang and Fuzhi Dai and Han Wang}, + title = { + {A tungsten deep neural-network potential for simulating mechanical + property degradation under fusion service environment} + }, + journal = {Nucl. Fusion}, + year = 2022, + volume = 62, + issue = 12, + pages = 126013, + doi = {10.1088/1741-4326/ac888b}, +} + +@misc{Zhang_2022_DPA1, + annote = {attention-based descriptor}, + author = { + Zhang, Duo and Bi, Hangrui and Dai, Fu-Zhi and Jiang, Wanrun and Zhang, + Linfeng and Wang, Han + }, + title = { + {DPA-1: Pretraining of Attention-based Deep Potential Model for Molecular + Simulation} + }, + publisher = {arXiv}, + year = 2022, + doi = {10.48550/arXiv.2208.08236}, +} + +@article{Zhang_PhysPlasmas_2020_v27_p122704, + annote = {frame-specific parameters (e.g. electronic temperature)}, + author = { + Zhang, Yuzhi and Gao, Chang and Liu, Qianrui and Zhang, Linfeng and Wang, + Han and Chen, Mohan + }, + title = { + {Warm dense matter simulation via electron temperature dependent deep + potential molecular dynamics} + }, + journal = {Phys. Plasmas}, + volume = 27, + number = 12, + pages = 122704, + year = 2020, + month = 12, + doi = {10.1063/5.0023265}, +} + +@misc{Zeng_2023_TTMDPMD, + annote = {atom-specific parameter (e.g. electron temperature)}, + author = { + Zeng, Qiyu and Chen, Bo and Zhang, Shen and Kang, Dongdong and Wang, Han + and Yu, Xiaoxiang and Dai, Jiayu + }, + title = {{Full-scale ab initio simulations of laser-driven atomistic dynamics}}, + publisher = {arXiv}, + year = 2023, + doi = {10.48550/arXiv.2308.13863}, +} + +@article{Zhang_PhysRevB_2020_v102_p41121, + annote = {fit dipole}, + title = {{Deep neural network for the dielectric response of insulators}}, + author = { + Zhang, Linfeng and Chen, Mohan and Wu, Xifan and Wang, Han and E, Weinan + and Car, Roberto + }, + journal = {Phys. Rev. B}, + volume = 102, + number = 4, + pages = {041121}, + year = 2020, + publisher = {APS}, + doi = {10.1103/PhysRevB.102.041121}, +} + +@article{Sommers_PhysChemChemPhys_2020_v22_p10592, + annote = {fit polarizability}, + title = { + {Raman spectrum and polarizability of liquid water from deep neural + networks} + }, + author = { + Sommers, Grace M and Andrade, Marcos F Calegari and Zhang, Linfeng and + Wang, Han and Car, Roberto + }, + journal = {Phys. Chem. Chem. Phys.}, + volume = 22, + number = 19, + pages = {10592--10602}, + year = 2020, + publisher = {Royal Society of Chemistry}, + doi = {10.1039/D0CP01893G}, +} + +@article{Zeng_JChemTheoryComput_2023_v19_p1261, + annote = {fit relative energies}, + author = {Jinzhe Zeng and Yujun Tao and Timothy J Giese and Darrin M York}, + title = {{QD{\pi}: A Quantum Deep Potential Interaction Model for Drug Discovery}}, + journal = {J. Chem. Theory Comput.}, + year = 2023, + volume = 19, + issue = 4, + pages = {1261--1275}, + doi = {10.1021/acs.jctc.2c01172}, +} + +@article{Zeng_PhysRevB_2022_v105_p174109, + annote = {fit density of states}, + author = { + Qiyu Zeng and Bo Chen and Xiaoxiang Yu and Shen Zhang and Dongdong Kang and + Han Wang and Jiayu Dai + }, + title = { + {Towards large-scale and spatiotemporally resolved diagnosis of electronic + density of states by deep learning} + }, + journal = {Phys. Rev. B}, + year = 2022, + volume = 105, + issue = 17, + pages = 174109, + doi = {10.1103/PhysRevB.105.174109}, +} + +@article{Zhang_JChemPhys_2022_v156_p124107, + annote = {DPLR, se\_e2\_r, hybrid descriptor}, + author = { + Linfeng Zhang and Han Wang and Maria Carolina Muniz and Athanassios Z + Panagiotopoulos and Roberto Car and Weinan E + }, + title = {{A deep potential model with long-range electrostatic interactions}}, + journal = {J. Chem. Phys.}, + year = 2022, + volume = 156, + issue = 12, + pages = 124107, + doi = {10.1063/5.0083669}, +} + +@article{Zeng_JChemTheoryComput_2021_v17_p6993, + annote = {DPRc}, + title = { + {Development of Range-Corrected Deep Learning Potentials for Fast, Accurate + Quantum Mechanical/molecular Mechanical Simulations of Chemical Reactions + in Solution} + }, + author = { + Zeng, Jinzhe and Giese, Timothy J and Ekesan, {\c{S}}{\"o}len and York, + Darrin M + }, + journal = {J. Chem. Theory Comput.}, + year = 2021, + volume = 17, + issue = 11, + pages = {6993--7009}, + doi = {10.1021/acs.jctc.1c00201}, +} + +@article{Wang_ApplPhysLett_2019_v114_p244101, + annote = {Interpolation with a pair-wise potential}, + title = { + {Deep learning inter-atomic potential model for accurate irradiation damage + simulations} + }, + author = {Wang, Hao and Guo, Xun and Zhang, Linfeng and Wang, Han and Xue, Jianming}, + journal = {Appl. Phys. Lett.}, + volume = 114, + number = 24, + pages = 244101, + year = 2019, + publisher = {AIP Publishing LLC}, + doi = {10.1063/1.5098061}, +} + +@article{Zhang_PhysRevMater_2019_v3_p23804, + annote = {model deviation}, + title = { + {Active learning of uniformly accurate interatomic potentials for materials + simulation} + }, + author = {Linfeng Zhang and De-Ye Lin and Han Wang and Roberto Car and Weinan E}, + journal = {Phys. Rev. Mater.}, + volume = 3, + issue = 2, + pages = 23804, + year = 2019, + publisher = {American Physical Society}, + doi = {10.1103/PhysRevMaterials.3.023804}, +} + +@article{Lu_JChemTheoryComput_2022_v18_p5555, + annote = {DP Compress}, + author = { + Denghui Lu and Wanrun Jiang and Yixiao Chen and Linfeng Zhang and Weile Jia + and Han Wang and Mohan Chen + }, + title = { + {DP Compress: A Model Compression Scheme for Generating Efficient Deep + Potential Models} + }, + journal = {J. Chem. Theory Comput.}, + year = 2022, + volume = 18, + issue = 9, + pages = {5555--5567}, + doi = {10.1021/acs.jctc.2c00102}, +} + +@article{Mo_npjComputMater_2022_v8_p107, + annote = {NVNMD}, + author = { + Pinghui Mo and Chang Li and Dan Zhao and Yujia Zhang and Mengchao Shi and + Junhua Li and Jie Liu + }, + title = { + {Accurate and efficient molecular dynamics based on machine learning and + non von Neumann architecture} + }, + journal = {npj Comput. Mater.}, + year = 2022, + volume = 8, + issue = 1, + pages = 107, + doi = {10.1038/s41524-022-00773-z}, +} + +@article{Zeng_EnergyFuels_2021_v35_p762, + annote = {relative or atomic model deviation}, + author = {Jinzhe Zeng and Linfeng Zhang and Han Wang and Tong Zhu}, + title = { + {Exploring the Chemical Space of Linear Alkane Pyrolysis via Deep Potential + GENerator} + }, + journal = {Energy \& Fuels}, + volume = 35, + number = 1, + pages = {762--769}, + year = 2021, + doi = {10.1021/acs.energyfuels.0c03211}, +} diff --git a/backend/read_env.py b/backend/read_env.py index 079211d4d7..06f6f0c7e2 100644 --- a/backend/read_env.py +++ b/backend/read_env.py @@ -60,7 +60,7 @@ def get_argument_from_env() -> Tuple[str, list, list, dict, str]: if hipcc_flags is not None: os.environ["HIPFLAGS"] = os.environ.get("HIPFLAGS", "") + " " + hipcc_flags else: - raise RuntimeError("Unsupported DP_VARIANT option: %s" % dp_variant) + raise RuntimeError(f"Unsupported DP_VARIANT option: {dp_variant}") if os.environ.get("DP_BUILD_TESTING", "0") == "1": cmake_args.append("-DBUILD_TESTING:BOOL=TRUE") diff --git a/data/raw/copy_raw.py b/data/raw/copy_raw.py index 69ccdf5c63..2a4078df4d 100755 --- a/data/raw/copy_raw.py +++ b/data/raw/copy_raw.py @@ -85,7 +85,7 @@ def _main(): ) args = parser.parse_args() - print("# copy the system by %s copies" % args.ncopies) # noqa: T201 + print(f"# copy the system by {args.ncopies} copies") # noqa: T201 assert np.all( np.array(args.ncopies, dtype=int) >= np.array([1, 1, 1], dtype=int) ), "number of copies should be larger than or equal to 1" diff --git a/deepmd/cluster/local.py b/deepmd/cluster/local.py index 3c12c9dc85..694f6b8b56 100644 --- a/deepmd/cluster/local.py +++ b/deepmd/cluster/local.py @@ -43,7 +43,7 @@ def get_gpus(): stdout, stderr = p.communicate() if p.returncode != 0: decoded = stderr.decode("UTF-8") - raise RuntimeError("Failed to detect availbe GPUs due to:\n%s" % decoded) + raise RuntimeError(f"Failed to detect availbe GPUs due to:\n{decoded}") decoded = stdout.decode("UTF-8").strip() num_gpus = int(decoded) return list(range(num_gpus)) if num_gpus > 0 else None diff --git a/deepmd/descriptor/descriptor.py b/deepmd/descriptor/descriptor.py index 70c6cb2758..3e3115b9dd 100644 --- a/deepmd/descriptor/descriptor.py +++ b/deepmd/descriptor/descriptor.py @@ -283,7 +283,7 @@ def enable_compression( This method is called by others when the descriptor supported compression. """ raise NotImplementedError( - "Descriptor %s doesn't support compression!" % type(self).__name__ + f"Descriptor {type(self).__name__} doesn't support compression!" ) def enable_mixed_precision(self, mixed_prec: Optional[dict] = None) -> None: @@ -299,8 +299,7 @@ def enable_mixed_precision(self, mixed_prec: Optional[dict] = None) -> None: This method is called by others when the descriptor supported compression. """ raise NotImplementedError( - "Descriptor %s doesn't support mixed precision training!" - % type(self).__name__ + f"Descriptor {type(self).__name__} doesn't support mixed precision training!" ) @abstractmethod @@ -351,8 +350,7 @@ def init_variables( This method is called by others when the descriptor supported initialization from the given variables. """ raise NotImplementedError( - "Descriptor %s doesn't support initialization from the given variables!" - % type(self).__name__ + f"Descriptor {type(self).__name__} doesn't support initialization from the given variables!" ) def get_tensor_names(self, suffix: str = "") -> Tuple[str]: @@ -369,7 +367,7 @@ def get_tensor_names(self, suffix: str = "") -> Tuple[str]: Names of tensors """ raise NotImplementedError( - "Descriptor %s doesn't support this property!" % type(self).__name__ + f"Descriptor {type(self).__name__} doesn't support this property!" ) def pass_tensors_from_frz_model( @@ -389,7 +387,7 @@ def pass_tensors_from_frz_model( :meth:`get_tensor_names`. """ raise NotImplementedError( - "Descriptor %s doesn't support this method!" % type(self).__name__ + f"Descriptor {type(self).__name__} doesn't support this method!" ) def build_type_exclude_mask( diff --git a/deepmd/descriptor/loc_frame.py b/deepmd/descriptor/loc_frame.py index ccb66c864d..410cd038ac 100644 --- a/deepmd/descriptor/loc_frame.py +++ b/deepmd/descriptor/loc_frame.py @@ -427,12 +427,8 @@ def init_variables( suffix : str, optional The suffix of the scope """ - self.davg = get_tensor_by_name_from_graph( - graph, "descrpt_attr%s/t_avg" % suffix - ) - self.dstd = get_tensor_by_name_from_graph( - graph, "descrpt_attr%s/t_std" % suffix - ) + self.davg = get_tensor_by_name_from_graph(graph, f"descrpt_attr{suffix}/t_avg") + self.dstd = get_tensor_by_name_from_graph(graph, f"descrpt_attr{suffix}/t_std") @classmethod def update_sel(cls, global_jdata: dict, local_jdata: dict): diff --git a/deepmd/descriptor/se.py b/deepmd/descriptor/se.py index 598f6f9ff8..064e1c3bf2 100644 --- a/deepmd/descriptor/se.py +++ b/deepmd/descriptor/se.py @@ -130,12 +130,8 @@ def init_variables( self.embedding_net_variables = get_embedding_net_variables_from_graph_def( graph_def, suffix=suffix ) - self.davg = get_tensor_by_name_from_graph( - graph, "descrpt_attr%s/t_avg" % suffix - ) - self.dstd = get_tensor_by_name_from_graph( - graph, "descrpt_attr%s/t_std" % suffix - ) + self.davg = get_tensor_by_name_from_graph(graph, f"descrpt_attr{suffix}/t_avg") + self.dstd = get_tensor_by_name_from_graph(graph, f"descrpt_attr{suffix}/t_std") @property def precision(self) -> tf.DType: diff --git a/deepmd/descriptor/se_a.py b/deepmd/descriptor/se_a.py index ddbf9a34e5..f3e62d3672 100644 --- a/deepmd/descriptor/se_a.py +++ b/deepmd/descriptor/se_a.py @@ -540,12 +540,8 @@ def enable_compression( min_nbor_dist, table_extrapolate, table_stride_1, table_stride_2 ) - self.davg = get_tensor_by_name_from_graph( - graph, "descrpt_attr%s/t_avg" % suffix - ) - self.dstd = get_tensor_by_name_from_graph( - graph, "descrpt_attr%s/t_std" % suffix - ) + self.davg = get_tensor_by_name_from_graph(graph, f"descrpt_attr{suffix}/t_avg") + self.dstd = get_tensor_by_name_from_graph(graph, f"descrpt_attr{suffix}/t_std") def enable_mixed_precision(self, mixed_prec: Optional[dict] = None) -> None: """Reveive the mixed precision setting. @@ -1291,14 +1287,14 @@ def init_variables( super().init_variables(graph=graph, graph_def=graph_def, suffix=suffix) try: self.original_sel = get_tensor_by_name_from_graph( - graph, "descrpt_attr%s/original_sel" % suffix + graph, f"descrpt_attr{suffix}/original_sel" ) except GraphWithoutTensorError: # original_sel is not restored in old graphs, assume sel never changed before pass # check sel == original sel? try: - sel = get_tensor_by_name_from_graph(graph, "descrpt_attr%s/sel" % suffix) + sel = get_tensor_by_name_from_graph(graph, f"descrpt_attr{suffix}/sel") except GraphWithoutTensorError: # sel is not restored in old graphs pass diff --git a/deepmd/descriptor/se_atten.py b/deepmd/descriptor/se_atten.py index a9058cbdef..5615863254 100644 --- a/deepmd/descriptor/se_atten.py +++ b/deepmd/descriptor/se_atten.py @@ -447,12 +447,8 @@ def enable_compression( ) self.two_embd = make_data(self, self.final_type_embedding) - self.davg = get_tensor_by_name_from_graph( - graph, "descrpt_attr%s/t_avg" % suffix - ) - self.dstd = get_tensor_by_name_from_graph( - graph, "descrpt_attr%s/t_std" % suffix - ) + self.davg = get_tensor_by_name_from_graph(graph, f"descrpt_attr{suffix}/t_avg") + self.dstd = get_tensor_by_name_from_graph(graph, f"descrpt_attr{suffix}/t_std") def build( self, diff --git a/deepmd/descriptor/se_r.py b/deepmd/descriptor/se_r.py index b603d7098b..d5f8e59d18 100644 --- a/deepmd/descriptor/se_r.py +++ b/deepmd/descriptor/se_r.py @@ -365,12 +365,8 @@ def enable_compression( min_nbor_dist, table_extrapolate, table_stride_1, table_stride_2 ) - self.davg = get_tensor_by_name_from_graph( - graph, "descrpt_attr%s/t_avg" % suffix - ) - self.dstd = get_tensor_by_name_from_graph( - graph, "descrpt_attr%s/t_std" % suffix - ) + self.davg = get_tensor_by_name_from_graph(graph, f"descrpt_attr{suffix}/t_avg") + self.dstd = get_tensor_by_name_from_graph(graph, f"descrpt_attr{suffix}/t_std") def build( self, diff --git a/deepmd/descriptor/se_t.py b/deepmd/descriptor/se_t.py index 86e5ca6a1e..906ca144c4 100644 --- a/deepmd/descriptor/se_t.py +++ b/deepmd/descriptor/se_t.py @@ -368,12 +368,8 @@ def enable_compression( min_nbor_dist, table_extrapolate, table_stride_1 * 10, table_stride_2 * 10 ) - self.davg = get_tensor_by_name_from_graph( - graph, "descrpt_attr%s/t_avg" % suffix - ) - self.dstd = get_tensor_by_name_from_graph( - graph, "descrpt_attr%s/t_std" % suffix - ) + self.davg = get_tensor_by_name_from_graph(graph, f"descrpt_attr{suffix}/t_avg") + self.dstd = get_tensor_by_name_from_graph(graph, f"descrpt_attr{suffix}/t_std") def build( self, diff --git a/deepmd/entrypoints/compress.py b/deepmd/entrypoints/compress.py index 61d6dfcb44..85f5ed4e74 100644 --- a/deepmd/entrypoints/compress.py +++ b/deepmd/entrypoints/compress.py @@ -101,11 +101,10 @@ def compress( except GraphWithoutTensorError as e: if training_script is None: raise RuntimeError( - "The input frozen model: %s has no training script or min_nbor_dist information, " + f"The input frozen model: {input} has no training script or min_nbor_dist information, " "which is not supported by the model compression interface. " "Please consider using the --training-script command within the model compression interface to provide the training script of the input frozen model. " "Note that the input training script must contain the correct path to the training data." - % input ) from e elif not os.path.exists(training_script): raise RuntimeError( @@ -160,10 +159,10 @@ def compress( ) except GraphTooLargeError as e: raise RuntimeError( - "The uniform step size of the tabulation's first table is %f, " + f"The uniform step size of the tabulation's first table is {step:f}, " "which is too small. This leads to a very large graph size, " "exceeding protobuf's limitation (2 GB). You should try to " - "increase the step size." % step + "increase the step size." ) from e # reset the graph, otherwise the size limitation will be only 2 GB / 2 = 1 GB @@ -176,10 +175,10 @@ def compress( freeze(checkpoint_folder=checkpoint_folder, output=output, node_names=None) except GraphTooLargeError as e: raise RuntimeError( - "The uniform step size of the tabulation's first table is %f, " + f"The uniform step size of the tabulation's first table is {step:f}, " "which is too small. This leads to a very large graph size, " "exceeding protobuf's limitation (2 GB). You should try to " - "increase the step size." % step + "increase the step size." ) from e diff --git a/deepmd/entrypoints/freeze.py b/deepmd/entrypoints/freeze.py index f13ea85ab0..ddb9d3cf68 100755 --- a/deepmd/entrypoints/freeze.py +++ b/deepmd/entrypoints/freeze.py @@ -368,9 +368,9 @@ def freeze_graph( different_set -= set(optional_node) if different_set: log.warning( - "The following nodes are not in the graph: %s. " + f"The following nodes are not in the graph: {different_set}. " "Skip freezeing these nodes. You may be freezing " - "a checkpoint generated by an old version." % different_set + "a checkpoint generated by an old version." ) # use intersection as output list output_node = list(set(output_node) & set(input_node)) diff --git a/deepmd/entrypoints/neighbor_stat.py b/deepmd/entrypoints/neighbor_stat.py index 28cab00ad2..1c082322b5 100644 --- a/deepmd/entrypoints/neighbor_stat.py +++ b/deepmd/entrypoints/neighbor_stat.py @@ -59,6 +59,6 @@ def neighbor_stat( data.get_batch() nei = NeighborStat(data.get_ntypes(), rcut, one_type=one_type) min_nbor_dist, max_nbor_size = nei.get_stat(data) - log.info("min_nbor_dist: %f" % min_nbor_dist) - log.info("max_nbor_size: %s" % str(max_nbor_size)) + log.info(f"min_nbor_dist: {min_nbor_dist:f}") + log.info(f"max_nbor_size: {max_nbor_size!s}") return min_nbor_dist, max_nbor_size diff --git a/deepmd/entrypoints/test.py b/deepmd/entrypoints/test.py index 7bd4883925..1a8e507639 100644 --- a/deepmd/entrypoints/test.py +++ b/deepmd/entrypoints/test.py @@ -410,14 +410,14 @@ def test_ener( save_txt_file( detail_path.with_suffix(".e.out"), pe, - header="%s: data_e pred_e" % system, + header=f"{system}: data_e pred_e", append=append_detail, ) pe_atom = pe / natoms save_txt_file( detail_path.with_suffix(".e_peratom.out"), pe_atom, - header="%s: data_e pred_e" % system, + header=f"{system}: data_e pred_e", append=append_detail, ) if dp.get_ntypes_spin() == 0: @@ -431,7 +431,7 @@ def test_ener( save_txt_file( detail_path.with_suffix(".f.out"), pf, - header="%s: data_fx data_fy data_fz pred_fx pred_fy pred_fz" % system, + header=f"{system}: data_fx data_fy data_fz pred_fx pred_fy pred_fz", append=append_detail, ) else: @@ -446,14 +446,13 @@ def test_ener( save_txt_file( detail_path.with_suffix(".fr.out"), pf_real, - header="%s: data_fx data_fy data_fz pred_fx pred_fy pred_fz" % system, + header=f"{system}: data_fx data_fy data_fz pred_fx pred_fy pred_fz", append=append_detail, ) save_txt_file( detail_path.with_suffix(".fm.out"), pf_mag, - header="%s: data_fmx data_fmy data_fmz pred_fmx pred_fmy pred_fmz" - % system, + header=f"{system}: data_fmx data_fmy data_fmz pred_fmx pred_fmy pred_fmz", append=append_detail, ) pv = np.concatenate( diff --git a/deepmd/fit/dos.py b/deepmd/fit/dos.py index bbf7d39a09..57059b1387 100644 --- a/deepmd/fit/dos.py +++ b/deepmd/fit/dos.py @@ -587,21 +587,21 @@ def init_variables( self.fitting_net_variables.update(shared_variables) if self.numb_fparam > 0: self.fparam_avg = get_tensor_by_name_from_graph( - graph, "fitting_attr%s/t_fparam_avg" % suffix + graph, f"fitting_attr{suffix}/t_fparam_avg" ) self.fparam_inv_std = get_tensor_by_name_from_graph( - graph, "fitting_attr%s/t_fparam_istd" % suffix + graph, f"fitting_attr{suffix}/t_fparam_istd" ) if self.numb_aparam > 0: self.aparam_avg = get_tensor_by_name_from_graph( - graph, "fitting_attr%s/t_aparam_avg" % suffix + graph, f"fitting_attr{suffix}/t_aparam_avg" ) self.aparam_inv_std = get_tensor_by_name_from_graph( - graph, "fitting_attr%s/t_aparam_istd" % suffix + graph, f"fitting_attr{suffix}/t_aparam_istd" ) try: self.bias_dos = get_tensor_by_name_from_graph( - graph, "fitting_attr%s/t_bias_dos" % suffix + graph, f"fitting_attr{suffix}/t_bias_dos" ) except GraphWithoutTensorError: # for compatibility, old models has no t_bias_dos diff --git a/deepmd/fit/ener.py b/deepmd/fit/ener.py index 4610384d7e..e417076fce 100644 --- a/deepmd/fit/ener.py +++ b/deepmd/fit/ener.py @@ -754,21 +754,21 @@ def init_variables( self.fitting_net_variables.update(shared_variables) if self.numb_fparam > 0: self.fparam_avg = get_tensor_by_name_from_graph( - graph, "fitting_attr%s/t_fparam_avg" % suffix + graph, f"fitting_attr{suffix}/t_fparam_avg" ) self.fparam_inv_std = get_tensor_by_name_from_graph( - graph, "fitting_attr%s/t_fparam_istd" % suffix + graph, f"fitting_attr{suffix}/t_fparam_istd" ) if self.numb_aparam > 0: self.aparam_avg = get_tensor_by_name_from_graph( - graph, "fitting_attr%s/t_aparam_avg" % suffix + graph, f"fitting_attr{suffix}/t_aparam_avg" ) self.aparam_inv_std = get_tensor_by_name_from_graph( - graph, "fitting_attr%s/t_aparam_istd" % suffix + graph, f"fitting_attr{suffix}/t_aparam_istd" ) try: self.bias_atom_e = get_tensor_by_name_from_graph( - graph, "fitting_attr%s/t_bias_atom_e" % suffix + graph, f"fitting_attr{suffix}/t_bias_atom_e" ) except GraphWithoutTensorError: # for compatibility, old models has no t_bias_atom_e diff --git a/deepmd/fit/fitting.py b/deepmd/fit/fitting.py index a467ec1201..61af88a82b 100644 --- a/deepmd/fit/fitting.py +++ b/deepmd/fit/fitting.py @@ -82,8 +82,7 @@ def init_variables( This method is called by others when the fitting supported initialization from the given variables. """ raise NotImplementedError( - "Fitting %s doesn't support initialization from the given variables!" - % type(self).__name__ + f"Fitting {type(self).__name__} doesn't support initialization from the given variables!" ) @abstractmethod diff --git a/deepmd/infer/deep_pot.py b/deepmd/infer/deep_pot.py index 81cfdde7a8..ea72d1330b 100644 --- a/deepmd/infer/deep_pot.py +++ b/deepmd/infer/deep_pot.py @@ -124,7 +124,7 @@ def __init__( # check if the graph has these operations: # if yes add them - if ("%s/t_efield" % load_prefix) in operations: + if (f"{load_prefix}/t_efield") in operations: self.tensors.update({"t_efield": "t_efield:0"}) self.has_efield = True else: @@ -132,7 +132,7 @@ def __init__( self.t_efield = None self.has_efield = False - if ("%s/t_fparam" % load_prefix) in operations: + if (f"{load_prefix}/t_fparam") in operations: self.tensors.update({"t_fparam": "t_fparam:0"}) self.has_fparam = True else: @@ -140,7 +140,7 @@ def __init__( self.t_fparam = None self.has_fparam = False - if ("%s/t_aparam" % load_prefix) in operations: + if (f"{load_prefix}/t_aparam") in operations: self.tensors.update({"t_aparam": "t_aparam:0"}) self.has_aparam = True else: @@ -148,7 +148,7 @@ def __init__( self.t_aparam = None self.has_aparam = False - if ("%s/spin_attr/ntypes_spin" % load_prefix) in operations: + if (f"{load_prefix}/spin_attr/ntypes_spin") in operations: self.tensors.update({"t_ntypes_spin": "spin_attr/ntypes_spin:0"}) self.has_spin = True else: diff --git a/deepmd/model/dos.py b/deepmd/model/dos.py index 22e291a0f0..76329b5798 100644 --- a/deepmd/model/dos.py +++ b/deepmd/model/dos.py @@ -228,6 +228,6 @@ def init_variables( self.fitting.init_variables(graph, graph_def, suffix=suffix) tf.constant("compressed_model", name="model_type", dtype=tf.string) else: - raise RuntimeError("Unknown model type %s" % model_type) + raise RuntimeError(f"Unknown model type {model_type}") if self.typeebd is not None: self.typeebd.init_variables(graph, graph_def, suffix=suffix) diff --git a/deepmd/model/ener.py b/deepmd/model/ener.py index 0d8d66b305..7f665fe2c3 100644 --- a/deepmd/model/ener.py +++ b/deepmd/model/ener.py @@ -375,7 +375,7 @@ def init_variables( self.fitting.init_variables(graph, graph_def, suffix=suffix) tf.constant("compressed_model", name="model_type", dtype=tf.string) else: - raise RuntimeError("Unknown model type %s" % model_type) + raise RuntimeError(f"Unknown model type {model_type}") if ( self.typeebd is not None and self.typeebd.type_embedding_net_variables is None diff --git a/deepmd/model/model.py b/deepmd/model/model.py index 6117b4942d..3f2fde415f 100644 --- a/deepmd/model/model.py +++ b/deepmd/model/model.py @@ -301,11 +301,11 @@ def build_descrpt( else: tf.constant( self.rcut, - name="descrpt_attr%s/rcut" % suffix, + name=f"descrpt_attr{suffix}/rcut", dtype=GLOBAL_TF_FLOAT_PRECISION, ) tf.constant( - self.ntypes, name="descrpt_attr%s/ntypes" % suffix, dtype=tf.int32 + self.ntypes, name=f"descrpt_attr{suffix}/ntypes", dtype=tf.int32 ) if "global_feed_dict" in input_dict: feed_dict = input_dict["global_feed_dict"] @@ -320,7 +320,7 @@ def build_descrpt( ) return_elements = [ *self.descrpt.get_tensor_names(suffix=suffix), - "o_descriptor%s:0" % suffix, + f"o_descriptor{suffix}:0", ] if frz_model is not None: imported_tensors = self._import_graph_def_from_frz_model( diff --git a/deepmd/model/tensor.py b/deepmd/model/tensor.py index 6a21e085f3..9564e9b903 100644 --- a/deepmd/model/tensor.py +++ b/deepmd/model/tensor.py @@ -234,7 +234,7 @@ def init_variables( self.fitting.init_variables(graph, graph_def, suffix=suffix) tf.constant("compressed_model", name="model_type", dtype=tf.string) else: - raise RuntimeError("Unknown model type %s" % model_type) + raise RuntimeError(f"Unknown model type {model_type}") class WFCModel(TensorModel): diff --git a/deepmd/nvnmd/entrypoints/train.py b/deepmd/nvnmd/entrypoints/train.py index 6e14b6f865..439ebaed0a 100644 --- a/deepmd/nvnmd/entrypoints/train.py +++ b/deepmd/nvnmd/entrypoints/train.py @@ -126,7 +126,7 @@ def train_nvnmd( ): # test input if not os.path.exists(INPUT): - log.warning("The input script %s does not exist" % (INPUT)) + log.warning(f"The input script {INPUT} does not exist") # STEP1 PATH_CNN = "nvnmd_cnn" CONFIG_CNN = os.path.join(PATH_CNN, "config.npy") diff --git a/deepmd/nvnmd/entrypoints/wrap.py b/deepmd/nvnmd/entrypoints/wrap.py index 1ba2ed7384..868afbed93 100644 --- a/deepmd/nvnmd/entrypoints/wrap.py +++ b/deepmd/nvnmd/entrypoints/wrap.py @@ -137,7 +137,7 @@ def wrap(self): # DEVELOP_DEBUG if jdata_sys["debug"]: log.info("%s: %d x % d bit" % (k, h, w * 4)) - FioTxt().save("nvnmd/wrap/h%s.txt" % (k), d) + FioTxt().save(f"nvnmd/wrap/h{k}.txt", d) datas[ii] = d # update h & w of nvnmd_cfg nvnmd_cfg.size["NH_DATA"] = nhs diff --git a/deepmd/nvnmd/utils/fio.py b/deepmd/nvnmd/utils/fio.py index 82567e3917..3efd7520dd 100644 --- a/deepmd/nvnmd/utils/fio.py +++ b/deepmd/nvnmd/utils/fio.py @@ -180,7 +180,7 @@ def save(self, file_name: str, data: List[str]): buff.extend(list(bytearray.fromhex(si))[::-1]) # with open(file_name, "wb") as fp: - fp.write(struct.pack("%sB" % len(buff), *buff)) + fp.write(struct.pack(f"{len(buff)}B", *buff)) class FioTxt: diff --git a/deepmd/train/trainer.py b/deepmd/train/trainer.py index 719250e7fb..d059aa84cc 100644 --- a/deepmd/train/trainer.py +++ b/deepmd/train/trainer.py @@ -239,7 +239,7 @@ def build(self, data=None, stop_batch=0, origin_type_map=None, suffix=""): ) else: log.info( - "fitting net %s training without frame parameter" % fitting_key + f"fitting net {fitting_key} training without frame parameter" ) if not self.is_compress: @@ -437,8 +437,7 @@ def _build_optimizer(self, fitting_key=None): _TF_VERSION = Version(TF_VERSION) if _TF_VERSION < Version("1.14.0"): raise RuntimeError( - "TensorFlow version %s is not compatible with the mixed precision setting. Please consider upgrading your TF version!" - % TF_VERSION + f"TensorFlow version {TF_VERSION} is not compatible with the mixed precision setting. Please consider upgrading your TF version!" ) elif _TF_VERSION < Version("2.4.0"): optimizer = tf.train.experimental.enable_mixed_precision_graph_rewrite( @@ -502,14 +501,14 @@ def _init_session(self): fp = open(self.disp_file, "w") fp.close() elif self.run_opt.init_mode == "init_from_model": - log.info("initialize from model %s" % self.run_opt.init_model) + log.info(f"initialize from model {self.run_opt.init_model}") run_sess(self.sess, init_op) self.saver.restore(self.sess, self.run_opt.init_model) run_sess(self.sess, self.global_step.assign(0)) fp = open(self.disp_file, "w") fp.close() elif self.run_opt.init_mode == "restart": - log.info("restart from model %s" % self.run_opt.restart) + log.info(f"restart from model {self.run_opt.restart}") run_sess(self.sess, init_op) self.saver.restore(self.sess, self.run_opt.restart) elif self.run_opt.init_mode == "init_from_frz_model": @@ -844,7 +843,7 @@ def save_checkpoint(self, cur_batch: int): os.symlink(os.path.relpath(ori_ff, os.path.dirname(new_ff)), new_ff) else: shutil.copyfile(ori_ff, new_ff) - log.info("saved checkpoint %s" % self.save_ckpt) + log.info(f"saved checkpoint {self.save_ckpt}") def get_feed_dict(self, batch, is_training): feed_dict = {} @@ -970,7 +969,7 @@ def print_on_training( prop_fmt = " %11.2e" for k in train_results.keys(): print_str += prop_fmt % (train_results[k]) - print_str += " %8.1e\n" % cur_lr + print_str += f" {cur_lr:8.1e}\n" else: for fitting_key in train_results: if valid_results[fitting_key] is not None: @@ -985,7 +984,7 @@ def print_on_training( prop_fmt = " %11.2e" for k in train_results[fitting_key].keys(): print_str += prop_fmt % (train_results[fitting_key][k]) - print_str += " %8.1e\n" % cur_lr_dict[fitting_key] + print_str += f" {cur_lr_dict[fitting_key]:8.1e}\n" fp.write(print_str) fp.flush() @@ -1063,9 +1062,8 @@ def _init_from_frz_model(self): except GraphWithoutTensorError as e: # throw runtime error if the frozen_model has no model type information... raise RuntimeError( - "The input frozen model: %s has no 'model_type' information, " + f"The input frozen model: {self.run_opt.init_frz_model} has no 'model_type' information, " "which is not supported by the 'dp train init-frz-model' interface. " - % self.run_opt.init_frz_model ) from e else: self.model_type = bytes.decode(t_model_type) @@ -1117,9 +1115,8 @@ def _init_from_pretrained_model( except GraphWithoutTensorError as e: # throw runtime error if the frozen_model has no model type information... raise RuntimeError( - "The input frozen pretrained model: %s has no 'model_type' information, " + f"The input frozen pretrained model: {self.run_opt.finetune} has no 'model_type' information, " "which is not supported by the 'dp train finetune' interface. " - % self.run_opt.finetune ) from e else: self.model_type = bytes.decode(t_model_type) diff --git a/deepmd/utils/convert.py b/deepmd/utils/convert.py index 13e07f0885..ff90b596d2 100644 --- a/deepmd/utils/convert.py +++ b/deepmd/utils/convert.py @@ -77,8 +77,7 @@ def convert_to_21(input_model: str, output_model: str, version: Optional[str] = convert_pb_to_pbtxt(input_model, "frozen_model.pbtxt") if version is None: raise ValueError( - "The version of the DP graph %s cannot be detected. Please do the conversion manually." - % (input_model) + f"The version of the DP graph {input_model} cannot be detected. Please do the conversion manually." ) if version in SpecifierSet("<1.0"): convert_dp012_to_dp10("frozen_model.pbtxt") diff --git a/deepmd/utils/finetune.py b/deepmd/utils/finetune.py index 922d131b7e..84b0da962f 100644 --- a/deepmd/utils/finetune.py +++ b/deepmd/utils/finetune.py @@ -33,10 +33,9 @@ def replace_model_params_with_pretrained_model( t_jdata = get_tensor_by_name(pretrained_model, "train_attr/training_script") except GraphWithoutTensorError as e: raise RuntimeError( - "The input frozen pretrained model: %s has no training script, " + f"The input frozen pretrained model: {input} has no training script, " "which is not supported to perform finetuning. " "Please use the model pretrained with v2.1.5 or higher version of DeePMD-kit." - % input ) from e pretrained_jdata = json.loads(t_jdata) diff --git a/deepmd/utils/multi_init.py b/deepmd/utils/multi_init.py index d29a42cf0f..83de69e3a0 100644 --- a/deepmd/utils/multi_init.py +++ b/deepmd/utils/multi_init.py @@ -33,10 +33,9 @@ def replace_model_params_with_frz_multi_model( t_jdata = get_tensor_by_name(pretrained_model, "train_attr/training_script") except GraphWithoutTensorError as e: raise RuntimeError( - "The input frozen pretrained model: %s has no training script, " + f"The input frozen pretrained model: {input} has no training script, " "which is not supported to perform multi-task training. " "Please use the model pretrained with v2.1.5 or higher version of DeePMD-kit." - % input ) from e pretrained_jdata = json.loads(t_jdata) diff --git a/deepmd/utils/neighbor_stat.py b/deepmd/utils/neighbor_stat.py index 982ead3549..51c8c99658 100644 --- a/deepmd/utils/neighbor_stat.py +++ b/deepmd/utils/neighbor_stat.py @@ -210,16 +210,15 @@ def get_stat(self, data: DeepmdDataSystem) -> Tuple[float, np.ndarray]: for mn, dt, jj in self.iterator(data): if np.isinf(dt): log.warning( - "Atoms with no neighbors found in %s. Please make sure it's what you expected." - % jj + f"Atoms with no neighbors found in {jj}. Please make sure it's what you expected." ) if dt < min_nbor_dist: if math.isclose(dt, 0.0, rel_tol=1e-6): # it's unexpected that the distance between two atoms is zero # zero distance will cause nan (#874) raise RuntimeError( - "Some atoms are overlapping in %s. Please check your" - " training data to remove duplicated atoms." % jj + f"Some atoms are overlapping in {jj}. Please check your" + " training data to remove duplicated atoms." ) min_nbor_dist = dt max_nbor_size = np.maximum(mn, max_nbor_size) diff --git a/deepmd_utils/entrypoints/doc.py b/deepmd_utils/entrypoints/doc.py index 2c2c5e8451..457796c026 100644 --- a/deepmd_utils/entrypoints/doc.py +++ b/deepmd_utils/entrypoints/doc.py @@ -16,5 +16,5 @@ def doc_train_input(*, out_type: str = "rst", **kwargs): elif out_type == "json": doc_str = gen_json() else: - raise RuntimeError("Unsupported out type %s" % out_type) + raise RuntimeError(f"Unsupported out type {out_type}") print(doc_str) # noqa: T201 diff --git a/deepmd_utils/env.py b/deepmd_utils/env.py index b1d4958ed8..75a3ecf288 100644 --- a/deepmd_utils/env.py +++ b/deepmd_utils/env.py @@ -22,7 +22,7 @@ global_float_prec = "float" else: raise RuntimeError( - "Unsupported float precision option: %s. Supported: high," + f"Unsupported float precision option: {dp_float_prec}. Supported: high," "low. Please set precision with environmental variable " - "DP_INTERFACE_PREC." % dp_float_prec + "DP_INTERFACE_PREC." ) diff --git a/deepmd_utils/main.py b/deepmd_utils/main.py index ae4852acc9..82dacdbac2 100644 --- a/deepmd_utils/main.py +++ b/deepmd_utils/main.py @@ -544,7 +544,7 @@ def main_parser() -> argparse.ArgumentParser: # --version parser.add_argument( - "--version", action="version", version="DeePMD-kit v%s" % __version__ + "--version", action="version", version=f"DeePMD-kit v{__version__}" ) # * train nvnmd script ****************************************************************** diff --git a/deepmd_utils/utils/data.py b/deepmd_utils/utils/data.py index 534216dfaf..6494d25675 100644 --- a/deepmd_utils/utils/data.py +++ b/deepmd_utils/utils/data.py @@ -359,7 +359,7 @@ def get_natoms_vec(self, ntypes: int): def avg(self, key): """Return the average value of an item.""" if key not in self.data_dict.keys(): - raise RuntimeError("key %s has not been added" % key) + raise RuntimeError(f"key {key} has not been added") info = self.data_dict[key] ndof = info["ndof"] eners = [] @@ -568,7 +568,7 @@ def _load_data( data = np.repeat(data, repeat).reshape([nframes, -1]) return np.float32(1.0), data elif must: - raise RuntimeError("%s not found!" % path) + raise RuntimeError(f"{path} not found!") else: data = np.full([nframes, ndof], default, dtype=dtype) if repeat != 1: diff --git a/deepmd_utils/utils/data_system.py b/deepmd_utils/utils/data_system.py index f83f587590..a2abca85db 100644 --- a/deepmd_utils/utils/data_system.py +++ b/deepmd_utils/utils/data_system.py @@ -559,7 +559,7 @@ def print_summary(self, name): ) log.info("found %d system(s):" % self.nsystems) log.info( - ("%s " % self._format_name_length("system", sys_width)) + ("{} ".format(self._format_name_length("system", sys_width))) + ("%6s %6s %6s %9s %3s" % ("natoms", "bch_sz", "n_bch", "prob", "pbc")) ) for ii in range(self.nsystems): diff --git a/deepmd_utils/utils/path.py b/deepmd_utils/utils/path.py index a8e4bc329f..751ee3731e 100644 --- a/deepmd_utils/utils/path.py +++ b/deepmd_utils/utils/path.py @@ -39,7 +39,7 @@ def __new__(cls, path: str): # assume h5 if it is not dir # TODO: check if it is a real h5? or just check suffix? return super().__new__(DPH5Path) - raise FileNotFoundError("%s not found" % path) + raise FileNotFoundError(f"{path} not found") return super().__new__(cls) @abstractmethod diff --git a/doc/conf.py b/doc/conf.py index fae850a132..09dc43fa68 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -174,7 +174,7 @@ def setup(app): import typing for typing_type in typing.__all__: - numpydoc_xref_aliases[typing_type] = "typing.%s" % typing_type + numpydoc_xref_aliases[typing_type] = f"typing.{typing_type}" rst_epilog = f""" .. |ACTIVATION_FN| replace:: {list_to_doc(ACTIVATION_FN_DICT.keys())} diff --git a/source/api_c/include/deepmd.hpp b/source/api_c/include/deepmd.hpp index f348a3dbe9..059612f7af 100644 --- a/source/api_c/include/deepmd.hpp +++ b/source/api_c/include/deepmd.hpp @@ -25,9 +25,9 @@ namespace hpp { **/ struct deepmd_exception : public std::runtime_error { public: - deepmd_exception() : runtime_error("DeePMD-kit C API Error!"){}; + deepmd_exception() : runtime_error("DeePMD-kit C API Error!") {}; deepmd_exception(const std::string &msg) - : runtime_error(std::string("DeePMD-kit C API Error: ") + msg){}; + : runtime_error(std::string("DeePMD-kit C API Error: ") + msg) {}; }; } // namespace hpp } // namespace deepmd @@ -620,7 +620,7 @@ class DeepPot { /** * @brief DP constructor without initialization. **/ - DeepPot() : dp(nullptr){}; + DeepPot() : dp(nullptr) {}; ~DeepPot() { DP_DeleteDeepPot(dp); }; /** * @brief DP constructor with initialization. @@ -1160,7 +1160,7 @@ class DeepPotModelDevi { /** * @brief DP model deviation constructor without initialization. **/ - DeepPotModelDevi() : dp(nullptr){}; + DeepPotModelDevi() : dp(nullptr) {}; ~DeepPotModelDevi() { DP_DeleteDeepPotModelDevi(dp); }; /** * @brief DP model deviation constructor with initialization. @@ -1785,7 +1785,7 @@ class DeepTensor { /** * @brief Deep Tensor constructor without initialization. **/ - DeepTensor() : dt(nullptr){}; + DeepTensor() : dt(nullptr) {}; ~DeepTensor() { DP_DeleteDeepTensor(dt); }; /** * @brief DeepTensor constructor with initialization. @@ -2161,7 +2161,7 @@ class DipoleChargeModifier { /** * @brief DipoleChargeModifier constructor without initialization. **/ - DipoleChargeModifier() : dcm(nullptr){}; + DipoleChargeModifier() : dcm(nullptr) {}; ~DipoleChargeModifier() { DP_DeleteDipoleChargeModifier(dcm); }; /** * @brief DipoleChargeModifier constructor with initialization. diff --git a/source/api_c/tests/test_deeppot_a_hpp.cc b/source/api_c/tests/test_deeppot_a_hpp.cc index 814122d538..388b53fdfd 100644 --- a/source/api_c/tests/test_deeppot_a_hpp.cc +++ b/source/api_c/tests/test_deeppot_a_hpp.cc @@ -140,7 +140,7 @@ TYPED_TEST(TestInferDeepPotAHPP, cpu_build_nlist_numfv) { public: MyModel(deepmd::hpp::DeepPot& dp_, const std::vector& atype_) - : mydp(dp_), atype(atype_){}; + : mydp(dp_), atype(atype_) {}; virtual void compute(double& ener, std::vector& force, std::vector& virial, diff --git a/source/api_cc/include/DataModifier.h b/source/api_cc/include/DataModifier.h index 0f46b5e0f8..9933f034a6 100644 --- a/source/api_cc/include/DataModifier.h +++ b/source/api_cc/include/DataModifier.h @@ -14,7 +14,7 @@ class DipoleChargeModifierBase { /** * @brief Dipole charge modifier without initialization. **/ - DipoleChargeModifierBase(){}; + DipoleChargeModifierBase() {}; /** * @brief Dipole charge modifier without initialization. * @param[in] model The name of the frozen model file. @@ -24,7 +24,7 @@ class DipoleChargeModifierBase { DipoleChargeModifierBase(const std::string& model, const int& gpu_rank = 0, const std::string& name_scope = ""); - virtual ~DipoleChargeModifierBase(){}; + virtual ~DipoleChargeModifierBase() {}; /** * @brief Initialize the dipole charge modifier. * @param[in] model The name of the frozen model file. diff --git a/source/api_cc/include/DeepPot.h b/source/api_cc/include/DeepPot.h index fa35d4b13a..3da5c34184 100644 --- a/source/api_cc/include/DeepPot.h +++ b/source/api_cc/include/DeepPot.h @@ -15,8 +15,8 @@ class DeepPotBase { /** * @brief DP constructor without initialization. **/ - DeepPotBase(){}; - virtual ~DeepPotBase(){}; + DeepPotBase() {}; + virtual ~DeepPotBase() {}; /** * @brief DP constructor with initialization. * @param[in] model The name of the frozen model file. diff --git a/source/api_cc/include/DeepTensor.h b/source/api_cc/include/DeepTensor.h index 5592942d87..f355413d80 100644 --- a/source/api_cc/include/DeepTensor.h +++ b/source/api_cc/include/DeepTensor.h @@ -15,8 +15,8 @@ class DeepTensorBase { /** * @brief Deep Tensor constructor without initialization. **/ - DeepTensorBase(){}; - virtual ~DeepTensorBase(){}; + DeepTensorBase() {}; + virtual ~DeepTensorBase() {}; /** * @brief Deep Tensor constructor with initialization.. * @param[in] model The name of the frozen model file. diff --git a/source/api_cc/include/common.h b/source/api_cc/include/common.h index 7982c4f89d..ede34b68c9 100644 --- a/source/api_cc/include/common.h +++ b/source/api_cc/include/common.h @@ -170,9 +170,9 @@ void load_op_library(); **/ struct tf_exception : public deepmd::deepmd_exception { public: - tf_exception() : deepmd::deepmd_exception("TensorFlow Error!"){}; + tf_exception() : deepmd::deepmd_exception("TensorFlow Error!") {}; tf_exception(const std::string& msg) - : deepmd::deepmd_exception(std::string("TensorFlow Error: ") + msg){}; + : deepmd::deepmd_exception(std::string("TensorFlow Error: ") + msg) {}; }; /** diff --git a/source/api_cc/src/DataModifier.cc b/source/api_cc/src/DataModifier.cc index d44d552bb2..e9aee65de2 100644 --- a/source/api_cc/src/DataModifier.cc +++ b/source/api_cc/src/DataModifier.cc @@ -15,7 +15,7 @@ DipoleChargeModifier::DipoleChargeModifier(const std::string& model, init(model, gpu_rank, name_scope_); } -DipoleChargeModifier::~DipoleChargeModifier(){}; +DipoleChargeModifier::~DipoleChargeModifier() {}; void DipoleChargeModifier::init(const std::string& model, const int& gpu_rank, diff --git a/source/api_cc/tests/test_deeppot_a.cc b/source/api_cc/tests/test_deeppot_a.cc index 067b2ff524..ae1384e8a3 100644 --- a/source/api_cc/tests/test_deeppot_a.cc +++ b/source/api_cc/tests/test_deeppot_a.cc @@ -143,7 +143,7 @@ TYPED_TEST(TestInferDeepPotA, cpu_build_nlist_numfv) { public: MyModel(deepmd::DeepPot& dp_, const std::vector& atype_) - : mydp(dp_), atype(atype_){}; + : mydp(dp_), atype(atype_) {}; virtual void compute(double& ener, std::vector& force, std::vector& virial, diff --git a/source/api_cc/tests/test_deeppot_r.cc b/source/api_cc/tests/test_deeppot_r.cc index 8eec36522e..86fa4b091f 100644 --- a/source/api_cc/tests/test_deeppot_r.cc +++ b/source/api_cc/tests/test_deeppot_r.cc @@ -143,7 +143,7 @@ TYPED_TEST(TestInferDeepPotR, cpu_build_nlist_numfv) { public: MyModel(deepmd::DeepPot& dp_, const std::vector& atype_) - : mydp(dp_), atype(atype_){}; + : mydp(dp_), atype(atype_) {}; virtual void compute(double& ener, std::vector& force, std::vector& virial, diff --git a/source/install/build_tf.py b/source/install/build_tf.py index 15847d2c21..13f773ce2c 100755 --- a/source/install/build_tf.py +++ b/source/install/build_tf.py @@ -192,7 +192,7 @@ def path(self) -> Path: @property def gzip_path(self) -> Path: if self.gzip is None: - raise RuntimeError("gzip is None for %s" % self.path) + raise RuntimeError(f"gzip is None for {self.path}") return PACKAGE_DIR / self.gzip @property @@ -257,10 +257,9 @@ def __call__(self): dd() else: dlog.info( - "Skip installing %s, which has been already installed" - % dd.__class__.__name__ + f"Skip installing {dd.__class__.__name__}, which has been already installed" ) - dlog.info("Start installing %s..." % self.__class__.__name__) + dlog.info(f"Start installing {self.__class__.__name__}...") with tempfile.TemporaryDirectory() as tmpdirname: self._prefix = Path(tmpdirname) self.build() @@ -621,7 +620,7 @@ def dependencies(self) -> Dict[str, Build]: def build(self): tf_res = self.resources["tensorflow"] - src = tf_res.gzip_path / ("tensorflow-%s" % self.version) + src = tf_res.gzip_path / (f"tensorflow-{self.version}") with set_directory(src): # configure -- need bazelisk in PATH call( diff --git a/source/lib/include/errors.h b/source/lib/include/errors.h index 6687d2afa2..d0de379537 100644 --- a/source/lib/include/errors.h +++ b/source/lib/include/errors.h @@ -10,15 +10,15 @@ namespace deepmd { **/ struct deepmd_exception : public std::runtime_error { public: - deepmd_exception() : runtime_error("DeePMD-kit Error!"){}; + deepmd_exception() : runtime_error("DeePMD-kit Error!") {}; deepmd_exception(const std::string& msg) - : runtime_error(std::string("DeePMD-kit Error: ") + msg){}; + : runtime_error(std::string("DeePMD-kit Error: ") + msg) {}; }; struct deepmd_exception_oom : public deepmd_exception { public: - deepmd_exception_oom() : deepmd_exception("DeePMD-kit OOM!"){}; + deepmd_exception_oom() : deepmd_exception("DeePMD-kit OOM!") {}; deepmd_exception_oom(const std::string& msg) - : deepmd_exception(std::string("DeePMD-kit OOM: ") + msg){}; + : deepmd_exception(std::string("DeePMD-kit OOM: ") + msg) {}; }; }; // namespace deepmd diff --git a/source/lib/include/neighbor_list.h b/source/lib/include/neighbor_list.h index eb510eb25b..39c2064b56 100644 --- a/source/lib/include/neighbor_list.h +++ b/source/lib/include/neighbor_list.h @@ -26,13 +26,13 @@ struct InputNlist { int* numneigh; /// Array stores the core region atom's neighbor index int** firstneigh; - InputNlist() : inum(0), ilist(NULL), numneigh(NULL), firstneigh(NULL){}; + InputNlist() : inum(0), ilist(NULL), numneigh(NULL), firstneigh(NULL) {}; InputNlist(int inum_, int* ilist_, int* numneigh_, int** firstneigh_) : inum(inum_), ilist(ilist_), numneigh(numneigh_), - firstneigh(firstneigh_){}; - ~InputNlist(){}; + firstneigh(firstneigh_) {}; + ~InputNlist() {}; }; /** diff --git a/source/lmp/pppm_dplr.h b/source/lmp/pppm_dplr.h index e87fc6a241..1484a16e72 100644 --- a/source/lmp/pppm_dplr.h +++ b/source/lmp/pppm_dplr.h @@ -25,7 +25,7 @@ class PPPMDPLR : public PPPM { #else PPPMDPLR(class LAMMPS *); #endif - ~PPPMDPLR() override{}; + ~PPPMDPLR() override {}; void init() override; const std::vector &get_fele() const { return fele; }; diff --git a/source/md/include/Integrator.h b/source/md/include/Integrator.h index 73e84e7097..945109fb20 100644 --- a/source/md/include/Integrator.h +++ b/source/md/include/Integrator.h @@ -9,7 +9,7 @@ template class Integrator { public: - Integrator() : massConst(UnitManager::IntegratorMassConstant){}; + Integrator() : massConst(UnitManager::IntegratorMassConstant) {}; public: void stepVeloc(std::vector& vv, diff --git a/source/md/include/Tabulated.h b/source/md/include/Tabulated.h index 5ab6e02bc3..4c618db213 100644 --- a/source/md/include/Tabulated.h +++ b/source/md/include/Tabulated.h @@ -13,7 +13,7 @@ typedef float VALUETYPE; class Tabulated { public: - Tabulated(){}; + Tabulated() {}; Tabulated(const VALUETYPE rc, const VALUETYPE hh, const std::vector& tab); diff --git a/source/md/include/Trajectory.h b/source/md/include/Trajectory.h index 862b393ea4..52964f3b37 100644 --- a/source/md/include/Trajectory.h +++ b/source/md/include/Trajectory.h @@ -11,7 +11,7 @@ class XtcSaver { public: - XtcSaver() : inited(false), prec(1000){}; + XtcSaver() : inited(false), prec(1000) {}; ~XtcSaver(); XtcSaver(const char *filename, const int &natoms); bool reinit(const char *filename, const int &natoms); @@ -33,7 +33,7 @@ class XtcSaver { class TrrSaver { public: - TrrSaver() : inited(false), lambda(0){}; + TrrSaver() : inited(false), lambda(0) {}; ~TrrSaver(); TrrSaver(const char *filename, const int &natoms); bool reinit(const char *filename, const int &natoms); diff --git a/source/md/include/UnitManager.h b/source/md/include/UnitManager.h index 70393c406e..9bd1e75b9a 100644 --- a/source/md/include/UnitManager.h +++ b/source/md/include/UnitManager.h @@ -5,7 +5,7 @@ class UnitManager { protected: - UnitManager(){}; + UnitManager() {}; public: static double Degree2Radian; diff --git a/source/op/add_flt_nvnmd.cc b/source/op/add_flt_nvnmd.cc index 079e05d785..db3554665a 100644 --- a/source/op/add_flt_nvnmd.cc +++ b/source/op/add_flt_nvnmd.cc @@ -52,7 +52,7 @@ template class AddFltNvnmdOp : public OpKernel { public: /// Constructor. - explicit AddFltNvnmdOp(OpKernelConstruction* context) : OpKernel(context){}; + explicit AddFltNvnmdOp(OpKernelConstruction* context) : OpKernel(context) {}; /// Compute the descriptor /// param: context diff --git a/source/op/copy_flt_nvnmd.cc b/source/op/copy_flt_nvnmd.cc index d9a1984115..3ca9b17c31 100644 --- a/source/op/copy_flt_nvnmd.cc +++ b/source/op/copy_flt_nvnmd.cc @@ -50,7 +50,7 @@ template class CopyFltNvnmdOp : public OpKernel { public: /// Constructor. - explicit CopyFltNvnmdOp(OpKernelConstruction* context) : OpKernel(context){}; + explicit CopyFltNvnmdOp(OpKernelConstruction* context) : OpKernel(context) {}; /// Compute the descriptor /// param: context diff --git a/source/op/dotmul_flt_nvnmd.cc b/source/op/dotmul_flt_nvnmd.cc index d7c2c8d3c3..1aca3e8bf8 100644 --- a/source/op/dotmul_flt_nvnmd.cc +++ b/source/op/dotmul_flt_nvnmd.cc @@ -61,7 +61,7 @@ class DotmulFltNvnmdOp : public OpKernel { public: /// Constructor. explicit DotmulFltNvnmdOp(OpKernelConstruction *context) - : OpKernel(context){}; + : OpKernel(context) {}; /// Compute the descriptor /// param: context diff --git a/source/op/flt_nvnmd.cc b/source/op/flt_nvnmd.cc index 634c76b662..4794caeedc 100644 --- a/source/op/flt_nvnmd.cc +++ b/source/op/flt_nvnmd.cc @@ -48,7 +48,7 @@ template class FltNvnmdOp : public OpKernel { public: /// Constructor. - explicit FltNvnmdOp(OpKernelConstruction* context) : OpKernel(context){}; + explicit FltNvnmdOp(OpKernelConstruction* context) : OpKernel(context) {}; /// Compute the descriptor /// param: context diff --git a/source/op/mul_flt_nvnmd.cc b/source/op/mul_flt_nvnmd.cc index d18cf20508..bbbeec073d 100644 --- a/source/op/mul_flt_nvnmd.cc +++ b/source/op/mul_flt_nvnmd.cc @@ -52,7 +52,7 @@ template class MulFltNvnmdOp : public OpKernel { public: /// Constructor. - explicit MulFltNvnmdOp(OpKernelConstruction* context) : OpKernel(context){}; + explicit MulFltNvnmdOp(OpKernelConstruction* context) : OpKernel(context) {}; /// Compute the descriptor /// param: context diff --git a/source/tests/common.py b/source/tests/common.py index 5a7477d7e7..d9b300f640 100644 --- a/source/tests/common.py +++ b/source/tests/common.py @@ -663,8 +663,7 @@ def __init__(self, sys_path, set_prefix, seed=None, shuffle_test=True): ] if any(has_fparam) and (not all(has_fparam)): raise RuntimeError( - "system %s: if any set has frame parameter, then all sets should have frame parameter" - % sys_path + f"system {sys_path}: if any set has frame parameter, then all sets should have frame parameter" ) if all(has_fparam): self.has_fparam = 0 @@ -676,8 +675,7 @@ def __init__(self, sys_path, set_prefix, seed=None, shuffle_test=True): ] if any(has_aparam) and (not all(has_aparam)): raise RuntimeError( - "system %s: if any set has frame parameter, then all sets should have frame parameter" - % sys_path + f"system {sys_path}: if any set has frame parameter, then all sets should have frame parameter" ) if all(has_aparam): self.has_aparam = 0 @@ -767,7 +765,7 @@ def load_data(self, set_name, data_name, shape, is_necessary=True): return data return 1, data elif is_necessary: - raise OSError("%s not found!" % path) + raise OSError(f"{path} not found!") else: data = np.zeros(shape) return 0, data @@ -1021,7 +1019,7 @@ def print_summary(self): sys_width = 42 tmp_msg += "---Summary of DataSystem-----------------------------------------\n" tmp_msg += "find %d system(s):\n" % self.nsystems - tmp_msg += "%s " % self.format_name_length("system", sys_width) + tmp_msg += "{} ".format(self.format_name_length("system", sys_width)) tmp_msg += "{} {} {}\n".format("natoms", "bch_sz", "n_bch") for ii in range(self.nsystems): tmp_msg += "%s %6d %6d %5d\n" % (