From 450a0c794a10cc59ba9e094cab2cf6e6cc923839 Mon Sep 17 00:00:00 2001 From: Peize Lin Date: Fri, 3 May 2019 04:11:41 +0800 Subject: [PATCH 001/233] add exx and opt_orb --- ABACUS.1.0.0/source/Makefile | 11 +- ABACUS.1.0.0/source/Makefile.Objects | 31 + ABACUS.1.0.0/source/Makefile.system | 35 +- .../source/Makefile.system.centos7-devel | 38 - ABACUS.1.0.0/source/Makefile.vars | 18 +- ABACUS.1.0.0/source/input.cpp | 1044 ++++++----- ABACUS.1.0.0/source/input.h | 32 +- ABACUS.1.0.0/source/input_conv.cpp | 117 +- ABACUS.1.0.0/source/run_frag.cpp | 62 +- .../src_external/src_pdiag/pdiag_double.cpp | 3 +- .../source/src_external/src_test/print_tmp.h | 45 + .../element_basis_index-unittest.cpp | 103 +- .../src_test/src_lcao/abfs-test.h | 19 + .../src_lcao/conv_coulomb_pot-unittest.h | 19 + .../src_lcao/exx_abfs-construct_orbs-test.h | 23 + .../src_test/src_lcao/exx_abfs-dm-test.h | 93 + .../exx_abfs-inverse_matrix_double-test.h | 466 +++++ .../src_test/src_lcao/exx_abfs-screen-test.h | 18 + .../src_test/src_lcao/exx_abfs-unittest.h | 95 + .../src_test/src_lcao/exx_lcao-test.h | 245 +++ .../src_external/src_test/test_function.h | 19 + .../source/src_global/boost_serialization.h | 97 + .../source/src_global/container_operator.h | 69 + .../source/src_global/global_function.h | 42 +- .../source/src_global/gram_schmidt_orth.h | 2 +- .../source/src_global/lapack_connector.h | 135 +- ABACUS.1.0.0/source/src_global/mathzone.cpp | 4 +- ABACUS.1.0.0/source/src_global/matrix-inl.h | 79 + ABACUS.1.0.0/source/src_global/matrix.cpp | 5 +- .../source/src_global/matrix_wrapper.h | 88 + .../src_global/matrix_wrapper_tianhe2.h | 52 + ABACUS.1.0.0/source/src_global/vector3.h | 1 + ABACUS.1.0.0/source/src_lcao/abfs-template.h | 58 + .../source/src_lcao/abfs-vector3_order.cpp | 26 + .../source/src_lcao/abfs-vector3_order.h | 72 + ABACUS.1.0.0/source/src_lcao/abfs.cpp | 518 ++++++ ABACUS.1.0.0/source/src_lcao/abfs.h | 96 + ABACUS.1.0.0/source/src_lcao/build_st_pw.cpp | 73 +- .../source/src_lcao/center2_orb-orb22.cpp | 8 +- .../source/src_lcao/center2_orb-orb22_ccp.cpp | 48 + .../source/src_lcao/center2_orb-orb22_ccp.h | 25 + .../source/src_lcao/conv_coulomb_pot-inl.h | 37 + .../source/src_lcao/conv_coulomb_pot.cpp | 123 ++ .../source/src_lcao/conv_coulomb_pot.h | 34 + .../src_lcao/conv_coulomb_pot_k-template.h | 30 + .../source/src_lcao/conv_coulomb_pot_k.cpp | 75 + .../source/src_lcao/conv_coulomb_pot_k.h | 30 + .../source/src_lcao/diago_lcao_matrix.cpp | 24 +- .../source/src_lcao/exx_abfs-abfs_index.cpp | 37 + .../source/src_lcao/exx_abfs-abfs_index.h | 23 + .../src_lcao/exx_abfs-construct_orbs.cpp | 480 +++++ .../source/src_lcao/exx_abfs-construct_orbs.h | 61 + ABACUS.1.0.0/source/src_lcao/exx_abfs-dm.cpp | 211 +++ ABACUS.1.0.0/source/src_lcao/exx_abfs-dm.h | 45 + ABACUS.1.0.0/source/src_lcao/exx_abfs-inl.h | 73 + .../exx_abfs-inverse_matrix_double.cpp | 170 ++ .../src_lcao/exx_abfs-inverse_matrix_double.h | 57 + .../source/src_lcao/exx_abfs-io-template.h | 72 + ABACUS.1.0.0/source/src_lcao/exx_abfs-io.cpp | 513 ++++++ ABACUS.1.0.0/source/src_lcao/exx_abfs-io.h | 58 + ABACUS.1.0.0/source/src_lcao/exx_abfs-jle.cpp | 56 + ABACUS.1.0.0/source/src_lcao/exx_abfs-jle.h | 25 + .../exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp | 310 ++++ .../exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h | 55 + .../src_lcao/exx_abfs-matrix_orbs11.cpp | 330 ++++ .../source/src_lcao/exx_abfs-matrix_orbs11.h | 65 + .../src_lcao/exx_abfs-matrix_orbs21.cpp | 530 ++++++ .../source/src_lcao/exx_abfs-matrix_orbs21.h | 85 + .../src_lcao/exx_abfs-matrix_orbs22.cpp | 304 ++++ .../source/src_lcao/exx_abfs-matrix_orbs22.h | 72 + ...-parallel-communicate-allreduce-template.h | 167 ++ ...xx_abfs-parallel-communicate-allreduce.cpp | 21 + .../exx_abfs-parallel-communicate-allreduce.h | 48 + ...abfs-parallel-communicate-dm-allreduce.cpp | 591 +++++++ .../exx_abfs-parallel-communicate-dm.cpp | 294 +++ .../exx_abfs-parallel-communicate-dm.h | 93 + .../exx_abfs-parallel-communicate-dm2.cpp | 122 ++ .../exx_abfs-parallel-communicate-dm2.h | 39 + ...fs-parallel-communicate-hexx-allreduce.cpp | 369 ++++ ..._abfs-parallel-communicate-hexx-template.h | 93 + .../exx_abfs-parallel-communicate-hexx.cpp | 155 ++ .../exx_abfs-parallel-communicate-hexx.h | 91 + .../exx_abfs-parallel-distribute-htime.cpp | 91 + .../exx_abfs-parallel-distribute-htime.h | 21 + .../exx_abfs-parallel-distribute-kmeans.cpp | 253 +++ .../exx_abfs-parallel-distribute-kmeans.h | 35 + .../source/src_lcao/exx_abfs-parallel.h | 27 + ABACUS.1.0.0/source/src_lcao/exx_abfs-pca.cpp | 144 ++ ABACUS.1.0.0/source/src_lcao/exx_abfs-pca.h | 32 + .../src_lcao/exx_abfs-screen-cauchy.cpp | 305 ++++ .../source/src_lcao/exx_abfs-screen-cauchy.h | 102 ++ .../src_lcao/exx_abfs-screen-schwarz.cpp | 200 +++ .../source/src_lcao/exx_abfs-screen-schwarz.h | 55 + ABACUS.1.0.0/source/src_lcao/exx_abfs.cpp | 1080 ++++++++++++ ABACUS.1.0.0/source/src_lcao/exx_abfs.h | 76 + ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 1569 +++++++++++++++++ ABACUS.1.0.0/source/src_lcao/exx_lcao.h | 118 ++ .../source/src_lcao/exx_opt_orb-print.cpp | 204 +++ ABACUS.1.0.0/source/src_lcao/exx_opt_orb.cpp | 349 ++++ ABACUS.1.0.0/source/src_lcao/exx_opt_orb.h | 37 + ABACUS.1.0.0/source/src_lcao/force_lcao.cpp | 7 +- ABACUS.1.0.0/source/src_lcao/gint_k_fvl.cpp | 54 +- ABACUS.1.0.0/source/src_lcao/global_fp.cpp | 3 + ABACUS.1.0.0/source/src_lcao/global_fp.h | 2 + .../source/src_lcao/grid_meshball.cpp | 2 - ABACUS.1.0.0/source/src_lcao/lcao_matrix.cpp | 115 +- ABACUS.1.0.0/source/src_lcao/lcao_matrix.h | 4 +- ABACUS.1.0.0/source/src_lcao/lcao_nnr.cpp | 1 + .../source/src_lcao/lcao_orbitals.cpp | 18 +- .../source/src_lcao/local_orbital_charge.cpp | 19 +- .../source/src_lcao/local_orbital_elec.cpp | 72 +- .../source/src_lcao/local_orbital_ions.cpp | 106 +- .../source/src_lcao/make_overlap_table.cpp | 22 +- .../source/src_lcao/sltk_adjacent_set.cpp | 1 - .../source/src_lcao/sltk_adjacent_set.h | 3 +- .../source/src_lcao/use_hamilt_matrix.cpp | 18 +- .../source/src_lcao/use_hamilt_matrix.h | 2 +- .../source/src_parallel/parallel_global.cpp | 15 +- .../source/src_parallel/parallel_grid.h | 2 +- .../source/src_parallel/parallel_pw.h | 6 +- ABACUS.1.0.0/source/src_pw/charge.cpp | 14 +- ABACUS.1.0.0/source/src_pw/charge.h | 2 +- ABACUS.1.0.0/source/src_pw/charge_broyden.h | 2 - ABACUS.1.0.0/source/src_pw/charge_pulay.cpp | 27 +- ABACUS.1.0.0/source/src_pw/charge_pulay.h | 16 +- ABACUS.1.0.0/source/src_pw/chi0_hilbert.cpp | 2 +- ABACUS.1.0.0/source/src_pw/electrons.cpp | 89 +- ABACUS.1.0.0/source/src_pw/energy.cpp | 104 +- ABACUS.1.0.0/source/src_pw/energy.h | 2 + ABACUS.1.0.0/source/src_pw/exx_global.h | 41 + ABACUS.1.0.0/source/src_pw/exx_lip.cpp | 931 ++++++++++ ABACUS.1.0.0/source/src_pw/exx_lip.h | 93 + ABACUS.1.0.0/source/src_pw/functional.cpp | 28 + ABACUS.1.0.0/source/src_pw/functional.h | 46 +- ABACUS.1.0.0/source/src_pw/gga_pw.cpp | 6 +- ABACUS.1.0.0/source/src_pw/global.cpp | 2 + ABACUS.1.0.0/source/src_pw/global.h | 12 +- ABACUS.1.0.0/source/src_pw/hamilt.cpp | 36 +- ABACUS.1.0.0/source/src_pw/hamilt_pw.cpp | 90 +- ABACUS.1.0.0/source/src_pw/ions.cpp | 29 +- ABACUS.1.0.0/source/src_pw/mdNVE.cpp | 15 - ABACUS.1.0.0/source/src_pw/potential.cpp | 101 +- .../source/src_pw/potential_libxc.cpp | 276 +++ ABACUS.1.0.0/source/src_pw/potential_libxc.h | 28 + ABACUS.1.0.0/source/src_pw/unitcell.cpp | 2 + ABACUS.1.0.0/source/src_pw/unitcell.h | 1 + .../source/src_pw/unitcell_pseudo.cpp | 31 +- ABACUS.1.0.0/source/src_pw/unitcell_pseudo.h | 2 +- ABACUS.1.0.0/source/src_pw/wavefunc.cpp | 3 +- ABACUS.1.0.0/source/src_pw/wavefunc.h | 12 +- ABACUS.1.0.0/source/src_pw/wavefunc_in_pw.cpp | 553 +++--- ABACUS.1.0.0/tools/opt_abfs_bash/__init__.py | 0 ABACUS.1.0.0/tools/opt_abfs_bash/exx.py | 62 + ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py | 99 ++ ABACUS.1.0.0/tools/opt_abfs_bash/read_stru.py | 205 +++ ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py | 164 ++ ABACUS.1.0.0/tools/opt_abfs_bash/utils.py | 41 + ABACUS.1.0.0/tools/opt_lcao_bash/dis.py | 104 ++ ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py | 29 + .../tools/opt_lcao_bash/print_file.py | 156 ++ ABACUS.1.0.0/tools/opt_lcao_bash/read_info.py | 34 + ABACUS.1.0.0/tools/opt_lcao_bash/utils.py | 2 + .../tools/opt_orb_pytorch/IO/__init__.py | 0 .../tools/opt_orb_pytorch/IO/func_C.py | 85 + .../tools/opt_orb_pytorch/IO/print_QSV.py | 29 + .../tools/opt_orb_pytorch/IO/print_orbital.py | 43 + .../tools/opt_orb_pytorch/IO/read_QSV.py | 157 ++ .../tools/opt_orb_pytorch/IO/read_json.py | 62 + .../tools/opt_orb_pytorch/__init__.py | 0 ABACUS.1.0.0/tools/opt_orb_pytorch/inverse.py | 55 + ABACUS.1.0.0/tools/opt_orb_pytorch/main.py | 130 ++ .../tools/opt_orb_pytorch/opt_orbital.py | 137 ++ .../tools/opt_orb_pytorch/opt_orbital.py_real | 86 + ABACUS.1.0.0/tools/opt_orb_pytorch/orbital.py | 80 + ABACUS.1.0.0/tools/opt_orb_pytorch/pf.py | 2 + .../tools/opt_orb_pytorch/torch_complex.py | 83 + .../tools/opt_orb_pytorch/unittest_inverse.py | 29 + ABACUS.1.0.0/tools/opt_orb_pytorch/util.py | 38 + 178 files changed, 18394 insertions(+), 1386 deletions(-) delete mode 100644 ABACUS.1.0.0/source/Makefile.system.centos7-devel create mode 100644 ABACUS.1.0.0/source/src_external/src_test/print_tmp.h create mode 100644 ABACUS.1.0.0/source/src_external/src_test/src_lcao/abfs-test.h create mode 100644 ABACUS.1.0.0/source/src_external/src_test/src_lcao/conv_coulomb_pot-unittest.h create mode 100644 ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_abfs-construct_orbs-test.h create mode 100644 ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_abfs-dm-test.h create mode 100644 ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_abfs-inverse_matrix_double-test.h create mode 100644 ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_abfs-screen-test.h create mode 100644 ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_abfs-unittest.h create mode 100644 ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_lcao-test.h create mode 100644 ABACUS.1.0.0/source/src_global/boost_serialization.h create mode 100644 ABACUS.1.0.0/source/src_global/container_operator.h create mode 100644 ABACUS.1.0.0/source/src_global/matrix-inl.h create mode 100644 ABACUS.1.0.0/source/src_global/matrix_wrapper.h create mode 100644 ABACUS.1.0.0/source/src_global/matrix_wrapper_tianhe2.h create mode 100644 ABACUS.1.0.0/source/src_lcao/abfs-template.h create mode 100644 ABACUS.1.0.0/source/src_lcao/abfs-vector3_order.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/abfs-vector3_order.h create mode 100644 ABACUS.1.0.0/source/src_lcao/abfs.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/abfs.h create mode 100644 ABACUS.1.0.0/source/src_lcao/center2_orb-orb22_ccp.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/center2_orb-orb22_ccp.h create mode 100644 ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot-inl.h create mode 100644 ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot.h create mode 100644 ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k-template.h create mode 100644 ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-abfs_index.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-abfs_index.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-construct_orbs.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-construct_orbs.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-dm.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-dm.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-inl.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-inverse_matrix_double.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-inverse_matrix_double.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-io-template.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-io.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-io.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-jle.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-jle.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs11.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs11.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs21.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs21.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs22.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs22.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-allreduce-template.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-allreduce.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-allreduce.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm-allreduce.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm2.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm2.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-template.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-htime.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-htime.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-kmeans.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-kmeans.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-pca.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-pca.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-cauchy.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-cauchy.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_lcao.h create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_opt_orb-print.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_opt_orb.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_opt_orb.h create mode 100644 ABACUS.1.0.0/source/src_pw/exx_global.h create mode 100644 ABACUS.1.0.0/source/src_pw/exx_lip.cpp create mode 100644 ABACUS.1.0.0/source/src_pw/exx_lip.h create mode 100644 ABACUS.1.0.0/source/src_pw/potential_libxc.cpp create mode 100644 ABACUS.1.0.0/source/src_pw/potential_libxc.h create mode 100644 ABACUS.1.0.0/tools/opt_abfs_bash/__init__.py create mode 100644 ABACUS.1.0.0/tools/opt_abfs_bash/exx.py create mode 100644 ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py create mode 100644 ABACUS.1.0.0/tools/opt_abfs_bash/read_stru.py create mode 100644 ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py create mode 100644 ABACUS.1.0.0/tools/opt_abfs_bash/utils.py create mode 100644 ABACUS.1.0.0/tools/opt_lcao_bash/dis.py create mode 100644 ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py create mode 100644 ABACUS.1.0.0/tools/opt_lcao_bash/print_file.py create mode 100644 ABACUS.1.0.0/tools/opt_lcao_bash/read_info.py create mode 100644 ABACUS.1.0.0/tools/opt_lcao_bash/utils.py create mode 100644 ABACUS.1.0.0/tools/opt_orb_pytorch/IO/__init__.py create mode 100644 ABACUS.1.0.0/tools/opt_orb_pytorch/IO/func_C.py create mode 100644 ABACUS.1.0.0/tools/opt_orb_pytorch/IO/print_QSV.py create mode 100644 ABACUS.1.0.0/tools/opt_orb_pytorch/IO/print_orbital.py create mode 100644 ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_QSV.py create mode 100644 ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_json.py create mode 100644 ABACUS.1.0.0/tools/opt_orb_pytorch/__init__.py create mode 100644 ABACUS.1.0.0/tools/opt_orb_pytorch/inverse.py create mode 100644 ABACUS.1.0.0/tools/opt_orb_pytorch/main.py create mode 100644 ABACUS.1.0.0/tools/opt_orb_pytorch/opt_orbital.py create mode 100644 ABACUS.1.0.0/tools/opt_orb_pytorch/opt_orbital.py_real create mode 100644 ABACUS.1.0.0/tools/opt_orb_pytorch/orbital.py create mode 100644 ABACUS.1.0.0/tools/opt_orb_pytorch/pf.py create mode 100644 ABACUS.1.0.0/tools/opt_orb_pytorch/torch_complex.py create mode 100644 ABACUS.1.0.0/tools/opt_orb_pytorch/unittest_inverse.py create mode 100644 ABACUS.1.0.0/tools/opt_orb_pytorch/util.py diff --git a/ABACUS.1.0.0/source/Makefile b/ABACUS.1.0.0/source/Makefile index ac9d468607..3156416eb8 100644 --- a/ABACUS.1.0.0/source/Makefile +++ b/ABACUS.1.0.0/source/Makefile @@ -20,7 +20,7 @@ HONG_SER_SELINV = -D__FP ${HONG_FFTW} -D__SELINV HONG_GDB = -g -D__FP ${HONG_FFTW} #(2)mpi HONG_MPI = -D__FP ${HONG_FFTW} -D__MPI -HONG_MPI_SELINV = -D__FP ${HONG_FFTW} -D__MPI -D__SELINV -DMETIS +HONG_MPI_SELINV = -D__FP ${HONG_FFTW} -D__MPI -D__SELINV -DMETIS -DMKL_ILP64 -DEXX_DM=2 -DTEST_LIBXC=0 -DTEST_EXX_LCAO=0 -DTEST_EXX_RADIAL=1 #(3)memory HONG_MEM = ${HONG_FFTW} -D__FP -D_MCD_CHECK -DWIN32 -DMCD_VERBOSE @@ -33,12 +33,9 @@ HONG=${HONG_MPI_SELINV} #========================== # OPTIMIZE OPTIONS #========================== -#OPTS = -I/global/u2/m/mohan/software/boost_1_39_0/ -I../src_siao/ -#OPTS = -I/home/xiaohui/lib/boost_1_39_0/ -O3 -#OPTS = -I/home/mohan/software/boost_1_39_0/ -O3 #(1)gdb #xiaohui modify 2013-12-27 -OPTS_GDB = -g -W -I/home/mohan/software/boost_1_39_0/ +OPTS_GDB = -g -W -I${BOOST_INCLUDE_DIR} #(2)gprof #POTS = -pg @@ -63,8 +60,8 @@ PDIAG_OBJS=$(OBJS_PDIAG)\ #========================== # MAKING OPTIONS #========================== -fp_mpi : ${FP_OBJS} ${PDIAG_MR} ${PDIAG_OBJS}$ ${HEADERS} - ${CPLUSPLUS_MPI} ${OPTS} ${OPTS_MPI} $(FP_OBJS) ${PDIAG_OBJS} ${PDIAG_MR} ${LIBS} -o ../bin/${VERSION}.mpi.1.0.0_new +fp_mpi : ${FP_OBJS} ${PDIAG_MR} ${PDIAG_OBJS} ${HEADERS} + ${CPLUSPLUS_MPI} ${OPTS} ${OPTS_MPI} $(FP_OBJS) ${PDIAG_OBJS} ${PDIAG_MR} ${LIBS} -o ../bin/${VERSION}.mpi.1.0.0_exx fp : ${FP_OBJS} ${HEADERS} ${CPLUSPLUS} ${OPTS} $(FP_OBJS) ${LIBS} -o ${VERSION}.fp.x diff --git a/ABACUS.1.0.0/source/Makefile.Objects b/ABACUS.1.0.0/source/Makefile.Objects index 6171cc6d7b..6eccc1a796 100644 --- a/ABACUS.1.0.0/source/Makefile.Objects +++ b/ABACUS.1.0.0/source/Makefile.Objects @@ -59,6 +59,7 @@ epsilon0_vasp.o\ md.o\ mdNVE.o\ mdNVT.o\ +exx_lip.o\ soc.o\ toWannier90.o \ unkOverlap_pw.o \ @@ -167,9 +168,38 @@ pdiag_common.o \ hs_matrix.o \ subgrid_oper.o \ GenELPA.o \ +conv_coulomb_pot.o \ +conv_coulomb_pot_k.o \ center2_orb-orb11.o \ center2_orb-orb21.o \ center2_orb-orb22.o \ +abfs.o \ +abfs-vector3_order.o \ +exx_abfs.o \ +exx_abfs-abfs_index.o \ +exx_abfs-dm.o \ +exx_abfs-inverse_matrix_double.o \ +exx_abfs-jle.o \ +exx_abfs-io.o \ +exx_abfs-construct_orbs.o \ +exx_abfs-matrix_orbs11.o \ +exx_abfs-matrix_orbs21.o \ +exx_abfs-matrix_orbs22.o \ +exx_abfs-matrix_lcaoslcaos_lcaoslcaos.o \ +exx_abfs-pca.o \ +exx_abfs-parallel-communicate-allreduce.o \ +exx_abfs-parallel-communicate-dm.o \ +exx_abfs-parallel-communicate-dm-allreduce.o \ +exx_abfs-parallel-communicate-dm2.o \ +exx_abfs-parallel-communicate-hexx.o \ +exx_abfs-parallel-communicate-hexx-allreduce.o \ +exx_abfs-parallel-distribute-htime.o \ +exx_abfs-parallel-distribute-kmeans.o \ +exx_abfs-screen-schwarz.o \ +exx_abfs-screen-cauchy.o \ +exx_lcao.o \ +exx_opt_orb.o \ +exx_opt_orb-print.o \ wfc_dm_2d.o \ unkOverlap_lcao.o \ @@ -213,6 +243,7 @@ charge_broyden.o \ charge_extra.o \ gga_pw.o \ potential.o \ +potential_libxc.o \ efield.o \ magnetism.o\ optical.o\ diff --git a/ABACUS.1.0.0/source/Makefile.system b/ABACUS.1.0.0/source/Makefile.system index e6001385f2..3080dca364 100644 --- a/ABACUS.1.0.0/source/Makefile.system +++ b/ABACUS.1.0.0/source/Makefile.system @@ -3,28 +3,35 @@ include Makefile.vars #========================== # LIB and INCLUDE #========================== + +BOOST_INCLUDE_DIR = ${BOOST_DIR}/include +BOOST_LIB_DIR = ${BOOST_DIR}/lib + +LAPACK_INCLUDE_DIR = ${LAPACK_DIR}/include +LAPACK_LIB_DIR = ${LAPACK_DIR}/lib/intel64 + HONG_FFTW = -D__FFTW3 FFTW_INCLUDE_DIR = ${FFTW_DIR}/include -FFTW_LIB_DIR = ${FFTW_DIR}/lib +FFTW_LIB_DIR = ${FFTW_DIR}/lib # or #FFTW_INCLUDE_DIR = $(MKLROOT)/include/fftw -#FFTW_LIB_DIR = $(MKLROOT)/lib/intel64 +#FFTW_LIB_DIR = $(MKLROOT)/lib/intel64 -BOOST_INCLUDE_DIR = ${BOOST_DIR}/include - -LAPACK_INCLUDE_DIR = ${LAPACK_DIR}/include -LAPACK_LIB_DIR = ${LAPACK_DIR}/lib/intel64 +ELPA_LIB_DIR = ${ELPA_DIR}/lib -ELPA_LIB_DIR = ${ELPA_DIR}/lib +LIBXC_INCLUDE_DIR = ${LIBXC_DIR}/include +LIBXC_LIB_DIR = ${LIBXC_DIR}/lib #========================== # LIBS and INCLUDES #========================== LIBS = \ -lifcore -lm \ --L${FFTW_LIB_DIR} -lfftw3 -Wl,-rpath=${FFTW_LIB_DIR} \ +-L${BOOST_LIB_DIR} -lboost_serialization -lboost_mpi -Wl,-rpath=${BOOST_LIB_DIR} \ -L${LAPACK_LIB_DIR} -Wl,--start-group -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lmkl_scalapack_lp64 -lmkl_blacs_intelmpi_lp64 -Wl,--end-group -Wl,-rpath=${LAPACK_LIB_DIR} \ --L${ELPA_LIB_DIR} -lelpa -Wl,-rpath=${ELPA_LIB_DIR} +-L${FFTW_LIB_DIR} -lfftw3 -Wl,-rpath=${FFTW_LIB_DIR} \ +-L${ELPA_LIB_DIR} -lelpa -Wl,-rpath=${ELPA_LIB_DIR} \ +-L${LIBXC_LIB_DIR} -lxc -Wl,-rpath=${LIBXC_LIB_DIR} #LIBS = \ #-liomp5 -lpthread -lm -ldl \ @@ -32,10 +39,16 @@ LIBS = \ #-L${LAPACK_LIB_DIR} -Wl,--start-group -lmkl_scalapack_lp64 -lmkl_cdft_core -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lmkl_blacs_intelmpi_lp64 -Wl,--end-group -Wl,-rpath=${LAPACK_LIB_DIR} \ #-L${ELPA_LIB_DIR} -lelpa -Wl,-rpath=${ELPA_LIB_DIR} -INCLUDE = -I. -Icommands -I${BOOST_INCLUDE_DIR} -I${FFTW_INCLUDE_DIR} -I${LAPACK_INCLUDE_DIR} +INCLUDE = -I. -Icommands -I${BOOST_INCLUDE_DIR} -I${LAPACK_INCLUDE_DIR} -I${FFTW_INCLUDE_DIR} -I${LIBXC_INCLUDE_DIR} +#NOTE by mohan +#--------------------------------------------------------- +# be careful about -lmkl_intel_lp64 and -lmkl_solver_lp64 +# don't use -lmkl_intel_ilp64 and -lmkl_solver_ilp64 +# it may leads to the segmenfault of BLAS and LAPACK. +#--------------------------------------------------------- #========================== # OPTIMIZE OPTIONS #========================== -OPTS = ${INCLUDE} -Ofast -xHost -std=c++11 -simd -lpthread -march=native -m64 -qopenmp -Werror -Wall -pedantic +OPTS = ${INCLUDE} -Ofast -xHost -std=c++17 -simd -lpthread -march=native -m64 -qopenmp -Werror -Wall -pedantic OPTS_MPI = -cxx=${CPLUSPLUS} diff --git a/ABACUS.1.0.0/source/Makefile.system.centos7-devel b/ABACUS.1.0.0/source/Makefile.system.centos7-devel deleted file mode 100644 index 41807349e1..0000000000 --- a/ABACUS.1.0.0/source/Makefile.system.centos7-devel +++ /dev/null @@ -1,38 +0,0 @@ -#--------------------------------------------- -# FFTW directories -#--------------------------------------------- -FFTW_INCLUDE=/usr/include -FFTW_LIB_DIR=/usr/lib64 -#--------------------------------------------- -# BOOST directories -#--------------------------------------------- -BOOST_INCLUDE=/usr/include/boost -BOOST_LIB_DIR=/usr/lib64 -#--------------------------------------------- -# LAPACK/BLAS directories -#--------------------------------------------- -#--------------------------------------------- -# LAPACK/BLAS directories -#--------------------------------------------- -BLAS_LAPACK_LIB="${MKLROOT}/lib/intel64/libmkl_scalapack_lp64.a -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_lp64.a ${MKLROOT}/lib/intel64/libmkl_core.a ${MKLROOT}/lib/intel64/libmkl_sequential.a ${MKLROOT}/lib/intel64/libmkl_blacs_intelmpi_lp64.a -Wl,--end-group -lpthread -lm" -# ELPA root directory, may be changed if necessary -ELPA=/opt/elpa -ELPA_LIB=${ELPA}/lib -#ELPA_INCLUDE=${ELPA}/include/elpa-2016.05.004 - -#--------------------------------------------- -# All libraries -#--------------------------------------------- -LIBS = -L${FFTW_LIB_DIR} -L${ELPA_LIB} -L${BOOST_LIB_DIR} -lfftw -lelpa -lifcore -qopenmp "${BLAS_LAPACK_LIB}" - -#--------------------------------------------- -# Compiler flags for all compilers -#--------------------------------------------- -#OPTS = -I. -Icommands -I${BOOST_INCLUDE} -I${FFTW_INCLUDE} -Ofast -xHost -diag-disable=858 -std=c++11 -OPTS = -I. -Icommands -I${BOOST_INCLUDE} -I${FFTW_INCLUDE} -ipo -Ofast -xHost -diag-disable=858 -std=c++11 - -#--------------------------------------------- -# C++ compiler and options -#--------------------------------------------- -CPLUSPLUS = mpiicc -CPLUSPLUS_MPI = mpiicc diff --git a/ABACUS.1.0.0/source/Makefile.vars b/ABACUS.1.0.0/source/Makefile.vars index afa7e10e96..c59e29dc28 100644 --- a/ABACUS.1.0.0/source/Makefile.vars +++ b/ABACUS.1.0.0/source/Makefile.vars @@ -1,15 +1,7 @@ CPLUSPLUS = icpc - CPLUSPLUS_MPI = mpiicpc - -#LAPACK_LIB_DIR = /public/intel2017/compilers_and_libraries_2017.1.132/linux/mkl/lib/intel64 -LAPACK_LIB_DIR = $(MKLROOT)/lib/intel64 - -#FFTW_DIR = /public/udata/xiaohui/software/fftw2 -FFTW_DIR =/opt/fftw/3.3.6-p12/intel/2017.update4 - -#BOOST_DIR = /public/udata/xiaohui/software/boost_1_39_0 -BOOST_DIR = /opt/boost/1.64.0 - -#ELPA_LIB_DIR = /public/udata/xiaohui/ELPA-2016.05.004/lib -ELPA_LIB_DIR = /opt/elpa/intel_2017_update4/lib +BOOST_DIR = /home/linpz/software/boost_1_66_0 +LAPACK_DIR = /opt/intel/mkl +FFTW_DIR = /home/linpz/software/fftw-2.1.5 +ELPA_DIR = /home/linpz/software/elpa-2016.05.004 +LIBXC_DIR = /home/linpz/software/libxc-4.0.4 diff --git a/ABACUS.1.0.0/source/input.cpp b/ABACUS.1.0.0/source/input.cpp index 31bc140037..d9114ca36f 100644 --- a/ABACUS.1.0.0/source/input.cpp +++ b/ABACUS.1.0.0/source/input.cpp @@ -285,14 +285,14 @@ void Input::Default(void) out_potential = 0; out_wf = false; out_dos = 0; - out_band = 0; + out_band = 0; out_hs = 0; out_lowf = false; out_alllog = false; dos_emin_ev = -15;//(ev) dos_emax_ev = 15;//(ev) dos_edelta_ev = 0.01;//(ev) - b_coef = 0.07; + b_coef = 0.07; //---------------------------------------------------------- // LCAO //---------------------------------------------------------- @@ -329,25 +329,25 @@ void Input::Default(void) md_delt=1.0; */ //md and related parameters(added by zheng da ye) - md_mdtype=1; - md_tauthermo=0; - md_taubaro=0; - md_dt=-1; - md_nresn=3; - md_nyosh=3; - md_qmass=1; - md_tfirst=0; //kelvin - md_tlast=md_tfirst; - md_dumpmdfred=1; - md_mdoutpath="mdoutput"; + md_mdtype=1; + md_tauthermo=0; + md_taubaro=0; + md_dt=-1; + md_nresn=3; + md_nyosh=3; + md_qmass=1; + md_tfirst=0; //kelvin + md_tlast=md_tfirst; + md_dumpmdfred=1; + md_mdoutpath="mdoutput"; md_domsd=0; - md_domsdatom=0; - md_rstmd=0; - md_outputstressperiod=1; - md_fixtemperature=1; - md_ediff=1e-4; + md_domsdatom=0; + md_rstmd=0; + md_outputstressperiod=1; + md_fixtemperature=1; + md_ediff=1e-4; md_ediffg=1e-3; - md_msdstartTime=1; + md_msdstartTime=1; //end of zhengdaye's add. //---------------------------------------------------------- @@ -368,46 +368,76 @@ void Input::Default(void) //----------------------------------------------------------- // spectrum // pengfei Li add 2016-11-23 //----------------------------------------------------------- - //epsilon=false; - //epsilon_choice=0; - spectral_type="None"; - spectral_method=0; - kernel_type="rpa"; - eels_method=0; - absorption_method=0; - system="bulk"; - eta=0.05; - domega=0.01; - nomega=300; - ecut_chi=1; - //oband=1; - q_start[0]=0.1; q_start[1]=0.1; q_start[2]=0.1; - q_direct[0]=1; q_direct[1]=0; q_direct[2]=0; - //start_q=1; - //interval_q=1; - nq=1; - out_epsilon=true; - out_chi=false; - out_chi0=false; - fermi_level=0.0; - coulomb_cutoff=false; - - kmesh_interpolation=false; - for(int i=0; i<100; i++) - { - qcar[i][0] = 0.0; qcar[i][1] = 0.0; qcar[i][2] = 0.0; - } - - lcao_box[0] = 10; lcao_box[1] = 10; lcao_box[2] = 10; + //epsilon=false; + //epsilon_choice=0; + spectral_type="None"; + spectral_method=0; + kernel_type="rpa"; + eels_method=0; + absorption_method=0; + system="bulk"; + eta=0.05; + domega=0.01; + nomega=300; + ecut_chi=1; + //oband=1; + q_start[0]=0.1; q_start[1]=0.1; q_start[2]=0.1; + q_direct[0]=1; q_direct[1]=0; q_direct[2]=0; + //start_q=1; + //interval_q=1; + nq=1; + out_epsilon=true; + out_chi=false; + out_chi0=false; + fermi_level=0.0; + coulomb_cutoff=false; + + kmesh_interpolation=false; + for(int i=0; i<100; i++) + { + qcar[i][0] = 0.0; qcar[i][1] = 0.0; qcar[i][2] = 0.0; + } + + lcao_box[0] = 10; lcao_box[1] = 10; lcao_box[2] = 10; + + //epsilon0 = false; + //intersmear = 0.01; + intrasmear = 0.0; + shift = 0.0; + metalcalc = false; + eps_degauss = 0.01; + + //epsilon0_choice = 0; + +//---------------------------------------------------------- +// exx //Peize Lin add 2018-06-20 +//---------------------------------------------------------- + exx_hybrid_type = "no"; + + exx_hybrid_alpha = 0.25; + exx_hse_omega = 0.11; + + exx_separate_loop = true; + exx_hybrid_step = 100; - //epsilon0 = false; - //intersmear = 0.01; - intrasmear = 0.0; - shift = 0.0; - metalcalc = false; - eps_degauss = 0.01; + exx_lambda = 0.3; - //epsilon0_choice = 0; + exx_pca_threshold = 0; + exx_c_threshold = 0; + exx_v_threshold = 0; + exx_dm_threshold = 0; + exx_schwarz_threshold = 0; + exx_cauchy_threshold = 0; + + exx_distribute_type = "htime"; + + exx_h_mixing_mode = "no"; + exx_h_mixing_beta = 0.7; + + exx_opt_orb_lmax = 0; + exx_opt_orb_ecut = 0.0; + exx_opt_orb_tolerence = 0.0; + //added by zhengdy-soc noncolin = false; lspinorb = false; @@ -759,7 +789,7 @@ bool Input::Read(const string &fn) { read_value(ifs, fixed_axes); } - else if (strcmp("move_method", word) == 0) + else if (strcmp("move_method", word) == 0) { read_value(ifs, ion_dynamics); } @@ -1147,372 +1177,452 @@ bool Input::Read(const string &fn) } */ //added begin by zheng daye - else if (strcmp("md_mdtype",word) == 0) - { - read_value(ifs, md_mdtype); - } - else if (strcmp("md_tauthermo",word) == 0) - { - read_value(ifs, md_tauthermo); - } - else if (strcmp("md_taubaro",word) == 0) - { - read_value(ifs,md_taubaro ); - } - else if (strcmp("md_dt",word) == 0) - { - read_value(ifs, md_dt); - } - else if (strcmp("md_nresn",word) == 0) - { - read_value(ifs,md_nresn ); - } - else if (strcmp("md_nyosh",word) == 0) - { - read_value(ifs, md_nyosh); - } - else if (strcmp("md_qmass",word) == 0) - { - read_value(ifs,md_qmass ); - } - else if (strcmp("md_tfirst",word) == 0) - { - read_value(ifs, md_tfirst); - } - else if (strcmp("md_tlast",word) == 0) - { - read_value(ifs,md_tlast ); - if(md_tfirst!=md_tlast) + else if (strcmp("md_mdtype",word) == 0) + { + read_value(ifs, md_mdtype); + } + else if (strcmp("md_tauthermo",word) == 0) + { + read_value(ifs, md_tauthermo); + } + else if (strcmp("md_taubaro",word) == 0) + { + read_value(ifs,md_taubaro ); + } + else if (strcmp("md_dt",word) == 0) + { + read_value(ifs, md_dt); + } + else if (strcmp("md_nresn",word) == 0) + { + read_value(ifs,md_nresn ); + } + else if (strcmp("md_nyosh",word) == 0) + { + read_value(ifs, md_nyosh); + } + else if (strcmp("md_qmass",word) == 0) { - ifstream file1; - file1.open("ChangeTemp.dat"); - if(!file1) // Peize Lin fix bug 2016-08-06 + read_value(ifs,md_qmass ); + } + else if (strcmp("md_tfirst",word) == 0) + { + read_value(ifs, md_tfirst); + } + else if (strcmp("md_tlast",word) == 0) + { + read_value(ifs,md_tlast ); + if(md_tfirst!=md_tlast) { - ofstream file; - file.open("ChangeTemp.dat"); - for(int ii=0;ii<30;ii++) + ifstream file1; + file1.open("ChangeTemp.dat"); + if(!file1) // Peize Lin fix bug 2016-08-06 { - file<> vdwD2_period.x >> vdwD2_period.y; - read_value(ifs, vdwD2_period.z); - } - else if (strcmp("vdwd2_radius", word) == 0) - { - read_value(ifs, vdwD2_radius); - } - else if (strcmp("vdwd2_radius_unit", word) == 0) - { - read_value(ifs, vdwD2_radius_unit); - } + read_value(ifs, vdwD2_period.z); + } + else if (strcmp("vdwd2_radius", word) == 0) + { + read_value(ifs, vdwD2_radius); + } + else if (strcmp("vdwd2_radius_unit", word) == 0) + { + read_value(ifs, vdwD2_radius_unit); + } //-------------------------------------------------------- // epsilon pengfei Li 2016-11-23 //-------------------------------------------------------- - //else if (strcmp("epsilon", word) == 0) - //{ - // read_value(ifs, epsilon); - //} - //else if (strcmp("epsilon_choice", word) == 0) - //{ - // read_value(ifs, epsilon_choice); - //} + //else if (strcmp("epsilon", word) == 0) + //{ + // read_value(ifs, epsilon); + //} + //else if (strcmp("epsilon_choice", word) == 0) + //{ + // read_value(ifs, epsilon_choice); + //} else if (strcmp("spectral_type", word) == 0) - { - read_value(ifs, spectral_type); - } + { + read_value(ifs, spectral_type); + } else if (strcmp("spectral_method", word) == 0) - { - read_value(ifs, spectral_method); - } + { + read_value(ifs, spectral_method); + } else if (strcmp("kernel_type", word) == 0) - { - read_value(ifs, kernel_type); - } + { + read_value(ifs, kernel_type); + } else if (strcmp("eels_method", word) == 0) - { - read_value(ifs, eels_method); - } + { + read_value(ifs, eels_method); + } else if (strcmp("absorption_method", word) == 0) + { + read_value(ifs, absorption_method); + } + else if (strcmp("system", word) == 0) + { + read_value(ifs, system); + } + else if (strcmp("eta", word) == 0) + { + read_value(ifs, eta); + } + else if (strcmp("domega", word) == 0) + { + read_value(ifs, domega); + } + else if (strcmp("nomega", word) == 0) + { + read_value(ifs, nomega); + } + else if (strcmp("ecut_chi", word) == 0) + { + read_value(ifs, ecut_chi); + } + //else if (strcmp("oband", word) == 0) + //{ + // read_value(ifs, oband); + //} + else if (strcmp("q_start", word) == 0) + { + ifs >> q_start[0]; ifs >> q_start[1]; read_value(ifs, q_start[2]); + } + else if (strcmp("q_direction", word) == 0) + { + ifs >> q_direct[0]; ifs >> q_direct[1]; read_value(ifs, q_direct[2]); + } + //else if (strcmp("start_q", word) == 0) + //{ + // read_value(ifs, start_q); + //} + //else if (strcmp("interval_q", word) == 0) + //{ + // read_value(ifs, interval_q); + //} + else if (strcmp("nq", word) == 0) + { + read_value(ifs, nq); + } + else if (strcmp("out_epsilon", word) == 0) + { + read_value(ifs, out_epsilon); + } + else if (strcmp("out_chi", word) == 0) + { + read_value(ifs, out_chi); + } + else if (strcmp("out_chi0", word) == 0) + { + read_value(ifs, out_chi0); + } + else if (strcmp("fermi_level", word) == 0) + { + read_value(ifs, fermi_level); + } + else if (strcmp("coulomb_cutoff", word) == 0) + { + read_value(ifs, coulomb_cutoff); + } + else if (strcmp("kmesh_interpolation", word) == 0) + { + read_value(ifs, kmesh_interpolation); + } + else if (strcmp("qcar", word) == 0) + { + for(int i=0; i> qcar[i][0]; ifs >> qcar[i][1]; read_value(ifs, qcar[i][2]); + } + } + else if (strcmp("supercell_scale", word) == 0) + { + ifs >> lcao_box[0]; ifs >> lcao_box[1]; + read_value(ifs, lcao_box[2]); + } + //else if (strcmp("epsilon0", word) == 0) + //{ + // read_value(ifs, epsilon0); + //} + //else if (strcmp("intersmear", word) == 0) + //{ + // read_value(ifs, intersmear); + //} + else if (strcmp("intrasmear", word) == 0) + { + read_value(ifs, intrasmear); + } + else if (strcmp("shift", word) == 0) + { + read_value(ifs, shift); + } + else if (strcmp("metalcalc", word) == 0) + { + read_value(ifs, metalcalc); + } + else if (strcmp("eps_degauss", word) == 0) + { + read_value(ifs, eps_degauss); + } + //else if (strcmp("epsilon0_choice", word) == 0) + //{ + // read_value(ifs, epsilon0_choice); + //} +//---------------------------------------------------------- +// exx +// Peize Lin add 2018-06-20 +//---------------------------------------------------------- + else if (strcmp("exx_hybrid_type", word) == 0) { - read_value(ifs, absorption_method); - } - else if (strcmp("system", word) == 0) - { - read_value(ifs, system); - } - else if (strcmp("eta", word) == 0) - { - read_value(ifs, eta); - } - else if (strcmp("domega", word) == 0) + read_value(ifs, exx_hybrid_type); + } + else if (strcmp("exx_hybrid_alpha", word) == 0) { - read_value(ifs, domega); - } - else if (strcmp("nomega", word) == 0) + read_value(ifs, exx_hybrid_alpha); + } + else if (strcmp("exx_hse_omega", word) == 0) { - read_value(ifs, nomega); - } - else if (strcmp("ecut_chi", word) == 0) + read_value(ifs, exx_hse_omega); + } + else if (strcmp("exx_separate_loop", word) == 0) { - read_value(ifs, ecut_chi); - } - //else if (strcmp("oband", word) == 0) - //{ - // read_value(ifs, oband); - //} - else if (strcmp("q_start", word) == 0) + read_value(ifs, exx_separate_loop); + } + else if (strcmp("exx_hybrid_step", word) == 0) { - ifs >> q_start[0]; ifs >> q_start[1]; read_value(ifs, q_start[2]); - } - else if (strcmp("q_direction", word) == 0) + read_value(ifs, exx_hybrid_step); + } + else if (strcmp("exx_lambda", word) == 0) { - ifs >> q_direct[0]; ifs >> q_direct[1]; read_value(ifs, q_direct[2]); - } - //else if (strcmp("start_q", word) == 0) - //{ - // read_value(ifs, start_q); - //} - //else if (strcmp("interval_q", word) == 0) - //{ - // read_value(ifs, interval_q); - //} - else if (strcmp("nq", word) == 0) + read_value(ifs, exx_lambda); + } + else if (strcmp("exx_pca_threshold", word) == 0) { - read_value(ifs, nq); - } - else if (strcmp("out_epsilon", word) == 0) + read_value(ifs, exx_pca_threshold); + } + else if (strcmp("exx_c_threshold", word) == 0) { - read_value(ifs, out_epsilon); - } - else if (strcmp("out_chi", word) == 0) + read_value(ifs, exx_c_threshold); + } + else if (strcmp("exx_v_threshold", word) == 0) { - read_value(ifs, out_chi); - } - else if (strcmp("out_chi0", word) == 0) + read_value(ifs, exx_v_threshold); + } + else if (strcmp("exx_dm_threshold", word) == 0) { - read_value(ifs, out_chi0); - } - else if (strcmp("fermi_level", word) == 0) + read_value(ifs, exx_dm_threshold); + } + else if (strcmp("exx_schwarz_threshold", word) == 0) { - read_value(ifs, fermi_level); - } - else if (strcmp("coulomb_cutoff", word) == 0) + read_value(ifs, exx_schwarz_threshold); + } + else if (strcmp("exx_cauchy_threshold", word) == 0) { - read_value(ifs, coulomb_cutoff); - } - else if (strcmp("kmesh_interpolation", word) == 0) + read_value(ifs, exx_cauchy_threshold); + } + else if (strcmp("exx_distribute_type", word) == 0) { - read_value(ifs, kmesh_interpolation); + read_value(ifs, exx_distribute_type); } - else if (strcmp("qcar", word) == 0) + else if (strcmp("exx_h_mixing_mode", word) == 0) { - for(int i=0; i> qcar[i][0]; ifs >> qcar[i][1]; read_value(ifs, qcar[i][2]); - } + read_value(ifs, exx_h_mixing_mode); } - else if (strcmp("supercell_scale", word) == 0) + else if (strcmp("exx_h_mixing_beta", word) == 0) { - ifs >> lcao_box[0]; ifs >> lcao_box[1]; - read_value(ifs, lcao_box[2]); - } - //else if (strcmp("epsilon0", word) == 0) - //{ - // read_value(ifs, epsilon0); - //} - //else if (strcmp("intersmear", word) == 0) - //{ - // read_value(ifs, intersmear); - //} - else if (strcmp("intrasmear", word) == 0) + read_value(ifs, exx_h_mixing_beta); + } + else if (strcmp("exx_opt_orb_lmax", word) == 0) { - read_value(ifs, intrasmear); + read_value(ifs, exx_opt_orb_lmax); } - else if (strcmp("shift", word) == 0) + else if (strcmp("exx_opt_orb_ecut", word) == 0) { - read_value(ifs, shift); + read_value(ifs, exx_opt_orb_ecut); } - else if (strcmp("metalcalc", word) == 0) - { - read_value(ifs, metalcalc); - } - else if (strcmp("eps_degauss", word) == 0) + else if (strcmp("exx_opt_orb_tolerence", word) == 0) { - read_value(ifs, eps_degauss); + read_value(ifs, exx_opt_orb_tolerence); } - else if (strcmp("noncolin", word) == 0) - { - read_value(ifs, noncolin); - } - else if (strcmp("lspinorb", word) == 0) - { - read_value(ifs, lspinorb); - } - else if (strcmp("starting_spin_angle", word) == 0) - { - read_value(ifs, starting_spin_angle); - } - else if (strcmp("angle1", word) == 0) - { - delete[] angle1; - if(ntype<1) angle1 = new double[1]; - else + else if (strcmp("noncolin", word) == 0) + { + read_value(ifs, noncolin); + } + else if (strcmp("lspinorb", word) == 0) + { + read_value(ifs, lspinorb); + } + else if (strcmp("starting_spin_angle", word) == 0) { - angle1 = new double[ntype]; - ZEROS(angle1, ntype); - for(int i = 0;i>angle1[i]; + read_value(ifs, starting_spin_angle); + } + else if (strcmp("angle1", word) == 0) + { + delete[] angle1; + if(ntype<1) angle1 = new double[1]; + else + { + angle1 = new double[ntype]; + ZEROS(angle1, ntype); + for(int i = 0;i>angle1[i]; + } + ifs.ignore(150, '\n'); } - ifs.ignore(150, '\n'); } - } - else if (strcmp("angle2", word) == 0) - { - delete[] angle2; - if(ntype<1) angle2 = new double[1]; - else + else if (strcmp("angle2", word) == 0) { - angle2 = new double[ntype]; - ZEROS(angle2, ntype); - for(int i = 0;i>angle2[i]; + delete[] angle2; + if(ntype<1) angle2 = new double[1]; + else + { + angle2 = new double[ntype]; + ZEROS(angle2, ntype); + for(int i = 0;i>angle2[i]; + } + ifs.ignore(150, '\n'); } - ifs.ignore(150, '\n'); } - } //else if (strcmp("epsilon0_choice", word) == 0) //{ // read_value(ifs, epsilon0_choice); //} -else if (strcmp("cell_factor", word) == 0) -{ - read_value(ifs, cell_factor); -} + else if (strcmp("cell_factor", word) == 0) + { + read_value(ifs, cell_factor); + } else { //xiaohui add 2015-09-15 @@ -1798,58 +1908,82 @@ void Input::Bcast() Parallel_Common::bcast_double(td_force_dt); Parallel_Common::bcast_int(vext); Parallel_Common::bcast_int(vext_dire); - // pengfei Li add 2016-11-23 - //Parallel_Common::bcast_bool( epsilon ); - //Parallel_Common::bcast_int( epsilon_choice ); - Parallel_Common::bcast_string( spectral_type ); - Parallel_Common::bcast_int( spectral_method ); - Parallel_Common::bcast_string( kernel_type ); - Parallel_Common::bcast_int( eels_method ); - Parallel_Common::bcast_int( absorption_method ); - Parallel_Common::bcast_string( system ); - Parallel_Common::bcast_double( eta ); - Parallel_Common::bcast_double( domega ); - Parallel_Common::bcast_int( nomega ); - Parallel_Common::bcast_int( ecut_chi ); - //Parallel_Common::bcast_int( oband ); - Parallel_Common::bcast_double( q_start[0]); - Parallel_Common::bcast_double( q_start[1]); - Parallel_Common::bcast_double( q_start[2]); - Parallel_Common::bcast_double( q_direct[0]); - Parallel_Common::bcast_double( q_direct[1]); - Parallel_Common::bcast_double( q_direct[2]); - //Parallel_Common::bcast_int( start_q ); - //Parallel_Common::bcast_int( interval_q ); - Parallel_Common::bcast_int( nq ); - Parallel_Common::bcast_bool( out_epsilon ); - Parallel_Common::bcast_bool( out_chi ); - Parallel_Common::bcast_bool( out_chi0 ); - Parallel_Common::bcast_double( fermi_level ); - Parallel_Common::bcast_bool( coulomb_cutoff ); - Parallel_Common::bcast_bool( kmesh_interpolation ); - for(int i=0; i<100; i++) - { - Parallel_Common::bcast_double( qcar[i][0] ); - Parallel_Common::bcast_double( qcar[i][1] ); - Parallel_Common::bcast_double( qcar[i][2] ); - } - Parallel_Common::bcast_int( lcao_box[0] ); - Parallel_Common::bcast_int( lcao_box[1] ); - Parallel_Common::bcast_int( lcao_box[2] ); - //Parallel_Common::bcast_bool( epsilon0 ); - //Parallel_Common::bcast_double( intersmear ); - Parallel_Common::bcast_double( intrasmear ); - Parallel_Common::bcast_double( shift ); - Parallel_Common::bcast_bool( metalcalc ); - Parallel_Common::bcast_double( eps_degauss ); - Parallel_Common::bcast_bool( noncolin ); - Parallel_Common::bcast_bool( lspinorb ); - Parallel_Common::bcast_bool( starting_spin_angle ); - for(int i = 0;i 1 - //force = 0; + //force = 0; /* - if(!noncolin) - force = 1; - else { + if(!noncolin) + force = 1; + else + { force = 0;//modified by zhengdy-soc, can't calculate force now! cout<<"sorry, can't calculate force with soc now, would be implement in next version!"<1) + { + WARNING_QUIT("INPUT","must 0 < exx_hybrid_alpha < 1"); + } + if(exx_hybrid_step<=0) + { + WARNING_QUIT("INPUT","must exx_hybrid_step > 0"); + } + if(exx_distribute_type!="htime" && exx_distribute_type!="kmeans") + { + WARNING_QUIT("INPUT","exx_distribute_type must be htime or kmeans"); + } + if(exx_h_mixing_mode!="no" && exx_h_mixing_mode!="plain" && exx_h_mixing_mode!="pulay") + { + WARNING_QUIT("INPUT","exx_h_mixing_mode must be no, plain or pulay"); + } + if(exx_h_mixing_beta<0 || exx_h_mixing_beta>1) + { + WARNING_QUIT("INPUT","must 0 < exx_h_mixing_beta < 1"); + } + } + if(exx_hybrid_type=="opt_orb") + { + if(exx_opt_orb_lmax<0) + { + WARNING_QUIT("INPUT","exx_opt_orb_lmax must >=0"); + } + if(exx_opt_orb_ecut<0) + { + WARNING_QUIT("INPUT","exx_opt_orb_ecut must >=0"); + } + if(exx_opt_orb_tolerence<0) + { + WARNING_QUIT("INPUT","exx_opt_orb_tolerence must >=0"); + } + } + //2015-06-15, xiaohui if(mixing_mode == "pulay" && mixing_gg0 > 0.0) { @@ -2711,6 +2889,26 @@ void Input::Print(const string &fn)const OUTP(ofs,"starting_spin_angle",starting_spin_angle,"starting_spin_angle"); //OUTP(ofs,"epsilon0_choice",epsilon0_choice,"0: vasp's method 1: pwscf's method"); + + ofs << "\n#Parameters (17.exx)" << endl; //Peize Lin add 2018-06-20 + OUTP(ofs,"exx_hybrid_type",exx_hybrid_type,"no, hf, pbe0, hse or opt_orb"); + OUTP(ofs,"exx_hybrid_alpha",exx_hybrid_alpha,""); + OUTP(ofs,"exx_hse_omega",exx_hse_omega,""); + OUTP(ofs,"exx_separate_loop",exx_separate_loop,"0 or 1"); + OUTP(ofs,"exx_hybrid_step",exx_hybrid_step,""); + OUTP(ofs,"exx_lambda",exx_lambda,""); + OUTP(ofs,"exx_pca_threshold",exx_pca_threshold,""); + OUTP(ofs,"exx_c_threshold",exx_c_threshold,""); + OUTP(ofs,"exx_v_threshold",exx_v_threshold,""); + OUTP(ofs,"exx_dm_threshold",exx_dm_threshold,""); + OUTP(ofs,"exx_schwarz_threshold",exx_schwarz_threshold,""); + OUTP(ofs,"exx_cauchy_threshold",exx_cauchy_threshold,""); + OUTP(ofs,"exx_distribute_type",exx_distribute_type,"htime or kmeans"); + OUTP(ofs,"exx_h_mixing_mode",exx_h_mixing_mode,"no, plain or pulay"); + OUTP(ofs,"exx_h_mixing_beta",exx_h_mixing_beta,""); + OUTP(ofs,"exx_opt_orb_lmax",exx_opt_orb_lmax,""); + OUTP(ofs,"exx_opt_orb_ecut",exx_opt_orb_ecut,""); + OUTP(ofs,"exx_opt_orb_tolerence",exx_opt_orb_tolerence,""); //Fuxiang add 2016-10-26 ofs << "\n#Parameters (17.tddft)" << endl; diff --git a/ABACUS.1.0.0/source/input.h b/ABACUS.1.0.0/source/input.h index 18b1c1fced..860a1d8f19 100644 --- a/ABACUS.1.0.0/source/input.h +++ b/ABACUS.1.0.0/source/input.h @@ -309,6 +309,37 @@ class Input double *angle1; double *angle2; + +//========================================================== +// exx +// Peize Lin add 2018-06-20 +//========================================================== + string exx_hybrid_type; // "no", "hf", "pbe0", "hse" + + double exx_hybrid_alpha; + double exx_hse_omega; + + bool exx_separate_loop; // 0 or 1 + int exx_hybrid_step; + + double exx_lambda; + + double exx_pca_threshold; + double exx_c_threshold; + double exx_v_threshold; + double exx_dm_threshold; + double exx_schwarz_threshold; + double exx_cauchy_threshold; + + string exx_distribute_type; + + string exx_h_mixing_mode; // "no", "plain" + double exx_h_mixing_beta; + + int exx_opt_orb_lmax; + double exx_opt_orb_ecut; + double exx_opt_orb_tolerence; + //========================================================== // tddft // Fuxiang He add 2016-10-26 @@ -323,7 +354,6 @@ class Input int vext; //add extern potential or not int vext_dire; //vext direction - //xiaohui add 2015-09-16 bool input_error; diff --git a/ABACUS.1.0.0/source/input_conv.cpp b/ABACUS.1.0.0/source/input_conv.cpp index 194ff796d4..e834d51202 100644 --- a/ABACUS.1.0.0/source/input_conv.cpp +++ b/ABACUS.1.0.0/source/input_conv.cpp @@ -15,6 +15,7 @@ #include "src_pw/epsilon0_pwscf.h" #include "src_pw/epsilon0_vasp.h" #include "src_pw/unitcell.h" +#include "src_lcao/exx_abfs-jle.h" //xiaohui modified 2013-03-23, adding "//" before #include... //#include "../../src_develop/src_siao/selinv.h" @@ -88,46 +89,46 @@ void Input_Conv::Convert(void) Ions_Move_Basic::trust_radius_ini = INPUT.trust_radius_ini; Ions_Move_Basic::out_stru = INPUT.out_stru; //mohan add 2012-03-23 STRESS = INPUT.stress; - if(INPUT.fixed_axes == "None") // pengfei Li add 2018-11-11 - { - ucell.lc[0] = 1; ucell.lc[1] = 1; ucell.lc[2] = 1; - } + if(INPUT.fixed_axes == "None") // pengfei Li add 2018-11-11 + { + ucell.lc[0] = 1; ucell.lc[1] = 1; ucell.lc[2] = 1; + } else if(INPUT.fixed_axes == "volume") { ucell.lc[0] = 1; ucell.lc[1] = 1; ucell.lc[2] = 1; } - else if(INPUT.fixed_axes == "a") - { - ucell.lc[0] = 0; ucell.lc[1] = 1; ucell.lc[2] = 1; - } - else if(INPUT.fixed_axes == "b") - { - ucell.lc[0] = 1; ucell.lc[1] = 0; ucell.lc[2] = 1; - } - else if(INPUT.fixed_axes == "c") - { - ucell.lc[0] = 1; ucell.lc[1] = 1; ucell.lc[2] = 0; - } - else if(INPUT.fixed_axes == "ab") - { - ucell.lc[0] = 0; ucell.lc[1] = 0; ucell.lc[2] = 1; - } - else if(INPUT.fixed_axes == "ac") - { - ucell.lc[0] = 0; ucell.lc[1] = 1; ucell.lc[2] = 0; - } - else if(INPUT.fixed_axes == "bc") - { - ucell.lc[0] = 1; ucell.lc[1] = 0; ucell.lc[2] = 0; - } - else if(INPUT.fixed_axes == "abc") - { - ucell.lc[0] = 0; ucell.lc[1] = 0; ucell.lc[2] = 0; - } - else - { - WARNING_QUIT("Input", "fixed_axes should be None,a,b,c,ab,ac,bc or abc!"); - } + else if(INPUT.fixed_axes == "a") + { + ucell.lc[0] = 0; ucell.lc[1] = 1; ucell.lc[2] = 1; + } + else if(INPUT.fixed_axes == "b") + { + ucell.lc[0] = 1; ucell.lc[1] = 0; ucell.lc[2] = 1; + } + else if(INPUT.fixed_axes == "c") + { + ucell.lc[0] = 1; ucell.lc[1] = 1; ucell.lc[2] = 0; + } + else if(INPUT.fixed_axes == "ab") + { + ucell.lc[0] = 0; ucell.lc[1] = 0; ucell.lc[2] = 1; + } + else if(INPUT.fixed_axes == "ac") + { + ucell.lc[0] = 0; ucell.lc[1] = 1; ucell.lc[2] = 0; + } + else if(INPUT.fixed_axes == "bc") + { + ucell.lc[0] = 1; ucell.lc[1] = 0; ucell.lc[2] = 0; + } + else if(INPUT.fixed_axes == "abc") + { + ucell.lc[0] = 0; ucell.lc[1] = 0; ucell.lc[2] = 0; + } + else + { + WARNING_QUIT("Input", "fixed_axes should be None,a,b,c,ab,ac,bc or abc!"); + } MOVE_IONS = INPUT.ion_dynamics; OUT_LEVEL = INPUT.out_level; Ions_Move_CG::CG_THRESHOLD = INPUT.cg_threshold; // pengfei add 2013-09-09 @@ -389,6 +390,50 @@ void Input_Conv::Convert(void) MD::md_delt=INPUT.md_delt; */ +//---------------------------------------------------------- +// about exx //Peize Lin add 2018-06-20 +//---------------------------------------------------------- + if(INPUT.exx_hybrid_type=="no") + { + exx_global.info.hybrid_type = Exx_Global::Hybrid_Type::No; + } + else + { + if(INPUT.exx_hybrid_type=="hf") + exx_global.info.hybrid_type = Exx_Global::Hybrid_Type::HF; + else if(INPUT.exx_hybrid_type=="pbe0") + exx_global.info.hybrid_type = Exx_Global::Hybrid_Type::PBE0; + else if(INPUT.exx_hybrid_type=="hse") + exx_global.info.hybrid_type = Exx_Global::Hybrid_Type::HSE; + else if(INPUT.exx_hybrid_type=="opt_orb") + exx_global.info.hybrid_type = Exx_Global::Hybrid_Type::Generate_Matrix; + exx_global.info.hybrid_alpha = INPUT.exx_hybrid_alpha ; + exx_global.info.hse_omega = INPUT.exx_hse_omega ; + exx_global.info.separate_loop = INPUT.exx_separate_loop ; + exx_global.info.hybrid_step = INPUT.exx_hybrid_step ; + exx_lip.info.lambda = INPUT.exx_lambda ; + exx_lcao.info.pca_threshold = INPUT.exx_pca_threshold ; + exx_lcao.info.c_threshold = INPUT.exx_c_threshold ; + exx_lcao.info.v_threshold = INPUT.exx_v_threshold ; + exx_lcao.info.dm_threshold = INPUT.exx_dm_threshold ; + exx_lcao.info.schwarz_threshold = INPUT.exx_schwarz_threshold ; + exx_lcao.info.cauchy_threshold = INPUT.exx_cauchy_threshold ; + if(INPUT.exx_distribute_type=="htime") + exx_lcao.info.distribute_type = Exx_Lcao::Distribute_Type::Htime; + else if(INPUT.exx_distribute_type=="kmeans") + exx_lcao.info.distribute_type = Exx_Lcao::Distribute_Type::Kmeans; + if(INPUT.exx_h_mixing_mode=="no") + exx_lcao.info.H_mixing_mode = Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode::No; + else if(INPUT.exx_h_mixing_mode=="plain") + exx_lcao.info.H_mixing_mode = Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode::Plain; + else if(INPUT.exx_h_mixing_mode=="pulay") + exx_lcao.info.H_mixing_mode = Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode::Pulay; + exx_lcao.info.H_mixing_beta = INPUT.exx_h_mixing_beta; + Exx_Abfs::Jle::Lmax = INPUT.exx_opt_orb_lmax; + Exx_Abfs::Jle::Ecut_exx = INPUT.exx_opt_orb_ecut; + Exx_Abfs::Jle::tolerence = INPUT.exx_opt_orb_tolerence; + } + ppcell.cell_factor = INPUT.cell_factor; //LiuXh add 20180619 timer::tick("Input_Conv","Convert",'B'); diff --git a/ABACUS.1.0.0/source/run_frag.cpp b/ABACUS.1.0.0/source/run_frag.cpp index 0ff3576e9f..976c3fd3cd 100644 --- a/ABACUS.1.0.0/source/run_frag.cpp +++ b/ABACUS.1.0.0/source/run_frag.cpp @@ -123,6 +123,21 @@ void Run_Frag::pw_line(void) // Initial start wave functions //================================ wf.wfcinit(); + + switch(exx_global.info.hybrid_type) // Peize Lin add 2019-03-09 + { + case Exx_Global::Hybrid_Type::HF: + case Exx_Global::Hybrid_Type::PBE0: + case Exx_Global::Hybrid_Type::HSE: + exx_lip.init(&kv, &wf, &pw, &UFFT, &ucell); + break; + case Exx_Global::Hybrid_Type::No: + break; + case Exx_Global::Hybrid_Type::Generate_Matrix: + default: + throw invalid_argument(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + } + DONE(ofs_running,"INIT BASIS"); //========================================================= // @@ -227,6 +242,19 @@ void Run_Frag::frag_LCAO_line(void) // declration enum use_wf_coef {SOME_PW, ALL_LO}; use_wf_coef uoc = ALL_LO; + + // Peize Lin add 2018-11-30 + if(CALCULATION=="nscf") + { + switch(exx_global.info.hybrid_type) + { + case Exx_Global::Hybrid_Type::HF: + case Exx_Global::Hybrid_Type::PBE0: + case Exx_Global::Hybrid_Type::HSE: + exx_global.info.set_xcfunc(xcf); + break; + } + } switch (uoc) { @@ -258,6 +286,24 @@ void Run_Frag::frag_LCAO_line(void) DONE(ofs_running,"INIT SOME_PW"); break; } + + // Peize Lin 2016-12-03 + if (CALCULATION=="scf" || CALCULATION=="md" || CALCULATION=="relax") + { + switch(exx_global.info.hybrid_type) + { + case Exx_Global::Hybrid_Type::HF: + case Exx_Global::Hybrid_Type::PBE0: + case Exx_Global::Hybrid_Type::HSE: + exx_lcao.init(); + break; + case Exx_Global::Hybrid_Type::No: + case Exx_Global::Hybrid_Type::Generate_Matrix: + break; + default: + throw invalid_argument(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + } + } Local_Orbital_Ions ions; ions.opt_ions(); @@ -340,6 +386,20 @@ void Run_Frag::frag_pw_line(void) // Initial start wave functions //================================ wf.wfcinit(); + + switch(exx_global.info.hybrid_type) // Peize Lin add 2019-03-09 + { + case Exx_Global::Hybrid_Type::HF: + case Exx_Global::Hybrid_Type::PBE0: + case Exx_Global::Hybrid_Type::HSE: + exx_lip.init(&kv, &wf, &pw, &UFFT, &ucell); + break; + case Exx_Global::Hybrid_Type::No: + break; + case Exx_Global::Hybrid_Type::Generate_Matrix: + default: + throw invalid_argument(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + } //if (winput::before_iter) //{ @@ -377,7 +437,7 @@ void Run_Frag::frag_pw_line(void) { wf.wanf2[ik].create(NLOCAL, wf.npwx); //if ( LOCAL_BASIS == 3 || LOCAL_BASIS == 0 ) xiaohui modify 2013-09-01 - if(BASIS_TYPE=="pw") //xiaohui add 2013-09-01. Attention! "LOCAL_BASIS==3"??? + if(BASIS_TYPE=="pw") //xiaohui add 2013-09-01. Attention! "LOCAL_BASIS==3"??? { cout << " ik=" << ik + 1 << endl; diff --git a/ABACUS.1.0.0/source/src_external/src_pdiag/pdiag_double.cpp b/ABACUS.1.0.0/source/src_external/src_pdiag/pdiag_double.cpp index 9d03d0b05b..83ae70b775 100644 --- a/ABACUS.1.0.0/source/src_external/src_pdiag/pdiag_double.cpp +++ b/ABACUS.1.0.0/source/src_external/src_pdiag/pdiag_double.cpp @@ -27,7 +27,6 @@ inline int cart2blacs(MPI_Comm comm_2D, int nprows, int npcols, int N, int nblk, int myprow, mypcol; int *usermap=new int[nprows*npcols]; int info=0; - for(int i=0; i +#include +using namespace std; + +template +static void print_tmp(const T &S) +{ + for( const auto &s1 : S) + { + const auto i1=s1.first; + for( const auto &s2 : s1.second ) + { + const auto i2=s2.first; + for( const auto &s3 : s2.second ) + { + const auto i3=s3.first; + cout<,weak_ptr>>> &ms, ofstream &ofs) +{ + for( const auto & c1 : ms ) + for( const auto & c2 : c1.second ) + for( const auto & c3 : c2.second ) + { + ofs<,shared_ptr>>> &ms, ofstream &ofs) +{ + for( const auto & c1 : ms ) + for( const auto & c2 : c1.second ) + for( const auto & c3 : c2.second ) + { + ofs< + +static void test_adjs( ostream & os ) +{ + for( size_t it=0; it!=ucell.ntype; ++it ) + for( size_t ia=0; ia!=ucell.atoms[it].na; ++ia ) + { + const int iat = ucell.itia2iat(it,ia); + const map>> adjs = Abfs::get_adjs(iat); + os<<"@@@\t"< &box2 : atom2.second ) + os< +#include +#include + +void print_orbs( const vector>>> & orbs, const std::string & file_name ) +{ + std::ofstream ofsN(file_name); + for( size_t T=0; T!=orbs.size(); ++T ) + for( size_t L=0; L!=orbs[T].size(); ++L ) + for( size_t N=0; N!=orbs[T][L].size(); ++N ) + { + ofsN< +#include +#include +#include +#include "src_global/global_function.h" +#include "src_global/matrix.h" +#include "src_pw/global.h" + +class Exx_Abfs_DM_Test +{ +public: + static map>> cal_DMk_raw_readfile( const set> &atom_pairs ); + static vector>> read_wfc( const string &file_name ); + static matrix read_wg( const string &file_name ); +}; + +map>> +Exx_Abfs_DM_Test::cal_DMk_raw_readfile( const set> &atom_pairs ) +{ + static int istep=-1; ++istep; + TITLE("cal_DMk_raw_readfile_"+TO_STRING(istep)); + matrix wf_wg = read_wg( "wf.wg/wf.wg_"+TO_STRING(istep) ); + vector>>> wfc(kv.nks); + for( size_t ik=0; ik!=kv.nks; ++ik ) + wfc[ik] = read_wfc( "hvec/hvec_"+TO_STRING(istep)+"_"+TO_STRING(ik) ); + + + const double SPIN_multiple = 0.5*NSPIN; + + map>> DMk_raw; + for( const pair & atom_pair : atom_pairs ) + { + const size_t iat1 = atom_pair.first; + const size_t iat2 = atom_pair.second; + const size_t it1 = ucell.iat2it[iat1]; + const size_t it2 = ucell.iat2it[iat2]; + const size_t ia1 = ucell.iat2ia[iat1]; + const size_t ia2 = ucell.iat2ia[iat2]; + + DMk_raw[iat1][iat2] = vector( kv.nks, {ucell.atoms[it1].nw,ucell.atoms[it2].nw} ); + for( size_t ik=0; ik!=kv.nks; ++ik ) + { + for( size_t iw1=0; iw1!=ucell.atoms[it1].nw; ++iw1 ) + { + for( size_t iw2=0; iw2!=ucell.atoms[it2].nw; ++iw2 ) + { + for( size_t ib=0; ib!=NBANDS; ++ib ) + { + DMk_raw[iat1][iat2][ik](iw1,iw2) += wf_wg(ik,ib) * conj(wfc[ik][ib][ucell.itiaiw2iwt(it1,ia1,iw1)]) * wfc[ik][ib][ucell.itiaiw2iwt(it2,ia2,iw2)]; + } + } + } + DMk_raw[iat1][iat2][ik] *= SPIN_multiple; + } + } + return DMk_raw; +} + + + +vector>> Exx_Abfs_DM_Test::read_wfc( const string &file_name ) +{ + vector>> wfc(NBANDS,vector>(NLOCAL)); + ifstream ifs(file_name); + for( size_t iw=0; iw!=NLOCAL; ++iw ) + { + for( size_t ib=0; ib!=NBANDS; ++ib ) + { + double a,b; + ifs>>a>>b; + wfc[ib][iw] = {a,b}; + } + } + ifs.close(); + return wfc; +} + + + +matrix Exx_Abfs_DM_Test::read_wg( const string &file_name ) +{ + matrix wf_wg(kv.nks,NBANDS); + ifstream ifs(file_name); + for( size_t ik=0; ik!=kv.nks; ++ik ) + { + for( size_t ib=0; ib!=NBANDS; ++ib ) + { + ifs>>wf_wg(ik,ib); + } + } + ifs.close(); + return wf_wg; +} diff --git a/ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_abfs-inverse_matrix_double-test.h b/ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_abfs-inverse_matrix_double-test.h new file mode 100644 index 0000000000..930e55ea4a --- /dev/null +++ b/ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_abfs-inverse_matrix_double-test.h @@ -0,0 +1,466 @@ +#ifndef EXX_ABFS_INVERSE_MATRIX_DOUBLE_TEST_H +#define EXX_ABFS_INVERSE_MATRIX_DOUBLE_TEST_H + +#include "src_lcao/exx_abfs-inverse_matrix_double.h" + +matrix init_matrix(); + +int inverse_matrix_double_test() +{ + matrix m = init_matrix(); + matrix mI(m.nr,m.nc); + + Exx_Abfs::Inverse_Matrix_Double I; + I.init(m.nr); + I.input(m); + I.cal_inverse( Exx_Abfs::Inverse_Matrix_Double::Method::dsyev ); + I.output(mI); + + ofstream ofs("m_mI.dat"); + ofs< +#include +#include "src_lcao/abfs.h" + +static void test_screen( const string & file_name, const map,double>>> & m ) +{ + ofstream ofs(file_name); + for( const auto m1 : m ) + for( const auto m2 : m1.second ) + for( const auto m3 : m2.second ) + ofs< +#include +using namespace std; + +#include "src_lcao/exx_abfs.h" + +#include "src_external/src_test/src_global/matrix-test.h" +#include "src_external/src_test/src_lcao/exx_abfs-unittest.h" + +static void of_abfs_cpp( const string &file_name, const vector>> &orb ) +{ + for( int i=0; i!=orb.size(); ++i ) + for( int j=0; j!=orb[i].size(); ++j ) + for( int k=0; k!=orb[i][j].size(); ++k ) + { + stringstream ss; ss<>>> &matrix ) +{ + for( const auto & m1 : matrix ) + { + const size_t TA = m1.first; + { + for( const auto & m2 : m1.second ) + { + const size_t IA = m2.first; + for( const auto & m3 : m2.second ) + { + const size_t TB = m3.first; + for( const auto & m4 : m3.second ) + { + const size_t IB = m4.first; + const auto & m = m4.second; + + cout<>>> &ms ) +{ + ofstream ofs(file_name.c_str()); + ofs<<"0000"<>>>> &ms ) +{ + ofstream ofs(file_name.c_str()); + ofs<<"0000"<>>>>> &ms ) +{ + ofstream ofs(file_name.c_str()); + ofs<<"0000"< +#include +#include +#include +#include +using namespace std; + +inline double time_during ( const timeval &t_start, const timeval &t_end ) +{ + return (double)(t_end.tv_sec-t_start.tv_sec) + (double)(t_end.tv_usec-t_start.tv_usec)/1000000.0; +}; +inline double time_during ( const timeval &t_start ) +{ + timeval t_end; + gettimeofday( &t_end, NULL ); + return time_during(t_start,t_end); +}; + + + +inline size_t get_sizeof( const matrix & m ){ return sizeof(double)*m.nr*m.nc; } +inline size_t get_sizeof( const ComplexMatrix & m ){ return sizeof(double)*m.nr*m.nc; } +inline size_t get_sizeof( const shared_ptr & m ){ return sizeof(matrix)+sizeof(double)*m->nr*m->nc; } +inline size_t get_sizeof( const shared_ptr & m ){ return sizeof(ComplexMatrix)+sizeof(double)*m->nr*m->nc; } +inline size_t get_sizeof( const weak_ptr & m ){ return sizeof(matrix)+sizeof(double)*m.lock()->nr*m.lock()->nc; } +inline size_t get_sizeof( const weak_ptr & m ){ return sizeof(ComplexMatrix)+sizeof(double)*m.lock()->nr*m.lock()->nc; } +template static size_t get_sizeof( const vector & v ) +{ + size_t length = sizeof(T)*v.size(); + for( const T & i : v ) length+=get_sizeof(i); + return length; +} +template static size_t get_sizeof( const map & m ) +{ + size_t length = (sizeof(T1)+sizeof(T2))*m.size(); + for( const auto & i : m ) length+=get_sizeof(i.second); + return length; +} + + + +template +static void ofs_matrixes( const string & file_name, const map &ms, const bool flag_print_content=true ) +{ + ofstream ofs(file_name,ofstream::app); + for( const auto &m : ms ) + { + ofs< +static void ofs_matrixes( const string & file_name, const vector &ms, const bool flag_print_content=true ) +{ + ofstream ofs(file_name,ofstream::app); + for( size_t i=0; i +static void ofs_matrixes( const string & file_name, const weak_ptr & ms, const bool flag_print_content=true ) +{ + ofstream ofs(file_name,ofstream::app); + if(flag_print_content) + ofs<<*ms.lock()< +static void ofs_matrixes( const string & file_name, const shared_ptr & ms, const bool flag_print_content=true ) +{ + ofstream ofs(file_name,ofstream::app); + if(flag_print_content) + ofs<<*ms< +static void ofs_matrixes( const string & file_name, const map>>> & ms, const bool flag_print_content=true ) +{ + ofstream ofs(file_name,ofstream::app); + for( const auto &m1 : ms ) + { + const auto i1 = m1.first; + for( const auto &m2 : m1.second ) + { + const auto i2 = m2.first; + for( const auto &m3 : m2.second ) + { + const auto i3 = m3.first; + ofs< +static void ofs_matrixes( const string & file_name, const map>>> & ms, const bool flag_print_content=true ) +{ + ofstream ofs(file_name,ofstream::app); + for( const auto &m1 : ms ) + { + const auto i1 = m1.first; + for( const auto &m2 : m1.second ) + { + const auto i2 = m2.first; + for( const auto &m3 : m2.second ) + { + const auto i3 = m3.first; + ofs< +static void ofs_matrixes( const string & file_name, const map>> & ms, const bool flag_print_content=true ) +{ + ofstream ofs(file_name,ofstream::app); + for( const auto &m1 : ms ) + { + const auto i1 = m1.first; + for( const auto &m2 : m1.second ) + { + const auto i2 = m2.first; + for( size_t i3=0; i3!=m2.second.size(); ++i3 ) + { + ofs< +static void ofs_matrixes( const string & file_name, const map>>> & ms, const bool flag_print_content=true ) +{ + ofstream ofs(file_name,ofstream::app); + for( const auto &m1 : ms ) + { + const auto i1 = m1.first; + for( const auto &m2 : m1.second ) + { + const auto i2 = m2.first; + for( const auto &m3 : m2.second ) + { + const auto i3 = m3.first; + for( size_t i4=0; i4!=m3.second.size(); ++i4 ) + { + ofs< +static void ofs_matrixes( const string & file_name, const map>> & ms, const bool flag_print_content=true ) +{ + ofstream ofs(file_name,ofstream::app); + for( const auto &m1 : ms ) + { + const auto i1 = m1.first; + for( const auto &m2 : m1.second ) + { + const auto i2 = m2.first; + for( const auto &m3 : m2.second ) + { + const auto i3 = m3.first; + ofs< #include +#include +#include #include #include #include @@ -30,6 +32,23 @@ static std::ostream & operator<<( std::ostream & os, const std::vector &v ) return os; } +// Peize Lin add 2016-06-06 +template +static std::ostream & operator<<( std::ostream & os, const std::set &v ) +{ + for( const T &i : v ) + os< +static std::ostream & operator<<( std::ostream & os, const std::pair &p ) +{ + os< +#include +#include +#include + +#include +#include +#include +#include + +#include "src_global/vector3.h" +#include "src_lcao/abfs-vector3_order.h" +#include "src_global/matrix.h" +#include "src_global/matrix_wrapper.h" + +namespace boost +{ + namespace serialization + { + // Vector3 Peize Lin add 2018-07-01 + template + inline void serialize(Archive & ar, Vector3 & v, const unsigned int version) + { + ar & v.x; + ar & v.y; + ar & v.z; + } + + // Abfs::Vector3_Order Peize Lin add 2018-07-01 + template + inline void serialize(Archive & ar, Abfs::Vector3_Order & v, const unsigned int version) + { + ar & v.x; + ar & v.y; + ar & v.z; + } + + // matrix Peize Lin add 2018-07-01 + template + inline void save( Archive & ar, const matrix & m, const unsigned int /*file_version*/ ) + { + const collection_size_type nr(m.nr), nc(m.nc); + ar << BOOST_SERIALIZATION_NVP(nr) << BOOST_SERIALIZATION_NVP(nc); + if( nr && nc ) + ar << serialization::make_array( m.c, nr*nc ); + } + template + inline void load( Archive & ar, matrix &m, const unsigned int /*file_version*/ ) + { + collection_size_type nr, nc; + ar >> BOOST_SERIALIZATION_NVP(nr) >> BOOST_SERIALIZATION_NVP(nc); + m.create(nr,nc,false); + if( nr && nc ) + ar >> serialization::make_array( m.c, nr*nc ); + } + template + inline void serialize( Archive & ar, matrix & m, const unsigned int file_version ) + { + boost::serialization::split_free(ar, m, file_version); + } + + // MatrixWrapper Peize Lin add 2018-07-31 + template + inline void save( Archive & ar, const Matrix_Wrapper & m, const unsigned int /*file_version*/ ) + { + const collection_size_type nr(m.nr), nc(m.nc); + ar << BOOST_SERIALIZATION_NVP(nr) << BOOST_SERIALIZATION_NVP(nc); + if( nr && nc ) + ar << serialization::make_array( m.c, nr*nc ); + } + template + inline void load( Archive & ar, Matrix_Wrapper &m, const unsigned int /*file_version*/ ) + { + collection_size_type nr, nc; + ar >> BOOST_SERIALIZATION_NVP(nr) >> BOOST_SERIALIZATION_NVP(nc); + m.create(nr,nc,false); + if( nr && nc ) + ar >> serialization::make_array( m.c, nr*nc ); + } + template + inline void serialize( Archive & ar, Matrix_Wrapper & m, const unsigned int file_version ) + { + boost::serialization::split_free(ar, m, file_version); + } + } +} + + +#include + +BOOST_SERIALIZATION_COLLECTION_TRAITS(Vector3) +BOOST_SERIALIZATION_COLLECTION_TRAITS(Abfs::Vector3_Order) + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_global/container_operator.h b/ABACUS.1.0.0/source/src_global/container_operator.h new file mode 100644 index 0000000000..eaaf220e39 --- /dev/null +++ b/ABACUS.1.0.0/source/src_global/container_operator.h @@ -0,0 +1,69 @@ +#ifndef CONTAINER_OPERATOR_H +#define CONTAINER_OPERATOR_H + +#include +#include +#include +using namespace std; + + + +template< typename T> +vector operator + ( const vector & x1, const vector & x2 ) +{ + assert(x1.size()==x2.size()); + vector x; + for( size_t i=0; i!=x1.size(); ++i ) + x.push_back(x1[i]+x2[i]); + return x; +} + +template< typename T> +vector operator - ( const vector & x1, const vector & x2 ) +{ + assert(x1.size()==x2.size()); + vector x; + for( size_t i=0; i!=x1.size(); ++i ) + x.push_back(x1[i]-x2[i]); + return x; +} + +template< typename T1, typename T2 > +map operator + ( const map & x1, const map & x2 ) +{ + map x; + for( const auto &x1i : x1 ) + x.insert(make_pair( x1i.first, x1i.second + x2.at(x1i.first) )); + return x; +} + +template< typename T1, typename T2 > +map operator - ( const map & x1, const map & x2 ) +{ + map x; + for( const auto &x1i : x1 ) + x.insert(make_pair( x1i.first, x1i.second - x2.at(x1i.first) )); + return x; +} + + + +template< typename T1, typename T2 > +vector operator * ( const T1 & x1, const vector & x2 ) +{ + vector x; + for( size_t i=0; i!=x2.size(); ++i ) + x.push_back(x1*x2[i]); + return x; +} + +template< typename T1, typename T21, typename T22 > +map operator * ( const T1 & x1, const map & x2 ) +{ + map x; + for( const auto & x2i : x2 ) + x.insert(make_pair( x2i.first, x1*x2i.second )); + return x; +} + +#endif // CONTAINER_OPERATOR_H \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_global/global_function.h b/ABACUS.1.0.0/source/src_global/global_function.h index bb07569175..7d9775a5a5 100644 --- a/ABACUS.1.0.0/source/src_global/global_function.h +++ b/ABACUS.1.0.0/source/src_global/global_function.h @@ -17,7 +17,7 @@ #include #include "global_variable.h" -//#include "global_function-func_each_2.h" // Peize Lin add 2016-09-07 +#include "global_function-func_each_2.h" // Peize Lin add 2016-09-07 using namespace std; @@ -221,4 +221,44 @@ std::string TO_STRING ( const T &n ) return newstr.str(); } +//========================================================== +// GLOBAL FUNCTION : +// NAME : MAP_EXIST +// find whether exists the map index +// if exist return the ptr called, else return nullptr +// example: map_exist(ms,i,j,k) -> try to find ms[i][j][k] +// Peize Lin add 2018-07-16 +//========================================================== +template< typename T_map, typename T_key1 > +inline void* MAP_EXIST( T_map &ms, const T_key1 &key1 ) +{ + auto ms1 = ms.find(key1); + if( ms1 == ms.end() ) return nullptr; + return static_cast(&ms1->second); +} + +template< typename T_map, typename T_key1, typename... T_key_tail > +inline void* MAP_EXIST( T_map &ms, const T_key1 &key1, const T_key_tail&... key_tail ) +{ + auto ms1 = ms.find(key1); + if( ms1 == ms.end() ) return nullptr; + return MAP_EXIST( ms1->second, key_tail... ); +} + +template< typename T_map, typename T_key1 > +inline const void* MAP_EXIST( const T_map &ms, const T_key1 &key1 ) +{ + auto ms1 = ms.find(key1); + if( ms1 == ms.end() ) return nullptr; + return static_cast(&ms1->second); +} + +template< typename T_map, typename T_key1, typename... T_key_tail > +inline const void* MAP_EXIST( const T_map &ms, const T_key1 &key1, const T_key_tail&... key_tail ) +{ + auto ms1 = ms.find(key1); + if( ms1 == ms.end() ) return nullptr; + return MAP_EXIST( ms1->second, key_tail... ); +} + #endif diff --git a/ABACUS.1.0.0/source/src_global/gram_schmidt_orth.h b/ABACUS.1.0.0/source/src_global/gram_schmidt_orth.h index 29c91c1299..702e212ffe 100644 --- a/ABACUS.1.0.0/source/src_global/gram_schmidt_orth.h +++ b/ABACUS.1.0.0/source/src_global/gram_schmidt_orth.h @@ -23,7 +23,7 @@ class Gram_Schmidt_Orth private: - const Coordinate &coordinate; + const Coordinate coordinate; const vector &rab; vector radial_2; diff --git a/ABACUS.1.0.0/source/src_global/lapack_connector.h b/ABACUS.1.0.0/source/src_global/lapack_connector.h index d9f3070d2e..bf34a1f75c 100644 --- a/ABACUS.1.0.0/source/src_global/lapack_connector.h +++ b/ABACUS.1.0.0/source/src_global/lapack_connector.h @@ -77,32 +77,38 @@ extern "C" void pdgetrf_(const int *m, const int *n, double *a, const int *ia, const int *ja, int *desca, int *ipiv, int *info); // Peize Lin add ?axpy 2016-08-04, to compute y=a*x+y - void saxpy_(const int *N, const float *alpha, const float *X, const int *incX, float *Y, const int *incY); - void daxpy_(const int *N, const double *alpha, const double *X, const int *incX, double *Y, const int *incY); - void caxpy_(const int *N, const complex *alpha, const complex *X, const int *incX, complex *Y, const int *incY); - void zaxpy_(const int *N, const complex *alpha, const complex *X, const int *incX, complex *Y, const int *incY); + void saxpy_(const int *n, const float *alpha, const float *X, const int *incX, float *Y, const int *incY); + void daxpy_(const int *n, const double *alpha, const double *X, const int *incX, double *Y, const int *incY); + void caxpy_(const int *n, const complex *alpha, const complex *X, const int *incX, complex *Y, const int *incY); + void zaxpy_(const int *n, const complex *alpha, const complex *X, const int *incX, complex *Y, const int *incY); // Peize Lin add ?scal 2016-08-04, to compute x=a*x - void sscal_(const int *N, const float *alpha, float *X, const int *incX); - void dscal_(const int *N, const double *alpha, double *X, const int *incX); - void cscal_(const int *N, const complex *alpha, complex *X, const int *incX); - void zscal_(const int *N, const complex *alpha, complex *X, const int *incX); + void sscal_(const int *n, const float *alpha, float *X, const int *incX); + void dscal_(const int *n, const double *alpha, double *X, const int *incX); + void cscal_(const int *n, const complex *alpha, complex *X, const int *incX); + void zscal_(const int *n, const complex *alpha, complex *X, const int *incX); // Peize Lin add ?dot 2017-10-27, to compute d=x*y - float sdot_(const int *N, const float *X, const int *incX, const float *Y, const int *incY); - double ddot_(const int *N, const double *X, const int *incX, const double *Y, const int *incY); + float sdot_(const int *n, const float *X, const int *incX, const float *Y, const int *incY); + double ddot_(const int *n, const double *X, const int *incX, const double *Y, const int *incY); // Peize Lin add ?gemm 2017-10-27, to compute C = a * A.? * B.? + b * C void sgemm_(const char *transa, const char *transb, const int *m, const int *n, const int *k, - const float *alpha, const float *a, const int *lda, const float *b, const int *ldb, - const float *beta, float *c, const int *ldc); + const float *alpha, const float *A, const int *lda, const float *B, const int *ldb, + const float *beta, float *C, const int *ldc); void dgemm_(const char *transa, const char *transb, const int *m, const int *n, const int *k, - const double *alpha, const double *a, const int *lda, const double *b, const int *ldb, - const double *beta, double *c, const int *ldc); + const double *alpha, const double *A, const int *lda, const double *B, const int *ldb, + const double *beta, double *C, const int *ldc); void zgemm_(const char *transa, const char *transb, const int *m, const int *n, const int *k, - const complex *alpha, const complex *a, const int *lda, const complex *b, const int *ldb, - const complex *beta, complex *c, const int *ldc); + const complex *alpha, const complex *A, const int *lda, const complex *B, const int *ldb, + const complex *beta, complex *C, const int *ldc); // Peize Lin add ?nrm2 2018-06-12, to compute out = ||x||_2 = \sqrt{ \sum_i x_i**2 } - float snrm2_( const int *N, const float *X, const int *incX ); - double dnrm2_( const int *N, const double *X, const int *incX ); - double dznrm2_( const int *N, const complex *X, const int *incX ); + float snrm2_( const int *n, const float *X, const int *incX ); + double dnrm2_( const int *n, const double *X, const int *incX ); + double dznrm2_( const int *n, const complex *X, const int *incX ); + // Peize Lin add zherk 2019-04-14 + // if trans=='N': C = a * A * A.H + b * C + // if trans=='C': C = a * A.H * A + b * C + void zherk_(const char *uplo, const char *trans, const int *n, const int *k, + const double *alpha, const complex *A, const int *lda, + const double *beta, complex *C, const int *ldc); }; // Class LapackConnector provide the connector to fortran lapack routine. @@ -187,10 +193,33 @@ class LapackConnector { case 'U': return 'L'; case 'L': return 'U'; - default: throw invalid_argument("Uplo must be 'U' or 'L'"); + default: throw invalid_argument("uplo must be 'U' or 'L'"); } } + // Peize Lin add 2019-04-14 + static inline + char change_trans_NT(const char &trans) + { + switch(trans) + { + case 'N': return 'T'; + case 'T': return 'N'; + default: throw invalid_argument("trans must be 'N' or 'T'"); + } + } + // Peize Lin add 2019-04-14 + static inline + char change_trans_NC(const char &trans) + { + switch(trans) + { + case 'N': return 'C'; + case 'C': return 'N'; + default: throw invalid_argument("trans must be 'N' or 'C'"); + } + } + public: static inline @@ -486,7 +515,6 @@ class LapackConnector dpotrf_( &uplo_changed, &n, a.c, &lda, info ); } - // Peize Lin add 2016-07-09 static inline void dpotri( char uplo, const int n, matrix &a, const int lda, int *info ) @@ -498,60 +526,60 @@ class LapackConnector // Peize Lin add 2016-08-04 // y=a*x+y static inline - void axpy( const int N, const float alpha, const float *X, const int incX, float *Y, const int incY) + void axpy( const int n, const float alpha, const float *X, const int incX, float *Y, const int incY) { - saxpy_(&N, &alpha, X, &incX, Y, &incY); + saxpy_(&n, &alpha, X, &incX, Y, &incY); } static inline - void axpy( const int N, const double alpha, const double *X, const int incX, double *Y, const int incY) + void axpy( const int n, const double alpha, const double *X, const int incX, double *Y, const int incY) { - daxpy_(&N, &alpha, X, &incX, Y, &incY); + daxpy_(&n, &alpha, X, &incX, Y, &incY); } static inline - void axpy( const int N, const complex alpha, const complex *X, const int incX, complex *Y, const int incY) + void axpy( const int n, const complex alpha, const complex *X, const int incX, complex *Y, const int incY) { - caxpy_(&N, &alpha, X, &incX, Y, &incY); + caxpy_(&n, &alpha, X, &incX, Y, &incY); } static inline - void axpy( const int N, const complex alpha, const complex *X, const int incX, complex *Y, const int incY) + void axpy( const int n, const complex alpha, const complex *X, const int incX, complex *Y, const int incY) { - zaxpy_(&N, &alpha, X, &incX, Y, &incY); + zaxpy_(&n, &alpha, X, &incX, Y, &incY); } // Peize Lin add 2016-08-04 // x=a*x static inline - void scal( const int N, const float alpha, float *X, const int incX) + void scal( const int n, const float alpha, float *X, const int incX) { - sscal_(&N, &alpha, X, &incX); + sscal_(&n, &alpha, X, &incX); } static inline - void scal( const int N, const double alpha, double *X, const int incX) + void scal( const int n, const double alpha, double *X, const int incX) { - dscal_(&N, &alpha, X, &incX); + dscal_(&n, &alpha, X, &incX); } static inline - void scal( const int N, const complex alpha, complex *X, const int incX) + void scal( const int n, const complex alpha, complex *X, const int incX) { - cscal_(&N, &alpha, X, &incX); + cscal_(&n, &alpha, X, &incX); } static inline - void scal( const int N, const complex alpha, complex *X, const int incX) + void scal( const int n, const complex alpha, complex *X, const int incX) { - zscal_(&N, &alpha, X, &incX); + zscal_(&n, &alpha, X, &incX); } // Peize Lin add 2017-10-27 // d=x*y static inline - float dot( const int N, const float *X, const int incX, const float *Y, const int incY) + float dot( const int n, const float *X, const int incX, const float *Y, const int incY) { - return sdot_(&N, X, &incX, Y, &incY); + return sdot_(&n, X, &incX, Y, &incY); } static inline - double dot( const int N, const double *X, const int incX, const double *Y, const int incY) + double dot( const int n, const double *X, const int incX, const double *Y, const int incY) { - return ddot_(&N, X, &incX, Y, &incY); + return ddot_(&n, X, &incX, Y, &incY); } // Peize Lin add 2017-10-27, fix bug trans 2019-01-17 @@ -587,20 +615,33 @@ class LapackConnector // Peize Lin add 2018-06-12 // out = ||x||_2 static inline - float nrm2( const int N, const float *X, const int incX ) + float nrm2( const int n, const float *X, const int incX ) { - return snrm2_( &N, X, &incX ); + return snrm2_( &n, X, &incX ); } static inline - double nrm2( const int N, const double *X, const int incX ) + double nrm2( const int n, const double *X, const int incX ) { - return dnrm2_( &N, X, &incX ); + return dnrm2_( &n, X, &incX ); } static inline - double nrm2( const int N, const complex *X, const int incX ) + double nrm2( const int n, const complex *X, const int incX ) { - return dznrm2_( &N, X, &incX ); + return dznrm2_( &n, X, &incX ); } + // Peize Lin add 2019-04-14 + // if trans=='N': C = a * A * A.H + b * C + // if trans=='C': C = a * A.H * A + b * C + static inline + void zherk(const char uplo, const char trans, const int n, const int k, + const double alpha, const complex *A, const int lda, + const double beta, complex *C, const int ldc) + { + const char uplo_changed = change_uplo(uplo); + const char trans_changed = change_trans_NC(trans); + zherk_(&uplo_changed, &trans_changed, &n, &k, &alpha, A, &lda, &beta, C, &ldc); + } + }; #endif // LAPACKCONNECTOR_HPP diff --git a/ABACUS.1.0.0/source/src_global/mathzone.cpp b/ABACUS.1.0.0/source/src_global/mathzone.cpp index 0ed2a82373..841883e25c 100644 --- a/ABACUS.1.0.0/source/src_global/mathzone.cpp +++ b/ABACUS.1.0.0/source/src_global/mathzone.cpp @@ -89,8 +89,8 @@ double Mathzone::Polynomial_Interpolation cout << "\n x = " << x; cout << "\n table_interval = " << table_interval; cout << "\n iq=" << iq << " table_length = " << table_length << endl; - cout << "\n Not enough space allocated for radial FFT: try restarting with a larger cell_factor" << endl; //LiuXh add 20180619 - cout << "\n Now cell_factor is: " << ppcell.cell_factor << endl; //LiuXh add 20180619 + cout << "\n Not enough space allocated for radial FFT: try restarting with a larger cell_factor" << endl; //LiuXh add 20180619 + cout << "\n Now cell_factor is: " << ppcell.cell_factor << endl; //LiuXh add 20180619 } assert(iq < table_length-4); const double x0 = position - static_cast(iq); diff --git a/ABACUS.1.0.0/source/src_global/matrix-inl.h b/ABACUS.1.0.0/source/src_global/matrix-inl.h new file mode 100644 index 0000000000..e27eb576be --- /dev/null +++ b/ABACUS.1.0.0/source/src_global/matrix-inl.h @@ -0,0 +1,79 @@ +#ifndef MATRIX_INL_H +#define MATRIX_INL_H + +#include "matrix.h" +#include + +// test +#include +using namespace std; + +inline matrix::matrix( const int nrows, const int ncols, const bool flag_zero ) + :nr(nrows), nc(ncols), c(nullptr) +{ +cout<<__FILE__<<__LINE__<zero_out(); + } +} + +inline matrix::matrix( const matrix &m_in ) +{ +cout<<__FILE__<<__LINE__<create( m_in.nr, m_in.nc, false ); +cout<<__FILE__<<__LINE__<=0); assert(ir=0); assert(ic=0); assert(ir=0); assert(ic::min(); + double value = 0; const int size = nr * nc; for( int i=0; i + +// !!! Attention: c is very dangerous, may be changed by other class, +// e.g. changed the value, size!=nr*nc, deleted + +class Matrix_Wrapper +{ +public: + double *c; + int nr; + int nc; + bool flag_delete_c; + + Matrix_Wrapper(): nr(0), nc(0), c(nullptr), flag_delete_c(false){} + Matrix_Wrapper( const matrix &m ): nr(m.nr), nc(m.nc), c(m.c), flag_delete_c(false){} + inline void create( const int nr_in, const int nc_in, const bool flag_zero ); + inline matrix to_matrix(); + ~Matrix_Wrapper(){ if(flag_delete_c) delete[]c; } + Matrix_Wrapper( const Matrix_Wrapper &m )=delete; + Matrix_Wrapper( Matrix_Wrapper &m )=delete; + inline Matrix_Wrapper( Matrix_Wrapper &&m ); + inline Matrix_Wrapper&operator=( const Matrix_Wrapper&m ); + inline Matrix_Wrapper&operator=( Matrix_Wrapper&&m ); +}; + + +inline void Matrix_Wrapper::create( const int nr_in, const int nc_in, const bool flag_zero ) +{ + nr = nr_in; nc = nc_in; + if(flag_delete_c) + delete[] c; + c = new double[nr*nc]; + flag_delete_c = true; + if(flag_zero) + memset( c, 0, sizeof(double)*nr*nc ); +} + +inline matrix Matrix_Wrapper::to_matrix() +{ + assert( flag_delete_c==true ); + flag_delete_c = false; + matrix m; + m.nr = nr; m.nc = nc; + m.c = c; + return m; +} + +inline Matrix_Wrapper::Matrix_Wrapper( Matrix_Wrapper &&m ) + :nr(m.nr), + nc(m.nc), + c(m.c), + flag_delete_c(m.flag_delete_c) +{ + m.nr = m.nc = 0; + m.c = nullptr; + m.flag_delete_c = false; +} + +inline Matrix_Wrapper& Matrix_Wrapper::operator=( const Matrix_Wrapper&m ) +{ + assert( !m.flag_delete_c ); + nr = m.nr; nc = m.nc; c = m.c; flag_delete_c = m.flag_delete_c; + return *this; +} + +inline Matrix_Wrapper& Matrix_Wrapper::operator=( Matrix_Wrapper&&m ) +{ + nr = m.nr; nc = m.nc; c = m.c; flag_delete_c = m.flag_delete_c; + m.nr = 0; m.nc = 0; m.c = nullptr; m.flag_delete_c = false; + return *this; +} + +#endif + +#else +#include "matrix_wrapper_tianhe2.h" +#endif diff --git a/ABACUS.1.0.0/source/src_global/matrix_wrapper_tianhe2.h b/ABACUS.1.0.0/source/src_global/matrix_wrapper_tianhe2.h new file mode 100644 index 0000000000..7761b893ac --- /dev/null +++ b/ABACUS.1.0.0/source/src_global/matrix_wrapper_tianhe2.h @@ -0,0 +1,52 @@ +//========================================================== +// AUTHOR : Peize Lin +// DATE : 2018-07-31 +//========================================================== + +#ifndef MATRIX_WRAPPER_H +#define MATRIX_WRAPPER_H + +#include "src_global/matrix.h" +#include + +// !!! Attention: c is very dangerous, may point to somewhere deleted + +class Matrix_Wrapper +{ +public: + double *c; + int nr; + int nc; + + Matrix_Wrapper(): nr(0), nc(0), c(nullptr){} + Matrix_Wrapper( const matrix &m ): nr(m.nr), nc(m.nc), c(m.c){} + inline void create( const int nr_in, const int nc_in, const bool flag_zero ); + inline matrix to_matrix(); + Matrix_Wrapper( const Matrix_Wrapper &m ): nr(m.nr), nc(m.nc), c(m.c){} + Matrix_Wrapper( Matrix_Wrapper &m ): nr(m.nr), nc(m.nc), c(m.c){} + Matrix_Wrapper( Matrix_Wrapper &&m ): nr(m.nr), nc(m.nc), c(m.c){} + inline Matrix_Wrapper&operator=( const Matrix_Wrapper&m ){ nr=m.nr; nc=m.nc; c=m.c; }; + inline Matrix_Wrapper&operator=( Matrix_Wrapper&m ){ nr=m.nr; nc=m.nc; c=m.c; }; + inline Matrix_Wrapper&operator=( Matrix_Wrapper&&m ){ nr=m.nr; nc=m.nc; c=m.c; }; +}; + + +inline void Matrix_Wrapper::create( const int nr_in, const int nc_in, const bool flag_zero ) +{ + nr = nr_in; nc = nc_in; + c = new double[nr*nc]; + if(flag_zero) + memset( c, 0, sizeof(double)*nr*nc ); +} + +inline matrix Matrix_Wrapper::to_matrix() +{ + matrix m; + m.nr = nr; m.nc = nc; + m.c = c; + nr = nc = 0; + c = nullptr; + return m; +} + +#endif diff --git a/ABACUS.1.0.0/source/src_global/vector3.h b/ABACUS.1.0.0/source/src_global/vector3.h index 36f24f9eea..12ff05c951 100644 --- a/ABACUS.1.0.0/source/src_global/vector3.h +++ b/ABACUS.1.0.0/source/src_global/vector3.h @@ -22,6 +22,7 @@ class Vector3 T z; Vector3(const T &x1 = 0,const T &y1 = 0,const T &z1 = 0) :x(x1),y(y1),z(z1){}; + Vector3(const Vector3 &v) :x(v.x),y(v.y),z(v.z){}; // Peize Lin add 2018-07-16 void set(const T &x1, const T &y1,const T &z1) { x = x1; y = y1; z = z1; } Vector3& operator =(const Vector3 &u) { x=u.x; y=u.y; z=u.z; return *this; } diff --git a/ABACUS.1.0.0/source/src_lcao/abfs-template.h b/ABACUS.1.0.0/source/src_lcao/abfs-template.h new file mode 100644 index 0000000000..105aad4664 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/abfs-template.h @@ -0,0 +1,58 @@ +#ifndef ABFS_TEMPLATE_H +#define ABFS_TEMPLATE_H + +#include "abfs.h" + +template +void Abfs::delete_empty_ptrs( map>>> &ptrs ) +{ + TITLE("Abfs","delete_empty_ptrs"); + for( auto iter1=ptrs.begin(); iter1!=ptrs.end(); ) + { + for( auto iter2=iter1->second.begin(); iter2!=iter1->second.end(); ) + { + for( auto iter3=iter2->second.begin(); iter3!=iter2->second.end(); ) + { + if( iter3->second.expired() ) iter2->second.erase(iter3++); + else ++iter3; + } + if( iter2->second.empty() ) iter1->second.erase(iter2++); + else ++iter2; + } + if( iter1->second.empty() ) ptrs.erase(iter1++); + else ++iter1; + } +} + +template +void Abfs::delete_threshold_ptrs( map>>> &ptrs, const double threshold) +{ + TITLE("Abfs","delete_threshold_ptrs"); + for( auto iter1=ptrs.begin(); iter1!=ptrs.end(); ) + { + for( auto iter2=iter1->second.begin(); iter2!=iter1->second.end(); ) + { + for( auto iter3=iter2->second.begin(); iter3!=iter2->second.end(); ) + { + if( iter3->second->absmax()<=threshold ) iter2->second.erase(iter3++); + else ++iter3; + } + if( iter2->second.empty() ) iter1->second.erase(iter2++); + else ++iter2; + } + if( iter1->second.empty() ) ptrs.erase(iter1++); + else ++iter1; + } +} + +template +vector> Abfs::get_atom_pair(const map> &m) +{ + vector> atom_pairs; + for(const auto &mA : m) + for(const auto &mB : mA.second) + atom_pairs.push_back({mA.first,mB.first}); + return atom_pairs; +} + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/abfs-vector3_order.cpp b/ABACUS.1.0.0/source/src_lcao/abfs-vector3_order.cpp new file mode 100644 index 0000000000..4400d77a0f --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/abfs-vector3_order.cpp @@ -0,0 +1,26 @@ +#include "abfs-vector3_order.h" + +template<> +bool operator< ( const Abfs::Vector3_Order &v1, const Abfs::Vector3_Order &v2 ) +{ + constexpr double threshold = 1E-8; + if ( v1.x < v2.x - threshold ) return true; + else if ( v1.x > v2.x + threshold ) return false; + if ( v1.y < v2.y - threshold ) return true; + else if ( v1.y > v2.y + threshold ) return false; + if ( v1.z < v2.z - threshold ) return true; + else if ( v1.z > v2.z + threshold ) return false; + return false; +} + +template<> +bool operator< ( const Abfs::Vector3_Order &v1, const Abfs::Vector3_Order &v2 ) +{ + if ( v1.x < v2.x ) return true; + else if ( v1.x > v2.x ) return false; + if ( v1.y < v2.y ) return true; + else if ( v1.y > v2.y ) return false; + if ( v1.z < v2.z ) return true; + else if ( v1.z > v2.z ) return false; + return false; +} \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/abfs-vector3_order.h b/ABACUS.1.0.0/source/src_lcao/abfs-vector3_order.h new file mode 100644 index 0000000000..c2c5648dca --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/abfs-vector3_order.h @@ -0,0 +1,72 @@ +//========================================================== +// AUTHOR : Peize Lin +// DATE : 2017-01-10 +//========================================================== + +#ifndef ABFS_VECTOR3_ORDER_H +#define ABFS_VECTOR3_ORDER_H + +#include "src_lcao/abfs.h" + +#include +#include + +template class Abfs::Vector3_Order: public Vector3 +{ +public: + Vector3_Order(const Vector3 &v):Vector3(v){} + Vector3_Order(const T &x,const T &y,const T &z):Vector3(x,y,z){} + Vector3_Order()=default; +}; + +template +bool operator< ( const Abfs::Vector3_Order &v1, const Abfs::Vector3_Order &v2 ); + +/* +template +bool operator> ( const Abfs::Vector3_Order &v1, const Abfs::Vector3_Order &v2 ) +{ + if( v1.x>v2.x ) return true; + else if ( v1.xv2.y ) return true; + else if ( v1.yv2.z ) return true; + else if ( v1.z +bool operator<= ( const Abfs::Vector3_Order &v1, const Abfs::Vector3_Order &v2 ) +{ + if( v1.xv2.x ) return false; + if( v1.yv2.y ) return false; + if( v1.zv2.z ) return false; + return true; +} + +template +bool operator>= ( const Abfs::Vector3_Order &v1, const Abfs::Vector3_Order &v2 ) +{ + if( v1.x>v2.x ) return true; + else if ( v1.xv2.y ) return true; + else if ( v1.yv2.z ) return true; + else if ( v1.z +Abfs::Vector3_Order operator% ( const Abfs::Vector3_Order &v1, const Abfs::Vector3_Order &v2 ) +{ + auto mod = [](const int i, const int n){ return (i%n+3*n/2)%n-n/2; }; // [-n/2,n/2] +// auto mod = [](const int i, const int n){ return (i%n+n)%n; }; // [0,n] + return Abfs::Vector3_Order{ mod(v1.x,v2.x), mod(v1.y,v2.y), mod(v1.z,v2.z) }; +} + +#endif // ABFS_VECTOR3_ORDER_H \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/abfs.cpp b/ABACUS.1.0.0/source/src_lcao/abfs.cpp new file mode 100644 index 0000000000..3ec1c2b826 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/abfs.cpp @@ -0,0 +1,518 @@ +#include "abfs.h" +#include "abfs-vector3_order.h" +#include "abfs-template.h" + +#include "exx_abfs-inverse_matrix_double.h" +#include "src_pw/global.h" +#include "src_global/global_function.h" + +#include // Peize Lin test +#include // Peize Lin test +#include "src_external/src_test/src_global/matrix-test.h" // Peize Lin test + +map,shared_ptr>>> Abfs::cal_Cs( + const set &atom_centres, + const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, + const Exx_Abfs::Matrix_Orbs21 &m_abfslcaos_lcaos, + const Element_Basis_Index::IndexLNM &index_abfs, + const Element_Basis_Index::IndexLNM &index_lcaos, + const double threshold, + map,weak_ptr>>> &Cws, + map,weak_ptr>>> &Vws ) +{ + TITLE("Abfs","cal_Cs"); + + // pre-cal Vws on same atom, speed up DPcal_V() in DPcal_C() + vector> Vs_same_atom(ucell.ntype); + for(size_t it=0; it!=ucell.ntype; ++it) + Vs_same_atom[it] = DPcal_V( it,it,{0,0,0}, m_abfs_abfs, index_abfs, 0,true,Vws ); + + map,shared_ptr>>> Cs; + for( const int iat1 : atom_centres ) + { + const size_t it1 = ucell.iat2it[iat1]; + const size_t ia1 = ucell.iat2ia[iat1]; + const Vector3_Order tau1( ucell.atoms[it1].tau[ia1] ); + + const map>> adjs = get_adjs(iat1); + for( const auto & atom2 : adjs ) + { + const int iat2 = atom2.first; + const int it2 = ucell.iat2it[iat2]; + const int ia2 = ucell.iat2ia[iat2]; + const Vector3_Order tau2( ucell.atoms[it2].tau[ia2] ); + for( const Vector3 &box2 : atom2.second ) + { +//cout<<"cal_Cs\t"<>> + Abfs::cal_Vps( + const set> &atom_pairs, + const vector> &Coulomb_potential_boxes, + const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, + const Element_Basis_Index::Index &index_abfs, + map,shared_ptr>>> &Vs, + map,weak_ptr>>> &Vws ) +{ + map>> Vps; + + for( const pair & atom_pair : atom_pairs ) + { + const size_t iat1 = atom_pair.first; + const size_t iat2 = atom_pair.second; + const size_t it1 = ucell.iat2it[iat1]; + const size_t ia1 = ucell.iat2ia[iat1]; + const size_t it2 = ucell.iat2it[iat2]; + const size_t ia2 = ucell.iat2ia[iat2]; + const Vector3_Order tau1 = ucell.atoms[it1].tau[ia1]; + const Vector3_Order tau2 = ucell.atoms[it2].tau[ia2]; + + for( const Vector3_Order &box2 : Coulomb_potential_boxes ) + { + const vector> Vs_tmp = DPcal_V( it1, it2, -tau1+tau2+(box2*ucell.latvec), m_abfs_abfs, index_abfs, Vws ); + Vs[iat1][iat2][box2] = Vs_tmp[0]; Vs[iat2][iat1][-box2] = Vs_tmp[1]; + } + + Vps[iat1][iat2] = make_shared( Vs[iat1][iat2][{0,0,0}]->nr, Vs[iat1][iat2][{0,0,0}]->nc ); + for( const Vector3_Order &box2 : Coulomb_potential_boxes ) + *Vps[iat1][iat2] += *Vs[iat1][iat2][box2]; + } + return Vps; +} +*/ + +/* +map,shared_ptr>>> + Abfs::cal_Vps( + const vector> &atom_pairs, + const vector> &Coulomb_potential_boxes, + const vector> &Born_von_Karman_boxes, + const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, + const Element_Basis_Index::IndexLNM &index_abfs, + map,shared_ptr>>> &Vs, + map,weak_ptr>>> &Vws ) +{ + TITLE("Abfs","cal_Vps"); + + map,shared_ptr>>> Vps; + + for( const pair & atom_pair : atom_pairs ) + { + const size_t iat1 = atom_pair.first; + const size_t iat2 = atom_pair.second; + const size_t it1 = ucell.iat2it[iat1]; + const size_t ia1 = ucell.iat2ia[iat1]; + const size_t it2 = ucell.iat2it[iat2]; + const size_t ia2 = ucell.iat2ia[iat2]; + const Vector3_Order tau1 = ucell.atoms[it1].tau[ia1]; + const Vector3_Order tau2 = ucell.atoms[it2].tau[ia2]; + + for( const Vector3_Order &box2 : Coulomb_potential_boxes ) + { +cout<<"cal_Vs\t"<> Vs_tmp = DPcal_V( it1, it2, -tau1+tau2+(box2*ucell.latvec), m_abfs_abfs, index_abfs, Vws ); + Vs[iat1][iat2][box2] = Vs_tmp[0]; Vs[iat2][iat1][-box2] = Vs_tmp[1]; + } + + vector Vkps( kv.nks/NSPIN, {Vs[iat1][iat2][{0,0,0}]->nr, Vs[iat1][iat2][{0,0,0}]->nc} ); + for( size_t ik=0; ik!=kv.nks/NSPIN; ++ik ) + for( const Vector3_Order &box2 : Coulomb_potential_boxes ) + Vkps[ik] += static_cast(*Vs[iat1][iat2][box2]) * exp(-TWO_PI*IMAG_UNIT*(kv.kvec_c[ik]*(box2*ucell.latvec))); + + for( const Vector3_Order &box2 : Born_von_Karman_boxes ) + { + ComplexMatrix Vps_tmp ( Vkps[0].nr, Vkps[0].nc ); + for( size_t ik=0; ik!=kv.nks/NSPIN; ++ik ) + Vps_tmp += Vkps[ik] * kv.wk[ik]*(0.5*NSPIN) * exp(TWO_PI*IMAG_UNIT*(kv.kvec_c[ik]*(box2*ucell.latvec))); + Vps[iat1][iat2][box2] = make_shared( Vps_tmp.real() ); + } + } + return Vps; +} +*/ + +map,shared_ptr>>> Abfs::cal_Vs( + const vector> &atom_pairs, + const vector> &Coulomb_potential_boxes, + const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, + const Element_Basis_Index::IndexLNM &index_abfs, + const int rmesh_times, + const double threshold, + map,weak_ptr>>> &Vws ) +{ + TITLE("Abfs","cal_Vs"); + map,shared_ptr>>> Vs; + for( const pair & atom_pair : atom_pairs ) + { + const size_t iat1 = atom_pair.first; + const size_t iat2 = atom_pair.second; + const size_t it1 = ucell.iat2it[iat1]; + const size_t ia1 = ucell.iat2ia[iat1]; + const size_t it2 = ucell.iat2it[iat2]; + const size_t ia2 = ucell.iat2ia[iat2]; + const Vector3_Order tau1 = ucell.atoms[it1].tau[ia1]; + const Vector3_Order tau2 = ucell.atoms[it2].tau[ia2]; + + for( const Vector3_Order &box2 : Coulomb_potential_boxes ) + { + const Vector3_Order delta_R = -tau1+tau2+(box2*ucell.latvec); + if( delta_R.norm()*ucell.lat0 > ORB.Phi[it1].getRcut()*rmesh_times + ORB.Phi[it2].getRcut() ) + continue; +//cout<<"cal_Vs\t"<,shared_ptr> Abfs::cal_mps( + const Abfs::Vector3_Order &Born_von_Karman_period, + const map,shared_ptr> &ms ) +{ + map< Vector3_Order, vector> > indexs; + for( const auto & m : ms ) + { + const Vector3_Order & box = m.first; + indexs[box%Born_von_Karman_period].push_back(box); + } + + #if TEST_EXX_LCAO==1 + { + static int istep=0; + ofstream ofs( "mps_index_"+TO_STRING(iat1)+"_"+TO_STRING(iat2)+"_"+TO_STRING(istep++) ); + for( const auto index : indexs ) + { + ofs< & box : index.second ) + ofs<<"\t"<,shared_ptr> mps; + for( const auto & index : indexs ) + { + const Vector3_Order & boxp = index.first; + assert(index.second.size()>=1); + if( index.second.size()==1 ) + mps[boxp] = ms.at(index.second[0]); + else + { + mps[boxp] = make_shared(); + *mps[boxp] = *ms.at(index.second[0]); + for( size_t i=1; i,shared_ptr>>> Abfs::cal_mps( + const Abfs::Vector3_Order &Born_von_Karman_period, + const map,shared_ptr>>> &ms ) +{ + TITLE("Abfs","cal_mps"); + map,shared_ptr>>> mps; + for( const auto & m1s : ms ) + for( const auto & m12s : m1s.second ) + mps[m1s.first][m12s.first] = cal_mps( Born_von_Karman_period, m12s.second ); + return mps; +} + + +shared_ptr Abfs::DPcal_C( + const size_t &it1, + const size_t &it2, + const Vector3_Order &R, + const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, + const Exx_Abfs::Matrix_Orbs21 &m_abfslcaos_lcaos, + const Element_Basis_Index::IndexLNM &index_abfs, + const Element_Basis_Index::IndexLNM &index_lcaos, + const double threshold, + const bool writable, + map,weak_ptr>>> &Cws, + map,weak_ptr>>> &Vws ) +{ + // Attention: + // 在计算 C[it1,it1,0][it2,R] åŽï¼Œé¢å¤–计算 C[it2,it2,0][it1,-R] 几乎ä¸è€—时。 + // if ä»…ä¿å­˜ C[it1,it1,0][it2,R],ä¸ä¿å­˜ C[it2,it2,0][it1,-R]: + // if C[it2,it2,0][it1,-R] 在本核上亦需计算: + // 浪费时间é‡ç®—一é + // if C[it2,it2,0][it1,-R] 在本核上ä¸éœ€è®¡ç®—: + // 好 + // if åŒæ—¶ä¿å­˜ C[it1,it1,0][it2,R]ã€C[it2,it2,0][it1,-R]: + // if C[it2,it2,0][it1,-R] 在本核上亦需计算: + // 好 + // if C[it2,it2,0][it1,-R] 在本核上ä¸éœ€è®¡ç®—: + // 浪费空间(å¯åœ¨ç®—完全部CsåŽæ ¹æ®éœ€è¦åˆ é™¤æ— éœ€çš„Cs,释放空间?) + // æ ¹æ®åŽç»­æƒ…况选择æƒè¡¡ã€‚ + +// TITLE("Abfs","DPcal_C"); + const weak_ptr * const Cws_ptr = static_cast * const>( MAP_EXIST( Cws, it1, it2, R ) ); + if( Cws_ptr && !Cws_ptr->expired() ) + return Cws[it1][it2][R].lock(); + else + { +//cout<<"DPcal_C\t"<(0,0,0)==R) && (it1==it2) ) + { + const shared_ptr A = + make_shared( m_abfslcaos_lcaos.cal_overlap_matrix( it1,it2,0,0,index_abfs,index_lcaos,index_lcaos,Exx_Abfs::Matrix_Orbs21::Matrix_Order::A2B_A1 ) ); + const shared_ptr V = DPcal_V(it1,it2,{0,0,0},m_abfs_abfs,index_abfs,0,false,Vws); + const shared_ptr L = cal_I(V); + shared_ptr C = make_shared( 0.5 * *A * *L ); + if(C->absmax()<=threshold) C->create(0,0); + if(writable) Cws[it1][it2][R] = C; + return C; + } + else + { + const vector> A = + { make_shared( m_abfslcaos_lcaos.cal_overlap_matrix(it1,it2,0,R ,index_abfs,index_lcaos,index_lcaos,Exx_Abfs::Matrix_Orbs21::Matrix_Order::A2B_A1) ) , + make_shared( m_abfslcaos_lcaos.cal_overlap_matrix(it2,it1,0,-R,index_abfs,index_lcaos,index_lcaos,Exx_Abfs::Matrix_Orbs21::Matrix_Order::BA2_A1) ) }; + + const shared_ptr V_00 = DPcal_V(it1,it1,{0,0,0},m_abfs_abfs,index_abfs,0,false,Vws); + const shared_ptr V_01 = DPcal_V(it1,it2,R, m_abfs_abfs,index_abfs,0,false,Vws); + const shared_ptr V_10 = DPcal_V(it2,it1,-R, m_abfs_abfs,index_abfs,0,false,Vws); + const shared_ptr V_11 = DPcal_V(it2,it2,{0,0,0},m_abfs_abfs,index_abfs,0,false,Vws); + const vector>> V = + {{ V_00, V_01 }, + { V_10, V_11 }}; + + const vector>> L = cal_I(V); + + shared_ptr C = make_shared( *A[0] * *L[0][0] + *A[1] * *L[1][0] ); + if(C->absmax()<=threshold) C->create(0,0); + if(writable) Cws[it1][it2][R] = C; + return C; + } + } +} + +shared_ptr Abfs::DPcal_V( + const size_t &it1, + const size_t &it2, + const Vector3_Order &R, + const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, + const Element_Basis_Index::IndexLNM &index_abfs, + const double threshold, + const bool writable, + map,weak_ptr>>> &Vws) +{ +// TITLE("Abfs","DPcal_V"); + + const weak_ptr * const Vws12_ptr = static_cast * const>( MAP_EXIST( Vws, it1, it2, R ) ); + const weak_ptr * const Vws21_ptr = static_cast * const>( MAP_EXIST( Vws, it2, it1, -R ) ); + if( Vws12_ptr && !Vws12_ptr->expired() ) + return Vws12_ptr->lock(); + else if( Vws21_ptr && !Vws21_ptr->expired() ) + { + shared_ptr VT = make_shared( transpose(*Vws21_ptr->lock()) ); + if(VT->absmax()<=threshold) VT->create(0,0); + if(writable) Vws[it1][it2][R] = VT; + return VT; + } + else + { +//cout<<"DPcal_V\t"< V = make_shared( m_abfs_abfs.cal_overlap_matrix(it1,it2,0,R,index_abfs,index_abfs) ); + if(V->absmax()<=threshold) V->create(0,0); + if(writable) Vws[it1][it2][R] = V; + return V; + } +} + +map>> Abfs::get_adjs( const size_t &iat ) +{ +// TITLE("Abfs","get_adjs"); + const int it = ucell.iat2it[iat]; + const int ia = ucell.iat2ia[iat]; + const Vector3 &tau = ucell.atoms[it].tau[ia]; + + map>> adjs; + GridD.Find_atom( tau, it, ia ); + for( int ad=0; ad box_ad = GridD.getBox(ad); + const Vector3 tau_ad = GridD.getAdjacentTau(ad); + + if( (tau-tau_ad).norm()*ucell.lat0 < ORB.Phi[it].getRcut()+ORB.Phi[it_ad].getRcut() ) + adjs[iat_ad].push_back(box_ad); + } + return adjs; +} + +vector>>> Abfs::get_adjs() +{ + vector>>> adjs(ucell.nat); + for( size_t iat=0; iat!=ucell.nat; ++iat ) + adjs[iat] = Abfs::get_adjs(iat); + return adjs; +} + +/* +set> Abfs::get_H_pairs_core( const vector> &atom_pairs ) +{ + TITLE("Exx_Lcao","allocate_Hexx"); + + set> H_atom_pairs_core; + for( const pair & atom_pair : atom_pairs ) + { + const size_t iat1 = atom_pair.first; + const size_t iat2 = atom_pair.second; + + const map>> adj1s = Abfs::get_adjs(iat1); + const map>> adj2s = Abfs::get_adjs(iat2); + + H_atom_pairs_core.insert({iat1,iat2}); + for( const auto & atom3 : adj1s ) + { + const size_t iat3 = atom3.first; + H_atom_pairs_core.insert({iat3,iat2}); + for( const auto & atom4 : adj2s ) + { + const size_t iat4 = atom4.first; + H_atom_pairs_core.insert({iat1,iat4}); + H_atom_pairs_core.insert({iat3,iat4}); + } + } + } + return H_atom_pairs_core; +} +*/ + +set> Abfs::get_H_pairs_core( const vector> &atom_pairs ) +{ + TITLE("Exx_Lcao","allocate_Hexx"); + + const vector>>> adjs = Abfs::get_adjs(); + + auto get_set_adjs = [&adjs]( const set &as ) -> set + { + set aRs; + for( const size_t a : as ) + for( const auto &aR : adjs[a] ) + aRs.insert(aR.first); + return aRs; + }; + + // {(0,1),(3,5),(0,4),(7,8),(6,5)} + const vector> & a1_a2 = atom_pairs; + + // => {1:{0}, 5:{3,6}, 4:{0}, 8:{7}} + map> a2_a1s; + for( const auto & a1_a2_i : a1_a2 ) + a2_a1s[ a1_a2_i.second ].insert( a1_a2_i.first ); + + // => {{0}:{1,4}, {3,6}:{5}, {7}:{8}} + map,set> a1s_a2s; + for( const auto & a2_a1s_i : a2_a1s ) + a1s_a2s[ a2_a1s_i.second ].insert( a2_a1s_i.first ); + a2_a1s.clear(); + + // => {R(0):{1,4}, R(3)UR(6):{5}, R(7):{8}} + // imaging R(0)==R(3)UR(6): + // => {R(0):{1,4,5}, R(7):{8}} + map,set> a1Rs_a2s; + for( const auto & a1s_a2s_i : a1s_a2s ) + { + const set a1Rs_i = get_set_adjs(a1s_a2s_i.first); + a1Rs_a2s[a1Rs_i].insert(a1s_a2s_i.second.begin(), a1s_a2s_i.second.end()); + } + a1s_a2s.clear(); + + // => {R(0):R(1)UR(4)UR(5), R(7):R(8)} + set> a1Rs_a2Rs; + for( const auto & a1Rs_a2s_i : a1Rs_a2s ) + { + const set a2Rs_i = get_set_adjs(a1Rs_a2s_i.second); + for( const size_t a1R_i : a1Rs_a2s_i.first ) + for( const size_t a2R_i : a2Rs_i ) + a1Rs_a2Rs.insert({a1R_i,a2R_i}); + } + a1Rs_a2s.clear(); + + return a1Rs_a2Rs; +} + +shared_ptr Abfs::cal_I( const shared_ptr &m ) +{ +// TITLE("Abfs","cal_I1"); + Exx_Abfs::Inverse_Matrix_Double I; + I.init( m->nc ); + I.input( m ); + + #if TEST_EXX_LCAO==1 + ofstream ofs("I.dat",ofstream::app); + ofs<<"@"< m_new = make_shared(m->nr,m->nc); + I.output( m_new ); + return m_new; +} + +vector>> Abfs::cal_I( const vector>> &ms ) +{ +// TITLE("Abfs","cal_I4"); + Exx_Abfs::Inverse_Matrix_Double I; + I.init( ms[0][0]->nc + ms[0][1]->nc ); + I.input( ms[0][0], ms[0][1], ms[1][0], ms[1][1] ); + + #if TEST_EXX_LCAO==1 + ofstream ofs("I.dat",ofstream::app); + ofs<<"@"<>> ms_new( 2, vector>(2) ); + for( size_t i=0; i!=2; ++i ) + for(size_t j=0; j!=2; ++j ) + ms_new[i][j] = make_shared( ms[i][j]->nr, ms[i][j]->nc ); + I.output( ms_new[0][0], ms_new[0][1], ms_new[1][0], ms_new[1][1] ); + return ms_new; +} diff --git a/ABACUS.1.0.0/source/src_lcao/abfs.h b/ABACUS.1.0.0/source/src_lcao/abfs.h new file mode 100644 index 0000000000..b19f329d0f --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/abfs.h @@ -0,0 +1,96 @@ +#ifndef ABFS_H +#define ABFS_H + +#include "src_global/vector3.h" +#include "src_global/matrix.h" +#include "src_lcao/exx_abfs.h" + +#include +#include +#include +#include + +class Abfs +{ +public: + + template class Vector3_Order; + + // Cs[iat1][iat2][box2] + // Cws[it1,it1,0][it2,R] + // Vws[it1,0][it2,R] + static map,shared_ptr>>> cal_Cs( + const set &atom_centres, + const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, + const Exx_Abfs::Matrix_Orbs21 &m_abfslcaos_lcaos, + const Element_Basis_Index::IndexLNM &index_abfs, + const Element_Basis_Index::IndexLNM &index_lcaos, + const double threshold, + map,weak_ptr>>> &Cws, + map,weak_ptr>>> &Vws ); + + // Vs[iat1][iat2][box2] + // Vws[it1,0][it2,R] + static map,shared_ptr>>> cal_Vs( + const vector> &atom_pairs, + const vector> &Coulomb_potential_boxes, + const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, + const Element_Basis_Index::IndexLNM &index_abfs, + const int rmesh_times, + const double threshold, + map,weak_ptr>>> &Vws ); + + // use matrixes ms to get period mps + static map,shared_ptr> + cal_mps( + const Abfs::Vector3_Order &Born_von_Karman_period, + const map,shared_ptr> &ms ); + // mps[iat1][iat2][box2] + static map,shared_ptr>>> + cal_mps( + const Abfs::Vector3_Order &Born_von_Karman_period, + const map,shared_ptr>>> &ms ); + + // C[it1,it1,0][it2,R] + static shared_ptr DPcal_C( + const size_t &it1, + const size_t &it2, + const Vector3_Order &R, // unit: ucell.lat0 + const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, + const Exx_Abfs::Matrix_Orbs21 &m_abfslcaos_lcaos, + const Element_Basis_Index::IndexLNM &index_abfs, + const Element_Basis_Index::IndexLNM &index_lcaos, + const double threshold, + const bool writable, + map,weak_ptr>>> &Cws, + map,weak_ptr>>> &Vws ); + + // V[it1,0][it2,R] + static shared_ptr DPcal_V( + const size_t &it1, + const size_t &it2, + const Vector3_Order &R, // unit: ucell.lat0 + const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, + const Element_Basis_Index::IndexLNM &index_abfs, + const double threshold, + const bool writable, + map,weak_ptr>>> &Vws ); + +// static map>> get_adjs( const size_t &T, const Vector3 &tau_cartesian ); + static map>> get_adjs( const size_t &iat ); + static vector>>> get_adjs(); + static set> get_H_pairs_core( const vector> &atom_pairs ); + + static shared_ptr cal_I( const shared_ptr &m ); + static vector>> cal_I( const vector>> &ms ); + + template + static void delete_empty_ptrs( map>>> &ptrs ); + template + static void delete_threshold_ptrs( map>>> &ptrs, const double threshold); + + template + static vector> get_atom_pair(const map> &m); +}; + +#endif // ABFS_H \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/build_st_pw.cpp b/ABACUS.1.0.0/source/src_lcao/build_st_pw.cpp index b880c229ce..acdffb62df 100644 --- a/ABACUS.1.0.0/source/src_lcao/build_st_pw.cpp +++ b/ABACUS.1.0.0/source/src_lcao/build_st_pw.cpp @@ -90,10 +90,10 @@ void Build_ST_pw::set_ST(const int &ik, const char& dtype) v += conj(wf.wanf2[ik](mu, ig)) * wf.wanf2[ik](nu, ig) * wf.g2kin[ig]; } if(NONCOLIN) - for (int ig = 0; ig < kv.ngk[ik]; ig++) - { - v += conj(wf.wanf2[ik](mu, ig + wf.npwx)) * wf.wanf2[ik](nu, ig + wf.npwx) * wf.g2kin[ig]; - } + for (int ig = 0; ig < kv.ngk[ik]; ig++) + { + v += conj(wf.wanf2[ik](mu, ig + wf.npwx)) * wf.wanf2[ik](nu, ig + wf.npwx) * wf.g2kin[ig]; + } // cout << "i=" << i << " j=" << j << " v=" << v << endl; //----------------------------------------- @@ -130,49 +130,50 @@ void Build_ST_pw::set_local(const int &ik) for(int i=0; i v = ZERO; for(int ig=0; ig v = ZERO; + for(int ig=0; ig* psi_down = new complex [npw]; diff --git a/ABACUS.1.0.0/source/src_lcao/center2_orb-orb22.cpp b/ABACUS.1.0.0/source/src_lcao/center2_orb-orb22.cpp index 91d71383d9..778108d61a 100644 --- a/ABACUS.1.0.0/source/src_lcao/center2_orb-orb22.cpp +++ b/ABACUS.1.0.0/source/src_lcao/center2_orb-orb22.cpp @@ -22,8 +22,6 @@ Center2_Orb::Orb22::Orb22( void Center2_Orb::Orb22::init_radial_table() { - TITLE("Center2_Orb::Orb22::init_radial_table"); - const Numerical_Orbital_Lm & nB_short = (nB1.getNr()<=nB2.getNr()) ? nB1 : nB2; vector nB_tmp(nB_short.getNr()); @@ -31,7 +29,7 @@ void Center2_Orb::Orb22::init_radial_table() { nB_tmp[ir] = nB1.getPsi(ir) * nB2.getPsi(ir); } - + const int LB1 = nB1.getL(); const int LB2 = nB2.getL(); for( int LB = abs(LB1-LB2); LB<=LB1+LB2; ++LB) @@ -63,8 +61,6 @@ void Center2_Orb::Orb22::init_radial_table() void Center2_Orb::Orb22::init_radial_table( const set &radials ) { - TITLE("Center2_Orb::Orb22::init_radial_table"); - const Numerical_Orbital_Lm & nB_short = (nB1.getNr()<=nB2.getNr()) ? nB1 : nB2; vector nB_tmp(nB_short.getNr()); @@ -106,8 +102,6 @@ double Center2_Orb::Orb22::cal_overlap( const Vector3 &RA, const Vector3 &RB, const int &mA1, const int &mA2, const int &mB1, const int &mB2) const { - TITLE("Center2_Orb::Orb22::cal_overlap"); - const int LB1 = nB1.getL(); const int LB2 = nB2.getL(); diff --git a/ABACUS.1.0.0/source/src_lcao/center2_orb-orb22_ccp.cpp b/ABACUS.1.0.0/source/src_lcao/center2_orb-orb22_ccp.cpp new file mode 100644 index 0000000000..f80f0cfa4f --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/center2_orb-orb22_ccp.cpp @@ -0,0 +1,48 @@ +#include "center2_orb-orb22_ccp.h" +#include "conv_coulomb_pot.h" +#include "conv_coulomb_pot-inl.h" + +void Center2_Orb::Orb22_Ccp::init_radial_table() +{ + vector nB_tmp(nB1.getNr()); + for( size_t ir=0; ir!=nB_tmp.size(); ++ir) + { + nB_tmp[ir] = nB1.getPsi(ir) * nB2.getPsi(ir); + } + const int LB1 = nB1.getL(); + const int LB2 = nB2.getL(); + for( int LB = abs(LB1-LB2); LB<=LB1+LB2; ++LB) + { + if( (LB-std::abs(LB1-LB2))%2==1 ) // if LA+LB-LAB == odd, then Gaunt_Coefficients = 0 + continue; + +//cout<<"LB\t"< +void Conv_Coulomb_Pot::cal_orbs_ccp( + const T & orbs, + T & orbs_ccp, + size_t rmesh_times, + size_t kmesh_times ) +{ + orbs_ccp.resize(orbs.size()); + for( int i=0; i!=orbs.size(); ++i ) + { + cal_orbs_ccp( orbs[i], orbs_ccp[i], rmesh_times, kmesh_times ); + } +} + +template<> +void Conv_Coulomb_Pot::cal_orbs_ccp( + const Numerical_Orbital_Lm & orbs, + Numerical_Orbital_Lm & orbs_ccp, + size_t rmesh_times, + size_t kmesh_times ); + +#endif diff --git a/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot.cpp b/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot.cpp new file mode 100644 index 0000000000..ef87663767 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot.cpp @@ -0,0 +1,123 @@ +#include "conv_coulomb_pot.h" +#include "conv_coulomb_pot-inl.h" +#include "src_global/mathzone.h" +#include "src_global/constants.h" +#include "src_global/global_function.h" + +#include "src_external/src_test/test_function.h" + +Conv_Coulomb_Pot::Conv_Coulomb_Pot(const Numerical_Orbital_Lm &orb_in) + :orb(orb_in) +{ + conv_coulomb_pot.resize(orb.getNr()); +} + + +double Conv_Coulomb_Pot::get_conv_coulomb_pot(const size_t &ir) const +{ + if( ir < conv_coulomb_pot.size() ) + { + return conv_coulomb_pot[ir]; + } + else + { + double r_radial = get_r_radial_outofrange( ir ); + return conv_coulomb_pot_extra / pow(r_radial,orb.getL()+1); + } +} + + +void Conv_Coulomb_Pot::cal_conv_coulomb_pot() +{ + vector tmp_func( orb.getNr() ); + vector tmp_integral( orb.getNr() ); + + // \int_{r'=0}^{r} dr' f(r') * r'^{L+2} / r^{L+1} + for( size_t ir=0; ir!=orb.getNr(); ++ir ) + { + tmp_func[ir] = orb.getPsi(ir) * pow( orb.getRadial(ir), orb.getL()+2 ); + } + Mathzone::Simpson_Integral_0toall( orb.getNr(), VECTOR_TO_PTR(tmp_func), orb.getRab(), VECTOR_TO_PTR(tmp_integral) ); + conv_coulomb_pot[0]=0; + for( size_t ir=1; ir!=orb.getNr(); ++ir ) + { + conv_coulomb_pot[ir] = tmp_integral[ir] / pow( orb.getRadial(ir), orb.getL()+1 ); + } + + // \int_{r'=0}^{Rcut} dr' f(r') * r'^{L+2} + conv_coulomb_pot_extra = tmp_integral.back(); + + // \int_{r'=r}^{+\infty} dr' f(r') * r^{L} / r'^{L-1} + tmp_func[0]=0; + for( size_t ir=1; ir!=orb.getNr(); ++ir ) + { + tmp_func[ir] = orb.getPsi(ir) / pow( orb.getRadial(ir), orb.getL()-1 ); + } + Mathzone::Simpson_Integral_alltoinf( orb.getNr(), VECTOR_TO_PTR(tmp_func), orb.getRab(), VECTOR_TO_PTR(tmp_integral) ); + for( size_t ir=0; ir!=orb.getNr(); ++ir ) + { + conv_coulomb_pot[ir] += tmp_integral[ir] * pow( orb.getRadial(ir), orb.getL() ); + } + + // 4pi/(2L+1) + const double coefficient = 4*PI/(2*orb.getL()+1); + for( size_t ir=0; ir!=orb.getNr(); ++ir ) + { + conv_coulomb_pot[ir] *= coefficient; + } + conv_coulomb_pot_extra *= coefficient; +} + + +template<> +void Conv_Coulomb_Pot::cal_orbs_ccp( + const Numerical_Orbital_Lm & orbs, + Numerical_Orbital_Lm & orbs_ccp, + size_t rmesh_times, + size_t kmesh_times ) +{ + Conv_Coulomb_Pot ccp( orbs ); + ccp.cal_conv_coulomb_pot(); + + const size_t mesh = (rmesh_times * orbs.getNr()) | 1; // mesh must be odd for simspon integral + vector psi( mesh ); + for( size_t ir=0; ir!=mesh ; ++ir) + { + psi[ir] = ccp.get_conv_coulomb_pot(ir); + } + + vector rab( mesh ); + for( size_t ir=0; ir!=mesh ; ++ir) + { + if( ir r_radial( mesh ); + for( size_t ir=0; ir!=mesh ; ++ir) + { + if( ir +using std::vector; + +#include "numerical_orbital_lm.h" + +// out of conv_coulomb_pot.size(), imagine all rab(i.e. dr) are equal to rab[conv_coulomb_pot.size()-1] +class Conv_Coulomb_Pot +{ +public: + Conv_Coulomb_Pot(const Numerical_Orbital_Lm &orb_in); + + const vector &get_conv_coulomb_pot() const { return conv_coulomb_pot; } + double get_conv_coulomb_pot(const size_t &ir) const; + + void cal_conv_coulomb_pot(); + +public: + // only for > ... > + // the number of "vector" can be 0 to any + template< typename T > + static void cal_orbs_ccp( const T & orb, T & orb_ccp, size_t rmesh_times=1, size_t kmesh_times=1 ); + +private: + const Numerical_Orbital_Lm &orb; + vector conv_coulomb_pot; + double conv_coulomb_pot_extra; + + inline double get_r_radial_outofrange( size_t ir ) const; +}; + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k-template.h b/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k-template.h new file mode 100644 index 0000000000..f720326134 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k-template.h @@ -0,0 +1,30 @@ +#ifndef CONV_COULOMB_POT_K_TEMPLATE_H +#define CONV_COULOMB_POT_K_TEMPLATE_H + +#include "conv_coulomb_pot_k.h" +#include +#include + +template< typename T > +T Conv_Coulomb_Pot_K::cal_orbs_ccp( + const T & orbs, + const Ccp_Type &ccp_type, + const double rmesh_times, + const double omega, + const double Rcut) +{ + T orbs_ccp(orbs.size()); + for( size_t i=0; i!=orbs.size(); ++i ) + orbs_ccp[i] = cal_orbs_ccp( orbs[i], ccp_type, rmesh_times, omega, Rcut ); + return orbs_ccp; +} + +extern template +Numerical_Orbital_Lm Conv_Coulomb_Pot_K::cal_orbs_ccp( + const Numerical_Orbital_Lm & orbs, + const Ccp_Type &ccp_type, + const double rmesh_times, + const double omega, + const double Rcut); + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.cpp b/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.cpp new file mode 100644 index 0000000000..b6d2984722 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.cpp @@ -0,0 +1,75 @@ +#include "conv_coulomb_pot_k.h" +#include "src_global/constants.h" +#include "src_lcao/numerical_orbital_lm.h" + +std::vector Conv_Coulomb_Pot_K::cal_psi_ccp( const std::vector & psif ) +{ + std::vector psik2_ccp(psif.size()); + for( size_t ik=0; ik Conv_Coulomb_Pot_K::cal_psi_hse( + const std::vector & psif, + const std::vector & k_radial, + const double omega) +{ + std::vector psik2_ccp(psif.size()); + for( size_t ik=0; ik +Numerical_Orbital_Lm Conv_Coulomb_Pot_K::cal_orbs_ccp( + const Numerical_Orbital_Lm & orbs, + const Ccp_Type &ccp_type, + const double rmesh_times, + const double omega, + const double Rcut) +{ + std::vector psik2_ccp; + switch(ccp_type) + { + case Ccp_Type::Ccp: + psik2_ccp = cal_psi_ccp( orbs.get_psif() ); break; + case Ccp_Type::Hse: + psik2_ccp = cal_psi_hse( orbs.get_psif(), orbs.get_k_radial(), omega ); break; + default: + throw( TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__) ); break; + } + + const double dr = orbs.get_rab().back(); + const int Nr = (static_cast(orbs.getNr()*rmesh_times)) | 1; + std::vector rab(Nr); + for( size_t ir=0; ir r_radial(Nr); + for( size_t ir=0; ir +#include + +class Conv_Coulomb_Pot_K +{ +public: + + enum class Ccp_Type{ Ccp, Hse }; + + template static T cal_orbs_ccp( + const T & orbs, + const Ccp_Type &ccp_type, + const double rmesh_times = 1, + const double omega = std::numeric_limits::min(), + const double Rcut = std::numeric_limits::max()); + +private: + + static std::vector cal_psi_ccp( const std::vector & psif ); + + static std::vector cal_psi_hse( + const std::vector & psif, + const std::vector & k_radial, + const double omega); +}; + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/diago_lcao_matrix.cpp b/ABACUS.1.0.0/source/src_lcao/diago_lcao_matrix.cpp index 81432a47dc..5747153ce9 100644 --- a/ABACUS.1.0.0/source/src_lcao/diago_lcao_matrix.cpp +++ b/ABACUS.1.0.0/source/src_lcao/diago_lcao_matrix.cpp @@ -168,6 +168,7 @@ void Diago_LCAO_Matrix::using_HPSEPS_complex(const int &ik, complex** wf ofs_running << setprecision(6); //LiuXh, 2017-03-21 ParaO.diago_complex_begin(ik, wfc, wfc_2d, LM.Hloc2, LM.Sloc2, wf.ekb[ik]); + //added by zhengdy-soc, rearrange the WFC_K from [up,down,up,down...] to [up,up...down,down...], if(NONCOLIN) { @@ -203,7 +204,6 @@ void Diago_LCAO_Matrix::using_LAPACK_complex(const int &ik, complex **wf { for(int j=0; j **wf hm.cdiaghg(NLOCAL, NBANDS, Htmp, Stmp, NLOCAL, en, hvec); if(!NONCOLIN) - for(int ib=0; ib>> &orb ) +{ + Element_Basis_Index::Range range; + range.resize( orb.size() ); + for( size_t T=0; T!=range.size(); ++T ) + { + range[T].resize( orb[T].size() ); + for( size_t L=0; L!=range[T].size(); ++L ) + { + range[T][L].N = orb[T][L].size(); + range[T][L].M = 2*L+1; + } + } + return range; +} diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-abfs_index.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-abfs_index.h new file mode 100644 index 0000000000..e44344af3b --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-abfs_index.h @@ -0,0 +1,23 @@ +#ifndef EXX_ABFS_ABFS_INDEX_H +#define EXX_ABFS_ABFS_INDEX_H + +#include "exx_abfs.h" + +#include +#include "src_global/element_basis_index.h" +#include "src_lcao/numerical_orbital_lm.h" + +class LCAO_Orbitals; + +class Exx_Abfs::Abfs_Index +{ +public: + static size_t get_index_index( + const Element_Basis_Index::IndexLNM &index_A, const size_t &TA, const size_t &LA, const size_t &NA, const size_t &MA, + const Element_Basis_Index::IndexLNM &index_B, const size_t &TB, const size_t &LB, const size_t &NB, const size_t &MB ) + { return index_A[TA][LA][NA][MA] * index_B[TB].count_size + index_B[TB][LB][NB][MB]; } + static Element_Basis_Index::Range construct_range( const LCAO_Orbitals &orb ); + static Element_Basis_Index::Range construct_range( const vector>> &orb ); +}; + +#endif // EXX_ABFS_ABFS_INDEX_H \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-construct_orbs.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-construct_orbs.cpp new file mode 100644 index 0000000000..2488cc3e1f --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-construct_orbs.cpp @@ -0,0 +1,480 @@ +#include "exx_abfs-construct_orbs.h" +#include "exx_abfs-pca.h" + +#include "src_lcao/lcao_orbitals.h" +#include "src_global/gram_schmidt_orth.h" +#include "src_global/gram_schmidt_orth-inl.h" + +#include "src_external/src_test/src_lcao/exx_abfs-construct_orbs-test.h" // Peize Lin test +#include "src_lcao/global_fp.h" + +vector>> Exx_Abfs::Construct_Orbs::change_orbs( + const LCAO_Orbitals &orbs_in, + const double kmesh_times ) +{ + TITLE("Exx_Abfs::Construct_Orbs::change_orbs"); + + vector>> orbs; + orbs.resize( orbs_in.get_ntype() ); + for (int T = 0; T < orbs_in.get_ntype() ; T++) + { + orbs[T].resize( orbs_in.Phi[T].getLmax()+1 ); + for (int L=0; L <= orbs_in.Phi[T].getLmax() ; L++) + { + orbs[T][L].resize( orbs_in.Phi[T].getNchi(L) ); + for (int N = 0; N < orbs_in.Phi[T].getNchi(L); ++N) + { + const auto &orb_origin = orbs_in.Phi[T].PhiLN(L,N); + orbs[T][L][N].set_orbital_info( + orb_origin.getLabel(), + orb_origin.getType(), + orb_origin.getL(), + orb_origin.getChi(), + orb_origin.getNr(), + orb_origin.getRab(), + orb_origin.getRadial(), + Numerical_Orbital_Lm::Psi_Type::Psi, + orb_origin.getPsi(), + static_cast(orb_origin.getNk() * kmesh_times) | 1, // Nk must be odd + orb_origin.getDk(), // Peize Lin change 2017-04-16 +// orb_origin.getDk() / kmesh_times, + orb_origin.getDruniform(), + false, + true); + } + } + } + return orbs; +} + +vector>> Exx_Abfs::Construct_Orbs::change_orbs( + const vector>> &orbs_in, + const double kmesh_times ) +{ + TITLE("Exx_Abfs::Construct_Orbs::change_orbs"); + return orbital( get_psi(orbs_in), orbs_in, kmesh_times ); +} + +// P = u/r * Y +/* +template +vector>> Exx_Abfs::Construct_Orbs::abfs_same_atom( + const Orbs_Type &orbs, + const double kmesh_times, + const double norm_threshold ) +{ + const vector>>> + &&abfs_same_atom_psir = psir_mult_psir( orbs ); + const vector>>> + &&abfs_same_atom_psir_orth = orth( abfs_same_atom_psir, orbs, norm_threshold ); + const vector>>> + &&abfs_same_atom_psi_orth = div_r( abfs_same_atom_psir_orth, orbs.get_r_radial ); + const vector>> + &&abfs_same_atom = orbital( abfs_same_atom_psi_orth, orbs, kmesh_times ); + return abfs_same_atom; +} +*/ + +// P = f * Y +vector>> Exx_Abfs::Construct_Orbs::abfs_same_atom( + const vector>> &orbs, + const double kmesh_times_mot, + const double times_threshold ) +{ + TITLE("Exx_Abfs::Construct_Orbs::abfs_same_atom"); + + const vector>>> + abfs_same_atom_psi = psi_mult_psi( orbs ); + + const vector>>> + abfs_same_atom_orth_psi = orth( abfs_same_atom_psi, orbs ); + const vector>> + abfs_same_atom = orbital( abfs_same_atom_orth_psi, orbs, 1 ); + + #if TEST_EXX_LCAO==1 + print_orbs(abfs_same_atom_psi,"abfs_same_atom_psi.dat"); + print_orbs(abfs_same_atom_orth_psi,"abfs_same_atom_orth_psi.dat"); + #elif TEST_EXX_LCAO==-1 + #error "TEST_EXX_LCAO" + #endif + + const vector>>> + abfs_same_atom_pca_psi = pca( abfs_same_atom, orbs, kmesh_times_mot, times_threshold ); + + #if TEST_EXX_LCAO==1 + print_orbs(abfs_same_atom_pca_psi,"abfs_same_atom_pca_psi.dat"); + #elif TEST_EXX_LCAO==-1 + #error "TEST_EXX_LCAO" + #endif + + const vector>> + &&abfs_same_atom_pca = orbital( abfs_same_atom_pca_psi, orbs, 1 ); + return abfs_same_atom_pca; +} + +vector>> Exx_Abfs::Construct_Orbs::orth_orbs( + const vector>> &orbs, + const double norm_threshold ) +{ + TITLE("Exx_Abfs::Construct_Orbs::orth_orbs"); + const vector>>> + orbs_psi = get_psi( orbs ); + const vector>>> + orbs_psi_orth = orth( orbs_psi, orbs, norm_threshold ); + const vector>> + orbs_new = orbital( orbs_psi_orth, orbs, 1 ); + return orbs_new; +} + +/* +template<> +vector>>> Exx_Abfs::Construct_Orbs::psi_mult_psi( + const LCAO_Orbitals &orbs ) +{ + vector>>> psi_mult_psi( orbs.get_ntype() ); + for( int T=0; T!=orbs.get_ntype(); ++T ) + { + psi_mult_psi[T].resize( 2*orbs.Phi[T].getLmax()+1 ); + for( int L1=0; L1<=orbs.Phi[T].getLmax(); ++L1 ) + { + for( int N1=0; N1!=orbs.Phi[T].getNchi(L1); ++N1 ) + { + for( int L2=L1; L2<=orbs.Phi[T].getLmax(); ++L2 ) + { + for( int N2=((L2==L1)?N1:0); N2!=orbs.Phi[T].getNchi(L2); ++N2 ) + { + assert( orbs.Phi[T].PhiLN(L1,N1).getNr()==orbs.Phi[T].PhiLN(L2,N2).getNr() ); + + vector mult_psir( orbs.Phi[T].PhiLN(L1,N1).getNr() ); + for( int ir=0; ir!=orbs.Phi[T].PhiLN(L1,N1).getNr(); ++ir) + { + mult_psir[ir] = orbs.Phi[T].PhiLN(L1,N1).getPsi(ir) * orbs.Phi[T].PhiLN(L2,N2).getPsi(ir) ; + } + for( int L_new=std::abs(L2-L1); L_new<=L1+L2; ++L_new ) + { + psi_mult_psi[T][L_new].push_back(mult_psir); + } + } + } + } + } + } + return psi_mult_psi; +} +*/ + +vector>>> Exx_Abfs::Construct_Orbs::psi_mult_psi( + const vector>> &orbs ) +{ + vector>>> psi_mult_psi( orbs.size() ); + for( int T=0; T!=orbs.size(); ++T ) + { + psi_mult_psi[T].resize( 2*orbs[T].size()-1 ); + for( int L1=0; L1!=orbs[T].size(); ++L1 ) + { + for( int N1=0; N1!=orbs[T][L1].size(); ++N1 ) + { + for( int L2=L1; L2!=orbs[T].size(); ++L2 ) + { + for( int N2=((L2==L1)?N1:0); N2!=orbs[T][L2].size(); ++N2 ) + { + assert( orbs[T][L1][N1].getNr()==orbs[T][L2][N2].getNr() ); + + vector mult_psir( orbs[T][L1][N1].getNr() ); + for( int ir=0; ir!=orbs[T][L1][N1].getNr(); ++ir) + { + mult_psir[ir] = orbs[T][L1][N1].getPsi(ir) * orbs[T][L2][N2].getPsi(ir) ; + } + for( int L_new=std::abs(L1-L2); L_new<=L1+L2; ++L_new ) + { + psi_mult_psi[T][L_new].push_back(mult_psir); + } + } + } + } + } + } + return psi_mult_psi; +} + +/* +template<> +vector>>> Exx_Abfs::Construct_Orbs::psir_mult_psir( + const LCAO_Orbitals &orbs ) +{ + vector>>> psir_mult_psir( orbs.get_ntype() ); + for( int T=0; T!=orbs.get_ntype(); ++T ) + { + psir_mult_psir[T].resize( 2*orbs.Phi[T].getLmax()+1 ); + for( int L1=0; L1<=orbs.Phi[T].getLmax(); ++L1 ) + { + for( int N1=0; N1!=orbs.Phi[T].getNchi(L1); ++N1 ) + { + for( int L2=L1; L2<=orbs.Phi[T].getLmax(); ++L2 ) + { + for( int N2=((L2==L1)?N1:0); N2!=orbs.Phi[T].getNchi(L2); ++N2 ) + { + assert( orbs.Phi[T].PhiLN(L1,N1).getNr()==orbs.Phi[T].PhiLN(L2,N2).getNr() ); + + vector mult_psir( orbs.Phi[T].PhiLN(L1,N1).getNr() ); + for( int ir=0; ir!=orbs.Phi[T].PhiLN(L1,N1).getNr(); ++ir) + { + mult_psir[ir] = orbs.Phi[T].PhiLN(L1,N1).getPsi_r(ir) * orbs.Phi[T].PhiLN(L2,N2).getPsi_r(ir) ; + } + for( int L_new=std::abs(L1-L2); L_new<=L1+L2; ++L_new ) + { + psir_mult_psir[T][L_new].push_back(mult_psir); + } + } + } + } + } + } + return psir_mult_psir; +} +*/ + +vector>>> Exx_Abfs::Construct_Orbs::psir_mult_psir( + const vector>> &orbs ) +{ + vector>>> psir_mult_psir( orbs.size() ); + for( int T=0; T!=orbs.size(); ++T ) + { + psir_mult_psir[T].resize( 2*orbs[T].size()-1 ); + for( int L1=0; L1!=orbs[T].size(); ++L1 ) + { + for( int N1=0; N1!=orbs[T][L1].size(); ++N1 ) + { + for( int L2=L1; L2!=orbs[T].size(); ++L2 ) + { + for( int N2=((L2==L1)?N1:0); N2!=orbs[T][L2].size(); ++N2 ) + { + assert( orbs[T][L1][N1].getNr()==orbs[T][L2][N2].getNr() ); + + vector mult_psir( orbs[T][L1][N1].getNr() ); + for( int ir=0; ir!=orbs[T][L1][N1].getNr(); ++ir) + { + mult_psir[ir] = orbs[T][L1][N1].getPsi_r(ir) * orbs[T][L2][N2].getPsi_r(ir) ; + } + for( int L_new=std::abs(L1-L2); L_new<=L1+L2; ++L_new ) + { + psir_mult_psir[T][L_new].push_back(mult_psir); + } + } + } + } + } + } + return psir_mult_psir; +} + +vector>>> Exx_Abfs::Construct_Orbs::pca( + const vector>> &abfs, + const vector>> &orbs, + const double kmesh_times_mot, + const double times_threshold ) +{ +ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); + if(times_threshold>1) + return vector>>>(abfs.size()); + + const vector,matrix>>> && eig = Exx_Abfs::PCA::cal_PCA( orbs, abfs, kmesh_times_mot ); + + const vector>>> && psis = get_psi( abfs ); + vector>>> psis_new( psis.size() ); + + for( size_t T=0; T!=eig.size(); ++T ) + { + double eig_value_max = 0; + for( size_t L=0; L!=eig[T].size(); ++L ) + for( size_t M=0; M!=eig[T][L].first.size(); ++M ) + { +ofs< &eig_value = eig[T][L].first; + const matrix &eig_vec = eig[T][L].second; + for( size_t M=0; M!=eig_value.size(); ++M ) + { + if( eig_value[M] > eig_value_threshold ) + { + vector psi_new( psis[T][L][0].size() ); + for( size_t N=0; N!=psis[T][L].size(); ++N ) + for( size_t ir=0; ir!=psi_new.size(); ++ir ) + psi_new[ir] += eig_vec(M,N) * psis[T][L][N][ir]; + psis_new[T][L].push_back( psi_new ); + } + } + } + } + else + { + WARNING(TO_STRING(__FILE__), + "Element "+TO_STRING(T)+" , all training data (lcao[i]*lcao[j]) are all the same. So PCA randomly choose an abf as the result."); + psis_new[T].resize( psis[T].size() ); + for( size_t L=0; L!=psis[T].size(); ++L ) + if( !psis[T][L].empty() ) + { + psis_new[T][L].push_back(psis[T][L][0]); + break; + } + } + } +ofs.close(); + return psis_new; +} + + +vector>>> Exx_Abfs::Construct_Orbs::orth( + const vector>>> &psis, + const vector>> &orbs, + const double norm_threshold ) +{ + vector>>> psis_orth( psis.size() ); + for( int T=0; T!=psis.size(); ++T ) + { + const Numerical_Orbital_Lm &orb = orbs[T][0][0]; + Gram_Schmidt_Orth gso( + orb.get_rab(), + Gram_Schmidt_Orth::Coordinate::Sphere ); + psis_orth[T].resize( psis[T].size() ); + for( int L=0; L!=psis[T].size(); ++L ) + { + psis_orth[T][L] = gso.cal_orth( psis[T][L], norm_threshold ); // Peize Lin test 2016-10-08 +// psis_orth[T][L] = gso.cal_orth( psis[T][L] ); // Peize Lin test 2016-10-08 + } + } + return psis_orth; +} + +vector>>> Exx_Abfs::Construct_Orbs::div_r( + const vector>>> &psirs, + const vector &r_radial ) +{ + vector>>> psis( psirs.size() ); + for( int T=0; T!=psirs.size(); ++T ) + { + psis[T].resize( psirs[T].size() ); + for( int L=0; L!=psirs[T].size(); ++L ) + { + psis[T][L].resize( psirs[T][L].size() ); + for( int N=0; N!=psirs[T][L].size(); ++N ) + { + psis[T][L][N].resize( psirs[T][L][N].size() ); + psis[T][L][N][0] = 0; + for( int ir=1; ir!=psirs[T][L][N].size(); ++ir ) + { + psis[T][L][N][ir] = psirs[T][L][N][ir] / r_radial[ir]; + } + } + } + } + return psis; +} + +vector>>> Exx_Abfs::Construct_Orbs::get_psi( + const vector>> &orbs ) +{ + vector>>> orbs_psi( orbs.size() ); + for( int T=0; T!=orbs.size(); ++T ) + { + orbs_psi[T].resize( orbs[T].size() ); + for( int L=0; L!=orbs[T].size(); ++L ) + { + orbs_psi[T][L].resize( orbs[T][L].size() ); + for( int N=0; N!=orbs[T][L].size(); ++N ) + { + orbs_psi[T][L][N] = orbs[T][L][N].get_psi(); + } + } + } + return orbs_psi; +} + +vector>> Exx_Abfs::Construct_Orbs::orbital( + const vector>>> &psis, + const vector>> &orbs_info, + const double kmesh_times) +{ + vector>> orbs_new( psis.size() ); + for( int T=0; T!=psis.size(); ++T ) + { + const Numerical_Orbital_Lm &orb_info = orbs_info[T][0][0]; + orbs_new[T].resize( psis[T].size() ); + for( int L=0; L!=psis[T].size(); ++L ) + { + orbs_new[T][L].resize( psis[T][L].size() ); + for( int N=0; N!=psis[T][L].size(); ++N ) + { + orbs_new[T][L][N].set_orbital_info( + orb_info.getLabel(), + T, + L, + N, + orb_info.getNr(), + orb_info.getRab(), + orb_info.getRadial(), + Numerical_Orbital_Lm::Psi_Type::Psi, + VECTOR_TO_PTR(psis[T][L][N]), + static_cast(orb_info.getNk() * kmesh_times) | 1, // Nk must be odd + orb_info.getDk(), // Peize Lin test 2017-04-16 +// orb_info.getDk() / kmesh_times, + orb_info.getDruniform(), + false, + true); + } + } + } + return orbs_new; +} + +/* +vector>>> Exx_Abfs::Construct_Orbs::get_psi( + const LCAO_Orbitals &orbs ) +{ + vector>>> orbs_psi( orbs.get_ntype() ); + for( int T=0; T!=orbs.get_ntype(); ++T ) + { + orbs_psi[T].resize( orbs.Phi[T].getLmax()+1 ); + for( int L=0; L<=orbs.Phi[T].getLmax(); ++L ) + { + orbs_psi[T][L].resize( orbs.Phi[T].getNchi(L) ); + for( int N=0; N!=orbs.Phi[T].getNchi(L); ++N ) + { + orbs_psi[T][L][N] = orbs.Phi[T].PhiLN(L,N).get_psi(); + } + } + } + return orbs_psi; +} +*/ + +/* +template<> +inline const Numerical_Orbital_Lm &Exx_Abfs::Construct_Orbs::get_orbital( + const LCAO_Orbitals &orbs, + const size_t T, const size_t L, const size_t N) +{ + return orbs.Phi[T].PhiLN(L,N); +} +*/ + +/* +template<> +inline const Numerical_Orbital_Lm &Exx_Abfs::Construct_Orbs::get_orbital( + const vector>> &orbs, + const size_t T, const size_t L, const size_t N) +{ + return orbs[T][L][N]; +} +*/ diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-construct_orbs.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-construct_orbs.h new file mode 100644 index 0000000000..85b82346c2 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-construct_orbs.h @@ -0,0 +1,61 @@ +#ifndef EXX_ABFS_CONSTRUCT_ORBS_H +#define EXX_ABFS_CONSTRUCT_ORBS_H + +#include "exx_abfs.h" + +#include +#include "numerical_orbital_lm.h" + +class LCAO_Orbitals; + +class Exx_Abfs::Construct_Orbs +{ +public: + static vector>> change_orbs( + const LCAO_Orbitals &orb_in, + const double kmesh_times ); + static vector>> change_orbs( + const vector>> &orb_in, + const double kmesh_times ); + + static vector>> abfs_same_atom( + const vector>> &lcaos, + const double kmesh_times_mot, + const double times_threshold=0); + + static vector>> orth_orbs( + const vector>> &orbs, + const double norm_threshold=std::numeric_limits::min() ); + +private: + static vector>>> psi_mult_psi( + const vector>> &lcaos ); + + static vector>>> psir_mult_psir( + const vector>> &lcaos ); + + static vector>>> orth( + const vector>>> &psis, + const vector>> &lcaos, + const double norm_threshold = std::numeric_limits::min() ); + + static vector>>> pca( + const vector>> &abfs, + const vector>> &orbs, + const double kmesh_times_mot, + const double times_threshold ); + + static vector>>> div_r( + const vector>>> &psirs, + const vector &r_radial ); + + static vector>> orbital( + const vector>>> &psis, + const vector>> &orbs_info, + const double kmesh_times); + + static vector>>> get_psi( + const vector>> &orbs ); +}; + +#endif // EXX_ABFS_IO_ASA_H \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-dm.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-dm.cpp new file mode 100644 index 0000000000..0c42dcdcf0 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-dm.cpp @@ -0,0 +1,211 @@ +#include "exx_abfs.h" + +#include "src_pw/global.h" +#include "src_global/mathzone.h" +#include "src_pw/charge_pulay.h" +#include "src_global/container_operator.h" + +#include "src_external/src_test/src_global/matrix-test.h" +#include "src_external/src_test/src_global/complexmatrix-test.h" +#include "src_external/src_test/src_lcao/exx_lcao-test.h" +#include "src_external/src_test/src_lcao/exx_abfs-dm-test.h" + +void Exx_Abfs::DM::cal_DM( + const set> &atom_pairs, + const vector> &Born_von_Karman_boxes) +{ + TITLE("Exx_Abfs::DM::cal_DM"); + + cal_DMk_mixing( chr, atom_pairs ); + + for( const pair & atom_pair : atom_pairs ) + { + const size_t iat1 = atom_pair.first; + const size_t iat2 = atom_pair.second; + const size_t it1 = ucell.iat2it[iat1]; + const size_t it2 = ucell.iat2it[iat2]; + + for( const Vector3 &box : Born_von_Karman_boxes ) + { + DMr[iat1][iat2][box] = vector( NSPIN, {ucell.atoms[it1].nw,ucell.atoms[it2].nw} ); + for( size_t ik=0; ik!=kv.nks; ++ik ) + { + DMr[iat1][iat2][box][kv.isk[ik]] += ( DMk[iat1][iat2][ik] * exp( -TWO_PI*IMAG_UNIT* (kv.kvec_c[ik]* (box*ucell.latvec)) ) ).real(); + } + } + } +} + + + +void Exx_Abfs::DM::cal_DMk_mixing( + const Charge_Broyden &charge, + const set> &atom_pairs ) +{ + TITLE("Exx_Abfs::DM::cal_DMk_mixing"); + + if(flag_mix) + { + if ( charge.mixing_mode == "plain" ) + { + plain_mixing( charge, atom_pairs ); + } + else if ( charge.mixing_mode == "kerker" ) + { + throw invalid_argument("mixing density matrix can't be kerker. In "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + } + else if ( charge.mixing_mode == "pulay" ) + { + pulay_mixing( charge, atom_pairs ); + } + else if ( charge.mixing_mode == "pulay-kerker" ) + { + throw invalid_argument("mixing density matrix can't be pulay-kerker. In "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + } + else + { + throw invalid_argument("mixing density matrix error. In "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + } + } + else + { + DMk = cal_DMk_raw(atom_pairs); +// DMk = Exx_Abfs_DM_Test::cal_DMk_raw_readfile(atom_pairs); // Peize Lin test 2018-03-27 + + #if TEST_EXX_LCAO==1 + static int istep=0; + ofs_matrixes("DMk_"+TO_STRING(istep++)+".dat(@Exx_Abfs::DM::cal_DMk_mixing)",DMk); + #elif TEST_EXX_LCAO==-1 + #error + #endif + } +} + + + +map>> Exx_Abfs::DM::cal_DMk_raw( const set> &atom_pairs ) const +{ + TITLE("Exx_Abfs::DM::cal_DMk_raw"); + + const double SPIN_multiple = 0.5*NSPIN; + + map>> DMk_raw; + for( const pair & atom_pair : atom_pairs ) + { + const size_t iat1 = atom_pair.first; + const size_t iat2 = atom_pair.second; + const size_t it1 = ucell.iat2it[iat1]; + const size_t it2 = ucell.iat2it[iat2]; + const size_t ia1 = ucell.iat2ia[iat1]; + const size_t ia2 = ucell.iat2ia[iat2]; + + DMk_raw[iat1][iat2] = vector( kv.nks, {ucell.atoms[it1].nw,ucell.atoms[it2].nw} ); + for( size_t ik=0; ik!=kv.nks; ++ik ) + { + for( size_t iw1=0; iw1!=ucell.atoms[it1].nw; ++iw1 ) + { + for( size_t iw2=0; iw2!=ucell.atoms[it2].nw; ++iw2 ) + { + for( size_t ib=0; ib!=NBANDS; ++ib ) + { + if( GAMMA_ONLY_LOCAL ) + DMk_raw[iat1][iat2][ik](iw1,iw2) += wf.wg(ik,ib) * LOWF.WFC_GAMMA[ik][ib][ucell.itiaiw2iwt(it1,ia1,iw1)] * LOWF.WFC_GAMMA[ik][ib][ucell.itiaiw2iwt(it2,ia2,iw2)]; + else + DMk_raw[iat1][iat2][ik](iw1,iw2) += wf.wg(ik,ib) * LOWF.WFC_K[ik][ib][ucell.itiaiw2iwt(it1,ia1,iw1)] * conj(LOWF.WFC_K[ik][ib][ucell.itiaiw2iwt(it2,ia2,iw2)]); + } + } + } + DMk_raw[iat1][iat2][ik] *= SPIN_multiple; + } + } + + #if TEST_EXX_LCAO==1 + static int istep=0; + ofs_matrixes("DMk_raw_"+TO_STRING(istep++)+".dat(@Exx_Abfs::DM::cal_DMk_raw)",DMk_raw); + #elif TEST_EXX_LCAO==-1 + #error + #endif + return DMk_raw; +} + + + +void Exx_Abfs::DM::plain_mixing( + const Charge_Broyden &charge, + const set> &atom_pairs) +{ + TITLE("Exx_Abfs::DM::plain_mixing"); + + if(DMk.empty()) + DMk = cal_DMk_raw(atom_pairs); + else + DMk = charge.mixing_beta * cal_DMk_raw(atom_pairs) + (1-charge.mixing_beta) * DMk; +} + + + +void Exx_Abfs::DM::pulay_mixing( + const Charge_Broyden &charge, + const set> &atom_pairs) +{ + if( 1==charge.totstep ) + { + DMk_pulay_seq.clear(); + } + + DMk_pulay_seq.push_back( charge.mixing_beta * cal_DMk_raw(atom_pairs) + (1-charge.mixing_beta) * DMk ); + if( charge.totstep > charge.rstep ) + DMk_pulay_seq.pop_front(); + + if( 1==charge.totstep ) + { + DMk = DMk_pulay_seq.front(); + } + else + { + const int alpha_size = DMk_pulay_seq.size()-1; + const int alpha_end = charge.idstep; + const int alpha_begin = alpha_end - alpha_size; + auto alpha_index = [&](const int i){ return ((alpha_begin+i)%charge.dstep+charge.dstep)%charge.dstep; }; + + DMk = (1+charge.alpha[alpha_index(alpha_size-1)]) * DMk_pulay_seq.back(); + for( size_t i=1; i +#include +#include + +class Charge_Broyden; + +class Exx_Abfs::DM +{ +public: + map>> DMk; // DMk[iat1][iat2][ik](iw1,iw2) + map,vector>>> DMr; // DMr[iat1][iat2][box][is](iw1,iw2) + deque>>> DMk_pulay_seq; // DMk_pulay_seq[istep][iat1][iat2][ik](iw1,iw2) +// double DM_threshold = std::numeric_limits::min(); + bool flag_mix; + +public: + void cal_DM( + const set> &atom_pairs, + const vector> &Born_von_Karman_boxes); + map>> cal_DMk_raw( const set> &atom_pairs ) const; + +private: + void cal_DMk_mixing( + const Charge_Broyden &charge, + const set> &atom_pairs ); + void plain_mixing( + const Charge_Broyden &charge, + const set> &atom_pairs); + void pulay_mixing( + const Charge_Broyden &charge, + const set> &atom_pairs); + +// double cal_DM_delta(); + +// void set_DM_threshold(double DM_threshold_in) { DM_threshold = DM_threshold_in; } +// double get_DM_threshold() const { return DM_threshold; } +}; + +#endif // EXX_ABFS_DM_H \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-inl.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-inl.h new file mode 100644 index 0000000000..c8c4c2ee22 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-inl.h @@ -0,0 +1,73 @@ +#ifndef EXX_ABFS_INL_H +#define EXX_ABFS_INL_H + +#include "exx_abfs.h" + +template +void Exx_Abfs::minus_matrixes( + map &A, + const map &B) const +{ + for( auto & a : A ) + { + const T1 i = a.first; + minus_matrixes( a.second, B.at(i) ); + } + return A; +} + +template +void Exx_Abfs::minus_matrixes( + vector &A, + const vector &B) const +{ + for( size_t i=0; i!=A.size(); ++i ) + minus_matrixes( A[i], B[i] ); + return A; +} + +template<> +void Exx_Abfs::minus_matrixes( + matrix &A, + const matrix &B) const +{ + A -= B; +} + + +/* +map>>> &Exx_Abfs::minus_matrixes( + map>>> &mAs, + const map>>> & mBs) const +{ + for( const auto m1 : mBs ) + { + const size_t i1 = m1.first; + for( const auto m2 : m1.second ) + { + const size_t i2 = m2.first; + for( const auto m3 : m2.second ) + { + const size_t i3 = m3.first; + for( const auto m4 : m3.second ) + { + const size_t i4 = m4.first; + + // Peize Lin test + cout< + +#include "src_external/src_test/src_global/matrix-test.h" // Peize Lin test + +void Exx_Abfs::Inverse_Matrix_Double::init(const int &dim_in) +{ + this->dim = dim_in; + assert(dim>0); + + this->info = 0; + this->A.create(dim, dim,false); +} + +void Exx_Abfs::Inverse_Matrix_Double::cal_inverse( const Method &method ) +{ + TITLE("Exx_Abfs::Inverse_Matrix_Double::cal_inverse"); + + #if TEST_EXX_LCAO==1 + static int i=0; + ofstream ofs("inverse_matrix_"+TO_STRING(i)); + ofs< eigen_value(A.nr); + LapackConnector::dsyev('V','U',A,VECTOR_TO_PTR(eigen_value),info); + + #if TEST_EXX_LCAO==1 + for( const double &ie : eigen_value ) + cout<threshold) ? (1.0/eigen_value[i]) : 0; + A = transpose(A) * eigen_value_inverse * A; + */ + + matrix eA( A.nr, A.nc ); + int ie=0; + for( int i=0; i!=A.nr; ++i ) + if( eigen_value[i] > threshold ) + { + LapackConnector::axpy( A.nc, sqrt(1.0/eigen_value[i]), A.c+i*A.nc,1, eA.c+ie*eA.nc,1 ); + ++ie; + } + LapackConnector::gemm( 'T','N', eA.nc,eA.nc,ie, 1, eA.c,eA.nc, eA.c,eA.nc, 0, A.c,A.nc ); +} + + +void Exx_Abfs::Inverse_Matrix_Double::input( const matrix &m ) +{ + for( size_t ir=0; ir!=m.nr; ++ir ) + for( size_t ic=0; ic!=m.nc; ++ic ) + A(ir,ic) = m(ir,ic); +} + +void Exx_Abfs::Inverse_Matrix_Double::input( + const matrix &m_00, + const matrix &m_01, + const matrix &m_10, + const matrix &m_11) +{ + const size_t delta_nr = m_00.nr, delta_nc = m_00.nc; + + for( size_t ir=0; ir!=m_00.nr; ++ir ) + for( size_t ic=0; ic!=m_00.nc; ++ic ) + A(ir,ic) = m_00(ir,ic); + for( size_t ir=0; ir!=m_01.nr; ++ir ) + for( size_t ic=0; ic!=m_01.nc; ++ic ) + A(ir,ic+delta_nc) = m_01(ir,ic); + for( size_t ir=0; ir!=m_10.nr; ++ir ) + for( size_t ic=0; ic!=m_10.nc; ++ic ) + A(ir+delta_nr,ic) = m_10(ir,ic); + for( size_t ir=0; ir!=m_11.nr; ++ir ) + for( size_t ic=0; ic!=m_11.nc; ++ic ) + A(ir+delta_nr,ic+delta_nc) = m_11(ir,ic); +} + +void Exx_Abfs::Inverse_Matrix_Double::output( matrix &m ) const +{ + for( size_t ir=0; ir!=m.nr; ++ir ) + for( size_t ic=0; ic!=m.nc; ++ic ) + m(ir,ic) = A(ir,ic); +} + +void Exx_Abfs::Inverse_Matrix_Double::output( + matrix &m_00, + matrix &m_01, + matrix &m_10, + matrix &m_11) const +{ + const size_t delta_nr = m_00.nr, delta_nc = m_00.nc; + + for( size_t ir=0; ir!=m_00.nr; ++ir ) + for( size_t ic=0; ic!=m_00.nc; ++ic ) + m_00(ir,ic) = A(ir,ic); + for( size_t ir=0; ir!=m_01.nr; ++ir ) + for( size_t ic=0; ic!=m_01.nc; ++ic ) + m_01(ir,ic) = A(ir,ic+delta_nc); + for( size_t ir=0; ir!=m_10.nr; ++ir ) + for( size_t ic=0; ic!=m_10.nc; ++ic ) + m_10(ir,ic) = A(ir+delta_nr,ic); + for( size_t ir=0; ir!=m_11.nr; ++ir ) + for( size_t ic=0; ic!=m_11.nc; ++ic ) + m_11(ir,ic) = A(ir+delta_nr,ic+delta_nc); +} + +void Exx_Abfs::Inverse_Matrix_Double::copy_down_triangle() +{ + for( size_t ir=0; ir!=A.nr; ++ir ) + for( size_t ic=0; ic!=ir; ++ic ) + A(ir,ic) = A(ic,ir); +} \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-inverse_matrix_double.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-inverse_matrix_double.h new file mode 100644 index 0000000000..c4e9cbd478 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-inverse_matrix_double.h @@ -0,0 +1,57 @@ +#ifndef EXX_ABFS_INVERSE_MATRIX_DOUBLE_H +#define EXX_ABFS_INVERSE_MATRIX_DOUBLE_H + +#include "exx_abfs.h" + +#include "src_global/matrix.h" + +#include + +class Exx_Abfs::Inverse_Matrix_Double +{ +public: + enum class Method{dpotrf,dsyev}; + + matrix A; + void init( const int &dim_in); + + void input( const matrix &m ); + void input( const shared_ptr &pm ) { input(*pm); } + void input( + const matrix &m_00, + const matrix &m_01, + const matrix &m_10, + const matrix &m_11); + void input( + const shared_ptr &pm_00, + const shared_ptr &pm_01, + const shared_ptr &pm_10, + const shared_ptr &pm_11) { input( *pm_00, *pm_01, *pm_10, *pm_11 ); } + + void cal_inverse( const Method &method ); + + void output( matrix &m ) const; + void output( const shared_ptr &pm ) const { output(*pm); } + void output( + matrix &m_00, + matrix &m_01, + matrix &m_10, + matrix &m_11) const; + void output( + const shared_ptr &pm_00, + const shared_ptr &pm_01, + const shared_ptr &pm_10, + const shared_ptr &pm_11) const { output( *pm_00, *pm_01, *pm_10, *pm_11 ); } + +private: + + void using_dpotrf(); + void using_dsyev( const double &threshold_condition_number = 0 ); + + void copy_down_triangle(); + + int dim; + int info; +}; + +#endif // EXX_ABFS_INVERSE_MATRIX_DOUBLE_H \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-io-template.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-io-template.h new file mode 100644 index 0000000000..bf57e37d87 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-io-template.h @@ -0,0 +1,72 @@ +#ifndef EXX_ABFS_IO_TEMPLATE_H +#define EXX_ABFS_IO_TEMPLATE_H + +#include "src_lcao/exx_abfs-io.h" +#include "src_global/boost_serialization.h" +#include +#include + +template +void Exx_Abfs::IO::output_binary( const T &data, const std::string &file_name ) +{ + std::ofstream ofs(file_name,std::ios::binary); + boost::archive::binary_oarchive oa(ofs); + oa << data; + ofs.close(); +} + +template +T Exx_Abfs::IO::input_binary( const std::string &file_name ) +{ + std::ifstream ifs(file_name,std::ios::binary); + boost::archive::binary_iarchive ia(ifs); + T data; + ia >> data; + ifs.close(); + return data; +} + +template +void Exx_Abfs::IO::output_text( const T &data, const std::string &file_name ) +{ + std::ofstream ofs(file_name); + boost::archive::text_oarchive oa(ofs); + oa << std::move(data); + ofs.close(); +} + +template +T Exx_Abfs::IO::input_text( const std::string &file_name ) +{ + std::ifstream ifs(file_name); + boost::archive::text_iarchive ia(ifs); + T data; + ia >> data; + ifs.close(); + return data; +} + +template +void Exx_Abfs::IO::bcast( T &data, const int rank_src, MPI_Comm mpi_comm ) +{ + int my_rank; MPI_Comm_rank( mpi_comm, &my_rank ); + if(MY_RANK==rank_src) + { + boost::mpi::packed_oarchive oar(mpi_comm); + oar << data; + const int data_size = oar.size(); + MPI_Bcast( const_cast(&data_size), 1, MPI_INT, rank_src, mpi_comm ); + MPI_Bcast( const_cast(oar.address()), oar.size(), MPI_PACKED, rank_src, mpi_comm ); + } + else + { + int data_size; + MPI_Bcast( &data_size, 1, MPI_INT, rank_src, mpi_comm ); + boost::mpi::packed_iarchive iar(mpi_comm); + iar.resize(data_size); + MPI_Bcast( iar.address(), data_size, MPI_PACKED, rank_src, mpi_comm ); + iar >> data; + } +} + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-io.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-io.cpp new file mode 100644 index 0000000000..95edc26d45 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-io.cpp @@ -0,0 +1,513 @@ +#include +#include + +#include "exx_abfs-io.h" +#include "exx_abfs-io-template.h" +#include "exx_abfs-jle.h" +#include "exx_abfs-abfs_index.h" +#include "../src_pw/global.h" +#include "lcao_orbitals.h" +#include "../src_global/global_function.h" + +vector>> Exx_Abfs::IO::construct_abfs( + const LCAO_Orbitals &orbs, + const vector &files_abfs, + const double kmesh_times ) +{ + vector>> abfs( files_abfs.size() ); + for( size_t T=0; T!=files_abfs.size(); ++T ) + abfs[T] = construct_abfs_T( + files_abfs[T], + T, + static_cast(orbs.get_kmesh() * kmesh_times) | 1, // Nk must be odd +// orbs.get_dk() / kmesh_times, + orbs.get_dk(), // Peize Lin change 2017-04-16 + orbs.get_dr_uniform() ); + + return abfs; +} + +vector>> Exx_Abfs::IO::construct_abfs( + const vector>> & abfs_pre, + const LCAO_Orbitals &orbs, + const vector &files_abfs, + const double kmesh_times ) +{ + vector>> + &&abfs = construct_abfs( orbs, files_abfs, kmesh_times ); + + assert( abfs.size() == abfs_pre.size() ); + for( size_t T=0; T!=abfs.size(); ++T ) + { + if( abfs[T].size() < abfs_pre[T].size() ) + abfs[T].resize( abfs_pre[T].size() ); + for( size_t L=0; L!=abfs_pre[T].size(); ++L ) + { + abfs[T][L].insert( abfs[T][L].begin(), abfs_pre[T][L].begin(), abfs_pre[T][L].end() ); + } + } + + return abfs; +} + +vector> Exx_Abfs::IO::construct_abfs_T( + const string & file_name, + const int &T, + const int &nk, + const double &dk, + const double &dr_uniform) +{ + string label; + size_t L_size; + map N_size; + size_t meshr; + double dr; + map>> psis; + + /*---------------------- + 1.read abfs + ----------------------*/ + string word; + + ifstream ifs( file_name.c_str() ); + if(!ifs) + throw runtime_error(" Can't find the abfs ORBITAL file."); + + while( ifs.good() ) + { + ifs >> word; + + if( "Element"==word ) + { + READ_VALUE( ifs, label ); + } + else if ( "Lmax"==word ) + { + READ_VALUE( ifs, L_size ); + + if( L_size>=9 ) + { + stringstream ss; + ss<<"Lmax>=9 error in "<<__FILE__<<" line "<<__LINE__; + throw invalid_argument(ss.str()); + } + } + else if ( "Sorbital-->"==word ) + { + READ_VALUE( ifs, N_size[0] ); + } + else if ( "Porbital-->"==word ) + { + READ_VALUE( ifs, N_size[1] ); + } + else if ( "Dorbital-->"==word ) + { + READ_VALUE( ifs, N_size[2] ); + } + else if ( "Forbital-->"==word ) + { + READ_VALUE( ifs, N_size[3] ); + } + else if ( "Gorbital-->"==word ) + { + READ_VALUE( ifs, N_size[4] ); + } + else if ( "Horbital-->"==word ) + { + READ_VALUE( ifs, N_size[5] ); + } + else if ( "Iorbital-->"==word ) + { + READ_VALUE( ifs, N_size[6] ); + } + else if ( "Jorbital-->"==word ) + { + READ_VALUE( ifs, N_size[7] ); + } + else if ( "Korbital-->"==word ) + { + READ_VALUE( ifs, N_size[8] ); + } + else if ( "END"==word ) + { + break; + } + } + + CHECK_NAME(ifs, "Mesh"); + ifs >> meshr; + + CHECK_NAME(ifs, "dr"); + ifs >> dr; + + while(ifs.good()) + { + ifs >> word; + if(word=="Type") + { + string s_L, s_N; + ifs >> s_L >> s_N; + + size_t T,L,N; + ifs >> T >> L >> N; + + psis[L][N].resize(meshr); + for(int ir=0; ir!=meshr; ir++) + { + ifs >> psis[L][N][ir]; + } + } + + } + ifs.close(); + + + /*---------------------- + 2.check L,N orbital + ----------------------*/ + for( size_t L=0; L<=L_size; ++L ) + if( N_size.find(L) == N_size.end() ) + { + stringstream ss; + ss<<"Can't find N of L="< rab(meshr); + vector radial(meshr); + for( int ir=0; ir!=meshr; ++ir ) + { + rab[ir] = dr; + radial[ir] = ir*dr; //mohan 2010-04-19 + } + + + /*---------------------- + 4.normalize psi + ----------------------*/ + for( size_t L=0; L<=L_size; ++L ) + { + for( size_t N=0; N!=N_size[L]; ++N ) + { + vector psir(meshr); + vector inner(meshr); + psis[L][N].resize(meshr); + for( int ir=0; ir!=meshr; ++ir ) + { + psir[ir] = psis[L][N][ir] * radial[ir]; + inner[ir] = psir[ir] * psir[ir]; + } + double unit = 0.0; + Mathzone::Simpson_Integral(meshr, VECTOR_TO_PTR(inner), VECTOR_TO_PTR(rab), unit); + for( int ir=0; ir!=meshr; ++ir ) + { + psis[L][N][ir] /= sqrt(unit); + } + } + } + + + /*---------------------- + 5.construct abfs + ----------------------*/ + vector> abfs_T; + + abfs_T.resize(L_size+1); + for( size_t L=0; L<=L_size; ++L ) + { + abfs_T[L].resize(N_size[L]); + for( size_t N=0; N!=N_size[L]; ++N ) + { + abfs_T[L][N].set_orbital_info( + label, + T, //type + L, //angular momentum L + N, // number of orbitals of this L + meshr, // number of radial mesh + VECTOR_TO_PTR(rab), + VECTOR_TO_PTR(radial),// radial mesh value(a.u.) + Numerical_Orbital_Lm::Psi_Type::Psi, + VECTOR_TO_PTR(psis[L][N]), // radial wave function + nk, + dk, + dr_uniform, + false, + true); + } + } + + return abfs_T; +} + +void Exx_Abfs::IO::print_matrix( + const string &file_name_prefix, + const map>>>> &matrixes_Q, + const map>>> &matrixes_S, + const map>>> &matrixes_V, + const Element_Basis_Index::Range &range_jles, + const Element_Basis_Index::IndexLNM &index_jles, + const Element_Basis_Index::Range &range_lcaos, + const Element_Basis_Index::IndexLNM &index_lcaos ) +{ + auto print_header = [&]( ofstream &ofs, size_t TA, size_t IA, size_t TB, size_t IB ) + { + ofs << ucell.lat0 << endl; + + ofs << ucell.latvec.e11 << " " << ucell.latvec.e12 << " " << ucell.latvec.e13 << endl; + ofs << ucell.latvec.e21 << " " << ucell.latvec.e22 << " " << ucell.latvec.e23 << endl; + ofs << ucell.latvec.e31 << " " << ucell.latvec.e32 << " " << ucell.latvec.e33 << endl; + + if( TA==TB ) + { + ofs << 1 << " ntype" << endl; + ofs << ucell.atoms[TA].label << " label" << endl; + if( IA==IB ) + { + ofs << 1 << " na" << endl; + ofs << ucell.atoms[TA].tau[IA].x << " " + << ucell.atoms[TA].tau[IA].y << " " + << ucell.atoms[TA].tau[IA].z << endl; + } + else + { + ofs << 2 << " na" << endl; + ofs << ucell.atoms[TA].tau[IA].x << " " + << ucell.atoms[TA].tau[IA].y << " " + << ucell.atoms[TA].tau[IA].z << endl; + ofs << ucell.atoms[TB].tau[IB].x << " " + << ucell.atoms[TB].tau[IB].y << " " + << ucell.atoms[TB].tau[IB].z << endl; + } + } + else + { + ofs << 2 << " ntype" << endl; + ofs << ucell.atoms[TA].label << " label" << endl; + ofs << 1 << " na" << endl; + ofs << ucell.atoms[TA].tau[IA].x << " " + << ucell.atoms[TA].tau[IA].y << " " + << ucell.atoms[TA].tau[IA].z << endl; + ofs << ucell.atoms[TB].label << " label" << endl; + ofs << 1 << " na" << endl; + ofs << ucell.atoms[TB].tau[IB].x << " " + << ucell.atoms[TB].tau[IB].y << " " + << ucell.atoms[TB].tau[IB].z << endl; + } + + // ecutwfc_jlq determine the jlq corresponding to plane wave calculation. + ofs << Exx_Abfs::Jle::Ecut_exx << " ecutwfc" << endl; // mohan add 2009-09-08 + + // this parameter determine the total number of jlq. + ofs << Exx_Abfs::Jle::Ecut_exx << " ecutwfc_jlq" << endl;//mohan modify 2009-09-08 + + assert( ORB.Phi[TA].getRcut() == ORB.Phi[TB].getRcut() ); + ofs << ORB.Phi[TA].getRcut() << " rcut_Jlq" << endl; + + // mohan add 'smooth' and 'sigma' 2009-08-28 + ofs << 0 << " smooth" << endl; + ofs << 0 << " sigma" << endl; + + ofs << Exx_Abfs::Jle::tolerence << " tolerence" << endl; + + ofs << Exx_Abfs::Jle::Lmax << " lmax" << endl; + + ofs << kv.nkstot << " nks" << endl; + ofs << index_lcaos[TA].count_size * index_lcaos[TB].count_size << " nbands" << endl; + + auto cal_sum_M = [&range_jles](size_t T) -> size_t + { + size_t sum_M = 0; + for( size_t L = 0; L!=range_jles[T].size(); ++L ) + sum_M += range_jles[T][L].M; + return sum_M; + }; + const size_t nwfc = (TA==TB && IA==IB) ? cal_sum_M(TA) : cal_sum_M(TA)+cal_sum_M(TB); + ofs << nwfc << " nwfc" << endl; + + const size_t ecut_numberA = static_cast( sqrt( Exx_Abfs::Jle::Ecut_exx ) * ORB.Phi[TA].getRcut() / PI ); // Rydberg Unit + const size_t ecut_numberB = static_cast( sqrt( Exx_Abfs::Jle::Ecut_exx ) * ORB.Phi[TB].getRcut() / PI ); // Rydberg Unit + assert( ecut_numberA == ecut_numberB ); + ofs << ecut_numberA << " ne" << endl; + + ofs << "" << endl; + for( int ik=0; ik!=kv.nkstot; ++ik ) + { + ofs << kv.kvec_c[ik].x << " " << kv.kvec_c[ik].y << " " << kv.kvec_c[ik].z; + ofs << " " << kv.wk[ik] * 0.5 << endl; + } + ofs << "" << endl; + + ofs << endl; + }; + + auto print_Q = [&]( ofstream &ofs, const size_t TA, const size_t IA, const size_t TB, const size_t IB, const double scale=1 ) + { + /*--------------------- + < jY | Psi > + ---------------------*/ + + ofs<< "" << std::endl; + + for( int ik=0; ik!=kv.nkstot; ++ik ) + for( size_t LA=0; LA!=range_lcaos[TA].size(); ++LA ) + for( size_t NA=0; NA!=range_lcaos[TA][LA].N; ++NA ) + for( size_t MA=0; MA!=range_lcaos[TA][LA].M; ++MA ) + for( size_t LB=0; LB!=range_lcaos[TB].size(); ++LB ) + for( size_t NB=0; NB!=range_lcaos[TB][LB].N; ++NB ) + for( size_t MB=0; MB!=range_lcaos[TB][LB].M; ++MB ) + { + const vector & matrix_Q = matrixes_Q.at(TA).at(IA).at(TB).at(IB); + const size_t index_lcao + = Exx_Abfs::Abfs_Index::get_index_index( + index_lcaos,TA,LA,NA,MA, + index_lcaos,TB,LB,NB,MB ); + + auto f = [&]( size_t Tj, size_t Ij ) + { + for( size_t Lj=0; Lj!=range_jles[Tj].size(); ++Lj ) + for( size_t Mj=0; Mj!=range_jles[Tj][Lj].M; ++Mj ) // attention! M first N second + for( size_t Nj=0; Nj!=range_jles[Tj][Lj].N; ++Nj ) + ofs << matrix_Q[Ij]( + index_lcao, + index_jles[Tj][Lj][Nj][Mj] ) + * scale << "\t" + << 0.0 * scale << std::endl; + }; + + if( TA==TB && IA==IB ) + { + f(TA,0); + } + else + { + f(TA,0); + f(TB,1); + } + } + + + ofs<< "" << std::endl << std::endl; + }; + + + auto print_S = [&]( ofstream &ofs, const size_t TA, const size_t IA, const size_t TB, const size_t IB, const double scale=1 ) + { + /*--------------------- + < jY | jY > + ---------------------*/ + auto q1q2 = [&]( size_t T1, size_t I1, size_t T2, size_t I2, size_t L1, size_t M1, size_t L2, size_t M2) + { + const matrix & matrix_S = matrixes_S.at(T1).at(I1).at(T2).at(I2); + for( size_t N1=0; N1!=range_jles[T1][L1].N; ++N1) + for( size_t N2=0; N2!=range_jles[T2][L2].N; ++N2) + ofs<< matrix_S( index_jles[T1][L1][N1][M1], index_jles[T2][L2][N2][M2] ) * scale << "\t" << 0.0 * scale << std::endl; + }; + + auto atom2 = [&]( size_t T1, size_t I1, size_t T2, size_t I2, size_t L1, size_t M1) + { + for( size_t L2=0; L2!=range_jles[T2].size(); ++L2 ) + for( size_t M2=0; M2!=range_jles[T2][L2].M; ++M2 ) + q1q2(T1,I1,T2,I2,L1,M1,L2,M2); + }; + + auto atom1 = [&]( size_t T1, size_t I1) + { + for( size_t L1=0; L1!=range_jles[T1].size(); ++L1 ) + for( size_t M1=0; M1!=range_jles[T1][L1].M; ++M1 ) + { + if( TA==TB && IA==IB ) + { + atom2(T1,I1,TA,IA,L1,M1); + } + else + { + atom2(T1,I1,TA,IA,L1,M1); + atom2(T1,I1,TB,IB,L1,M1); + } + } + }; + + ofs<< "" <" << std::endl << std::endl; + }; + + + auto print_V = [&]( ofstream &ofs, const size_t TA, const size_t IA, const size_t TB, const size_t IB, const double scale=1 ) + { + /*--------------------- + < Psi | Psi > + ---------------------*/ + ofs << "" << std::endl; + + const matrix & matrix_V = matrixes_V.at(TA).at(IA).at(TB).at(IB); + + for( int ik=0; ik!=kv.nkstot; ++ik ) + // for ib = 0 to NBANDS + for( size_t LA=0; LA!=range_lcaos[TA].size(); ++LA ) + for( size_t NA=0; NA!=range_lcaos[TA][LA].N; ++NA ) + for( size_t MA=0; MA!=range_lcaos[TA][LA].M; ++MA ) + for( size_t LB=0; LB!=range_lcaos[TB].size(); ++LB ) + for( size_t NB=0; NB!=range_lcaos[TB][LB].N; ++NB ) + for( size_t MB=0; MB!=range_lcaos[TB][LB].M; ++MB ) + ofs << matrix_V( index_lcaos[TA][LA][NA][MA], index_lcaos[TB][LB][NB][MB] ) * scale << std::endl; + + ofs << "" << std::endl << std::endl; + }; + + + auto cal_R2 = []( const size_t TA, const size_t IA, const size_t TB, const size_t IB ) ->double + { + Numerical_Orbital::set_position( ucell.atoms[TA].tau[IA], ucell.atoms[TB].tau[IB] ); + const double R = Numerical_Orbital::get_distance()*ucell.lat0; + return R*R; + }; + + for( size_t TA=0; TA!=ucell.ntype; ++TA ) + { + for( size_t IA=0; IA!=ucell.atoms[TA].na; ++IA ) + { + for( size_t TB=TA; TB!=ucell.ntype; ++TB ) + { + for( size_t IB=((TB==TA)?IA:0); IB!=ucell.atoms[TB].na; ++IB ) + { + ofstream ofs(( file_name_prefix+"matrix_"+TO_STRING(TA)+"_"+TO_STRING(IA)+"_"+TO_STRING(TB)+"_"+TO_STRING(IB) ).c_str()); + print_header( ofs, TA, IA, TB, IB ); +// const double scale = 1.0 / max( matrixes_V.at(TA).at(IA).at(TB).at(IB) ); + const double scale = 1; // Peize Lin test +// const double scale = cal_R2(TA,IA,TB,IB); + print_Q( ofs, TA, IA, TB, IB, sqrt(scale) ); + print_S( ofs, TA, IA, TB, IB ); + print_V( ofs, TA, IA, TB, IB, scale ); + } + } + } + } +} \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-io.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-io.h new file mode 100644 index 0000000000..ae3a9e87c1 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-io.h @@ -0,0 +1,58 @@ +#ifndef EXX_ABFS_IO_H +#define EXX_ABFS_IO_H + +#include "exx_abfs.h" + +#include +#include +#include "src_lcao/numerical_orbital_lm.h" +#include "src_global/matrix.h" +#include "src_global/element_basis_index.h" + +class LCAO_Orbitals; + +class Exx_Abfs::IO +{ +public: + static void print_matrix( + const string &file_name_prefix, + const map>>>> &matrixes_Q, + const map>>> &matrixes_S, + const map>>> &matrixes_V, + const Element_Basis_Index::Range &range_jles, + const Element_Basis_Index::IndexLNM &index_jles, + const Element_Basis_Index::Range &range_lcaos, + const Element_Basis_Index::IndexLNM &index_lcaos ); + + static vector>> construct_abfs( + const LCAO_Orbitals &orbs, + const vector &files_abfs, + const double kmesh_times=1 ); // close dK, keep Kcut + + static vector>> construct_abfs( + const vector>> &abfs_pre, + const LCAO_Orbitals &orbs, + const vector &files_abfs, + const double kmesh_times=1 ); // close dK, keep Kcut + + template + static void output_binary( const T &data, const string &file_name ); + template + static T input_binary( const string &file_name ); + template + static void output_text( const T &data, const string &file_name ); + template + static T input_text( const string &file_name ); + template + static void bcast( T &data, const int rank_src, MPI_Comm mpi_comm ); + +private: + static vector> construct_abfs_T( + const string & file_name, + const int &T, + const int &nk, + const double &dk, + const double &dr_uniform); +}; + +#endif // EXX_ABFS_IO_H \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-jle.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-jle.cpp new file mode 100644 index 0000000000..3dd461f827 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-jle.cpp @@ -0,0 +1,56 @@ +#include "exx_abfs-jle.h" + +#include "../src_pw/global.h" +#include "lcao_orbitals.h" +#include "../src_global/global_function.h" +#include "../src_global/mathzone.h" + +int Exx_Abfs::Jle::Lmax = 2; +double Exx_Abfs::Jle::Ecut_exx = 60; +double Exx_Abfs::Jle::tolerence = 1.0e-12; + +void Exx_Abfs::Jle::init_jle( const double kmesh_times ) +{ + jle.resize( ucell.ntype ); + + for (int T = 0; T < ucell.ntype ; T++) + { + jle[T].resize( Lmax+1 ); + for (int L=0; L <= Lmax ; ++L) + { + const size_t ecut_number + = static_cast( sqrt( Ecut_exx ) * ORB.Phi[T].getRcut() / PI ); // Rydberg Unit. + + jle[T][L].resize( ecut_number ); + + vector en(ecut_number, 0.0); + Mathzone::Spherical_Bessel_Roots(ecut_number, L, tolerence, VECTOR_TO_PTR(en), ORB.Phi[T].getRcut()); + + for(size_t E=0; E!=ecut_number; ++E) + { + vector jle_r( ORB.Phi[T].PhiLN(0,0).getNr() ); + Mathzone::Spherical_Bessel( + ORB.Phi[T].PhiLN(0,0).getNr(), + ORB.Phi[T].PhiLN(0,0).getRadial(), + en[E], + L, + VECTOR_TO_PTR(jle_r)); + jle[T][L][E].set_orbital_info( + ORB.Phi[T].PhiLN(0,0).getLabel(), + ORB.Phi[T].PhiLN(0,0).getType(), + L, + E, // N? + ORB.Phi[T].PhiLN(0,0).getNr(), + ORB.Phi[T].PhiLN(0,0).getRab(), + ORB.Phi[T].PhiLN(0,0).getRadial(), + Numerical_Orbital_Lm::Psi_Type::Psi, + VECTOR_TO_PTR(jle_r), + static_cast(ORB.Phi[T].PhiLN(0,0).getNk() * kmesh_times) | 1, + ORB.Phi[T].PhiLN(0,0).getDk(), + ORB.Phi[T].PhiLN(0,0).getDruniform(), + false, + true); + } + } + } +} \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-jle.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-jle.h new file mode 100644 index 0000000000..f1441a1b25 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-jle.h @@ -0,0 +1,25 @@ +#ifndef EXX_ABFS_JLE_H +#define EXX_ABFS_JLE_H + +#include "exx_abfs.h" + +#include +#include "numerical_orbital_lm.h" + +class Exx_Abfs::Jle +{ +public: + + vector< + vector< + vector< + Numerical_Orbital_Lm>>> jle; + + void init_jle( const double kmesh_times ); + + static int Lmax; + static double Ecut_exx; + static double tolerence; +}; + +#endif // EXX_ABFS_JLE_H \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp new file mode 100644 index 0000000000..de8150b10c --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp @@ -0,0 +1,310 @@ +#include "exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h" + +#include "../src_pw/global.h" +#include "lcao_orbitals.h" +#include "ylm.h" + +#include "../src_external/src_test/test_function.h" // Peize Lin test 2016-04-05 + +void Exx_Abfs::Matrix_Lcaoslcaos_Lcaoslcaos::init( + const int mode, + const double kmesh_times, + const double rmesh_times) +{ + //========================================= + // (1) MOT: make overlap table. + //========================================= + MOT.allocate( + ORB.get_ntype(), // number of atom types + ORB.get_lmax(), // max L used to calculate overlap + static_cast(ORB.get_kmesh() * kmesh_times) | 1, // kpoints, for integration in k space + ORB.get_Rmax() * rmesh_times, // max value of radial table + ORB.get_dR(), // delta R, for making radial table +// ORB.get_dk() / kmesh_times); // delta k, for integration in k space + ORB.get_dk()); // Peize Lin change 2017-04-16 + int Lmax_used, Lmax; + MOT.init_Table_Spherical_Bessel (4,mode, Lmax_used, Lmax); +// MOT.init_OV_Tpair(); // for MOT.OV_L2plus1 +// MOT.Destroy_Table_Spherical_Bessel (Lmax_used); // why? + + //========================================= + // (2) init Ylm Coef + //========================================= + Ylm::set_coefficients (); + + //========================================= + // (3) make Gaunt coefficients table + //========================================= + MGT.init_Gaunt_CH( 2*Lmax+1 ); // why +1 + MGT.init_Gaunt( 2*Lmax+1 ); +} + +void Exx_Abfs::Matrix_Lcaoslcaos_Lcaoslcaos::init_radial( + const vector>> &orb_A, + const vector>> &orb_B ) +{ + for( size_t TA = 0; TA!=orb_A.size(); ++TA ) + for( size_t TB=0; TB!=orb_B.size(); ++TB ) + for( size_t LA=0; LA!=orb_A[TA].size(); ++LA ) + for( size_t NA=0; NA!=orb_A[TA][LA].size(); ++NA ) + for( size_t LB=0; LB!=orb_B[TB].size(); ++LB ) + for( size_t NB=0; NB!=orb_B[TB][LB].size(); ++NB ) + center2_orb22_s[TA][TB][LA][NA][LB].insert( + make_pair(NB, Center2_Orb::Orb22( + orb_A[TA][LA][NA], + orb_A[TA][LA][NA], + orb_B[TB][LB][NB], + orb_B[TB][LB][NB], + MOT, MGT))); +} + +void Exx_Abfs::Matrix_Lcaoslcaos_Lcaoslcaos::init_radial( + const LCAO_Orbitals &orb_A, + const LCAO_Orbitals &orb_B ) +{ + for( size_t TA = 0; TA!=orb_A.get_ntype(); ++TA ) + for( size_t TB=0; TB!=orb_B.get_ntype(); ++TB ) + for( size_t LA=0; LA<=orb_A.Phi[TA].getLmax(); ++LA ) + for( size_t NA=0; NA!=orb_A.Phi[TA].getNchi(LA); ++NA ) + for( size_t LB=0; LB<=orb_B.Phi[TB].getLmax(); ++LB ) + for( size_t NB=0; NB!=orb_B.Phi[TB].getNchi(LB); ++NB ) + center2_orb22_s[TA][TB][LA][NA][LB].insert( + make_pair(NB, Center2_Orb::Orb22( + orb_A.Phi[TA].PhiLN(LA,NA), + orb_A.Phi[TA].PhiLN(LA,NA), + orb_B.Phi[TB].PhiLN(LB,NB), + orb_B.Phi[TB].PhiLN(LB,NB), + MOT, MGT))); +} + +void Exx_Abfs::Matrix_Lcaoslcaos_Lcaoslcaos::init_radial_table() +{ + for( auto &co1 : center2_orb22_s ) + for( auto &co2 : co1.second ) + for( auto &co3 : co2.second ) + for( auto &co4 : co3.second ) + for( auto &co5 : co4.second ) + for( auto &co6 : co5.second ) + co6.second.init_radial_table(); +} + +void Exx_Abfs::Matrix_Lcaoslcaos_Lcaoslcaos::init_radial_table( map>> &Rs ) +{ + for( auto &co1 : center2_orb22_s ) + for( auto &co2 : co1.second ) + { + set radials; + for( const double &R : Rs[co1.first][co2.first] ) + { + const double position = R * ucell.lat0 / MOT.dr; + const size_t iq = static_cast(position); + for( size_t i=0; i!=4; ++i ) + radials.insert(iq+i); + } + + for( auto &co3 : co2.second ) + for( auto &co4 : co3.second ) + for( auto &co5 : co4.second ) + for( auto &co6 : co5.second ) + co6.second.init_radial_table(radials); + } +} + +/*void Matrix_Phiphi_Phiphi::cal_overlap_matrix() +{ + for( auto &co1 : center2_orb22_s ) + { + const size_t T = co1.first; + for (size_t IA=0; IA!=ucell.atoms[T].na; ++IA) + { + const Vector3 &tauA( ucell.atoms[T].tau[IA] ); + GridD.Find_atom(tauA); + + for( auto &co2 : co1.second ) + { + const size_t LA = co2.first; + for( size_t MA=0; MA!=2*LA+1; ++MA) + { + for( auto &co3 : co2.second ) + { + + for (int ad = 0; ad < GridD.getAdjacentNum()+1; ++ad) + { + if( T != GridD.getType(ad) ) + continue; + const Vector3 &tauB( GridD.getAdjacentTau(ad) ); + + for( auto &co4 : co3.second ) + { + const size_t LB = co4.first; + for( size_t MB=0; MB!=2*LB+1; ++MB) + { + for( auto &co5 : co4.second ) + { + co5.second.cal_ST_Phi12_R(tauA, tauB, MA, MA, MB, MB); + + } + } + + } + } + } + } + } + } + } +}*/ + +map>>> Exx_Abfs::Matrix_Lcaoslcaos_Lcaoslcaos::cal_overlap_matrix( + const Element_Basis_Index::IndexLNM &index_r, + const Element_Basis_Index::IndexLNM &index_c ) +{ + map>>> matrixes; + + for( auto &co1 : center2_orb22_s ) + { + const int TA = co1.first; + for (int IA=0; IA!=ucell.atoms[TA].na; ++IA) + { + const Vector3 &tauA( ucell.atoms[TA].tau[IA] ); + + for( auto &co2 : co1.second ) + { + const size_t TB = co2.first; + for ( int IB=0; IB!=ucell.atoms[TB].na; ++IB ) + { + const Vector3 &tauB( ucell.atoms[TB].tau[IB] ); + + matrixes[TA][IA][TB][IB].create( index_r[TA].count_size, index_c[TB].count_size ); + + for( auto &co3 : co2.second ) + { + const int LA = co3.first; + for( auto &co4 : co3.second ) + { + const size_t NA = co4.first; + for( int MA=0; MA!=2*LA+1; ++MA) + { + for( auto &co5 : co4.second ) + { + const int LB = co5.first; + for( auto &co6 : co5.second ) + { + const size_t NB = co6.first; + for( int MB=0; MB!=2*LB+1; ++MB) + { + matrixes[TA][IA][TB][IB]( index_r[TA][LA][NA][MA], index_c[TB][LB][NB][MB] ) + = co6.second.cal_overlap( tauA*ucell.lat0, tauB*ucell.lat0, MA, MA, MB, MB ); + + // Peize Lin test +// cout< &tauA( ucell.atoms[T].tau[IA] ); + + for( auto &co2 : co1.second ) + { + const int LA = co2.first; +// Peize Lin test 2015-04-05 +{ + stringstream ss; + ss<<" "< &tauB( ucell.atoms[T].tau[IB] ); + + for( auto &co4 : co3.second ) + { + const int LB = co4.first; +// Peize Lin test 2015-04-05 +{ + stringstream ss; + ss<<" "< +using std::vector; +#include +using std::map; +#include +using std::set; + +#include "exx_abfs.h" +#include "make_overlap_table.h" +#include "make_gaunt_table.h" +#include "center2_orb-orb22.h" + +class LCAO_Orbitals; + +class Exx_Abfs::Matrix_Lcaoslcaos_Lcaoslcaos +{ +public: + // mode: + // 1: + void init( + const int mode, + const double kmesh_times=1, // extend Kcut, keep dK + const double rmesh_times=1); // extend Rcut, keep dR + + void init_radial( + const vector>> &orb_A, + const vector>> &orb_B ); + void init_radial( + const LCAO_Orbitals &orb_A, + const LCAO_Orbitals &orb_B ); + + void init_radial_table(); + void init_radial_table( map>> &Rs ); // unit is ucell.lat0 + + map>>> cal_overlap_matrix( + const Element_Basis_Index::IndexLNM &index_r, + const Element_Basis_Index::IndexLNM &index_c ); + +private: + + Make_Overlap_Table MOT; + Make_Gaunt_Table MGT; + + map>>>>> center2_orb22_s; +}; +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs11.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs11.cpp new file mode 100644 index 0000000000..2b40ac5a1a --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs11.cpp @@ -0,0 +1,330 @@ +#include "exx_abfs-matrix_orbs11.h" + +#include +#include +#include "src_pw/global.h" +#include "src_lcao/lcao_orbitals.h" +#include "src_lcao/ylm.h" +#include "src_global/global_function.h" + +#include // Peize Lin test +#include "src_external/src_test/test_function.h" // Peize Lin test 2016-04-05 +#include "src_external/src_test/src_lcao/exx_lcao-test.h" +#include "src_lcao/global_fp.h" + +void Exx_Abfs::Matrix_Orbs11::init( + const int mode, + const double kmesh_times, + const double rmesh_times) +{ + TITLE("Exx_Abfs::Matrix_Orbs11","init"); + //========================================= + // (1) MOT: make overlap table. + //========================================= + +ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; +gettimeofday( &t_start, NULL); + MOT.allocate( + ORB.get_ntype(), // number of atom types + std::max( ORB.get_lmax(), Exx_Abfs::Lmax ), // max L used to calculate overlap + static_cast(ORB.get_kmesh() * kmesh_times) | 1, // kpoints, for integration in k space + ORB.get_Rmax() * rmesh_times, // max value of radial table + ORB.get_dR(), // delta R, for making radial table +// ORB.get_dk() / kmesh_times); // delta k, for integration in k space + ORB.get_dk()); // Peize Lin change 2017-04-16 +ofs<<"TIME@Exx_Abfs::Matrix_Orbs11::init::MOT.allocate\t"<>> &orb_A, + const vector>> &orb_B) +{ +ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; +gettimeofday( &t_start, NULL); + TITLE("Exx_Abfs::Matrix_Orbs11","init_radial"); + for( size_t TA = 0; TA!=orb_A.size(); ++TA ) + for( size_t TB=0; TB!=orb_B.size(); ++TB ) + for( int LA=0; LA!=orb_A[TA].size(); ++LA ) + for( size_t NA=0; NA!=orb_A[TA][LA].size(); ++NA ) + for( int LB=0; LB!=orb_B[TB].size(); ++LB ) + for( size_t NB=0; NB!=orb_B[TB][LB].size(); ++NB ) + center2_orb11_s[TA][TB][LA][NA][LB].insert( + make_pair(NB, Center2_Orb::Orb11( + orb_A[TA][LA][NA], + orb_B[TB][LB][NB], + MOT, MGT))); +ofs<<"TIME@Exx_Abfs::Matrix_Orbs11::init_radial\t"<>> &Rs ) +{ +ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; +gettimeofday( &t_start, NULL); + TITLE("Exx_Abfs::Matrix_Orbs11","init_radial_table_Rs"); + for( const auto &RsA : Rs ) + for( const auto &RsB : RsA.second ) + { + set radials; + for( const double &R : RsB.second ) + { + const double position = R * ucell.lat0 / MOT.dr; + const size_t iq = static_cast(position); + for( size_t i=0; i!=4; ++i ) + radials.insert(iq+i); + } + + #if TEST_EXX_LCAO==1 + { + static int i=0; + ofstream ofs("Matrix_Orbs_Orbs_radials_"+TO_STRING(i++)); + for( const auto r : radials ) + ofs<>>> Matrix_Orbs11::cal_overlap_matrix( + const Exx_Abfs::Abfs_Index::Index &index_r, + const Exx_Abfs::Abfs_Index::Index &index_c ) +{ + map>>> matrix_V; + + for( auto &co1 : center2_orb11_s ) + { + const size_t TA = co1.first; + for (size_t IA=0; IA!=ucell.atoms[TA].na; ++IA) + { + const Vector3 &tauA( ucell.atoms[TA].tau[IA] ); + GridD.Find_atom(tauA); + + for( auto &co2 : co1.second ) + { + const int LA = co2.first; + for( size_t MA=0; MA!=2*LA+1; ++MA) + { + for( auto &co3 : co2.second ) + { + const size_t NA = co3.first; + for (int ad = 0; ad < GridD.getAdjacentNum()+1; ++ad) + { + for( auto &co4 : co3.second ) + { + const size_t TB = co4.first; + if( TB != GridD.getType(ad) ) + continue; + const Vector3 &tauB( GridD.getAdjacentTau(ad) ); + const size_t IB = GridD.getNatom(ad); + + for( auto &co5 : co4.second ) + { + const int LB = co5.first; + for( size_t MB=0; MB!=2*LB+1; ++MB) + { + for( auto &co6 : co5.second ) + { + const size_t NB = co6.firs; + co6.second.cal_ST_Phi12_R(tauA, tauB, MA, MB); + + matrix_V[TA][IA][TB][IB]( index_r[TA][LA][MA][NA], index_c[TB][LB][MB][NB] ) = co6.second.olm[0]; + } + } + } + } + } + } + } + } + } + } + return matrix_V; +} +*/ + +matrix Exx_Abfs::Matrix_Orbs11::cal_overlap_matrix( + const size_t TA, + const size_t TB, + const Vector3 &tauA, + const Vector3 &tauB, + const Element_Basis_Index::IndexLNM &index_r, + const Element_Basis_Index::IndexLNM &index_c ) const +{ +// TITLE("Exx_Abfs::Matrix_Orbs11","cal_overlap_matrix"); + + matrix m( index_r[TA].count_size, index_c[TB].count_size ); + + for( const auto &co3 : center2_orb11_s.at(TA).at(TB) ) + { + const int LA = co3.first; + for( const auto &co4 : co3.second ) + { + const size_t NA = co4.first; + for( size_t MA=0; MA!=2*LA+1; ++MA ) + { + for( const auto &co5 : co4.second ) + { + const int LB = co5.first; + for( const auto &co6 : co5.second ) + { + const size_t NB = co6.first; + for( size_t MB=0; MB!=2*LB+1; ++MB ) + { +//if(TA==TB&&LA==LB&&NA==NB&&MA==MB) {exx_cout_flag=true; cout<>>> Exx_Abfs::Matrix_Orbs11::cal_overlap_matrix( + const Element_Basis_Index::IndexLNM &index_r, + const Element_Basis_Index::IndexLNM &index_c ) const +{ +ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; +gettimeofday( &t_start, NULL); + TITLE("Exx_Abfs::Matrix_Orbs11","cal_overlap_matrix"); + + map>>> matrixes; + + for( const auto &co1 : center2_orb11_s ) + { + const size_t TA = co1.first; + for (size_t IA=0; IA!=ucell.atoms[TA].na; ++IA) + { + const Vector3 &tauA( ucell.atoms[TA].tau[IA] ); + + for( const auto &co2 : co1.second ) + { + const size_t TB = co2.first; + for (size_t IB=0; IB!=ucell.atoms[TB].na; ++IB) + { + const Vector3 &tauB( ucell.atoms[TB].tau[IB] ); + + matrixes[TA][IA][TB][IB] = cal_overlap_matrix( TA, TB, tauA, tauB, index_r, index_c ); + } + } + } + } +ofs<<"TIME@Exx_Abfs::Matrix_Orbs11::cal_overlap_matrix\t"< +using std::vector; +#include +using std::map; +#include +using std::set; + +#include "exx_abfs.h" +#include "make_overlap_table.h" +#include "make_gaunt_table.h" +#include "center2_orb-orb11.h" + +class LCAO_Orbitals; + +class Exx_Abfs::Matrix_Orbs11 +{ +public: + // mode: + // 1: + // 2: + void init( + const int mode, + const double kmesh_times=1, // extend Kcut, keep dK + const double rmesh_times=1); // extend Rcut, keep dR + + void init_radial( + const vector>> &orb_A, + const vector>> &orb_B); + void init_radial( + const LCAO_Orbitals &orb_A, + const LCAO_Orbitals &orb_B); + + void init_radial_table(); + void init_radial_table( const map>> &Rs ); // unit: ucell.lat0 + + matrix cal_overlap_matrix( + const size_t TA, + const size_t TB, + const Vector3 &tauA, // unit: ucell.lat0 + const Vector3 &tauB, // unit: ucell.lat0 + const Element_Basis_Index::IndexLNM &index_r, + const Element_Basis_Index::IndexLNM &index_c ) const; + map>>> cal_overlap_matrix( + const Element_Basis_Index::IndexLNM &index_r, + const Element_Basis_Index::IndexLNM &index_c ) const; + +protected: + Make_Overlap_Table MOT; + Make_Gaunt_Table MGT; + + map>>>>> center2_orb11_s; +}; + +// this->center2_orb11_s[TA][TB][LA][NA][LB][NB] + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs21.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs21.cpp new file mode 100644 index 0000000000..8b05191b55 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs21.cpp @@ -0,0 +1,530 @@ +#include "exx_abfs-matrix_orbs21.h" + +#include "exx_abfs.h" +#include "exx_abfs-abfs_index.h" + +#include +#include +#include "src_pw/global.h" +#include "src_lcao/lcao_orbitals.h" +#include "src_lcao/ylm.h" + +#include // Peize Lin test +#include "src_external/src_test/test_function.h" // Peize Lin test 2016-04-05 +#include "src_external/src_test/src_lcao/exx_lcao-test.h" +#include "src_lcao/global_fp.h" + +void Exx_Abfs::Matrix_Orbs21::init( + const int mode, + const double kmesh_times, + const double rmesh_times) +{ + TITLE("Exx_Abfs::Matrix_Orbs21","init"); + //========================================= + // (1) MOT: make overlap table. + //========================================= +ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; +gettimeofday( &t_start, NULL); + MOT.allocate( + ORB.get_ntype(), // number of atom types + std::max( ORB.get_lmax(), Exx_Abfs::Lmax ), // max L used to calculate overlap + static_cast(ORB.get_kmesh() * kmesh_times) | 1, // kpoints, for integration in k space + ORB.get_Rmax() * rmesh_times, // max value of radial table + ORB.get_dR(), // delta R, for making radial table +// ORB.get_dk() / kmesh_times); // delta k, for integration in k space + ORB.get_dk()); // Peize Lin change 2017-04-16 +ofs<<"TIME@Exx_Abfs::Matrix_Orbs21::init::MOT.allocate\t"<>> &orb_A1, + const vector>> &orb_A2, + const vector>> &orb_B ) +{ +ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; +gettimeofday( &t_start, NULL); + + TITLE("Exx_Abfs::Matrix_Orbs21","init_radial"); + + assert(orb_A1.size()==orb_A2.size()); + for( size_t TA=0; TA!=orb_A1.size(); ++TA ) + for( size_t TB=0; TB!=orb_B.size(); ++TB ) + for( int LA1=0; LA1!=orb_A1[TA].size(); ++LA1 ) + for( size_t NA1=0; NA1!=orb_A1[TA][LA1].size(); ++NA1 ) + for( int LA2=0; LA2!=orb_A2[TA].size(); ++LA2 ) + for( size_t NA2=0; NA2!=orb_A2[TA][LA2].size(); ++NA2 ) + for( int LB=0; LB!=orb_B[TB].size(); ++LB ) + for( size_t NB=0; NB!=orb_B[TB][LB].size(); ++NB ) + center2_orb21_s[TA][TB][LA1][NA1][LA2][NA2][LB].insert( + make_pair(NB, Center2_Orb::Orb21( + orb_A1[TA][LA1][NA1], + orb_A2[TA][LA2][NA2], + orb_B[TB][LB][NB], + MOT, MGT))); +ofs<<"TIME@Exx_Abfs::Matrix_Orbs21::init_radial\t"<>> &orb_A1, + const LCAO_Orbitals &orb_A2, + const LCAO_Orbitals &orb_B ) +{ +ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; +gettimeofday( &t_start, NULL); + + TITLE("Exx_Abfs::Matrix_Orbs21","init_radial"); + + assert( orb_A1.size() == orb_A2.get_ntype() ); + for( size_t TA=0; TA!=orb_A1.size(); ++TA ) + for( size_t TB=0; TB!=orb_B.get_ntype(); ++TB) + for( int LA1=0; LA1!=orb_A1[TA].size(); ++LA1 ) + for( size_t NA1=0; NA1!=orb_A1[TA][LA1].size(); ++NA1 ) + for( int LA2=0; LA2<=orb_A2.Phi[TA].getLmax(); ++LA2 ) + for( size_t NA2=0; NA2!=orb_A2.Phi[TA].getNchi(LA2); ++NA2 ) + for( int LB=0; LB<=orb_B.Phi[TB].getLmax(); ++LB ) + for( size_t NB=0; NB!=orb_B.Phi[TB].getNchi(LB); ++NB ) + center2_orb21_s[TA][TB][LA1][NA1][LA2][NA2][LB].insert( + make_pair(NB, Center2_Orb::Orb21( + orb_A1[TA][LA1][NA1], + orb_A2.Phi[TA].PhiLN(LA2,NA2), + orb_B.Phi[TB].PhiLN(LB,NB), + MOT, MGT))); +ofs<<"TIME@Exx_Abfs::Matrix_Orbs21::init_radial\t"<>> &Rs ) +{ +ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; +gettimeofday( &t_start, NULL); + + TITLE("Exx_Abfs::Matrix_Orbs21","init_radial_table_Rs"); + + for( const auto &RsA : Rs ) + for( const auto &RsB : RsA.second ) + { + set radials; + for( const double &R : RsB.second ) + { + const double position = R * ucell.lat0 / MOT.dr; + const size_t iq = static_cast(position); + for( size_t i=0; i!=4; ++i ) + radials.insert(iq+i); + } + + #if TEST_EXX_LCAO==1 + static int i=0; + ofstream ofs("Matrix_Orbsorbs_Orbs_radials_"+TO_STRING(i++)); + for( const auto r : radials ) + ofs<>>>> Matrix_Abfsphi_Phi::cal_overlap_matrix( + const Exx_Abfs::Abfs_Index::Index &index_abfs, + const Exx_Abfs::Abfs_Index::Index &index_orb ) +{ + map>>>> matrix_A; + + for( auto &co1 : center2_orb21_s ) + { + const size_t TA = co1.first; + for (size_t IA=0; IA!=ucell.atoms[TA].na; ++IA) + { + const Vector3 &tauA( ucell.atoms[TA].tau[IA] ); + GridD.Find_atom(tauA); + + for( auto &co2 : co1.second ) + { + const int LA1 = co2.first; + for( size_t MA1=0; MA1!=2*LA1+1; ++MA1) + { + for( auto &co3 : co2.second ) + { + const size_t NA1 = co3.first; + for( auto &co4 : co3.second ) + { + const int LA2 = co4.first; + for( size_t MA2=0; MA2!=2*LA2+1; ++MA2) + { + for( auto &co5 : co4.second ) + { + const size_t NA2 = co4.first; + for (int ad = 0; ad < GridD.getAdjacentNum()+1; ++ad) + { + for( auto &co6 : co5.second ) + { + const size_t TB = co6.first; + if( TB != GridD.getType(ad) ) + continue; + const Vector3 &tauB( GridD.getAdjacentTau(ad) ); + const size_t IB = GridD.getNatom(ad); + + for( auto &co7 : co6.second ) + { + const int LB = co7.first; + for( size_t MB=0; MB!=2*LB+1; ++MB) + { + for( auto &co8 : co7.second ) + { + const size_t NB = co8.first; + co8.second.cal_ST_Phi12_R(tauA, tauB, MA1, MA2, MB); + + matrix_A[TA][IA][TB][IB][0]( Exx_Abfs::Abfs_Index::get_index_index( index_orb,TA,LA2,MA2,NA2, index_orb,TB,LB,MB,NB ), index_abfs[TA][LA1][MA1][NA1] ) + = matrix_A[TB][IB][TA][IA][1]( Exx_Abfs::Abfs_Index::get_index_index( index_orb,TB,LB,MB,NB, index_orb,TA,LA2,MA2,NA2 ), index_abfs[TA][LA1][MA1][NA1] ) + = co8.second.olm[0]; + } + } + } + } + } + } + } + } + } + } + } + } + } + return matrix_A; +}*/ + +matrix Exx_Abfs::Matrix_Orbs21::cal_overlap_matrix( + const size_t TA, + const size_t TB, + const Vector3 &tauA, + const Vector3 &tauB, + const Element_Basis_Index::IndexLNM &index_A1, + const Element_Basis_Index::IndexLNM &index_A2, + const Element_Basis_Index::IndexLNM &index_B, + const Matrix_Order &matrix_order) const +{ + TITLE("Exx_Abfs::Matrix_Orbs21","cal_overlap_matrix"); + + matrix m; + switch(matrix_order) + { + case Matrix_Order::A2B_A1: m.create( index_A2[TA].count_size*index_B [TB].count_size, index_A1[TA].count_size ); break; + case Matrix_Order::BA2_A1: m.create( index_B [TB].count_size*index_A2[TA].count_size, index_A1[TA].count_size ); break; + default: throw invalid_argument( "Matrix_Order wrong in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__) ); + } + + for( const auto &co3 : center2_orb21_s.at(TA).at(TB) ) + { + const int LA1 = co3.first; + for( const auto &co4 : co3.second ) + { + const size_t NA1 = co4.first; + for( size_t MA1=0; MA1!=2*LA1+1; ++MA1 ) + { + for( const auto &co5 : co4.second ) + { + const int LA2 = co5.first; + for( const auto &co6 : co5.second ) + { + const size_t NA2 = co6.first; + for( size_t MA2=0; MA2!=2*LA2+1; ++MA2 ) + { + for( const auto &co7 : co6.second ) + { + const int LB = co7.first; + for( const auto &co8 : co7.second ) + { + const size_t NB = co8.first; + for( size_t MB=0; MB!=2*LB+1; ++MB ) + { + const double overlap = co8.second.cal_overlap( tauA*ucell.lat0, tauB*ucell.lat0, MA1, MA2, MB ); + + switch(matrix_order) + { + case Matrix_Order::A2B_A1: + m( + Exx_Abfs::Abfs_Index::get_index_index( + index_A2,TA,LA2,NA2,MA2, + index_B,TB,LB,NB,MB ), + index_A1[TA][LA1][NA1][MA1] ) + = overlap; + break; + case Matrix_Order::BA2_A1: + m( + Exx_Abfs::Abfs_Index::get_index_index( + index_B,TB,LB,NB,MB, + index_A2,TA,LA2,NA2,MA2), + index_A1[TA][LA1][NA1][MA1] ) + = overlap; + break; + default: throw invalid_argument( "Matrix_Order wrong in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__) ); + } + } + } + } + } + } + } + } + } + } + return m; +} + +vector Exx_Abfs::Matrix_Orbs21::cal_overlap_matrix( + const size_t TA, + const size_t TB, + const Vector3 &tauA, + const Vector3 &tauB, + const Element_Basis_Index::IndexLNM &index_A1, + const Element_Basis_Index::IndexLNM &index_A2, + const Element_Basis_Index::IndexLNM &index_B) const +{ + TITLE("Exx_Abfs::Matrix_Orbs21","cal_overlap_matrix"); + + matrix m_A2B_A1( index_A2[TA].count_size*index_B[TB].count_size, index_A1[TA].count_size ); + matrix m_BA2_A1( index_B[TB].count_size*index_A2[TA].count_size, index_A1[TA].count_size ); + + for( const auto &co3 : center2_orb21_s.at(TA).at(TB) ) + { + const int LA1 = co3.first; + for( const auto &co4 : co3.second ) + { + const size_t NA1 = co4.first; + for( size_t MA1=0; MA1!=2*LA1+1; ++MA1 ) + { + for( const auto &co5 : co4.second ) + { + const int LA2 = co5.first; + for( const auto &co6 : co5.second ) + { + const size_t NA2 = co6.first; + for( size_t MA2=0; MA2!=2*LA2+1; ++MA2 ) + { + for( const auto &co7 : co6.second ) + { + const int LB = co7.first; + for( const auto &co8 : co7.second ) + { + const size_t NB = co8.first; + for( size_t MB=0; MB!=2*LB+1; ++MB ) + { + const double overlap = co8.second.cal_overlap( tauA*ucell.lat0, tauB*ucell.lat0, MA1, MA2, MB ); + + m_A2B_A1( + Exx_Abfs::Abfs_Index::get_index_index( + index_A2,TA,LA2,NA2,MA2, + index_B,TB,LB,NB,MB ), + index_A1[TA][LA1][NA1][MA1] ) + = m_BA2_A1( + Exx_Abfs::Abfs_Index::get_index_index( + index_B,TB,LB,NB,MB, + index_A2,TA,LA2,NA2,MA2), + index_A1[TA][LA1][NA1][MA1] ) + = overlap; + } + } + } + } + } + } + } + } + } + return vector{ std::move(m_A2B_A1), std::move(m_BA2_A1) }; +} + +map>>>> Exx_Abfs::Matrix_Orbs21::cal_overlap_matrix( + const Element_Basis_Index::IndexLNM &index_A1, + const Element_Basis_Index::IndexLNM &index_A2, + const Element_Basis_Index::IndexLNM &index_B) const +{ +ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; +gettimeofday( &t_start, NULL); + + TITLE("Exx_Abfs::Matrix_Orbs21","cal_overlap_matrix"); + + map>>>> matrixes; + + for( const auto &co1 : center2_orb21_s ) + { + const size_t TA = co1.first; + for( size_t IA=0; IA!=ucell.atoms[TA].na; ++IA ) + { + const Vector3 &tauA( ucell.atoms[TA].tau[IA] ); + + for( const auto &co2 : co1.second ) + { + const size_t TB = co2.first; + for( size_t IB=0; IB!=ucell.atoms[TB].na; ++IB ) + { + const Vector3 &tauB( ucell.atoms[TB].tau[IB] ); + + const vector &&m = cal_overlap_matrix( TA, TB, tauA, tauB, index_A1, index_A2, index_B ); + matrixes[TA][IA][TB][IB].resize(2); + matrixes[TA][IA][TB][IB][0] = std::move(m[0]); + matrixes[TB][IB][TA][IA].resize(2); + matrixes[TB][IB][TA][IA][1] = std::move(m[1]); +/* + matrixes[TA][IA][TB][IB].resize(2); + matrixes[TA][IA][TB][IB][0].create( index_A2[TA].count_size*index_B[TB].count_size, index_A1[TA].count_size ); + matrixes[TB][IB][TA][IA].resize(2); + matrixes[TB][IB][TA][IA][1].create( index_B[TB].count_size*index_A2[TA].count_size, index_A1[TA].count_size ); + + for( const auto &co3 : co2.second ) + { + const size_t LA1 = co3.first; + for( const auto &co4 : co3.second ) + { + const size_t NA1 = co4.first; + for( size_t MA1=0; MA1!=2*LA1+1; ++MA1 ) + { + for( const auto &co5 : co4.second ) + { + const size_t LA2 = co5.first; + for( const auto &co6 : co5.second ) + { + const size_t NA2 = co6.first; + for( size_t MA2=0; MA2!=2*LA2+1; ++MA2 ) + { + for( const auto &co7 : co6.second ) + { + const size_t LB = co7.first; + for( const auto &co8 : co7.second ) + { + const size_t NB = co8.first; + for( size_t MB=0; MB!=2*LB+1; ++MB ) + { + + // Peize Lin test // Peize Lin test +// { +// ofstream ofs("orb11-i_exp",ofstream::app); +// ofs< +using std::vector; +#include +using std::map; +#include +using std::set; + +#include "exx_abfs.h" +#include "make_overlap_table.h" +#include "make_gaunt_table.h" +#include "center2_orb-orb21.h" + +class LCAO_Orbitals; + +class Exx_Abfs::Matrix_Orbs21 +{ +public: + // mode: + // 1: + void init( + const int mode, + const double kmesh_times=1, // extend Kcut, keep dK + const double rmesh_times=1); // extend Rcut, keep dR + + void init_radial( + const vector>> &orb_A1, + const vector>> &orb_A2, + const vector>> &orb_B ); + void init_radial( + const vector>> &orb_A1, + const LCAO_Orbitals &orb_A2, + const LCAO_Orbitals &orb_B ); + + void init_radial_table(); + void init_radial_table( const map>> &Rs ); // unit: ucell.lat0 + + enum class Matrix_Order{A2B_A1,BA2_A1}; + matrix cal_overlap_matrix( + const size_t TA, + const size_t TB, + const Vector3 &tauA, // unit: ucell.lat0 + const Vector3 &tauB, // unit: ucell.lat0 + const Element_Basis_Index::IndexLNM &index_A1, + const Element_Basis_Index::IndexLNM &index_A2, + const Element_Basis_Index::IndexLNM &index_B, + const Matrix_Order &matrix_order) const; + vector cal_overlap_matrix( + const size_t TA, + const size_t TB, + const Vector3 &tauA, // unit: ucell.lat0 + const Vector3 &tauB, // unit: ucell.lat0 + const Element_Basis_Index::IndexLNM &index_A1, + const Element_Basis_Index::IndexLNM &index_A2, + const Element_Basis_Index::IndexLNM &index_B) const; + map>>>> cal_overlap_matrix( + const Element_Basis_Index::IndexLNM &index_A1, + const Element_Basis_Index::IndexLNM &index_A2, + const Element_Basis_Index::IndexLNM &index_B) const; + +protected: + Make_Overlap_Table MOT; + Make_Gaunt_Table MGT; + + map>>>>>>> center2_orb21_s; +}; + +// this->center2_orb21_s[TA][TB][LA1][NA1][LA2][NA2][LB][NB] + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs22.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs22.cpp new file mode 100644 index 0000000000..488ae7b77e --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs22.cpp @@ -0,0 +1,304 @@ +#include "exx_abfs-matrix_orbs22.h" + +#include "exx_abfs.h" +#include "exx_abfs-abfs_index.h" + +#include "src_pw/global.h" +#include "src_lcao/lcao_orbitals.h" +#include "src_lcao/ylm.h" + +#include "../src_external/src_test/test_function.h" // Peize Lin test 2016-04-05 +#include "src_external/src_test/src_lcao/exx_lcao-test.h" +#include "src_lcao/global_fp.h" + +void Exx_Abfs::Matrix_Orbs22::init( + const int mode, + const double kmesh_times, + const double rmesh_times) +{ +ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; +gettimeofday( &t_start, NULL); + + //========================================= + // (1) MOT: make overlap table. + //========================================= + MOT.allocate( + ORB.get_ntype(), // number of atom types + ORB.get_lmax(), // max L used to calculate overlap + static_cast(ORB.get_kmesh() * kmesh_times) | 1, // kpoints, for integration in k space + ORB.get_Rmax() * rmesh_times, // max value of radial table + ORB.get_dR(), // delta R, for making radial table +// ORB.get_dk() / kmesh_times); // delta k, for integration in k space + ORB.get_dk()); // Peize Lin change 2017-04-16 + int Lmax_used, Lmax; + MOT.init_Table_Spherical_Bessel (4,mode, Lmax_used, Lmax); +// MOT.init_OV_Tpair(); // for MOT.OV_L2plus1 +// MOT.Destroy_Table_Spherical_Bessel (Lmax_used); // why? + + //========================================= + // (2) init Ylm Coef + //========================================= + Ylm::set_coefficients (); + + //========================================= + // (3) make Gaunt coefficients table + //========================================= + MGT.init_Gaunt_CH( 2*Lmax+1 ); // why +1 + MGT.init_Gaunt( 2*Lmax+1 ); +ofs<<"TIME@Exx_Abfs::Matrix_Orbs22::init\t"<>> &orb_A1, + const vector>> &orb_A2, + const vector>> &orb_B1, + const vector>> &orb_B2 ) +{ +ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; +gettimeofday( &t_start, NULL); + TITLE("Exx_Abfs::Matrix_Orbs22","init_radial"); + + assert(orb_A1.size()==orb_A2.size()); + assert(orb_B1.size()==orb_B2.size()); + for( size_t TA = 0; TA!=orb_A1.size(); ++TA ) + for( size_t TB=0; TB!=orb_B1.size(); ++TB ) + for( int LA1=0; LA1!=orb_A1[TA].size(); ++LA1 ) + for( size_t NA1=0; NA1!=orb_A1[TA][LA1].size(); ++NA1 ) + for( int LA2=0; LA2!=orb_A2[TA].size(); ++LA2 ) + for( size_t NA2=0; NA2!=orb_A2[TA][LA2].size(); ++NA2 ) + for( int LB1=0; LB1!=orb_B1[TB].size(); ++LB1 ) + for( size_t NB1=0; NB1!=orb_B1[TB][LB1].size(); ++NB1 ) + for( size_t LB2=0; LB2!=orb_B2[TB].size(); ++LB2 ) + for( size_t NB2=0; NB2!=orb_B2[TB][LB2].size(); ++NB2 ) + center2_orb22_s[TA][TB][LA1][NA1][LA2][NA2][LB1][NB1][LB2].insert( + make_pair(NB2, Center2_Orb::Orb22( + orb_A1[TA][LA1][NA1], + orb_A2[TA][LA2][NA2], + orb_B1[TB][LB1][NB1], + orb_B2[TB][LB2][NB2], + MOT, MGT))); +ofs<<"TIME@Exx_Abfs::Matrix_Orbs22::init_radial\t"<>> &Rs ) +{ +ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; +gettimeofday( &t_start, NULL); + TITLE("Exx_Abfs::Matrix_Orbs22","init_radial_table_Rs"); + + for( const auto &RsA : Rs ) + for( const auto &RsB : RsA.second ) + { + set radials; + for( const double &R : RsB.second ) + { + const double position = R * ucell.lat0 / MOT.dr; + const size_t iq = static_cast(position); + for( size_t i=0; i!=4; ++i ) + radials.insert(iq+i); + } + + for( auto &coC : center2_orb22_s.at(RsA.first).at(RsB.first) ) + for( auto &coD : coC.second ) + for( auto &coE : coD.second ) + for( auto &coF : coE.second ) + for( auto &coG : coF.second ) + for( auto &coH : coG.second ) + for( auto &coI : coH.second ) + for( auto &coJ : coI.second ) + coJ.second.init_radial_table(radials); + } +ofs<<"TIME@Exx_Abfs::Matrix_Orbs22::init_radial_table\t"< &tauA, + const Vector3 &tauB, + const Element_Basis_Index::IndexLNM &index_A1, + const Element_Basis_Index::IndexLNM &index_A2, + const Element_Basis_Index::IndexLNM &index_B1, + const Element_Basis_Index::IndexLNM &index_B2, + const Matrix_Order &matrix_order) const +{ + TITLE("Exx_Abfs::Matrix_Orbs22","cal_overlap_matrix"); + + matrix m; + switch(matrix_order) + { + case Matrix_Order::A1B1_A2B2: m.create( index_A1[TA].count_size*index_B1[TB].count_size, index_A2[TA].count_size*index_B2[TB].count_size ); break; + default: throw invalid_argument( "Matrix_Order wrong in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__) ); + } + + for( const auto &co3 : center2_orb22_s.at(TA).at(TB) ) + { + const int LA1 = co3.first; + for( const auto &co4 : co3.second ) + { + const size_t NA1 = co4.first; + for( size_t MA1=0; MA1!=2*LA1+1; ++MA1 ) + { + for( const auto &co5 : co4.second ) + { + const int LA2 = co5.first; + for( const auto &co6 : co5.second ) + { + const size_t NA2 = co6.first; + for( size_t MA2=0; MA2!=2*LA2+1; ++MA2 ) + { + for( const auto &co7 : co6.second ) + { + const int LB1 = co7.first; + for( const auto &co8 : co7.second ) + { + const size_t NB1 = co8.first; + for( size_t MB1=0; MB1!=2*LB1+1; ++MB1 ) + { + for( const auto &co9 : co8.second ) + { + const int LB2 = co9.first; + for( const auto & co10 : co9.second ) + { + const size_t NB2 = co10.first; + for( size_t MB2=0; MB2!=2*LB2+1; ++MB2 ) + { + + const double overlap = co10.second.cal_overlap( tauA*ucell.lat0, tauB*ucell.lat0, MA1, MA2, MB1, MB2 ); + + switch(matrix_order) + { + case Matrix_Order::A1B1_A2B2: + m( + Exx_Abfs::Abfs_Index::get_index_index( + index_A1,TA,LA1,NA1,MA1, + index_B1,TB,LB1,NB1,MB1 ), + Exx_Abfs::Abfs_Index::get_index_index( + index_A2,TA,LA2,NA2,MA2, + index_B2,TB,LB2,NB2,MB2 ) ) + = overlap; + break; + default: throw invalid_argument( "Matrix_Order wrong in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__) ); + } + } + } + } + } + } + } + } + } + } + } + } + } + return m; +} + + +map>>> Exx_Abfs::Matrix_Orbs22::cal_overlap_matrix( + const Element_Basis_Index::IndexLNM &index_A1, + const Element_Basis_Index::IndexLNM &index_A2, + const Element_Basis_Index::IndexLNM &index_B1, + const Element_Basis_Index::IndexLNM &index_B2 ) const +{ +ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; +gettimeofday( &t_start, NULL); + map>>> matrixes; + + for( const auto &co1 : center2_orb22_s ) + { + const size_t TA = co1.first; + for( size_t IA=0; IA!=ucell.atoms[TA].na; ++IA ) + { + const Vector3 &tauA( ucell.atoms[TA].tau[IA] ); + + for( const auto &co2 : co1.second ) + { + const size_t TB = co2.first; + for( size_t IB=0; IB!=ucell.atoms[TB].na; ++IB ) + { + const Vector3 &tauB( ucell.atoms[TB].tau[IB] ); + + matrixes[TA][IA][TB][IB] = cal_overlap_matrix( + TA, + TB, + ucell.atoms[TA].tau[IA], + ucell.atoms[TB].tau[IB], + index_A1, + index_A2, + index_B1, + index_B2, + Matrix_Order::A1B1_A2B2); + } + } + } + } +ofs<<"TIME@Exx_Abfs::Matrix_Orbs22::cal_overlap_matrix\t"< +using std::map; + +#include "exx_abfs.h" +#include "make_overlap_table.h" +#include "make_gaunt_table.h" +#include "center2_orb-orb22.h" + +class LCAO_Orbitals; + +class Exx_Abfs::Matrix_Orbs22 +{ +public: + // mode: + // 1: + void init( + const int mode, + const double kmesh_times=1, // extend Kcut, keep dK + const double rmesh_times=1); // extend Rcut, keep dR + + void init_radial( + const vector>> &orb_A1, + const vector>> &orb_A2, + const vector>> &orb_B1, + const vector>> &orb_B2 ); + void init_radial( + const LCAO_Orbitals &orb_A1, + const LCAO_Orbitals &orb_A2, + const LCAO_Orbitals &orb_B1, + const LCAO_Orbitals &orb_B2 ); + + void init_radial_table(); + void init_radial_table( const map>> &Rs ); // unit is ucell.lat0 + + enum class Matrix_Order{A1B1_A2B2}; + matrix cal_overlap_matrix( + const size_t TA, + const size_t TB, + const Vector3 &tauA, + const Vector3 &tauB, + const Element_Basis_Index::IndexLNM &index_A1, + const Element_Basis_Index::IndexLNM &index_A2, + const Element_Basis_Index::IndexLNM &index_B1, + const Element_Basis_Index::IndexLNM &index_B2, + const Matrix_Order &matrix_order) const; + map>>> cal_overlap_matrix( + const Element_Basis_Index::IndexLNM &index_A1, + const Element_Basis_Index::IndexLNM &index_A2, + const Element_Basis_Index::IndexLNM &index_B1, + const Element_Basis_Index::IndexLNM &index_B2 ) const; + +private: + + Make_Overlap_Table MOT; + Make_Gaunt_Table MGT; + + map>>>>>>>>> center2_orb22_s; +}; +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-allreduce-template.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-allreduce-template.h new file mode 100644 index 0000000000..0b628bbaab --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-allreduce-template.h @@ -0,0 +1,167 @@ +#ifndef EXX_ABFS_PARALLEL_COMMUNICATE_ALLREDUCE_TEMPLATE_H +#define EXX_ABFS_PARALLEL_COMMUNICATE_ALLREDUCE_TEMPLATE_H + +#include "exx_abfs-parallel-communicate-allreduce.h" + +#include + +#include +#include +#include "src_global/boost_serialization.h" + +#include +#include + +#ifdef _OPENMP +#include +#endif + +#include "src_external/src_test/src_lcao/exx_lcao-test.h" + + +template< typename T > +T Exx_Abfs::Parallel::Communicate::Allreduce::allreduce( + T & data_local, + std::function & insert_function) +{ +ofstream ofs_mpi( "allreduce_"+TO_STRING(my_rank), ofstream::app ); +timeval t_start; +double t_probe=0, t_recv=0; + + vector threads; + atomic_flag insert_lock = ATOMIC_FLAG_INIT; + atomic rank_delta=1; + for( int i=0; i<2; ++i ) + ask(rank_delta++); + +gettimeofday(&t_start,NULL); + boost::mpi::packed_oarchive oar(mpi_comm); + oar << data_local; +ofs_mpi<<"sizeof_oar:\t"< request_isends(comm_sz); + boost::dynamic_bitset<> flag_isends(comm_sz,false); + flag_isends[my_rank] = true; + +gettimeofday(&t_start,NULL); + T data_all; + insert_function( data_all, data_local ); + boost::dynamic_bitset<> flag_irecvs(comm_sz,false); + flag_irecvs[my_rank] = true; +ofs_mpi<<"insert\t"< iarps( comm_sz ); + for( auto &iarp : iarps ) + iarp = new boost::mpi::packed_iarchive{MPI_COMM_WORLD}; + + #ifdef _OPENMP + const int omp_threads = omp_get_max_threads(); + omp_set_num_threads(1); + #endif + + while( !flag_irecvs.all() || !flag_isends.all() ) + { + MPI_Status status; +gettimeofday(&t_start,NULL); + MPI_Probe( MPI_ANY_SOURCE, MPI_ANY_TAG, mpi_comm, &status ); +t_probe+=time_during(t_start); + switch(status.MPI_TAG) + { + case tag_ask: + { + const int rank_send = status.MPI_SOURCE; + int message_ignore; +gettimeofday(&t_start,NULL); + MPI_Recv( &message_ignore, 1, MPI_INT, rank_send, tag_ask, mpi_comm, MPI_STATUS_IGNORE ); +t_recv+=time_during(t_start); + MPI_Isend( oar.address(), oar.size(), MPI_PACKED, rank_send, tag_data, mpi_comm, &request_isends[rank_send] ); + flag_isends[rank_send] = true; + break; + } + case tag_data: + { + const int rank_recv = status.MPI_SOURCE; + + int data_size; + MPI_Get_count( &status, MPI_PACKED, &data_size ); + boost::mpi::packed_iarchive & iar = *iarps[rank_recv]; + iar.resize(data_size); + +gettimeofday(&t_start,NULL); + MPI_Recv( iar.address(), data_size, MPI_PACKED, rank_recv, tag_data, mpi_comm, MPI_STATUS_IGNORE ); +t_recv+=time_during(t_start); + + threads.push_back(std::thread( + &Exx_Abfs::Parallel::Communicate::Allreduce::allreduce_thread, this, + std::ref(iar), std::ref(insert_function), std::ref(data_all), + std::ref(rank_delta), std::ref(insert_lock) )); + flag_irecvs[rank_recv] = true; +ofs_mpi< +void Exx_Abfs::Parallel::Communicate::Allreduce::allreduce_thread( + boost::mpi::packed_iarchive &iar, + std::function &insert_function, + T &data_all, + atomic &rank_delta, + atomic_flag &insert_lock ) +{ +ofstream ofs_mpi( "allreduce_"+TO_STRING(my_rank)+"_"+TO_STRING(this_thread::get_id()), ofstream::app ); +timeval t_start; + +ofs_mpi<<"sizeof_iar:\t"<> data_rank; +ofs_mpi<>\t"< + +Exx_Abfs::Parallel::Communicate::Allreduce::Allreduce( const MPI_Comm & mpi_comm_in ) + :mpi_comm(mpi_comm_in) +{ + MPI_Comm_size( mpi_comm, &comm_sz ); + MPI_Comm_rank( mpi_comm, &my_rank ); +} + + +void Exx_Abfs::Parallel::Communicate::Allreduce::ask( const int rank_delta_now ) const +{ + if( rank_delta_now < comm_sz ) + { + const int rank_ask = ( my_rank + rank_delta_now ) % comm_sz; + MPI_Request request_ask; + MPI_Isend( &tag_ask, 1, MPI_INT, rank_ask, tag_ask, mpi_comm, &request_ask ); + } +} \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-allreduce.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-allreduce.h new file mode 100644 index 0000000000..28be739a47 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-allreduce.h @@ -0,0 +1,48 @@ +#ifndef EXX_ABFS_PARALLEL_COMMUNICATE_ALLREDUCE_H +#define EXX_ABFS_PARALLEL_COMMUNICATE_ALLREDUCE_H + +#include "exx_abfs-parallel.h" +#include +#include +#include + +/* + Here are 3 kinds of parallel: + 1. exx + 2. 2D for diag + 3. grid +*/ +class Exx_Abfs::Parallel::Communicate::Allreduce +{ +public: + + Allreduce( const MPI_Comm & mpi_comm_in ); + + template< typename T > + T allreduce( + T & data_local, + std::function & insert_function); // insert_function( data_all, data_rank ) + + +private: + + void ask( const int rank_delta_now ) const; + + template< typename T > + void allreduce_thread( + boost::mpi::packed_iarchive &iar, + std::function & insert_function, + T &data_all, + atomic &rank_delta, + atomic_flag &insert_lock ); + + int comm_sz; + int my_rank; + const MPI_Comm & mpi_comm; + + static constexpr int tag_ask = 1; + static constexpr int tag_data = 2; +}; + + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm-allreduce.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm-allreduce.cpp new file mode 100644 index 0000000000..5de737e839 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm-allreduce.cpp @@ -0,0 +1,591 @@ +#include "exx_abfs-parallel-communicate-dm.h" +#include "src_global/boost_serialization.h" + +#include +#ifdef _OPENMP +#include +#endif + +#include "src_external/src_test/src_lcao/exx_lcao-test.h" + +Exx_Abfs::Parallel::Communicate::DM::Allreduce::Allreduce( + const MPI_Comm & mpi_comm_in, + vector,matrix>>>> &data_local_in, + const Abfs::Vector3_Order &Born_von_Karman_period, + const set> &H_atom_pairs_core) + :mpi_comm(mpi_comm_in), + data_local(data_local_in), + lock_insert(ATOMIC_FLAG_INIT), + lock_atom_unset_read(0) +{ + data_all.resize(NSPIN); + + set> Born_Von_Karman_boxes; + for( int ix=0; ix!=Born_von_Karman_period.x; ++ix ) + for( int iy=0; iy!=Born_von_Karman_period.y; ++iy ) + for( int iz=0; iz!=Born_von_Karman_period.z; ++iz ) + Born_Von_Karman_boxes.insert({ix,iy,iz}); + for( const auto pair : H_atom_pairs_core ) + atom_unset[pair.first][pair.second] = Born_Von_Karman_boxes; + + MPI_Comm_size( mpi_comm, &comm_sz ); + MPI_Comm_rank( mpi_comm, &my_rank ); + + rank_delta = 1; + + oarps_isend_data.resize( comm_sz ); + for( auto &oarp_isend_data : oarps_isend_data ) + oarp_isend_data = new boost::mpi::packed_oarchive{mpi_comm}; + oarps_atom_unset.resize( comm_sz ); + for( auto &oarp_atom_unset : oarps_atom_unset ) + oarp_atom_unset = new boost::mpi::packed_oarchive{mpi_comm}; + iarps_recv_data.resize( comm_sz ); + for( auto &iarp_recv_data : iarps_recv_data ) + iarp_recv_data = new boost::mpi::packed_iarchive{mpi_comm}; + iarps_atom_asked.resize( comm_sz ); + for( auto &iarp_atom_asked : iarps_atom_asked ) + iarp_atom_asked = new boost::mpi::packed_iarchive{mpi_comm}; + + // 0: undo 1: thread finish 2: MPI begin + flags_isend_data.resize(comm_sz); + for( int irank=0; irank!=comm_sz; ++irank ) + flags_isend_data[irank] = new atomic(0); + *flags_isend_data[my_rank] = 2; + + flags_ask_atom.resize(comm_sz); + for( int irank=0; irank!=comm_sz; ++irank ) + flags_ask_atom[irank] = new atomic(0); + *flags_ask_atom[my_rank] = 2; + + flags_recv_data.resize(comm_sz,false); + flags_recv_data[my_rank] = true; +} + + +Exx_Abfs::Parallel::Communicate::DM::Allreduce::~Allreduce() +{ +//ofstream ofs_mpi("allreduce_"+TO_STRING(MY_RANK),ofstream::app); +//ofs_mpi<<"delete_begin\t"<<__FILE__<<__LINE__<,matrix>>>> +Exx_Abfs::Parallel::Communicate::DM::Allreduce::grid_to_exx() +{ +timeval t_start; +ofstream ofs_mpi("allreduce_"+TO_STRING(MY_RANK),ofstream::app); + + auto clear_oars = [&]( vector &requests, boost::dynamic_bitset<> &flags, vector &oarps, const string &s ) + { + if( flags.none() ) return; + for( int irank=0; irank!=comm_sz; ++irank ) + { + if( flags[irank] ) + { + int flag_finish; + if(MPI_SUCCESS!=MPI_Test( &requests[irank], &flag_finish, MPI_STATUS_IGNORE )) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + if( flag_finish ) + { +//ofs_mpi<<"delete_begin\t"<*> &flags ) -> bool + { + int sum=0; + for( size_t i=0; i threads; + + vector requests_isend_data(comm_sz); + vector requests_ask(comm_sz); + boost::dynamic_bitset<> flags_request_isend_data(comm_sz,false); + boost::dynamic_bitset<> flags_request_ask(comm_sz,false); + + #ifdef _OPENMP + const int omp_threads = omp_get_max_threads(); + omp_set_num_threads(1); + #endif + + while( !if_finish(flags_ask_atom) || !if_finish(flags_isend_data) || !flags_recv_data.all() ) + { + MPI_Status status; + int flag_message; + if(MPI_SUCCESS!=MPI_Iprobe( MPI_ANY_SOURCE, MPI_ANY_TAG, mpi_comm, &flag_message, &status )) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + if(flag_message) + { + int message_size; + if(MPI_SUCCESS!=MPI_Get_count( &status, MPI_PACKED, &message_size )) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + + switch(status.MPI_TAG) + { + case tag_ask: + { + const int rank_asked = status.MPI_SOURCE; + +gettimeofday(&t_start, NULL); + iarps_atom_asked[rank_asked]->resize(message_size); + if(MPI_SUCCESS!=MPI_Recv( iarps_atom_asked[rank_asked]->address(), message_size, MPI_PACKED, rank_asked, tag_ask, mpi_comm, MPI_STATUS_IGNORE )) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); +ofs_mpi<<"TIME@ MPI_Recv tag_ask\t"<resize(message_size); + if(MPI_SUCCESS!=MPI_Recv( iarps_recv_data[rank_data]->address(), message_size, MPI_PACKED, rank_data, tag_data, mpi_comm, MPI_STATUS_IGNORE )) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + flags_recv_data[rank_data] = true; +ofs_mpi<<"TIME@ MPI_Recv tag_data\t"<address(), oarps_atom_unset[rank_ask]->size(), MPI_PACKED, rank_ask, tag_ask, mpi_comm, &requests_ask[rank_ask] )) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + flags_request_ask[rank_ask] = true; + *flags_ask_atom[rank_ask] = 2; +ofs_mpi<<"TIME@ MPI_Isend atom_unset\t"<address(), oarps_isend_data[rank_asked]->size(), MPI_PACKED, rank_asked, tag_data, mpi_comm, &requests_isend_data[rank_asked] )) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + flags_request_isend_data[rank_asked] = true; + *flags_isend_data[rank_asked] = 2; +ofs_mpi<<"TIME@ MPI_Isend isend_data\t"<size()<,Matrix_Wrapper>>>> & v ) -> bool + { + for( const auto &i : v ) + if(!i.empty()) return false; + return true; + }; +timeval t_start; +ofstream ofs_thread("allreduce_"+TO_STRING(MY_RANK)+"_"+TO_STRING(this_thread::get_id()),ofstream::app); +ofs_thread<<"recv\t"<,Matrix_Wrapper>>>> data_rank; +gettimeofday(&t_start, NULL); + *iarps_recv_data[rank_data] >> data_rank; +ofs_thread<<"finish iarps_recv_data >>\t"<size()<>\t"<size()<resize(0); +//ofs_thread<<"delete_end\t"<<"iarps_recv_data\t"<,matrix>>>> &data_rank ) +{ + vector,matrix>>*> data_rank_Ap(NSPIN,nullptr); + vector,matrix>*> data_rank_Bp(NSPIN,nullptr); + vector data_rank_Cp(NSPIN,nullptr); +ofstream ofs_mpi("allreduce_"+TO_STRING(MY_RANK),ofstream::app); +ofs_mpi<<"insert_data"<first; + for( int is=0; is!=NSPIN; ++is ) data_rank_Ap[is] = static_cast,matrix>>*>( MAP_EXIST( data_rank[is], iat1 ) ); + if( !data_rank_Ap[0] ){ ++atom_unset_Ap; continue; } +//ofs_mpi<<" "<second.begin(); atom_unset_Bp!=atom_unset_Ap->second.end(); ) + { + const size_t iat2 = atom_unset_Bp->first; + for( int is=0; is!=NSPIN; ++is ) data_rank_Bp[is] = static_cast,matrix>*>( MAP_EXIST( *data_rank_Ap[is], iat2 ) ); + if( !data_rank_Bp[0] ){ ++atom_unset_Bp; continue; } +//ofs_mpi<<" "<second.begin(); atom_unset_Cp!=atom_unset_Bp->second.end(); ) + { + const Abfs::Vector3_Order &box2 = *atom_unset_Cp; + for( int is=0; is!=NSPIN; ++is ) data_rank_Cp[is] = static_cast( MAP_EXIST( *data_rank_Bp[is], box2 ) ); + if( !data_rank_Cp[0] ){ ++atom_unset_Cp; continue; } +//ofs_mpi<<" "<c ) + { + auto &data_all_C = data_all[is][iat1][iat2][box2]; + if(!data_all_C.c) + data_all_C = std::move(*data_rank_Cp[is]); + } + + atom_unset_Bp->second.erase( atom_unset_Cp++ ); + } + if( atom_unset_Bp->second.empty() ) + atom_unset_Ap->second.erase( atom_unset_Bp++ ); + else + ++atom_unset_Bp; + } + if( atom_unset_Ap->second.empty() ) + atom_unset.erase( atom_unset_Ap++ ); + else + ++atom_unset_Ap; + } +ofs_mpi<<"finish insert"<,Matrix_Wrapper>>>> &data_rank ) +{ + vector,Matrix_Wrapper>>*> data_rank_Ap(NSPIN,nullptr); + vector,Matrix_Wrapper>*> data_rank_Bp(NSPIN,nullptr); + vector data_rank_Cp(NSPIN,nullptr); +ofstream ofs_thread("allreduce_"+TO_STRING(MY_RANK)+"_"+TO_STRING(this_thread::get_id()),ofstream::app); +ofs_thread<<"insert_data"<first; + for( int is=0; is!=NSPIN; ++is ) data_rank_Ap[is] = static_cast,Matrix_Wrapper>>*>(MAP_EXIST( data_rank[is], iat1 )); + if( !data_rank_Ap[0] ){ ++atom_unset_Ap; continue; } +//ofs_thread<<" "<second.begin(); atom_unset_Bp!=atom_unset_Ap->second.end(); ) + { + const size_t iat2 = atom_unset_Bp->first; + for( int is=0; is!=NSPIN; ++is ) data_rank_Bp[is] = static_cast,Matrix_Wrapper>*>(MAP_EXIST( *data_rank_Ap[is], iat2 )); + if( !data_rank_Bp[0] ){ ++atom_unset_Bp; continue; } +//ofs_thread<<" "<second.begin(); atom_unset_Cp!=atom_unset_Bp->second.end(); ) + { + const Abfs::Vector3_Order &box2 = *atom_unset_Cp; + for( int is=0; is!=NSPIN; ++is ) data_rank_Cp[is] = static_cast(MAP_EXIST( *data_rank_Bp[is], box2 )); + if( !data_rank_Cp[0] ){ ++atom_unset_Cp; continue; } +//ofs_thread<<" "<c ) + { + auto & data_all_C = data_all[is][iat1][iat2][box2]; + if( !data_all_C.c ) + data_all_C = data_rank_Cp[is]->to_matrix(); + } + + atom_unset_Bp->second.erase( atom_unset_Cp++ ); + } + if( atom_unset_Bp->second.empty() ) + atom_unset_Ap->second.erase( atom_unset_Bp++ ); + else + ++atom_unset_Bp; + } + if( atom_unset_Ap->second.empty() ) + atom_unset.erase( atom_unset_Ap++ ); + else + ++atom_unset_Ap; + } +ofs_thread<<"finish insert"<>>> atom_asked; +gettimeofday(&t_start, NULL); + *iarps_atom_asked[rank_asked] >> atom_asked; +ofs_thread<<"finish iarps_atom_asked >>\t"<size()<>\t"<resize(0); +//ofs_thread<<"delete_end\t"<<"iarps_atom_asked\t"<,Matrix_Wrapper>>>> matrix_wrapped = get_data_local_wrapper(atom_asked); +ofs_thread<<"finish get_data_local_wrapper"<size()<,Matrix_Wrapper>>>> +Exx_Abfs::Parallel::Communicate::DM::Allreduce::get_data_local_wrapper( + const map>>> & atom_asked ) const +{ +//ofstream ofs_thread("allreduce_"+TO_STRING(MY_RANK)+"_"+TO_STRING(this_thread::get_id()),ofstream::app); +//ofs_thread<<"get_data_local_wrapper"<,Matrix_Wrapper>>>> mw(NSPIN); + for( int is=0; is!=NSPIN; ++is ) + { + auto &mw_is = mw[is]; + const auto &data_local_is = data_local[is]; + for( const auto & atom_asked_A : atom_asked ) + { + const size_t iat1 = atom_asked_A.first; + if( auto data_local_A = static_cast,matrix>> * const>(MAP_EXIST( data_local_is, iat1 )) ) + { + auto &mw_A = mw_is[iat1]; + for( const auto & atom_asked_B : atom_asked_A.second ) + { + const size_t iat2 = atom_asked_B.first; + if( auto data_local_B = static_cast,matrix> * const>(MAP_EXIST( *data_local_A, iat2 )) ) + { + auto &mw_B = mw_A[iat2]; + for( const auto & atom_asked_C : atom_asked_B.second ) + { + const Abfs::Vector3_Order &box2 = atom_asked_C; + if( auto data_local_C = static_cast(MAP_EXIST( *data_local_B, box2 )) ) + { + mw_B[box2] = *data_local_C; + } + } + } + } + } + } + } +//ofs_thread.close(); + return mw; +} +*/ + +vector,Matrix_Wrapper>>>> +Exx_Abfs::Parallel::Communicate::DM::Allreduce::get_data_local_wrapper( + const map>>> & atom_asked ) const +{ +ofstream ofs_thread("allreduce_"+TO_STRING(MY_RANK)+"_"+TO_STRING(this_thread::get_id()),ofstream::app); +ofs_thread<<"get_data_local_wrapper"<,Matrix_Wrapper>>>> mw(NSPIN); + for( int is=0; is!=NSPIN; ++is ) + { + auto &mw_is = mw[is]; + const auto &data_localw_is = data_localw[is]; + for( const auto & atom_asked_A : atom_asked ) + { + const size_t iat1 = atom_asked_A.first; + if( auto data_localw_A = static_cast,Matrix_Wrapper>> * const>(MAP_EXIST( data_localw_is, iat1 )) ) + { + auto &mw_A = mw_is[iat1]; + for( const auto & atom_asked_B : atom_asked_A.second ) + { + const size_t iat2 = atom_asked_B.first; + if( auto data_localw_B = static_cast,Matrix_Wrapper> * const>(MAP_EXIST( *data_localw_A, iat2 )) ) + { + auto &mw_B = mw_A[iat2]; + for( const auto & atom_asked_C : atom_asked_B.second ) + { + const Abfs::Vector3_Order &box2 = atom_asked_C; + if( auto data_localw_C = static_cast(MAP_EXIST( *data_localw_B, box2 )) ) + { + mw_B[box2] = *data_localw_C; + } + } + } + } + } + } + } +ofs_thread.close(); + return mw; +} + +vector,Matrix_Wrapper>>>> +Exx_Abfs::Parallel::Communicate::DM::Allreduce::get_data_local_wrapper() const +{ +ofstream ofs_thread("allreduce_"+TO_STRING(MY_RANK)+"_"+TO_STRING(this_thread::get_id()),ofstream::app); +ofs_thread<<"get_data_local_wrapper"<,Matrix_Wrapper>>>> mw(NSPIN); + for( int is=0; is!=NSPIN; ++is ) + { + const auto &data_local_is = data_local[is]; + auto &mw_is = mw[is]; + for( const auto &data_local_A : data_local_is ) + { + const size_t iat1 = data_local_A.first; + auto &mw_A = mw_is[iat1]; + for( const auto &data_local_B : data_local_A.second ) + { + const size_t iat2 = data_local_B.first; + auto &mw_B = mw_A[iat2]; + for( const auto &data_local_C : data_local_B.second ) + { + const Abfs::Vector3_Order &box2 = data_local_C.first; + mw_B[box2] = data_local_C.second; + } + } + } + } +ofs_thread.close(); + return mw; +} diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm.cpp new file mode 100644 index 0000000000..64a18710c0 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm.cpp @@ -0,0 +1,294 @@ +#include "exx_abfs-parallel-communicate-dm.h" +#include "src_lcao/global_fp.h" +#include "src_pw/global.h" +#include "src_lcao/record_adj.h" + +#include "src_external/src_test/src_lcao/exx_lcao-test.h" +#include "lcao_nnr.h" +//#include + +/* +void Exx_Abfs::Parallel::Communicate::DM::set_atom_in_exx( const set> &H_atom_pairs_core ) +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM::set_atom_in_exx"); + + atom_in_exx.row.resize(ucell.nat); + atom_in_exx.col.resize(ucell.nat); + for( const auto pair : H_atom_pairs_core ) + { + atom_in_exx.row[pair.first] = true; + atom_in_exx.col[pair.second] = true; + } +} +*/ + +/* +map,matrix>>> +Exx_Abfs::Parallel::Communicate::DM::m2D_to_a2Dexx( + const matrix &DM_m2D, + const int iwt1_index_begin, + const int iwt2_index_begin) const +{ + map,matrix>>> DM_a2Dexx; + for( int iwt1_m2D=0; iwt1_m2D(0,0,0))(iw1,iw2) = DM_m2D(iwt1_m2D,iwt2_m2D); + } + catch(const std::out_of_range&) + { + DM_a2Dexx[iat1][iat2][Abfs::Vector3_Order(0,0,0)].creat( + ucell.atoms[ucell.iat2it[iat1]].nw, + ucell.atoms[ucell.iat2it[iat2]].nw); + DM_a2Dexx[iat1][iat2][Abfs::Vector3_Order(0,0,0)](iw1,iw2) = DM_m2D(iwt1_m2D,iwt2_m2D); + } + } + } + return DM_a2Dexx; +} + + +Exx_Abfs::Parallel::Communicate::DM::a2Dexx_to_exx( + map,matrix>>> & m_exx, + map,matrix>>> & m_a2Dexx ) const +{ + for( size_t is=0; is!=NSPIN; ++is ) + { + for( auto & m_a2DexxA : m_a2Dexx[is] ) + { + const size_t iat1 = m_a2DexxA.first; + for( auto & m_a2DexxB : m_a2DexxA.second ) + { + const size_t iat2 = m_a2DexxB.first; + for( auto & m_a2DexxC : m_a2DexxB.second ) + { + const Abfs::Vector3_Order & box2 = m_a2DexxC.first; + if( m_a2DexxC.second.absmax() < threshold ) continue; + try { m_exx[is].at(iat1).at(iat2).at(box2) += m_a2DexxC.second ; } + catch(std::out_of_range&) { m_exx[is] [iat1] [iat2] [box2] = std::move(m_a2DexxC.second); } + } + } + } + m_a2Dexx[is].clear(); + } +} + + +Exx_Abfs::Parallel::Communicate::DM::f( + const matrix &DM_m2D, + const int iwt1_index_begin, + const int iwt2_index_begin) +{ + map,matrix>>> & DM_a2Dexx = + m2D_to_a2Dexx( DM_m2D, iwt1_index_begin, iwt2_index_begin ); + a2Dexx_to_exx( this->DMr, DM_a2Dexx ); +} +*/ + +void Exx_Abfs::Parallel::Communicate::DM::cal_DM( + const Abfs::Vector3_Order &Born_von_Karman_period, + const set> &H_atom_pairs_core, + const double threshold ) +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM::cal_DM"); + +ofstream ofs_time("time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; +//gettimeofday( &t_start, NULL); +#if false + vector,matrix>>>> DM_grid = LOC_to_grid( Born_von_Karman_period, threshold ); +//ofs_time<<"TIME@ Exx_Abfs::Parallel::Communicate::DM::LOC_to_grid\t"<DMr = allreduce.grid_to_exx(); +//ofs_time<<"TIME@ Exx_Abfs::Parallel::Communicate::DM::Allreduce::grid_to_exx\t"< vector,matrix>>>> + { + vector> Born_von_Karman_boxes; + for( int ix=0; ix,matrix>>>> DM_grid(NSPIN); + for( const auto &DMrA : dm_my.DMr ) + { + const size_t iat1 = DMrA.first; + for( const auto &DMrB : DMrA.second ) + { + const size_t iat2 = DMrB.first; + for( const auto &DMrC : DMrB.second ) + { + const auto box2 = DMrC.first; + for( size_t is=0; is!=DMrC.second.size(); ++is ) + DM_grid[is][iat1][iat2][box2] = std::move(DMrC.second[is]); + } + } + } + return DM_grid; + }; +//gettimeofday( &t_start, NULL); + this->DMr = cal_dm_my(); +//ofs_time<<"TIME@ Exx_Abfs::Parallel::Communicate::DM::Allreduce::cal_dm_my\t"<,matrix>>>> +Exx_Abfs::Parallel::Communicate::DM::LOC_to_grid( + const Abfs::Vector3_Order &Born_von_Karman_period, + const double threshold ) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM::LOC_to_grid"); + + const double SPIN_multiple = 0.5*NSPIN; + + vector,matrix>>>> DM_grid(NSPIN); + if(GAMMA_ONLY_LOCAL) + { +{ + ofstream ofs("LOC.DM_"+TO_STRING(MY_RANK)); + for( int is=0; is!=NSPIN; ++is ) + { + for( int i1=0; i1!=GridT.lgd; ++i1 ) + { + for( int i2=0; i2!=GridT.lgd; ++i2 ) + ofs<= threshold ) + DM_grid[is][iat1][iat2][{0,0,0}] = DM_grid_2D * SPIN_multiple; + else + DM_grid[is][iat1][iat2][{0,0,0}]; // to erase atom_unset + iwt2_index += nw2; + } + iwt1_index += nw1; + } + + /* + for( int iwt1_grid=0; iwt1_grid box2( RA.info[iat1][iat2_2D][0], RA.info[iat1][iat2_2D][1], RA.info[iat1][iat2_2D][2] ); + const Abfs::Vector3_Order boxp2 = box2%Born_von_Karman_period; + const int nw1 = ucell.atoms[ucell.iat2it[iat1]].nw; + const int nw2 = ucell.atoms[ucell.iat2it[iat2]].nw; +{ + ofs_LOC_DM<<"@\t"<= threshold ) + DM_grid[is][iat1][iat2][boxp2] = DM_grid_2D * SPIN_multiple; + else + DM_grid[is][iat1][iat2][boxp2]; // to erase atom_unset + } + iw_index += nw1*nw2; + } + } + } +ofs_LOC_DM.close(); + } + return DM_grid; +} + diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm.h new file mode 100644 index 0000000000..60e8ef77dc --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm.h @@ -0,0 +1,93 @@ +#ifndef EXX_ABFS_PARALLEL_COMMUNICATE_DM_H +#define EXX_ABFS_PARALLEL_COMMUNICATE_DM_H + +#include "exx_abfs-parallel.h" +#include "src_global/matrix.h" +#include "src_global/matrix_wrapper.h" +#include "src_lcao/abfs-vector3_order.h" +#include +#include +#include +#include +#include +#include +#include + +class Exx_Abfs::Parallel::Communicate::DM +{ +public: + + void cal_DM( + const Abfs::Vector3_Order &Born_von_Karman_period, + const set> &H_atom_pairs_core, + const double threshold ); + + vector,matrix>>>> DMr; + +private: + + vector,matrix>>>> LOC_to_grid( + const Abfs::Vector3_Order &Born_von_Karman_period, + const double threshold ) const; + + class Allreduce + { + public: + Allreduce( + const MPI_Comm & mpi_comm_in, + vector,matrix>>>> &data_local_in, + const Abfs::Vector3_Order &Born_von_Karman_period, + const set> &H_atom_pairs_core); + ~Allreduce(); + vector,matrix>>>> grid_to_exx(); + + private: + void ask( const int rank_delta_now ); + void recv_data_process( const int rank_data ); + void insert_data( vector,matrix>>>> &data_rank ); + void insert_data( vector,Matrix_Wrapper>>>> &data_rank ); + void send_data_process( const int rank_asked ); + vector,Matrix_Wrapper>>>> get_data_local_wrapper( const map>>> & atom_asked ) const; + vector,Matrix_Wrapper>>>> get_data_local_wrapper() const; + + private: + vector,matrix>>>> data_all; + vector,matrix>>>> &data_local; + vector,Matrix_Wrapper>>>> data_localw; + + map>>> atom_unset; + + const MPI_Comm & mpi_comm; + int comm_sz; + int my_rank; + + static constexpr int tag_ask = 1; + static constexpr int tag_data = 2; + + atomic_flag lock_insert; + atomic lock_atom_unset_read; + atomic rank_delta; + + vector oarps_isend_data; + vector oarps_atom_unset; + vector iarps_recv_data; + vector iarps_atom_asked; + + vector*> flags_isend_data; + vector*> flags_ask_atom; + boost::dynamic_bitset<> flags_recv_data; + }; + + +/* +private: + struct + { + vector row; + vector col; + }atom_in_exx; + void set_atom_in_exx( const set> &H_atom_pairs_core ); +*/ +}; + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm2.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm2.cpp new file mode 100644 index 0000000000..c0bf158a29 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm2.cpp @@ -0,0 +1,122 @@ +#include "exx_abfs-parallel-communicate-dm2.h" +#include "src_pw/global.h" + + +void Exx_Abfs::Parallel::Communicate::DM2::init( + const set> &H_atom_pairs_core, + const double threshold_in) +{ + threshold = threshold_in; + + atom_in_exx.row.resize(ucell.nat,false); + atom_in_exx.col.resize(ucell.nat,false); + atom_in_exx.row_col.resize(ucell.nat,vector(ucell.nat,false)); + + for( const auto &pair : H_atom_pairs_core ) + { + atom_in_exx.row[pair.first] = true; + atom_in_exx.col[pair.second] = true; + atom_in_exx.row_col[pair.first][pair.second] = true; + } +} + +void Exx_Abfs::Parallel::Communicate::DM2::clear_DMr() +{ + DMr.clear(); + DMr.resize(NSPIN); +} + +void Exx_Abfs::Parallel::Communicate::DM2::set_DM_gamma( const matrix &DM_2D, const int is, const pair &index_begin ) +{ + auto get_iats = []( const int n, const int i_begin, const vector &in_exx ) -> map> + { + map> iats; + for( int i=0; i=0; --i ) + { + const int iat = ucell.iwt2iat[i+i_begin]; + if( in_exx[iat] ) + iats[iat].first=i; + } + return iats; + }; + const map> iat1s = get_iats( DM_2D.nr, index_begin.first, atom_in_exx.row ); + const map> iat2s = get_iats( DM_2D.nc, index_begin.second, atom_in_exx.col ); + + const double SPIN_multiple = 0.5*NSPIN; + for( const auto &iat1sA : iat1s ) + { + const int iat1 = iat1sA.first; + const auto &iat1_range = iat1sA.second; + for( const auto &iat2sA : iat2s ) + { + const int iat2 = iat2sA.first; + const auto &iat2_range = iat2sA.second; + if( !atom_in_exx.row_col[iat1][iat2] ) continue; + + matrix DM_local( ucell.atoms[ucell.iat2it[iat1]].nw, ucell.atoms[ucell.iat2it[iat2]].nw ); + const int iw2_begin = ucell.iwt2iw[ iat2_range.first + index_begin.second ]; + for( int iw1_2D=iat1_range.first; iw1_2D<=iat1_range.second; ++iw1_2D ) + { + const int iw1 = ucell.iwt2iw[ iw1_2D + index_begin.first ]; + memcpy( + &DM_local( iw1, iw2_begin ), + &DM_2D( iw1_2D, iat2_range.first ), + ( iat2_range.second - iat2_range.first + 1 )*sizeof(double) ); + } + DM_local *= SPIN_multiple; + + if( DM_local.absmax() < threshold ) continue; + + if( matrix*const DM_ptr = static_cast(MAP_EXIST( DMr[is], iat1, iat2, Abfs::Vector3_Order{0,0,0} )) ) + *DM_ptr += DM_local; + else + DMr[is][iat1][iat2][{0,0,0}] = std::move(DM_local); + } + } +} + + + + +void Exx_Abfs::Parallel::Communicate::DM2::cal_DM_k( + const Abfs::Vector3_Order &Born_von_Karman_period, + const set> &H_atom_pairs_core, + const double threshold ) +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM::cal_DM"); + + vector> Born_von_Karman_boxes; + for( int ix=0; ix{ix,iy,iz} % Born_von_Karman_period ); + + Exx_Abfs::DM dm_my; + dm_my.flag_mix = false; + dm_my.cal_DM( H_atom_pairs_core, Born_von_Karman_boxes ); + + this->DMr.clear(); + this->DMr.resize(NSPIN); + for( const auto &DMrA : dm_my.DMr ) + { + const size_t iat1 = DMrA.first; + for( const auto &DMrB : DMrA.second ) + { + const size_t iat2 = DMrB.first; + for( const auto &DMrC : DMrB.second ) + { + const auto box2 = DMrC.first; + for( size_t is=0; is!=DMrC.second.size(); ++is ) + if( DMrC.second[is].absmax() >= threshold ) + DMr[is][iat1][iat2][box2] = std::move(DMrC.second[is]); + } + } + } + +} diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm2.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm2.h new file mode 100644 index 0000000000..b23d30705d --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm2.h @@ -0,0 +1,39 @@ +#ifndef EXX_ABFS_PARALLEL_COMMUNICATE_DM2_H +#define EXX_ABFS_PARALLEL_COMMUNICATE_DM2_H + +#include "exx_abfs-parallel.h" +#include "src_global/matrix.h" +#include "src_lcao/abfs-vector3_order.h" +#include +#include + +class Exx_Abfs::Parallel::Communicate::DM2 +{ +public: + + void init( + const set> &H_atom_pairs_core, + const double threshold_in); + void clear_DMr(); + void set_DM_gamma( const matrix &DM_2D, const int is, const pair &index_begin ); + + void cal_DM_k( + const Abfs::Vector3_Order &Born_von_Karman_period, + const set> &H_atom_pairs_core, + const double threshold ); + + vector,matrix>>>> DMr; + +private: + + double threshold; + + struct + { + vector row; + vector col; + vector> row_col; + }atom_in_exx; +}; + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce.cpp new file mode 100644 index 0000000000..7de8938f7e --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce.cpp @@ -0,0 +1,369 @@ +#include "exx_abfs-parallel-communicate-hexx.h" +#include "src_global/boost_serialization.h" + +#include "src_pw/global.h" +#include "src_lcao/global_fp.h" + +#include +#ifdef _OPENMP +#include +#endif + +Exx_Abfs::Parallel::Communicate::Hexx::Allreduce::Allreduce( + const MPI_Comm & mpi_comm_in, + vector,matrix>>>> &data_local_in ) + :mpi_comm(mpi_comm_in), + data_local(data_local_in), + lock_insert(ATOMIC_FLAG_INIT) +{ + data_all.resize(NSPIN); + + MPI_Comm_size( mpi_comm, &comm_sz ); + MPI_Comm_rank( mpi_comm, &my_rank ); + + rank_delta = 1; + + set_atom_in_2D(); + oarp_atom_in_2D = new boost::mpi::packed_oarchive{mpi_comm}; + *oarp_atom_in_2D << atom_in_2D; + + oarps_isend_data.resize( comm_sz ); + for( auto &oarp_isend_data : oarps_isend_data ) + oarp_isend_data = new boost::mpi::packed_oarchive{mpi_comm}; + iarps_recv_data.resize( comm_sz ); + for( auto &iarp_recv_data : iarps_recv_data ) + iarp_recv_data = new boost::mpi::packed_iarchive{mpi_comm}; + iarps_atom_asked.resize( comm_sz ); + for( auto &iarp_atom_asked : iarps_atom_asked ) + iarp_atom_asked = new boost::mpi::packed_iarchive{mpi_comm}; + + // 0: undo 1: thread finish 2: MPI begin + flags_isend_data.resize(comm_sz); + for( int irank=0; irank!=comm_sz; ++irank ) + flags_isend_data[irank] = new atomic(0); + *flags_isend_data[my_rank] = 2; + + flags_ask_atom.resize(comm_sz); + for( int irank=0; irank!=comm_sz; ++irank ) + flags_ask_atom[irank] = new atomic(0); + *flags_ask_atom[my_rank] = 2; + + flags_recv_data.resize(comm_sz,false); + flags_recv_data[my_rank] = true; +} + + +Exx_Abfs::Parallel::Communicate::Hexx::Allreduce::~Allreduce() +{ + delete oarp_atom_in_2D; + for( auto &oarp_isend_data : oarps_isend_data ) + if(oarp_isend_data) + delete oarp_isend_data; + for( auto &iarp_recv_data : iarps_recv_data ) + if(iarp_recv_data) + delete iarp_recv_data; + for( auto &iarp_atom_asked : iarps_atom_asked ) + if(iarp_atom_asked) + delete iarp_atom_asked; + for( int irank=0; irank!=comm_sz; ++irank ) + delete flags_isend_data[irank]; + for( int irank=0; irank!=comm_sz; ++irank ) + delete flags_ask_atom[irank]; +} + + + +vector,matrix>>>> +Exx_Abfs::Parallel::Communicate::Hexx::Allreduce::exx_to_a2D() +{ + auto clear_oars = [&]( vector &requests, boost::dynamic_bitset<> &flags, vector &oarps, const string &s ) + { + if( flags.none() ) return; + for( int irank=0; irank!=comm_sz; ++irank ) + { + if( flags[irank] ) + { + int flag_finish; + if(MPI_SUCCESS!=MPI_Test( &requests[irank], &flag_finish, MPI_STATUS_IGNORE )) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + if( flag_finish ) + { + delete oarps[irank]; + oarps[irank] = nullptr; + } + flags[irank] = false; + } + } + }; + + auto if_finish = []( const vector*> &flags ) -> bool + { + int sum=0; + for( size_t i=0; i threads; + + vector requests_isend_data(comm_sz); + vector requests_ask(comm_sz); + boost::dynamic_bitset<> flags_request_isend_data(comm_sz,false); + + #ifdef _OPENMP + const int omp_threads = omp_get_max_threads(); + omp_set_num_threads(1); + #endif + + while( !if_finish(flags_ask_atom) || !if_finish(flags_isend_data) || !flags_recv_data.all() ) + { + MPI_Status status; + int flag_message; + if(MPI_SUCCESS!=MPI_Iprobe( MPI_ANY_SOURCE, MPI_ANY_TAG, mpi_comm, &flag_message, &status )) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + if(flag_message) + { + int message_size; + if(MPI_SUCCESS!=MPI_Get_count( &status, MPI_PACKED, &message_size )) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + + switch(status.MPI_TAG) + { + case tag_ask: + { + const int rank_asked = status.MPI_SOURCE; + + iarps_atom_asked[rank_asked]->resize(message_size); + if(MPI_SUCCESS!=MPI_Recv( iarps_atom_asked[rank_asked]->address(), message_size, MPI_PACKED, rank_asked, tag_ask, mpi_comm, MPI_STATUS_IGNORE )) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + + threads.push_back(std::thread( + &Exx_Abfs::Parallel::Communicate::Hexx::Allreduce::send_data_process, this, + rank_asked )); + break; + } + case tag_data: + { + const int rank_data = status.MPI_SOURCE; + + iarps_recv_data[rank_data]->resize(message_size); + if(MPI_SUCCESS!=MPI_Recv( iarps_recv_data[rank_data]->address(), message_size, MPI_PACKED, rank_data, tag_data, mpi_comm, MPI_STATUS_IGNORE )) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + flags_recv_data[rank_data] = true; + + threads.push_back(std::thread( + &Exx_Abfs::Parallel::Communicate::Hexx::Allreduce::recv_data_process, this, + rank_data )); + break; + } + default: + throw invalid_argument(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + } + } + + for( int rank_ask=0; rank_ask!=comm_sz; ++rank_ask ) + if( *flags_ask_atom[rank_ask] == 1 ) + { + if(MPI_SUCCESS!=MPI_Isend( oarp_atom_in_2D->address(), oarp_atom_in_2D->size(), MPI_PACKED, rank_ask, tag_ask, mpi_comm, &requests_ask[rank_ask] )) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + *flags_ask_atom[rank_ask] = 2; + } + for( int rank_asked=0; rank_asked!=comm_sz; ++rank_asked ) + if( *flags_isend_data[rank_asked] == 1 ) + { + if(MPI_SUCCESS!=MPI_Isend( oarps_isend_data[rank_asked]->address(), oarps_isend_data[rank_asked]->size(), MPI_PACKED, rank_asked, tag_data, mpi_comm, &requests_isend_data[rank_asked] )) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + flags_request_isend_data[rank_asked] = true; + *flags_isend_data[rank_asked] = 2; + } + + clear_oars( requests_isend_data, flags_request_isend_data, oarps_isend_data, "oarps_isend_data" ); + } + + while( lock_insert.test_and_set() ); + insert_data(); + lock_insert.clear(); + + for( std::thread & t : threads ) + t.join(); + for( int i_rank=0; i_rank=0 ) + atom_in_2D.first[iat] = true; + if( ParaO.trace_loc_col[iwt]>=0 ) + atom_in_2D.second[iat] = true; + } + } + } +} + + +void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce::ask( const int rank_delta_now ) +{ + if( rank_delta_now < comm_sz ) + { + const int rank_ask = ( my_rank + rank_delta_now ) % comm_sz; + *flags_ask_atom[rank_ask] = 1; + } +} + + + +void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce::recv_data_process( const int rank_data ) +{ + auto vector_empty = []( const vector,Matrix_Wrapper>>>> & v ) -> bool + { + for( const auto &i : v ) + if(!i.empty()) return false; + return true; + }; + + vector,Matrix_Wrapper>>>> data_rank; + *iarps_recv_data[rank_data] >> data_rank; + iarps_recv_data[rank_data]->resize(0); + + if(!vector_empty(data_rank)) + { + while( lock_insert.test_and_set() ); + insert_data(data_rank); + lock_insert.clear(); + } + + ask(rank_delta++); + + #ifdef MATRIX_WRAPPER_TIANHE2 + for( auto &data_rank_is : data_rank ) + for( auto &data_rank_A : data_rank_is ) + for( auto &data_rank_B : data_rank_A.second ) + for( auto &data_rank_C : data_rank_B.second ) + if(!data_rank_C.second.c) + delete[] data_rank_C.second.c; + #endif +} + + +void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce::insert_data( + vector,Matrix_Wrapper>>>> &data_rank ) +{ + for( int is=0; is!=NSPIN; ++is ) + { + auto &data_rank_is = data_rank[is]; + auto &data_all_is = data_all[is]; + for( auto &data_rank_A : data_rank_is ) + { + const size_t iat1 = data_rank_A.first; + auto &data_all_A = data_all_is[iat1]; + for( auto &data_rank_B : data_rank_A.second ) + { + const size_t iat2 = data_rank_B.first; + auto &data_all_B = data_all_A[iat2]; + for( auto &data_rank_C : data_rank_B.second ) + { + const Abfs::Vector3_Order &box2 = data_rank_C.first; + auto &data_all_C = data_all_B[box2]; + if(data_all_C.c) + data_all_C += data_rank_C.second.to_matrix(); + else + data_all_C = data_rank_C.second.to_matrix(); + } + } + } + } +} + + +void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce::insert_data() +{ + for( int is=0; is!=NSPIN; ++is ) + { + auto &data_local_is = data_local[is]; + auto &data_all_is = data_all[is]; + for( auto &data_local_A : data_local_is ) + { + const size_t iat1 = data_local_A.first; + if( !atom_in_2D.first[iat1] ) continue; + auto &data_all_A = data_all_is[iat1]; + for( auto &data_local_B : data_local_A.second ) + { + const size_t iat2 = data_local_B.first; + if( !atom_in_2D.second[iat2] ) continue; + auto &data_all_B = data_all_A[iat2]; + for( auto &data_local_C : data_local_B.second ) + { + const Abfs::Vector3_Order &box2 = data_local_C.first; + auto &data_all_C = data_all_B[box2]; + if( data_all_C.c ) + data_all_C += data_local_C.second; + else + data_all_C = std::move(data_local_C.second); + } + } + } + } +} + + + +void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce::send_data_process( const int rank_asked ) +{ + pair< vector, vector > atom_asked; + *iarps_atom_asked[rank_asked] >> atom_asked; + iarps_atom_asked[rank_asked]->resize(0); + + const vector,Matrix_Wrapper>>>> matrix_wrapped = get_data_local_wrapper(atom_asked); + *oarps_isend_data[rank_asked] << matrix_wrapped; + + *flags_isend_data[rank_asked] = 1; +} + + +vector,Matrix_Wrapper>>>> +Exx_Abfs::Parallel::Communicate::Hexx::Allreduce::get_data_local_wrapper( const pair,vector> &atom_asked ) const +{ + vector,Matrix_Wrapper>>>> mw(NSPIN); + for( int is=0; is!=NSPIN; ++is ) + { + auto &data_local_is = data_local[is]; + auto &mw_is = mw[is]; + for( auto &data_local_A : data_local_is ) + { + const size_t iat1 = data_local_A.first; + if( !atom_asked.first[iat1] ) continue; + auto &mw_A = mw_is[iat1]; + for( auto &data_local_B : data_local_A.second ) + { + const size_t iat2 = data_local_B.first; + if( !atom_asked.second[iat2] ) continue; + auto &mw_B = mw_A[iat2]; + for( auto &data_local_C : data_local_B.second ) + { + const Abfs::Vector3_Order &box2 = data_local_C.first; + mw_B[box2] = data_local_C.second; + } + } + } + } + return mw; +} diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-template.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-template.h new file mode 100644 index 0000000000..d3955f1929 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-template.h @@ -0,0 +1,93 @@ +#ifndef EXX_ABFS_PARALLEL_COMMUNICATE_HEXX_TEMPLATE_H +#define EXX_ABFS_PARALLEL_COMMUNICATE_HEXX_TEMPLATE_H + +#include "exx_abfs-parallel-communicate-hexx.h" + +#include "src_pw/global.h" +#include "src_lcao/global_fp.h" + +template< typename T > +T Exx_Abfs::Parallel::Communicate::Hexx::a2D_to_m2D( const map> & H_a2D ) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::Hexx::a2D_to_m2D"); + + T H_m2D; + if(KS_SOLVER=="genelpa") + H_m2D.create( ParaO.ncol, ParaO.nrow ); + else + H_m2D.create( ParaO.nrow, ParaO.ncol ); + + for( const auto H_a2DA : H_a2D ) + { + const size_t iat1 = H_a2DA.first; + for( const auto H_a2DB : H_a2DA.second ) + { + const size_t iat2 = H_a2DB.first; + const T & H = H_a2DB.second; + + for( int iw1=0; iw1!=H.nr; ++iw1 ) + { + const int iwt1 = ucell.itiaiw2iwt( ucell.iat2it[iat1], ucell.iat2ia[iat1], iw1 ); + const int iwt1_m2D = ParaO.trace_loc_row[iwt1]; + if( iwt1_m2D == -1 ) continue; + + for( int iw2=0; iw2!=H.nc; ++iw2 ) + { + const int iwt2 = ucell.itiaiw2iwt( ucell.iat2it[iat2], ucell.iat2ia[iat2], iw2 ); + const int iwt2_m2D = ParaO.trace_loc_col[iwt2]; + if( iwt2_m2D == -1 ) continue; + + if(KS_SOLVER=="genelpa") + H_m2D( iwt2_m2D, iwt1_m2D ) = H(iw1,iw2); + else + H_m2D( iwt1_m2D, iwt2_m2D ) = H(iw1,iw2); + } + } + } + } + return H_m2D; +} + + +template +T Exx_Abfs::Parallel::Communicate::Hexx::pulay_mixing( const T &H_pulay_old, deque &H_seq, const T &H_new ) +{ + TITLE("Exx_Abfs::Parallel::Communicate::Hexx::pulay_mixing"); + + + T H_pulay; + if( 0==chr.totstep ) + { + H_seq.clear(); + H_pulay = H_new; + } + else + { + H_seq.push_back( + (1-chr.mixing_beta) * H_pulay_old + chr.mixing_beta * H_new ); + if( H_seq.size() > chr.dstep+1 ) + H_seq.pop_front(); + + if( 1==H_seq.size() ) + { + H_pulay = H_seq[0]; + } + else + { + auto pos_mod = [](const int i, const int N){ return (i%N+N)%N; }; + auto index = [&](const int i) -> int + { + const int alpha_size = H_seq.size()-1; + const int alpha_begin = chr.idstep - alpha_size; + return pos_mod( alpha_begin+i, chr.dstep ); + }; + H_pulay = (1+chr.alpha[index(H_seq.size()-2)]) * H_seq[H_seq.size()-1]; + for( int i=1; i<=H_seq.size()-2; ++i ) + H_pulay += ( chr.alpha[index(i-1)] - chr.alpha[index(i)] ) * H_seq[i]; + H_pulay -= chr.alpha[index(0)] * H_seq[0]; + } + } + return H_pulay; +} + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp new file mode 100644 index 0000000000..ebc9ab2b5d --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp @@ -0,0 +1,155 @@ +#include "exx_abfs-parallel-communicate-hexx.h" +#include "exx_abfs-parallel-communicate-hexx-template.h" +#include "exx_abfs-parallel-communicate-allreduce-template.h" +#include "src_pw/global.h" +#include "src_global/global_function.h" +#include "exx_abfs-io.h" +#include "exx_abfs-io-template.h" + +#include "src_external/src_test/src_lcao/exx_lcao-test.h" +//#include + +void Exx_Abfs::Parallel::Communicate::Hexx::Rexx_to_Km2D( + vector,matrix>>>> &HR_exx, + const pair &io_HR_a2D ) +{ + TITLE("Exx_Abfs::Parallel::Communicate::Hexx::Rexx_to_Km2D"); + +//ofstream ofs_time("time_"+TO_STRING(MY_RANK),ofstream::app); +//timeval t_start; + +//gettimeofday( &t_start, NULL); + MPI_Barrier(MPI_COMM_WORLD); // Peize Lin test +//ofs_time<<"TIME@ MPI_Barrier\t"<,matrix>>>> HR_a2D; + if(io_HR_a2D.first) + HR_a2D = Exx_Abfs::IO::input_binary,matrix>>>>>( + global_out_dir+"HR_exx_"+TO_STRING(MY_RANK)); + else + { + Allreduce allreduce(MPI_COMM_WORLD,HR_exx); + HR_a2D = allreduce.exx_to_a2D(); + } + if(io_HR_a2D.second) + Exx_Abfs::IO::output_binary( HR_a2D, global_out_dir+"HR_exx_"+TO_STRING(MY_RANK) ); +//ofs_time<<"TIME@ Exx_Abfs::Parallel::Communicate::Hexx::Allreduce::exx_to_a2D\t"<> HK_a2D = R_to_K(HR_a2D[is]); +//ofs_time<<"TIME@ Exx_Abfs::Parallel::Communicate::Hexx::R_to_K\t"<> HK_a2D = R_to_K(HR_a2D[kv.isk[ik]],ik); +//ofs_time<<"TIME@ Exx_Abfs::Parallel::Communicate::Hexx::R_to_K\t"<> Exx_Abfs::Parallel::Communicate::Hexx::R_to_K( + map,matrix>>> & HR) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::Hexx::R_to_K"); + + map> HK; + for( auto & HR1 : HR ) + { + const size_t iat1 = HR1.first; + for( auto & HR2 : HR1.second ) + { + const size_t iat2 = HR2.first; + assert(HR2.second.size()==1); + HK[iat1][iat2] = std::move( HR2.second.at(Vector3{0,0,0}) ); + } + } + return HK; +} + + +map> Exx_Abfs::Parallel::Communicate::Hexx::R_to_K( + const map,matrix>>> & HR, + const size_t ik) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::Hexx::R_to_K"); + + map> HK; + for( auto & HRA : HR ) + { + const size_t iat1 = HRA.first; + for( auto & HRB : HRA.second ) + { + const size_t iat2 = HRB.first; + + ComplexMatrix HK_tmp( + ucell.atoms[ucell.iat2it[iat1]].nw, + ucell.atoms[ucell.iat2it[iat2]].nw); + for( auto & HRC : HRB.second ) + { + const Abfs::Vector3_Order & box2 = HRC.first; + HK_tmp += ComplexMatrix(HRC.second) * exp( TWO_PI*IMAG_UNIT * (kv.kvec_c[ik] * (box2*ucell.latvec)) ); + } + HK[iat1][iat2] = std::move(HK_tmp); + } + } + return HK; +} + + + diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.h new file mode 100644 index 0000000000..4e6ba25205 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.h @@ -0,0 +1,91 @@ +#ifndef EXX_ABFS_PARALLEL_COMMUNICATE_HEXX_H +#define EXX_ABFS_PARALLEL_COMMUNICATE_HEXX_H + +#include "exx_abfs-parallel.h" +#include "src_global/matrix.h" +#include "src_global/matrix_wrapper.h" +#include "src_global/complexmatrix.h" +#include "src_lcao/abfs-vector3_order.h" +#include +#include +#include +#include +#include +#include +#include + +class Exx_Abfs::Parallel::Communicate::Hexx +{ +public: + void Rexx_to_Km2D( + vector,matrix>>>> &HR_exx, + const pair &io_HR_a2D ); + +private: + map> R_to_K( + map,matrix>>> & HR) const; + map> R_to_K( + const map,matrix>>> & HR, + const size_t ik) const; + template< typename T > + T a2D_to_m2D( const map> & H_a2D ) const; + template + T pulay_mixing( const T &H_pulay_old, deque &H_seq, const T &H_new ); + + class Allreduce + { + public: + Allreduce( + const MPI_Comm &mpi_comm_in, + vector,matrix>>>> &data_local_in ); + ~Allreduce(); + vector,matrix>>>> exx_to_a2D(); + + private: + void set_atom_in_2D(); + void ask( const int rank_delta_now ); + void recv_data_process( const int rank_data ); + void insert_data( vector,Matrix_Wrapper>>>> &data_rank ); + void insert_data(); + void send_data_process( const int rank_asked ); + vector,Matrix_Wrapper>>>> get_data_local_wrapper( + const pair,vector> &atom_asked ) const; + + private: + vector,matrix>>>> data_all; + vector,matrix>>>> &data_local; + + pair< vector, vector > atom_in_2D; + + const MPI_Comm & mpi_comm; + int comm_sz; + int my_rank; + + static constexpr int tag_ask = 1; + static constexpr int tag_data = 2; + + atomic_flag lock_insert; + atomic rank_delta; + + boost::mpi::packed_oarchive *oarp_atom_in_2D; + vector oarps_isend_data; + vector iarps_recv_data; + vector iarps_atom_asked; + + vector*> flags_isend_data; + vector*> flags_ask_atom; + boost::dynamic_bitset<> flags_recv_data; + }; + +public: + vector HK_Gamma_m2D; + vector HK_K_m2D; + vector> HK_Gamma_m2D_pulay_seq; + vector> HK_K_m2D_pulay_seq; + + enum class Mixing_Mode{ No, Plain, Pulay }; + Mixing_Mode mixing_mode; + double mixing_beta; +}; + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-htime.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-htime.cpp new file mode 100644 index 0000000000..0fd301f06c --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-htime.cpp @@ -0,0 +1,91 @@ +#include "exx_abfs-parallel-distribute-htime.h" + +#include "src_pw/global.h" +#include "src_lcao/abfs.h" +#include + +vector> Exx_Abfs::Parallel::Distribute::Htime::distribute( const Abfs::Vector3_Order & Born_von_Karman_period ) +{ + TITLE("Exx_Abfs::Parallel::distribute"); + const vector Nadj = cal_Nadj(Born_von_Karman_period); + +//for( const size_t & i : Nadj ) +// cout<>> pair_costs = cal_pair_costs(Nadj); + +//for( const auto & i : pair_costs ) +// cout<>> rank_work = cal_rank_work(pair_costs); + +//for( size_t irank=0; irank!=rank_work.size(); ++irank ) +//{ +// cout< Exx_Abfs::Parallel::Distribute::Htime::cal_Nadj( const Abfs::Vector3_Order & Born_von_Karman_period ) +{ + TITLE("Exx_Abfs::Parallel::cal_Nadj"); + vector Nadj(ucell.nat); + for( size_t iat=0; iat!=ucell.nat; ++iat ) + { + const map>> + adjs = Abfs::get_adjs(iat); + for( const auto & adj_i : adjs ) + { + set> boxp; + for( const auto & box : adj_i.second ) + boxp.insert( box % Born_von_Karman_period ); + Nadj[iat] += boxp.size(); + } + } + return Nadj; +} + +// { Ni*Nj, {i,j} } +vector>> Exx_Abfs::Parallel::Distribute::Htime::cal_pair_costs( const vector &Nadj ) +{ + TITLE("Exx_Abfs::Parallel::cal_pair_costs"); + vector>> pair_costs; + for( size_t iat1=0; iat1> & pair_cost1, + const pair> & pair_cost2 ) -> bool + { return pair_cost1.first > pair_cost2.first; }; + std::sort( pair_costs.begin(), pair_costs.end(), comp ); + return pair_costs; +} + +vector>> Exx_Abfs::Parallel::Distribute::Htime::cal_rank_work( const vector>> & pair_costs ) +{ + TITLE("Exx_Abfs::Parallel::cal_rank_work"); + vector> rank_cost(NPROC); // rank_cost[i] = { irank, cost } + for( size_t irank=0; irank!=NPROC; ++irank ) + rank_cost[irank] = { irank, 0 }; + + auto comp = []( + const pair & rank_cost1, + const pair & rank_cost2 ) + { return rank_cost1.second > rank_cost2.second; }; + + vector>> rank_work(NPROC); // rank_work[irank] = { {iat1,iat2}, {iat1,iat2}, ... } + for( const auto pair_cost : pair_costs ) + { + pop_heap( rank_cost.begin(), rank_cost.end(), comp ); +//cout< +#include + +class Exx_Abfs::Parallel::Distribute::Htime +{ +public: + static vector> distribute( const Abfs::Vector3_Order & Born_von_Karman_period ); +private: + static vector cal_Nadj( const Abfs::Vector3_Order & Born_von_Karman_period ); + static vector>> cal_pair_costs( const vector &Nadj ); + static vector>> cal_rank_work( const vector>> & pair_costs ); +}; + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-kmeans.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-kmeans.cpp new file mode 100644 index 0000000000..7f6bb213ae --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-kmeans.cpp @@ -0,0 +1,253 @@ +#include "exx_abfs-parallel-distribute-kmeans.h" +#include "src_pw/global.h" +#include + +vector +Exx_Abfs::Parallel::Distribute::Kmeans::cluster( const int Nc ) +{ + TITLE("Exx_Abfs::Parallel::Distribute::Kmeans::cluster"); + + vector clusters(Nc+1); // clusters[Nc] just for atoms init + vector atoms(ucell.nat); + +ofstream ofs_mpi("kmeans_"+TO_STRING(Nc)+"_"+TO_STRING(MY_RANK),ofstream::app); + + auto init = [&]() -> void + { +ofs_mpi< flag_is_center(Nx*Ny*Nz,true); + for( int ic_big=Nc/2; ic_big flag_is_center(Nc,true); +// flag_is_center.resize(Nx*Ny*Nz,false); +// std::shuffle( flag_is_center.begin(), flag_is_center.end(), std::default_random_engine(Nc*Nx*Ny*Nz) ); // Nc*Nx*Ny*Nz is just a seed, for all thread be the same + + +for( int ic_big=0; ic_big taud_max = {0,0,0}, + taud_min = {1,1,1}; + for( int iat=0; iat & taud = ucell.atoms[ ucell.iat2it[iat] ].taud[ ucell.iat2ia[iat] ]; + taud_max.x = max( taud.x, taud_max.x ); + taud_max.y = max( taud.y, taud_max.y ); + taud_max.z = max( taud.z, taud_max.z ); + taud_min.x = min( taud.x, taud_min.x ); + taud_min.y = min( taud.y, taud_min.y ); + taud_min.z = min( taud.z, taud_min.z ); + } + const Vector3 taud_delta( + (taud_max.x-taud_min.x)/Nx, + (taud_max.y-taud_min.y)/Ny, + (taud_max.z-taud_min.z)/Nz); +ofs_mpi< uniform(0,1); + for( int ic=0; ic::max(); + } +for( int ic=0; ic bool + { +//ofs_mpi<<__FILE__<<__LINE__<(cluster.size); + +for( int ic=0; ic> +Exx_Abfs::Parallel::Distribute::Kmeans::distribute( const MPI_Comm & mpi_comm, const int multiple_core ) +{ + TITLE("Exx_Abfs::Parallel::Distribute::Kmeans::distribute"); + + assert(multiple_core>=1); + int comm_size; MPI_Comm_size( mpi_comm, &comm_size ); + int my_rank; MPI_Comm_rank( mpi_comm, &my_rank ); + const int comm_size_nominal = comm_size * multiple_core; + +//for( int N=2; N<=20; ++N ) +// cluster(N); + + { + auto classify_atom = []( const int Ng, const vector &atoms ) -> vector> + { + vector> clusters_atoms(Ng); + for( size_t iat=0; iat &cluster_atoms) -> vector> + { + vector> rank_work; + for( size_t i1=0; i1 &cluster_atoms1, const vector &cluster_atoms2 ) -> vector> + { + vector> rank_work; + for( const size_t iat1 : cluster_atoms1 ) + for( const size_t iat2 : cluster_atoms2 ) + rank_work.push_back({iat1,iat2}); + return rank_work; + }; + + const int Ng = static_cast(sqrt(2*comm_size_nominal)); + if( Ng*(Ng+1)/2 == comm_size_nominal ) + { + + vector> rank_work; + const vector atoms = cluster(Ng); + const vector> clusters_atoms = classify_atom(Ng,atoms); + for( size_t ig1=0, rank_tmp=0; ig1> rank_work_tmp = + (ig1==ig2) ? + g_same_cluster(clusters_atoms[ig1]) : + g_different_cluster(clusters_atoms[ig1],clusters_atoms[ig2]); + rank_work.insert( rank_work.end(), rank_work_tmp.begin(), rank_work_tmp.end() ); + } + return rank_work; + } + } + { + int N1 = static_cast(sqrt(comm_size_nominal)); + while(comm_size_nominal%N1) --N1; + const int N2=comm_size_nominal/N1; + + auto f = [&]( const vector &atoms1, const vector &atoms2 ) -> vector> + { + auto index = [&](const int ic1, const int ic2){ return (ic1*N2+ic2)%comm_size; }; + + vector>> rank_work(comm_size); + for( size_t iatA=0; iatA> & rank_work1 = rank_work[index(atoms1[iatA].center, atoms2[iatB].center)]; + vector> & rank_work2 = rank_work[index(atoms1[iatB].center, atoms2[iatA].center)]; + if( rank_work1.size() < rank_work2.size() ) + rank_work1.push_back({iatA,iatB}); + else + rank_work2.push_back({iatB,iatA}); + } + return rank_work[my_rank]; + }; + + if(N1==N2) + { + const vector atoms = cluster(N1); + return f(atoms,atoms); + } + else + { + const vector atoms1 = cluster(N1); + const vector atoms2 = cluster(N2); + return f(atoms1,atoms2); + } + } + + +} diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-kmeans.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-kmeans.h new file mode 100644 index 0000000000..342da01a22 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-kmeans.h @@ -0,0 +1,35 @@ +#ifndef EXX_ABFS_PARALLEL_DISTRIBUTE_KMEANS_H +#define EXX_ABFS_PARALLEL_DISTRIBUTE_KMEANS_H + +#include "exx_abfs-parallel.h" +#include "src_global/vector3.h" +#include +#include +#include + +class Exx_Abfs::Parallel::Distribute::Kmeans +{ +public: + + static vector> distribute( const MPI_Comm & mpi_comm, const int multiple_core=1 ); + +private: + + struct Cluster + { + Vector3 tau; + size_t size; + Vector3 tau_sum; + }; + + struct Atom + { + Vector3 tau; + int center; + double distance; + }; + + static vector cluster( const int Nc ); +}; + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel.h new file mode 100644 index 0000000000..66f570ab2f --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel.h @@ -0,0 +1,27 @@ +#ifndef EXX_ABFS_PARALLEL_H +#define EXX_ABFS_PARALLEL_H + +#include "exx_abfs.h" + +class Exx_Abfs::Parallel +{ + public: + + class Distribute + { + public: + class Htime; + class Kmeans; + }; + + class Communicate + { + public: + class Allreduce; + class Hexx; + class DM; + class DM2; + }; +}; + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-pca.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-pca.cpp new file mode 100644 index 0000000000..aaca74a6b8 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-pca.cpp @@ -0,0 +1,144 @@ +#include "exx_abfs-pca.h" + +#include "exx_abfs-abfs_index.h" +#include "exx_abfs-matrix_orbs11.h" +#include "exx_abfs-matrix_orbs21.h" +#include "exx_abfs-inverse_matrix_double.h" + +#include "src_global/lapack_connector.h" +#include "src_global/global_function.h" + +#include +#include + +#include "src_external/src_test/src_global/element_basis_index-test.h" // Peize Lin test +#include "src_external/src_test/src_lcao/exx_lcao-test.h" // Peize Lin test +#include // Peize Lin test +#include "src_lcao/global_fp.h" // Peize Lin test + +vector,matrix>>> Exx_Abfs::PCA::cal_PCA( + const vector>> &lcaos, + const vector>> &abfs, + const double kmesh_times ) +{ + TITLE("Exx_Abfs::PCA::cal_PCA"); +ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; + + const Element_Basis_Index::Range + && range_lcaos = Exx_Abfs::Abfs_Index::construct_range( lcaos ); + const Element_Basis_Index::IndexLNM + && index_lcaos = Element_Basis_Index::construct_index( range_lcaos ); + + const Element_Basis_Index::Range + && range_abfs = Exx_Abfs::Abfs_Index::construct_range( abfs ); + const Element_Basis_Index::IndexLNM + && index_abfs = Element_Basis_Index::construct_index( range_abfs ); + +ofs<::min(); + for( size_t T=0; T!=abfs.size(); ++T ) + Exx_Abfs::Lmax = std::max( Exx_Abfs::Lmax, static_cast(abfs[T].size())-1 ); + + Exx_Abfs::Matrix_Orbs21 m_abfslcaos_lcaos; +//gettimeofday( &t_start, NULL); + m_abfslcaos_lcaos.init( 1, kmesh_times, 1 ); +//ofs<<"TIME@m_abfslcaos_lcaos.init\t"<>> delta_R; + for( size_t it=0; it!=abfs.size(); ++it ) + delta_R[it][it] = {0.0}; +//gettimeofday( &t_start, NULL); + m_abfslcaos_lcaos.init_radial_table(delta_R); +//ofs<<"TIME@m_abfslcaos_lcaos.init_radial_table\t"<,matrix>>> eig(abfs.size()); + for( size_t T=0; T!=abfs.size(); ++T ) + { + const matrix && A = m_abfslcaos_lcaos.cal_overlap_matrix( + T, + T, + Vector3{0,0,0}, + Vector3{0,0,0}, + index_abfs, + index_lcaos, + index_lcaos, + Exx_Abfs::Matrix_Orbs21::Matrix_Order::A2B_A1); +//ofs<<"A:"< eig_value(mm.nr); + + int info; +gettimeofday( &t_start, NULL); + LapackConnector::dsyev( 'V', 'U', mm, VECTOR_TO_PTR(eig_value), info ); +ofs<<"TIME@LapackConnector::dsyev\t"< + +// training data: lcaos[i] * lcaos[j] +// old basis: abfs +// new basis: to be constructed +// ( all lcaos and abfs on same atom ) + +class Exx_Abfs::PCA +{ +public: + static vector,matrix>>> cal_PCA( + const vector>> &lcaos, + const vector>> &abfs, // abfs must be orthonormal + const double kmesh_times ); +private: + static matrix get_sub_matrix( + const matrix & m, + const size_t & T, + const size_t & L, + const Element_Basis_Index::Range & range, + const Element_Basis_Index::IndexLNM & index ); + static matrix get_column_mean0_matrix( const matrix & m ); +}; + +#endif // EXX_ABFS_PCA_H \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-cauchy.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-cauchy.cpp new file mode 100644 index 0000000000..649a8e73bb --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-cauchy.cpp @@ -0,0 +1,305 @@ +#include "exx_abfs-screen-cauchy.h" + +#include "src_pw/global.h" + +#include "src_external/src_test/src_lcao/exx_abfs-screen-test.h" +//double Exx_Abfs::Screen::Cauchy::num_screen1 = 0; +//double Exx_Abfs::Screen::Cauchy::num_screen2 = 0; +//double Exx_Abfs::Screen::Cauchy::num_screen3 = 0; +//double Exx_Abfs::Screen::Cauchy::num_cal = 0; + +void Exx_Abfs::Screen::Cauchy::init( + const bool flag_screen_cauchy_in, + const double threshold_in, + const Abfs::Vector3_Order Born_von_Karman_period_in) +{ + TITLE("Exx_Abfs::Screen::Cauchy::init"); + flag_screen_cauchy = flag_screen_cauchy_in; + threshold = threshold_in; + Born_von_Karman_period = Born_von_Karman_period_in; +} + +void Exx_Abfs::Screen::Cauchy::cal_norm_C_max( + const map,shared_ptr>>> & Cs, + const Element_Basis_Index::IndexLNM & index_lcaos, + const Element_Basis_Index::IndexLNM & index_abfs) +{ + if(!flag_screen_cauchy) return; + TITLE("Exx_Abfs::Screen::Cauchy::cal_norm_C_max"); + + for( const auto & Cs1 : Cs ) + { + const size_t iat1 = Cs1.first; + const size_t it1 = ucell.iat2it[iat1]; + for( const auto & Cs2 : Cs1.second ) + { + const size_t iat2 = Cs2.first; + const size_t it2 = ucell.iat2it[iat2]; + for( const auto & Cs3 : Cs2.second ) + { + const Abfs::Vector3_Order &box2 = Cs3.first; + const matrix & C = *Cs3.second; + + const size_t nw1 = index_lcaos[it1].count_size, + nw2 = index_lcaos[it2].count_size, + nw3 = index_abfs[it1].count_size; + + { // || C(i) || || C(i) C^+(i) || + valarray C_norm2_outer(nw1); + valarray C_norm4_outer(nw1); + for( size_t iw1=0; iw1!=nw1; ++iw1 ) + { + // C_outer( iw2, iw3 ) = C( iw1, iw2, iw3 ) + matrix C_outer( nw2, nw3 ); +// for( size_t iw2=0; iw2!=nw2; ++iw2 ) +// memcpy( C_outer.c+iw2*nw3, C.c+(iw1*nw2+iw2)*nw3, sizeof(double)*nw3 ); + memcpy( C_outer.c, C.c+iw1*nw2*nw3, sizeof(double)*nw2*nw3 ); + + C_norm2_outer[iw1] = C_outer.norm(); // || C || + C_norm4_outer[iw1] = m_mT(C_outer).norm(); // || C C^+ || + } + C_norm2_outer_max[iat1][iat2][box2] = C_norm2_outer.max(); // || C || + C_norm4_outer_max[iat1][iat2][box2] = sqrt( C_norm4_outer.max() ); // sqrt{ || C C^+ || } + } + + { // || C(j) || || C(j) C^+(j) || + valarray C_norm2_inner(nw2); + valarray C_norm4_inner(nw2); + for( size_t iw2=0; iw2!=nw2; ++iw2 ) + { + // C_inner( iw1, iw3 ) = C( iw1, iw2, iw3 ) + matrix C_inner( nw1, nw3 ); +// for( size_t iw1=0; iw1!=nw1; ++iw1 ) +// memcpy( C_inner.c+iw1*nw3, C.c+(iw1*nw2+iw2)*nw3, sizeof(double)*nw3 ); + const size_t nw23 = nw2*nw3; + const auto length = sizeof(double)*nw3; + double * C_inner_ptr = C_inner.c; + const double * C_ptr = C.c+iw2*nw3; + for( size_t iw1=0; iw1!=nw1; ++iw1, C_inner_ptr+=nw3, C_ptr+=nw23 ) + memcpy( C_inner_ptr, C_ptr, length ); + + C_norm2_inner[iw2] = C_inner.norm(); // || C || + C_norm4_inner[iw2] = m_mT(C_inner).norm(); // || C C^+ || + } + C_norm2_inner_max[iat1][iat2][box2] = C_norm2_inner.max(); // || C || + C_norm4_inner_max[iat1][iat2][box2] = sqrt( C_norm4_inner.max() ); // sqrt{ || C C^+ || } + } + + /* + matrix C_norm2_12( nw1, nw2 ); + for( size_t iw1=0; iw1!=nw1; ++iw1 ) + for( size_t iw2=0; iw2!=nw2; ++iw2 ) + C_norm2_12(iw1,iw2) = nrm2( nw3, C+iw1+iw2, 1 ); + valarray C_norm2_1(nw1); + for( size_t iw1=0; iw1!=nw1; ++iw1 ) + C_norm2_1(iw1) = nrm2( nw2, C_norm2_12+iw1, 1 ); + valarray C_norm2_2(nw2); + for( size_t iw2=0; iw2!=nw2; ++iw2 ) + C_norm2_2(iw2) = nrm2( nw1, C_norm2_12+iw2, 1 ); + + C_norm2_1_max[iat1][iat2][box2] = C_norm2_1.max(); + C_norm2_2_max[iat1][iat2][box2] = C_norm2_2.max(); + */ + } + } + } +} + +void Exx_Abfs::Screen::Cauchy::cal_norm_V( const map,shared_ptr>>> & Vs ) +{ + if(!flag_screen_cauchy) return; + TITLE("Exx_Abfs::Screen::Cauchy::cal_norm_V"); + + for( const auto & Vs1 : Vs ) + { + const size_t iat1 = Vs1.first; + for( const auto & Vs2 : Vs1.second ) + { + const size_t iat2 = Vs2.first; + for( const auto & Vs3 : Vs2.second ) + { + const Abfs::Vector3_Order &box2 = Vs3.first; + const matrix & V = *Vs3.second; + + V_norm4[iat1][iat2][box2] = sqrt( m_mT(V).norm() ); // \sqrt{ || V V^+ || } + } + } + } +} + +void Exx_Abfs::Screen::Cauchy::cal_norm_D_max( const vector,matrix>>>> & Ds ) +{ + if(!flag_screen_cauchy) return; + TITLE("Exx_Abfs::Screen::Cauchy::cal_norm_D_max"); + + for( size_t is=0; is!=NSPIN; ++is ) + { + for( const auto & DsA : Ds[is] ) + { + const size_t iat1 = DsA.first; + for( const auto & DsB : DsA.second ) + { + const size_t iat2 = DsB.first; + for( const auto & DsC : DsB.second ) + { + const Abfs::Vector3_Order &box2 = DsC.first; + const matrix & D = DsC.second; + const double D_norm4 = sqrt( m_mT(D).norm() ); // \sqrt{ || D D^+ || } + D_norm4_max[iat1][iat2][box2] = max( D_norm4, D_norm4_max[iat1][iat2][box2] ); // \sqrt{ || D D^+ || } + } + } + } + } +} + +Exx_Abfs::Screen::Cauchy::Info_Step Exx_Abfs::Screen::Cauchy::input_info( + const size_t iat1, const size_t iat2, const size_t iat3, const size_t iat4, + const Abfs::Vector3_Order & box2, + const Abfs::Vector3_Order & box3, + const Abfs::Vector3_Order & box4 ) const +{ + Info_Step info_step; + + info_step.C1_norm4_max = C_norm4_outer_max.at(iat1).at(iat3).at(box3); + info_step.C3_norm4_max = C_norm4_inner_max.at(iat1).at(iat3).at(box3); + info_step.C2_norm4_max = C_norm4_outer_max.at(iat2).at(iat4).at(box4); + info_step.C4_norm4_max = C_norm4_inner_max.at(iat2).at(iat4).at(box4); + + info_step.C1_norm2_max = C_norm2_outer_max.at(iat1).at(iat3).at(box3); + info_step.C3_norm2_max = C_norm2_inner_max.at(iat1).at(iat3).at(box3); + + info_step.V_norm4 = V_norm4.at(iat1).at(iat2).at(box2); + + if( const double*const D_ptr = static_cast(MAP_EXIST( D_norm4_max, iat3, iat4, Abfs::Vector3_Order(box2-box3+box4)%Born_von_Karman_period )) ) + info_step.D34_norm4_max = *D_ptr; + else + info_step.D34_norm4_max = 0; + if( const double*const D_ptr = static_cast(MAP_EXIST( D_norm4_max, iat3, iat2, Abfs::Vector3_Order(box2-box3 )%Born_von_Karman_period )) ) + info_step.D32_norm4_max = *D_ptr; + else + info_step.D32_norm4_max = 0; + if( const double*const D_ptr = static_cast(MAP_EXIST( D_norm4_max, iat1, iat4, Abfs::Vector3_Order(box2 +box4)%Born_von_Karman_period )) ) + info_step.D14_norm4_max = *D_ptr; + else + info_step.D14_norm4_max = 0; + if( const double*const D_ptr = static_cast(MAP_EXIST( D_norm4_max, iat1, iat2, Abfs::Vector3_Order(box2 )%Born_von_Karman_period )) ) + info_step.D12_norm4_max = *D_ptr; + else + info_step.D12_norm4_max = 0; + + return info_step; +} + +int Exx_Abfs::Screen::Cauchy::postcalA( const Info_Step & info_step ) const +{ + if( !flag_screen_cauchy ) return 4; + if( info_step.C1_norm4_max * info_step.V_norm4 * info_step.C2_norm4_max * info_step.D34_norm4_max > threshold ) return 4; + if( info_step.C3_norm4_max * info_step.V_norm4 * info_step.C2_norm4_max * info_step.D14_norm4_max > threshold ) return 3; + if( info_step.C1_norm4_max * info_step.V_norm4 * info_step.C4_norm4_max * info_step.D32_norm4_max > threshold ) return 2; + if( info_step.C3_norm4_max * info_step.V_norm4 * info_step.C4_norm4_max * info_step.D12_norm4_max > threshold ) return 1; +// ++num_screen1; + return 0; +} + +int Exx_Abfs::Screen::Cauchy::postcalB( + const Info_Step & info_step, + const matrix & VC_T, // iw2, \mu1, iw4 + const size_t range_iw2, + const size_t range_mu1, + const size_t range_iw4, + const int postcal_in) const +{ + if( !flag_screen_cauchy ) return 4; + switch(postcal_in) // Attention: case and go on calculating + { + case 4: case 3: + { + const double VC2_norm2_max = cal_matrix_outer_max( VC_T, range_iw2, range_mu1 * range_iw4 ); + if( info_step.C1_norm4_max * VC2_norm2_max * info_step.D34_norm4_max > threshold ) return 4; // H_{12} + if( info_step.C3_norm4_max * VC2_norm2_max * info_step.D14_norm4_max > threshold ) return 3; // H_{32} + } + case 2: case 1: + { + const double VC4_norm2_max = cal_matrix_inner_max( VC_T, range_iw2 * range_mu1, range_iw4 ); + if( info_step.C1_norm4_max * VC4_norm2_max * info_step.D32_norm4_max > threshold ) return 2; // H_{14} + if( info_step.C3_norm4_max * VC4_norm2_max * info_step.D12_norm4_max > threshold ) return 1; // H_{34} + } + } +// ++num_screen2; + return 0; +} + +bool Exx_Abfs::Screen::Cauchy::postcalC( + const Info_Step & info_step, + const matrix & DVC, // iw1/iw3, \mu1, iw2/iw4 + const size_t range_iw13, + const size_t range_mu1, + const size_t range_iw24, + const size_t iw13H) const +{ + if( !flag_screen_cauchy ) return true; + const double DVC24_norm2_max = cal_matrix_inner_max( DVC, range_iw13 * range_mu1, range_iw24 ); + switch(iw13H) + { + case 1: + if( info_step.C1_norm2_max * DVC24_norm2_max > threshold ) + { +// num_cal += 0.25/NSPIN; + return true; + } + else + { +// num_screen3 += 0.25/NSPIN; + return false; + } + break; + case 3: + if( info_step.C3_norm2_max * DVC24_norm2_max > threshold ) + { +// num_cal += 0.25/NSPIN; + return true; + } + else + { +// num_screen3 += 0.25/NSPIN; + return false; + } + break; + default: + throw domain_error(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + } +} + +// max_j \sqrt{ \sum_i m(i,j)^2 } +double Exx_Abfs::Screen::Cauchy::cal_matrix_inner_max( const matrix & m, const size_t ni, const size_t nj ) const +{ + assert( m.nr*m.nc == ni*nj ); + valarray m_inner(0.0,nj); + double * const m_inner_ptr = &m_inner[0]; + for( size_t i=0; i m_outer(ni); + for( size_t i=0; i +#include + +class Exx_Abfs::Screen::Cauchy +{ +public: + struct Info_Step + { + double C1_norm4_max; + double C3_norm4_max; + double C2_norm4_max; + double C4_norm4_max; + + double C1_norm2_max; + double C3_norm2_max; + + double V_norm4; + + double D34_norm4_max; + double D32_norm4_max; + double D14_norm4_max; + double D12_norm4_max; + }; + +public: + + void init( + const bool flag_screen_cauchy_in, + const double threshold_in, + const Abfs::Vector3_Order Born_von_Karman_period_in); + void cal_norm_C_max( + const map,shared_ptr>>> & Cs, + const Element_Basis_Index::IndexLNM & index_lcaos, + const Element_Basis_Index::IndexLNM & index_abfs); + void cal_norm_V( const map,shared_ptr>>> & Vs ); + void cal_norm_D_max( const vector,matrix>>>> & Ds ); + + Info_Step input_info( + const size_t iat1, const size_t iat2, const size_t iat3, const size_t iat4, + const Abfs::Vector3_Order & box2, + const Abfs::Vector3_Order & box3, + const Abfs::Vector3_Order & box4 ) const; + int postcalA( const Info_Step & info_step ) const; + int postcalB( + const Info_Step & info_step, + const matrix & VC_T, // iw2, \mu1, iw4 + const size_t range_iw2, + const size_t range_mu1, + const size_t range_iw4, + const int postcal_in) const; + bool postcalC( + const Info_Step & info_step, + const matrix & DVC, // iw1/iw3, \mu1, iw2/iw4 + const size_t range_iw13, + const size_t range_mu1, + const size_t range_iw24, + const size_t iw13H) const; + bool postcalD( const matrix & H ) const { return (H.absmax()>threshold) ? true : false; } + +private: + // max_j \sqrt{ \sum_i m(i,j)^2 } + double cal_matrix_inner_max( const matrix & m, const size_t ni, const size_t nj ) const; + // max_i \sqrt{ \sum_j m(i,j)^2 } + double cal_matrix_outer_max( const matrix & m, const size_t ni, const size_t nj ) const; + // m m^+ + matrix m_mT( const matrix & m ) const; + +private: + + bool flag_screen_cauchy = false; + double threshold = 0; + Abfs::Vector3_Order Born_von_Karman_period; + +private: + + // \sqrt{ || C C^+ || } for C_{ I i \mu, K k } + map,double>>> C_norm4_outer_max; // max_i \sqrt{ || C_i C_i^+ || } + map,double>>> C_norm4_inner_max; // max_k \sqrt{ || C_k C_k^+ || } + + // \sqrt{ || V V^+ || } for V_{ U \mu, V \nu } + map,double>>> V_norm4; + + // \sqrt{ || m m^+ || } for D_{ K k, L l } + map,double>>> D_norm4_max; // max_is \sqrt{ || m m^+ || } + + // || C || for C_{ I i \mu, K k } + map,double>>> C_norm2_outer_max; // max_i || C_i || + map,double>>> C_norm2_inner_max; // max_k || C_k || + +//public: +// static double num_screen1; +// static double num_screen2; +// static double num_screen3; +// static double num_cal; +}; + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.cpp new file mode 100644 index 0000000000..bee0f7b473 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.cpp @@ -0,0 +1,200 @@ +#include "exx_abfs-screen-schwarz.h" +#include "src_pw/global.h" +#include "src_global/lapack_connector.h" +#include +#include +#include +#include + +#include "src_external/src_test/src_lcao/exx_abfs-screen-test.h" +#include "src_external/src_test/src_lcao/exx_lcao-test.h" +//double Exx_Abfs::Screen::Schwarz::num_screen = 0; +//double Exx_Abfs::Screen::Schwarz::num_cal = 0; + +void Exx_Abfs::Screen::Schwarz::init( + const bool flag_screen_schwarz_in, + const double threshold_in ) +{ + flag_screen_schwarz = flag_screen_schwarz_in; + threshold = threshold_in * threshold_in; +} + + +void Exx_Abfs::Screen::Schwarz::cal_max_pair_fock( + const set &atom_centres, + const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, + const Exx_Abfs::Matrix_Orbs21 &m_abfslcaos_lcaos, + const Element_Basis_Index::IndexLNM &index_abfs, + const Element_Basis_Index::IndexLNM &index_lcaos, + const Abfs::Vector3_Order &Born_von_Karman_period, + map,weak_ptr>>> &Cws, + map,weak_ptr>>> &Vws ) +{ + if(!flag_screen_schwarz) return; + TITLE("Exx_Abfs::Screen::Schwarz::cal_max_pair_fock"); + + const vector>>> adjs = Abfs::get_adjs(); + const vector atom_centers_v( atom_centres.begin(), atom_centres.end() ); + + // pre-cal Vws on same atom, speed up DPcal_V() + vector> Vs_same_atom(ucell.ntype); + for(size_t it=0; it!=ucell.ntype; ++it) + Vs_same_atom[it] = Abfs::DPcal_V( it,it,{0,0,0}, m_abfs_abfs, index_abfs, 0,true,Vws ); + + const int mkl_threads = mkl_get_max_threads(); + mkl_set_num_threads(1); + + atomic i_atom_centre = 0; + atomic_flag lock_max_pair_fock = ATOMIC_FLAG_INIT; + + vector ts; + for( int it=0; it &atom_centres, + const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, + const Exx_Abfs::Matrix_Orbs21 &m_abfslcaos_lcaos, + const Element_Basis_Index::IndexLNM &index_abfs, + const Element_Basis_Index::IndexLNM &index_lcaos, + const Abfs::Vector3_Order &Born_von_Karman_period, + map,weak_ptr>>> &Cws, + map,weak_ptr>>> &Vws, + const vector>>> &adjs, + atomic &i_atom_centre, + atomic_flag &lock_max_pair_fock) +{ + TITLE("Exx_Abfs::Screen::Schwarz::cal_max_pair_fock_thread"); + + // m_out( i1, i2, i3 ) = m_in( i2, i1, i3 ) + auto change_matrix_order =[]( const matrix &m_in, const size_t n1 ) -> matrix + { + assert( m_in.nr%n1 == 0 ); + matrix m_out( m_in.nr, m_in.nc, false ); + const size_t n2 = m_in.nr/n1, + n3 = m_in.nc, + n13 = n1*n3; + const auto length = n3*sizeof(double); + double * m_out_ptr = m_out.c; + for( size_t i1=0; i1!=n1; ++i1 ) + { + const double * m_in_ptr = m_in.c + i1*n3; + for( size_t i2=0; i2!=n2; ++i2, m_in_ptr+=n13, m_out_ptr+=n3 ) + memcpy( m_out_ptr, m_in_ptr, length ); + } + return m_out; + }; + + // max_i m(i,i) + auto max_diagnal = []( const matrix & m ) -> double + { + assert(m.nr==m.nc); + double diagnal = -std::numeric_limits::max(); + for( size_t i=0; i!=m.nr; ++i ) + diagnal = max( diagnal, m(i,i) ); + return diagnal; + }; + + // m * m.T + auto m_mT = []( const matrix & m1, const matrix & m2 ) -> matrix + { + assert( m1.nc == m2.nc ); + matrix mm( m1.nr, m2.nr, false ); + LapackConnector::gemm( 'N','T', m1.nr,m2.nr,m1.nc, 1, m1.c,m1.nc, m2.c,m2.nc, 0, mm.c,mm.nc ); + return mm; + }; + + while(true) + { + const size_t i_atom_centre_now = i_atom_centre++; + if( i_atom_centre_now >= atom_centres.size() ) return; + + map,double>> max_pair_fock_thread; + + const size_t iat1 = atom_centres[i_atom_centre_now]; + const size_t it1 = ucell.iat2it[iat1]; + const size_t ia1 = ucell.iat2ia[iat1]; + const Abfs::Vector3_Order tau1( ucell.atoms[it1].tau[ia1] ); + + const map>> adj = adjs[iat1]; + for( const auto & atom2 : adj ) + { + const int iat2 = atom2.first; + const int it2 = ucell.iat2it[iat2]; + const int ia2 = ucell.iat2ia[iat2]; + const Abfs::Vector3_Order tau2( ucell.atoms[it2].tau[ia2] ); + + map,shared_ptr> pair_fock_s; + for( const Vector3 &box2 : atom2.second ) + { + const Abfs::Vector3_Order R = -tau1+(tau2+box2*ucell.latvec); + + const matrix C_12 = *Abfs::DPcal_C( it1,it2,R, m_abfs_abfs,m_abfslcaos_lcaos, index_abfs,index_lcaos, 0,false,Cws,Vws ); + const matrix C_21 = change_matrix_order( + *Abfs::DPcal_C( it2,it1,-R, m_abfs_abfs,m_abfslcaos_lcaos, index_abfs,index_lcaos, 0,false,Cws,Vws ), + index_lcaos[it1].count_size); + + const matrix V_11 = *Abfs::DPcal_V(it1,it1,{0,0,0},m_abfs_abfs,index_abfs,0,false,Vws); + const matrix V_12 = *Abfs::DPcal_V(it1,it2,R, m_abfs_abfs,index_abfs,0,false,Vws); + const matrix V_21 = *Abfs::DPcal_V(it2,it1,-R, m_abfs_abfs,index_abfs,0,false,Vws); + const matrix V_22 = *Abfs::DPcal_V(it2,it2,{0,0,0},m_abfs_abfs,index_abfs,0,false,Vws); + + pair_fock_s[box2] = make_shared( + m_mT( C_12 * V_11, C_12 ) + + m_mT( C_12 * V_12, C_21 ) + + m_mT( C_21 * V_21, C_12 ) + + m_mT( C_21 * V_22, C_21 )); + } + + const map,shared_ptr> pair_fock_ps = Abfs::cal_mps( Born_von_Karman_period, pair_fock_s ); + + for( const auto & pair_fock_p : pair_fock_ps ) + { + const Abfs::Vector3_Order & box2 = pair_fock_p.first; + max_pair_fock_thread[iat2][box2] = max_diagnal(*pair_fock_p.second); + } + } + + while( lock_max_pair_fock.test_and_set() ); + max_pair_fock[iat1] = std::move(max_pair_fock_thread); + lock_max_pair_fock.clear(); + } +} + +bool Exx_Abfs::Screen::Schwarz::screen( + const size_t iat1, const size_t iat2, const size_t iat3, const size_t iat4, + const Abfs::Vector3_Order & box3, const Abfs::Vector3_Order & box4 ) const +{ + if(!flag_screen_schwarz) + return false; + if( max_pair_fock.at(iat1).at(iat3).at(box3) * max_pair_fock.at(iat2).at(iat4).at(box4) > threshold ) + { +// num_cal += 1; + return false; + } + else + { +// num_screen += 1; + return true; + } +} \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.h new file mode 100644 index 0000000000..3e1d4ad297 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.h @@ -0,0 +1,55 @@ +#ifndef EXX_ABFS_SCREEN_SCHWARZ +#define EXX_ABFS_SCREEN_SCHWARZ + +#include "exx_abfs.h" +#include "abfs.h" +#include "src_global/matrix.h" +#include +#include + +// |\braket{ik|jl}| \leq \sqrt{ \braket{ik|ik} \braket{jl|jl} } + +class Exx_Abfs::Screen::Schwarz +{ +public: + void init( + const bool flag_screen_schwarz_in, + const double threshold_in); + void cal_max_pair_fock( + const set &atom_centres, + const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, + const Exx_Abfs::Matrix_Orbs21 &m_abfslcaos_lcaos, + const Element_Basis_Index::IndexLNM &index_abfs, + const Element_Basis_Index::IndexLNM &index_lcaos, + const Abfs::Vector3_Order &Born_von_Karman_period, + map,weak_ptr>>> &Cws, + map,weak_ptr>>> &Vws ); + bool screen( + const size_t iat1, const size_t iat2, const size_t iat3, const size_t iat4, + const Abfs::Vector3_Order & box3, const Abfs::Vector3_Order & box4 ) const; + +private: + void cal_max_pair_fock_thread( + const vector &atom_centres, + const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, + const Exx_Abfs::Matrix_Orbs21 &m_abfslcaos_lcaos, + const Element_Basis_Index::IndexLNM &index_abfs, + const Element_Basis_Index::IndexLNM &index_lcaos, + const Abfs::Vector3_Order &Born_von_Karman_period, + map,weak_ptr>>> &Cws, + map,weak_ptr>>> &Vws, + const vector>>> &adjs, + atomic &i_atom_centre, + atomic_flag &lock_max_pair_fock); + +private: + bool flag_screen_schwarz = false; + double threshold = 0; + map,double>>> max_pair_fock; + +public: +// static double num_screen; +// static double num_cal; +}; + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs.cpp new file mode 100644 index 0000000000..569bdc5a4a --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs.cpp @@ -0,0 +1,1080 @@ +#include "exx_abfs.h" + +#include "exx_abfs-abfs_index.h" +#include "exx_abfs-jle.h" +#include "exx_abfs-inverse_matrix_double.h" +#include "exx_abfs-io.h" +#include "exx_abfs-construct_orbs.h" + +#include "exx_abfs-matrix_orbs11.h" +#include "exx_abfs-matrix_orbs21.h" +#include "exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h" + +#include "lcao_orbitals.h" +#include "conv_coulomb_pot.h" +#include "conv_coulomb_pot-inl.h" + +#include "src_global/global_function.h" + +#include "src_external/src_test/test_function.h" // Peize Lin test +#include "src_external/src_test/src_lcao/exx_abfs-unittest.h" +#include "src_external/src_test/src_lcao/make_gaunt_table-unittest.h" +#include "src_external/src_test/src_global/element_basis_index-test.h" // Peize Lin test 2016-04-05 +#include "src_pw/global.h" +#include // Peize Lin test + +int Exx_Abfs::Lmax = 0; // Peize Lin test + +void Exx_Abfs::test_all() const +{ + auto test_MGT = []() + { + const int Lmax = 3; + Make_Gaunt_Table MGT; + MGT.init_Gaunt_CH( Lmax ); + MGT.init_Gaunt( Lmax ); + cout_MGT(MGT,Lmax); + }; + + auto test_abfs = []() + { + const vector>> + &&lcaos = Construct_Orbs::change_orbs( ORB, 1 ); + const vector>> + &&abfs = Construct_Orbs::abfs_same_atom( lcaos, 1 ); + + for( size_t T=0; T!=abfs.size(); ++T ) + Lmax = std::max( Lmax, static_cast(abfs[T].size())-1 ); + + const Element_Basis_Index::Range + &&range_abfs = Abfs_Index::construct_range( abfs ); + const Element_Basis_Index::IndexLNM + &&index_abfs = Element_Basis_Index::construct_index( range_abfs ); + + Matrix_Orbs11 m_abfs_abfs; + cout<<"D1"<>>> + &&ms_abfs_abfs = m_abfs_abfs.cal_overlap_matrix( index_abfs, index_abfs ); + ofs_ms("ms_abfs_abfs",ms_abfs_abfs); + }; + + auto test_svd = []() + { + const vector>> + &&lcaos = Construct_Orbs::change_orbs( ORB, 1 ); + const vector>> + &&abfs = Construct_Orbs::abfs_same_atom( lcaos, 1 ); + + for( size_t T=0; T!=abfs.size(); ++T ) + Lmax = std::max( Lmax, static_cast(abfs[T].size())-1 ); + + const Element_Basis_Index::Range + &&range_abfs = Abfs_Index::construct_range( abfs ); + const Element_Basis_Index::IndexLNM + &&index_abfs = Element_Basis_Index::construct_index( range_abfs ); + + const Element_Basis_Index::Range + &&range_lcaos = Abfs_Index::construct_range( ORB ); + const Element_Basis_Index::IndexLNM + &&index_lcaos = Element_Basis_Index::construct_index( range_lcaos ); + + Matrix_Orbs21 m_abfslcaos_lcaos; + m_abfslcaos_lcaos.init( 1, 1, 1 ); + m_abfslcaos_lcaos.init_radial( abfs, ORB, ORB ); + m_abfslcaos_lcaos.init_radial_table(); + const map>>>> + &&ms_lcaos2_abfs = m_abfslcaos_lcaos.cal_overlap_matrix( index_abfs, index_lcaos, index_lcaos ); + ofs_ms("ms_lcaos2_abfs",ms_lcaos2_abfs); + }; + + auto test_GriD = []() + { + for (int T1 = 0; T1 < ucell.ntype; ++T1) + for (int I1 = 0; I1 < ucell.atoms[T1].na; ++I1) + { + cout<<"@\t"<>> +// &&abfs_same_atom = Construct_Orbs::abfs_same_atom( ORB ); + + Exx_Abfs::Lmax = Jle::Lmax; +// for( size_t T=0; T!=abfs_same_atom.size(); ++T ) +// Exx_Abfs::Lmax = std::max( Exx_Abfs::Lmax, static_cast(abfs_same_atom[T].size()) ); + +cout<>>> + &&ms_jys_jys = m_jys_jys.cal_overlap_matrix( index_jys, index_jys ); + +ofs_ms("ms_jys_jys",ms_jys_jys); + + map>>>> + &&ms_lcaos2_jys = m_jyslcaos_lcaos.cal_overlap_matrix( index_jys, index_lcaos, index_lcaos ); + +ofs_ms("ms_lcaos2_jys",ms_lcaos2_jys); + +cout<<"G2"<>>> + &&ms_lcaos2_lcaos2 = mllll.cal_overlap_matrix( index_lcaos, index_lcaos ); + +ofs_ms("ms_lcaos2_lcaos2",ms_lcaos2_lcaos2); + +cout<<"G3"<>>>> +// &&ms_lcaos2_asa = m_asalcaos_lcaos.cal_overlap_matrix( index_asa, index_lcaos, index_lcaos ); + +//ofs_ms("ms_lcaos2_asa",ms_lcaos2_asa); + +cout<<"G4"<>>> +// &&ms_asa_asa = m_asa_asa.cal_overlap_matrix( index_asa, index_asa ); + +//ofs_ms("ms_asa_asa",ms_asa_asa); + +cout<<"G5"<>>>>> +// &&ms_asa_asa_I = cal_I( ms_asa_asa, index_asa ); + +//ofs_ms("ms_asa_asa_I",ms_asa_asa_I); + +cout<<"G6"<>>> +// &&ms_asa_jys = m_asa_jys.cal_overlap_matrix( index_asa, index_jys ); + +//ofs_ms("ms_asa_jys",ms_asa_jys); + +// const map>>> +// &&ms_lcaos2_lcaos2_proj_asa = cal_lcaos2_lcaos2_proj_asa( ms_lcaos2_asa, ms_asa_asa_I, range_lcaos, index_lcaos ); + +//ofs_ms("ms_lcaos2_lcaos2_proj_asa",ms_lcaos2_lcaos2_proj_asa); + +// const map>>>> +// &&ms_lcaos2_jys_proj_asa = cal_lcaos2_jys_proj_asa( ms_lcaos2_asa, ms_asa_asa_I, ms_asa_jys ); + +//ofs_ms("ms_lcaos2_jys_proj_asa",ms_lcaos2_jys_proj_asa); + +cout<<"G7"< +// minus_matrix = []( matrix &mA, const matrix &mB ){ mA-=mB; }; +// // ms_lcaos2_lcaos2 -= ms_lcaos2_lcaos2_proj_asa +// FUNC_EACH_2( ms_lcaos2_lcaos2, ms_lcaos2_lcaos2_proj_asa, minus_matrix ); +// // ms_lcaos2_jys -= ms_lcaos2_jys_proj_asa +// FUNC_EACH_2( ms_lcaos2_jys, ms_lcaos2_jys_proj_asa, minus_matrix ); + +//ofs_ms("ms_lcaos2_lcaos2_new",ms_lcaos2_lcaos2); +//ofs_ms("ms_lcaos2_jys_new",ms_lcaos2_jys); + +cout<<"H"<files_abfs) +// cout<>> + &&lcaos = Construct_Orbs::change_orbs( ORB, this->kmesh_times ); + const vector>> + &&abfs_same_atom = Construct_Orbs::abfs_same_atom( lcaos, this->kmesh_times ); + // Peize Lin test +// vector>> +// &&abfs_same_atom = IO::Abfs_Same_Atom::construct( ORB ); +// for( size_t T=0; T!=abfs_same_atom.size(); ++T ) +// if( abfs_same_atom[T].size()>4 ) +// abfs_same_atom[T].resize(4); + +const Element_Basis_Index::Range + &&range_asa = Abfs_Index::construct_range( abfs_same_atom ); +cout<>> +// &&abfs = IO::construct_abfs( ORB, this->files_abfs, this->kmesh_times ); // Peize Lin test +// &&abfs = IO::construct_abfs( abfs_same_atom, ORB, this->files_abfs, this->kmesh_times ); // Peize Lin test + &abfs = abfs_same_atom; + + for( size_t T=0; T!=abfs.size(); ++T ) + this->Lmax = std::max( this->Lmax, static_cast(abfs[T].size())-1 ); + +cout<kmesh_times); +cout<<"D12"<kmesh_times); +cout<<"D22"<>>> + &&ms_lcaos2_lcaos2 = mllll.cal_overlap_matrix( index_lcaos, index_lcaos ); + +ofs_ms("ms_lcaos2_lcaos2",ms_lcaos2_lcaos2); + +cout<<"G3"<>>>> + &&ms_lcaos2_abfs = m_abfslcaos_lcaos.cal_overlap_matrix( index_abfs, index_lcaos, index_lcaos ); + +ofs_ms("ms_lcaos2_abfs",ms_lcaos2_abfs); + +cout<<"G4"<>>> + &&ms_abfs_abfs = m_abfs_abfs.cal_overlap_matrix( index_abfs, index_abfs ); + +ofs_ms("ms_abfs_abfs",ms_abfs_abfs); + +cout<<"G5"<>>>>> + &&ms_abfs_abfs_I = cal_I( ms_abfs_abfs, index_abfs ); + +ofs_ms("ms_abfs_abfs_I",ms_abfs_abfs_I); + +cout<<"G6"<>>> + &&ms_lcaos2_lcaos2_proj_abfs = cal_lcaos2_lcaos2_proj_asa( ms_lcaos2_abfs, ms_abfs_abfs_I, range_lcaos, index_lcaos ); + +ofs_ms("ms_lcaos2_lcaos2_proj_abfs",ms_lcaos2_lcaos2_proj_abfs); + +cout<<"G7"< + minus_matrix = []( matrix &mA, const matrix &mB ){ mA-=mB; }; + // ms_lcaos2_lcaos2 -= ms_lcaos2_lcaos2_proj_asa + FUNC_EACH_2( ms_lcaos2_lcaos2, ms_lcaos2_lcaos2_proj_abfs, minus_matrix ); + +ofs_ms("ms_lcaos2_lcaos2_new",ms_lcaos2_lcaos2); + +cout<<"H"<>> + &&lcaos = Construct_Orbs::change_orbs( ORB, this->kmesh_times ); +// &&lcaos = Construct_Orbs::change_orbs( ORB, 1 ); + +cout<<"A1"<>> + &&abfs_same_atom = Construct_Orbs::abfs_same_atom( lcaos, this->kmesh_times ); +cout<<"A2"<>> +// &&abfs_origin = IO::construct_abfs( abfs_same_atom, ORB, this->files_abfs, this->kmesh_times ); // Peize Lin test +// &&abfs = IO::construct_abfs( ORB, this->files_abfs, this->kmesh_times ); // Peize Lin test +cout<<"A3"<>> +// &&abfs = Construct_Orbs::orth_orbs( abfs_origin ); // Peize Lin test + &&abfs = Construct_Orbs::orth_orbs( abfs_same_atom ); // Peize Lin test +cout<<"A4"<>> abfs_ccp; + Conv_Coulomb_Pot::cal_orbs_ccp( abfs, abfs_ccp, this->rmesh_times, 1 ); + + for( size_t T=0; T!=abfs.size(); ++T ) + this->Lmax = std::max( this->Lmax, static_cast(abfs[T].size())-1 ); + +cout<<"B"<>>> + &&matrix_V = m_lcaos_lcaos.cal_overlap_matrix(index_lcaos,index_lcaos); + + ofstream ofs("S_matrix.dat"); + for( const auto & m1 : matrix_V ) + { + const size_t TA = m1.first; + for( const auto & m2 : m1.second ) + { + const size_t IA = m2.first; + for( const auto & m3 : m2.second ) + { + const size_t TB = m3.first; + for( const auto & m4 : m3.second ) + { + const size_t IB = m4.first; + ofs<kmesh_times); + m_lcaos_lcaos.init_radial( lcaos, lcaos ); + m_lcaos_lcaos.init_radial_table(); + const map>>> + &&matrix_V = m_lcaos_lcaos.cal_overlap_matrix(index_lcaos,index_lcaos); + + ofstream ofs("S_matrix.dat"); + for( const auto & m1 : matrix_V ) + { + const size_t TA = m1.first; + for( const auto & m2 : m1.second ) + { + const size_t IA = m2.first; + for( const auto & m3 : m2.second ) + { + const size_t TB = m3.first; + for( const auto & m4 : m3.second ) + { + const size_t IB = m4.first; + ofs< m_ll2_ll2; +cout<<"D0"<kmesh_times, this->rmesh_times ); +cout<<"D1"<>>> + &&ms_ll2_ll2 = m_ll2_ll2.cal_overlap_matrix(index_lcaos,index_lcaos); +cout<<"D4"<kmesh_times, this->rmesh_times ); +cout<<"D2"<kmesh_times, this->rmesh_times ); + m_abfslcaos_lcaos.init_radial( abfs_ccp, lcaos, lcaos ); + m_abfslcaos_lcaos.init_radial_table(); + +cout<<"F"<>>> + &&ms_abfs_abfs = m_abfs_abfs.cal_overlap_matrix( index_abfs, index_abfs ); +ofs_ms("ms_abfs_abfs",ms_abfs_abfs); + + const map>>>> + &&ms_lcaos2_abfs = m_abfslcaos_lcaos.cal_overlap_matrix( index_abfs, index_lcaos, index_lcaos ); +ofs_ms("ms_lcaos2_abfs",ms_lcaos2_abfs); + +cout<<"G"<>>>>> + &&ms_abfs_abfs_I = cal_I( ms_abfs_abfs, index_abfs ); +ofs_ms("ms_abfs_abfs_I",ms_abfs_abfs_I); + +cout<<"G1"<>>>> + &&ms_C = cal_C( ms_lcaos2_abfs, ms_abfs_abfs_I ); +ofs_ms("ms_C",ms_C); + +cout<<"H"< .I +// & +// +// .I +map>>>>> Exx_Abfs::cal_I( + const map>>> &ms, + const Element_Basis_Index::IndexLNM &index ) +{ + map>>>>> ms_I; + + for( const auto &m1 : ms ) + { + const size_t TA = m1.first; + for( const auto &m2 : m1.second ) + { + const size_t IA = m2.first; + for( const auto &m3 : m2.second ) + { + const size_t TB = m3.first; + for( const auto &m4 : m3.second ) + { + const size_t IB = m4.first; + + Inverse_Matrix_Double ms_tmp; + + if( TA==TB && IA==IB ) + { + const size_t size_A = index[TA].count_size; + + ms_tmp.init( size_A ); + ms_tmp.input( + ms.at(TA).at(IA).at(TA).at(IA) ); + } + else + { + const size_t size_A = index[TA].count_size; + const size_t size_B = index[TB].count_size; + + ms_tmp.init( size_A + size_B ); + ms_tmp.input( + ms.at(TA).at(IA).at(TA).at(IA), + ms.at(TA).at(IA).at(TB).at(IB), + ms.at(TB).at(IB).at(TA).at(IA), + ms.at(TB).at(IB).at(TB).at(IB)); + } + + // Peize Lin test +// cout<(1) ); + ms_I[TA][IA][TB][IB][0][0].create( size_A, size_A ); + + ms_tmp.output( + ms_I[TA][IA][TB][IB][0][0]); + } + else + { + const size_t size_A = index[TA].count_size; + const size_t size_B = index[TB].count_size; + + ms_I[TA][IA][TB][IB].resize( 2, vector(2) ); + ms_I[TA][IA][TB][IB][0][0].create( size_A, size_A ); + ms_I[TA][IA][TB][IB][0][1].create( size_A, size_B ); + ms_I[TA][IA][TB][IB][1][0].create( size_B, size_A ); + ms_I[TA][IA][TB][IB][1][1].create( size_B, size_B ); + + ms_tmp.output( + ms_I[TA][IA][TB][IB][0][0], + ms_I[TA][IA][TB][IB][0][1], + ms_I[TA][IA][TB][IB][1][0], + ms_I[TA][IA][TB][IB][1][1]); + } + } + } + } + } + return ms_I; +} + +// * .I +map>>>> Exx_Abfs::cal_C( + const map>>>> &ms_lcaos2_abfs, + const map>>>>> &ms_abfs_abfs_I ) +{ + map>>>> ms_C; + + for( const auto & m1 : ms_lcaos2_abfs ) + { + const size_t TA = m1.first; + for( const auto & m2 : m1.second ) + { + const size_t IA = m2.first; + for( const auto &m3 : m2.second ) + { + const size_t TB = m3.first; + for( const auto &m4 : m3.second ) + { + const size_t IB = m4.first; + + if( TA==TB && IA==IB ) + { + ms_C[TA][IA][TB][IB].resize(1); + ms_C[TA][IA][TB][IB][0].create( m4.second[0].nr, m4.second[0].nc ); + + const auto &m_lcaos2_abfs = m4.second; + const auto &m_abfs_abfs_I = ms_abfs_abfs_I.at(TA).at(IA).at(TB).at(IB); + + ms_C[TA][IA][TB][IB][0] = m_lcaos2_abfs[0] * m_abfs_abfs_I[0][0]; + } + else + { + ms_C[TA][IA][TB][IB].resize(2); + for( size_t i=0; i<2; ++i ) + ms_C[TA][IA][TB][IB][i].create( m4.second[i].nr, m4.second[i].nc ); + + const auto &m_lcaos2_abfs = m4.second; + const auto &m_abfs_abfs_I = ms_abfs_abfs_I.at(TA).at(IA).at(TB).at(IB); + ms_C[TA][IA][TB][IB][0] = m_lcaos2_abfs[0] * m_abfs_abfs_I[0][0] + + m_lcaos2_abfs[1] * m_abfs_abfs_I[1][0]; + ms_C[TA][IA][TB][IB][1] = m_lcaos2_abfs[0] * m_abfs_abfs_I[0][1] + + m_lcaos2_abfs[1] * m_abfs_abfs_I[1][1]; + } + } + } + } + } + return ms_C; +} + +// (*.I) * * (.I*) +void Exx_Abfs::cal_CVC( + const map>>>> &ms_C, + const map>>> &ms_abfs_abfs ) const +{ + ofstream ofs("ms_CVC"); + + for( const auto & m11 : ms_C ) + { + const size_t TA = m11.first; + for( const auto & m12 : m11.second ) + { + const size_t IA = m12.first; + for( const auto & m13 : m12.second ) + { + const size_t TB = m13.first; + for( const auto & m14 : m13.second ) + { + const size_t IB = m14.first; + for( const auto & m21 : ms_C ) + { + const size_t TC = m21.first; + for( const auto & m22 : m21.second ) + { + const size_t IC = m22.first; + for( const auto & m23 : m22.second ) + { + const size_t TD = m23.first; + for( const auto & m24 : m23.second ) + { + const size_t ID = m24.first; + + auto m_00 = [&](){ return m14.second[0] * ms_abfs_abfs.at(TA).at(IA).at(TC).at(IC) * transpose(m24.second[0]); }; + auto m_01 = [&](){ return m14.second[0] * ms_abfs_abfs.at(TA).at(IA).at(TD).at(ID) * transpose(m24.second[1]); }; + auto m_10 = [&](){ return m14.second[1] * ms_abfs_abfs.at(TB).at(IB).at(TC).at(IC) * transpose(m24.second[0]); }; + auto m_11 = [&](){ return m14.second[1] * ms_abfs_abfs.at(TB).at(IB).at(TD).at(ID) * transpose(m24.second[1]); }; + + //matrix_CVC[TA][IA][TB][IB]|[TC][IC][TD][ID] = + matrix mm; // Peize Lin test + + if( TA==TB && IA==IB ) + { + if( TC==TD && IC==ID ) + { + mm = m_00(); + } + else + { + mm = m_00()+m_01(); + } + } + else + { + if( TC==TD && IC==ID ) + { + mm = m_00()+m_10(); + } + else + { + mm = m_00()+m_01()+m_10()+m_11(); + } + } + + // Peize Lin test + ofs< * .I * +map>>> Exx_Abfs::cal_lcaos2_lcaos2_proj_asa( + const map>>>> &ms_lcaos2_asa, + const map>>>>> &ms_asa_asa_I, + const Element_Basis_Index::Range &range, + const Element_Basis_Index::IndexLNM &index) +{ + map>>> ms_lcaos2_lcaos2_proj_asa; + for( const auto &m1 : ms_lcaos2_asa ) + { + const size_t TA = m1.first; + for( const auto & m2 : m1.second ) + { + const size_t IA = m2.first; + for( const auto & m3 : m2.second ) + { + const size_t TB = m3.first; + for( const auto & m4 : m3.second ) + { + const size_t IB = m4.first; + const auto & m_lcaos2_asa = m4.second; + const auto & m_abfs_abfs_I = ms_asa_asa_I.at(TA).at(IA).at(TB).at(IB); + + vector mql(2); + size_t matrix_num; + if( TA==TB && IA==IB ) + { + matrix_num = 1; + mql[0] = m_lcaos2_asa[0] * m_abfs_abfs_I[0][0]; + } + else + { + matrix_num = 2; + mql[0] = m_lcaos2_asa[0] * m_abfs_abfs_I[0][0] + m_lcaos2_asa[1] * m_abfs_abfs_I[1][0]; + mql[1] = m_lcaos2_asa[0] * m_abfs_abfs_I[0][1] + m_lcaos2_asa[1] * m_abfs_abfs_I[1][1]; + } + + ms_lcaos2_lcaos2_proj_asa[TA][IA][TB][IB].create( + index[TA].count_size, + index[TB].count_size ); + for( size_t LA=0; LA!=range[TA].size(); ++LA ) + for( size_t NA=0; NA!=range[TA][LA].N; ++NA ) + for( size_t MA=0; MA!=range[TA][LA].M; ++MA ) + for( size_t LB=0; LB!=range[TB].size(); ++LB ) + for( size_t NB=0; NB!=range[TB][LB].N; ++NB ) + for( size_t MB=0; MB!=range[TB][LB].M; ++MB ) + { + double mv_sas = 0.0; + for( size_t im=0; im!=matrix_num; ++im ) + { + assert( mql[im].nc==m_lcaos2_asa[im].nc ); + for( size_t ic=0; ic!=mql[im].nc; ++ic ) + { + mv_sas + += mql[im]( + Exx_Abfs::Abfs_Index::get_index_index( + index,TA,LA,NA,MA, + index,TB,LB,NB,MB ), + ic) + * m_lcaos2_asa[im]( + Exx_Abfs::Abfs_Index::get_index_index( + index,TA,LA,NA,MA, + index,TB,LB,NB,MB ), + ic); + } + } + ms_lcaos2_lcaos2_proj_asa[TA][IA][TB][IB]( + index[TA][LA][NA][MA], + index[TB][LB][NB][MB] ) + = mv_sas; + } + } + } + } + } + return ms_lcaos2_lcaos2_proj_asa; +} + +// * .I * +map>>>> Exx_Abfs::cal_lcaos2_jys_proj_asa( + const map>>>> &ms_lcaos2_asa, + const map>>>>> &ms_asa_asa_I, + const map>>> &ms_asa_jys) +{ + map>>>> ms_lcaos2_jys_proj_asa; + + for( const auto & m1 : ms_lcaos2_asa ) + { + const size_t TA = m1.first; + for( const auto & m2 : m1.second ) + { + const size_t IA = m2.first; + for( const auto &m3 : m2.second ) + { + const size_t TB = m3.first; + for( const auto &m4 : m3.second ) + { + const size_t IB = m4.first; + + if( TA==TB && IA==IB ) + { + ms_lcaos2_jys_proj_asa[TA][IA][TB][IB].resize(1); + + ms_lcaos2_jys_proj_asa[TA][IA][TB][IB][0] + = ms_lcaos2_asa.at(TA).at(IA).at(TB).at(IB)[0] + * ms_asa_asa_I.at(TA).at(IA).at(TB).at(IB)[0][0] + * ms_asa_jys.at(TA).at(IA).at(TA).at(IA); + } + else + { + vector ms_tmp(2); + for( size_t i=0; i<2; ++i ) + ms_tmp[i] + = ms_lcaos2_asa.at(TA).at(IA).at(TB).at(IB)[0] + * ms_asa_asa_I.at(TA).at(IA).at(TB).at(IB)[0][i] + + ms_lcaos2_asa.at(TA).at(IA).at(TB).at(IB)[1] + * ms_asa_asa_I.at(TA).at(IA).at(TB).at(IB)[1][i]; + + ms_lcaos2_jys_proj_asa[TA][IA][TB][IB].resize(2); + + ms_lcaos2_jys_proj_asa[TA][IA][TB][IB][0] + = ms_tmp[0] + * ms_asa_jys.at(TA).at(IA).at(TA).at(IA) + + ms_tmp[1] + * ms_asa_jys.at(TB).at(IB).at(TA).at(IA); + + ms_lcaos2_jys_proj_asa[TA][IA][TB][IB][1] + = ms_tmp[0] + * ms_asa_jys.at(TA).at(IA).at(TB).at(IB) + + ms_tmp[1] + * ms_asa_jys.at(TB).at(IB).at(TB).at(IB); + } + } + } + } + } + return ms_lcaos2_jys_proj_asa; +} + +/* +void cal_R_supercell() +{ + vector R_supercell; + for( size_t x=0; x!=kv.nmp[0]; ++x) + for( size_t y=0; y!=kv.nmp[1]; ++y ) + for( size_t z=0; z!=kv.nmp[2]; ++z ) + R_supercell.push_back(Vector3_Exx(x,y,z)); +} +*/ +/* +void density_matrix() +{ + vector DM_k(kv.nks); + for( size_t ik=0; ik!=kv.nks; ++ik ) + { + for( size_t ib=0; ib!=NBANDS; ++ib ) + { + for( size_t iw1=0; iw1!=NLOCAL; ++iw1 ) + { + for( size_t iw2=0; iw2!=NLOCAL; ++iw2 ) + { + DM_k[ik](iw1,iw2) += wf.wg(ik,ib) * conj(LOWF.WFC_K[ik][ib][iw1]) * LOWF.WFC_K[ik][ib][iw2]; + } + } + } + } + + vector> DM_R( NSPIN, vector(R_supercell.size()) ); + for( size_t is=0; is!=NSPIN; ++is ) + { + const size_t k_start = (NSPIN==1) ? 0 : ((is==0) ? 0 : (kv.nks/2)); + const size_t k_end = (NSPIN==1) ? kv.nks : ((is==0) ? (kv.nks/2) : kv.nks); + for( size_it iR=0; iR!=R_supercell.size(); ++iR ) + { + for( size_t ik=k_start; ik!=k_end; ++ik ) + { + DM_R[is][iR] += exp(TWO_PI*IMAG_UNIT*dot(kv.kvec_d[ik],R_supercell[iR])) * DM[ik]; + } + } + } +} +*/ \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs.h new file mode 100644 index 0000000000..113466195a --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs.h @@ -0,0 +1,76 @@ +#ifndef EXX_ABFS_H +#define EXX_ABFS_H + +#include +using std::vector; +#include +using std::map; +#include + +#include "src_lcao/numerical_orbital_lm.h" +#include "src_global/element_basis_index.h" +#include "src_global/matrix.h" +#include "src_global/vector3.h" + +class Exx_Abfs +{ +public: + + void test_all() const; + void generate_matrix() const; + void test_abfs1() const; + void test_abfs2() const; + void cal_exx() const; + + class Abfs_Index; + class Jle; + class Inverse_Matrix_Double; + class IO; + class Construct_Orbs; + class PCA; + class DM; + class Parallel; + class Screen + {public: + class Schwarz; + class Cauchy; + }; + + class Matrix_Orbs11; + class Matrix_Orbs21; + class Matrix_Orbs22; + + class Matrix_Lcaoslcaos_Lcaoslcaos; +// template< typename type_Orb22 > class Matrix_Lcaoslcaos_Lcaoslcaos2; // Peize Lin test + + int rmesh_times = 5; // Peize Lin test + int kmesh_times = 1; // Peize Lin test + static int Lmax; // Peize Lin test + +public: + + static map>>>>> cal_I( + const map>>> &ms, + const Element_Basis_Index::IndexLNM &index ); + + static map>>>> cal_C( + const map>>>> &matrix_A, + const map>>>>> &matrix_L ); + + void cal_CVC( + const map>>>> &matrix_C, + const map>>> &matrix_V ) const; + + static map>>> cal_lcaos2_lcaos2_proj_asa( + const map>>>> &ms_lcaos2_asa, + const map>>>>> &ms_asa_asa_I, + const Element_Basis_Index::Range &range, + const Element_Basis_Index::IndexLNM &index); + + static map>>>> cal_lcaos2_jys_proj_asa( + const map>>>> &ms_lcaos2_asa, + const map>>>>> &ms_asa_asa_I, + const map>>> &ms_asa_jys); +}; + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp new file mode 100644 index 0000000000..3f167f8109 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp @@ -0,0 +1,1569 @@ +#include "exx_lcao.h" + +#include "src_pw/global.h" +#include "src_global/global_function.h" + +#include "conv_coulomb_pot.h" +#include "conv_coulomb_pot-inl.h" +#include "conv_coulomb_pot_k.h" +#include "conv_coulomb_pot_k-template.h" + +#include "abfs-template.h" +#include "exx_abfs.h" +#include "exx_abfs-construct_orbs.h" +#include "exx_abfs-abfs_index.h" +#include "exx_abfs-screen-schwarz.h" +#include "exx_abfs-io.h" +#include "exx_abfs-io-template.h" +#include "exx_abfs-parallel.h" +#include "exx_abfs-parallel-distribute-htime.h" +#include "exx_abfs-parallel-distribute-kmeans.h" + +#include +#include + +// Peize Lin test +#include +#include +#include "src_external/src_test/src_global/element_basis_index-test.h" +#include "src_external/src_test/src_global/matrix-test.h" +#include "src_external/src_test/print_tmp.h" +#include "src_external/src_test/src_global/sph_bessel-unittest.h" +#include "src_external/src_test/src_lcao/exx_lcao-test.h" +#include "src_external/src_test/src_lcao/abfs-test.h" +#include "src_lcao/lcao_nnr.h" + +/* +// m_new( i2*n1+i1, i3 ) = m( i1*n2+i2, i3 ) +static matrix transform ( + const matrix & m, + const size_t n1, const size_t n2, const size_t n3 ) +{ + assert( n1*n2*n3 == m.nr*m.nc ); + const auto length = sizeof(double)*n3; + matrix m_new( n1*n2, n3, false ); + for( size_t i1=0; i1!=n1; ++i1 ) + { + for( size_t i2=0; i2!=n2; ++i2 ) + memcpy( m_new.c+(i2*n1+i1)*n3, m.c+(i1*n2+i2)*n3, length ); + } + return m_new; +} +*/ + + +// Peize Lin test +Exx_Lcao::Exx_Lcao( const Exx_Global::Exx_Info &info_global ) + :rmesh_times(10), + kmesh_times(4), + info(info_global) +{ + auto test_gemm = []() + { + auto init_matrix = [](const int nr, const int nc, const double add) -> matrix + { + matrix m(nr,nc); + for(int i=0; i matrix + { + matrix mT(m.nc,m.nr); + for(int ir=0; ir!=m.nr; ++ir) + for(int ic=0; ic!=m.nc; ++ic) + mT(ic,ir) = m(ir,ic); + return mT; + }; + auto print_matrix = [](const matrix &m1,const matrix &m2,const matrix &m3) + { + cout< & v ) + { + ofstream ofs(file); + for( size_t i=0; i!=v.size(); ++i ) + ofs<BvK_period( kv.nmp[0], kv.nmp[1], kv.nmp[2] ); + vector> boxes; + for( int x=0; x!=BvK_period.x; ++x ) + for( int y=0; y!=BvK_period.y; ++y ) + for( int z=0; z!=BvK_period.z; ++z ) + boxes.push_back({x,y,z}); + + cout<<"boxes:"<>(boxes[i])<<"\t"; + cout<>(boxes[i])) )<<"\t"; + cout< x = {1,2,3}; + cout<> y = { {1.1,2.2}, {3.3,-4.4}, {-5.5,-6.6} }; + cout< z = {1,2,3,4,5,6}; + cout<lcaos = Exx_Abfs::Construct_Orbs::change_orbs( ORB, this->kmesh_times ); +ofs_mpi<<"TIME@ Exx_Abfs::Construct_Orbs::change_orbs\t"<>> + abfs_same_atom = Exx_Abfs::Construct_Orbs::abfs_same_atom( lcaos, this->kmesh_times, info.pca_threshold ); // Peize Lin test +ofs_mpi<abfs = abfs_same_atom; + else + this->abfs = Exx_Abfs::IO::construct_abfs( abfs_same_atom, ORB, info.files_abfs, this->kmesh_times ); +// this->abfs = Exx_Abfs::Construct_Orbs::orth_orbs( abfs_origin ); // Peize Lin test +ofs_mpi<<"TIME@ Exx_Abfs::Construct_Orbs::abfs\t"<>> &orbs) + { + for(size_t N=0; N!=orbs[0][0].size(); ++N) + { + for(size_t ir=0; ir!=orbs[0][0][N].getNr(); ++ir) + cout<>> &orbs) + { + ofstream ofs(file_name); + for( size_t T=0; T!=orbs.size(); ++T ) + for( size_t L=0; L!=orbs[T].size(); ++L ) + for( size_t N=0; N!=orbs[T][L].size(); ++N ) + { +// ofs<rmesh_times, 1 ); +//{ +// ofstream ofs("exx_lcao"+TO_STRING(MY_RANK)); +// ofs<::type>(exx_lcao.info.hybrid_type)<abfs, Conv_Coulomb_Pot_K::Ccp_Type::Ccp, this->rmesh_times ); break; + case Exx_Global::Hybrid_Type::HSE: + abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp( this->abfs, Conv_Coulomb_Pot_K::Ccp_Type::Hse, this->rmesh_times, info.hse_omega ); break; + default: + throw domain_error(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; + } +ofs_mpi<<"TIME@ Conv_Coulomb_Pot_K::cal_orbs_ccp\t"<>> & orbs, + const int power ) + { + for( size_t i=0; i!=orbs.size(); ++i ) + for( size_t j=0; j!=orbs[i].size(); ++j ) + for( size_t k=0; k!=orbs[i][j].size(); ++k ) + { + const Numerical_Orbital_Lm & orb = orbs[i][j][k]; + ofstream ofs(file_name+"_"+TO_STRING(i)+"_"+TO_STRING(j)+"_"+TO_STRING(k)); + for( size_t ik=0; ik!=orb.getNk(); ++ik ) + ofs<(abfs[T].size())-1 ); + +ofs_mpi<<"Exx_Abfs::Lmax:\t"<kmesh_times, (1+this->rmesh_times)/2.0 ); +ofs_mpi<<"TIME@ m_abfs_abfs.init\t"<kmesh_times, 1 ); +ofs_mpi<<"TIME@ m_abfslcaos_lcaos.init\t"<{kv.nmp[0],kv.nmp[1],kv.nmp[2]}; +ofs_mpi<<"TIME@ Exx_Lcao::init\t"<kmesh_times, 1 ); + m_abfs_abfs.init_radial( abfs, abfs ); + m_abfs_abfs.init_radial_table(); + + Exx_Abfs::Matrix_Orbs21 m_abfslcaos_lcaos; + m_abfslcaos_lcaos.init( 1, this->kmesh_times, 1 ); + m_abfslcaos_lcaos.init_radial( abfs, lcaos, lcaos ); + m_abfslcaos_lcaos.init_radial_table(); + + map,weak_ptr>>> Cws; + map,weak_ptr>>> Vws; + shared_ptr C = Abfs::DPcal_C( + 0, + 0, + {0,0,0}, + m_abfs_abfs, + m_abfslcaos_lcaos, + index_abfs, + index_lcaos, + 0, + true, + Cws, + Vws); + cout<<*C<>> lcaos_ccp; + Conv_Coulomb_Pot::cal_orbs_ccp( lcaos, lcaos_ccp ); + Exx_Abfs::Matrix_Orbs11 m_lcaos_ccp; + m_lcaos_ccp.init(1,1,1); + m_lcaos_ccp.init_radial(lcaos,lcaos_ccp); + m_lcaos_ccp.init_radial_table(); + const matrix m_overlap_coulomb = m_lcaos_ccp.cal_overlap_matrix( 0,0, {0,0,0},{0,0,0}, index_lcaos,index_lcaos ); + + ofstream ofs("matrix_overlap.dat"); + ofs<> &atom_pairs_core) -> set + { + set atom_centres_core; + for( const pair & atom_pair : atom_pairs_core ) + { + atom_centres_core.insert(atom_pair.first); + atom_centres_core.insert(atom_pair.second); + } + return atom_centres_core; + }; + +gettimeofday( &t_start, NULL); + if(atom_pairs_core_origin.empty()) + switch(this->info.distribute_type) + { + case Exx_Lcao::Distribute_Type::Htime: + atom_pairs_core_origin = Exx_Abfs::Parallel::Distribute::Htime::distribute( Born_von_Karman_period ); break; + case Exx_Lcao::Distribute_Type::Kmeans: + atom_pairs_core_origin = Exx_Abfs::Parallel::Distribute::Kmeans::distribute( MPI_COMM_WORLD ); break; + default: + throw domain_error(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; + //throw domain_error(TO_STRING(static_cast::type>(info.distribute_type))+"\t"+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; + } +ofs_mpi<<"atom_pairs_core_origin\t"< atom_centres_core = cal_atom_centres_core(atom_pairs_core); + +gettimeofday( &t_start, NULL); + H_atom_pairs_core = Abfs::get_H_pairs_core( atom_pairs_core ); +ofs_mpi<<"H_atom_pairs_core\t"<DM_para.cal_DM( Born_von_Karman_period, H_atom_pairs_core, info.dm_threshold ); +ofs_mpi<<"TIME@ Exx_Lcao::cal_DM\t"<DM_para.cal_DM_k( Born_von_Karman_period, H_atom_pairs_core, info.dm_threshold ); +ofs_mpi<<"TIME@ Exx_Lcao::cal_DM\t"<,matrix>>>> HexxR = cal_Hexx(); +ofs_mpi<<"TIME@ Exx_Lcao::cal_Hexx\t"<energy = cal_energy(HexxR); +ofs_mpi<<"TIME@ Exx_Lcao::cal_energy\t"< & box2 : atom2.second ) + { + ofs<<"@\t"<,matrix>>>> HexxR; + Hexx_para.Rexx_to_Km2D( HexxR, {pot.start_pot=="file",chr.out_charge} ); +} + +/* +void Exx_Lcao::cal_Hexx_gamma( const set> &atom_pairs ) +{ + for( const pair & atom_pair : atom_pairs ) + { + const size_t iat1 = atom_pair.first; + const size_t iat2 = atom_pair.second; + const size_t it1 = ucell.iat2it[iat1]; + const size_t it2 = ucell.iat2it[iat2]; + + const vector adj1s = Abfs::get_adjs( ucell.atoms[it1].tau[ucell.iat2ia[iat2]] ); + const vector adj2s = Abfs::get_adjs( ucell.atoms[it2].tau[ucell.iat2ia[iat2]] ); + for( const Abfs::Atom_Info & atom3 : adj1s ) + { + const size_t iat3 = ucell.itia2iat( atom3.T, atom3.I ); + for( const Abfs::Atom_Info & atom4 : adj2s ) + { + const size_t iat4 = ucell.itia2iat( atom4.T, atom4.I ); + const matrix matrix_1342 = *Cs[iat1][iat3][atom3.box] * *Vps_gamma[iat1][iat2] * *Cs[iat2][iat4][atom4.box]; + + for( size_t iw1=0; iw1!=ucell.atoms[it1].nw; ++iw1 ) + for( size_t iw2=0; iw2!=ucell.atoms[it2].nw; ++iw2 ) + for( size_t iw3=0; iw3!=ucell.atoms[atom3.T].nw; ++iw3 ) + for( size_t iw4=0; iw4!=ucell.atoms[atom4.T].nw; ++iw4 ) + { + const double matrix_element_1342 = matrix_1342( iw1*ucell.atoms[atom3.T].nw+iw3, iw2*ucell.atoms[atom4.T].nw+iw4 ); + for( size_t is=0; is!=NSPIN; ++is ) + { + Hexx_gamma[iat1][iat2][is](iw1,iw2) = matrix_element_1342 * DM_Gamma[iat3][iat4][is](iw3,iw4); + Hexx_gamma[iat1][iat4][is](iw1,iw4) = matrix_element_1342 * DM_Gamma[iat3][iat2][is](iw3,iw2); + Hexx_gamma[iat3][iat2][is](iw3,iw2) = matrix_element_1342 * DM_Gamma[iat1][iat4][is](iw1,iw4); + Hexx_gamma[iat3][iat4][is](iw3,iw4) = matrix_element_1342 * DM_Gamma[iat1][iat2][is](iw1,iw2); + } + } + } + } + } +} +*/ + +double Exx_Lcao::cal_energy( + const vector,matrix>>>> &HexxR ) const +{ + TITLE("Exx_Lcao","cal_energy"); +ofstream ofs_mpi(test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; +gettimeofday( &t_start, NULL); + + double energy = 0; + for( size_t is=0; is!=NSPIN; ++is ) + { + for( const auto & HA : HexxR[is] ) + { + const size_t iat1 = HA.first; + for( const auto & HB : HA.second ) + { + const size_t iat2 = HB.first; + for( const auto & HC : HB.second ) + { + const Abfs::Vector3_Order & box2 = HC.first; + if( const matrix*const DMr_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat1, iat2, box2 )) ) + { + const matrix & H = HC.second; + assert(DMr_ptr->nr == H.nr); + assert(DMr_ptr->nc == H.nc); + energy += LapackConnector::dot( H.nr*H.nc, DMr_ptr->c,1, H.c,1 ); + } + } + } + } + } + energy *= 2.0/NSPIN; // ? + energy /= 2; // /2 for Ry + +ofs_mpi<<"TIME@ Exx_Lcao::cal_energy_cal\t"< &atom_centres_core, const vector> &atom_pairs_core ) +{ + TITLE("Exx_Lcao::init_radial_table_ions"); + +ofstream ofs_mpi(test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; + + map>> radial_R; + + auto print_atom = [&](ostream &os) + { + os<<"atom_centres_core:"<<"\t"; + for(const auto &a : atom_centres_core) + os< tau1 = ucell.atoms[it1].tau[ia1]; + + const map>> adjs = Abfs::get_adjs(iat1); + for( const auto & atom2 : adjs ) + { + const size_t iat2 = atom2.first; + const size_t it2 = ucell.iat2it[iat2]; + const size_t ia2 = ucell.iat2ia[iat2]; + const Vector3 &tau2 = ucell.atoms[it2].tau[ia2]; + for( const Abfs::Vector3_Order &box2 : atom2.second ) + { + const double delta_R = (-tau1+tau2+(box2*ucell.latvec)).norm(); +// const double delta_R = (-tau1+tau2).norm(); + + #if TEST_EXX_LCAO==1 + ofs_C<<-tau1+tau2+(box2*ucell.latvec)<<"\t"<=1 + m_abfslcaos_lcaos.init_radial_table(radial_R); +#else + m_abfslcaos_lcaos.init_radial_table(); +#endif +ofs_mpi<<"TIME@ m_abfslcaos_lcaos.init_radial_table\t"< & atom_pair : atom_pairs_core ) + { + const size_t iat1 = atom_pair.first; + const size_t iat2 = atom_pair.second; + const size_t it1 = ucell.iat2it[iat1]; + const size_t ia1 = ucell.iat2ia[iat1]; + const size_t it2 = ucell.iat2it[iat2]; + const size_t ia2 = ucell.iat2ia[iat2]; + const Vector3 &tau1 = ucell.atoms[it1].tau[ia1]; + const Vector3 &tau2 = ucell.atoms[it2].tau[ia2]; + + for( const Vector3 &box2 : Coulomb_potential_boxes ) + { + const double delta_R = (-tau1+tau2+(box2*ucell.latvec)).norm(); + + #if TEST_EXX_LCAO==1 + ofs_V<<-tau1+tau2+(box2*ucell.latvec)<<"\t"<=1 + m_abfs_abfs.init_radial_table(radial_R); +#else + m_abfs_abfs.init_radial_table(); +#endif +ofs_mpi<<"TIME@ m_abfs_abfs.init_radial_table\t"<,matrix>>>> Exx_Lcao::cal_Hexx() const +{ + const int mkl_threads = mkl_get_max_threads(); + mkl_set_num_threads(1); + + atomic i_atom_pair = 0; + atomic_flag Hexx_lock = ATOMIC_FLAG_INIT; + vector,matrix>>>> HexxR(NSPIN); + + vector ts; +// for( int it=0; it & i_atom_pair, + atomic_flag & Hexx_lock, + vector,matrix>>>> & HexxR) const +{ + // m_new( i2, i1, i3 ) = m( i1, i2, i3 ) + auto transform = []( + const matrix & m, + const size_t n1, const size_t n2, const size_t n3 ) -> matrix + { + assert( n1*n2*n3 == m.nr*m.nc ); + const auto length = sizeof(double)*n3; + const auto n13 = n1*n3; + const double *m_ptr = m.c; + matrix m_new( n1*n2, n3, false ); + for( size_t i1=0; i1!=n1; ++i1 ) + { + double *m_new_ptr = m_new.c+i1*n3; + for( size_t i2=0; i2!=n2; ++i2, m_ptr+=n3, m_new_ptr+=n13 ) + memcpy( m_new_ptr, m_ptr, length ); + } + return m_new; + }; + + // C = alpha * A.? * B.? + auto gemm = []( + const char transA, // A / A.T / A.C + const char transB, // B / B.T / B.C + const int M, // A.?.nr = C.nr + const int N, // B.?.nc = C.nc + const int K, // A.?.nc = B.?.nr + const double alpha, + const matrix & A, + const matrix & B) -> matrix + { + matrix C(M,N,false); + LapackConnector::gemm( + transA, transB, + M, N, K, + alpha, + A.c, (transA=='N')?K:M, + B.c, (transB=='N')?N:K, + 0, + C.c, N ); + return C; + }; + + // insert m_tmp into m_all + auto insert_matrixes = []( + vector,matrix>>>> & m_all, + vector,matrix>>>> & m_tmp) + { + for( size_t is=0; is!=NSPIN; ++is ) + { + for( auto & m_tmp1 : m_tmp[is] ) + { + const size_t iat1 = m_tmp1.first; + for( auto & m_tmp2 : m_tmp1.second ) + { + const size_t iat2 = m_tmp2.first; + for( auto & m_tmp3 : m_tmp2.second ) + { + const Abfs::Vector3_Order & box2 = m_tmp3.first; + if( matrix*const m_all_ptr = static_cast(MAP_EXIST( m_all[is], iat1, iat2, box2 )) ) + *m_all_ptr += m_tmp3.second; + else + m_all[is][iat1][iat2][box2] = std::move(m_tmp3.second); + } + } + } + m_tmp[is].clear(); + } + }; + + auto vector_empty = []( const vector,matrix>>>> & v ) -> bool + { + for( const auto &i : v ) + if(!i.empty()) return false; + return true; + }; + +ofstream ofs_thread(test_dir.thread+"thread_"+TO_STRING(MY_RANK)+"_"+TO_STRING(std::this_thread::get_id())); + + TITLE("Exx_Lcao","cal_Hexx_thread"); + +timeval t_start, t_start_all; +gettimeofday( &t_start_all, NULL); + + vector,matrix>>>> HexxR_tmp(NSPIN); + + while(true) + { + const size_t i_atom_pair_now = i_atom_pair++; + if( i_atom_pair_now >= atom_pairs_core.size() ) + { + if(!vector_empty(HexxR_tmp)) + { + while( Hexx_lock.test_and_set() ); + insert_matrixes(HexxR,HexxR_tmp); + Hexx_lock.clear(); + } +ofs_thread<<"TIME@ Exx_Lcao::cal_Hexx_thread\t"< & box3 = Cp1.first; + const auto & Cp13 = Cp1.second; + + for( const auto & Cp2 : Cp2s.second ) + { + const Abfs::Vector3_Order & box4 = Cp2.first; + const auto & Cp24 = Cp2.second; + + if( schwarz.screen( iat1,iat2,iat3,iat4, box3,box4 ) ) continue; + + for( const auto &Vp : Vps.at(iat1).at(iat2) ) + { + const Abfs::Vector3_Order & box2 = Vp.first; + + const matrix & C_13 = *Cp13, // iw1*iw3, \mu1 + & V = *Vp.second, // \mu1, \mu2 + & C_24 = *Cp24; // iw2*iw4, \mu2 + + const Exx_Abfs::Screen::Cauchy::Info_Step info_step = cauchy.input_info( iat1, iat2, iat3, iat4, box2, box3, box4 ); + int cauchy_postcal; + if(!( cauchy_postcal = cauchy.postcalA( info_step ) )) continue; + +// assert( V.nc==C_24.nc ); + const matrix VC_24 = gemm( // \mu1, iw2*iw4 + 'N', 'T', + index_abfs[it1].count_size, + index_lcaos[it2].count_size * index_lcaos[it4].count_size, + index_abfs[it2].count_size, + 1, V, C_24 ); + const matrix VC_24_T = transform( VC_24, // iw2*\mu1, iw4 + index_abfs[it1].count_size, + index_lcaos[it2].count_size, + index_lcaos[it4].count_size ); + if(!( cauchy_postcal = cauchy.postcalB( info_step, VC_24_T, index_lcaos[it2].count_size, index_abfs[it1].count_size, index_lcaos[it4].count_size, cauchy_postcal ) )) continue; + + const matrix C_13_T = transform( C_13, // iw3*iw1, \mu1 + index_lcaos[it1].count_size, + index_lcaos[it3].count_size, + index_abfs[it1].count_size ); + + for( size_t is=0; is!=NSPIN; ++is ) + { + switch( cauchy_postcal ) // Attention: case and go on calculating + { + case 4: + { + const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat3, iat4, Abfs::Vector3_Order(box2-box3+box4)%Born_von_Karman_period )); + if( DM_ptr ) + { + const matrix DVC_32 = gemm( // iw3, \mu1*iw2 + 'N', 'T', + index_lcaos[it3].count_size, + index_abfs[it1].count_size * index_lcaos[it2].count_size, + index_lcaos[it4].count_size, + 1, + *DM_ptr, + VC_24 ); + if( cauchy.postcalC( info_step, DVC_32, index_lcaos[it3].count_size, index_abfs[it1].count_size, index_lcaos[it2].count_size, 1 ) ) + { + const matrix Hexx_12 = gemm( // iw1, iw2 + 'N', 'N', + index_lcaos[it1].count_size, + index_lcaos[it2].count_size, + index_lcaos[it3].count_size * index_abfs[it1].count_size, + -2, C_13, DVC_32 ); + if( cauchy.postcalD( Hexx_12 ) ) + { + if(iat1!=iat2) + { + const matrix Hexx_21 = transpose(Hexx_12); + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat2, iat1, Abfs::Vector3_Order(-box2)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_21; + else + HexxR_tmp[is][iat2][iat1][Abfs::Vector3_Order(-box2)%Born_von_Karman_period] = std::move(Hexx_21); + } + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat1, iat2, Abfs::Vector3_Order(box2)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_12; + else + HexxR_tmp[is][iat1][iat2][Abfs::Vector3_Order(box2)%Born_von_Karman_period] = std::move(Hexx_12); + } + } + } + } // end case 4 + case 3: + { + if( const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat1, iat4, Abfs::Vector3_Order(box2+box4)%Born_von_Karman_period )) ) + { + const matrix DVC_12 = gemm( // iw1, \mu1*iw2 + 'N', 'T', + index_lcaos[it1].count_size, + index_abfs[it1].count_size * index_lcaos[it2].count_size, + index_lcaos[it4].count_size, + 1, + *DM_ptr, + VC_24 ); + if( cauchy.postcalC( info_step, DVC_12, index_lcaos[it1].count_size, index_abfs[it1].count_size, index_lcaos[it2].count_size, 3 ) ) + { + const matrix Hexx_32 = gemm( // iw3, iw2 + 'N', 'N', + index_lcaos[it3].count_size, + index_lcaos[it2].count_size, + index_lcaos[it1].count_size * index_abfs[it1].count_size, + -2, C_13_T, DVC_12 ); + if( cauchy.postcalD( Hexx_32 ) ) + { + if(iat1!=iat2) + { + const matrix Hexx_23 = transpose(Hexx_32); + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat2, iat3, Abfs::Vector3_Order(-box2+box3)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_23; + else + HexxR_tmp[is][iat2][iat3][Abfs::Vector3_Order(-box2+box3)%Born_von_Karman_period] = std::move(Hexx_23); + } + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat3, iat2, Abfs::Vector3_Order(box2-box3)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_32; + else + HexxR_tmp[is][iat3][iat2][Abfs::Vector3_Order(box2-box3)%Born_von_Karman_period] = std::move(Hexx_32); + } + } + } + } // end case 3 + case 2: + { + if( const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat3, iat2, Abfs::Vector3_Order(box2-box3)%Born_von_Karman_period )) ) + { + const matrix DVC_34 = gemm( // iw3, \mu1*iw4 + 'N', 'N', + index_lcaos[it3].count_size, + index_abfs[it1].count_size * index_lcaos[it4].count_size, + index_lcaos[it2].count_size, + 1, + *DM_ptr, + VC_24_T ); + if( cauchy.postcalC( info_step, DVC_34, index_lcaos[it3].count_size, index_abfs[it1].count_size, index_lcaos[it4].count_size, 1 ) ) + { + const matrix Hexx_14 = gemm( // iw1, iw4 + 'N', 'N', + index_lcaos[it1].count_size, + index_lcaos[it4].count_size, + index_lcaos[it3].count_size * index_abfs[it1].count_size, + -2, C_13, DVC_34 ); + if( cauchy.postcalD( Hexx_14 ) ) + { + if(iat1!=iat2) + { + const matrix Hexx_41 = transpose(Hexx_14); + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat4, iat1, Abfs::Vector3_Order(-box2-box4)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_41; + else + HexxR_tmp[is][iat4][iat1][Abfs::Vector3_Order(-box2-box4)%Born_von_Karman_period] = std::move(Hexx_41); + } + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat1, iat4, Abfs::Vector3_Order(box2+box4)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_14; + else + HexxR_tmp[is][iat1][iat4][Abfs::Vector3_Order(box2+box4)%Born_von_Karman_period] = std::move(Hexx_14); + } + } + } + } // end case 2 + case 1: + { + if( const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat1, iat2, Abfs::Vector3_Order(box2)%Born_von_Karman_period )) ) + { + const matrix DVC_14 = gemm( // iw1, \mu1*iw4 + 'N', 'N', + index_lcaos[it1].count_size, + index_abfs[it1].count_size * index_lcaos[it4].count_size, + index_lcaos[it2].count_size, + 1, + *DM_ptr, + VC_24_T ); + if( cauchy.postcalC( info_step, DVC_14, index_lcaos[it1].count_size, index_abfs[it1].count_size, index_lcaos[it4].count_size, 3 ) ) + { + const matrix Hexx_34 = gemm( // iw3, iw4 + 'N', 'N', + index_lcaos[it3].count_size, + index_lcaos[it4].count_size, + index_lcaos[it1].count_size * index_abfs[it1].count_size, + -2, C_13_T, DVC_14 ); + if( cauchy.postcalD( Hexx_34 ) ) + { + if(iat1!=iat2) + { + const matrix Hexx_43 = transpose(Hexx_34); + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat4, iat3, Abfs::Vector3_Order(-box2+box3-box4)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_43; + else + HexxR_tmp[is][iat4][iat3][Abfs::Vector3_Order(-box2+box3-box4)%Born_von_Karman_period] = std::move(Hexx_43); + } + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat3, iat4, Abfs::Vector3_Order(box2-box3+box4)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_34; + else + HexxR_tmp[is][iat3][iat4][Abfs::Vector3_Order(box2-box3+box4)%Born_von_Karman_period] = std::move(Hexx_34); + } + } + } + } // end case 1 + case 0: ; + } // end switch cauchy_postcal + } // end for is + } // end for box2 + } // end for box4 + } // end for box3 + + if( !vector_empty(HexxR_tmp) && !Hexx_lock.test_and_set() ) + { + insert_matrixes(HexxR,HexxR_tmp); + Hexx_lock.clear(); + } + } // end for iat4 + } // end for iat3 + } // end if i_atom_pair_now < atom_pairs_core.size() + } // end while(true) +} diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.h b/ABACUS.1.0.0/source/src_lcao/exx_lcao.h new file mode 100644 index 0000000000..c12e16cc93 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.h @@ -0,0 +1,118 @@ +#ifndef EXX_LCAO_H +#define EXX_LCAO_H + +#include "src_lcao/abfs.h" +#include "src_lcao/abfs-vector3_order.h" +#include "src_lcao/exx_abfs-matrix_orbs11.h" +#include "src_lcao/exx_abfs-matrix_orbs21.h" +#include "src_lcao/exx_abfs-dm.h" +#include "src_lcao/exx_abfs-parallel-communicate-hexx.h" +#include "src_lcao/exx_abfs-parallel-communicate-dm.h" +#include "src_lcao/exx_abfs-parallel-communicate-dm2.h" +#include "src_lcao/exx_abfs-screen-schwarz.h" +#include "src_lcao/exx_abfs-screen-cauchy.h" +#include "src_global/element_basis_index.h" +#include "src_pw/functional.h" +#include "src_pw/exx_global.h" + +#include +#include +#include +#include +#include +#include +#include + +class Exx_Lcao +{ +public: + struct{ string process; string thread; string matrix; } test_dir; // Peize Lin test + Exx_Lcao( const Exx_Global::Exx_Info &info_global ); // Peize Lin test +public: + void init(); + void cal_exx_ions(); + void cal_exx_elec(); + void cal_exx_elec_nscf(); + void add_Hexx(const size_t ik, const double alpha) const; +private: + vector,matrix>>>> cal_Hexx() const; + void cal_Hexx_thread( + atomic & i_atom_pair, + atomic_flag & Hexx_lock, + vector,matrix>>>> & HexxR) const; + double cal_energy( + const vector,matrix>>>> &HexxR ) const; + void init_radial_table_ions( const set &atom_centres_core, const vector> &atom_pairs_core ); + +public: + enum class Distribute_Type {Htime,Kmeans}; + +public: + double get_energy() const { return energy; } + +private: + + int rmesh_times = 1; // Peize Lin test + int kmesh_times = 4; // Peize Lin test + +#if EXX_DM==1 + Exx_Abfs::Parallel::Communicate::DM DM_para; +#elif EXX_DM==2 + Exx_Abfs::Parallel::Communicate::DM2 DM_para; +#endif + Exx_Abfs::Parallel::Communicate::Hexx Hexx_para; + double energy = 0.0; + + vector>> lcaos; + vector>> abfs; + vector>> abfs_ccp; + Element_Basis_Index::IndexLNM index_lcaos; + Element_Basis_Index::IndexLNM index_abfs; + + Exx_Abfs::Matrix_Orbs11 m_abfs_abfs; + Exx_Abfs::Matrix_Orbs21 m_abfslcaos_lcaos; + + map,weak_ptr>>> Cws; // Cws[it1][it2][R] + map,weak_ptr>>> Vws; // Vws[it1][it2][R] + map,shared_ptr>>> Cs; // Cs[iat1][iat2][box2] + map,shared_ptr>>> Cps; // Cs[iat1][iat2][box2] + map,shared_ptr>>> Vs; // Vs[iat1][iat2][box2] + map,shared_ptr>>> Vps; // Vps[iat1][iat2][box2] + + vector> atom_pairs_core_origin; + vector> atom_pairs_core; + set> H_atom_pairs_core; + vector> Coulomb_potential_boxes; + Abfs::Vector3_Order Born_von_Karman_period; + + Exx_Abfs::Screen::Schwarz schwarz; + Exx_Abfs::Screen::Cauchy cauchy; + +public: + struct Exx_Info + { + const Exx_Global::Hybrid_Type &hybrid_type; + + const double &hse_omega; + + double pca_threshold = 0; + vector files_abfs; + double c_threshold = 0; + double v_threshold = 0; + double dm_threshold = 0; + double schwarz_threshold = 0; + double cauchy_threshold = 0; + + Exx_Lcao::Distribute_Type distribute_type; + + Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode H_mixing_mode; + double H_mixing_beta; + + Exx_Info( const Exx_Global::Exx_Info &info_global ); + }; + Exx_Info info; + + friend class Local_Orbital_Charge; +}; + +#endif // EXX_LCAO_H \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_opt_orb-print.cpp b/ABACUS.1.0.0/source/src_lcao/exx_opt_orb-print.cpp new file mode 100644 index 0000000000..b64b14b3a2 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_opt_orb-print.cpp @@ -0,0 +1,204 @@ +#include "exx_opt_orb.h" +#include "src_pw/global.h" +#include "src_lcao/exx_abfs-jle.h" + +void Exx_Opt_Orb::print_matrix( + const string &file_name, + const vector &matrix_Q, + const vector> &matrix_S, + const matrix &matrix_V, + const size_t TA, const size_t IA, const size_t TB, const size_t IB, + const Element_Basis_Index::Range &range_jles, + const Element_Basis_Index::IndexLNM &index_jles) const +{ + auto print_header = [&]( ofstream &ofs ) + { + ofs << ucell.lat0 << endl; + + ofs << ucell.latvec.e11 << " " << ucell.latvec.e12 << " " << ucell.latvec.e13 << endl; + ofs << ucell.latvec.e21 << " " << ucell.latvec.e22 << " " << ucell.latvec.e23 << endl; + ofs << ucell.latvec.e31 << " " << ucell.latvec.e32 << " " << ucell.latvec.e33 << endl; + + if( TA==TB ) + { + ofs << 1 << " ntype" << endl; + ofs << ucell.atoms[TA].label << " label" << endl; + if( IA==IB ) + { + ofs << 1 << " na" << endl; + ofs << ucell.atoms[TA].tau[IA].x << " " + << ucell.atoms[TA].tau[IA].y << " " + << ucell.atoms[TA].tau[IA].z << endl; + } + else + { + ofs << 2 << " na" << endl; + ofs << ucell.atoms[TA].tau[IA].x << " " + << ucell.atoms[TA].tau[IA].y << " " + << ucell.atoms[TA].tau[IA].z << endl; + ofs << ucell.atoms[TB].tau[IB].x << " " + << ucell.atoms[TB].tau[IB].y << " " + << ucell.atoms[TB].tau[IB].z << endl; + } + } + else + { + ofs << 2 << " ntype" << endl; + ofs << ucell.atoms[TA].label << " label" << endl; + ofs << 1 << " na" << endl; + ofs << ucell.atoms[TA].tau[IA].x << " " + << ucell.atoms[TA].tau[IA].y << " " + << ucell.atoms[TA].tau[IA].z << endl; + ofs << ucell.atoms[TB].label << " label" << endl; + ofs << 1 << " na" << endl; + ofs << ucell.atoms[TB].tau[IB].x << " " + << ucell.atoms[TB].tau[IB].y << " " + << ucell.atoms[TB].tau[IB].z << endl; + } + + // ecutwfc_jlq determine the jlq corresponding to plane wave calculation. + ofs << Exx_Abfs::Jle::Ecut_exx << " ecutwfc" << endl; // mohan add 2009-09-08 + + // this parameter determine the total number of jlq. + ofs << Exx_Abfs::Jle::Ecut_exx << " ecutwfc_jlq" << endl;//mohan modify 2009-09-08 + + if(TA==TB) + ofs << ORB.Phi[TA].getRcut() << " rcut_Jlq" << endl; + else + ofs << ORB.Phi[TA].getRcut() << " " << ORB.Phi[TB].getRcut() << " rcut_Jlq" << endl; + + // mohan add 'smooth' and 'sigma' 2009-08-28 + ofs << 0 << " smooth" << endl; + ofs << 0 << " sigma" << endl; + + ofs << Exx_Abfs::Jle::tolerence << " tolerence" << endl; + + ofs << Exx_Abfs::Jle::Lmax << " lmax" << endl; + + ofs << kv.nkstot << " nks" << endl; + assert( matrix_V.nr == matrix_V.nc ); + ofs << matrix_V.nr << " nbands" << endl; + + auto cal_sum_M = [&range_jles](size_t T) -> size_t + { + size_t sum_M = 0; + for( size_t L = 0; L!=range_jles[T].size(); ++L ) + sum_M += range_jles[T][L].M; + return sum_M; + }; + const size_t nwfc = (TA==TB && IA==IB) ? cal_sum_M(TA) : cal_sum_M(TA)+cal_sum_M(TB); + ofs << nwfc << " nwfc" << endl; + + const size_t ecut_numberA = static_cast( sqrt( Exx_Abfs::Jle::Ecut_exx ) * ORB.Phi[TA].getRcut() / PI ); // Rydberg Unit + const size_t ecut_numberB = static_cast( sqrt( Exx_Abfs::Jle::Ecut_exx ) * ORB.Phi[TB].getRcut() / PI ); // Rydberg Unit + if(TA==TB) + ofs << ecut_numberA << " ne" << endl; + else + ofs << ecut_numberA << " " << ecut_numberB << " ne" << endl; + + ofs << "" << endl; + for( int ik=0; ik!=kv.nkstot; ++ik ) + { + ofs << kv.kvec_c[ik].x << " " << kv.kvec_c[ik].y << " " << kv.kvec_c[ik].z; + ofs << " " << kv.wk[ik] * 0.5 << endl; + } + ofs << "" << endl; + + ofs << endl; + }; + + + auto print_Q = [&]( ofstream &ofs ) + { + //--------------------- + // < Psi | jY > + //--------------------- + ofs<< "" << std::endl; + + for( size_t ib=0; ib!=matrix_V.nr; ++ib ) + { + for( size_t iat=0; iat!=matrix_Q.size(); ++iat ) + { + const size_t it = (iat==0) ? TA : TB; + for( size_t il=0; il!=range_jles[it].size(); ++il ) + { + for( size_t im=0; im!=range_jles[it][il].M; ++im ) + { + for( size_t iq=0; iq!=range_jles[it][il].N; ++iq ) + { + ofs<" << std::endl << std::endl; + }; + + + auto print_S = [&]( ofstream &ofs, const double scale=1 ) + { + //--------------------- + // < jY | jY > + //--------------------- + ofs<< "" <" << std::endl << std::endl; + }; + + + auto print_V = [&]( ofstream &ofs, const double scale=1 ) + { + //--------------------- + // < Psi | Psi > + //--------------------- + ofs << "" << std::endl; + + for( size_t ib1=0; ib1!=matrix_V.nr; ++ib1 ) + { + for( size_t ib2=0; ib2!=matrix_V.nc; ++ib2 ) + { + ofs<" << std::endl << std::endl; + }; + + ofstream ofs(file_name+"_"+TO_STRING(TA)+"_"+TO_STRING(IA)+"_"+TO_STRING(TB)+"_"+TO_STRING(IB)); + print_header(ofs); + print_Q(ofs); + print_S(ofs); + print_V(ofs); + ofs.close(); +} \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_opt_orb.cpp b/ABACUS.1.0.0/source/src_lcao/exx_opt_orb.cpp new file mode 100644 index 0000000000..47243f0832 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_opt_orb.cpp @@ -0,0 +1,349 @@ +#include "exx_opt_orb.h" +#include "src_pw/global.h" +#include "src_lcao/numerical_orbital_lm.h" +#include "src_lcao/exx_abfs.h" +#include "src_lcao/exx_abfs-abfs_index.h" +#include "src_lcao/exx_abfs-construct_orbs.h" +#include "src_lcao/exx_abfs-inverse_matrix_double.h" +#include "src_lcao/exx_abfs-jle.h" +#include "src_lcao/lcao_orbitals.h" +#include "src_lcao/exx_abfs-matrix_orbs11.h" +#include "src_lcao/exx_abfs-matrix_orbs21.h" +#include "src_lcao/exx_abfs-matrix_orbs22.h" + +#include "src_external/src_test/src_lcao/exx_abfs-unittest.h" +#include "src_external/src_test/src_lcao/exx_lcao-test.h" +#include "src_external/src_test/src_global/element_basis_index-test.h" + +void Exx_Opt_Orb::generate_matrix() const +{ + TITLE("Exx_Opt_Orb::generate_matrix"); + + const vector>> lcaos = Exx_Abfs::Construct_Orbs::change_orbs( ORB, this->kmesh_times ); + + const vector>> abfs = Exx_Abfs::Construct_Orbs::abfs_same_atom( lcaos, this->kmesh_times, exx_lcao.info.pca_threshold ); + + Exx_Abfs::Jle jle; + jle.init_jle( this->kmesh_times ); + + Exx_Abfs::Lmax = Exx_Abfs::Jle::Lmax; + for( size_t T=0; T!=abfs.size(); ++T ) + Exx_Abfs::Lmax = std::max( Exx_Abfs::Lmax, static_cast(abfs[T].size())-1 ); + + const Element_Basis_Index::Range range_lcaos = Exx_Abfs::Abfs_Index::construct_range( lcaos ); + const Element_Basis_Index::IndexLNM index_lcaos = Element_Basis_Index::construct_index( range_lcaos ); + + const Element_Basis_Index::Range range_abfs = Exx_Abfs::Abfs_Index::construct_range( abfs ); + const Element_Basis_Index::IndexLNM index_abfs = Element_Basis_Index::construct_index( range_abfs ); + + const Element_Basis_Index::Range range_jys = Exx_Abfs::Abfs_Index::construct_range( jle.jle ); + const Element_Basis_Index::IndexLNM index_jys = Element_Basis_Index::construct_index( range_jys ); + +cout<>> radial_R = get_radial_R(); +#if TEST_EXX_RADIAL==2 + { + for(const auto & rA : radial_R) + for(const auto & rB : rA.second) + { + cout<kmesh_times, 1 ); + m_lcaoslcaos_lcaoslcaos.init_radial( lcaos, lcaos, lcaos, lcaos ); +#if TEST_EXX_RADIAL>=1 + m_lcaoslcaos_lcaoslcaos.init_radial_table(radial_R); +#else + m_lcaoslcaos_lcaoslcaos.init_radial_table(); +#endif + + Exx_Abfs::Matrix_Orbs21 m_jyslcaos_lcaos; + m_jyslcaos_lcaos.init( 1, this->kmesh_times, 1 ); + m_jyslcaos_lcaos.init_radial( jle.jle, lcaos, lcaos ); +#if TEST_EXX_RADIAL>=1 + m_jyslcaos_lcaos.init_radial_table(radial_R); +#else + m_jyslcaos_lcaos.init_radial_table(); +#endif + + Exx_Abfs::Matrix_Orbs11 m_jys_jys; + m_jys_jys.init( 2, this->kmesh_times, 1 ); + m_jys_jys.init_radial( jle.jle, jle.jle ); +#if TEST_EXX_RADIAL>=1 + m_jys_jys.init_radial_table(radial_R); +#else + m_jys_jys.init_radial_table(); +#endif + + Exx_Abfs::Matrix_Orbs11 m_abfs_abfs; + m_abfs_abfs.init( 2, this->kmesh_times, 1 ); + m_abfs_abfs.init_radial( abfs, abfs ); +#if TEST_EXX_RADIAL>=1 + m_abfs_abfs.init_radial_table(radial_R); +#else + m_abfs_abfs.init_radial_table(radial_R); +#endif + + Exx_Abfs::Matrix_Orbs21 m_abfslcaos_lcaos; + m_abfslcaos_lcaos.init( 1, this->kmesh_times, 1 ); + m_abfslcaos_lcaos.init_radial( abfs, lcaos, lcaos ); +#if TEST_EXX_RADIAL>=1 + m_abfslcaos_lcaos.init_radial_table(radial_R); +#else + m_abfslcaos_lcaos.init_radial_table(); +#endif + + Exx_Abfs::Matrix_Orbs11 m_jys_abfs; + m_jys_abfs.init( 2, this->kmesh_times, 1 ); + m_jys_abfs.init_radial( jle.jle, abfs ); +#if TEST_EXX_RADIAL>=1 + m_jys_abfs.init_radial_table(radial_R); +#else + m_jys_abfs.init_radial_table(); +#endif + + // < lcaos lcaos | lcaos lcaos > + const map>>> + ms_lcaoslcaos_lcaoslcaos = m_lcaoslcaos_lcaoslcaos.cal_overlap_matrix( index_lcaos, index_lcaos, index_lcaos, index_lcaos); + + // < lcaos lcaos | jys > + const map>>>> + ms_lcaoslcaos_jys = m_jyslcaos_lcaos.cal_overlap_matrix( index_jys, index_lcaos, index_lcaos ); + + // < jys | jys > + const map>>> + ms_jys_jys = m_jys_jys.cal_overlap_matrix( index_jys, index_jys ); + + // < abfs | abfs > + const map>>> + ms_abfs_abfs = m_abfs_abfs.cal_overlap_matrix( index_abfs, index_abfs ); + + // < lcaos lcaos | abfs > + const map>>>> + ms_lcaoslcaos_abfs = m_abfslcaos_lcaos.cal_overlap_matrix( index_abfs, index_lcaos, index_lcaos ); + + // < jys | abfs > + const map>>> + ms_jys_abfs = m_jys_abfs.cal_overlap_matrix( index_jys, index_abfs ); + +ofs_matrixes(exx_lcao.test_dir.matrix+"ms_jys_jys",ms_jys_jys); +ofs_matrixes(exx_lcao.test_dir.matrix+"ms_lcaoslcaos_jys",ms_lcaoslcaos_jys); +ofs_matrixes(exx_lcao.test_dir.matrix+"ms_lcaoslcaos_lcaoslcaos",ms_lcaoslcaos_lcaoslcaos); +ofs_matrixes(exx_lcao.test_dir.matrix+"ms_abfs_abfs",ms_abfs_abfs); +ofs_matrixes(exx_lcao.test_dir.matrix+"ms_lcaoslcaos_abfs",ms_lcaoslcaos_abfs); +ofs_matrixes(exx_lcao.test_dir.matrix+"ms_jys_abfs",ms_jys_abfs); + + for( size_t TA=0; TA!=ucell.ntype; ++TA ) + { + for( size_t IA=0; IA!=ucell.atoms[TA].na; ++IA ) + { + for( size_t TB=0; TB!=ucell.ntype; ++TB ) + { + for( size_t IB=0; IB!=ucell.atoms[TB].na; ++IB ) + { + if( TA==TB && IA==IB ) + { + const size_t T=TA, I=IA; + if(exx_lcao.info.pca_threshold<=1) + { + // < abfs | abfs >.I + const vector> ms_abfs_abfs_I = cal_I( ms_abfs_abfs, T,I,T,I ); + // < lcaos lcaos | lcaos lcaos > - < lcaos lcaos | abfs > * < abfs | abfs >.I * < abfs | lcaos lcaos > + const matrix m_lcaoslcaos_lcaoslcaos_proj = + cal_proj( + ms_lcaoslcaos_lcaoslcaos.at(T).at(I).at(T).at(I), + ms_lcaoslcaos_abfs.at(T).at(I).at(T).at(I), + ms_abfs_abfs_I, + ms_lcaoslcaos_abfs.at(T).at(I).at(T).at(I)); + // < lcaos lcaos | jys > - < lcaos lcaos | abfs > * < abfs | abfs >.I * < abfs | jys > + const vector m_lcaoslcaos_jys_proj = + {cal_proj( + ms_lcaoslcaos_jys.at(T).at(I).at(T).at(I)[0], + ms_lcaoslcaos_abfs.at(T).at(I).at(T).at(I), + ms_abfs_abfs_I, + {ms_jys_abfs.at(T).at(I).at(T).at(I)})}; + // < jys | jys > - < jys | abfs > * < abfs | abfs >.I * < abfs | jys > + const vector> m_jys_jys_proj = + {{cal_proj( + ms_jys_jys.at(T).at(I).at(T).at(I), + {ms_jys_abfs.at(T).at(I).at(T).at(I)}, + ms_abfs_abfs_I, + {ms_jys_abfs.at(T).at(I).at(T).at(I)})}}; + print_matrix( + "matrix", + m_lcaoslcaos_jys_proj, + m_jys_jys_proj, + m_lcaoslcaos_lcaoslcaos_proj, + TA, IA, TB, IB, + range_jys, index_jys ); + } + else + { + print_matrix( + "matrix", + ms_lcaoslcaos_jys.at(T).at(I).at(T).at(I), + {{ms_jys_jys.at(T).at(I).at(T).at(I)}}, + ms_lcaoslcaos_lcaoslcaos.at(T).at(I).at(T).at(I), + TA, IA, TB, IB, + range_jys, index_jys ); + } + } + else + { + if(exx_lcao.info.pca_threshold<=1) + { + // < abfs | abfs >.I + const vector> ms_abfs_abfs_I = cal_I( ms_abfs_abfs, TA,IA,TB,IB ); + // < lcaos lcaos | lcaos lcaos > - < lcaos lcaos | abfs > * < abfs | abfs >.I * < abfs | lcaos lcaos > + const matrix m_lcaoslcaos_lcaoslcaos_proj = + cal_proj( + ms_lcaoslcaos_lcaoslcaos.at(TA).at(IA).at(TB).at(IB), + ms_lcaoslcaos_abfs.at(TA).at(IA).at(TB).at(IB), + ms_abfs_abfs_I, + ms_lcaoslcaos_abfs.at(TA).at(IA).at(TB).at(IB)); + // < lcaos lcaos | jys > - < lcaos lcaos | abfs > * < abfs | abfs >.I * < abfs | jys > + const vector m_lcaoslcaos_jys_proj = + {cal_proj( + ms_lcaoslcaos_jys.at(TA).at(IA).at(TB).at(IB)[0], + ms_lcaoslcaos_abfs.at(TA).at(IA).at(TB).at(IB), + ms_abfs_abfs_I, + { ms_jys_abfs.at(TA).at(IA).at(TA).at(IA), ms_jys_abfs.at(TA).at(IA).at(TB).at(IB) }), + cal_proj( + ms_lcaoslcaos_jys.at(TA).at(IA).at(TB).at(IB)[1], + ms_lcaoslcaos_abfs.at(TA).at(IA).at(TB).at(IB), + ms_abfs_abfs_I, + { ms_jys_abfs.at(TB).at(IB).at(TA).at(IA), ms_jys_abfs.at(TB).at(IB).at(TB).at(IB) })}; + // < jys | jys > - < jys | abfs > * < abfs | abfs >.I * < abfs | jys > + const vector> m_jys_jys_proj = + {{cal_proj( + ms_jys_jys.at(TA).at(IA).at(TA).at(IA), + { ms_jys_abfs.at(TA).at(IA).at(TA).at(IA), ms_jys_abfs.at(TA).at(IA).at(TB).at(IB) }, + ms_abfs_abfs_I, + { ms_jys_abfs.at(TA).at(IA).at(TA).at(IA), ms_jys_abfs.at(TA).at(IA).at(TB).at(IB) }), + cal_proj( + ms_jys_jys.at(TA).at(IA).at(TB).at(IB), + { ms_jys_abfs.at(TA).at(IA).at(TA).at(IA), ms_jys_abfs.at(TA).at(IA).at(TB).at(IB) }, + ms_abfs_abfs_I, + { ms_jys_abfs.at(TB).at(IB).at(TA).at(IA), ms_jys_abfs.at(TB).at(IB).at(TB).at(IB) }) }, + {cal_proj( + ms_jys_jys.at(TB).at(IB).at(TA).at(IA), + { ms_jys_abfs.at(TB).at(IB).at(TA).at(IA), ms_jys_abfs.at(TB).at(IB).at(TB).at(IB) }, + ms_abfs_abfs_I, + { ms_jys_abfs.at(TA).at(IA).at(TA).at(IA), ms_jys_abfs.at(TA).at(IA).at(TB).at(IB) }), + cal_proj( + ms_jys_jys.at(TB).at(IB).at(TB).at(IB), + { ms_jys_abfs.at(TB).at(IB).at(TA).at(IA), ms_jys_abfs.at(TB).at(IB).at(TB).at(IB) }, + ms_abfs_abfs_I, + { ms_jys_abfs.at(TB).at(IB).at(TA).at(IA), ms_jys_abfs.at(TB).at(IB).at(TB).at(IB) }) }}; + print_matrix( + "matrix", + m_lcaoslcaos_jys_proj, + m_jys_jys_proj, + m_lcaoslcaos_lcaoslcaos_proj, + TA, IA, TB, IB, + range_jys, index_jys ); + } + else + { + print_matrix( + "matrix", + ms_lcaoslcaos_jys.at(TA).at(IA).at(TB).at(IB), + {{ms_jys_jys.at(TA).at(IA).at(TA).at(IA), ms_jys_jys.at(TA).at(IA).at(TB).at(IB)}, + {ms_jys_jys.at(TB).at(IB).at(TA).at(IA), ms_jys_jys.at(TB).at(IB).at(TB).at(IB)}}, + ms_lcaoslcaos_lcaoslcaos.at(TA).at(IA).at(TB).at(IB), + TA, IA, TB, IB, + range_jys, index_jys ); + } + } + } + } + } + } +} + +// m_big - m_left * m_middle * m_right.T +matrix Exx_Opt_Orb::cal_proj( + const matrix & m_big, + const vector & m_left, + const vector> & m_middle, + const vector & m_right ) const +{ + TITLE("Exx_Opt_Orb::cal_proj"); + +//auto print_nrc = [](const matrix & m){ cout<<"\t"<> Exx_Opt_Orb::cal_I( + const map>>> &ms, + const size_t TA, const size_t IA, const size_t TB, const size_t IB ) const +{ + TITLE("Exx_Opt_Orb::cal_I"); + + if( TA==TB && IA==IB ) + { + vector> m_I + {{ {ms.at(TA).at(IA).at(TA).at(IA).nr, ms.at(TA).at(IA).at(TA).at(IA).nc} }}; + Exx_Abfs::Inverse_Matrix_Double inv; + inv.init( ms.at(TA).at(IA).at(TA).at(IA).nr ); + inv.input( ms.at(TA).at(IA).at(TA).at(IA) ); + inv.cal_inverse( Exx_Abfs::Inverse_Matrix_Double::Method::dsyev ); + inv.output( m_I[0][0] ); + return m_I; + } + else + { + vector> m_I + {{ {ms.at(TA).at(IA).at(TA).at(IA).nr, ms.at(TA).at(IA).at(TA).at(IA).nc}, + {ms.at(TA).at(IA).at(TB).at(IB).nr, ms.at(TA).at(IA).at(TB).at(IB).nc} }, + { {ms.at(TB).at(IB).at(TA).at(IA).nr, ms.at(TB).at(IB).at(TA).at(IA).nc}, + {ms.at(TB).at(IB).at(TB).at(IB).nr, ms.at(TB).at(IB).at(TB).at(IB).nc} }}; + Exx_Abfs::Inverse_Matrix_Double inv; + inv.init( ms.at(TA).at(IA).at(TA).at(IA).nr + ms.at(TB).at(IB).at(TA).at(IA).nr ); + inv.input( ms.at(TA).at(IA).at(TA).at(IA), ms.at(TA).at(IA).at(TB).at(IB), ms.at(TB).at(IB).at(TA).at(IA), ms.at(TB).at(IB).at(TB).at(IB) ); + inv.cal_inverse( Exx_Abfs::Inverse_Matrix_Double::Method::dsyev ); + inv.output( m_I[0][0], m_I[0][1], m_I[1][0], m_I[1][1] ); + return m_I; + } +} + +map>> Exx_Opt_Orb::get_radial_R() const +{ + TITLE("Exx_Opt_Orb::get_radial_R"); + map>> radial_R; + for( size_t TA=0; TA!=ucell.ntype; ++TA ) + for( size_t IA=0; IA!=ucell.atoms[TA].na; ++IA ) + for( size_t TB=0; TB!=ucell.ntype; ++TB ) + for( size_t IB=0; IB!=ucell.atoms[TB].na; ++IB ) + { + const Vector3 &tauA = ucell.atoms[TA].tau[IA]; + const Vector3 &tauB = ucell.atoms[TB].tau[IB]; + const double delta_R = (-tauA+tauB).norm(); + radial_R[TA][TB].insert( delta_R ); + radial_R[TB][TA].insert( delta_R ); + } + return radial_R; +} \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_opt_orb.h b/ABACUS.1.0.0/source/src_lcao/exx_opt_orb.h new file mode 100644 index 0000000000..2e56e8bfe2 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_opt_orb.h @@ -0,0 +1,37 @@ +#ifndef EXX_OPT_ORB_H +#define EXX_OPT_ORB_H + +#include "src_global/matrix.h" +#include "src_global/element_basis_index.h" +#include +#include +#include +using namespace std; + +class Exx_Opt_Orb +{ +public: + void generate_matrix() const; +private: + vector> cal_I( + const map>>> &ms, + const size_t TA, const size_t IA, const size_t TB, const size_t IB ) const; + matrix cal_proj( + const matrix & m_big, + const vector & m_left, + const vector> & m_middle, + const vector & m_right ) const; + void print_matrix( + const string &file_name, + const vector &matrix_Q, + const vector> &matrix_S, + const matrix &matrix_V, + const size_t TA, const size_t IA, const size_t TB, const size_t IB, + const Element_Basis_Index::Range &range_jles, + const Element_Basis_Index::IndexLNM &index_jles) const; + map>> get_radial_R() const; + + int kmesh_times = 4; +}; + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/force_lcao.cpp b/ABACUS.1.0.0/source/src_lcao/force_lcao.cpp index 40fdccee5a..b68077c705 100644 --- a/ABACUS.1.0.0/source/src_lcao/force_lcao.cpp +++ b/ABACUS.1.0.0/source/src_lcao/force_lcao.cpp @@ -1,5 +1,6 @@ #include "force_lcao.h" -#include "../src_pw/global.h" +#include "src_pw/global.h" +#include "src_pw/potential_libxc.h" double Force_LCAO::force_invalid_threshold_ev = 0.00; @@ -676,7 +677,11 @@ void Force_LCAO::cal_force_cc(void) timer::tick("Force_LCAO","cal_force_cc",'E'); // recalculate the exchange-correlation potential. matrix vxc(NSPIN, pw.nrxx); + #ifdef TEST_LIBXC + Potential_Libxc::v_xc(chr.rho, en.etxc, en.vtxc, vxc); + #else pot.v_xc(chr.rho, en.etxc, en.vtxc, vxc); + #endif complex * psiv = new complex [pw.nrxx]; ZEROS(psiv, pw.nrxx); diff --git a/ABACUS.1.0.0/source/src_lcao/gint_k_fvl.cpp b/ABACUS.1.0.0/source/src_lcao/gint_k_fvl.cpp index b6478c4d40..22aeb40b74 100644 --- a/ABACUS.1.0.0/source/src_lcao/gint_k_fvl.cpp +++ b/ABACUS.1.0.0/source/src_lcao/gint_k_fvl.cpp @@ -593,12 +593,12 @@ void Gint_k::evaluate_vl_stress(const int &grid_index, const int &size, const in vpsir1 = iw1px[0] * vldr3[ib]; vpsir2 = iw1py[0] * vldr3[ib]; vpsir3 = iw1pz[0] * vldr3[ib]; - vpsir11 = iw1px[0] * vldr3[ib] * dr[ib][ia1][0]; - vpsir22 = iw1py[0] * vldr3[ib] * dr[ib][ia1][1]; - vpsir33 = iw1pz[0] * vldr3[ib] * dr[ib][ia1][2]; - vpsir12 = iw1px[0] * vldr3[ib] * dr[ib][ia1][1]; - vpsir13 = iw1px[0] * vldr3[ib] * dr[ib][ia1][2]; - vpsir23 = iw1py[0] * vldr3[ib] * dr[ib][ia1][2]; + vpsir11 = iw1px[0] * vldr3[ib] * dr[ib][ia1][0]; + vpsir22 = iw1py[0] * vldr3[ib] * dr[ib][ia1][1]; + vpsir33 = iw1pz[0] * vldr3[ib] * dr[ib][ia1][2]; + vpsir12 = iw1px[0] * vldr3[ib] * dr[ib][ia1][1]; + vpsir13 = iw1px[0] * vldr3[ib] * dr[ib][ia1][2]; + vpsir23 = iw1py[0] * vldr3[ib] * dr[ib][ia1][2]; ++iw1px; ++iw1py; ++iw1pz; @@ -624,12 +624,12 @@ void Gint_k::evaluate_vl_stress(const int &grid_index, const int &size, const in pvp2 = &pvdpy[iww]; pvp3 = &pvdpz[iww]; - pvp11 = &pvdp11[iww]; //zhengdy add 2017/3/28 - pvp22 = &pvdp22[iww]; - pvp33 = &pvdp33[iww]; - pvp12 = &pvdp12[iww]; - pvp13 = &pvdp13[iww]; - pvp23 = &pvdp23[iww]; + pvp11 = &pvdp11[iww]; //zhengdy add 2017/3/28 + pvp22 = &pvdp22[iww]; + pvp33 = &pvdp33[iww]; + pvp12 = &pvdp12[iww]; + pvp13 = &pvdp13[iww]; + pvp23 = &pvdp23[iww]; //------------------------------------ // circle for wave functions of atom 2. //------------------------------------ @@ -655,15 +655,15 @@ void Gint_k::evaluate_vl_stress(const int &grid_index, const int &size, const in // bug here!!!!!!!!!!!!!!!!!!!!!!!!!!! // DM(R) * psi1(r) * v(r) * psi2_R(r) - pvp1[0] += dmR2[0] * vpsir1 * iw2p[0]; - pvp2[0] += dmR2[0] * vpsir2 * iw2p[0]; - pvp3[0] += dmR2[0] * vpsir3 * iw2p[0]; - pvp11[0] += dmR2[0] * vpsir11 * iw2p[0] ; - pvp22[0] += dmR2[0] * vpsir22 * iw2p[0] ; - pvp33[0] += dmR2[0] * vpsir33 * iw2p[0] ; - pvp12[0] += dmR2[0] * vpsir12 * iw2p[0] ; - pvp13[0] += dmR2[0] * vpsir13 * iw2p[0] ; - pvp23[0] += dmR2[0] * vpsir23 * iw2p[0] ; + pvp1[0] += dmR2[0] * vpsir1 * iw2p[0]; + pvp2[0] += dmR2[0] * vpsir2 * iw2p[0]; + pvp3[0] += dmR2[0] * vpsir3 * iw2p[0]; + pvp11[0] += dmR2[0] * vpsir11 * iw2p[0] ; + pvp22[0] += dmR2[0] * vpsir22 * iw2p[0] ; + pvp33[0] += dmR2[0] * vpsir33 * iw2p[0] ; + pvp12[0] += dmR2[0] * vpsir12 * iw2p[0] ; + pvp13[0] += dmR2[0] * vpsir13 * iw2p[0] ; + pvp23[0] += dmR2[0] * vpsir23 * iw2p[0] ; // pvp1[0] += vpsir1 * iw2p[0]; // pvp2[0] += vpsir2 * iw2p[0]; // pvp3[0] += vpsir3 * iw2p[0]; @@ -677,12 +677,12 @@ void Gint_k::evaluate_vl_stress(const int &grid_index, const int &size, const in ++pvp1; ++pvp2; ++pvp3; - ++pvp11; - ++pvp22; - ++pvp33; - ++pvp12; - ++pvp13; - ++pvp23; + ++pvp11; + ++pvp22; + ++pvp33; + ++pvp12; + ++pvp13; + ++pvp23; //density matrix ++dmR2; } diff --git a/ABACUS.1.0.0/source/src_lcao/global_fp.cpp b/ABACUS.1.0.0/source/src_lcao/global_fp.cpp index 9d6a7ed276..26f71f90dc 100644 --- a/ABACUS.1.0.0/source/src_lcao/global_fp.cpp +++ b/ABACUS.1.0.0/source/src_lcao/global_fp.cpp @@ -1,4 +1,5 @@ #include "global_fp.h" +#include "src_pw/global.h" #ifdef __FP Grid_Driver GridD; @@ -9,5 +10,7 @@ Local_Orbital_wfc LOWF; LCAO_Matrix LM; Use_Hamilt_Matrix UHM; SubGrid_oper SGO; //mohan add 2012-01-12 +Exx_Lcao exx_lcao(exx_global.info); // Peize Lin add 2016-12-03 + #endif diff --git a/ABACUS.1.0.0/source/src_lcao/global_fp.h b/ABACUS.1.0.0/source/src_lcao/global_fp.h index 94abeb2353..8eca8076e5 100644 --- a/ABACUS.1.0.0/source/src_lcao/global_fp.h +++ b/ABACUS.1.0.0/source/src_lcao/global_fp.h @@ -14,6 +14,7 @@ #include "src_lcao/lcao_orbitals.h" #include "src_lcao/use_overlap_table.h" #include "src_parallel/subgrid_oper.h" +#include "src_lcao/exx_lcao.h" extern Grid_Driver GridD; extern Parallel_Atoms ParaA; @@ -23,6 +24,7 @@ extern Local_Orbital_Charge LOC; extern LCAO_Matrix LM; extern Use_Hamilt_Matrix UHM; extern SubGrid_oper SGO; //mohan add 2012-01-12 +extern Exx_Lcao exx_lcao; // Peize Lin add 2016-12-03 #endif #endif diff --git a/ABACUS.1.0.0/source/src_lcao/grid_meshball.cpp b/ABACUS.1.0.0/source/src_lcao/grid_meshball.cpp index 1e7f72d00f..aac2855dd3 100644 --- a/ABACUS.1.0.0/source/src_lcao/grid_meshball.cpp +++ b/ABACUS.1.0.0/source/src_lcao/grid_meshball.cpp @@ -154,7 +154,6 @@ double Grid_MeshBall::deal_with_atom_spillage(const double *pos) } //LiuXh add 2018-12-14 -///* void Grid_MeshBall::delete_meshball_positions(void) { TITLE("Grid_MeshBall","delete_meshball_positions"); @@ -169,4 +168,3 @@ void Grid_MeshBall::delete_meshball_positions(void) } return; } -//*/ diff --git a/ABACUS.1.0.0/source/src_lcao/lcao_matrix.cpp b/ABACUS.1.0.0/source/src_lcao/lcao_matrix.cpp index bc790e3c28..6cdee0dd7b 100644 --- a/ABACUS.1.0.0/source/src_lcao/lcao_matrix.cpp +++ b/ABACUS.1.0.0/source/src_lcao/lcao_matrix.cpp @@ -408,66 +408,83 @@ void LCAO_Matrix::zeros_HSR(const char &mtype, const int &nnr) return; } -void LCAO_Matrix::print_HSk(const char &mtype, const char &vtype, const double &accuracy) +// Peize Lin add vtype='A' 2018-11-30 +void LCAO_Matrix::print_HSk(const char &mtype, const char &vtype, const double &accuracy, ostream &os) { TITLE("LCAO_Matrix","print_HSk"); - if(mtype=='S') cout << "Sloc2 matrix" << endl; - else if(mtype=='T') cout << "Hloc_fixed2 matrix" << endl; - else if(mtype=='H') cout << "Hloc matrix" << endl; + if(mtype=='S') os << "Sloc2 matrix" << endl; + else if(mtype=='T') os << "Hloc_fixed2 matrix" << endl; + else if(mtype=='H') os << "Hloc2 matrix" << endl; else { WARNING_QUIT("LCAO_Matrix::print_HSk","Check input parameter: mtype."); } - if(vtype=='C') cout << " Output norm." << endl; - else if(vtype=='R') cout << " Output real part." << endl; - else if(vtype=='I') cout << " Output imag part." << endl; + if(vtype=='C') os << " Output norm." << endl; + else if(vtype=='R') os << " Output real part." << endl; + else if(vtype=='I') os << " Output imag part." << endl; + else if(vtype=='A') os << " Output complex." << endl; - cout << setprecision(8) << endl; + os << setprecision(8) << endl; for(int i=0; i accuracy ) - { - cout << setw(15) << v; + complex v; + if(mtype=='S') v = Sloc2[index]; + else if(mtype=='T') v = Hloc_fixed2[index]; + else if(mtype=='H') v = Hloc2[index]; + auto threshold = [accuracy]( const double v ){ return abs(v)>accuracy ? v : 0.0; }; + os << '(' << threshold(v.real()) << ',' << threshold(v.imag()) << "\t"; } else { - cout << setw(15) << "0"; + double v=-888.888;//wrong number + if(vtype=='R') + { + if(mtype=='S') v = Sloc2[index].real(); + else if(mtype=='T') v = Hloc_fixed2[index].real(); + else if(mtype=='H') v = Hloc2[index].real(); + } + else if(vtype=='C') + { + if(mtype=='S') v = sqrt( norm ( Sloc2[index] ) ); + else if(mtype=='T') v = sqrt( norm ( Hloc_fixed2[index] ) ); + else if(mtype=='H') v = sqrt( norm ( Hloc2[index] ) ); + } + else if(vtype=='I') + { + if(mtype=='S') v = Sloc2[index].imag(); + else if(mtype=='T') v = Hloc_fixed2[index].imag(); + else if(mtype=='H') v = Hloc2[index].imag(); + } + + if( abs(v) > accuracy ) + { + // os << setw(15) << v; + os << v << "\t"; + } + else + { + // os << setw(15) << "0"; + os << "0" << "\t"; + } } } - cout << endl; + os << endl; } - cout << endl; - cout << setprecision(6) << endl; + os << endl; + os << setprecision(6) << endl; return; } -void LCAO_Matrix::print_HSgamma(const char &mtype) +void LCAO_Matrix::print_HSgamma(const char &mtype, ostream &os) { TITLE("Parallel_Orbitals","print_HSgamma"); @@ -479,8 +496,8 @@ void LCAO_Matrix::print_HSgamma(const char &mtype) { if(!BFIELD) { - cout << setprecision(8); - cout << " print Sloc" << endl; + os << setprecision(8); + os << " print Sloc" << endl; for(int i=0; i 1.0e-8) { - cout << setw(15) << v; + os << setw(15) << v; } else { - cout << setw(15) << "0"; + os << setw(15) << "0"; } }//end j - cout << endl; + os << endl; }//end i } @@ -513,7 +530,7 @@ void LCAO_Matrix::print_HSgamma(const char &mtype) << setw(10) << Sloc[i * this->ncol + j] << endl; } } - cout << "\n Smatrix" << endl; + os << "\n Smatrix" << endl; //ofs_running << setprecision(5) << endl; for(int i=0; i 1.0e-8) { - cout << setw(15) << v; + os << setw(15) << v; } else { - cout << setw(15) << "0"; + os << setw(15) << "0"; } }//end j - cout << endl; + os << endl; }//end i } } @@ -617,7 +634,7 @@ void LCAO_Matrix::print_HSgamma(const char &mtype) if(!BFIELD) { - cout << " print Hloc" << endl; + os << " print Hloc" << endl; for(int i=0; i 1.0e-8) { - cout << setw(15) << v; + os << setw(15) << v; } else { - cout << setw(15) << "0"; + os << setw(15) << "0"; } }//end j - cout << endl; + os << endl; }//end i } diff --git a/ABACUS.1.0.0/source/src_lcao/lcao_matrix.h b/ABACUS.1.0.0/source/src_lcao/lcao_matrix.h index 2bf9ee3710..8b487b1cad 100644 --- a/ABACUS.1.0.0/source/src_lcao/lcao_matrix.h +++ b/ABACUS.1.0.0/source/src_lcao/lcao_matrix.h @@ -129,8 +129,8 @@ class LCAO_Matrix void zeros_HSk(const char &mtype); void zeros_HSR(const char &mtype, const int &nnr); - void print_HSgamma(const char &mtype); - void print_HSk(const char &mtype, const char &vtype = 'C', const double &accuracy = 1.0e-5); + void print_HSgamma(const char &mtype, ostream &os=cout); + void print_HSk(const char &mtype, const char &vtype = 'C', const double &accuracy = 1.0e-5, ostream &os=cout); void update_Hloc(void); void update_Hloc2(void); diff --git a/ABACUS.1.0.0/source/src_lcao/lcao_nnr.cpp b/ABACUS.1.0.0/source/src_lcao/lcao_nnr.cpp index 4422ebfbce..d7622acf51 100644 --- a/ABACUS.1.0.0/source/src_lcao/lcao_nnr.cpp +++ b/ABACUS.1.0.0/source/src_lcao/lcao_nnr.cpp @@ -44,6 +44,7 @@ LCAO_nnr::~LCAO_nnr() void LCAO_nnr::cal_nnr(void) { TITLE("LCAO_nnr","cal_nnr"); + delete[] nlocdim; delete[] nlocstart; nlocdim = new int[ucell.nat]; diff --git a/ABACUS.1.0.0/source/src_lcao/lcao_orbitals.cpp b/ABACUS.1.0.0/source/src_lcao/lcao_orbitals.cpp index b5c2ae7e99..be8f3be775 100644 --- a/ABACUS.1.0.0/source/src_lcao/lcao_orbitals.cpp +++ b/ABACUS.1.0.0/source/src_lcao/lcao_orbitals.cpp @@ -291,7 +291,7 @@ void LCAO_Orbitals::Set_NonLocal(const int &it, int &n_projectors) // get the number of non-local projectors n_projectors = atom->nbeta; const int N_PROJECTORS = atom->nh;//zhengdy-soc -cout << " number of projectros " << N_PROJECTORS << endl; + cout << " number of projectros " << N_PROJECTORS << endl; // cout << " number of projectros " << n_projectors << endl; // set the nonlocal projector objects @@ -760,14 +760,14 @@ void LCAO_Orbitals::Read_PAO(const int& it) int meshr_read; if(MY_RANK==0) //pengfei 2014-10-13 { - while (in.good()) - { - in >> word; - if (std::strcmp(word , "END") == 0) // Peize Lin fix bug about strcmp 2016-08-02 - { - break; - } - } + while (in.good()) + { + in >> word; + if (std::strcmp(word , "END") == 0) // Peize Lin fix bug about strcmp 2016-08-02 + { + break; + } + } CHECK_NAME(in, "Mesh"); in >> meshr; diff --git a/ABACUS.1.0.0/source/src_lcao/local_orbital_charge.cpp b/ABACUS.1.0.0/source/src_lcao/local_orbital_charge.cpp index 310601b4c0..f23cc264ec 100644 --- a/ABACUS.1.0.0/source/src_lcao/local_orbital_charge.cpp +++ b/ABACUS.1.0.0/source/src_lcao/local_orbital_charge.cpp @@ -2,9 +2,6 @@ #include "../src_pw/global.h" #include "blas_interface.h" -#include "src_external/src_test/test_function.h" -#include "src_external/src_test/src_global/complexmatrix-test.h" - //#include "../src_onscaling/on_tests.h" //#include "../src_siao/selinv.h" // 2014.10.29 add memory pool for DM and DM_B by yshen @@ -362,7 +359,7 @@ void Local_Orbital_Charge::sum_bands(void) NOTE("Calculate the density matrix!"); this->cal_dk_k( GridT ); } //xiaohui add 2013-09-02. Attention... - + for(int is=0; isDM[is][i], lgd_now); @@ -806,9 +808,14 @@ void Local_Orbital_Charge::cal_dk_gamma(void) } } } + + #if EXX_DM==2 + if( Exx_Global::Hybrid_Type::HF==exx_lcao.info.hybrid_type || Exx_Global::Hybrid_Type::PBE0==exx_lcao.info.hybrid_type || Exx_Global::Hybrid_Type::HSE==exx_lcao.info.hybrid_type ) + exx_lcao.DM_para.set_DM_gamma( rho_row_col, is, {row_count*300,col_count*300} ); + #endif } // end for col_count } // end for row_count - } // end for is + } // end for is } // end if !BFIELD #endif //2015-09-06, xiaohui #ifndef __MPI //2015-09-06, xiaohui diff --git a/ABACUS.1.0.0/source/src_lcao/local_orbital_elec.cpp b/ABACUS.1.0.0/source/src_lcao/local_orbital_elec.cpp index d416ff02bb..602d4529e2 100644 --- a/ABACUS.1.0.0/source/src_lcao/local_orbital_elec.cpp +++ b/ABACUS.1.0.0/source/src_lcao/local_orbital_elec.cpp @@ -129,8 +129,8 @@ void Local_Orbital_Elec::scf(const int &istep) // mohan add 2010-07-16 // used for pulay mixing. - if(iter==1) chr.new_e_iteration = true; - else chr.new_e_iteration = false; + if(iter==1) chr.set_new_e_iteration(true); + else chr.set_new_e_iteration(false); // set converged threshold, // automatically updated during self consistency, only for CG. @@ -196,7 +196,6 @@ void Local_Orbital_Elec::scf(const int &istep) } //fuxiang add 2016-11-1 - if(tddft==1 && iter == 1) { this->WFC_init = new complex**[kv.nks]; @@ -237,9 +236,19 @@ void Local_Orbital_Elec::scf(const int &istep) } } } - } - - + } + + // calculate exact-exchange + switch(xcf.iexch_now) // Peize Lin add 2018-10-30 + { + case 5: case 6: case 9: + if( !exx_global.info.separate_loop ) + { + exx_lcao.cal_exx_elec(); + } + break; + } + // (1) calculate the bands. cal_bands(istep); @@ -275,28 +284,8 @@ void Local_Orbital_Elec::scf(const int &istep) // (2) chr.save_rho_before_sum_band(); - // (3) sum bands to calculate charge density Occupy::calculate_weights(); - -/* if(istep==0) - { - for (int ib=0; ib < 3; ib++) - { - wf.wg(0,ib) = 2.0; - } - wf.wg(0,3) = 1.75; - wf.wg(0,4) = 0.25; - } - for (int ik = 0; ik < kv.nks; ik++) - { - for (int ib = 0; ib < NBANDS; ib++) - { - cout << "wf.wg(ik, ib): " << wf.wg(ik, ib) << endl; - } - } -*/ - for(int ik=0; ik +#include "exx_abfs.h" double Make_Overlap_Table::dr = -1.0; Make_Overlap_Table::Make_Overlap_Table() @@ -1328,10 +1328,10 @@ void Make_Overlap_Table::init_Lmax (const int orb_num, const int mode, int &Lmax //use 2lmax+1 in dS Lmax_used = 2*Lmax + 1; break; -// case 2: // used in or -// Lmax = max(Lmax, Exx_Abfs::Lmax); -// Lmax_used = 2*Lmax + 1; -// break; + case 2: // used in or + Lmax = max(Lmax, Exx_Abfs::Lmax); + Lmax_used = 2*Lmax + 1; + break; case 3: // used in berryphase by jingan cal_Lmax_Phi(Lmax); Lmax++; @@ -1345,12 +1345,12 @@ void Make_Overlap_Table::init_Lmax (const int orb_num, const int mode, int &Lmax case 3: switch( mode ) { -// case 1: // used in or -// cal_Lmax_Phi(Lmax); -// Lmax_used = 2*Lmax + 1; -// Lmax = max(Lmax, Exx_Abfs::Lmax); -// Lmax_used += Exx_Abfs::Lmax; -// break; + case 1: // used in or + cal_Lmax_Phi(Lmax); + Lmax_used = 2*Lmax + 1; + Lmax = max(Lmax, Exx_Abfs::Lmax); + Lmax_used += Exx_Abfs::Lmax; + break; default: throw invalid_argument("Make_Overlap_Table::init_Lmax orb_num=3, mode error"); break; diff --git a/ABACUS.1.0.0/source/src_lcao/sltk_adjacent_set.cpp b/ABACUS.1.0.0/source/src_lcao/sltk_adjacent_set.cpp index 1e06f22c41..7ea63f29c0 100644 --- a/ABACUS.1.0.0/source/src_lcao/sltk_adjacent_set.cpp +++ b/ABACUS.1.0.0/source/src_lcao/sltk_adjacent_set.cpp @@ -67,7 +67,6 @@ void AdjacentSet::set } void AdjacentSet::assertCoordinateIsRight(const int x, const int y, const int z, const char* const s) -throw(std::out_of_range) { /* if (x > 1 || x < -1 || y > 1 || y < -1 || z > 1 || z < -1) { diff --git a/ABACUS.1.0.0/source/src_lcao/sltk_adjacent_set.h b/ABACUS.1.0.0/source/src_lcao/sltk_adjacent_set.h index 95ef0f459f..64404f5b7a 100644 --- a/ABACUS.1.0.0/source/src_lcao/sltk_adjacent_set.h +++ b/ABACUS.1.0.0/source/src_lcao/sltk_adjacent_set.h @@ -31,8 +31,7 @@ class AdjacentSet // throw the exception "out_of_range". //========================================================== static - void assertCoordinateIsRight(const int x, const int y, const int z, const char* const s) - throw(std::out_of_range); + void assertCoordinateIsRight(const int x, const int y, const int z, const char* const s); // Peize Lin delete throw(std::out_of_range) 2018-07-14 //========================================================== // MEMBER VARIABLE : diff --git a/ABACUS.1.0.0/source/src_lcao/use_hamilt_matrix.cpp b/ABACUS.1.0.0/source/src_lcao/use_hamilt_matrix.cpp index 40f094761b..3db1fbc9dd 100644 --- a/ABACUS.1.0.0/source/src_lcao/use_hamilt_matrix.cpp +++ b/ABACUS.1.0.0/source/src_lcao/use_hamilt_matrix.cpp @@ -89,7 +89,7 @@ void Use_Hamilt_Matrix::set_ion(void) return; } -void Use_Hamilt_Matrix::calculate_Hgamma(void) +void Use_Hamilt_Matrix::calculate_Hgamma( const int &ik ) // Peize Lin add ik 2016-12-03 { TITLE("Use_Hamilt_Matrix","calculate_Hgamma"); timer::tick("Use_Hamilt_Matrix","cal_Hgamma",'F'); @@ -148,6 +148,14 @@ void Use_Hamilt_Matrix::calculate_Hgamma(void) //------------------------------------------------ LCAO_Vna::smooth_vl1(); } + + // Peize Lin add 2016-12-03 + if( 5==xcf.iexch_now && 0==xcf.igcx_now ) // HF + exx_lcao.add_Hexx(ik,1); + else if( 6==xcf.iexch_now && 8==xcf.igcx_now ) // PBE0 + exx_lcao.add_Hexx(ik,exx_global.info.hybrid_alpha); + else if( 9==xcf.iexch_now && 12==xcf.igcx_now ) // HSE + exx_lcao.add_Hexx(ik,exx_global.info.hybrid_alpha); } time_t time_vlocal_end = time(NULL); @@ -323,6 +331,14 @@ void Use_Hamilt_Matrix::calculate_Hk(const int &ik) LM.zeros_HSR('H', LNNR.nnr); if(!NONCOLIN) this->GK.folding_vl_k(ik); else this->GK.folding_vl_k_nc(ik); + + // Peize Lin add 2016-12-03 + if( 5==xcf.iexch_now && 0==xcf.igcx_now ) // HF + exx_lcao.add_Hexx(ik,1); + else if( 6==xcf.iexch_now && 8==xcf.igcx_now ) // PBE0 + exx_lcao.add_Hexx(ik,0.25); + else if( 9==xcf.iexch_now && 12==xcf.igcx_now ) // HSE + exx_lcao.add_Hexx(ik,0.25); } diff --git a/ABACUS.1.0.0/source/src_lcao/use_hamilt_matrix.h b/ABACUS.1.0.0/source/src_lcao/use_hamilt_matrix.h index e461948ba0..d04047ad7f 100644 --- a/ABACUS.1.0.0/source/src_lcao/use_hamilt_matrix.h +++ b/ABACUS.1.0.0/source/src_lcao/use_hamilt_matrix.h @@ -20,7 +20,7 @@ class Use_Hamilt_Matrix void calculate_Hk( const int &ik); // used for Gamma only Hamiltonian matrix. - void calculate_Hgamma(void); + void calculate_Hgamma( const int &ik ); // Peize Lin add ik 2016-12-03 // used for gamma only algorithms. Gint_Gamma GG; diff --git a/ABACUS.1.0.0/source/src_parallel/parallel_global.cpp b/ABACUS.1.0.0/source/src_parallel/parallel_global.cpp index 8cc218e754..9f606633ee 100644 --- a/ABACUS.1.0.0/source/src_parallel/parallel_global.cpp +++ b/ABACUS.1.0.0/source/src_parallel/parallel_global.cpp @@ -7,6 +7,10 @@ #include "parallel_reduce.h" #include "../src_global/global_function.h" +#ifdef _OPENMP +#include // Peize Lin add 2018-02-13 +#endif + using namespace std; #if defined __MPI @@ -151,7 +155,16 @@ void Parallel_Global::read_mpi_parameters(int argc,char **argv) } cout<new_e_iteration) { @@ -274,10 +272,31 @@ void Charge_Pulay::Pulay_mixing(void) this->read_rho(ifname.str()); } */ - + #if TEST_EXX_LCAO==1 + cout<<"Charge_Pulay::Pulay_mixing\t"<<__FILE__<<"\t"<<__LINE__<new_e_iteration = new_e_iteration_in; + + if(this->new_e_iteration) + { + irstep = 0; + idstep = 0; + totstep = 0; + } +} + void Charge_Pulay::allocate_pulay(const int &scheme) { //cout << "\n initp = " << initp << endl; diff --git a/ABACUS.1.0.0/source/src_pw/charge_pulay.h b/ABACUS.1.0.0/source/src_pw/charge_pulay.h index ab01b2b91b..ab6dbb92bf 100644 --- a/ABACUS.1.0.0/source/src_pw/charge_pulay.h +++ b/ABACUS.1.0.0/source/src_pw/charge_pulay.h @@ -12,21 +12,28 @@ //=================================== #include "tools.h" #include "charge_mixing.h" +#include "src_lcao/exx_abfs-dm.h" +#include "src_lcao/exx_abfs-parallel-communicate-hexx.h" + class Charge_Pulay: public Charge_Mixing { public: Charge_Pulay(); ~Charge_Pulay(); - // mohan add 2010-07-16 - bool new_e_iteration; - int irstep; //mohan add 2012-02-10 int idstep; int totstep; + + // Peize Lin add 2018-11-01, and set new_e_iteration protected + const bool &get_new_e_iteration(){ return new_e_iteration; } + void set_new_e_iteration( const bool new_e_iteration_in ); protected: + // mohan add 2010-07-16 + bool new_e_iteration; + // Pulay mixing method. void Pulay_mixing(); int rstep; // the record step; @@ -56,7 +63,8 @@ class Charge_Pulay: public Charge_Mixing // Sophisticated mixing method. void Modified_Broyden_mixing(); - + friend class Exx_Abfs::DM; + friend class Exx_Abfs::Parallel::Communicate::Hexx; }; #endif diff --git a/ABACUS.1.0.0/source/src_pw/chi0_hilbert.cpp b/ABACUS.1.0.0/source/src_pw/chi0_hilbert.cpp index 602cbf4d5f..937f31c651 100644 --- a/ABACUS.1.0.0/source/src_pw/chi0_hilbert.cpp +++ b/ABACUS.1.0.0/source/src_pw/chi0_hilbert.cpp @@ -1684,7 +1684,7 @@ void Chi0_hilbert::Cal_Chi0s(int iq) } } } - } + } } } diff --git a/ABACUS.1.0.0/source/src_pw/electrons.cpp b/ABACUS.1.0.0/source/src_pw/electrons.cpp index f67ec0a136..509a7267fd 100644 --- a/ABACUS.1.0.0/source/src_pw/electrons.cpp +++ b/ABACUS.1.0.0/source/src_pw/electrons.cpp @@ -101,7 +101,7 @@ void electrons::self_consistent(const int &istep) en.ewld = en.ewald(); set_ethr(); - + this->unit = 0; if(OUT_LEVEL=="ie") @@ -169,8 +169,8 @@ void electrons::self_consistent(const int &istep) << " ELEC=" << setw(4) << iter << "--------------------------------\n"; // mohan add 2010-07-16 - if(iter==1) chr.new_e_iteration = true; - else chr.new_e_iteration = false; + if(iter==1) chr.set_new_e_iteration(true); + else chr.set_new_e_iteration(false); // record the start time. start=std::clock(); @@ -194,6 +194,17 @@ void electrons::self_consistent(const int &istep) // first_iter_again: // Peize Lin delete 2019-05-01 + // calculate exact-exchange + switch(xcf.iexch_now) // Peize Lin add 2019-03-09 + { + case 5: case 6: case 9: + if( !exx_global.info.separate_loop ) + { + exx_lip.cal_exx(); + } + break; + } + //(2) calculate band energy using cg or davidson method. // output the new eigenvalues and wave functions. this->c_bands(); @@ -225,12 +236,14 @@ void electrons::self_consistent(const int &istep) // calculate the new eband here. chr.sum_band(); + // add exx + en.set_exx(); // Peize Lin add 2019-03-09 + //(6) calculate the delta_harris energy // according to new charge density. // mohan add 2009-01-23 en.calculate_harris(2); - Symmetry_rho srho; for(int is=0; isistep, this->iter, ik, h_diag, avg_iter_k); - avg_iter += avg_iter_k; + avg_iter += avg_iter_k; - en.print_band(ik); //mohan add 2012-04-16 + en.print_band(ik); //mohan add 2012-04-16 clock_t finish=clock(); const double duration = static_cast(finish - start) / CLOCKS_PER_SEC; - ofs_running << " " << setw(8) - << ik+1 << setw(15) - << avg_iter_k << setw(15) << duration << endl; + ofs_running << " " << setw(8) + << ik+1 << setw(15) + << avg_iter_k << setw(15) << duration << endl; }//End K Loop diff --git a/ABACUS.1.0.0/source/src_pw/energy.cpp b/ABACUS.1.0.0/source/src_pw/energy.cpp index 99df4de637..aaf4183bf0 100644 --- a/ABACUS.1.0.0/source/src_pw/energy.cpp +++ b/ABACUS.1.0.0/source/src_pw/energy.cpp @@ -97,52 +97,52 @@ bool print) ofs_running << "\n Density error is " << dr2 << endl; - if(OUT_LEVEL != "m") //xiaohui add "OUT_LEVEL", 2015-09-16 - { - //if(!LOCAL_BASIS)OUT(ofs_running,"Error Threshold",ethr); xiaohui modify 2013-09-02 - if(BASIS_TYPE=="pw")OUT(ofs_running,"Error Threshold",ethr); //xiaohui add 2013-09-02 - - if( this->printe>0 && ( (iter+1) % this->printe == 0 || converged || iter == NITER) ) + if(OUT_LEVEL != "m") //xiaohui add "OUT_LEVEL", 2015-09-16 { - ofs_running << "\n " << setw(12) << "Energy" << setw(30) << "Rydberg" << setw(30) << "eV" << endl; - this->print_format("E_KohnSham",etot); - this->print_format("E_Harris",etot_harris); - this->print_format("E_band",eband); - this->print_format("E_one_elec",eband+deband); - this->print_format("E_Hartree",ehart); - this->print_format("E_xc",etxc-etxcc); - this->print_format("E_Ewald",ewld); - this->print_format("E_demet",demet); //mohan add 2011-12-02 - this->print_format("E_descf",descf); - this->print_format("E_efield",Efield::etotefield); - if(vdwd2.vdwD2) //Peize Lin add 2014-04, update 2019-04-26 + //if(!LOCAL_BASIS)OUT(ofs_running,"Error Threshold",ethr); xiaohui modify 2013-09-02 + if(BASIS_TYPE=="pw")OUT(ofs_running,"Error Threshold",ethr); //xiaohui add 2013-09-02 + + if( this->printe>0 && ( (iter+1) % this->printe == 0 || converged || iter == NITER) ) { - this->print_format("E_vdwD2",vdwd2.energy_result); + ofs_running << "\n " << setw(12) << "Energy" << setw(30) << "Rydberg" << setw(30) << "eV" << endl; + this->print_format("E_KohnSham",etot); + this->print_format("E_Harris",etot_harris); + this->print_format("E_band",eband); + this->print_format("E_one_elec",eband+deband); + this->print_format("E_Hartree",ehart); + this->print_format("E_xc",etxc-etxcc); + this->print_format("E_Ewald",ewld); + this->print_format("E_demet",demet); //mohan add 2011-12-02 + this->print_format("E_descf",descf); + this->print_format("E_efield",Efield::etotefield); + if(vdwd2.vdwD2) //Peize Lin add 2014-04, update 2019-04-26 + { + this->print_format("E_vdwD2",vdwd2.energy_result); + } + this->print_format("E_exx",exx); + } + else + { + ofs_running << "\n " << setw(12) << "Energy" << setw(30) << "Rydberg" << setw(30) << "eV" << endl; + this->print_format("E_KohnSham",etot); + this->print_format("E_Harris",etot_harris); } -// this->print_format("e_exx",exx); - } - else - { - ofs_running << "\n " << setw(12) << "Energy" << setw(30) << "Rydberg" << setw(30) << "eV" << endl; - this->print_format("E_KohnSham",etot); - this->print_format("E_Harris",etot_harris); - } - if(TWO_EFERMI) - { - this->print_format("E_Fermi_up",ef_up); - this->print_format("E_Fermi_dw",ef_dw); - } - else + if(TWO_EFERMI) + { + this->print_format("E_Fermi_up",ef_up); + this->print_format("E_Fermi_dw",ef_dw); + } + else + { + this->print_format("E_Fermi",this->ef); + } + }//xiaohui add "OUT_LEVEL", 2015-09-16 + + if (iter_in == 1) // pengfei Li added 2015-1-31 { - this->print_format("E_Fermi",this->ef); + this->etot_old = this->etot; } - }//xiaohui add "OUT_LEVEL", 2015-09-16 - - if (iter_in == 1) // pengfei Li added 2015-1-31 - { - this->etot_old = this->etot; - } // for test, output eigenvalues. /* @@ -772,6 +772,10 @@ double energy::delta_e(void) #endif deband0 *= ucell.omega / pw.ncxyz; + + // \int rho(r) v_{exx}(r) dr = 2 E_{exx}[rho] + deband0 -= 2*exx; // Peize Lin add 2017-10-16 + return deband0; } // end subroutine delta_e #endif @@ -1135,3 +1139,23 @@ void energy::print_band(const int &ik) } return; } + +// Peize Lin add 2016-12-03 +void energy::set_exx() +{ + auto exx_energy = []() -> double + { + if("lcao_in_pw"==BASIS_TYPE) + return exx_lip.get_exx_energy(); + else if("lcao"==BASIS_TYPE) + return exx_lcao.get_energy(); + else + throw invalid_argument(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + }; + if( 5==xcf.iexch_now && 0==xcf.igcx_now ) // HF + this->exx = exx_energy(); + else if( 6==xcf.iexch_now && 8==xcf.igcx_now ) // PBE0 + this->exx = exx_global.info.hybrid_alpha * exx_energy(); + else if( 9==xcf.iexch_now && 12==xcf.igcx_now ) // HSE + this->exx = exx_global.info.hybrid_alpha * exx_energy(); +} \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_pw/energy.h b/ABACUS.1.0.0/source/src_pw/energy.h index b7c65feb51..e7bb6b4a78 100644 --- a/ABACUS.1.0.0/source/src_pw/energy.h +++ b/ABACUS.1.0.0/source/src_pw/energy.h @@ -96,6 +96,8 @@ class energy int &nrm ) const; + void set_exx(); // Peize Lin add 2016-12-03 + static int mxr; }; diff --git a/ABACUS.1.0.0/source/src_pw/exx_global.h b/ABACUS.1.0.0/source/src_pw/exx_global.h new file mode 100644 index 0000000000..67d74186d0 --- /dev/null +++ b/ABACUS.1.0.0/source/src_pw/exx_global.h @@ -0,0 +1,41 @@ +#ifndef EXX_GLOBAL_H +#define EXX_GLOBAL_H + +#include "src_pw/functional.h" + +struct Exx_Global +{ + enum class Hybrid_Type {No,HF,PBE0,HSE,Generate_Matrix}; + struct Exx_Info + { + Exx_Global::Hybrid_Type hybrid_type; + + double hybrid_alpha = 0.25; + double hse_omega = 0.11; + + bool separate_loop = true; + size_t hybrid_step = 1; + + void set_xcfunc( xcfunc &xcf ) const + { + switch( hybrid_type ) + { + case Exx_Global::Hybrid_Type::HF: + xcf.iexch_now=5; xcf.igcx_now=0; + xcf.icorr_now=0; xcf.igcc_now=0; + break; + case Exx_Global::Hybrid_Type::PBE0: + xcf.iexch_now=6; xcf.igcx_now=8; + break; + case Exx_Global::Hybrid_Type::HSE: + xcf.iexch_now=9; xcf.igcx_now=12; + break; + default: + throw invalid_argument(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + } + } + }; + Exx_Info info; +}; + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_pw/exx_lip.cpp b/ABACUS.1.0.0/source/src_pw/exx_lip.cpp new file mode 100644 index 0000000000..70941ea556 --- /dev/null +++ b/ABACUS.1.0.0/source/src_pw/exx_lip.cpp @@ -0,0 +1,931 @@ +//========================================================== +// AUTHOR : Peize Lin +// DATE : 2015-03-10 +//========================================================== + +#include "exx_lip.h" +#include "src_global/global_function.h" +#include "src_global/vector3.h" +#include "src_pw/global.h" +#include "src_pw/klist.h" +#include "src_pw/wavefunc.h" +#include "src_pw/wavefunc_in_pw.h" +#include "src_global/lapack_connector.h" +#include + +#include "src_external/src_test/test_function.h" + +Exx_Lip::Exx_Lip( const Exx_Global::Exx_Info &info_global ) + :init_finish(false), + info(info_global), + exx_matrix(NULL), + exx_energy(0){} + +Exx_Lip::Exx_Info::Exx_Info( const Exx_Global::Exx_Info &info_global ) + :hybrid_type(info_global.hybrid_type), + hse_omega(info_global.hse_omega){} + +void Exx_Lip::cal_exx() +{ + TITLE("Exx_Lip","cal_exx"); + auto my_time = [](timeval &t_begin) -> double + { + const double time_during = cal_time(t_begin); + gettimeofday(&t_begin, NULL); + return time_during; + }; + auto cout_t = [](const string &name, const double t) + { + cout<kv_ptr->nks; ++ik) + { + phi_cal(k_pack, ik); +t_phi_cal += my_time(t); + + judge_singularity(ik); + for( int iw_l=0; iw_lkv_ptr->nks/NSPIN; ++iq_tmp) // !!! k_point parallel incompleted. need to loop iq in other pool + { + int iq = (ik<(k_pack->kv_ptr->nks/NSPIN)) ? (iq_tmp%(q_pack->kv_ptr->nks/NSPIN)) : (iq_tmp%(q_pack->kv_ptr->nks/NSPIN)+(q_pack->kv_ptr->nks/NSPIN)); + qkg2_exp(ik, iq); +t_qkg2_exp += my_time(t); + for( int ib=0; ibkv_ptr->nks; ++ik) + { + phi_cal(k_pack, ik); + + judge_singularity(ik); + for( int iw_l=0; iw_lkv_ptr->nks/NSPIN; ++iq_tmp) // !!! k_point parallel incompleted. need to loop iq in other pool + { + int iq = (ik<(k_pack->kv_ptr->nks/NSPIN)) ? (iq_tmp%(q_pack->kv_ptr->nks/NSPIN)) : (iq_tmp%(q_pack->kv_ptr->nks/NSPIN)+(q_pack->kv_ptr->nks/NSPIN)); + qkg2_exp(ik, iq); + for( int ib=0; ibkv_ptr = kv_ptr_in; + k_pack->wf_ptr = wf_ptr_in; + pw_ptr = pw_ptr_in; + UFFT_ptr = UFFT_ptr_in; + ucell_ptr = ucell_ptr_in; + + int gzero_judge(-1); + if (pw_ptr->gcar[0]==Vector3(0.0,0.0,0.0)) + { + gzero_judge = RANK_IN_POOL; + } + MPI_Allreduce(&gzero_judge, &gzero_rank_in_pool, 1, MPI_INT, MPI_MAX, POOL_WORLD); + + k_pack->wf_wg.create(k_pack->kv_ptr->nks,NBANDS); + + k_pack->hvec_array = new ComplexMatrix [k_pack->kv_ptr->nks]; + for( int ik=0; ikkv_ptr->nks; ++ik) + { + k_pack->hvec_array[ik].create(NLOCAL,NBANDS); + } + + if (pot.start_pot=="atomic") + { + q_pack = k_pack; + } + else if(pot.start_pot=="file") + { + read_q_pack(); + } + + phi = new complex*[NLOCAL]; + for( int iw=0; iw[pw_ptr->nrxx]; + } + + psi = new complex**[q_pack->kv_ptr->nks]; + for( int iq=0; iqkv_ptr->nks; ++iq) + { + psi[iq] = new complex *[NBANDS]; + for( int ib=0; ib[pw_ptr->nrxx]; + } + } + + recip_qkg2 = new double [pw_ptr->ngmc]; + + b = new complex [NLOCAL*pw_ptr->ngmc]; + + sum1 = new complex [NLOCAL*NLOCAL]; + + if( Exx_Global::Hybrid_Type::HF==info.hybrid_type || Exx_Global::Hybrid_Type::PBE0==info.hybrid_type ) + if(gzero_rank_in_pool==RANK_IN_POOL) + { + b0 = new complex [NLOCAL]; + sum3 = new complex *[NLOCAL]; + for( int iw_l=0; iw_l [NLOCAL]; + } + } + else + { + b0 = NULL; + sum3 = NULL; + } + else + { + b0 = NULL; + sum3 = NULL; + } + + exx_matrix = new complex **[k_pack->kv_ptr->nks]; + for( int ik=0; ikkv_ptr->nks; ++ik) + { + exx_matrix[ik] = new complex*[NLOCAL]; + for( int iw_l=0; iw_l[NLOCAL]; + } + } + } + catch(const std::bad_alloc &ex) + { + WARNING_QUIT("exact_exchange","Memory"); + } + + init_finish = true; +} + +Exx_Lip::~Exx_Lip() +{ + TITLE("Exx_Lip","~Exx_Lip"); + if( init_finish) + { + for( int iw=0; iwkv_ptr->nks;++iq) + { + for( int ib=0;ibkv_ptr->nks; ++ik) + { + for( int iw_l=0; iw_lhvec_array; k_pack->hvec_array=NULL; + delete k_pack; + + if (pot.start_pot=="atomic") + { + q_pack = NULL; + } + else if(pot.start_pot=="file") + { + delete q_pack->kv_ptr; q_pack->kv_ptr=NULL; + delete q_pack->wf_ptr; q_pack->wf_ptr=NULL; + delete[] q_pack->hvec_array; q_pack->hvec_array=NULL; + delete q_pack; q_pack=NULL; + } + } +} + +void Exx_Lip::wf_wg_cal() +{ + TITLE("Exx_Lip","wf_wg_cal"); + if(NSPIN==1) + for( int ik=0; ikkv_ptr->nks; ++ik) + for( int ib=0; ibwf_wg(ik,ib) = k_pack->wf_ptr->wg(ik,ib)/2; + else if(NSPIN==2) + for( int ik=0; ikkv_ptr->nks; ++ik) + for( int ib=0; ibwf_wg(ik,ib) = k_pack->wf_ptr->wg(ik,ib); +} + +void Exx_Lip::phi_cal(k_package *kq_pack, int ikq) +{ + for( int iw=0; iw< NLOCAL; ++iw) + { + ZEROS( UFFT_ptr->porter, pw_ptr->nrxx ); + for( int ig=0; igkv_ptr->ngk[ikq]; ++ig) + UFFT_ptr->porter[ pw_ptr->ig2fftw[kq_pack->wf_ptr->igk(ikq,ig)] ] = kq_pack->wf_ptr->wanf2[ikq](iw,ig); + pw_ptr->FFT_wfc.FFT3D(UFFT_ptr->porter,1); + int ir(0); + for( int ix=0; ixncx; ++ix) + { + const double phase_x = kq_pack->kv_ptr->kvec_d[ikq].x * ix / pw_ptr->ncx; + for( int iy=0; iyncy; ++iy) + { + const double phase_xy = phase_x + kq_pack->kv_ptr->kvec_d[ikq].y * iy / pw_ptr->ncy; + for( int iz=pw_ptr->nczp_start; iznczp_start+pw_ptr->nczp; ++iz) + { + const double phase_xyz = phase_xy + kq_pack->kv_ptr->kvec_d[ikq].z * iz / pw_ptr->ncz; + const complex exp_tmp = exp(phase_xyz*TWO_PI*IMAG_UNIT); + phi[iw][ir] = UFFT_ptr->porter[ir]*exp_tmp; + ++ir; + } + } + } + } +} + +void Exx_Lip::psi_cal() +{ + TITLE("Exx_Lip","psi_cal"); + if (pot.start_pot=="atomic") + { + for( int iq = 0; iq < q_pack->kv_ptr->nks; ++iq) + { + for( int ib = 0; ib < NBANDS; ++ib) + { + ZEROS( UFFT_ptr->porter, pw_ptr->nrxx ); + for( int ig = 0; ig < q_pack->kv_ptr->ngk[iq] ; ++ig) + { + UFFT_ptr->porter[ pw_ptr->ig2fftw[q_pack->wf_ptr->igk(iq,ig)] ] = q_pack->wf_ptr->evc[iq](ib,ig); + } + pw_ptr->FFT_wfc.FFT3D(UFFT_ptr->porter,1); + int ir(0); + for( int ix=0; ixncx; ++ix) + { + const double phase_x = q_pack->kv_ptr->kvec_d[iq].x * ix / pw_ptr->ncx; + for( int iy=0; iyncy; ++iy) + { + const double phase_xy = phase_x + q_pack->kv_ptr->kvec_d[iq].y * iy / pw_ptr->ncy; + for( int iz=pw_ptr->nczp_start; iznczp_start+pw_ptr->nczp; ++iz) + { + const double phase_xyz = phase_xy + q_pack->kv_ptr->kvec_d[iq].z * iz / pw_ptr->ncz; + const complex exp_tmp = exp(phase_xyz*TWO_PI*IMAG_UNIT); + psi[iq][ib][ir] = UFFT_ptr->porter[ir]*exp_tmp; + ++ir; + } + } + } + } + } + } + else if(pot.start_pot=="file") + { + for( int iq=0; iqkv_ptr->nks; ++iq) + { + phi_cal( q_pack, iq); + for( int ib=0; ibnrxx); + for( int iw=0; iwnrxx; ++ir) + { + psi[iq][ib][ir] += q_pack->hvec_array[iq](iw,ib) * phi[iw][ir]; + } + } + } + } + } +/////////////////////////////////////////////////////////////////////////// +// !!! k_point parallel incompleted. need to loop iq in other pool +/////////////////////////////////////////////////////////////////////////// +} + +void Exx_Lip::judge_singularity( int ik) +{ + if (pot.start_pot=="atomic") + { + iq_vecik = ik; + } + else if(pot.start_pot=="file") + { + double min_q_minus_k(numeric_limits::max()); + for( int iq=0; iqkv_ptr->nks; ++iq) + { + const double q_minus_k ( (q_pack->kv_ptr->kvec_c[iq] - k_pack->kv_ptr->kvec_c[ik]).norm2() ); + if(q_minus_k < min_q_minus_k) + { + min_q_minus_k = q_minus_k; + iq_vecik = iq; + } + } + } +} + + +void Exx_Lip::qkg2_exp(int ik, int iq) +{ + for( int ig=0; igngmc; ++ig) + { + const double qkg2 = ( (q_pack->kv_ptr->kvec_c[iq] - k_pack->kv_ptr->kvec_c[ik] + pw_ptr->gcar[ig]) *(TWO_PI/ucell_ptr->lat0)).norm2(); + if( (Exx_Global::Hybrid_Type::PBE0==info.hybrid_type) || (Exx_Global::Hybrid_Type::HF==info.hybrid_type) ) + { + if( abs(qkg2)<1e-10 ) + recip_qkg2[ig] = 0.0; // 0 to ignore bb/qkg2 when qkg2==0 + else + recip_qkg2[ig] = 1.0/qkg2; + sum2_factor += recip_qkg2[ig] * exp(-info.lambda*qkg2) ; + recip_qkg2[ig] = sqrt(recip_qkg2[ig]); + } + else if(Exx_Global::Hybrid_Type::HSE==info.hybrid_type) + { + if( abs(qkg2)<1e-10 ) + recip_qkg2[ig] = 1.0/(2*info.hse_omega); + else + recip_qkg2[ig] = sqrt( (1-exp(-qkg2/(4*info.hse_omega*info.hse_omega))) /qkg2); + } + } +} + + +void Exx_Lip::b_cal( int ik, int iq, int ib) +{ + const Vector3 q_minus_k = q_pack->kv_ptr->kvec_d[iq] - k_pack->kv_ptr->kvec_d[ik]; + vector > mul_tmp(pw_ptr->nrxx); + for( size_t ir=0,ix=0; ixncx; ++ix) + { + const double phase_x = q_minus_k.x*ix/pw_ptr->ncx; + for( size_t iy=0; iyncy; ++iy) + { + const double phase_xy = phase_x + q_minus_k.y*iy/pw_ptr->ncy; + for( size_t iz=pw_ptr->nczp_start; iznczp_start+pw_ptr->nczp; ++iz) + { + const double phase_xyz = phase_xy + q_minus_k.z*iz/pw_ptr->ncz; + mul_tmp[ir] = exp(-phase_xyz*TWO_PI*IMAG_UNIT); + mul_tmp[ir] *= psi[iq][ib][ir]; + ++ir; + } + } + } + + complex * const porter = UFFT_ptr->porter; + const int * const ig2fftc = pw_ptr->ig2fftc; + for(size_t iw=0; iw< NLOCAL; ++iw) + { + const complex * const phi_w = phi[iw]; + for( size_t ir=0; irnrxx; ++ir) + { + porter[ir] = conj(phi_w[ir]) * mul_tmp[ir] ; +// porter[ir] = phi_w[ir] * psi_q_b[ir] *exp_tmp[ir] ; + } + pw_ptr->FFT_chg.FFT3D( porter, -1); + if( Exx_Global::Hybrid_Type::HF==info.hybrid_type || Exx_Global::Hybrid_Type::PBE0==info.hybrid_type ) + if((iq==iq_vecik) && (gzero_rank_in_pool==RANK_IN_POOL)) /// need to check while use k_point parallel + b0[iw] = porter[ pw_ptr->ig2fftc[0] ]; + complex * const b_w = b+iw*pw_ptr->ngmc; + for( size_t ig=0; igngmc; ++ig) + b_w[ig] = porter[ ig2fftc[ig] ] * recip_qkg2[ig]; + } +} + + +void Exx_Lip::sum3_cal(int iq, int ib) +{ + if( gzero_rank_in_pool == RANK_IN_POOL ) + for( int iw_l=0; iw_lwf_wg(iq,ib); +} + + +void Exx_Lip::b_sum( int iq, int ib) // Peize Lin change 2019-04-14 +{ + // sum1[iw_l,iw_r] += \sum_{ig} b[iw_l,ig] * conj(b[iw_r,ig]) * q_pack->wf_wg(iq,ib) + LapackConnector::zherk( + 'U','N', + NLOCAL, pw_ptr->ngmc, + q_pack->wf_wg(iq,ib), b, pw_ptr->ngmc, + 1.0, sum1, NLOCAL); +// cblas_zherk( CblasRowMajor, CblasUpper, CblasNoTrans, +// NLOCAL, pw_ptr->ngmc, +// q_pack->wf_wg(iq,ib), static_cast(b), pw_ptr->ngmc, +// 1.0, static_cast(sum1), NLOCAL); +} + +void Exx_Lip::sum_all(int ik) +{ + double sum2_factor_g(0.0); + if( Exx_Global::Hybrid_Type::HF==info.hybrid_type || Exx_Global::Hybrid_Type::PBE0==info.hybrid_type ) + MPI_Reduce( &sum2_factor, &sum2_factor_g, 1, MPI_DOUBLE, MPI_SUM, gzero_rank_in_pool, POOL_WORLD); + + for( size_t iw_l=1; iw_lomega *sum1[iw_l*NLOCAL+iw_r]); + if( Exx_Global::Hybrid_Type::HF==info.hybrid_type || Exx_Global::Hybrid_Type::PBE0==info.hybrid_type ) + if(gzero_rank_in_pool==RANK_IN_POOL) + { + exx_matrix[ik][iw_l][iw_r] += 2.0* (4*PI/ucell_ptr->omega *sum3[iw_l][iw_r] *sum2_factor_g ); + exx_matrix[ik][iw_l][iw_r] += 2.0* (-1/sqrt(info.lambda*PI)*(q_pack->kv_ptr->nks/NSPIN) * sum3[iw_l][iw_r]); + } + } + } +} + +void Exx_Lip::exx_energy_cal() +{ + TITLE("Exx_Lip","exx_energy_cal"); + + double exx_energy_tmp = 0.0; + + for( int ik=0; ikkv_ptr->nks; ++ik) + { + for( int iw_l=0; iw_lhvec_array[ik](iw_l,ib)) *k_pack->hvec_array[ik](iw_r,ib) ).real() *k_pack->wf_wg(ik,ib); + } + } + } + } + MPI_Allreduce( &exx_energy_tmp, &exx_energy, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); // !!! k_point parallel incompleted. different pools have different kv.nks => deadlock + exx_energy *= (NSPIN==1) ? 2 : 1; + exx_energy /= 2; // ETOT = E_band - 1/2 E_exx + + #if TEST_EXX==1 + { + ofstream ofs("exx_matrix.dat",ofstream::app); + static int istep=0; + ofs<<"istep:\t"<kv_ptr->nks; ++ik) + { + ofs<<"ik:\t"<kv_ptr->nks; ++ik) + { + ofs<<"ik:\t"< DM = {0,0}; + for( int ib=0; ibhvec_array[ik](iw_l,ib)) *k_pack->hvec_array[ik](iw_r,ib) *k_pack->wf_wg(ik,ib); + ofs<kv_ptr->nks; ++iq) + { + for( int ib=0; ibwf_wg(iq,ib)<<"\t"; + } + ofs_wf_wg<kv_ptr->nks; ++iq) + { + for( int iw=0; iwhvec_array[iq](iw,ib).real()<<" "<hvec_array[iq](iw,ib).imag()<<" "; + } + ofs_hvec<kv_ptr = new kvect(); + const string exx_kpoint_card = global_out_dir + exx_q_pack + global_kpoint_card; + q_pack->kv_ptr->set( symm, exx_kpoint_card, NSPIN, ucell_ptr->G, ucell_ptr->latvec ); +// q_pack->kv_ptr->set( symm, exx_kpoint_card, NSPIN, ucell_ptr->G, ucell_ptr->latvec, &Pkpoints ); + + + q_pack->wf_ptr = new wavefunc(); + q_pack->wf_ptr->init(q_pack->kv_ptr->nks); +// q_pack->wf_ptr->init(q_pack->kv_ptr->nks,q_pack->kv_ptr,ucell_ptr,pw_ptr,&ppcell,&ORB,&hm,&Pkpoints); + q_pack->wf_ptr->table_local.create(ucell.ntype, ucell.nmax_total, NQX); +// q_pack->wf_ptr->table_local.create(q_pack->wf_ptr->ucell_ptr->ntype, q_pack->wf_ptr->ucell_ptr->nmax_total, NQX); + Wavefunc_in_pw::make_table_q(ORB.orbital_file, q_pack->wf_ptr->table_local); +// Wavefunc_in_pw::make_table_q(q_pack->wf_ptr->ORB_ptr->orbital_file, q_pack->wf_ptr->table_local, q_pack->wf_ptr); + for(int iq=0; iqkv_ptr->nks; ++iq) + { + Wavefunc_in_pw::produce_local_basis_in_pw(iq, q_pack->wf_ptr->wanf2[iq], q_pack->wf_ptr->table_local); +// Wavefunc_in_pw::produce_local_basis_in_pw(iq, q_pack->wf_ptr->wanf2[iq], q_pack->wf_ptr->table_local, q_pack->wf_ptr); + } + + q_pack->wf_wg.create(q_pack->kv_ptr->nks,NBANDS); + if(!RANK_IN_POOL) + { + stringstream ss_wf_wg; + ss_wf_wg << global_out_dir << exx_q_pack << "wf_wg_" << MY_POOL; + ifstream ifs_wf_wg(ss_wf_wg.str().c_str()); + for( int iq = 0; iq < q_pack->kv_ptr->nks; ++iq) + { + for( int ib=0; ib>q_pack->wf_wg(iq,ib); + } + } + ifs_wf_wg.close(); + } + MPI_Bcast( q_pack->wf_wg.c, q_pack->kv_ptr->nks*NBANDS, MPI_DOUBLE, 0, POOL_WORLD); + + q_pack->hvec_array = new ComplexMatrix [q_pack->kv_ptr->nks]; + for( int iq=0; iqkv_ptr->nks; ++iq) + { + q_pack->hvec_array[iq].create(NLOCAL,NBANDS); + } + if(!RANK_IN_POOL) + { + stringstream ss_hvec; + ss_hvec << global_out_dir << exx_q_pack << "hvec_" << MY_POOL; + ifstream ifs_hvec(ss_hvec.str().c_str()); + for( int iq=0; iqkv_ptr->nks; ++iq) + { + for( int iw=0; iw>a>>b; + q_pack->hvec_array[iq](iw,ib) = {a,b}; + } + } + } + ifs_hvec.close(); + } + for( int iq=0; iqkv_ptr->nks; ++iq) + { + MPI_Bcast( q_pack->hvec_array[iq].c, NLOCAL*NBANDS, mpicomplex, 0, POOL_WORLD); + } + + return; +} + +/* +void Exx_Lip::write_q_pack() const +{ + + if( !RANK_IN_POOL ) + { + stringstream ssc; + ssc << global_out_dir << "exx_q_pack_" << MY_POOL; + ofstream ofs(ssc.str().c_str()); + if (!ofs) + { + WARNING("Exx_Lip::write_q_pack","Can't create Exx_Lip File!"); + } + + ofs<kv_ptr->nks<kv_ptr->nks; ++iq) + { + ofs<kv_ptr->ngk[iq]<<" "; + } + ofs<kv_ptr->nks; ++iq) + { + ofs<kv_ptr->nks; ++iq) + { + for( int ib=0; ibkv_ptr->nks; ++iq) + { + for( int iw=0; iw> q_pack->kv_ptr->nks; + } + + MPI_Bcast( &q_pack->kv_ptr->nks, 1, MPI_INT, 0, POOL_WORLD); + + q_pack->kv_ptr->ngk = new int [q_pack->kv_ptr->nks]; + q_pack.kvec_c = new Vector3 [q_pack->kv_ptr->nks]; + q_pack.kvec_d = new Vector3 [q_pack->kv_ptr->nks]; + double *kvec_tmp = new double [q_pack->kv_ptr->nks*6]; // just for MPI + q_pack.wf_wg = new double *[q_pack->kv_ptr->nks]; + for( int iq=0; iqkv_ptr->nks; ++iq) + { + q_pack.wf_wg[iq] = new double[NBANDS]; + } + q_pack.hvec_array = new ComplexMatrix [q_pack->kv_ptr->nks]; + for( int iq=0; iqkv_ptr->nks; ++iq) + { + q_pack.hvec_array[iq].create(NLOCAL,NBANDS); + } + + if( !RANK_IN_POOL ) + { + for( int iq = 0; iq < q_pack->kv_ptr->nks; ++iq) + { + ifs>>q_pack->kv_ptr->ngk[iq]; + } + for( int iq_tmp = 0; iq_tmp < q_pack->kv_ptr->nks*6; ++iq_tmp) + { + ifs>>kvec_tmp[iq_tmp]; + } + for( int iq = 0; iq < q_pack->kv_ptr->nks; ++iq) + { + for( int ib=0; ib>q_pack.wf_wg[iq][ib]; + } + } + for( int iq=0; iqkv_ptr->nks; ++iq) + { + for( int iw=0; iw>q_pack.hvec_array[iq](iw,ib).real()>>q_pack.hvec_array[iq](iw,ib).imag(); + } + } + } + ifs.close(); + } + + MPI_Bcast( q_pack->kv_ptr->ngk, q_pack->kv_ptr->nks, MPI_INT, 0, POOL_WORLD); + MPI_Bcast( kvec_tmp, q_pack->kv_ptr->nks*6, MPI_DOUBLE, 0, POOL_WORLD); + for( int iq=0; iqkv_ptr->nks; ++iq) + { + q_pack.kvec_c[iq].x = kvec_tmp[iq*6+0]; + q_pack.kvec_c[iq].y = kvec_tmp[iq*6+1]; + q_pack.kvec_c[iq].z = kvec_tmp[iq*6+2]; + q_pack.kvec_d[iq].x = kvec_tmp[iq*6+3]; + q_pack.kvec_d[iq].y = kvec_tmp[iq*6+4]; + q_pack.kvec_d[iq].z = kvec_tmp[iq*6+5]; + } + delete[] kvec_tmp; + for( int iq=0; iqkv_ptr->nks; ++iq) + { + MPI_Bcast( q_pack.wf_wg[iq], NBANDS, MPI_DOUBLE, 0, POOL_WORLD); + } + for( int iq=0; iqkv_ptr->nks; ++iq) + { + MPI_Bcast( q_pack.hvec_array[iq].c, NLOCAL*NBANDS, mpicomplex, 0, POOL_WORLD); + } + + + auto test_print = [&]() + { + stringstream sss; + sss << global_out_dir << "exx_q_pack_tmp" << MY_RANK; + ofstream ofs(sss.str().c_str()); + if (!ofs) + { + WARNING("Exx_Lip::write_q_pack","Can't create Exx_Lip File!"); + } + + ofs<kv_ptr->nks<kv_ptr->nks; ++iq) + { + ofs<kv_ptr->ngk[iq]<<" "; + } + ofs<kv_ptr->nks; ++iq) + { + ofs<kv_ptr->nks; ++iq) + { + for( int ib=0; ibkv_ptr->nks; ++iq) + { + for( int iw=0; iw * const * const * get_exx_matrix() const { return exx_matrix; } + double get_exx_energy() const { return exx_energy; } + + void write_q_pack() const; + +private: + + bool init_finish; + + int gzero_rank_in_pool; + + struct k_package + { + kvect *kv_ptr; + wavefunc *wf_ptr; + matrix wf_wg; + ComplexMatrix *hvec_array; + } *k_pack, *q_pack; + + int iq_vecik; + + complex **phi; + complex ***psi; + double *recip_qkg2; + double sum2_factor; + complex *b; + complex *b0; + complex *sum1; + complex **sum3; + + complex ***exx_matrix; + double exx_energy; + + void wf_wg_cal(); + void phi_cal(k_package *kq_pack, int ikq); + void psi_cal(); + void judge_singularity( int ik); + void qkg2_exp(int ik, int iq); + void b_cal(int ik, int iq, int ib); + void sum3_cal(int iq, int ib); + void b_sum(int iq, int ib); + void sum_all(int ik); + void exx_energy_cal(); + void read_q_pack(); + + friend void Hamilt_PW::cinitcgg(const int ik,const int nstart,const int n_band,const ComplexMatrix &psi,ComplexMatrix &evc,double *en); + +public: + PW_Basis *pw_ptr; + Use_FFT *UFFT_ptr; + UnitCell_pseudo *ucell_ptr; +}; + + +#endif diff --git a/ABACUS.1.0.0/source/src_pw/functional.cpp b/ABACUS.1.0.0/source/src_pw/functional.cpp index 11eb0dd777..f7a4b32958 100644 --- a/ABACUS.1.0.0/source/src_pw/functional.cpp +++ b/ABACUS.1.0.0/source/src_pw/functional.cpp @@ -4,6 +4,10 @@ //========================================================== #include "functional.h" +#include "src_global/global_function.h" +#include "src_pw/global.h" +#include "src_pw/exx_global.h" + xcfunc::xcfunc() { } @@ -211,6 +215,8 @@ void xcfunc::which_dft(const string *dft) // WRITE( stdout,'(a)') dftout copy_to_now(); + + hybrid_first(); return; } // end subroutine which_dft @@ -277,4 +283,26 @@ void xcfunc::copy_to_now() icorr_now = icorr; igcx_now = igcx ; igcc_now = igcc ; +} + +// Peize Lin add 2016-12-03 +void xcfunc::hybrid_first() +{ + // may do something + WARNING("functional","file "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)+" may error "); + if(Exx_Global::Hybrid_Type::HF==exx_global.info.hybrid_type) + { + iexch_now = 1; + igcx_now = 3; + } + else if(Exx_Global::Hybrid_Type::PBE0==exx_global.info.hybrid_type) + { + iexch_now = 1; + igcx_now = 3; + } + else if(Exx_Global::Hybrid_Type::HSE==exx_global.info.hybrid_type) + { + iexch_now = 1; + igcx_now = 3; + } } \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_pw/functional.h b/ABACUS.1.0.0/source/src_pw/functional.h index b5b5f14e17..ad0253f1cf 100644 --- a/ABACUS.1.0.0/source/src_pw/functional.h +++ b/ABACUS.1.0.0/source/src_pw/functional.h @@ -22,6 +22,9 @@ class xcfunc // "oep" Optimized Effective Potential iexch=4 // "hf" Hartree-Fock iexch=5 // "pb0x" PBE0 iexch=6 + // "b3lpx" B3LYP iexch=7 + // "kzk" Finite-size corrections iexch=8 + // "hsex" HSE06 iexch=9 // // Correlation: "noc" none icorr=0 // "pz" Perdew-Zunger icorr=1 (default) @@ -44,6 +47,10 @@ class xcfunc // "optx" Handy's exchange functional igcx =6 // "meta" meta-gga igcx =7 // "pb0x" PBE0 igcx =8 + // "b3lp" B3LYP igcx =9 + // "psx" PBEsol exchange igcx =10 + // "wcx" Wu-Cohen igcx =11 + // "hsex" HSE06 igcx =12 // // Gradient Correction on Correlation: // "nogc" none igcc =0 (default) @@ -55,20 +62,27 @@ class xcfunc // "meta" meta-gga igcc =6 // // Special cases: - // "bp" = "b88+p86" = Becke-Perdew grad.corr. - // "pw91" = "pw +ggx+ggc" = PW91 (aka GGA) - // "blyp" = "sla+b88+lyp+blyp"= BLYP - // "pbe" = "sla+pw+pbx+pbc" = PBE - // "revpbe"="sla+pw+rpb+pbc" = revPBE (Zhang-Yang) - // "hcth" = "nox+noc+hcth+hcth"=HCTH/120 - // "olyp" = "nox+lyp+optx+blyp" ////// UNTESTED ////// - + // "bp" = "b88+p86" = Becke-Perdew grad.corr. + // "pw91" = "pw +ggx+ggc" = PW91 (aka GGA) + // "blyp" = "sla+b88+lyp+blyp" = BLYP + // "pbe" = "sla+pw+pbx+pbc" = PBE + // "revpbe"= "sla+pw+rpb+pbc" = revPBE (Zhang-Yang) + // "pbesol"= "sla+pw+psx+psc" = PBEsol + // "hcth" = "nox+noc+hcth+hcth" = HCTH/120 + // "olyp" = "nox+lyp+optx+blyp"!!! UNTESTED !!! + // "tpss" = "sla+pw+meta+meta" = TPSS Meta-GGA + // "wc" = "sla+pw+wcx+pbc" = Wu-Cohen + // "pbe0" = "pb0x+pw+pb0x+pbc" = PBE0 + // "b3lyp" = "b3lp+vwn+b3lp+b3lp"= B3LYP + // "hse" = "hsex+pw+hsex+pbc" = HSE + + // References: // pz J.P.Perdew and A.Zunger, PRB 23, 5048 (1981) // vwn S.H.Vosko, L.Wilk, M.Nusair, Can.J.Phys. 58,1200(1980) - // wig E.P.Wigner, Trans. Faraday Soc. 34, 67 (1938) - // hl L.Hedin and B.I.Lundqvist, J. Phys. C4, 2064 (1971) - // gl O.Gunnarsson and B.I.Lundqvist, PRB 13, 4274 (1976) + // wig E.P.Wigner, Trans. Faraday Soc. 34, 67 (1938) + // hl L.Hedin and B.I.Lundqvist, J. Phys. C4, 2064 (1971) + // gl O.Gunnarsson and B.I.Lundqvist, PRB 13, 4274 (1976) // pw J.P.Perdew and Y.Wang, PRB 45, 13244 (1992) // obpz G.Ortiz and P.Ballone, PRB 50, 1391 (1994) // obpw as above @@ -76,10 +90,17 @@ class xcfunc // p86 J.P.Perdew, PRB 33, 8822 (1986) // pbe J.P.Perdew, K.Burke, M.Ernzerhof, PRL 77, 3865 (1996) // pw91 J.P.Perdew and Y. Wang, PRB 46, 6671 (1992) - // blyp C.Lee, W.Yang, R.G.Parr, PRB 37, 785 (1988) + // blyp C.Lee, W.Yang, R.G.Parr, PRB 37, 785 (1988) // hcth Handy et al, JCP 109, 6264 (1998) // olyp Handy et al, JCP 116, 5411 (2002) // revPBE Zhang and Yang, PRL 80, 890 (1998) + // meta J.Tao, J.P.Perdew, V.N.Staroverov, G.E. Scuseria,PRL 91, 146401 (2003) + // kzk H.Kwee, S. Zhang, H. Krakauer, PRL 100, 126404 (2008) + // pbe0 J.P.Perdew, M. Ernzerhof, K.Burke, JCP 105, 9982 (1996) + // b3lyp P.J. Stephens,F.J. Devlin,C.F. Chabalowski,M.J. Frisch J.Phys.Chem 98, 11623 (1994) + // pbesol J.P. Perdew et al., PRL 100, 136406 (2008) + // wc Z. Wu and R. E. Cohen, PRB 73, 235116 (2006) + // hse Paier J, Marsman M, Hummer K, et al, JPC 124(15): 154709 (2006) int iexch; int icorr; @@ -109,6 +130,7 @@ class xcfunc void set_dft_value(int &m,const int i); bool match_one(const string* dft, const string &name)const; void copy_to_now(); // Peize Lin add 2016-12-03 + void hybrid_first(); // Peize Lin add 2016-12-03 }; #endif //FUNCTION_H diff --git a/ABACUS.1.0.0/source/src_pw/gga_pw.cpp b/ABACUS.1.0.0/source/src_pw/gga_pw.cpp index ef47e8b81b..f3fe5c2909 100644 --- a/ABACUS.1.0.0/source/src_pw/gga_pw.cpp +++ b/ABACUS.1.0.0/source/src_pw/gga_pw.cpp @@ -9,9 +9,7 @@ void GGA_PW::gradcorr(double &etxc, double &vtxc, matrix &v) TITLE("GGA::gradcorr"); if (xcf.igcx_now == 0 && xcf.igcc_now == 0) - { return; - } bool igcc_is_lyp = false; if( xcf.igcc_now == 3 || xcf.igcc_now == 7) @@ -186,7 +184,7 @@ void GGA_PW::gradcorr(double &etxc, double &vtxc, matrix &v) if( rhotmp1[ir] < 0.0 ) segno = -1.0; XC_Functional::gcxc( arho, grho2a, sx, sc, v1x, v2x, v1c, v2c); - + // first term of the gradient correction: // D(rho*Exc)/D(rho) v(0, ir) += e2 * ( v1x + v1c ); @@ -251,7 +249,6 @@ void GGA_PW::gradcorr(double &etxc, double &vtxc, matrix &v) v2cud = 0.0; } - // first term of the gradient correction : D(rho*Exc)/D(rho) v(0,ir) = v(0,ir) + e2 * ( v1xup + v1cup ); v(1,ir) = v(1,ir) + e2 * ( v1xdw + v1cdw ); @@ -300,7 +297,6 @@ void GGA_PW::gradcorr(double &etxc, double &vtxc, matrix &v) for(int ir=0; ir 0 || istep > 0 || ntry > 0) { @@ -143,23 +143,23 @@ void Hamilt::diago( // we need to reorder the eigenvectors. } //else if ( DIAGO_TYPE=="dav" ) xiaohui modify 2013-09-02 - else if(KS_SOLVER=="dav") //xiaohui add 2013-09-02 - { - Diago_David david; - if(NPOL==1) david.diag(wf.evc[ik0], wf.ekb[ik], kv.ngk[ik], - NBANDS, precondition, DIAGO_DAVID_NDIM, - ETHR, DIAGO_CG_MAXITER, notconv, avg); - else{ - david.diag(wf.evc[ik0], wf.ekb[ik], wf.npwx*NPOL, - NBANDS, precondition, DIAGO_DAVID_NDIM, - ETHR, DIAGO_CG_MAXITER, notconv, avg); - } - } - else - { + else if(KS_SOLVER=="dav") //xiaohui add 2013-09-02 + { + Diago_David david; + if(NPOL==1) david.diag(wf.evc[ik0], wf.ekb[ik], kv.ngk[ik], + NBANDS, precondition, DIAGO_DAVID_NDIM, + ETHR, DIAGO_CG_MAXITER, notconv, avg); + else{ + david.diag(wf.evc[ik0], wf.ekb[ik], wf.npwx*NPOL, + NBANDS, precondition, DIAGO_DAVID_NDIM, + ETHR, DIAGO_CG_MAXITER, notconv, avg); + } + } + else + { //WARNING_QUIT("calculate_bands","Check DIAGO_TYPE !"); xiaohui modify 2013-09-02 - WARNING_QUIT("calculate_bands","Check KS_SOLVER !"); //xiaohui add 2013-09-02 - } + WARNING_QUIT("calculate_bands","Check KS_SOLVER !"); //xiaohui add 2013-09-02 + } avg_iter += avg; ++ntry; } diff --git a/ABACUS.1.0.0/source/src_pw/hamilt_pw.cpp b/ABACUS.1.0.0/source/src_pw/hamilt_pw.cpp index f5f7052a81..be6f0a10da 100644 --- a/ABACUS.1.0.0/source/src_pw/hamilt_pw.cpp +++ b/ABACUS.1.0.0/source/src_pw/hamilt_pw.cpp @@ -160,8 +160,9 @@ void Hamilt_PW::cinitcgg( for(int i=0; i[wf.npwx*NPOL]; - else p[i] = new complex[wf.npwx]; + p[i] = new complex[wf.npwx*NPOL]; + else + p[i] = new complex[wf.npwx]; } for(int i=0; ihvec_array[ik] = hvec; + break; + } + //cout << "\n <2> pw.gcar[0] = " << " " << pw.gcar[0].x << " " << pw.gcar[0].y << " " << pw.gcar[0].z << endl; //======================= //diagonize the H-matrix @@ -572,15 +600,15 @@ void Hamilt_PW::add_vuspsi(complex *hpsi_in,const complex *becp) { for (int ip2=0; ip2Ps[sum+ip2] += ppcell.deeq(CURRENT_SPIN, iat, ip, ip2) * becp[sum+ip]; - else - { - this->Ps[sum+ ip2*2] += ppcell.deeq_nc(0, iat, ip2, ip) * becp[sum+ip*2] - +ppcell.deeq_nc(1, iat, ip2, ip) * becp[sum+ip*2+1]; - this->Ps[sum+ ip2*2+1] += ppcell.deeq_nc(2, iat, ip2, ip) * becp[sum+ip*2] - +ppcell.deeq_nc(3, iat, ip2, ip) * becp[sum+ip*2+1]; - } + if(!NONCOLIN) + this->Ps[sum+ip2] += ppcell.deeq(CURRENT_SPIN, iat, ip, ip2) * becp[sum+ip]; + else + { + this->Ps[sum+ ip2*2] += ppcell.deeq_nc(0, iat, ip2, ip) * becp[sum+ip*2] + +ppcell.deeq_nc(1, iat, ip2, ip) * becp[sum+ip*2+1]; + this->Ps[sum+ ip2*2+1] += ppcell.deeq_nc(2, iat, ip2, ip) * becp[sum+ip*2] + +ppcell.deeq_nc(3, iat, ip2, ip) * becp[sum+ip*2+1]; + } }// end ih }//end jh if(!NONCOLIN) sum += Nprojs; @@ -602,31 +630,31 @@ void Hamilt_PW::add_vuspsi(complex *hpsi_in,const complex *becp) // use simple method. if(!NONCOLIN) - for(int i=0; i* p = &ppcell.vkb(i,0); - complex* p_end = p + wf.npw; - complex* hp = hpsi_in; - complex* psp = &Ps[i]; - for (;p* p = &ppcell.vkb(i,0); + complex* p_end = p + wf.npw; + complex* hp = hpsi_in; + complex* psp = &Ps[i]; + for (;p* p = &ppcell.vkb(i,0); - complex* p_end = p + wf.npw; - complex* hp = hpsi_in; - complex* hp1 = hpsi_in + wf.npwx; - complex* psp = &Ps[i*2]; - for (;p* p = &ppcell.vkb(i,0); + complex* p_end = p + wf.npw; + complex* hp = hpsi_in; + complex* hp1 = hpsi_in + wf.npwx; + complex* psp = &Ps[i*2]; + for (;pPs , 1, ppcell.vkb, // ppcell.nkb, ONE, hpsi , 1); diff --git a/ABACUS.1.0.0/source/src_pw/ions.cpp b/ABACUS.1.0.0/source/src_pw/ions.cpp index 66c75f1220..d8f5a2f15c 100644 --- a/ABACUS.1.0.0/source/src_pw/ions.cpp +++ b/ABACUS.1.0.0/source/src_pw/ions.cpp @@ -102,7 +102,34 @@ void Ions::opt_ions_pw(void) if (CALCULATION=="scf" || CALCULATION=="md" || CALCULATION=="relax" || CALCULATION=="cell-relax") // pengfei 2014-10-13 { - this->self_consistent(istep-1); + if( Exx_Global::Hybrid_Type::No==exx_global.info.hybrid_type ) + { + this->self_consistent(istep-1); + } + else if( Exx_Global::Hybrid_Type::Generate_Matrix == exx_global.info.hybrid_type ) + { + throw invalid_argument(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + } + else // Peize Lin add 2019-03-09 + { + if( exx_global.info.separate_loop ) + { + for( size_t hybrid_step=0; hybrid_step!=exx_global.info.hybrid_step; ++hybrid_step ) + { + this->self_consistent(istep-1); + if( electrons::iter==1 || hybrid_step==exx_global.info.hybrid_step-1 ) // exx converge + break; + exx_global.info.set_xcfunc(xcf); + exx_lip.cal_exx(); + } + } + else + { + this->self_consistent(istep-1); + exx_global.info.set_xcfunc(xcf); + this->self_consistent(istep-1); + } + } } else if(CALCULATION=="nscf") { diff --git a/ABACUS.1.0.0/source/src_pw/mdNVE.cpp b/ABACUS.1.0.0/source/src_pw/mdNVE.cpp index 98f09b82eb..4345c81a30 100644 --- a/ABACUS.1.0.0/source/src_pw/mdNVE.cpp +++ b/ABACUS.1.0.0/source/src_pw/mdNVE.cpp @@ -224,21 +224,6 @@ void mdNVE::runNVE(int step1){ printRDF(step1); }*/ -//test -{ - Matrix3 a(1.1,2.2,3.3,4.4,5.1,6.2,7.3,8.4,9.9); -// Matrix3 a(1,0,0,0,4,0,0,0,9); - Vector3 b(1,1,1),c; - Mathzone::Cartesian_to_Direct(b.x,b.y,b.z, - a.e11,a.e12,a.e13, - a.e21,a.e22,a.e23, - a.e31,a.e32,a.e33, - c.x,c.y,c.z ); - cout<<"test-c "<v_xc(rho_in, etxc, vtxc, v_in); - + #endif //---------------------------------------------------------- // calculate the Hartree potential @@ -594,10 +599,10 @@ void potential::v_h(int NSPIN,double &ehart, matrix &v, double** rho) //========================================== if(NSPIN==4) - for (int ir = 0;ir < pw.nrxx;ir++) - { - v(0, ir) += Porter[ir].real(); - } + for (int ir = 0;ir < pw.nrxx;ir++) + { + v(0, ir) += Porter[ir].real(); + } else for (int is = 0;is < NSPIN;is++) { @@ -816,17 +821,17 @@ void potential::set_vrs(const bool doublegrid) //================================================================= // define the total local potential (external + scf) for each spin //================================================================= - if(NSPIN==4&&is>0) - for (int i = 0;i < pw.nrxx;i++) - { - this->vrs(is, i) = this->vr(is, i); - } - else - for (int i = 0;i < pw.nrxx;i++) - { - this->vrs(is, i) = this->vltot[i] + this->vr(is, i); -// cout <<"i: "<< i <<" "<< "vrs: " << vrs(is,i) <0) + for (int i = 0;i < pw.nrxx;i++) + { + this->vrs(is, i) = this->vr(is, i); + } + else + for (int i = 0;i < pw.nrxx;i++) + { + this->vrs(is, i) = this->vltot[i] + this->vr(is, i); + // cout <<"i: "<< i <<" "<< "vrs: " << vrs(is,i) <(0.0 , 0.0); - ppcell.deeq_nc(is, iat, jh, ih) = complex(0.0 , 0.0); - } - else if(is==2) - { - ppcell.deeq_nc(is, iat, ih, jh) = complex(0.0 , 0.0); - ppcell.deeq_nc(is, iat, jh, ih) = complex(0.0 , 0.0); - } - else if(is==3) - { - ppcell.deeq_nc(is, iat, ih, jh) = ppcell.dvan(it, ih, jh); - ppcell.deeq_nc(is, iat, jh, ih) = ppcell.dvan(it, ih, jh); - } - } - else{ - ppcell.deeq(is, iat, ih, jh) = ppcell.dvan(it, ih, jh); - ppcell.deeq(is, iat, jh, ih) = ppcell.dvan(it, ih, jh); - } + if(LSPINORB) + { + ppcell.deeq_nc(is , iat , ih , jh)= ppcell.dvan_so(is , it , ih , jh); + ppcell.deeq_nc(is , iat , jh , ih)= ppcell.dvan_so(is , it , jh , ih); + } + else if( NONCOLIN ) + { + if(is==0) + { + ppcell.deeq_nc(is, iat, ih, jh) = ppcell.dvan(it, ih, jh); + ppcell.deeq_nc(is, iat, jh, ih) = ppcell.dvan(it, ih, jh); + } + else if(is==1) + { + ppcell.deeq_nc(is, iat, ih, jh) = complex(0.0 , 0.0); + ppcell.deeq_nc(is, iat, jh, ih) = complex(0.0 , 0.0); + } + else if(is==2) + { + ppcell.deeq_nc(is, iat, ih, jh) = complex(0.0 , 0.0); + ppcell.deeq_nc(is, iat, jh, ih) = complex(0.0 , 0.0); + } + else if(is==3) + { + ppcell.deeq_nc(is, iat, ih, jh) = ppcell.dvan(it, ih, jh); + ppcell.deeq_nc(is, iat, jh, ih) = ppcell.dvan(it, ih, jh); + } + } + else{ + ppcell.deeq(is, iat, ih, jh) = ppcell.dvan(it, ih, jh); + ppcell.deeq(is, iat, jh, ih) = ppcell.dvan(it, ih, jh); + } } } } diff --git a/ABACUS.1.0.0/source/src_pw/potential_libxc.cpp b/ABACUS.1.0.0/source/src_pw/potential_libxc.cpp new file mode 100644 index 0000000000..d845dccbea --- /dev/null +++ b/ABACUS.1.0.0/source/src_pw/potential_libxc.cpp @@ -0,0 +1,276 @@ +#include "potential_libxc.h" +#include "src_pw/global.h" +#include "src_lcao/global_fp.h" +#include "src_pw/tools.h" +#include "src_global/global_function.h" +#include "src_pw/gga_pw.h" + +void Potential_Libxc::v_xc( + const double * const * const rho_in, + double &etxc, + double &vtxc, + matrix &v) +{ + TITLE("potential","v_xc"); + timer::tick("Potential_Libxc","v_xc"); + + etxc = 0.0; + vtxc = 0.0; + v.zero_out(); + + vector funcs = init_func(); + + const auto input_tmp = cal_input( funcs, rho_in ); + const vector &rho = std::get<0>(input_tmp); + const vector &sigma = std::get<1>(input_tmp); + + for( XC(func_type) &func : funcs ) + { + vector exc ( pw.nrxx ); + vector vrho ( pw.nrxx * NSPIN ); + vector vsigma( pw.nrxx * ((1==NSPIN)?1:3) ); + + auto process_exc = [&]() + { + for( size_t is=0; is!=NSPIN; ++is ) + for( size_t ir=0; ir!=pw.nrxx; ++ir ) + etxc += e2 * exc[ir] * rho[ir*NSPIN+is]; + }; + auto process_vrho = [&]() + { + for( size_t is=0; is!=NSPIN; ++is ) + for( size_t ir=0; ir!=pw.nrxx; ++ir ) + { + v(is,ir) += e2 * vrho[ir*NSPIN+is]; + vtxc += e2 * vrho[ir*NSPIN+is] * rho_in[is][ir]; + } + }; + auto process_vsigma = [&]() + { + const std::vector>> &gdr = std::get<2>(input_tmp); + + vector>> h( NSPIN, vector>(pw.nrxx) ); + if( 1==NSPIN ) + for( size_t ir=0; ir!=pw.nrxx; ++ir ) + h[0][ir] = e2 * gdr[0][ir] * vsigma[ir]; + else + for( size_t ir=0; ir!=pw.nrxx; ++ir ) + { + h[0][ir] = e2 * gdr[0][ir] * vsigma[ir*3 ] + gdr[1][ir] * vsigma[ir*3+1]; + h[1][ir] = e2 * gdr[1][ir] * vsigma[ir*3+2] + gdr[0][ir] * vsigma[ir*3+1]; + } + for( size_t is=0; is!=NSPIN; ++is ) + { + vector dh(pw.nrxx); + GGA_PW::grad_dot( VECTOR_TO_PTR(h[is]), VECTOR_TO_PTR(dh) ); + for( size_t ir=0; ir!=pw.nrxx; ++ir ) + { + v(is,ir) -= e2 * dh[ir]; + vtxc -= e2 * dh[ir] * rho_in[is][ir]; + } + } + }; + + switch( func.info->family ) + { + case XC_FAMILY_LDA: + XC(lda_exc_vxc)( &func, pw.nrxx,VECTOR_TO_PTR(rho), VECTOR_TO_PTR(exc), VECTOR_TO_PTR(vrho) ); + process_exc(); + process_vrho(); + break; + case XC_FAMILY_GGA: + case XC_FAMILY_HYB_GGA: + XC(gga_exc_vxc)( &func, pw.nrxx, VECTOR_TO_PTR(rho), VECTOR_TO_PTR(sigma), VECTOR_TO_PTR(exc), VECTOR_TO_PTR(vrho), VECTOR_TO_PTR(vsigma) ); + process_exc(); + process_vrho(); + process_vsigma(); + break; + default: + throw domain_error("func.info->family ="+TO_STRING(func.info->family)+" unfinished "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + break; + } + + XC(func_end)(&func); + } + + Parallel_Reduce::reduce_double_pool( etxc ); + Parallel_Reduce::reduce_double_pool( vtxc ); + + etxc *= ucell.omega / pw.ncxyz; + vtxc *= ucell.omega / pw.ncxyz; + + timer::tick("Potential_Libxc","v_xc"); + return; +} + + + +std::vector Potential_Libxc::init_func() +{ + auto test_parameter_PBE0 = [&]() + { + TITLE("test_parameter_PBE0"); + XC(func_type) func; + XC(func_init)( &func, XC_HYB_GGA_XC_PBEH, XC_POLARIZED ); + + cout< funcs; + + const int xc_polarized = (1==NSPIN) ? XC_UNPOLARIZED : XC_POLARIZED; + + auto add_func = [&]( const int function ) + { + funcs.push_back({}); + XC(func_init)( &funcs.back(), function, xc_polarized ); + }; + + if( 6==xcf.iexch_now && 8==xcf.igcx_now && 4==xcf.icorr_now && 4==xcf.igcc_now ) + { + add_func( XC_HYB_GGA_XC_PBEH ); + double parameter_hse[3] = { exx_global.info.hybrid_alpha, exx_global.info.hse_omega, exx_global.info.hse_omega }; + xc_func_set_ext_params(&funcs.back(), parameter_hse); + return funcs; + } + else if( 9==xcf.iexch_now && 12==xcf.igcx_now && 4==xcf.icorr_now && 4==xcf.igcc_now ) + { + add_func( XC_HYB_GGA_XC_HSE06 ); + double parameter_hse[3] = { exx_global.info.hybrid_alpha, exx_global.info.hse_omega, exx_global.info.hse_omega }; + xc_func_set_ext_params(&funcs.back(), parameter_hse); + return funcs; + } + + if( 1==xcf.iexch_now && 0==xcf.igcx_now ) + add_func( XC_LDA_X ); + else if( 1==xcf.iexch_now && 3==xcf.igcx_now ) + add_func( XC_GGA_X_PBE ); + else + throw domain_error("iexch="+TO_STRING(xcf.iexch_now)+", igcx="+TO_STRING(xcf.igcx_now)+" unfinished"); + + if( 1==xcf.icorr_now && 0==xcf.igcc_now ) + add_func( XC_LDA_C_PZ ); + else if( 4==xcf.icorr_now && 4==xcf.igcc_now ) + add_func( XC_GGA_C_PBE ); + else + throw domain_error("icorr="+TO_STRING(xcf.icorr_now)+", igcc="+TO_STRING(xcf.igcc_now)+" unfinished"); + + return funcs; +} + + + +std::tuple< std::vector, std::vector, std::vector>> > +Potential_Libxc::cal_input( + const std::vector &funcs, + const double * const * const rho_in ) +{ + // ..., ↑_{i},↓_{i}, ↑_{i+1},↓_{i+1}, ... + std::vector rho; + // ..., ↑↑_{i},↑↓_{i},↓↓_{i}, ↑↑_{i+1},↑↓_{i+1},↓↓_{i+1}, ... + std::vector sigma; + // [...,↑_{i},↑_{i+1},...], [...,↓_{i},↓_{i+1},...] + std::vector>> gdr; + + bool finished_rho = false; + bool finished_gdr = false; + bool finished_sigma = false; + + auto cal_rho = [&]() + { + if(!finished_rho) + { + rho.resize( pw.nrxx * NSPIN ); + for( size_t is=0; is!=NSPIN; ++is ) + for( size_t ir=0; ir!=pw.nrxx; ++ir ) + { + rho[ir*NSPIN+is] = rho_in[is][ir] + 1.0/NSPIN*chr.rho_core[ir]; + } + } + finished_rho = true; + }; + + auto cal_gdr = [&]() + { + if(!finished_gdr) + { + for( size_t is=0; is!=NSPIN; ++is ) + chr.set_rhog(chr.rho[is], chr.rhog[is]); + chr.set_rhog(chr.rho_core, chr.rhog_core); + + gdr.resize( NSPIN ); + for( size_t is=0; is!=NSPIN; ++is ) + { + vector>rhog(pw.ngmc); + for(int ig=0; igfamily ) + { + case XC_FAMILY_LDA: + cal_rho(); + break; + case XC_FAMILY_GGA: + case XC_FAMILY_HYB_GGA: + cal_rho(); + cal_gdr(); + cal_sigma(); + break; + default: + throw domain_error("func.info->family ="+TO_STRING(func.info->family)+" unfinished "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + break; + } + } + + return std::make_tuple( rho, sigma, gdr ); +} diff --git a/ABACUS.1.0.0/source/src_pw/potential_libxc.h b/ABACUS.1.0.0/source/src_pw/potential_libxc.h new file mode 100644 index 0000000000..c270dd47c2 --- /dev/null +++ b/ABACUS.1.0.0/source/src_pw/potential_libxc.h @@ -0,0 +1,28 @@ +#ifndef POTENTIAL_LIBXC_H +#define POTENTIAL_LIBXC_H + +#include "src_global/matrix.h" +#include "src_global/vector3.h" +#include +#include +#include + +class Potential_Libxc +{ + public: + static void v_xc( + const double * const * const rho_in, + double &etxc, + double &vtxc, + matrix &v); + + private: + static std::vector init_func(); + // [ rho, sigma, gdr ] + static std::tuple< std::vector, std::vector, std::vector>> > + cal_input( + const std::vector &funcs, + const double * const * const rho_in ); +}; + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_pw/unitcell.cpp b/ABACUS.1.0.0/source/src_pw/unitcell.cpp index 9d6e4980d0..21dd2cd672 100644 --- a/ABACUS.1.0.0/source/src_pw/unitcell.cpp +++ b/ABACUS.1.0.0/source/src_pw/unitcell.cpp @@ -28,6 +28,7 @@ UnitCell::UnitCell() iat2it = new int[1]; iat2ia = new int[1]; iwt2iat = new int[1]; + iwt2iw = new int[1]; itia2iat.create(1,1); lc = new int[3]; @@ -55,6 +56,7 @@ UnitCell::~UnitCell() delete[] iat2it; delete[] iat2ia; delete[] iwt2iat; + delete[] iwt2iw; } diff --git a/ABACUS.1.0.0/source/src_pw/unitcell.h b/ABACUS.1.0.0/source/src_pw/unitcell.h index f45c732b95..8ad8b122b1 100644 --- a/ABACUS.1.0.0/source/src_pw/unitcell.h +++ b/ABACUS.1.0.0/source/src_pw/unitcell.h @@ -53,6 +53,7 @@ class UnitCell int *iat2it; //iat==>it, distinguish a atom belong to which type int *iat2ia; //iat==>ia int *iwt2iat; // iwt ==> iat. + int *iwt2iw; // iwt ==> iw, Peize Lin add 2018-07-02 IntArray itia2iat;//(it, ia)==>iat, the index in nat, add 2009-3-2 by mohan IntArray itiaiw2iwt;//(it, ia, iw)==>iwt, the index in nwfc, add 2009-3-2 by mohan //LiuXh add 20180515 diff --git a/ABACUS.1.0.0/source/src_pw/unitcell_pseudo.cpp b/ABACUS.1.0.0/source/src_pw/unitcell_pseudo.cpp index 069da37f2b..6d50e8f6aa 100644 --- a/ABACUS.1.0.0/source/src_pw/unitcell_pseudo.cpp +++ b/ABACUS.1.0.0/source/src_pw/unitcell_pseudo.cpp @@ -140,11 +140,11 @@ void UnitCell_pseudo::setup_cell( this->G = GT.Transpose(); this->GGT = G * GT; this->invGGT = GGT.Inverse(); - //LiuXh add 20180515 - this->GT0 = latvec.Inverse(); - this->G0 = GT.Transpose(); - this->GGT0 = G * GT; - this->invGGT0 = GGT.Inverse(); + //LiuXh add 20180515 + this->GT0 = latvec.Inverse(); + this->G0 = GT.Transpose(); + this->GGT0 = G * GT; + this->invGGT0 = GGT.Inverse(); ofs_running << endl; out.printM3(ofs_running,"Lattice vectors: (Cartesian coordinate: in unit of a_0)",latvec); @@ -353,6 +353,22 @@ void UnitCell_pseudo::read_atom_species(ifstream &ifa) } #endif + // Peize Lin add 2016-09-23 + if( Exx_Global::Hybrid_Type::HF == exx_lcao.info.hybrid_type || + Exx_Global::Hybrid_Type::PBE0 == exx_lcao.info.hybrid_type || + Exx_Global::Hybrid_Type::HSE == exx_lcao.info.hybrid_type ) + { + if( SCAN_BEGIN(ifa, "ABFS_ORBITAL") ) + { + for(int i=0; i> ofile; + exx_lcao.info.files_abfs.push_back(ofile); + } + } + } + //========================== // read in lattice constant //========================== @@ -1285,7 +1301,7 @@ void UnitCell_pseudo::cal_nwfc() { atoms[it].stapos_wf = NLOCAL; const int nlocal_it = atoms[it].nw * atoms[it].na; - if(!NONCOLIN) NLOCAL += nlocal_it; + if(!NONCOLIN) NLOCAL += nlocal_it; else NLOCAL += nlocal_it * 2;//zhengdy-soc // stringstream ss1; // ss1 << "number of local orbitals for species " << it; @@ -1307,7 +1323,9 @@ void UnitCell_pseudo::cal_nwfc() // mohan add 2010-09-26 assert(NLOCAL>0); delete[] iwt2iat; + delete[] iwt2iw; this->iwt2iat = new int[NLOCAL]; + this->iwt2iw = new int[NLOCAL]; this->itia2iat.create(ntype, namax); this->itiaiw2iwt.create(ntype, namax, nwmax); @@ -1323,6 +1341,7 @@ void UnitCell_pseudo::cal_nwfc() { this->itiaiw2iwt(it, ia, iw) = iwt; this->iwt2iat[iwt] = iat; + this->iwt2iw[iwt] = iw; ++iwt; } ++iat; diff --git a/ABACUS.1.0.0/source/src_pw/unitcell_pseudo.h b/ABACUS.1.0.0/source/src_pw/unitcell_pseudo.h index 4578d28500..78c5393039 100644 --- a/ABACUS.1.0.0/source/src_pw/unitcell_pseudo.h +++ b/ABACUS.1.0.0/source/src_pw/unitcell_pseudo.h @@ -39,7 +39,7 @@ class UnitCell_pseudo : public UnitCell void print_tau(void)const; void print_stru_file(const string &fn, const int &type=1)const; // mohan add 2011-03-22 void check_dtau(void); - void setup_cell_after_vc(const string &s_pseudopot_dir, const string &fn, ofstream &log); //LiuXh add 20180515 + void setup_cell_after_vc(const string &s_pseudopot_dir, const string &fn, ofstream &log); //LiuXh add 20180515 private: // member variables bool set_atom_flag;//added on 2009-3-8 by mohan diff --git a/ABACUS.1.0.0/source/src_pw/wavefunc.cpp b/ABACUS.1.0.0/source/src_pw/wavefunc.cpp index f3e7965f61..42d2a67823 100644 --- a/ABACUS.1.0.0/source/src_pw/wavefunc.cpp +++ b/ABACUS.1.0.0/source/src_pw/wavefunc.cpp @@ -418,6 +418,7 @@ void wavefunc::wfcinit_k(void) this->diago_PAO_in_pw_k(ik, wf.evc[ik]); } } + //--------------------------------------------------- // calculte the overlap //--------------------------------------------------- @@ -573,7 +574,7 @@ void wavefunc::wfcinit_k(void) { arg = gkqg * Rcar[iw1][iw2][ir] * TWO_PI; phase = complex( cos(arg), -sin(arg) ); - overlap_aux[iw1][iw2][g][ir] += conj(wf.wanf2[ik](iw1,ig)) * wanf2_q[ik][iw2][ig] * phase/kv.nks; + overlap_aux[iw1][iw2][g][ir] += conj(wf.wanf2[ik](iw1,ig)) * wanf2_q[ik][iw2][ig] * phase/static_cast(kv.nks); // Peize Lin add static_cast 2018-07-14 } } diff --git a/ABACUS.1.0.0/source/src_pw/wavefunc.h b/ABACUS.1.0.0/source/src_pw/wavefunc.h index 73eca11a20..dcfa6cfa33 100644 --- a/ABACUS.1.0.0/source/src_pw/wavefunc.h +++ b/ABACUS.1.0.0/source/src_pw/wavefunc.h @@ -50,15 +50,15 @@ class wavefunc : public WF_atomic void prepare_k(void); void diago_PAO_in_pw_k2(const int &ik, ComplexMatrix &wvf); - int get_R(int ix, int iy, int iz); // pengfei 2016-11-23 - int iw2it( int iw); - int iw2ia( int iw); + int get_R(int ix, int iy, int iz); // pengfei 2016-11-23 + int iw2it( int iw); + int iw2ia( int iw); void init_after_vc(const int nks); //LiuXh 20180515 - private: // pengfei 2016-11-23 + private: // pengfei 2016-11-23 - Vector3 ***R; - int ** Rmax; + Vector3 ***R; + int ** Rmax; }; diff --git a/ABACUS.1.0.0/source/src_pw/wavefunc_in_pw.cpp b/ABACUS.1.0.0/source/src_pw/wavefunc_in_pw.cpp index 007ae6f771..e9c6d812c6 100644 --- a/ABACUS.1.0.0/source/src_pw/wavefunc_in_pw.cpp +++ b/ABACUS.1.0.0/source/src_pw/wavefunc_in_pw.cpp @@ -342,130 +342,129 @@ cout<<"N: "< fup,fdown; - int nc; - //This routine creates two functions only in the case j=l+1/2 or exit in the other case - if(fabs(j-L+0.5<1e-4)) continue; - delete[] chiaux; - chiaux = new double [npw]; - //Find the functions j= l- 1/2 - if(L==0) - for(int ig=0;igucell.natomwfc) WARNING_QUIT("wf.atomic_wfc()","error: too many wfcs"); - for(int ig = 0;ig fup, fdown; - alpha = soc.angle1[it]; - gamman = -soc.angle2[it] + 0.5*PI; - for(int m = 0;m<2*L+1;m++) - { - const int lm = L*L +m; - if(iwall+2*L+1>ucell.natomwfc) WARNING_QUIT("wf.atomic_wfc()","error: too many wfcs"); - for(int ig = 0;ig fup,fdown; + int nc; + //This routine creates two functions only in the case j=l+1/2 or exit in the other case + if(fabs(j-L+0.5<1e-4)) continue; + delete[] chiaux; + chiaux = new double [npw]; + //Find the functions j= l- 1/2 + if(L==0) + for(int ig=0;igucell.natomwfc) WARNING_QUIT("wf.atomic_wfc()","error: too many wfcs"); + for(int ig = 0;ig fup, fdown; + alpha = soc.angle1[it]; + gamman = -soc.angle2[it] + 0.5*PI; + for(int m = 0;m<2*L+1;m++) + { + const int lm = L*L +m; + if(iwall+2*L+1>ucell.natomwfc) WARNING_QUIT("wf.atomic_wfc()","error: too many wfcs"); + for(int ig = 0;ig ((NQX-4) * DQ) ) - { - flq[ig] = 0.0; - } - else - { + if(gkq[ig].norm() * ucell.tpiba > ((NQX-4) * DQ) ) + { + flq[ig] = 0.0; + } + else + { flq[ig] = Mathzone::Polynomial_Interpolation(table_local, it, ic, NQX, DQ, gkq[ig].norm() * ucell.tpiba ); - } + } } - if(NONCOLIN) { - for(int is_N = 0; is_N < 2; is_N++) - { - if(L==0&&is_N==1) continue; - if(ucell.atoms[it].has_so) - { - const double j = double(L+is_N) - 0.5; - if (INPUT.starting_spin_angle|| !DOMAG) - {//atomic_wfc_so - double fact[2]; - for(int m=-L-1;m1e-8||fabs(fact[1])>1e-8) - { - for(int is=0;is<2;is++) - { - if(fabs(fact[is])>1e-8) - { - const int ind = ppcell.lmaxkb + soc.sph_ind(L,j,m,is); - ZEROS(aux, npw); - for(int n1=0;n1<2*L+1;n1++){ - const int lm = L*L +n1; - if(fabs(soc.rotylm(n1,ind))>1e-8) - for(int ig=0; ig(0.0 , 0.0); - }//is - iwall++; - }//if - }//m - }//if - else - {//atomic_wfc_so_mag - - double alpha, gamma; - complex fup,fdown; - int nc; - //This routine creates two functions only in the case j=l+1/2 or exit in the other case - if(fabs(j-L+0.5<1e-4)) continue; - delete[] chiaux; - chiaux = new double [npw]; - //Find the functions j= l- 1/2 - if(L==0) - for(int ig=0;igucell.natomwfc) WARNING_QUIT("wf.atomic_wfc()","error: too many wfcs"); - for(int ig = 0;ig fup, fdown; - alpha = soc.angle1[it]; - gamman = -soc.angle2[it] + 0.5*PI; - for(int m = 0;m<2*L+1;m++) - { - const int lm = L*L +m; - // if(iwall+2*l+1>ucell.natomwfc) WARNING_QUIT("wf.atomic_wfc()","error: too many wfcs"); - for(int ig = 0;ig1e-8||fabs(fact[1])>1e-8) + { + for(int is=0;is<2;is++) + { + if(fabs(fact[is])>1e-8) + { + const int ind = ppcell.lmaxkb + soc.sph_ind(L,j,m,is); + ZEROS(aux, npw); + for(int n1=0;n1<2*L+1;n1++){ + const int lm = L*L +n1; + if(fabs(soc.rotylm(n1,ind))>1e-8) + for(int ig=0; ig(0.0 , 0.0); + }//is + iwall++; + }//if + }//m + }//if + else + {//atomic_wfc_so_mag + + double alpha, gamma; + complex fup,fdown; + int nc; + //This routine creates two functions only in the case j=l+1/2 or exit in the other case + if(fabs(j-L+0.5<1e-4)) continue; + delete[] chiaux; + chiaux = new double [npw]; + //Find the functions j= l- 1/2 + if(L==0) + for(int ig=0;igucell.natomwfc) WARNING_QUIT("wf.atomic_wfc()","error: too many wfcs"); + for(int ig = 0;ig fup, fdown; + alpha = soc.angle1[it]; + gamman = -soc.angle2[it] + 0.5*PI; + for(int m = 0;m<2*L+1;m++) + { + const int lm = L*L +m; + // if(iwall+2*l+1>ucell.natomwfc) WARNING_QUIT("wf.atomic_wfc()","error: too many wfcs"); + for(int ig = 0;igLog.txt 2>&1 &') + else: + raise ValueError("utils.sub") + os.chdir("../") + +if __name__=="__main__": + cal() \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py b/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py new file mode 100644 index 0000000000..26b4989420 --- /dev/null +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py @@ -0,0 +1,99 @@ +import json +import os +import re +import textwrap +import read_stru +import utils + +def cp_matrix(folders_matrix): + os.mkdir(utils.folder_opt+"/"+utils.folder_opt_matrix) + folders_same_atom = set() + for folder_matrix in folders_matrix: + T1,T2 = folder_matrix.split("_")[0].split("-") + dis = float(folder_matrix.split("_")[1]) + if dis: + if T1==T2: + matrix_file = "matrix_0_0_0_1" + else: + matrix_file = "matrix_0_0_1_0" + else: + matrix_file = "matrix_0_0_0_0" + os.system(f"cp {folder_matrix}/{matrix_file} {utils.folder_opt}/{utils.folder_opt_matrix}/{folder_matrix}") + +def add_nbands(folders_matrix): + for folder_matrix in folders_matrix: + with open(f"{utils.folder_opt}/{utils.folder_opt_matrix}/{folder_matrix}","r") as file: + nband = int(re.compile(r"(\d+)\s+nbands").search(file.read()).group(1)) + folders_matrix[folder_matrix] = (folders_matrix[folder_matrix], nband) + +def set_input(folders_matrix): + Ts = read_stru.get_T() + input_dict = read_stru.get_input_dict() + Ecut = float(input_dict["ecutwfc"]) + info = utils.read_info() + input = { + "file_list": [f"{utils.folder_opt_matrix}/"+folder_matrix for folder_matrix in folders_matrix], + "info": + { + "Nt_all": Ts, + "Nu": {T:info["Nu"] for T in Ts}, + "Nb_true": [nbands for weight,nbands in folders_matrix.values()], + "weight": [weight for weight,nbands in folders_matrix.values()], + "Rcut": read_stru.get_Rcut(), + "dr": {T:utils.dr for T in Ts}, + "Ecut": {T:Ecut for T in Ts}, + "TSrate": 0.000001 + }, + "C_init_info":{ "init_from_file": False }, + "V_info": + { + "init_from_file": True, + "same_band": False + } + } + return json.dumps(input,indent=4) + +def cal(input): + info = utils.read_info() + with open(f"{utils.folder_opt}/input.json","w") as file: + file.write(input) + if utils.sub=="qsub": + with open(f"{utils.folder_opt}/sub.sh","w") as file: + file.write(textwrap.dedent(f"""\ + #!/bin/bash + #PBS -q batch + #PBS -l nodes=1:ppn=1 + #PBS -l walltime=24:00:00 + #PBS -o job.log + #PBS -e job.err + ulimit -s unlimited + cd $PBS_O_WORKDIR + EXEC={info["opt_orb"]} + python3 -u $EXEC + """)) + elif utils.sub=="tianhe2": + with open(f"{utils.folder_opt}/sub.sh","w") as file: + file.write(textwrap.dedent(f"""\ + #!/bin/bash + EXEC={info["opt_orb"]} + python3 -u $EXEC >Log.txt + """)) + os.chdir(utils.folder_opt) + if utils.sub=="qsub": + os.system("qsub sub.sh") + elif utils.sub=="tianhe2": + os.system("yhbatch -N 1 sub.sh") +# os.system(f'python3 -u {info["opt_orb"]}') + os.chdir("../") + +def all(): + os.mkdir(utils.folder_opt) + with open("folders","r") as file: + folders_matrix = json.loads(file.read()) + cp_matrix(folders_matrix.keys()) + add_nbands(folders_matrix) + input = set_input(folders_matrix) + cal(input) + +if __name__=="__main__": + all() \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/read_stru.py b/ABACUS.1.0.0/tools/opt_abfs_bash/read_stru.py new file mode 100644 index 0000000000..58523781be --- /dev/null +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/read_stru.py @@ -0,0 +1,205 @@ +import re +import numpy as np +import itertools +import numba +import functools +import os +import collections +import decimal +import json +import utils + +@functools.lru_cache(maxsize=None) +def get_input_dict(): + input_dict = dict() + with open("INPUT","r") as file: + for line in file: + line = line.strip() + if not line or line.startswith("#") or line=="INPUT_PARAMETERS": + continue + label, value = re.compile(r"\s+").split( line, maxsplit=1 ) + input_dict[label] = value + return input_dict + +def print_input(file,input_dict): + print("INPUT_PARAMETERS",file=file) + max_len = max([len(label) for label in input_dict]) + for label,value in input_dict.items(): + print( label, " "*(max_len-len(label)+4), value, file=file) + + +""" +@functools.lru_cache(maxsize=None) +def search_in_input(label): + with open("INPUT","r") as file: + regex = label+"\s+(\d+)" + value = re.compile(regex).search(file.read()).group(1) + return value +""" + +@functools.lru_cache(maxsize=None) +def get_k(): + with open("KPT","r") as file: + utils.search_sentence(file,"Gamma") + return list(map(int,file.readline().split()[:3])) + +@functools.lru_cache(maxsize=None) +def get_T(): + ntype = int(get_input_dict()["ntype"]) + T = [] + with open("STRU","r") as file: + utils.search_sentence(file,"ATOMIC_SPECIES") + for it in range(ntype): + line = file.readline() + T.append(line.split()[0]) + return T + +@functools.lru_cache(maxsize=None) +def get_Rcut(): + Ts = get_T() + lcao_path = get_lcao_path() + Rcut = dict() + for T in Ts: + with open(lcao_path[T],"r") as file: + for line in file: + if line.strip().startswith("Radius Cutoff(a.u.)"): + Rcut[T] = float(line.split()[-1]) + break + return Rcut + +@functools.lru_cache(maxsize=None) +def get_pseudo_path(): + Ts = get_T() + path = dict() + with open("STRU","r") as file: + utils.search_sentence(file,"ATOMIC_SPECIES") + for T in Ts: + path[T] = file.readline().split()[-1] + return path + +@functools.lru_cache(maxsize=None) +def get_lcao_path(): + Ts = get_T() + path = dict() + with open("STRU","r") as file: + utils.search_sentence(file,"NUMERICAL_ORBITAL") + for T in Ts: + path[T] = os.path.abspath(file.readline().strip()) + return path + +@functools.lru_cache(maxsize=None) +def get_lattice(): + with open("STRU","r") as file: + utils.search_sentence(file,"LATTICE_CONSTANT") + lat0 = float(file.readline().split()[0]) + with open("STRU","r") as file: + utils.search_sentence(file,"LATTICE_VECTORS") + lat_vec = [] + for i in range(3): + lat_vec.append(list(map(float,file.readline().split()))) + lat_vec = np.array(lat_vec) + with open("STRU","r") as file: + utils.search_sentence(file,"ATOMIC_POSITIONS") + position = file.readline().strip() + return lat0, lat_vec, position + +# R[T] = [..., [xi,yi,zi], ...] +def get_R(): + Ts = get_T() + R = dict() + with open("STRU","r") as file: + for T in Ts: + utils.search_sentence(file,T) + utils.ignore_lines(file,1) + na = int(file.readline().split()[0]) + R_tmp = [] + for i in range(na): + R_tmp.append(list(map(float,file.readline().split()[:3]))) + R[T] = np.array(R_tmp) + return R + +def change_R(R): + lat0, lat_vec, position = get_lattice() + if position == "Direct": + for T in R: + R[T] = np.dot(R[T],lat_vec) + elif position == "Cartesian_angstrom": + for T in R: + R[T] /= 0.529166 + for T in R: + R[T] *= lat0 + + nx,ny,nz = get_k() + lat_vec *= lat0 + for T in R: + R_new = [] + for ix in range(nx): + for iy in range(ny): + for iz in range(nz): + R_new.append( R[T] + np.dot(np.array([ix,iy,iz]), lat_vec) ) + R[T] = np.concatenate(R_new) + + return R + +# dis[T1,T2] = {..., i_dis:num, ...} +def cal_dis(R): + dis = dict() + for T1,T2 in itertools.combinations_with_replacement(R,2): + dis_TT = collections.defaultdict(int) + for ia1,ia2 in itertools.product(R[T1],R[T2]): + i_dis = np.linalg.norm(ia1-ia2) + dis_TT[i_dis] += 1 + dis[T1,T2] = dict(dis_TT) + return dis + +def round_dis(dis,precision): + dis_round = dict() + for T1,T2 in dis: + dis_TT = collections.defaultdict(int) + for i_dis,num in dis[T1,T2].items(): + i_dis = float(decimal.Decimal(i_dis).quantize(decimal.Decimal(str(precision)), rounding=decimal.ROUND_HALF_UP)) # test + dis_TT[i_dis] += num + dis_round[T1,T2] = dict(dis_TT) + return dis_round + +def cut_dis(dis): + Rcut = get_Rcut() + for T1,T2 in dis: + Rcut_sum = Rcut[T1]+Rcut[T2] + dis[T1,T2] = { i_dis:num for i_dis,num in dis[T1,T2].items() if i_disRcut_sum): + norm = np.linalg.norm(delta) + if norm>0 and normLog.txt') + os.chdir("../") + +# dis_opt[T1,T2] = [..., dis, ...] +def get_dis_opt(dis): + opt_mode = "kmeans" + dis_opt = dict() + info = utils.read_info() + for T1,T2 in dis: + dis_tmp = read_stru.delete_zero(dis[T1,T2]) + if len(dis_tmp)<=info["dimer_num"]: + dis_opt[T1,T2] = list(dis_tmp.keys()) + else: + if opt_mode=="linspace": + dis_opt[T1,T2] = np.linspace( min(dis_tmp), max(dis_tmp), info["dimer_num"] ) + elif opt_mode=="kmeans": + kmeans = KMeans(n_clusters=info["dimer_num"]) + label = kmeans.fit_predict( + np.array(list(dis_tmp.keys())).reshape(-1,1), + sample_weight = [num/i_dis**2 for i_dis,num in dis_tmp.items()]) + dis_opt[T1,T2] = list(kmeans.cluster_centers_.reshape(-1)) + pprint.pprint(dict(zip(dis_tmp.keys(),label))) + if T1==T2: + dis_opt[T1,T2].append(0.0) + return dis_opt + +# dis_weight[T1,T2] = {..., i_dis_opt:weight, ...} +def cal_dis_weight(dis_opt,dis_all): + def weight_func(x,D): + return (2/D**3)*x**3 + (-3/D**2)*x**2 + 1 + dis_weight = collections.defaultdict(dict) + for T1,T2 in dis_opt: + dis_opt_TT = sorted(dis_opt[T1,T2]) + for index,i_dis_opt in enumerate(dis_opt_TT): + i_weight = 0 + i_dis_low = dis_opt_TT[index-1] if index>0 else -np.infty + i_dis_up = dis_opt_TT[index+1] if index + 1 // smooth or not + 0.1 // sigma + {info["input"]["ecut"]} // energy cutoff for spherical bessel functions(Ry) + {info["input"]["rcut"]} // cutoff of wavefunctions(a.u.) + 1.0e-12 // tolerence + + """)) + + + + with open("STRU","w") as file: + file.write("ATOMIC_SPECIES\n") + file.write(f'{info["input"]["element"]} 1 {info["input"]["pseudo"]}\n') + file.write(textwrap.dedent(f"""\ + LATTICE_CONSTANT + {utils.lat0}\n + LATTICE_VECTORS + 1 0 0 + 0 1 0 + 0 0 1\n + ATOMIC_POSITIONS + Cartesian_angstrom + """)) + if info["input"]["element"] in ["Na","Li","K","Ca"]: + file.write(textwrap.dedent(f"""\ + {info["input"]["element"]} + 0.0 + 3 + 0 0 0 0 0 0 + 0 0 {dis} 0 0 0 + 0 {dis*0.86603} {dis*0.5} 0 0 0 + """)) + else: + file.write(textwrap.dedent(f"""\ + {info["input"]["element"]} + 0.0 + 2 + 0 0 0 0 0 0 + 0 0 {dis} 0 0 0 + """)) + + + + with open("KPT","w") as file: + file.write(textwrap.dedent(f"""\ + K_POINTS + 0 + Gamma + 1 1 1 0 0 0 + """)) + + + + with open("sub.sh","w") as file: + file.write(textwrap.dedent(f"""\ + #!/bin/bash + #PBS -q batch + #PBS -l nodes={info["exe"]["qsub"][0]}:ppn={info["exe"]["qsub"][1]} + #PBS -l walltime=1:00:00 + #PBS -o job.log + #PBS -e job.err + ulimit -s unlimited + cd $PBS_O_WORKDIR + EXEC={info["exe"]["exe_pw"]} + mpirun -n {info["exe"]["qsub"][0]*info["exe"]["qsub"][1]} $EXEC + """)) + + + + + +def print_file_opt(info,dis): + + with open("input.json","w") as file: + input = { + "file_list": [ f'../{info["input"]["element"]}-{info["input"]["rcut"]}-{distance}/test.{utils.lat0}.dat' for distance in dis[info["input"]["element"]] ], + "info": { + "Nt_all": [info["input"]["element"]], + "Nu": {info["input"]["element"] : info["orbital"]}, + "Nb_true": info["input"]["ref_bands"] if isinstance(info["input"]["ref_bands"],list) else [info["input"]["ref_bands"]] * len(dis[info["input"]["element"]]), + "weight": [1] * len(dis[info["input"]["element"]]), + "Rcut": {info["input"]["element"] : info["input"]["rcut"]}, + "dr": {info["input"]["element"] : utils.dr}, + "Ecut": {info["input"]["element"] : info["input"]["ecut"]} + }, + "C_init_info": { + "init_from_file": False + }, + "V_info": { + "same_band": True, + "init_from_file": False + } + } + file.write(json.dumps(input,indent=4)) + + + with open("sub.sh","w") as file: + file.write(textwrap.dedent(f"""\ + #!/bin/bash + #PBS -q batch + #PBS -l nodes=1:ppn=1 + #PBS -l walltime=1:00:00 + #PBS -o job.log + #PBS -e job.err + ulimit -s unlimited + cd $PBS_O_WORKDIR + EXEC={info["exe"]["exe_orbital"]} + python3 $EXEC + """)) \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_lcao_bash/read_info.py b/ABACUS.1.0.0/tools/opt_lcao_bash/read_info.py new file mode 100644 index 0000000000..17f5ccbce8 --- /dev/null +++ b/ABACUS.1.0.0/tools/opt_lcao_bash/read_info.py @@ -0,0 +1,34 @@ +import json +import os + +def read_info(file_name): + with open(file_name,"r") as file: + info = file.read() + info = json.loads(info) + info["input"]["pseudo_dir"] = os.path.abspath(info["input"].get("pseudo_dir","./")) + info["exe"]["qsub"] = info["exe"].get("qsub",[1,1]) + return info + +""" info.json +{ + "exe": + { + "exe_pw": "/home/linpz/ABACUS/ABACUS.1.0.1_2016-12-19/bin/ABACUS.mpi.1.0.0", + "exe_orbital": "/home/linpz/ABACUS/ABACUS_RI_git/tools/opt_orb_pytorch/main.py", + "qsub": [1,8] + }, + "input": + { + "element": "N", + "ref_bands": 5, or [5,5,5,5,5], + "nbands": 8, + "ecut": 50, + "rcut": 6, + "pseudo_dir": "../", + "pseudo": "N_ONCV_PBE-1.0.upf", + "sigma": 0.01 + }, + "orbital": [2,2,1] +} +""" + diff --git a/ABACUS.1.0.0/tools/opt_lcao_bash/utils.py b/ABACUS.1.0.0/tools/opt_lcao_bash/utils.py new file mode 100644 index 0000000000..2348f947ed --- /dev/null +++ b/ABACUS.1.0.0/tools/opt_lcao_bash/utils.py @@ -0,0 +1,2 @@ +lat0 = 20 +dr = 0.01 \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/__init__.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/func_C.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/func_C.py new file mode 100644 index 0000000000..ea18f13db2 --- /dev/null +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/func_C.py @@ -0,0 +1,85 @@ +from util import * +import torch + +def random_C_init(info): + """ C[it][il][ie,iu] """ + C = dict() + for it in info.Nt_all: + C[it] = ND_list(info.Nl[it]) + for il in range(info.Nl[it]): + C_tmp = torch.randn( info.Ne[it], info.Nu[it][il] )*2-1 #[-1,1] + C[it][il] = torch.autograd.Variable( C_tmp, requires_grad = True ) + return C + + + +def read_C_init(file_name,info): + """ C[it][il][ie,iu] """ + C = random_C_init(info) + + with open(file_name,"r") as file: + + for line in file: + if line.strip() == "": + line=None + break + ignore_line(file,1) + + while True: + line = file.readline().strip() + if line.startswith("Type"): + it,il,iu = list(map(int,file.readline().split())); + it=info.Nt_all[it-1]; iu-=1 + line = file.readline().split() + for ie in range(info.Ne[it]): + if not line: line = file.readline().split() + C[it][il].data[ie,iu] = float(line.pop(0)) + elif line.startswith(""): + break; + else: + raise IOError("unknown line in read_C_init "+file_name+"\n"+line) + return C + + + +def copy_C(C,info): + C_copy = dict() + for it in info.Nt_all: + C_copy[it] = ND_list(info.Nl[it]) + for il in range(info.Nl[it]): + C_copy[it][il] = C[it][il].clone() + return C_copy + + + +def write_C(file_name,info,C): + with open(file_name,"w") as file: + print("", file=file) + print("\tTotal number of radial orbitals.", file=file) + for it,C_t in C.items(): + for il,C_tl in enumerate(C_t): + for iu in range(C_tl.size()[1]): + print("\tType\tL\tZeta-Orbital", file=file) + print(f"\t {info.Nt_all.index(it)+1} \t{il}\t {iu+1}", file=file) + for ie in range(C_tl.size()[0]): + print("\t", C_tl.data[ie,iu], file=file) + print("", file=file) + + +#def init_C(info): +# """ C[it][il][ie,iu] """ +# C = ND_list(max(info.Nt)) +# for it in range(len(C)): +# C[it] = ND_list(info.Nl[it]) +# for il in range(info.Nl[it]): +# C[it][il] = torch.autograd.Variable( torch.Tensor( info.Ne, info.Nu[it][il] ), requires_grad = True ) +# +# with open("C_init.dat","r") as file: +# line = [] +# for it in range(len(C)): +# for il in range(info.Nl[it]): +# for i_n in range(info.Nu[it][il]): +# for ie in range(info.Ne[it]): +# if not line: line=file.readline().split() +# C[it][il].data[ie,i_n] = float(line.pop(0)) +# return C \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/print_QSV.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/print_QSV.py new file mode 100644 index 0000000000..750f29c49c --- /dev/null +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/print_QSV.py @@ -0,0 +1,29 @@ +def print_V(V,file_name): + """ V[ist][ib] """ + with open(file_name,"w") as file: + for V_s in V: + for V_sb in V_s: + print(1-V_sb.data[0],end="\t",file=file) + print(file=file) + +def print_S(S,file_name): + """ S[ist][it1,it2][il1][il2][ia1*im1*in1,ia2*im2*in2] """ + with open(file_name,"w") as file: + for ist,S_s in enumerate(S): + for (it1,it2),S_tt in S_s.items(): + for il1,S_ttl in enumerate(S_tt): + for il2,S_ttll in enumerate(S_ttl): + print(ist,it1,it2,il1,il2,file=file) + print(S_ttll.real.data.numpy(),file=file) + print(S_ttll.imag.data.numpy(),"\n",file=file) + +def print_Q(Q,file_name): + """ Q[ist][it][il][ib,ia*im*iu] """ + with open(file_name,"w") as file: + for ist,Q_s in enumerate(Q): + for it,Q_st in Q_s.items(): + for il,Q_stl in enumerate(Q_st): + print(ist,it,il,file=file) + print(Q_stl.real.data.numpy(),file=file) + print(Q_stl.imag.data.numpy(),"\n",file=file) + \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/print_orbital.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/print_orbital.py new file mode 100644 index 0000000000..69a68858c4 --- /dev/null +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/print_orbital.py @@ -0,0 +1,43 @@ +def print_orbital(orb,info): + """ orb[it][il][iu][r] """ + for it,orb_t in orb.items(): + with open("orb_{0}.dat".format(it),"w") as file: + print_orbital_head(file,info,it) + for il,orb_tl in enumerate(orb_t): + for iu,orb_tlu in enumerate(orb_tl): + print(""" Type L N""",file=file) + print(""" 0 {0} {1}""".format(il,iu),file=file) + for ir,orb_tlur in enumerate(orb_tlu): + print(orb_tlur,end="\t",file=file) + if ir%4==3: print(file=file) + print(file=file) + + +def plot_orbital(orb,Rcut,dr): + for it,orb_t in orb.items(): + with open("orb_{0}_plot.dat".format(it),"w") as file: + Nr = int(Rcut[it]/dr[it])+1 + for ir in range(Nr): + print(ir*dr[it],end="\t",file=file) + for il,orb_tl in enumerate(orb_t): + for orb_tlu in orb_tl: + print(orb_tlu[ir],end="\t",file=file) + print(file=file) + + +def print_orbital_head(file,info,it): + print( "---------------------------------------------------------------------------", file=file ) + print( "Element {0}".format(it), file=file ) + print( "Energy Cutoff(Ry) {0}".format(info.Ecut[it]), file=file ) + print( "Radius Cutoff(a.u.) {0}".format(info.Rcut[it]), file=file ) + print( "Lmax {0}".format(info.Nl[it]-1), file=file ) + l_name = ["S","P","D"]+list(map(chr,range(ord('F'),ord('Z')+1))) + for il,iu in enumerate(info.Nu[it]): + print( "Number of {0}orbital--> {1}".format(l_name[il],iu), file=file ) + print( "---------------------------------------------------------------------------", file=file ) + print( "SUMMARY END", file=file ) + print( file=file ) + print( "Mesh {0}".format(int(info.Rcut[it]/info.dr[it])+1), file=file ) + print( "dr {0}".format(info.dr[it]), file=file ) + + \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_QSV.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_QSV.py new file mode 100644 index 0000000000..00e3c09259 --- /dev/null +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_QSV.py @@ -0,0 +1,157 @@ +from util import * +import torch +import torch_complex +import itertools +import numpy as np + +def read_file(info,file_list,V_info): + """ QI[ist][it][il][ib*ia*im,ie] """ + """ SI[ist][it1][it2][il1][il2][ie1,ia1,im1,ia2,im2,ie2] """ + """ VI[ist][ib] """ + import copy + info_true = copy.deepcopy(info) + info_true.Nst = len(file_list) + info_true.Nt = ND_list(info_true.Nst,element="list()") + info_true.Na = ND_list(info_true.Nst,element="dict()") + info_true.Nb = ND_list(info_true.Nst) + info_true.Nk = ND_list(info_true.Nst) + info_true.Ne = dict() + info_true.weight = ND_list(info_true.Nst,element="list()") + QI=[]; SI=[]; VI=[] + + for ist_true,file_name in enumerate(file_list): + print(file_name) + with open(file_name,"r") as file: + + ignore_line(file,4) + Nt_tmp = int(file.readline().split()[0]) + for it in range(Nt_tmp): + t_tmp = file.readline().split()[0] + assert t_tmp in info.Nt_all + info_true.Nt[ist_true].append( t_tmp ) + info_true.Na[ist_true][t_tmp] = int(file.readline().split()[0]) + ignore_line( file, info_true.Na[ist_true][t_tmp] ) + ignore_line(file,6) + Nl_ist = int(file.readline().split()[0])+1 + for it,Nl_C in info.Nl.items(): + print(it,Nl_ist,Nl_C) + assert Nl_ist>=Nl_C + info_true.Nl[it] = Nl_ist + info_true.Nk[ist_true] = int(file.readline().split()[0]) + info_true.Nb[ist_true] = int(file.readline().split()[0]) + ignore_line(file,1) + Ne_tmp = list(map(int,file.readline().split()[:Nt_tmp])) + for it,Ne in zip(info_true.Nt[ist_true],Ne_tmp): + assert info_true.Ne.setdefault(it,Ne)==Ne + ignore_line(file,1) + for ik in range(info_true.Nk[ist_true]): + info_true.weight[ist_true].append(float(file.readline().split()[-1])) + ignore_line(file,3) + + line = None + for ik in range(info_true.Nk[ist_true]): + print("read QI:",ist_true,ik) + qi,line = read_QI(info_true,ist_true,file,line) + QI.append( qi ) + ignore_line(file,3) + for ik in range(info_true.Nk[ist_true]): + print("read SI:",ist_true,ik) + si,line = read_SI(info_true,ist_true,file,line) + SI.append( si ) + if V_info["init_from_file"]: + ignore_line(file,3) + for ik in range(info_true.Nk[ist_true]): + print("read VI:",ist_true,ik) + vi,line = read_VI(info_true,V_info,ist_true,file,line) + VI.append( vi ) + + info.Nst = sum(info_true.Nk,0) + import itertools + repeat_Nk = lambda x: list( itertools.chain.from_iterable( map( lambda x:itertools.repeat(*x), zip(x,info_true.Nk) ) ) ) + info.Nt = repeat_Nk(info_true.Nt) + info.Na = repeat_Nk(info_true.Na) + info.Nb = repeat_Nk(info_true.Nb) + info.Nb_true = repeat_Nk(info.Nb_true) + info.Ne = info_true.Ne + info.weight = list(itertools.chain.from_iterable([np.array(wk)*ws for wk,ws in zip(info_true.weight,info.weight)])) # info_true.weight[ist][ik] * info.weight[ist] + + return QI,SI,VI + + + + +def read_QI(info,ist,file,line=None): + """ QI[it][il][ib*ia*im,ie] """ + QI = dict() + for it in info.Nt[ist]: + QI[it] = ND_list(info.Nl[it]) + for il in range(info.Nl[it]): + QI[it][il] = torch_complex.ComplexTensor( + torch.autograd.Variable(torch.Tensor(info.Nb[ist],info.Na[ist][it],info.Nm(il),info.Ne[it])), + torch.autograd.Variable(torch.Tensor(info.Nb[ist],info.Na[ist][it],info.Nm(il),info.Ne[it])) ) + + for ib in range(info.Nb[ist]): + for it in info.Nt[ist]: + for ia in range(info.Na[ist][it]): + for il in range(info.Nl[it]): + for im in range(info.Nm(il)): + for ie in range(info.Ne[it]): + if not line: line = file.readline().split() + QI[it][il].real.data[ib,ia,im,ie] = float(line.pop(0)) + if not line: line = file.readline().split() + QI[it][il].imag.data[ib,ia,im,ie] = float(line.pop(0)) + for it in info.Nt[ist]: + for il in range(info.Nl[it]): + QI[it][il] = QI[it][il].view(-1,info.Ne[it]) + return QI,line + + + +def read_SI(info,ist,file,line=None): + """ SI[it1,it2][il1][il2][ie1,ia1,im1,ia2,im2,ie2] """ + SI = dict() + for it1,it2 in itertools.product( info.Nt[ist], info.Nt[ist] ): + SI[it1,it2] = ND_list(info.Nl[it1],info.Nl[it2]) + for il1,il2 in itertools.product( range(info.Nl[it1]), range(info.Nl[it2]) ): + SI[it1,it2][il1][il2] = torch_complex.ComplexTensor( + torch.autograd.Variable(torch.Tensor(info.Na[ist][it1],info.Nm(il1),info.Ne[it1],info.Na[ist][it2],info.Nm(il2),info.Ne[it2])), + torch.autograd.Variable(torch.Tensor(info.Na[ist][it1],info.Nm(il1),info.Ne[it1],info.Na[ist][it2],info.Nm(il2),info.Ne[it2])) ) + + for it1 in info.Nt[ist]: + for ia1 in range(info.Na[ist][it1]): + for il1 in range(info.Nl[it1]): + for im1 in range(info.Nm(il1)): + for it2 in info.Nt[ist]: + for ia2 in range(info.Na[ist][it2]): + for il2 in range(info.Nl[it2]): + for im2 in range(info.Nm(il2)): + for ie1 in range(info.Ne[it1]): + for ie2 in range(info.Ne[it2]): + if not line: line = file.readline().split() + SI[it1,it2][il1][il2].real.data[ia1,im1,ie1,ia2,im2,ie2] = float(line.pop(0)) + if not line: line = file.readline().split() + SI[it1,it2][il1][il2].imag.data[ia1,im1,ie1,ia2,im2,ie2] = float(line.pop(0)) + return SI,line + + + +def read_VI(info,V_info,ist,file,line=None): + if V_info["same_band"]: + """ VI[ib] """ + if V_info["init_from_file"]: + VI = torch.autograd.Variable(torch.Tensor(info.Nb[ist])) + for ib in range(info.Nb[ist]): + if not line: line = file.readline().split() + VI.data[ib] = float(line.pop(0)) + else: + VI = torch.autograd.Variable(torch.ones(info.Nb[ist])) + else: + """ VI[ib1,ib2] """ + if V_info["init_from_file"]: + VI = torch.autograd.Variable(torch.Tensor(info.Nb[ist],info.Nb[ist])) + for ib1,ib2 in itertools.product( range(info.Nb[ist]), range(info.Nb[ist]) ): + if not line: line = file.readline().split() + VI.data[ib1,ib2] = float(line.pop(0)) + else: + VI = torch.autograd.Variable(torch.eye(info.Nb[ist],info.Nb[ist])) + return VI,line \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_json.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_json.py new file mode 100644 index 0000000000..b5bc5735c4 --- /dev/null +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_json.py @@ -0,0 +1,62 @@ +import json +from util import Info + +def read_json(file_name): + + with open(file_name,"r") as file: + input = file.read() + input = json.loads(input) + + info = Info() + for info_attr,info_value in input["info"].items(): + info.__dict__[info_attr] = info_value + info.Nl = { it:len(Nu) for it,Nu in info.Nu.items() } + + return input["file_list"], info, input["C_init_info"], input["V_info"] + + """ file_name + { + "file_list": + [ + "/public/udata/linpz/try/SIA/pytorch/test/many_atoms/S2/S2.10.dat", + "/public/udata/linpz/try/SIA/pytorch/test/many_atoms/SO2/SO2.10.dat", + "/public/udata/linpz/try/SIA/pytorch/test/many_atoms/SO/SO.10.dat" + ], + "info": + { + "Nt_all": ["S","O"], + "Nu": {"S":[3,3,2],"O":[3,3,2]}, + "Nb_true": [7,9,7], + "weight": [2,3,1.5], + "Rcut": {"S":10,"O":10}, + "dr": {"S":0.01,"O":0.01}, + "Ecut": {"S":100,"O":100} + }, + "C_init_info": + { + "init_from_file": false, + "C_init_file": "/public/udata/linpz/try/SIA/pytorch/test/many_atoms/SIA/ORBITAL_RESULTS.txt" + }, + "V_info": + { + "init_from_file": true, + "same_band": false + } + } + """ + + """ info + Nt_all ["S", "O"] + Nu {"S":[3,3,2], "O":[3,3,2]} + Nb_true [7, 9, 7] + weight [2, 3, 1.5] + Rcut {"S":10, "O":10} + dr {"S":0.01, "O":0.01} + Ecut {"S":100, "O":100} + Nl {"S":2, "O":2} + Nst 3 + Nt [["S"], ["S","O"], ["S","O"]] + Na [{"S":2}, {"S":1,"O":2}, {"S":1,"O":1}] + Nb [7, 9, 7] + Ne {"S":22, "O":19} + """ \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/__init__.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/inverse.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/inverse.py new file mode 100644 index 0000000000..311519fae1 --- /dev/null +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/inverse.py @@ -0,0 +1,55 @@ +import torch + + +def inverse_DC(A,B,C,D): + tmp_A = inverse(A) # A^{-1} + #print("tmp_A",tmp_A) + tmp_AB = torch.mm(tmp_A,B) # A^{-1} B + #print("tmp_AB",tmp_AB) + tmp_CA = torch.mm(C,tmp_A) # C A^{-1} + #print("tmp_CA",tmp_CA) + tmp_X = inverse(D-torch.mm(tmp_CA,B)) # ( D - C A^{-1} B )^{-1} + #print("tmp_X",tmp_X) + tmp_ABX = torch.mm(tmp_AB,tmp_X) # A^{-1} B ( D - C A^{-1} B )^{-1} + #print("tmp_ABX",tmp_ABX) + tmp_XCA = torch.mm(tmp_X,tmp_CA) # ( D - C A^{-1} B )^{-1} C A^{-1} + #print("tmp_XCA",tmp_XCA) + tmp_ABXCA = torch.mm(tmp_ABX,tmp_CA) # A^{-1} B ( D - C A^{-1} B )^{-1} C A^{-1} + #print("tmp_ABXCA",tmp_ABXCA) + + tmp_up = torch.cat( [ tmp_A+tmp_ABXCA, -tmp_ABX ], dim=1 ) + tmp_down = torch.cat( [ -tmp_XCA, tmp_X ], dim=1 ) + I = torch.cat( [tmp_up,tmp_down], dim=0 ) + return I + + + +def inverse(M): + +# assert len(M.size()) == 2, "inverse must be 2D" +# assert M.size()[0] == M.size()[1], "inverse row != column" + + L = M.size()[0] + + if L==1: + return 1/M + + elif L==2: + det = torch.cat(list( M[:1,:1]*M[1:,1:] - M[:1,1:]*M[1:,:1] )*4).view(2,2) + I_up = torch.cat([M[1:,1:],-M[:1,1:]],dim=1) + I_down = torch.cat([-M[1:,:1],M[:1,:1]],dim=1) + I_all = torch.cat([I_up,I_down],dim=0) + return I_all/det + + elif L==3: + threshold = 1e-10 + if M[0,0].abs() > threshold: + return inverse_DC( M[:1,:1], M[:1,1:], M[1:,:1], M[1:,1:] ) + elif M[2,2].abs() > threshold: + return inverse_DC( M[:2,:2], M[:2,2:], M[2:,:2], M[2:,2:] ) + else: + raise ZeroDivisionError("matrix inverse") + + else: + L2 = L//2 + return inverse_DC( M[:L2,:L2], M[:L2,L2:], M[L2:,:L2], M[L2:,L2:] ) \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/main.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/main.py new file mode 100644 index 0000000000..54a1912a66 --- /dev/null +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/main.py @@ -0,0 +1,130 @@ +import IO.read_QSV +import IO.print_QSV +import IO.func_C +import IO.read_json +import IO.print_orbital +import opt_orbital +#import opt_orbital_old +import orbital +import torch +import numpy as np +import time + +time_start = time.time() + +file_list, info, C_init_info, V_info = IO.read_json.read_json("input.json") + +QI,SI,VI = IO.read_QSV.read_file(info,file_list,V_info) +print(info) + +#print("QI:\t",QI) +#print("SI:\t",SI) +#print("VI:\t",VI) + +if C_init_info["init_from_file"]: + C = IO.func_C.read_C_init( C_init_info["C_init_file"], info ) +else: + C = IO.func_C.random_C_init(info) +E = orbital.set_E(info,info.Rcut) +orbital.normalize( orbital.generate_orbital(info,C,E,info.Rcut,info.dr), info.dr,C,flag_norm_C=True) + +""" +Q = opt_orb.cal_Q(QI,C,info) +S = opt_orb.cal_S(SI,C,info) +V = opt_orb.cal_V(Q,S,info) +IO.print_QSV.print_Q(Q,"Q.dat") +IO.print_QSV.print_Q(QI,"QI.dat") +IO.print_QSV.print_S(S,"S.dat") +IO.print_QSV.print_S(SI,"SI.dat") +IO.print_QSV.print_V(V,"V.dat") + +Spillage = V_true-sum((sum(Vi[:info.Nb_true[ist]]) for ist,Vi in enumerate(V) ))/sum(info.Nb_true,0) +T = opt_orb.cal_T(C,E) +Loss = Spillage + 0.01*T + +orb = orbital.generate_orbital(info,C,E,info.Rcut,info.dr) +orbital.smooth_orbital(orb,info.Rcut,info.dr,0.1) +orbital.orth(orb,info.dr) +IO.print_orbital.print_orbital(orb) +IO.print_orbital.print_orbital_plot(orb,info.Rcut,info.dr) + +with open("Spillage.dat","w") as S_file, open("C.dat","w") as C_file: + print(Spillage.data[0],T.data[0],Loss.data[0],file=S_file) + print(C,file=C_file) + print("time:\t",time.time()-time_start) + +exit() +""" + + +opt_orb = opt_orbital.Opt_Orbital() +#opt_orb_old = opt_orbital_old.Opt_Orbital() + +#opt = torch.optim.Adam(sum( ([c.real,c.imag] for c in sum(C,[])), []), lr=1e-1, eps=1e-8) +opt = torch.optim.Adam( sum(C.values(),[]), lr=1E-2, eps=1e-20) + +with open("Spillage.dat","w") as S_file: + + loss_old = np.inf + + for i in range(20000): + Q = opt_orb.cal_Q(QI,C,info) + S = opt_orb.cal_S(SI,C,info) + V = opt_orb.cal_V(Q,S,info,V_info) +# V_old = opt_orb_old.cal_V(Q,S,info) + + """ + with open("V_old.dat","w") as file: + for v_old in V_old: + for vi in v_old: + print(vi.data[0],end="\t",file=file) + print(file=file) + with open("V.dat","w") as file: + for v in V: + for i in range(v.size()[0]): + for j in range(v.size()[1]): + print(v.data[i,j],end="\t",file=file) + print(file=file) + print(file=file) + with open("VI.dat","w") as file: + for v in VI: + for i in range(v.size()[0]): + for j in range(v.size()[1]): + print(v.data[i,j],end="\t",file=file) + print(file=file) + print(file=file) + """ + + + V_delta = ( torch.abs(VIi-Vi) for VIi,Vi in zip(VI,V) ) # abs or **2? + if V_info["same_band"]: + Spillage = sum( Vi[:info.Nb_true[ist]].sum() * info.weight[ist] for ist,Vi in enumerate(V_delta) ) / sum( Nb_true*weight for Nb_true,weight in zip(info.Nb_true,info.weight) ) + else: + Spillage = sum( Vi[:info.Nb_true[ist],:info.Nb_true[ist]].sum() * info.weight[ist] for ist,Vi in enumerate(V_delta) ) / sum( Nb_true**2*weight for Nb_true,weight in zip(info.Nb_true,info.weight) ) + T = opt_orb.cal_T(C,E) + if not "TSrate" in vars(): TSrate = torch.abs(0.002*Spillage/T).data[0] + Loss = Spillage + TSrate*T + + print(Spillage.data[0],T.data[0],Loss.data[0],file=S_file) + if Loss.data[0] < loss_old: + loss_old = Loss.data[0] + C_old = IO.func_C.copy_C(C,info) + flag_finish = 0 + else: + flag_finish += 1 + if flag_finish > 50: break + + opt.zero_grad() + Loss.backward() + opt.step() +# orbital.normalize( orbital.generate_orbital(info,C,E,info.Rcut,info.dr), info.dr,C,flag_norm_C=True) + + orb = orbital.generate_orbital(info,C_old,E,info.Rcut,info.dr) + orbital.smooth_orbital(orb,info.Rcut,info.dr,0.1) + orbital.orth(orb,info.dr) + IO.print_orbital.print_orbital(orb,info) + IO.print_orbital.plot_orbital(orb,info.Rcut,info.dr) + + IO.func_C.write_C("C.dat",info,C_old) + + print("time:\t",time.time()-time_start) \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/opt_orbital.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/opt_orbital.py new file mode 100644 index 0000000000..6c35f496f2 --- /dev/null +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/opt_orbital.py @@ -0,0 +1,137 @@ +from util import ND_list +import inverse +import torch_complex +import functools +import itertools +import torch + +class Opt_Orbital: + + def cal_Q(self,QI,C,info): + """ + Q[ist][it][il][ib,ia*im*iu] + = sum_{q} QI[ist][it][il][ib*ia*im,ie] * C[it][il][ie,iu] + """ + Q = ND_list(info.Nst,element="dict()") + for ist in range(info.Nst): + for it in info.Nt[ist]: + Q[ist][it] = ND_list(info.Nl[it]) + + for ist in range(info.Nst): + for it in info.Nt[ist]: + for il in range(info.Nl[it]): + Q[ist][it][il] = torch_complex.mm( QI[ist][it][il], C[it][il] ).view(info.Nb[ist],-1) + return Q + + + + def cal_S(self,SI,C,info): + """ + S[ist][it1,it2][il1][il2][ia1*im1*iu1,ia2*im2*iu2] + = sum_{ie1 ie2} C^*[it1][il1][ie1,iu1] * SI[ist][it1,it2][il1][il2][ia1,im1,ie1,ia2,im2,ie2] * C[it2][[il2][ie2,iu2] + """ + S = ND_list(info.Nst,element="dict()") + for ist in range(info.Nst): + for it1,it2 in itertools.product( info.Nt[ist], info.Nt[ist] ): + S[ist][it1,it2] = ND_list(info.Nl[it1],info.Nl[it2]) + + for ist in range(info.Nst): + for it1,it2 in itertools.product( info.Nt[ist], info.Nt[ist] ): + for il1,il2 in itertools.product( range(info.Nl[it1]), range(info.Nl[it2]) ): + # SI_C[ia1*im1*ie1*ia2*im2,iu2] + SI_C = torch_complex.mm( + SI[ist][it1,it2][il1][il2].view(-1,info.Ne[it2]), + C[it2][il2] ) + # SI_C[ia1*im1,ie1,ia2*im2*iu2] + SI_C = SI_C.view( info.Na[ist][it1]*info.Nm(il1), info.Ne[it1], -1 ) + # Ct[iu1,ie1] + Ct = C[it1][il1].t() + C_mm = functools.partial(torch_complex.mm,Ct) + # C_SI_C[ia1*im1][iu1,ia2*im2*iu2] + C_SI_C = list(map( C_mm, SI_C )) + # C_SI_C[ia1*im1*iu1,ia2*im2*iu2] + C_SI_C = torch_complex.cat( C_SI_C, dim=0 ) +#??? C_SI_C = C_SI_C.view(info.Na[ist][it1]*info.Nm(il1)*info.Nu[it1][il1],-1) + S[ist][it1,it2][il1][il2] = C_SI_C + return S + + + + def cal_V(self,Q,S,info,V_info): + """ + V[ist][ib] + = sum_{it1,ia1,il1,im1,iu1} sum_{it2,ia2,il2,im2,iu2} + Q[ist][it1][il1][ib,ia1*im1*iu1] * S[ist]{[it1][it2][il1][il2][ia1*im1*iu1,ia2*im2*iu2]}^{-1} * Q[ist][it2][il2][ib,ia2*im2*iu2] + V[ist][ib1,ib2] + = sum_{it1,ia1,il1,im1,iu1} sum_{it2,ia2,il2,im2,iu2} + Q[ist][it1][il1][ib1,ia1*im1*iu1] * S[ist]{[it1][it2][il1][il2][ia1*im1*iu1,ia2*im2*iu2]}^{-1} * Q[ist][it2][il2][ib2,ia2*im2*iu2] + """ + V = ND_list(info.Nst) + for ist in range(info.Nst): + + # S_s[it1][il1*ia1*im1*iu1,it2*il2*ia2*im2*iu2] + S_s = dict() + for it1 in info.Nt[ist]: + # S_st[it2][il1*ia1*im1*iu1,il2*ia2*im2*iu2] + S_st = dict() + for it2 in info.Nt[ist]: + # S_stt[il1][ia1*im1*iu1,il2*ia2*im2*iu2] + S_stt = ND_list(info.Nl[it1]) + for il1 in range(info.Nl[it1]): + S_stt[il1] = torch_complex.cat( S[ist][it1,it2][il1], dim=1 ) + S_st[it2] = torch_complex.cat( S_stt, dim=0 ) + S_s[it1] = torch_complex.cat( list(S_st.values()), dim=1 ) + # S_cat[it1*il1*iat*im1*iu1,iat2*il2*ia2*im2*iu2] + S_cat = torch_complex.cat( list(S_s.values()), dim=0 ) + S_I = torch_complex.inverse(S_cat) + + if V_info["same_band"]: + # V_s[ib] + V_s = ND_list(info.Nb[ist]) + for ib in range(info.Nb[ist]): + # Q_s[it][il*ia*im*iu] + Q_s = dict() + for it in info.Nt[ist]: + # Q_ts[il][ia*im*iu] + Q_ts = [ Q_stl[ib] for Q_stl in Q[ist][it] ] + Q_s[it] = torch_complex.cat(Q_ts) + # Q_cat[it*il*ia*im*iu] + Q_cat = torch_complex.cat(list(Q_s.values())) + V_s[ib] = torch_complex.dot( Q_cat.conj(), torch_complex.mv( S_I, Q_cat ) ).real + # V[ist][ib] + V[ist] = torch.cat(V_s) + else: + # Q_b[ib][0,it*il*ia*im*iu] + Q_b = ND_list(info.Nb[ist]) + for ib in range(info.Nb[ist]): + # Q_s[it][il*ia*im*iu] + Q_s = dict() + for it in info.Nt[ist]: + # Q_ts[il][ia*im*iu] + Q_ts = [ Q_stl[ib] for Q_stl in Q[ist][it] ] + Q_s[it] = torch_complex.cat(Q_ts) + Q_b[ib] = torch_complex.cat(list(Q_s.values())).view(1,-1) + # Q_cat[ib,it*il*ia*im*iu] + Q_cat = torch_complex.cat( Q_b, dim=0 ) + # V[ist][ib1,ib2] + V[ist] = torch_complex.mm( Q_cat.conj(), torch_complex.mm( S_I, Q_cat.t() ) ).real + + return V + + + def cal_T(self,C,E): + """ T = 0.5* sum_{it,il,iu} sum_{ie} ( E[it][il,ie] * C[it][il][ie,iu] )**2 """ + T = torch.autograd.Variable(torch.zeros(1)) + num = 0 + for it,C_t in C.items(): + for il,C_tl in enumerate(C_t): + for iu in range(C_tl.size()[1]): + T_tlu = torch.autograd.Variable(torch.zeros(1)) + Z_tlu = 0 + for ie in range(C_tl.size()[0]): + T_tlu = T_tlu + ( E[it][il,ie] * C_tl[ie,iu] )**2 + Z_tlu = Z_tlu + E[it].data[il,ie]**2 + T = T + T_tlu/Z_tlu + num += C_tl.size()[1] + T = 0.5 * T / num + return T \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/opt_orbital.py_real b/ABACUS.1.0.0/tools/opt_orb_pytorch/opt_orbital.py_real new file mode 100644 index 0000000000..5ade0f90fc --- /dev/null +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/opt_orbital.py_real @@ -0,0 +1,86 @@ +from global_function import ND_list +import inverse +import torch + +class SIA: + + def cal_Q(self,QI,C): + """ + Q[ist][it][il][ib,ia*im*iu] + = sum_{q} QI[ist][it][il][ib*ia*im,ie] * C[it][il][ie,iu] + """ + Q = ND_list(self.Nst) + for ist in range(self.Nst): + Q[ist] = ND_list(self.Nt[ist]) + for it in range(self.Nt[ist]): + Q[ist][it] = ND_list(self.Nl[it]) + + for ist in range(self.Nst): + for it in range(self.Nt[ist]): + for il in range(self.Nl[it]): + Q[ist][it][il] = torch.mm( QI[ist][it][il], C[it][il] ).view(self.Nb[ist],-1) + return Q + + + + def cal_S(self,SI,C): + """ + S[ist][it1][it2][il1][il2][ia1*im1*in1,ia2*im2*in2] + = sum_{ie1 ie2} C[it1][il1][ie1,in1] * SI[ist][it1][it2][il1][il2][ie1,ia1,im1,ia2,im2,ie2] * C[it2][[il2][ie2,in2] + """ + S = ND_list(self.Nst) + for ist in range(self.Nst): + S[ist] = ND_list(self.Nt[ist],self.Nt[ist]) + for it1 in range(self.Nt[ist]): + for it2 in range(self.Nt[ist]): + S[ist][it1][it2] = ND_list(self.Nl[it1],self.Nl[it2]) + + for ist in range(self.Nst): + for it1 in range(self.Nt[ist]): + for it2 in range(self.Nt[ist]): + for il1 in range(self.Nl[it1]): + for il2 in range(self.Nl[it2]): + S[ist][it1][it2][il1][il2] = torch.mm( + C[it1][il1].t(), + torch.mm( SI[ist][it1][it2][il1][il2].view(-1,self.Ne), C[it2][il2] ).view(self.Ne,-1) + ).view(self.Nn[it1][il1],self.Na[ist][it1]*self.Nm[il1],-1).transpose(0,1).view(self.Na[ist][it1]*self.Nm[il1]*self.Nn[it1][il1],-1) + return S + + + + def cal_V(self,Q,S): + """ + V[ist][ib] + = sum_{it1,ia1,il1,im1,in1} sum_{it2,ia2,il2,im2,in2} + Q[ist][it1][il1][ib,ia1*im1*in1] * S[ist]{[it1][it2][il1][il2][ia1*im1*in1,ia2*im2*in2]}^{-1} * Q[ist][it2][il2][ib,ia2*im2*in2] + """ + V = ND_list(self.Nst) + for ist in range(self.Nst): + V[ist] = ND_list(self.Nb[ist]) + + for ist in range(self.Nst): + + S_s = ND_list(self.Nt[ist]) + for it1 in range(self.Nt[ist]): + S_st = ND_list(self.Nt[ist]) + for it2 in range(self.Nt[ist]): + S_stt = ND_list(self.Nl[it1]) + for il1 in range(self.Nl[it1]): + S_stt[il1] = torch.cat( S[ist][it1][it2][il1], dim=1 ) + S_st[it2] = torch.cat( S_stt, dim=0 ) + S_s[it1] = torch.cat( S_st, dim=1 ) + S_cat = torch.cat( S_s, dim=0 ) + + S_I = inverse.inverse(S_cat) +# S_I = 1/S_cat + + for ib in range(self.Nb[ist]): + + Q_s = ND_list(self.Nt[ist]) + for it in range(self.Nt[ist]): + Q_s[it] = torch.cat([ Q_st[ib] for Q_st in Q[ist][it] ]) + Q_cat = torch.cat(Q_s) + + V[ist][ib] = torch.dot( Q_cat, torch.mv( S_I, Q_cat ) ) + + return V \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/orbital.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/orbital.py new file mode 100644 index 0000000000..220e3c1461 --- /dev/null +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/orbital.py @@ -0,0 +1,80 @@ +from util import ND_list +import numpy as np +from scipy.special import spherical_jn +from scipy.integrate import simps +from scipy.optimize import fsolve +import functools +import torch + +def generate_orbital(info,C,E,Rcut,dr): + """ C[it][il][ie,iu] """ + """ orb[it][il][iu][r] = \suml_{ie} C[it][il][ie,iu] * jn(il,ie*r) """ + orb = dict() + for it in info.Nt_all: + Nr = int(Rcut[it]/dr[it])+1 + orb[it] = ND_list(info.Nl[it]) + for il in range(info.Nl[it]): + orb[it][il] = ND_list(info.Nu[it][il]) + for iu in range(info.Nu[it][il]): + orb[it][il][iu] = np.zeros(Nr) + for ir in range(Nr): + r = ir * dr[it] + for ie in range(info.Ne[it]): + orb[it][il][iu][ir] += C[it][il].data[ie,iu] * spherical_jn(il,E[it].data[il,ie]*r) + return orb + + +def smooth_orbital(orb,Rcut,dr,sigma): + for it,orb_t in orb.items(): + for orb_tl in orb_t: + for orb_tlu in orb_tl: + for ir in range(orb_tlu.shape[0]): + assert orb_tlu.shape[0] == int(Rcut[it]/dr[it])+1 + r = ir * dr[it] + orb_tlu[ir] *= 1-np.exp( -(r-Rcut[it])**2/(2*sigma**2) ) + + + +def inner_product( orb1, orb2, dr ): + assert orb1.shape == orb2.shape + r = np.array(range(orb1.shape[0]))*dr + return simps( orb1 * orb2 * r * r, dx=dr ) + +def normalize(orb,dr,C=None,flag_norm_orb=False,flag_norm_C=False): + """ C[it][il][ie,iu] """ + """ orb[it][il][iu][r] = \suml_{ie} C[it][il][ie,iu] * jn(il,ie*r) """ + for it,orb_t in orb.items(): + for il,orb_tl in enumerate(orb_t): + for iu,orb_tlu in enumerate(orb_tl): + norm = np.sqrt(inner_product(orb_tlu,orb_tlu,dr[it])) + if flag_norm_orb: orb_tlu[:] = orb_tlu / norm + if flag_norm_C: C[it][il].data[:,iu] = C[it][il].data[:,iu] / norm + +def orth(orb,dr): + """ |n'> = 1/Z ( |n> - \sum_{i=0}^{n-1} |i> ) """ + """ orb[it][il][iu,r] """ + for it,orb_t in orb.items(): + for il,orb_tl in enumerate(orb_t): + for iu1,orb_tlu1 in enumerate(orb_tl): + for iu2 in range(iu1): + orb_tlu1[:] -= orb_tl[iu2] * inner_product(orb_tlu1,orb_tl[iu2],dr[it]) + orb_tlu1[:] = orb_tlu1 / np.sqrt(inner_product(orb_tlu1,orb_tlu1,dr[it])) + +def find_eigenvalue(Nl,Ne): + """ E[il,ie] """ + E = np.zeros((Nl,Ne+Nl+1)) + for ie in range(1,Ne+Nl+1): + E[0,ie] = ie*np.pi + for il in range(1,Nl): + jl = functools.partial(spherical_jn,il) + for ie in range(1,Ne+Nl+1-il): + E[il,ie] = fsolve( jl, (E[il-1,ie]+E[il-1,ie+1])/2 ) + return E[:,1:Ne+1] + +def set_E(info,Rcut): + """ E[it][il,ie] """ + eigenvalue = { it:find_eigenvalue(info.Nl[it],info.Ne[it]) for it in info.Nt_all } + E = dict() + for it in Rcut: + E[it] = torch.autograd.Variable(torch.from_numpy(( eigenvalue[it]/Rcut[it] ).astype("float32"))) + return E \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/pf.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/pf.py new file mode 100644 index 0000000000..e518fa02f7 --- /dev/null +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/pf.py @@ -0,0 +1,2 @@ +import profile +profile.run("import main","profile.dat") \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/torch_complex.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/torch_complex.py new file mode 100644 index 0000000000..d5f338d5d7 --- /dev/null +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/torch_complex.py @@ -0,0 +1,83 @@ +import torch + +class ComplexTensor: + def __init__(self,real,imag): + self.real = real + self.imag = imag + + def view(self,*args,**kwargs): + return ComplexTensor( self.real.view(*args,**kwargs), self.imag.view(*args,**kwargs) ) + def t(self,*args,**kwargs): + return ComplexTensor( self.real.t(*args,**kwargs), self.imag.t(*args,**kwargs) ) +# def transpose(self,*args,**kwargs): +# return ComplexTensor( self.real.transpose(*args,**kwargs), self.imag.transpose(*args,**kwargs) ) + def __getitem__(self,*args,**kwargs): + return ComplexTensor( self.real.__getitem__(*args,**kwargs), self.imag.__getitem__(*args,**kwargs) ) + def __str__(self): + return "<{0};{1}>".format(self.real, self.imag) + __repr__=__str__ +# def size(self,*args,**kwargs): +# return ComplexTensor( self.real.size(*args,**kwargs), self.imag.size(*args,**kwargs) ) + + def conj(self): + return ComplexTensor( self.real, -self.imag ) + + + +def dot( x1,x2, *args,**kwargs ): + if isinstance(x1,ComplexTensor): + if isinstance(x2,ComplexTensor): + return ComplexTensor( torch.dot( x1.real,x2.real, *args,**kwargs ) - torch.dot( x1.imag,x2.imag, *args,**kwargs ), torch.dot( x1.real,x2.imag, *args,**kwargs ) + torch.dot( x1.imag,x2.real, *args,**kwargs ) ) + else: + return ComplexTensor( torch.dot( x1.real,x2, *args,**kwargs ), torch.dot( x1.imag,x2, *args,**kwargs ) ) + else: + if isinstance(x2,ComplexTensor): + return ComplexTensor( torch.dot( x1,x2.real, *args,**kwargs ), torch.dot( x1,x2.imag, *args,**kwargs ) ) + else: + return torch.dot( x1,x2, *args,**kwargs ) +def mv( x1,x2, *args,**kwargs ): + if isinstance(x1,ComplexTensor): + if isinstance(x2,ComplexTensor): + return ComplexTensor( torch.mv( x1.real,x2.real, *args,**kwargs ) - torch.mv( x1.imag,x2.imag, *args,**kwargs ), torch.mv( x1.real,x2.imag, *args,**kwargs ) + torch.mv( x1.imag,x2.real, *args,**kwargs ) ) + else: + return ComplexTensor( torch.mv( x1.real,x2, *args,**kwargs ), torch.mv( x1.imag,x2, *args,**kwargs ) ) + else: + if isinstance(x2,ComplexTensor): + return ComplexTensor( torch.mv( x1,x2.real, *args,**kwargs ), torch.mv( x1,x2.imag, *args,**kwargs ) ) + else: + return torch.mv( x1,x2, *args,**kwargs ) +def mm( x1,x2, *args,**kwargs ): + if isinstance(x1,ComplexTensor): + if isinstance(x2,ComplexTensor): + return ComplexTensor( torch.mm( x1.real,x2.real, *args,**kwargs ) - torch.mm( x1.imag,x2.imag, *args,**kwargs ), torch.mm( x1.real,x2.imag, *args,**kwargs ) + torch.mm( x1.imag,x2.real, *args,**kwargs ) ) + else: + return ComplexTensor( torch.mm( x1.real,x2, *args,**kwargs ), torch.mm( x1.imag,x2, *args,**kwargs ) ) + else: + if isinstance(x2,ComplexTensor): + return ComplexTensor( torch.mm( x1,x2.real, *args,**kwargs ), torch.mm( x1,x2.imag, *args,**kwargs ) ) + else: + return torch.mm( x1,x2, *args,**kwargs ) + + +def cat( xs, *args,**kwargs ): + if isinstance(xs[0],ComplexTensor): + xs_real = []; xs_imag = [] + for x in xs: + xs_real.append(x.real) + xs_imag.append(x.imag) + return ComplexTensor( torch.cat(xs_real,*args,**kwargs), torch.cat(xs_imag,*args,**kwargs) ) + else: + return torch.cat(xs,*args,**kwargs) + + + +import inverse as inverse_real +def inverse(M): + if isinstance(M,ComplexTensor): + A=M.real + B=M.imag + tmp_AB = torch.mm(A.inverse(),B) # A^{-1} B + tmp_X = (A+torch.mm(B,tmp_AB)).inverse() # ( A + B A^{-1} B )^{-1} + return ComplexTensor( tmp_X, -torch.mm(tmp_AB,tmp_X) ) + else: + return M.inverse() \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/unittest_inverse.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/unittest_inverse.py new file mode 100644 index 0000000000..f4d4315610 --- /dev/null +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/unittest_inverse.py @@ -0,0 +1,29 @@ +import unittest +import inverse +import torch + +class unittest_inverse(unittest.TestCase): + + def inverse_test(self,a,ai_true): + + a=torch.Tensor(a) + a=torch.autograd.Variable(a) + + ai_test=inverse.inverse(a) + + ai_true = torch.Tensor(ai_true) + ai_true=torch.autograd.Variable(ai_true) + + self.assertFalse((ai_test!=ai_true).data.sum()) + + def test_inverse_1(self): + self.inverse_test( + [[1,2],[2,3]], + [[-3,2],[2,-1]] ) + def test_inverse_2(self): + self.inverse_test( + [[1,2,3],[2,4,5],[3,5,6]], + [[1,-3,2],[-3,3,-1],[2,-1,0]] ) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/util.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/util.py new file mode 100644 index 0000000000..ea435309a1 --- /dev/null +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/util.py @@ -0,0 +1,38 @@ +def ND_list(*sizes,element=None): + size_1,*size_other = sizes + l = [element] * size_1 + if size_other: + for i in range(len(l)): + l[i] = ND_list(*size_other,element=element) + else: + if element in ["dict()","list()"]: + for i in range(size_1): + l[i] = eval(element) + return l + + +def ignore_line(file,N): + for _ in range(N): + file.readline() + + +class Info: + def Nm(self,il): return 2*il+1 + def __str__(self): + return "\n".join([name+"\t"+str(value) for name,value in self.__dict__.items()]) + __repr__=__str__ + +def change_to_cuda(s): + if isinstance(s,list): + return [change_to_cuda(x) for x in s] + elif isinstance(s,dict): + return {i:change_to_cuda(x) for i,x in s.items()} + elif isinstance(s,torch.Tensor): + return s.cuda() + elif isinstance(s,torch.autograd.Variable): + return s.cuda() + elif isinstance(s,torch_complex.ComplexTensor): + return torch_complex.ComplexTensor( change_to_cuda(s.real), change_to_cuda(s.imag) ) + else: + print(s) + raise TypeError("change_to_cuda") \ No newline at end of file From d5aed782ed763ddc715806d23dec891926c8355f Mon Sep 17 00:00:00 2001 From: Peize Lin Date: Tue, 7 May 2019 04:13:01 +0800 Subject: [PATCH 002/233] 1. fix bug Exx_Abfs::Matrix_Orbs11::init_radial_table(Rs) Exx_Abfs::Matrix_Orbs21::init_radial_table(Rs) Exx_Abfs::Matrix_Orbs22::init_radial_table(Rs) 2. optimize code Sph_Bessel_Recursive::D2::cal_jlx_0() --- .../src_test/src_lcao/exx_lcao-test.h | 7 +++ .../src_global/sph_bessel_recursive-d2.cpp | 16 ++----- .../src_lcao/exx_abfs-matrix_orbs11.cpp | 48 +++++++++---------- .../src_lcao/exx_abfs-matrix_orbs21.cpp | 48 +++++++++---------- .../src_lcao/exx_abfs-matrix_orbs22.cpp | 40 +++++++++------- .../exx_abfs-parallel-distribute-kmeans.cpp | 2 +- ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 19 ++++---- ABACUS.1.0.0/source/src_lcao/exx_opt_orb.cpp | 10 ++-- ABACUS.1.0.0/source/src_pw/energy.cpp | 4 +- ABACUS.1.0.0/source/src_pw/threshold_elec.cpp | 1 + ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py | 5 +- ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py | 6 +-- 12 files changed, 105 insertions(+), 101 deletions(-) diff --git a/ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_lcao-test.h b/ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_lcao-test.h index 78758182a1..d901086890 100644 --- a/ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_lcao-test.h +++ b/ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_lcao-test.h @@ -5,6 +5,7 @@ #include "src_global/complexmatrix.h" #include "../src_global/complexmatrix-test.h" #include "../src_global/matrix-test.h" +#include #include #include #include @@ -22,6 +23,12 @@ inline double time_during ( const timeval &t_start ) gettimeofday( &t_end, NULL ); return time_during(t_start,t_end); }; +inline double time_cut(timeval &t) +{ + const double t_delta = time_during(t); + gettimeofday(&t, NULL ); + return t_delta; +} diff --git a/ABACUS.1.0.0/source/src_global/sph_bessel_recursive-d2.cpp b/ABACUS.1.0.0/source/src_global/sph_bessel_recursive-d2.cpp index 3e8fdabafb..5e2af9bf4a 100644 --- a/ABACUS.1.0.0/source/src_global/sph_bessel_recursive-d2.cpp +++ b/ABACUS.1.0.0/source/src_global/sph_bessel_recursive-d2.cpp @@ -13,6 +13,8 @@ // Peize Lin test #include #include +#include"src_external/src_test/src_lcao/exx_lcao-test.h" +#include"src_lcao/global_fp.h" using namespace std; vector Sph_Bessel_Recursive_Pool::D2::sb_pool; @@ -46,20 +48,12 @@ void Sph_Bessel_Recursive::D2::cal_jlx_0( const int l_size, const size_t ix1_siz for( int l=0; l!=l_size; ++l ) { const double jlx0 = (0==l) ? 1.0 : 0.0; - + if( jlx[l].size()(1,jlx0)); if( jlx[l][0].size()>> &Rs ) -{ +{ ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); timeval t_start; gettimeofday( &t_start, NULL); @@ -131,32 +131,28 @@ gettimeofday( &t_start, NULL); for( const auto &RsA : Rs ) for( const auto &RsB : RsA.second ) { - set radials; - for( const double &R : RsB.second ) - { - const double position = R * ucell.lat0 / MOT.dr; - const size_t iq = static_cast(position); - for( size_t i=0; i!=4; ++i ) - radials.insert(iq+i); - } - - #if TEST_EXX_LCAO==1 + if( auto* const center2_orb11_sAB = static_cast>>>*const>( + MAP_EXIST(center2_orb11_s, RsA.first, RsB.first)) ) { - static int i=0; - ofstream ofs("Matrix_Orbs_Orbs_radials_"+TO_STRING(i++)); - for( const auto r : radials ) - ofs< radials; + for( const double &R : RsB.second ) + { + const double position = R * ucell.lat0 / MOT.dr; + const size_t iq = static_cast(position); + for( size_t i=0; i!=4; ++i ) + radials.insert(iq+i); + } +ofs<<"\t"< radials; - for( const double &R : RsB.second ) + if( auto* const center2_orb21_sAB = static_cast>>>>>*const>( + MAP_EXIST(center2_orb21_s, RsA.first, RsB.first)) ) { - const double position = R * ucell.lat0 / MOT.dr; - const size_t iq = static_cast(position); - for( size_t i=0; i!=4; ++i ) - radials.insert(iq+i); +timeval t_small; +gettimeofday(&t_small, NULL); + set radials; + for( const double &R : RsB.second ) + { + const double position = R * ucell.lat0 / MOT.dr; + const size_t iq = static_cast(position); + for( size_t i=0; i!=4; ++i ) + radials.insert(iq+i); + } +ofs<<"\t"< radials; - for( const double &R : RsB.second ) + if( auto* center2_orb22_sAB = static_cast>>>>>>>*>( + MAP_EXIST(center2_orb22_s, RsA.first, RsB.first)) ) { - const double position = R * ucell.lat0 / MOT.dr; - const size_t iq = static_cast(position); - for( size_t i=0; i!=4; ++i ) - radials.insert(iq+i); +timeval t_small; +gettimeofday(&t_small, NULL); + set radials; + for( const double &R : RsB.second ) + { + const double position = R * ucell.lat0 / MOT.dr; + const size_t iq = static_cast(position); + for( size_t i=0; i!=4; ++i ) + radials.insert(iq+i); + } +ofs<<"\t"< clusters(Nc+1); // clusters[Nc] just for atoms init vector atoms(ucell.nat); -ofstream ofs_mpi("kmeans_"+TO_STRING(Nc)+"_"+TO_STRING(MY_RANK),ofstream::app); +ofstream ofs_mpi(exx_lcao.test_dir.process+"kmeans_"+TO_STRING(Nc)+"_"+TO_STRING(MY_RANK),ofstream::app); auto init = [&]() -> void { diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp index 3f167f8109..4b5bde0dc8 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp @@ -530,9 +530,8 @@ ofs_mpi<<"TIME@ Conv_Coulomb_Pot_K::cal_orbs_ccp\t"<>> lcaos = Exx_Abfs::Construct_Orbs::change_orbs( ORB, this->kmesh_times ); @@ -39,9 +41,9 @@ void Exx_Opt_Orb::generate_matrix() const const Element_Basis_Index::Range range_jys = Exx_Abfs::Abfs_Index::construct_range( jle.jle ); const Element_Basis_Index::IndexLNM index_jys = Element_Basis_Index::construct_index( range_jys ); -cout<>> radial_R = get_radial_R(); #if TEST_EXX_RADIAL==2 @@ -90,7 +92,7 @@ cout<=1 m_abfs_abfs.init_radial_table(radial_R); #else - m_abfs_abfs.init_radial_table(radial_R); + m_abfs_abfs.init_radial_table(); #endif Exx_Abfs::Matrix_Orbs21 m_abfslcaos_lcaos; diff --git a/ABACUS.1.0.0/source/src_pw/energy.cpp b/ABACUS.1.0.0/source/src_pw/energy.cpp index aaf4183bf0..e0c04ddfee 100644 --- a/ABACUS.1.0.0/source/src_pw/energy.cpp +++ b/ABACUS.1.0.0/source/src_pw/energy.cpp @@ -469,7 +469,6 @@ double energy::ewald(void) ewaldg = 0.0; } - // in plane wave basis, only use k=0 point is not // called "gamma_only", only if the wave functions // are stored as double type, the gamma_only = true. @@ -498,7 +497,6 @@ double energy::ewald(void) } } - ewaldg = FOUR_PI / ucell.omega * ewaldg; // cout << "\n ewaldg = " << ewaldg; @@ -515,7 +513,7 @@ double energy::ewald(void) // R-space sum here (only done for the processor that contains G=0) ewaldr = 0.0; if (pw.gstart == 1) - { + { rmax = 4.0 / sqrt(alpha) / ucell.lat0; if(test_energy)OUT(ofs_running,"rmax(unit lat0)",rmax); // with this choice terms up to ZiZj*erfc(4) are counted (erfc(4)=2x10^-8 diff --git a/ABACUS.1.0.0/source/src_pw/threshold_elec.cpp b/ABACUS.1.0.0/source/src_pw/threshold_elec.cpp index b348fc7b1b..daf3477115 100644 --- a/ABACUS.1.0.0/source/src_pw/threshold_elec.cpp +++ b/ABACUS.1.0.0/source/src_pw/threshold_elec.cpp @@ -20,6 +20,7 @@ Threshold_Elec::Threshold_Elec() void Threshold_Elec::set_ethr(void) const { + TITLE("Threshold_Elec","set_ethr"); //======================================================================== // setup ethr see setup.f90 Page 5/14 // setup ethr, the convergence threshold for eigenvalues diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py b/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py index 26b4989420..650e8a4537 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py @@ -41,8 +41,7 @@ def set_input(folders_matrix): "weight": [weight for weight,nbands in folders_matrix.values()], "Rcut": read_stru.get_Rcut(), "dr": {T:utils.dr for T in Ts}, - "Ecut": {T:Ecut for T in Ts}, - "TSrate": 0.000001 + "Ecut": {T:Ecut for T in Ts} }, "C_init_info":{ "init_from_file": False }, "V_info": @@ -63,7 +62,7 @@ def cal(input): #!/bin/bash #PBS -q batch #PBS -l nodes=1:ppn=1 - #PBS -l walltime=24:00:00 + #PBS -l walltime=2:00:00 #PBS -o job.log #PBS -e job.err ulimit -s unlimited diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py b/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py index 5281acb875..96a24b6dfd 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py @@ -88,8 +88,8 @@ def cal_ABACUS(T1,T2,i_dis): file.write(textwrap.dedent(f"""\ #!/bin/bash #PBS -q batch - #PBS -l nodes=1:ppn=4 - #PBS -l walltime=24:00:00 + #PBS -l nodes=1:ppn=1 + #PBS -l walltime=1:00:00 #PBS -o job.log #PBS -e job.err ulimit -s unlimited @@ -102,7 +102,7 @@ def cal_ABACUS(T1,T2,i_dis): if utils.sub=="qsub": os.system("qsub sub.sh") elif utils.sub=="tianh2": - os.system(f'yhrun -n 1 -c 4 {info["ABACUS"]} >Log.txt') + os.system(f'yhrun -n 1 -c 1 {info["ABACUS"]} >Log.txt') os.chdir("../") # dis_opt[T1,T2] = [..., dis, ...] From e67e352bf998f2a4439c4750cd4a1f1113e2096b Mon Sep 17 00:00:00 2001 From: Peize Lin Date: Tue, 14 May 2019 19:59:32 +0800 Subject: [PATCH 003/233] add 'bsub' in opt_lcao_bash and opt_abfs_bash --- ABACUS.1.0.0/tools/opt_abfs_bash/exx.py | 12 +++ ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py | 13 +++ ABACUS.1.0.0/tools/opt_abfs_bash/utils.py | 2 +- ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py | 13 ++- .../tools/opt_lcao_bash/print_file.py | 81 +++++++++++++------ 5 files changed, 93 insertions(+), 28 deletions(-) diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py b/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py index 088ac836f2..2dc1ef244a 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py @@ -48,10 +48,22 @@ def cal(): EXEC={info["ABACUS"]} mpirun -n 1 $EXEC """)) + elif utils.sub=="bsub": + with open(f"{utils.folder_exx}/sub.sh","w") as file: + file.write(textwrap.dedent(f"""\ + #!/bin/sh + #BSUB -q renxg + #BSUB -o job.log -e job.err + #BSUB -n 6 + export OMP_NUM_THREADS=6 + mpirun -n 1 {info['ABACUS']} + """)) os.chdir(utils.folder_exx) if utils.sub=="qsub": os.system("qsub sub.sh") + elif utils.sub=="bsub": + os.system(f"bsub < sub.sh") elif utils.sub=="tianhe2": os.system(f'yhrun -N 1 -n 1 -c 24 -t 1440 {info["ABACUS"]} >Log.txt 2>&1 &') else: diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py b/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py index 96a24b6dfd..5859e02ad9 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py @@ -97,10 +97,23 @@ def cal_ABACUS(T1,T2,i_dis): EXEC={info["ABACUS"]} mpirun -n 1 $EXEC """)) + elif utils.sub=="bsub": + with open(f"{folder}/sub.sh","w") as file: + file.write(textwrap.dedent(f"""\ + #!/bin/sh + #BSUB -q renxg + #BSUB -o job.log -e job.err + #BSUB -n 1 + export OMP_NUM_THREADS=1 + EXEC={info["ABACUS"]} + mpirun -n 1 $EXEC + """)) os.chdir(folder) if utils.sub=="qsub": os.system("qsub sub.sh") + elif utils.sub=="bsub": + os.system("bsub < sub.sh") elif utils.sub=="tianh2": os.system(f'yhrun -n 1 -c 1 {info["ABACUS"]} >Log.txt') os.chdir("../") diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/utils.py b/ABACUS.1.0.0/tools/opt_abfs_bash/utils.py index c9df56d1ea..82e231db04 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/utils.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/utils.py @@ -8,7 +8,7 @@ def read_info(flag=True): "ABACUS":"dir/ABACUS/ABACUS.mpi.1.0.0", "opt_orb":"dir/opt_orb/main.py", "Nu":[7,10,8,3,1], - "dimer_num":5, + "dimer_num":5 } """ with open("info","r") as file: diff --git a/ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py b/ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py index 002d462bbd..6a00b503d1 100644 --- a/ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py +++ b/ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py @@ -11,7 +11,12 @@ def cal_pw(): os.mkdir(folder) os.chdir(folder) print_file_pw(info,distance) - os.system("qsub sub.sh") + if utils.sub=="qsub": + os.system("qsub sub.sh") + elif utils.sub=="bsub": + os.system("bsub < sub.sh") + else: + raise KeyError("utils.sub = ",utils.sub) os.chdir("../") def cal_opt(): @@ -20,6 +25,12 @@ def cal_opt(): os.chdir("opt_orb") print_file_opt(info,dis) os.system("qsub sub.sh") + if utils.sub=="qsub": + os.system("qsub sub.sh") + elif utils.sub=="bsub": + os.system("bsub < sub.sh") + else: + raise KeyError("utils.sub = ",utils.sub) os.chdir("../") if __name__=="__main__": diff --git a/ABACUS.1.0.0/tools/opt_lcao_bash/print_file.py b/ABACUS.1.0.0/tools/opt_lcao_bash/print_file.py index 9442e5c880..c04803f5e2 100644 --- a/ABACUS.1.0.0/tools/opt_lcao_bash/print_file.py +++ b/ABACUS.1.0.0/tools/opt_lcao_bash/print_file.py @@ -98,19 +98,34 @@ def print_file_pw(info,dis): - with open("sub.sh","w") as file: - file.write(textwrap.dedent(f"""\ - #!/bin/bash - #PBS -q batch - #PBS -l nodes={info["exe"]["qsub"][0]}:ppn={info["exe"]["qsub"][1]} - #PBS -l walltime=1:00:00 - #PBS -o job.log - #PBS -e job.err - ulimit -s unlimited - cd $PBS_O_WORKDIR - EXEC={info["exe"]["exe_pw"]} - mpirun -n {info["exe"]["qsub"][0]*info["exe"]["qsub"][1]} $EXEC - """)) + elif utils.sub=="qsub": + with open("sub.sh","w") as file: + file.write(textwrap.dedent(f"""\ + #!/bin/bash + #PBS -q batch + #PBS -l nodes={info["exe"]["qsub"][0]}:ppn={info["exe"]["qsub"][1]} + #PBS -l walltime=1:00:00 + #PBS -o job.log + #PBS -e job.err + ulimit -s unlimited + cd $PBS_O_WORKDIR + EXEC={info["exe"]["exe_pw"]} + mpirun -n {info["exe"]["qsub"][0]*info["exe"]["qsub"][1]} $EXEC + """)) + elif utils.sub=="bsub": + with open("sub.sh","w") as file: + core = info["exe"]["qsub"][0]*info["exe"]["qsub"][1] + file.write(textwrap.dedent(f"""\ + #!/bin/sh + #BSUB -q renxg + #BSUB -o job.log -e job.err + #BSUB -n {core} + export OMP_NUM_THREADS=1 + EXEC={info["exe"]["exe_pw"]} + mpirun -n {core} $EXEC + """)) + else: + raise KeyError("utils.sub = ",utils.sub) @@ -141,16 +156,30 @@ def print_file_opt(info,dis): file.write(json.dumps(input,indent=4)) - with open("sub.sh","w") as file: - file.write(textwrap.dedent(f"""\ - #!/bin/bash - #PBS -q batch - #PBS -l nodes=1:ppn=1 - #PBS -l walltime=1:00:00 - #PBS -o job.log - #PBS -e job.err - ulimit -s unlimited - cd $PBS_O_WORKDIR - EXEC={info["exe"]["exe_orbital"]} - python3 $EXEC - """)) \ No newline at end of file + elif utils.sub=="qsub": + with open("sub.sh","w") as file: + file.write(textwrap.dedent(f"""\ + #!/bin/bash + #PBS -q batch + #PBS -l nodes=1:ppn=1 + #PBS -l walltime=1:00:00 + #PBS -o job.log + #PBS -e job.err + ulimit -s unlimited + cd $PBS_O_WORKDIR + EXEC={info["exe"]["exe_orbital"]} + python3 $EXEC + """)) + elif utils.sub=="bsub": + with open("sub.sh","w") as file: + file.write(textwrap.dedent(f"""\ + #!/bin/sh + #BSUB -q renxg + #BSUB -o job.log -e job.err + #BSUB -n 1 + export OMP_NUM_THREADS=1 + EXEC={info["exe"]["exe_orbital"]} + python3 $EXEC + """)) + else: + raise KeyError("utils.sub = ",utils.sub) \ No newline at end of file From 212f75d3663cd5cfc20899eb58ac5fb2cc50620e Mon Sep 17 00:00:00 2001 From: Peize Lin Date: Thu, 6 Jun 2019 05:04:56 +0800 Subject: [PATCH 004/233] 1. add opt_abfs_bash/set_dimer nband cal 2. add opt_abfs_bash skip_notes 3. update opt_abfs_bash and opt_lcao_bash mkdir --- ABACUS.1.0.0/tools/opt_abfs_bash/exx.py | 3 +- ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py | 5 +- ABACUS.1.0.0/tools/opt_abfs_bash/read_stru.py | 52 ++++++++++++++----- ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py | 17 +++--- ABACUS.1.0.0/tools/opt_abfs_bash/utils.py | 1 - ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py | 5 +- 6 files changed, 57 insertions(+), 26 deletions(-) diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py b/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py index 2dc1ef244a..c0a1368066 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py @@ -1,11 +1,12 @@ import os import re import textwrap +import pathlib import utils import read_stru def cal(): - os.mkdir(utils.folder_exx) + pathlib.Path(utils.folder_exx).mkdir(parents=True,exist_ok=False) os.system(f"cp INPUT {utils.folder_exx}/") os.system(f"cp KPT {utils.folder_exx}/") diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py b/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py index 650e8a4537..71317c78b2 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py @@ -2,11 +2,12 @@ import os import re import textwrap +import pathlib import read_stru import utils def cp_matrix(folders_matrix): - os.mkdir(utils.folder_opt+"/"+utils.folder_opt_matrix) + pathlib.Path(utils.folder_opt+"/"+utils.folder_opt_matrix).mkdir(parents=True,exist_ok=False) folders_same_atom = set() for folder_matrix in folders_matrix: T1,T2 = folder_matrix.split("_")[0].split("-") @@ -86,7 +87,7 @@ def cal(input): os.chdir("../") def all(): - os.mkdir(utils.folder_opt) + pathlib.Path(utils.folder_opt).mkdir(parents=True,exist_ok=False) with open("folders","r") as file: folders_matrix = json.loads(file.read()) cp_matrix(folders_matrix.keys()) diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/read_stru.py b/ABACUS.1.0.0/tools/opt_abfs_bash/read_stru.py index 58523781be..2038e99867 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/read_stru.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/read_stru.py @@ -3,19 +3,26 @@ import itertools import numba import functools +import operator import os import collections import decimal import json import utils +def skip_notes(line): + line = re.compile(r"#.*").sub("",line) + line = re.compile(r"//.*").sub("",line) + line = line.strip() + return line + @functools.lru_cache(maxsize=None) def get_input_dict(): input_dict = dict() with open("INPUT","r") as file: for line in file: - line = line.strip() - if not line or line.startswith("#") or line=="INPUT_PARAMETERS": + line = skip_notes(line) + if not line or line=="INPUT_PARAMETERS": continue label, value = re.compile(r"\s+").split( line, maxsplit=1 ) input_dict[label] = value @@ -41,7 +48,7 @@ def search_in_input(label): def get_k(): with open("KPT","r") as file: utils.search_sentence(file,"Gamma") - return list(map(int,file.readline().split()[:3])) + return list(map(int,skip_notes(file.readline()).split()[:3])) @functools.lru_cache(maxsize=None) def get_T(): @@ -50,7 +57,7 @@ def get_T(): with open("STRU","r") as file: utils.search_sentence(file,"ATOMIC_SPECIES") for it in range(ntype): - line = file.readline() + line = skip_notes(file.readline()) T.append(line.split()[0]) return T @@ -62,7 +69,8 @@ def get_Rcut(): for T in Ts: with open(lcao_path[T],"r") as file: for line in file: - if line.strip().startswith("Radius Cutoff(a.u.)"): + line = skip_notes(line) + if line.startswith("Radius Cutoff(a.u.)"): Rcut[T] = float(line.split()[-1]) break return Rcut @@ -74,7 +82,7 @@ def get_pseudo_path(): with open("STRU","r") as file: utils.search_sentence(file,"ATOMIC_SPECIES") for T in Ts: - path[T] = file.readline().split()[-1] + path[T] = skip_notes(file.readline()).split()[-1] return path @functools.lru_cache(maxsize=None) @@ -84,24 +92,44 @@ def get_lcao_path(): with open("STRU","r") as file: utils.search_sentence(file,"NUMERICAL_ORBITAL") for T in Ts: - path[T] = os.path.abspath(file.readline().strip()) + path[T] = os.path.abspath(skip_notes(file.readline())) return path @functools.lru_cache(maxsize=None) def get_lattice(): with open("STRU","r") as file: utils.search_sentence(file,"LATTICE_CONSTANT") - lat0 = float(file.readline().split()[0]) + lat0 = float(skip_notes(file.readline()).split()[0]) with open("STRU","r") as file: utils.search_sentence(file,"LATTICE_VECTORS") lat_vec = [] for i in range(3): - lat_vec.append(list(map(float,file.readline().split()))) + lat_vec.append(list(map(float,skip_notes(file.readline()).split()))) lat_vec = np.array(lat_vec) with open("STRU","r") as file: utils.search_sentence(file,"ATOMIC_POSITIONS") - position = file.readline().strip() + position = skip_notes(file.readline()) return lat0, lat_vec, position + +@functools.lru_cache(maxsize=None) +def get_lcao(): + lcao = collections.defaultdict(list) + lcao_path = get_lcao_path() + for T in lcao_path: + with open(lcao_path[T],"r") as file: + for line in file: + line = skip_notes(line) + if line.startswith("Number of"): + lcao[T].append(int(line.split()[-1])) + return dict(lcao) + +@functools.lru_cache(maxsize=None) +def get_nw(): + nw = dict() + lcao = get_lcao() + for T in lcao: + nw[T] = functools.reduce(operator.add,((2*l+1)*n for l,n in enumerate(lcao[T]))) + return nw # R[T] = [..., [xi,yi,zi], ...] def get_R(): @@ -111,10 +139,10 @@ def get_R(): for T in Ts: utils.search_sentence(file,T) utils.ignore_lines(file,1) - na = int(file.readline().split()[0]) + na = int(skip_notes(file.readline()).split()[0]) R_tmp = [] for i in range(na): - R_tmp.append(list(map(float,file.readline().split()[:3]))) + R_tmp.append(list(map(float,skip_notes(file.readline()).split()[:3]))) R[T] = np.array(R_tmp) return R diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py b/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py index 5859e02ad9..166f085b08 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py @@ -6,27 +6,28 @@ import textwrap import utils import collections +import pathlib from sklearn.cluster import KMeans import read_stru def cal_ABACUS(T1,T2,i_dis): - folder = utils.folder_name(T1,T2,i_dis) - os.mkdir(folder) + folder = pathlib.Path(utils.folder_name(T1,T2,i_dis)).resolve() + folder.mkdir(parents=True,exist_ok=False) - with open(f"{folder}/INPUT","w") as file: + with open(folder/"INPUT","w") as file: info = utils.read_info() input_dict = read_stru.get_input_dict() input_dict["ntype"] = 1 if T1==T2 else 2 input_dict["exx_hybrid_type"] = 'opt_orb' - input_dict["nbands"] = utils.nband * (1 if abs(i_dis)<1E-10 else 2) + input_dict["nbands"] = (read_stru.get_nw()[T1] if abs(i_dis)<1E-10 else read_stru.get_nw()[T1]+read_stru.get_nw()[T2]) input_dict["nspin"] = 1 input_dict["gamma_only"] = 1 input_dict["pseudo_dir"] = os.path.abspath(input_dict.get("pseudo_dir",r"./")) input_dict["exx_opt_orb_lmax"] = len(info["Nu"])-1 read_stru.print_input(file,input_dict) - with open(f"{folder}/STRU","w") as file: + with open(folder/"STRU","w") as file: Ts = (T1,) if T1==T2 else (T1,T2) file.write("ATOMIC_SPECIES\n") pseudo_path = read_stru.get_pseudo_path() @@ -74,7 +75,7 @@ def cal_ABACUS(T1,T2,i_dis): {i_dis} 0 0 0 0 0 """)) - with open(f"{folder}/KPT","w") as file: + with open(folder/"KPT","w") as file: file.write(textwrap.dedent(f"""\ K_POINTS 0 @@ -84,7 +85,7 @@ def cal_ABACUS(T1,T2,i_dis): info = utils.read_info() if utils.sub=="qsub": - with open(f"{folder}/sub.sh","w") as file: + with open(folder/"sub.sh","w") as file: file.write(textwrap.dedent(f"""\ #!/bin/bash #PBS -q batch @@ -98,7 +99,7 @@ def cal_ABACUS(T1,T2,i_dis): mpirun -n 1 $EXEC """)) elif utils.sub=="bsub": - with open(f"{folder}/sub.sh","w") as file: + with open(folder/"sub.sh","w") as file: file.write(textwrap.dedent(f"""\ #!/bin/sh #BSUB -q renxg diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/utils.py b/ABACUS.1.0.0/tools/opt_abfs_bash/utils.py index 82e231db04..eb96cc24c0 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/utils.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/utils.py @@ -29,7 +29,6 @@ def floatlist_str(l): sub = "qsub" dr = 0.01 -nband = 8 def folder_name(T1,T2,i_dis): return f"{T1}-{T2}_{i_dis}" try: diff --git a/ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py b/ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py index 6a00b503d1..d9f72578dd 100644 --- a/ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py +++ b/ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py @@ -1,5 +1,6 @@ import os import sys +import pathlib from read_info import read_info from print_file import print_file_pw, print_file_opt from dis import dis @@ -8,7 +9,7 @@ def cal_pw(): info = read_info("info.json") for distance in dis[info["input"]["element"]]: folder = f'{info["input"]["element"]}-{info["input"]["rcut"]}-{distance}' - os.mkdir(folder) + pathlib.Path(folder).mkdir(parents=True,exist_ok=False) os.chdir(folder) print_file_pw(info,distance) if utils.sub=="qsub": @@ -21,7 +22,7 @@ def cal_pw(): def cal_opt(): info = read_info("info.json") - os.mkdir("opt_orb") + pathlib.Path("opt_orb").mkdir(parents=True,exist_ok=False) os.chdir("opt_orb") print_file_opt(info,dis) os.system("qsub sub.sh") From 6f63f11f436a7b02b9f7bc0c707a53117f7d38bb Mon Sep 17 00:00:00 2001 From: Peize Lin Date: Fri, 28 Jun 2019 11:18:22 +0800 Subject: [PATCH 005/233] update Exx_Lcao::cal_Hexx_thread loop structure --- ABACUS.1.0.0/source/Makefile.vars | 2 +- ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 403 +++++++++++----------- 2 files changed, 199 insertions(+), 206 deletions(-) diff --git a/ABACUS.1.0.0/source/Makefile.vars b/ABACUS.1.0.0/source/Makefile.vars index c59e29dc28..b66e4f4c83 100644 --- a/ABACUS.1.0.0/source/Makefile.vars +++ b/ABACUS.1.0.0/source/Makefile.vars @@ -2,6 +2,6 @@ CPLUSPLUS = icpc CPLUSPLUS_MPI = mpiicpc BOOST_DIR = /home/linpz/software/boost_1_66_0 LAPACK_DIR = /opt/intel/mkl -FFTW_DIR = /home/linpz/software/fftw-2.1.5 +FFTW_DIR = /home/linpz/software/fftw-3.3.8 ELPA_DIR = /home/linpz/software/elpa-2016.05.004 LIBXC_DIR = /home/linpz/software/libxc-4.0.4 diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp index 4b5bde0dc8..ab685afca7 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp @@ -1316,255 +1316,248 @@ timeval t_start, t_start_all; gettimeofday( &t_start_all, NULL); vector,matrix>>>> HexxR_tmp(NSPIN); - - while(true) + + while(const size_t i_atom_pair_now = i_atom_pair++ < atom_pairs_core.size() ) { - const size_t i_atom_pair_now = i_atom_pair++; - if( i_atom_pair_now >= atom_pairs_core.size() ) - { - if(!vector_empty(HexxR_tmp)) - { - while( Hexx_lock.test_and_set() ); - insert_matrixes(HexxR,HexxR_tmp); - Hexx_lock.clear(); - } -ofs_thread<<"TIME@ Exx_Lcao::cal_Hexx_thread\t"< & box3 = Cp1.first; + const auto & Cp13 = Cp1.second; - for( const auto & Cp1 : Cp1s.second ) + for( const auto & Cp2 : Cp2s.second ) { - const Abfs::Vector3_Order & box3 = Cp1.first; - const auto & Cp13 = Cp1.second; + const Abfs::Vector3_Order & box4 = Cp2.first; + const auto & Cp24 = Cp2.second; + + if( schwarz.screen( iat1,iat2,iat3,iat4, box3,box4 ) ) continue; - for( const auto & Cp2 : Cp2s.second ) + for( const auto &Vp : Vps.at(iat1).at(iat2) ) { - const Abfs::Vector3_Order & box4 = Cp2.first; - const auto & Cp24 = Cp2.second; - - if( schwarz.screen( iat1,iat2,iat3,iat4, box3,box4 ) ) continue; - - for( const auto &Vp : Vps.at(iat1).at(iat2) ) - { - const Abfs::Vector3_Order & box2 = Vp.first; + const Abfs::Vector3_Order & box2 = Vp.first; - const matrix & C_13 = *Cp13, // iw1*iw3, \mu1 - & V = *Vp.second, // \mu1, \mu2 - & C_24 = *Cp24; // iw2*iw4, \mu2 + const matrix & C_13 = *Cp13, // iw1*iw3, \mu1 + & V = *Vp.second, // \mu1, \mu2 + & C_24 = *Cp24; // iw2*iw4, \mu2 - const Exx_Abfs::Screen::Cauchy::Info_Step info_step = cauchy.input_info( iat1, iat2, iat3, iat4, box2, box3, box4 ); - int cauchy_postcal; - if(!( cauchy_postcal = cauchy.postcalA( info_step ) )) continue; + const Exx_Abfs::Screen::Cauchy::Info_Step info_step = cauchy.input_info( iat1, iat2, iat3, iat4, box2, box3, box4 ); + int cauchy_postcal; + if(!( cauchy_postcal = cauchy.postcalA( info_step ) )) continue; // assert( V.nc==C_24.nc ); - const matrix VC_24 = gemm( // \mu1, iw2*iw4 - 'N', 'T', - index_abfs[it1].count_size, - index_lcaos[it2].count_size * index_lcaos[it4].count_size, - index_abfs[it2].count_size, - 1, V, C_24 ); - const matrix VC_24_T = transform( VC_24, // iw2*\mu1, iw4 - index_abfs[it1].count_size, - index_lcaos[it2].count_size, - index_lcaos[it4].count_size ); - if(!( cauchy_postcal = cauchy.postcalB( info_step, VC_24_T, index_lcaos[it2].count_size, index_abfs[it1].count_size, index_lcaos[it4].count_size, cauchy_postcal ) )) continue; - - const matrix C_13_T = transform( C_13, // iw3*iw1, \mu1 - index_lcaos[it1].count_size, - index_lcaos[it3].count_size, - index_abfs[it1].count_size ); - - for( size_t is=0; is!=NSPIN; ++is ) + const matrix VC_24 = gemm( // \mu1, iw2*iw4 + 'N', 'T', + index_abfs[it1].count_size, + index_lcaos[it2].count_size * index_lcaos[it4].count_size, + index_abfs[it2].count_size, + 1, V, C_24 ); + const matrix VC_24_T = transform( VC_24, // iw2*\mu1, iw4 + index_abfs[it1].count_size, + index_lcaos[it2].count_size, + index_lcaos[it4].count_size ); + if(!( cauchy_postcal = cauchy.postcalB( info_step, VC_24_T, index_lcaos[it2].count_size, index_abfs[it1].count_size, index_lcaos[it4].count_size, cauchy_postcal ) )) continue; + + const matrix C_13_T = transform( C_13, // iw3*iw1, \mu1 + index_lcaos[it1].count_size, + index_lcaos[it3].count_size, + index_abfs[it1].count_size ); + + for( size_t is=0; is!=NSPIN; ++is ) + { + switch( cauchy_postcal ) // Attention: case and go on calculating { - switch( cauchy_postcal ) // Attention: case and go on calculating + case 4: { - case 4: + const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat3, iat4, Abfs::Vector3_Order(box2-box3+box4)%Born_von_Karman_period )); + if( DM_ptr ) { - const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat3, iat4, Abfs::Vector3_Order(box2-box3+box4)%Born_von_Karman_period )); - if( DM_ptr ) + const matrix DVC_32 = gemm( // iw3, \mu1*iw2 + 'N', 'T', + index_lcaos[it3].count_size, + index_abfs[it1].count_size * index_lcaos[it2].count_size, + index_lcaos[it4].count_size, + 1, + *DM_ptr, + VC_24 ); + if( cauchy.postcalC( info_step, DVC_32, index_lcaos[it3].count_size, index_abfs[it1].count_size, index_lcaos[it2].count_size, 1 ) ) { - const matrix DVC_32 = gemm( // iw3, \mu1*iw2 - 'N', 'T', - index_lcaos[it3].count_size, - index_abfs[it1].count_size * index_lcaos[it2].count_size, - index_lcaos[it4].count_size, - 1, - *DM_ptr, - VC_24 ); - if( cauchy.postcalC( info_step, DVC_32, index_lcaos[it3].count_size, index_abfs[it1].count_size, index_lcaos[it2].count_size, 1 ) ) + const matrix Hexx_12 = gemm( // iw1, iw2 + 'N', 'N', + index_lcaos[it1].count_size, + index_lcaos[it2].count_size, + index_lcaos[it3].count_size * index_abfs[it1].count_size, + -2, C_13, DVC_32 ); + if( cauchy.postcalD( Hexx_12 ) ) { - const matrix Hexx_12 = gemm( // iw1, iw2 - 'N', 'N', - index_lcaos[it1].count_size, - index_lcaos[it2].count_size, - index_lcaos[it3].count_size * index_abfs[it1].count_size, - -2, C_13, DVC_32 ); - if( cauchy.postcalD( Hexx_12 ) ) + if(iat1!=iat2) { - if(iat1!=iat2) - { - const matrix Hexx_21 = transpose(Hexx_12); - if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat2, iat1, Abfs::Vector3_Order(-box2)%Born_von_Karman_period )) ) - *HexxR_ptr += Hexx_21; - else - HexxR_tmp[is][iat2][iat1][Abfs::Vector3_Order(-box2)%Born_von_Karman_period] = std::move(Hexx_21); - } - if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat1, iat2, Abfs::Vector3_Order(box2)%Born_von_Karman_period )) ) - *HexxR_ptr += Hexx_12; + const matrix Hexx_21 = transpose(Hexx_12); + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat2, iat1, Abfs::Vector3_Order(-box2)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_21; else - HexxR_tmp[is][iat1][iat2][Abfs::Vector3_Order(box2)%Born_von_Karman_period] = std::move(Hexx_12); + HexxR_tmp[is][iat2][iat1][Abfs::Vector3_Order(-box2)%Born_von_Karman_period] = std::move(Hexx_21); } + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat1, iat2, Abfs::Vector3_Order(box2)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_12; + else + HexxR_tmp[is][iat1][iat2][Abfs::Vector3_Order(box2)%Born_von_Karman_period] = std::move(Hexx_12); } } - } // end case 4 - case 3: + } + } // end case 4 + case 3: + { + if( const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat1, iat4, Abfs::Vector3_Order(box2+box4)%Born_von_Karman_period )) ) { - if( const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat1, iat4, Abfs::Vector3_Order(box2+box4)%Born_von_Karman_period )) ) + const matrix DVC_12 = gemm( // iw1, \mu1*iw2 + 'N', 'T', + index_lcaos[it1].count_size, + index_abfs[it1].count_size * index_lcaos[it2].count_size, + index_lcaos[it4].count_size, + 1, + *DM_ptr, + VC_24 ); + if( cauchy.postcalC( info_step, DVC_12, index_lcaos[it1].count_size, index_abfs[it1].count_size, index_lcaos[it2].count_size, 3 ) ) { - const matrix DVC_12 = gemm( // iw1, \mu1*iw2 - 'N', 'T', - index_lcaos[it1].count_size, - index_abfs[it1].count_size * index_lcaos[it2].count_size, - index_lcaos[it4].count_size, - 1, - *DM_ptr, - VC_24 ); - if( cauchy.postcalC( info_step, DVC_12, index_lcaos[it1].count_size, index_abfs[it1].count_size, index_lcaos[it2].count_size, 3 ) ) + const matrix Hexx_32 = gemm( // iw3, iw2 + 'N', 'N', + index_lcaos[it3].count_size, + index_lcaos[it2].count_size, + index_lcaos[it1].count_size * index_abfs[it1].count_size, + -2, C_13_T, DVC_12 ); + if( cauchy.postcalD( Hexx_32 ) ) { - const matrix Hexx_32 = gemm( // iw3, iw2 - 'N', 'N', - index_lcaos[it3].count_size, - index_lcaos[it2].count_size, - index_lcaos[it1].count_size * index_abfs[it1].count_size, - -2, C_13_T, DVC_12 ); - if( cauchy.postcalD( Hexx_32 ) ) + if(iat1!=iat2) { - if(iat1!=iat2) - { - const matrix Hexx_23 = transpose(Hexx_32); - if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat2, iat3, Abfs::Vector3_Order(-box2+box3)%Born_von_Karman_period )) ) - *HexxR_ptr += Hexx_23; - else - HexxR_tmp[is][iat2][iat3][Abfs::Vector3_Order(-box2+box3)%Born_von_Karman_period] = std::move(Hexx_23); - } - if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat3, iat2, Abfs::Vector3_Order(box2-box3)%Born_von_Karman_period )) ) - *HexxR_ptr += Hexx_32; + const matrix Hexx_23 = transpose(Hexx_32); + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat2, iat3, Abfs::Vector3_Order(-box2+box3)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_23; else - HexxR_tmp[is][iat3][iat2][Abfs::Vector3_Order(box2-box3)%Born_von_Karman_period] = std::move(Hexx_32); + HexxR_tmp[is][iat2][iat3][Abfs::Vector3_Order(-box2+box3)%Born_von_Karman_period] = std::move(Hexx_23); } + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat3, iat2, Abfs::Vector3_Order(box2-box3)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_32; + else + HexxR_tmp[is][iat3][iat2][Abfs::Vector3_Order(box2-box3)%Born_von_Karman_period] = std::move(Hexx_32); } } - } // end case 3 - case 2: + } + } // end case 3 + case 2: + { + if( const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat3, iat2, Abfs::Vector3_Order(box2-box3)%Born_von_Karman_period )) ) { - if( const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat3, iat2, Abfs::Vector3_Order(box2-box3)%Born_von_Karman_period )) ) + const matrix DVC_34 = gemm( // iw3, \mu1*iw4 + 'N', 'N', + index_lcaos[it3].count_size, + index_abfs[it1].count_size * index_lcaos[it4].count_size, + index_lcaos[it2].count_size, + 1, + *DM_ptr, + VC_24_T ); + if( cauchy.postcalC( info_step, DVC_34, index_lcaos[it3].count_size, index_abfs[it1].count_size, index_lcaos[it4].count_size, 1 ) ) { - const matrix DVC_34 = gemm( // iw3, \mu1*iw4 + const matrix Hexx_14 = gemm( // iw1, iw4 'N', 'N', - index_lcaos[it3].count_size, - index_abfs[it1].count_size * index_lcaos[it4].count_size, - index_lcaos[it2].count_size, - 1, - *DM_ptr, - VC_24_T ); - if( cauchy.postcalC( info_step, DVC_34, index_lcaos[it3].count_size, index_abfs[it1].count_size, index_lcaos[it4].count_size, 1 ) ) + index_lcaos[it1].count_size, + index_lcaos[it4].count_size, + index_lcaos[it3].count_size * index_abfs[it1].count_size, + -2, C_13, DVC_34 ); + if( cauchy.postcalD( Hexx_14 ) ) { - const matrix Hexx_14 = gemm( // iw1, iw4 - 'N', 'N', - index_lcaos[it1].count_size, - index_lcaos[it4].count_size, - index_lcaos[it3].count_size * index_abfs[it1].count_size, - -2, C_13, DVC_34 ); - if( cauchy.postcalD( Hexx_14 ) ) + if(iat1!=iat2) { - if(iat1!=iat2) - { - const matrix Hexx_41 = transpose(Hexx_14); - if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat4, iat1, Abfs::Vector3_Order(-box2-box4)%Born_von_Karman_period )) ) - *HexxR_ptr += Hexx_41; - else - HexxR_tmp[is][iat4][iat1][Abfs::Vector3_Order(-box2-box4)%Born_von_Karman_period] = std::move(Hexx_41); - } - if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat1, iat4, Abfs::Vector3_Order(box2+box4)%Born_von_Karman_period )) ) - *HexxR_ptr += Hexx_14; + const matrix Hexx_41 = transpose(Hexx_14); + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat4, iat1, Abfs::Vector3_Order(-box2-box4)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_41; else - HexxR_tmp[is][iat1][iat4][Abfs::Vector3_Order(box2+box4)%Born_von_Karman_period] = std::move(Hexx_14); - } - } + HexxR_tmp[is][iat4][iat1][Abfs::Vector3_Order(-box2-box4)%Born_von_Karman_period] = std::move(Hexx_41); + } + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat1, iat4, Abfs::Vector3_Order(box2+box4)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_14; + else + HexxR_tmp[is][iat1][iat4][Abfs::Vector3_Order(box2+box4)%Born_von_Karman_period] = std::move(Hexx_14); + } } - } // end case 2 - case 1: + } + } // end case 2 + case 1: + { + if( const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat1, iat2, Abfs::Vector3_Order(box2)%Born_von_Karman_period )) ) { - if( const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat1, iat2, Abfs::Vector3_Order(box2)%Born_von_Karman_period )) ) + const matrix DVC_14 = gemm( // iw1, \mu1*iw4 + 'N', 'N', + index_lcaos[it1].count_size, + index_abfs[it1].count_size * index_lcaos[it4].count_size, + index_lcaos[it2].count_size, + 1, + *DM_ptr, + VC_24_T ); + if( cauchy.postcalC( info_step, DVC_14, index_lcaos[it1].count_size, index_abfs[it1].count_size, index_lcaos[it4].count_size, 3 ) ) { - const matrix DVC_14 = gemm( // iw1, \mu1*iw4 + const matrix Hexx_34 = gemm( // iw3, iw4 'N', 'N', - index_lcaos[it1].count_size, - index_abfs[it1].count_size * index_lcaos[it4].count_size, - index_lcaos[it2].count_size, - 1, - *DM_ptr, - VC_24_T ); - if( cauchy.postcalC( info_step, DVC_14, index_lcaos[it1].count_size, index_abfs[it1].count_size, index_lcaos[it4].count_size, 3 ) ) + index_lcaos[it3].count_size, + index_lcaos[it4].count_size, + index_lcaos[it1].count_size * index_abfs[it1].count_size, + -2, C_13_T, DVC_14 ); + if( cauchy.postcalD( Hexx_34 ) ) { - const matrix Hexx_34 = gemm( // iw3, iw4 - 'N', 'N', - index_lcaos[it3].count_size, - index_lcaos[it4].count_size, - index_lcaos[it1].count_size * index_abfs[it1].count_size, - -2, C_13_T, DVC_14 ); - if( cauchy.postcalD( Hexx_34 ) ) + if(iat1!=iat2) { - if(iat1!=iat2) - { - const matrix Hexx_43 = transpose(Hexx_34); - if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat4, iat3, Abfs::Vector3_Order(-box2+box3-box4)%Born_von_Karman_period )) ) - *HexxR_ptr += Hexx_43; - else - HexxR_tmp[is][iat4][iat3][Abfs::Vector3_Order(-box2+box3-box4)%Born_von_Karman_period] = std::move(Hexx_43); - } - if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat3, iat4, Abfs::Vector3_Order(box2-box3+box4)%Born_von_Karman_period )) ) - *HexxR_ptr += Hexx_34; + const matrix Hexx_43 = transpose(Hexx_34); + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat4, iat3, Abfs::Vector3_Order(-box2+box3-box4)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_43; else - HexxR_tmp[is][iat3][iat4][Abfs::Vector3_Order(box2-box3+box4)%Born_von_Karman_period] = std::move(Hexx_34); - } + HexxR_tmp[is][iat4][iat3][Abfs::Vector3_Order(-box2+box3-box4)%Born_von_Karman_period] = std::move(Hexx_43); + } + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat3, iat4, Abfs::Vector3_Order(box2-box3+box4)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_34; + else + HexxR_tmp[is][iat3][iat4][Abfs::Vector3_Order(box2-box3+box4)%Born_von_Karman_period] = std::move(Hexx_34); } } - } // end case 1 - case 0: ; - } // end switch cauchy_postcal - } // end for is - } // end for box2 - } // end for box4 - } // end for box3 - - if( !vector_empty(HexxR_tmp) && !Hexx_lock.test_and_set() ) - { - insert_matrixes(HexxR,HexxR_tmp); - Hexx_lock.clear(); - } - } // end for iat4 - } // end for iat3 - } // end if i_atom_pair_now < atom_pairs_core.size() - } // end while(true) + } + } // end case 1 + case 0: ; + } // end switch cauchy_postcal + } // end for is + } // end for box2 + } // end for box4 + } // end for box3 + + if( !vector_empty(HexxR_tmp) && !Hexx_lock.test_and_set() ) + { + insert_matrixes(HexxR,HexxR_tmp); + Hexx_lock.clear(); + } + } // end for iat4 + } // end for iat3 + } // end while + + if(!vector_empty(HexxR_tmp)) + { + while( Hexx_lock.test_and_set() ); + insert_matrixes(HexxR,HexxR_tmp); + Hexx_lock.clear(); + } +ofs_thread<<"TIME@ Exx_Lcao::cal_Hexx_thread\t"< Date: Wed, 3 Jul 2019 15:09:36 +0800 Subject: [PATCH 006/233] modified: src_lcao/local_orbital_charge.cpp 1. change some tab to spaces to make the code look better 2. last commit message " fix the bug when one or more processes have no bases, therefore they will not call setAlltoallvParameter, so the other processes" was add to the other source file, fix it here --- .../source/src_lcao/local_orbital_charge.cpp | 2248 ++++++++--------- 1 file changed, 1124 insertions(+), 1124 deletions(-) diff --git a/ABACUS.1.0.0/source/src_lcao/local_orbital_charge.cpp b/ABACUS.1.0.0/source/src_lcao/local_orbital_charge.cpp index f1e93abc24..3f4a50053e 100644 --- a/ABACUS.1.0.0/source/src_lcao/local_orbital_charge.cpp +++ b/ABACUS.1.0.0/source/src_lcao/local_orbital_charge.cpp @@ -20,18 +20,18 @@ extern "C" Local_Orbital_Charge::Local_Orbital_Charge() { - // for gamma algorithms. - this->init_DM = false; - this->lgd_now = 0; - this->lgd_last = 0; - - // for k-dependent algorithms. - this->init_DM_R = false; - out_dm = 0; - //xiaohui add 2014-06-19 - //band_local = new int[1]; - //Z_wg = new double[1]; - //Z_LOC = new double[1]; + // for gamma algorithms. + this->init_DM = false; + this->lgd_now = 0; + this->lgd_last = 0; + + // for k-dependent algorithms. + this->init_DM_R = false; + out_dm = 0; + //xiaohui add 2014-06-19 + //band_local = new int[1]; + //Z_wg = new double[1]; + //Z_LOC = new double[1]; sender_2D_index = new int[1]; sender_size_process = new int[1]; sender_displacement_process = new int[1]; @@ -43,28 +43,28 @@ Local_Orbital_Charge::Local_Orbital_Charge() Local_Orbital_Charge::~Local_Orbital_Charge() { - // with gamma point only - if (this->init_DM) - { - if(BFIELD) - { - for (int is=0; isinit_DM) + { + if(BFIELD) + { + for (int is=0; isinit_DM_R) - { - for(int is=0; isinit_DM_R) + { + for(int is=0; isnnrg_now = LNNR.nnrg; - //xiaohui add 'OUT_LEVEL' line, 2015-09-16 - if(OUT_LEVEL != "m") OUT(ofs_running,"nnrg_last",nnrg_last); - if(OUT_LEVEL != "m") OUT(ofs_running,"nnrg_now",nnrg_now); - - if(this->init_DM_R) - { - assert(nnrg_last > 0); - for(int is=0; is0) - { - this->DM_R = new double*[NSPIN]; - for(int is=0; isDM_R[is] = new double[nnrg_now]; - ZEROS(DM_R[is], nnrg_now); - } - this->nnrg_last = nnrg_now; - this->init_DM_R = true; - Memory::record("LocalOrbital_Charge","Density_Matrix",NSPIN*nnrg_now,"double"); - } - else if(nnrg_now==0) - { - this->init_DM_R = false; - } - else - { - WARNING_QUIT("Local_Orbital_Charge::allocate_k","check init_DM_R."); - } - - wfc_dm_2d.init(); // Peize Lin test 2019-01-16 - return; + TITLE("Local_Orbital_Charge","allocate_k"); + + this->nnrg_now = LNNR.nnrg; + //xiaohui add 'OUT_LEVEL' line, 2015-09-16 + if(OUT_LEVEL != "m") OUT(ofs_running,"nnrg_last",nnrg_last); + if(OUT_LEVEL != "m") OUT(ofs_running,"nnrg_now",nnrg_now); + + if(this->init_DM_R) + { + assert(nnrg_last > 0); + for(int is=0; is0) + { + this->DM_R = new double*[NSPIN]; + for(int is=0; isDM_R[is] = new double[nnrg_now]; + ZEROS(DM_R[is], nnrg_now); + } + this->nnrg_last = nnrg_now; + this->init_DM_R = true; + Memory::record("LocalOrbital_Charge","Density_Matrix",NSPIN*nnrg_now,"double"); + } + else if(nnrg_now==0) + { + this->init_DM_R = false; + } + else + { + WARNING_QUIT("Local_Orbital_Charge::allocate_k","check init_DM_R."); + } + + wfc_dm_2d.init(); // Peize Lin test 2019-01-16 + return; } // setup buffer parameters for tranforming 2D block-cyclic distributed DM matrix @@ -338,227 +338,227 @@ int Local_Orbital_Charge::setAlltoallvParameter(MPI_Comm comm_2D, int blacs_ctxt // positions change void Local_Orbital_Charge::allocate_gamma(const Grid_Technique >) { - TITLE("Local_Orbital_Charge","allocate_gamma"); - - //xiaohui add 2014-06-20 - //for(int is=0; isinit_DM) - //{ - // this->DM = new double**[NSPIN]; - // for(int is=0; isDM[is] = new double*[NLOCAL]; - - // for (int i=0; iinit_DM = true; - // Memory::record("LocalOrbital_Charge","Density_Kernal",NSPIN*NLOCAL*NLOCAL,"double"); - // } - //} - - //for (int i=0; iDM[is][NLOCAL], NLOCAL); - //} - //} - - //xiaohui modify 2014-06-18 - - // mohan fix serious bug 2010-09-06 - this->lgd_now = gt.lgd; - //xiaohui add 'OUT_LEVEL' line, 2015-09-16 - if(OUT_LEVEL != "m") OUT(ofs_running,"lgd_last",lgd_last); - if(OUT_LEVEL != "m") OUT(ofs_running,"lgd_now",lgd_now); - - // mohan add 2010-07-01 - if(this->init_DM) - { - if(BFIELD) - { - assert(lgd_last > 0); - for (int is=0; is 0); - for (int is=0; is 0) - { - if(BFIELD) - { - this->DM_B = new complex **[NSPIN]; - this->DM_B_pool = new complex *[NSPIN]; - for(int is=0; isDM_B_pool[is]=new complex [lgd_now*lgd_now]; - ZEROS(DM_B_pool[is], lgd_now*lgd_now); - this->DM_B[is] = new complex*[lgd_now]; - - for (int i=0; i"); - } - } - else - { - this->DM = new double**[NSPIN]; - this->DM_pool = new double *[NSPIN]; - for(int is=0; isDM_pool[is]=new double [lgd_now*lgd_now]; - ZEROS(DM_pool[is], lgd_now*lgd_now); - this->DM[is] = new double*[lgd_now]; - - for (int i=0; iinit_DM = true; - this->lgd_last = lgd_now; - //xiaohui add 'OUT_LEVEL', 2015-09-16 - if(OUT_LEVEL != "m") ofs_running << " allocate DM , the dimension is " << lgd_now << endl; - } - else if(lgd_now == 0) - { - this->init_DM = false; - } - else - { - WARNING_QUIT("Local_Orbital_Charge::allocate","lgd<0!Something Wrong!"); - } - + TITLE("Local_Orbital_Charge","allocate_gamma"); + + //xiaohui add 2014-06-20 + //for(int is=0; isinit_DM) + //{ + // this->DM = new double**[NSPIN]; + // for(int is=0; isDM[is] = new double*[NLOCAL]; + + // for (int i=0; iinit_DM = true; + // Memory::record("LocalOrbital_Charge","Density_Kernal",NSPIN*NLOCAL*NLOCAL,"double"); + // } + //} + + //for (int i=0; iDM[is][NLOCAL], NLOCAL); + //} + //} + + //xiaohui modify 2014-06-18 + + // mohan fix serious bug 2010-09-06 + this->lgd_now = gt.lgd; + //xiaohui add 'OUT_LEVEL' line, 2015-09-16 + if(OUT_LEVEL != "m") OUT(ofs_running,"lgd_last",lgd_last); + if(OUT_LEVEL != "m") OUT(ofs_running,"lgd_now",lgd_now); + + // mohan add 2010-07-01 + if(this->init_DM) + { + if(BFIELD) + { + assert(lgd_last > 0); + for (int is=0; is 0); + for (int is=0; is 0) + { + if(BFIELD) + { + this->DM_B = new complex **[NSPIN]; + this->DM_B_pool = new complex *[NSPIN]; + for(int is=0; isDM_B_pool[is]=new complex [lgd_now*lgd_now]; + ZEROS(DM_B_pool[is], lgd_now*lgd_now); + this->DM_B[is] = new complex*[lgd_now]; + + for (int i=0; i"); + } + } + else + { + this->DM = new double**[NSPIN]; + this->DM_pool = new double *[NSPIN]; + for(int is=0; isDM_pool[is]=new double [lgd_now*lgd_now]; + ZEROS(DM_pool[is], lgd_now*lgd_now); + this->DM[is] = new double*[lgd_now]; + + for (int i=0; iinit_DM = true; + this->lgd_last = lgd_now; + //xiaohui add 'OUT_LEVEL', 2015-09-16 + if(OUT_LEVEL != "m") ofs_running << " allocate DM , the dimension is " << lgd_now << endl; + } + else if(lgd_now == 0) + { + this->init_DM = false; + } + else + { + WARNING_QUIT("Local_Orbital_Charge::allocate","lgd<0!Something Wrong!"); + } + if(!BFIELD) setAlltoallvParameter(ParaO.comm_2D, ParaO.blacs_ctxt, ParaO.nb); - wfc_dm_2d.init(); // Peize Lin test 2019-01-16 - return; + wfc_dm_2d.init(); // Peize Lin test 2019-01-16 + return; } void Local_Orbital_Charge::sum_bands(void) { - TITLE("Local_Orbital_Charge","sum_bands"); - timer::tick("Local_Orbital_Cha","sum_bands",'E'); - - en.eband = 0.0; - //xiaohui modify 2013-09-02 - //if(LINEAR_SCALING == 2) - //{ - // //en.eband = ON.eband; - //} - //else if(LINEAR_SCALING == 1) - //{ - // //xiaohui modified 2013-07-22 - // //if(DIAGO_TYPE=="selinv") - // //{ - // // en.eband = Selinv::eband; - // //} - // //else - // //{ - // // ofs_running << " calculate eband " << endl; - // for(int ik=0; ikcal_dk_gamma();//calculate the density matrix. - // } - // // @@@@@@@ - // // test - // // @@@@@@@ - // /* - // cout << " Density Matrix:"; - // double sum = 0.0; - // for(int i=0; ical_dk_k( GridT ); - // } - //} xiaohui modify 2013-09-02. Attention... - - //xiaohui add 2013-09-02 - if(GAMMA_ONLY_LOCAL) - { - if(KS_SOLVER=="selinv") - { - //density matrix has already been calcualted. - } + TITLE("Local_Orbital_Charge","sum_bands"); + timer::tick("Local_Orbital_Cha","sum_bands",'E'); + + en.eband = 0.0; + //xiaohui modify 2013-09-02 + //if(LINEAR_SCALING == 2) + //{ + // //en.eband = ON.eband; + //} + //else if(LINEAR_SCALING == 1) + //{ + // //xiaohui modified 2013-07-22 + // //if(DIAGO_TYPE=="selinv") + // //{ + // // en.eband = Selinv::eband; + // //} + // //else + // //{ + // // ofs_running << " calculate eband " << endl; + // for(int ik=0; ikcal_dk_gamma();//calculate the density matrix. + // } + // // @@@@@@@ + // // test + // // @@@@@@@ + // /* + // cout << " Density Matrix:"; + // double sum = 0.0; + // for(int i=0; ical_dk_k( GridT ); + // } + //} xiaohui modify 2013-09-02. Attention... + + //xiaohui add 2013-09-02 + if(GAMMA_ONLY_LOCAL) + { + if(KS_SOLVER=="selinv") + { + //density matrix has already been calcualted. + } else if(KS_SOLVER=="genelpa") { if(NEW_DM>0) @@ -573,274 +573,274 @@ void Local_Orbital_Charge::sum_bands(void) this->cal_dk_gamma();//calculate the density matrix. } } - } - else - { - NOTE("Calculate the density matrix!"); - this->cal_dk_k( GridT ); - if(KS_SOLVER=="genelpa") // Peize Lin test 2019-05-15 - wfc_dm_2d.cal_dm(wf.wg); - } //xiaohui add 2013-09-02. Attention... - - for(int is=0; iscal_dk_k( GridT ); + if(KS_SOLVER=="genelpa") // Peize Lin test 2019-05-15 + wfc_dm_2d.cal_dm(wf.wg); + } //xiaohui add 2013-09-02. Attention... + + for(int is=0; is fac, Record_adj RA, - const int ia1, const int iw1_lo, const int nw1, const int gstart, - complex *WFC_PHASE, complex **DM_ATOM) + const int ia1, const int iw1_lo, const int nw1, const int gstart, + complex *WFC_PHASE, complex **DM_ATOM) { - const char transa='N', transb='T'; - const complex alpha=1, beta=1; - - for(int ik=0; ik **wfc = LOWF.WFC_K[ik]; - const int ispin = kv.isk[ik]; - int atom2start=0; - - for (int ia2 = 0; ia2 < RA.na_each[ia1]; ++ia2) - { - complex *DM=&DM_ATOM[ispin][atom2start]; - const int T2 = RA.info[ia1][ia2][3]; - const int I2 = RA.info[ia1][ia2][4]; - Atom* atom2 = &ucell.atoms[T2]; - const int start2 = ucell.itiaiw2iwt(T2,I2,0); - const int iw2_lo=gt.trace_lo[start2]; - const int nw2=atom2->nw; - complex exp_R= exp( fac * ( - kv.kvec_d[ik].x * RA.info[ia1][ia2][0] + - kv.kvec_d[ik].y * RA.info[ia1][ia2][1] + - kv.kvec_d[ik].z * RA.info[ia1][ia2][2] - ) ); - - //ZEROS(WFC_PHASE, NBANDS*nw1); - int ibStart=0; - int nRow=0; - for(int ib=0; ib0) - { - if(nRow==0) ibStart=ib; - const int iline=nRow*nw1; - complex phase=exp_R*wg_local; - for(int iw1=0; iw1 alpha=1, beta=1; + + for(int ik=0; ik **wfc = LOWF.WFC_K[ik]; + const int ispin = kv.isk[ik]; + int atom2start=0; + + for (int ia2 = 0; ia2 < RA.na_each[ia1]; ++ia2) + { + complex *DM=&DM_ATOM[ispin][atom2start]; + const int T2 = RA.info[ia1][ia2][3]; + const int I2 = RA.info[ia1][ia2][4]; + Atom* atom2 = &ucell.atoms[T2]; + const int start2 = ucell.itiaiw2iwt(T2,I2,0); + const int iw2_lo=gt.trace_lo[start2]; + const int nw2=atom2->nw; + complex exp_R= exp( fac * ( + kv.kvec_d[ik].x * RA.info[ia1][ia2][0] + + kv.kvec_d[ik].y * RA.info[ia1][ia2][1] + + kv.kvec_d[ik].z * RA.info[ia1][ia2][2] + ) ); + + //ZEROS(WFC_PHASE, NBANDS*nw1); + int ibStart=0; + int nRow=0; + for(int ib=0; ib0) + { + if(nRow==0) ibStart=ib; + const int iline=nRow*nw1; + complex phase=exp_R*wg_local; + for(int iw1=0; iw1 fac, Record_adj RA, - const int ia1, const int iw1_lo, const int nw1, const int gstart, - complex *WFC_PHASE, complex **DM_ATOM) + const int ia1, const int iw1_lo, const int nw1, const int gstart, + complex *WFC_PHASE, complex **DM_ATOM) { - if(NSPIN !=4 ) WARNING_QUIT("Local_Orbital_Charge","NSPIN not match!"); - const char transa='N', transb='T'; - const complex alpha=1, beta=1; - int ispin=0; - - for(int is1=0;is1<2;is1++) - { - for(int is2=0;is2<2;is2++) - { - for(int ik=0; ik **wfc = LOWF.WFC_K[ik]; - int atom2start=0; - - for (int ia2 = 0; ia2 < RA.na_each[ia1]; ++ia2) - { - complex *DM=&DM_ATOM[ispin][atom2start]; - const int T2 = RA.info[ia1][ia2][3]; - const int I2 = RA.info[ia1][ia2][4]; - Atom* atom2 = &ucell.atoms[T2]; - const int start2 = ucell.itiaiw2iwt(T2,I2,0); - const int iw2_lo=gt.trace_lo[start2] + NLOCAL/NPOL*is2; - const int nw2=atom2->nw; - complex exp_R= exp( fac * ( - kv.kvec_d[ik].x * RA.info[ia1][ia2][0] + - kv.kvec_d[ik].y * RA.info[ia1][ia2][1] + - kv.kvec_d[ik].z * RA.info[ia1][ia2][2] - ) ); - - //ZEROS(WFC_PHASE, NBANDS*nw1); - int ibStart=0; - int nRow=0; - for(int ib=0; ib0) - { - if(nRow==0) ibStart=ib; - const int iline=nRow*nw1; - complex phase=exp_R*w1; - for(int iw1=0; iw1 alpha=1, beta=1; + int ispin=0; + + for(int is1=0;is1<2;is1++) + { + for(int is2=0;is2<2;is2++) + { + for(int ik=0; ik **wfc = LOWF.WFC_K[ik]; + int atom2start=0; + + for (int ia2 = 0; ia2 < RA.na_each[ia1]; ++ia2) + { + complex *DM=&DM_ATOM[ispin][atom2start]; + const int T2 = RA.info[ia1][ia2][3]; + const int I2 = RA.info[ia1][ia2][4]; + Atom* atom2 = &ucell.atoms[T2]; + const int start2 = ucell.itiaiw2iwt(T2,I2,0); + const int iw2_lo=gt.trace_lo[start2] + NLOCAL/NPOL*is2; + const int nw2=atom2->nw; + complex exp_R= exp( fac * ( + kv.kvec_d[ik].x * RA.info[ia1][ia2][0] + + kv.kvec_d[ik].y * RA.info[ia1][ia2][1] + + kv.kvec_d[ik].z * RA.info[ia1][ia2][2] + ) ); + + //ZEROS(WFC_PHASE, NBANDS*nw1); + int ibStart=0; + int nRow=0; + for(int ib=0; ib0) + { + if(nRow==0) ibStart=ib; + const int iline=nRow*nw1; + complex phase=exp_R*w1; + for(int iw1=0; iw1 tau1, dtau; - - Record_adj RA; - RA.for_grid(gt); - - int ca = 0; - complex fac = TWO_PI * IMAG_UNIT; - - complex *WFC_PHASE=new complex[NLOCAL*ucell.nwmax]; - - int DM_ATOM_SIZE=1; - complex **DM_ATOM=new complex *[NSPIN]; - for(int is=0; is[DM_ATOM_SIZE]; - ZEROS(DM_ATOM[is], DM_ATOM_SIZE); - } - for(int T1=0; T1na; I1++) - { - const int iat = ucell.itia2iat(T1,I1); - if(gt.in_this_processor[iat]) - { - const int start1 = ucell.itiaiw2iwt(T1,I1,0); - const int gstart = LNNR.nlocstartg[iat]; - const int ng = LNNR.nlocdimg[iat]; - const int iw1_lo=gt.trace_lo[start1]; - const int nw1=atom1->nw; - - if(DM_ATOM_SIZE[DM_ATOM_SIZE]; - } - for(int is=0; isDM_R[is][gstart+iv]=DM_ATOM[is][iv].real(); - } - } - } // if gt.in_this_processor - }// I1 - }// T1 - - - //------------ - // for test - //------------ -/* cout << setprecision(3); - for(int i=0; i tau1, dtau; + + Record_adj RA; + RA.for_grid(gt); + + int ca = 0; + complex fac = TWO_PI * IMAG_UNIT; + + complex *WFC_PHASE=new complex[NLOCAL*ucell.nwmax]; + + int DM_ATOM_SIZE=1; + complex **DM_ATOM=new complex *[NSPIN]; + for(int is=0; is[DM_ATOM_SIZE]; + ZEROS(DM_ATOM[is], DM_ATOM_SIZE); + } + for(int T1=0; T1na; I1++) + { + const int iat = ucell.itia2iat(T1,I1); + if(gt.in_this_processor[iat]) + { + const int start1 = ucell.itiaiw2iwt(T1,I1,0); + const int gstart = LNNR.nlocstartg[iat]; + const int ng = LNNR.nlocdimg[iat]; + const int iw1_lo=gt.trace_lo[start1]; + const int nw1=atom1->nw; + + if(DM_ATOM_SIZE[DM_ATOM_SIZE]; + } + for(int is=0; isDM_R[is][gstart+iv]=DM_ATOM[is][iv].real(); + } + } + } // if gt.in_this_processor + }// I1 + }// T1 + + + //------------ + // for test + //------------ +/* cout << setprecision(3); + for(int i=0; iDM_B[is][i], lgd_now); - } - } - for(int is=0; is= 0) - { - // set a pointer. - complex *alpha = this->DM_B[is][mu_local]; - for (int j=i; j= 0) - { - for (int ib=0; ib0) - { - // dm = \sum ( wg * c[ib][mu] * c[ib][nu] ) - // dm saved accordint to sub-FFT box. - alpha[nu_local] += wg_local * (conj(LOWF.WFC_GAMMA_B[is][ib][mu_local]) * LOWF.WFC_GAMMA_B[is][ib][nu_local]).real(); - } - } - } - } - } - } - } - } + TITLE("Local_Orbital_Charge","cal_density_kernal"); + timer::tick("LocalOrbital_Charge","cal_dk_gamma",'F'); + + assert(NSPIN==kv.nks); + + if(BFIELD) + { + for(int is=0; isDM_B[is][i], lgd_now); + } + } + for(int is=0; is= 0) + { + // set a pointer. + complex *alpha = this->DM_B[is][mu_local]; + for (int j=i; j= 0) + { + for (int ib=0; ib0) + { + // dm = \sum ( wg * c[ib][mu] * c[ib][nu] ) + // dm saved accordint to sub-FFT box. + alpha[nu_local] += wg_local * (conj(LOWF.WFC_GAMMA_B[is][ib][mu_local]) * LOWF.WFC_GAMMA_B[is][ib][nu_local]).real(); + } + } + } + } + } + } + } + } #ifdef __MPI //2015-09-06, xiaohui - else // Peize Lin update 2018-07-02 - { - for( int is=0; isDM[is][i], lgd_now); - - int nprocs,myid; - MPI_Status status; - MPI_Comm_size(DIAG_HPSEPS_WORLD,&nprocs); - MPI_Comm_rank(DIAG_HPSEPS_WORLD,&myid); - - vector bands_local(DSIZE); - for (int id=0; id= NBANDS) - { - lastband_in_proc = id; - break; - } - } - - matrix wg_local(NSPIN,band_local); - for(int id=0, Total_Bands=0; id <= lastband_in_proc; ++id) - { - if(myid == id) - for(int is=0; isDM[is][row_mu][col_nu] = rho_row_col(i_row,i_col); - } - } - } - } // end for col_count - } // end for row_count + else // Peize Lin update 2018-07-02 + { + for( int is=0; isDM[is][i], lgd_now); + + int nprocs,myid; + MPI_Status status; + MPI_Comm_size(DIAG_HPSEPS_WORLD,&nprocs); + MPI_Comm_rank(DIAG_HPSEPS_WORLD,&myid); + + vector bands_local(DSIZE); + for (int id=0; id= NBANDS) + { + lastband_in_proc = id; + break; + } + } + + matrix wg_local(NSPIN,band_local); + for(int id=0, Total_Bands=0; id <= lastband_in_proc; ++id) + { + if(myid == id) + for(int is=0; isDM[is][row_mu][col_nu] = rho_row_col(i_row,i_col); + } + } + } + } // end for col_count + } // end for row_count ofs_running<<"DM[0][0:1][0:1] in cal_dk_gamma:"<DM[is][i], lgd_now); - for(int is=0; istaud[ia].x - << " " << atom->taud[ia].y - << " " << atom->taud[ia].z << endl; - } - } - - ofs << "\n " << NSPIN; - if(NSPIN==1||NSPIN==4) - { - ofs << "\n " << en.ef << " (fermi energy)"; - } - else if(NSPIN==2) - { - if(is==0)ofs << "\n " << en.ef_up << " (fermi energy for spin=1)"; - else if(is==1)ofs << "\n " << en.ef_dw << " (fermi energy for spin=2)"; - } - else - { - WARNING_QUIT("write_rho","check nspin!"); - } - - - ofs << "\n " << NLOCAL << " " << NLOCAL << endl; - - ofs << setprecision(precision); - ofs << scientific; - - } - - //ofs << "\n " << GAMMA_ONLY_LOCAL << " (GAMMA ONLY LOCAL)" << endl; + TITLE("Local_Orbital_Charge","write_dm"); + + if (out_dm==0) + { + return; + } + else if(iter % out_dm != 0) + { + return; + } + timer::tick("Local_Orbital_Charge","write_dm"); + + time_t start, end; + ofstream ofs; + + if(MY_RANK==0) + { + start = time(NULL); + + ofs.open(fn.c_str()); + if (!ofs) + { + WARNING("Charge::write_rho","Can't create Charge File!"); + } + + //ofs_running << "\n Output charge file." << endl; + + ofs << ucell.latName << endl;//1 + ofs << " " << ucell.lat0 * BOHR_TO_A << endl; + ofs << " " << ucell.latvec.e11 << " " << ucell.latvec.e12 << " " << ucell.latvec.e13 << endl; + ofs << " " << ucell.latvec.e21 << " " << ucell.latvec.e22 << " " << ucell.latvec.e23 << endl; + ofs << " " << ucell.latvec.e31 << " " << ucell.latvec.e32 << " " << ucell.latvec.e33 << endl; + for(int it=0; ittaud[ia].x + << " " << atom->taud[ia].y + << " " << atom->taud[ia].z << endl; + } + } + + ofs << "\n " << NSPIN; + if(NSPIN==1||NSPIN==4) + { + ofs << "\n " << en.ef << " (fermi energy)"; + } + else if(NSPIN==2) + { + if(is==0)ofs << "\n " << en.ef_up << " (fermi energy for spin=1)"; + else if(is==1)ofs << "\n " << en.ef_dw << " (fermi energy for spin=2)"; + } + else + { + WARNING_QUIT("write_rho","check nspin!"); + } + + + ofs << "\n " << NLOCAL << " " << NLOCAL << endl; + + ofs << setprecision(precision); + ofs << scientific; + + } + + //ofs << "\n " << GAMMA_ONLY_LOCAL << " (GAMMA ONLY LOCAL)" << endl; #ifndef __MPI - if(GAMMA_ONLY_LOCAL) - { - for(int i=0; iDM[is][i][j]; - } - } - } - else - { - WARNING_QUIT("write_dm","not ready yet"); - ofs << " " << LNNR.nnrg << " (nnrg)" << endl; - for(int i=0; iDM_R[is][i]; - } - } + if(GAMMA_ONLY_LOCAL) + { + for(int i=0; iDM[is][i][j]; + } + } + } + else + { + WARNING_QUIT("write_dm","not ready yet"); + ofs << " " << LNNR.nnrg << " (nnrg)" << endl; + for(int i=0; iDM_R[is][i]; + } + } #else - if(GAMMA_ONLY_LOCAL) - { - //xiaohui modify 2014-06-18 - - double* tmp = new double[NLOCAL]; - int* count = new int[NLOCAL]; - for (int i=0; i= 0) - { - for (int j=0; j= 0) - { - count[j]=1; - } - } - } - Parallel_Reduce::reduce_int_all( count, NLOCAL ); - - // reduce the density matrix for 'i' line. - ZEROS(tmp, NLOCAL); - if (mu >= 0) - { - for (int j=0; j=0) - { - tmp[j] = DM[is][mu][nu]; - //ofs_running << " dmi=" << i << " j=" << j << " " << DM[is][mu][nu] << endl; - } - } - } - Parallel_Reduce::reduce_double_all( tmp, NLOCAL ); - - if(MY_RANK==0) - { - for (int j=0; j0) - { - ofs << " " << tmp[j]/(double)count[j]; - } - else - { - ofs << " 0"; - } - } - } - } - delete[] tmp; - delete[] count; - - //xiaohui add 2014-06-18 - //for(int i=0; iDM[is][i][j]; - // } - //} - - } - else - { - ofs << " " << LNNR.nnrg << " (nnrg)" << endl; - WARNING_QUIT("local_orbital_charge","not ready to output DM_R"); - } + if(GAMMA_ONLY_LOCAL) + { + //xiaohui modify 2014-06-18 + + double* tmp = new double[NLOCAL]; + int* count = new int[NLOCAL]; + for (int i=0; i= 0) + { + for (int j=0; j= 0) + { + count[j]=1; + } + } + } + Parallel_Reduce::reduce_int_all( count, NLOCAL ); + + // reduce the density matrix for 'i' line. + ZEROS(tmp, NLOCAL); + if (mu >= 0) + { + for (int j=0; j=0) + { + tmp[j] = DM[is][mu][nu]; + //ofs_running << " dmi=" << i << " j=" << j << " " << DM[is][mu][nu] << endl; + } + } + } + Parallel_Reduce::reduce_double_all( tmp, NLOCAL ); + + if(MY_RANK==0) + { + for (int j=0; j0) + { + ofs << " " << tmp[j]/(double)count[j]; + } + else + { + ofs << " 0"; + } + } + } + } + delete[] tmp; + delete[] count; + + //xiaohui add 2014-06-18 + //for(int i=0; iDM[is][i][j]; + // } + //} + + } + else + { + ofs << " " << LNNR.nnrg << " (nnrg)" << endl; + WARNING_QUIT("local_orbital_charge","not ready to output DM_R"); + } #endif - if(MY_RANK==0) - { - end = time(NULL); - OUT_TIME("write_rho",start,end); - ofs.close(); - } - timer::tick("Local_Orbital_Charge","write_dm"); - - return; + if(MY_RANK==0) + { + end = time(NULL); + OUT_TIME("write_rho",start,end); + ofs.close(); + } + timer::tick("Local_Orbital_Charge","write_dm"); + + return; } void Local_Orbital_Charge::read_dm(const int &is, const string &fn) { - TITLE("Local_Orbital_Charge","read_dm"); - timer::tick("Local_Orbital_Charge","read_dm"); - - ofs_running << "\n processor 0 is reading density matrix from file < " << fn << " > " << endl; - //xiaohui modify 2015-03-25 - //bool quit_mesia = false; - bool quit_abacus = false; - - ifstream ifs; - if(MY_RANK==0) - { - ifs.open(fn.c_str()); - if (!ifs) - { - //xiaohui modify 2015-03-25 - //quit_mesia = true; - quit_abacus = true; - } - else - { - // if the number is not match, - // quit the program or not. - bool quit=false; - - string name; - ifs >> name; - - // check lattice constant, unit is Angstrom - CHECK_DOUBLE(ifs,ucell.lat0 * BOHR_TO_A,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e11,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e12,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e13,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e21,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e22,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e23,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e31,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e32,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e33,quit); - - for(int it=0; it> coordinate; - - for(int it=0; it " << endl; + //xiaohui modify 2015-03-25 + //bool quit_mesia = false; + bool quit_abacus = false; + + ifstream ifs; + if(MY_RANK==0) + { + ifs.open(fn.c_str()); + if (!ifs) + { + //xiaohui modify 2015-03-25 + //quit_mesia = true; + quit_abacus = true; + } + else + { + // if the number is not match, + // quit the program or not. + bool quit=false; + + string name; + ifs >> name; + + // check lattice constant, unit is Angstrom + CHECK_DOUBLE(ifs,ucell.lat0 * BOHR_TO_A,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e11,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e12,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e13,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e21,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e22,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e23,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e31,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e32,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e33,quit); + + for(int it=0; it> coordinate; + + for(int it=0; it> DM[is][i][j]; - } - } - } - else - { - WARNING_QUIT("Local_Orbital_Charge::read_dm","The nnrg should not be update"); - CHECK_INT(ifs,LNNR.nnrg); - - for(int i=0; i> DM_R[is][i]; - } - } + ofs_running << " Read SPIN = " << is+1 << " density matrix now." << endl; + + if(GAMMA_ONLY_LOCAL) + { + for(int i=0; i> DM[is][i][j]; + } + } + } + else + { + WARNING_QUIT("Local_Orbital_Charge::read_dm","The nnrg should not be update"); + CHECK_INT(ifs,LNNR.nnrg); + + for(int i=0; i> DM_R[is][i]; + } + } #else - // distribution of necessary data - //xiaohui modify 2015-03-25 - //Parallel_Common::bcast_bool(quit_mesia); - Parallel_Common::bcast_bool(quit_abacus); - //xiaohui modify 2015-03-25 - //if(quit_mesia) - if(quit_abacus) - { - WARNING_QUIT("Local_Orbital_Charge::read_dm","Can not find the density matrix file."); - } - - - if(NSPIN==1||NSPIN==4) - { - Parallel_Common::bcast_double(en.ef); - } - else if(NSPIN==2) - { - Parallel_Common::bcast_double(en.ef_up); - Parallel_Common::bcast_double(en.ef_dw); - } - - - if(GAMMA_ONLY_LOCAL) - { - //ofs_running << " NLOCAL=" << NLOCAL << endl; - //ofs_running << " lgd_now=" << lgd_now << endl; - //ofs_running << " GridT.lgd=" << GridT.lgd << endl; - - double *tmp = new double[NLOCAL]; - for(int i=0; i Date: Wed, 24 Jul 2019 20:13:06 +0800 Subject: [PATCH 007/233] 1. fix bug Exx_Lcao::cal_Hexx_thread while() 1.1 source/src_lcao/exx_lcao.cpp 2. exx H_mixing now rely on exx_seperate_loop and charge mixing, delete INPUT_PARAMETERS exx_h_mixing_mode and exx_h_mixing_beta 2.1 source/input.h 2.2 source/input.cpp 2.3 source/input_conv.cpp 2.4 source/src_lcao/exx_lcao.h 2.5 source/src_lcao/exx_lcao.cpp 3. add opt_orb_pytorch input["info"]["lr"] 3.1 tools/opt_orb_pytorch/IO/read_json.py 3.2 tools/opt_orb_pytorch/main.py 3.3 tools/opt_lcao_bash/print_file.py 3.4 tools/opt_abfs_bash/opt_orb.py 4. fix bug about sub 4.1 tools/opt_abfs_bash/set_dimer.py 4.2 tools/opt_abfs_bash/opt_orb.py 4.3 tools/opt_abfs_bash/exx.py 4.4 tools/opt_lcao_bash/print_file.py 5. change elpa to elpa_openmp 5.1 source/Makefile.vars 5.2 source/Makefile.system --- ABACUS.1.0.0/source/Makefile.system | 2 +- ABACUS.1.0.0/source/Makefile.vars | 6 ++--- ABACUS.1.0.0/source/input.cpp | 23 ------------------- ABACUS.1.0.0/source/input.h | 3 --- ABACUS.1.0.0/source/input_conv.cpp | 7 ------ ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 22 +++++++++++++++--- ABACUS.1.0.0/source/src_lcao/exx_lcao.h | 3 --- ABACUS.1.0.0/tools/opt_abfs_bash/exx.py | 7 +++--- ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py | 4 +++- ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py | 7 +++--- .../tools/opt_lcao_bash/print_file.py | 18 ++++++++------- .../tools/opt_orb_pytorch/IO/read_json.py | 3 ++- ABACUS.1.0.0/tools/opt_orb_pytorch/main.py | 2 +- 13 files changed, 45 insertions(+), 62 deletions(-) diff --git a/ABACUS.1.0.0/source/Makefile.system b/ABACUS.1.0.0/source/Makefile.system index 012283fcba..66bfa4caeb 100644 --- a/ABACUS.1.0.0/source/Makefile.system +++ b/ABACUS.1.0.0/source/Makefile.system @@ -20,7 +20,7 @@ FFTW_LIB_DIR = ${FFTW_DIR}/lib FFTW_LIB = -L${FFTW_LIB_DIR} -lfftw3 -Wl,-rpath=${FFTW_LIB_DIR} ELPA_LIB_DIR = ${ELPA_DIR}/lib -ELPA_LIB = -L${ELPA_LIB_DIR} -lelpa -Wl,-rpath=${ELPA_LIB_DIR} +ELPA_LIB = -L${ELPA_LIB_DIR} -lelpa_openmp -Wl,-rpath=${ELPA_LIB_DIR} LIBXC_INCLUDE_DIR = ${LIBXC_DIR}/include LIBXC_LIB_DIR = ${LIBXC_DIR}/lib diff --git a/ABACUS.1.0.0/source/Makefile.vars b/ABACUS.1.0.0/source/Makefile.vars index b66e4f4c83..aae4620447 100644 --- a/ABACUS.1.0.0/source/Makefile.vars +++ b/ABACUS.1.0.0/source/Makefile.vars @@ -1,7 +1,7 @@ CPLUSPLUS = icpc CPLUSPLUS_MPI = mpiicpc -BOOST_DIR = /home/linpz/software/boost_1_66_0 +BOOST_DIR = /home/linpz/software/boost-1.70 LAPACK_DIR = /opt/intel/mkl FFTW_DIR = /home/linpz/software/fftw-3.3.8 -ELPA_DIR = /home/linpz/software/elpa-2016.05.004 -LIBXC_DIR = /home/linpz/software/libxc-4.0.4 +ELPA_DIR = /home/linpz/software/elpa-2016.05.004-openmp +LIBXC_DIR = /home/linpz/software/libxc-4.3.4 diff --git a/ABACUS.1.0.0/source/input.cpp b/ABACUS.1.0.0/source/input.cpp index d441e36bef..af15c1fe9b 100644 --- a/ABACUS.1.0.0/source/input.cpp +++ b/ABACUS.1.0.0/source/input.cpp @@ -435,9 +435,6 @@ void Input::Default(void) exx_distribute_type = "htime"; - exx_h_mixing_mode = "no"; - exx_h_mixing_beta = 0.7; - exx_opt_orb_lmax = 0; exx_opt_orb_ecut = 0.0; exx_opt_orb_tolerence = 0.0; @@ -1545,14 +1542,6 @@ bool Input::Read(const string &fn) { read_value(ifs, exx_distribute_type); } - else if (strcmp("exx_h_mixing_mode", word) == 0) - { - read_value(ifs, exx_h_mixing_mode); - } - else if (strcmp("exx_h_mixing_beta", word) == 0) - { - read_value(ifs, exx_h_mixing_beta); - } else if (strcmp("exx_opt_orb_lmax", word) == 0) { read_value(ifs, exx_opt_orb_lmax); @@ -1965,8 +1954,6 @@ void Input::Bcast() Parallel_Common::bcast_double( exx_schwarz_threshold ); Parallel_Common::bcast_double( exx_cauchy_threshold ); Parallel_Common::bcast_string( exx_distribute_type ); - Parallel_Common::bcast_string( exx_h_mixing_mode ); - Parallel_Common::bcast_double( exx_h_mixing_beta ); Parallel_Common::bcast_int( exx_opt_orb_lmax ); Parallel_Common::bcast_double( exx_opt_orb_ecut ); Parallel_Common::bcast_double( exx_opt_orb_tolerence ); @@ -2589,14 +2576,6 @@ void Input::Check(void) { WARNING_QUIT("INPUT","exx_distribute_type must be htime or kmeans"); } - if(exx_h_mixing_mode!="no" && exx_h_mixing_mode!="plain" && exx_h_mixing_mode!="pulay") - { - WARNING_QUIT("INPUT","exx_h_mixing_mode must be no, plain or pulay"); - } - if(exx_h_mixing_beta<0 || exx_h_mixing_beta>1) - { - WARNING_QUIT("INPUT","must 0 < exx_h_mixing_beta < 1"); - } } if(exx_hybrid_type=="opt_orb") { @@ -2969,8 +2948,6 @@ void Input::Print(const string &fn)const OUTP(ofs,"exx_schwarz_threshold",exx_schwarz_threshold,""); OUTP(ofs,"exx_cauchy_threshold",exx_cauchy_threshold,""); OUTP(ofs,"exx_distribute_type",exx_distribute_type,"htime or kmeans"); - OUTP(ofs,"exx_h_mixing_mode",exx_h_mixing_mode,"no, plain or pulay"); - OUTP(ofs,"exx_h_mixing_beta",exx_h_mixing_beta,""); OUTP(ofs,"exx_opt_orb_lmax",exx_opt_orb_lmax,""); OUTP(ofs,"exx_opt_orb_ecut",exx_opt_orb_ecut,""); OUTP(ofs,"exx_opt_orb_tolerence",exx_opt_orb_tolerence,""); diff --git a/ABACUS.1.0.0/source/input.h b/ABACUS.1.0.0/source/input.h index 82792002a7..c2e04bcddd 100644 --- a/ABACUS.1.0.0/source/input.h +++ b/ABACUS.1.0.0/source/input.h @@ -334,9 +334,6 @@ class Input string exx_distribute_type; - string exx_h_mixing_mode; // "no", "plain" - double exx_h_mixing_beta; - int exx_opt_orb_lmax; double exx_opt_orb_ecut; double exx_opt_orb_tolerence; diff --git a/ABACUS.1.0.0/source/input_conv.cpp b/ABACUS.1.0.0/source/input_conv.cpp index df1680f551..f1ec3cda5d 100644 --- a/ABACUS.1.0.0/source/input_conv.cpp +++ b/ABACUS.1.0.0/source/input_conv.cpp @@ -422,13 +422,6 @@ void Input_Conv::Convert(void) exx_lcao.info.distribute_type = Exx_Lcao::Distribute_Type::Htime; else if(INPUT.exx_distribute_type=="kmeans") exx_lcao.info.distribute_type = Exx_Lcao::Distribute_Type::Kmeans; - if(INPUT.exx_h_mixing_mode=="no") - exx_lcao.info.H_mixing_mode = Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode::No; - else if(INPUT.exx_h_mixing_mode=="plain") - exx_lcao.info.H_mixing_mode = Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode::Plain; - else if(INPUT.exx_h_mixing_mode=="pulay") - exx_lcao.info.H_mixing_mode = Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode::Pulay; - exx_lcao.info.H_mixing_beta = INPUT.exx_h_mixing_beta; Exx_Abfs::Jle::Lmax = INPUT.exx_opt_orb_lmax; Exx_Abfs::Jle::Ecut_exx = INPUT.exx_opt_orb_ecut; Exx_Abfs::Jle::tolerence = INPUT.exx_opt_orb_tolerence; diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp index ab685afca7..d8a3c33b88 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp @@ -430,8 +430,21 @@ gettimeofday( &t_start_all, NULL); // DM.flag_mix = info.separate_loop ? false : true; // DM.flag_mix = false; // Peize Lin test - Hexx_para.mixing_mode = info.H_mixing_mode; - Hexx_para.mixing_beta = info.H_mixing_beta; + if(exx_global.info.separate_loop) + { + Hexx_para.mixing_mode = Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode::No; + Hexx_para.mixing_beta = 0; + } + else + { + if("plain"==chr.mixing_mode) + Hexx_para.mixing_mode = Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode::Plain; + else if("pulay"==chr.mixing_mode) + Hexx_para.mixing_mode = Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode::Pulay; + else + throw invalid_argument("exx mixing error. exx_separate_loop==false, mixing_mode!=plain or pulay"); + Hexx_para.mixing_beta = chr.mixing_beta; + } gettimeofday( &t_start, NULL); this->lcaos = Exx_Abfs::Construct_Orbs::change_orbs( ORB, this->kmesh_times ); @@ -1317,8 +1330,11 @@ gettimeofday( &t_start_all, NULL); vector,matrix>>>> HexxR_tmp(NSPIN); - while(const size_t i_atom_pair_now = i_atom_pair++ < atom_pairs_core.size() ) + while(true) { + const size_t i_atom_pair_now = i_atom_pair++; + if( i_atom_pair_now >= atom_pairs_core.size() ) break; + const size_t iat1 = atom_pairs_core[i_atom_pair_now].first; const size_t iat2 = atom_pairs_core[i_atom_pair_now].second; diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.h b/ABACUS.1.0.0/source/src_lcao/exx_lcao.h index c12e16cc93..71a22c8829 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.h +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.h @@ -104,9 +104,6 @@ class Exx_Lcao double cauchy_threshold = 0; Exx_Lcao::Distribute_Type distribute_type; - - Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode H_mixing_mode; - double H_mixing_beta; Exx_Info( const Exx_Global::Exx_Info &info_global ); }; diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py b/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py index c0a1368066..f37b55a81a 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py @@ -39,7 +39,7 @@ def cal(): with open(f"{utils.folder_exx}/sub.sh","w") as file: file.write(textwrap.dedent(f"""\ #!/bin/bash - #PBS -q batch + #PBS -q gold5120 #PBS -l nodes=1:ppn=28 #PBS -l walltime=24:00:00 #PBS -o job.log @@ -47,7 +47,7 @@ def cal(): ulimit -s unlimited cd $PBS_O_WORKDIR EXEC={info["ABACUS"]} - mpirun -n 1 $EXEC + mpirun -n 1 -env OMP_NUM_THREADS=28 $EXEC """)) elif utils.sub=="bsub": with open(f"{utils.folder_exx}/sub.sh","w") as file: @@ -56,8 +56,7 @@ def cal(): #BSUB -q renxg #BSUB -o job.log -e job.err #BSUB -n 6 - export OMP_NUM_THREADS=6 - mpirun -n 1 {info['ABACUS']} + mpirun -n 1 -env OMP_NUM_THREADS=6 {info['ABACUS']} """)) os.chdir(utils.folder_exx) diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py b/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py index 71317c78b2..825a0527c1 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py @@ -42,7 +42,8 @@ def set_input(folders_matrix): "weight": [weight for weight,nbands in folders_matrix.values()], "Rcut": read_stru.get_Rcut(), "dr": {T:utils.dr for T in Ts}, - "Ecut": {T:Ecut for T in Ts} + "Ecut": {T:Ecut for T in Ts}, + "lr": 0.01 }, "C_init_info":{ "init_from_file": False }, "V_info": @@ -68,6 +69,7 @@ def cal(input): #PBS -e job.err ulimit -s unlimited cd $PBS_O_WORKDIR + export OMP_NUM_THREADS=1 EXEC={info["opt_orb"]} python3 -u $EXEC """)) diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py b/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py index 166f085b08..7b172e83d7 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py @@ -88,7 +88,7 @@ def cal_ABACUS(T1,T2,i_dis): with open(folder/"sub.sh","w") as file: file.write(textwrap.dedent(f"""\ #!/bin/bash - #PBS -q batch + #PBS -q gold5120 #PBS -l nodes=1:ppn=1 #PBS -l walltime=1:00:00 #PBS -o job.log @@ -96,7 +96,7 @@ def cal_ABACUS(T1,T2,i_dis): ulimit -s unlimited cd $PBS_O_WORKDIR EXEC={info["ABACUS"]} - mpirun -n 1 $EXEC + mpirun -n 1 -env OMP_NUM_THREADS=1 $EXEC """)) elif utils.sub=="bsub": with open(folder/"sub.sh","w") as file: @@ -105,9 +105,8 @@ def cal_ABACUS(T1,T2,i_dis): #BSUB -q renxg #BSUB -o job.log -e job.err #BSUB -n 1 - export OMP_NUM_THREADS=1 EXEC={info["ABACUS"]} - mpirun -n 1 $EXEC + mpirun -n 1 -env OMP_NUM_THREADS=1 $EXEC """)) os.chdir(folder) diff --git a/ABACUS.1.0.0/tools/opt_lcao_bash/print_file.py b/ABACUS.1.0.0/tools/opt_lcao_bash/print_file.py index c04803f5e2..22766c2cba 100644 --- a/ABACUS.1.0.0/tools/opt_lcao_bash/print_file.py +++ b/ABACUS.1.0.0/tools/opt_lcao_bash/print_file.py @@ -98,11 +98,12 @@ def print_file_pw(info,dis): - elif utils.sub=="qsub": + if utils.sub=="qsub": with open("sub.sh","w") as file: + core = info["exe"]["qsub"][0]*info["exe"]["qsub"][1] file.write(textwrap.dedent(f"""\ #!/bin/bash - #PBS -q batch + #PBS -q gold5120 #PBS -l nodes={info["exe"]["qsub"][0]}:ppn={info["exe"]["qsub"][1]} #PBS -l walltime=1:00:00 #PBS -o job.log @@ -110,7 +111,7 @@ def print_file_pw(info,dis): ulimit -s unlimited cd $PBS_O_WORKDIR EXEC={info["exe"]["exe_pw"]} - mpirun -n {info["exe"]["qsub"][0]*info["exe"]["qsub"][1]} $EXEC + mpirun -n {core} -env OMP_NUM_THREADS=1 $EXEC """)) elif utils.sub=="bsub": with open("sub.sh","w") as file: @@ -120,9 +121,8 @@ def print_file_pw(info,dis): #BSUB -q renxg #BSUB -o job.log -e job.err #BSUB -n {core} - export OMP_NUM_THREADS=1 EXEC={info["exe"]["exe_pw"]} - mpirun -n {core} $EXEC + mpirun -n {core} -env OMP_NUM_THREADS=1 $EXEC """)) else: raise KeyError("utils.sub = ",utils.sub) @@ -143,7 +143,8 @@ def print_file_opt(info,dis): "weight": [1] * len(dis[info["input"]["element"]]), "Rcut": {info["input"]["element"] : info["input"]["rcut"]}, "dr": {info["input"]["element"] : utils.dr}, - "Ecut": {info["input"]["element"] : info["input"]["ecut"]} + "Ecut": {info["input"]["element"] : info["input"]["ecut"]}, + "lr": 0.01 }, "C_init_info": { "init_from_file": False @@ -156,17 +157,18 @@ def print_file_opt(info,dis): file.write(json.dumps(input,indent=4)) - elif utils.sub=="qsub": + if utils.sub=="qsub": with open("sub.sh","w") as file: file.write(textwrap.dedent(f"""\ #!/bin/bash - #PBS -q batch + #PBS -q gold5120 #PBS -l nodes=1:ppn=1 #PBS -l walltime=1:00:00 #PBS -o job.log #PBS -e job.err ulimit -s unlimited cd $PBS_O_WORKDIR + export OMP_NUM_THREADS=1 EXEC={info["exe"]["exe_orbital"]} python3 $EXEC """)) diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_json.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_json.py index b5bc5735c4..929e670532 100644 --- a/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_json.py +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_json.py @@ -30,7 +30,8 @@ def read_json(file_name): "weight": [2,3,1.5], "Rcut": {"S":10,"O":10}, "dr": {"S":0.01,"O":0.01}, - "Ecut": {"S":100,"O":100} + "Ecut": {"S":100,"O":100}, + "lr": 0.01 }, "C_init_info": { diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/main.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/main.py index 54a1912a66..134ffd5574 100644 --- a/ABACUS.1.0.0/tools/opt_orb_pytorch/main.py +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/main.py @@ -61,7 +61,7 @@ #opt_orb_old = opt_orbital_old.Opt_Orbital() #opt = torch.optim.Adam(sum( ([c.real,c.imag] for c in sum(C,[])), []), lr=1e-1, eps=1e-8) -opt = torch.optim.Adam( sum(C.values(),[]), lr=1E-2, eps=1e-20) +opt = torch.optim.Adam( sum(C.values(),[]), lr=info.lr, eps=1e-20) with open("Spillage.dat","w") as S_file: From d88b535c4aa6d7526cc63259b9d1ab9637142308 Mon Sep 17 00:00:00 2001 From: linpz Date: Wed, 24 Jul 2019 20:13:06 +0800 Subject: [PATCH 008/233] 1. fix bug Exx_Lcao::cal_Hexx_thread while() 1.1 source/src_lcao/exx_lcao.cpp 2. exx H_mixing now rely on exx_seperate_loop and charge mixing, delete INPUT_PARAMETERS exx_h_mixing_mode and exx_h_mixing_beta 2.1 source/input.h 2.2 source/input.cpp 2.3 source/input_conv.cpp 2.4 source/src_lcao/exx_lcao.h 2.5 source/src_lcao/exx_lcao.cpp 3. add opt_orb_pytorch input["info"]["lr"] 3.1 tools/opt_orb_pytorch/IO/read_json.py 3.2 tools/opt_orb_pytorch/main.py 3.3 tools/opt_lcao_bash/print_file.py 3.4 tools/opt_lcao_bash/utils.py 3.5 tools/opt_abfs_bash/opt_orb.py 3.6 tools/opt_abfs_bash/utils.py 4. fix bug about sub 4.1 tools/opt_abfs_bash/set_dimer.py 4.2 tools/opt_abfs_bash/opt_orb.py 4.3 tools/opt_abfs_bash/exx.py 4.4 tools/opt_lcao_bash/print_file.py 4.5 tools/opt_lcao_bash/opt_orb.py 4.6 tools/opt_lcao_bash/utils.py 5. change elpa to elpa_openmp 5.1 source/Makefile.vars 5.2 source/Makefile.system --- ABACUS.1.0.0/source/Makefile.system | 2 +- ABACUS.1.0.0/source/Makefile.vars | 6 ++--- ABACUS.1.0.0/source/input.cpp | 23 ------------------- ABACUS.1.0.0/source/input.h | 3 --- ABACUS.1.0.0/source/input_conv.cpp | 7 ------ ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 22 +++++++++++++++--- ABACUS.1.0.0/source/src_lcao/exx_lcao.h | 3 --- ABACUS.1.0.0/tools/opt_abfs_bash/exx.py | 7 +++--- ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py | 4 +++- ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py | 7 +++--- ABACUS.1.0.0/tools/opt_abfs_bash/utils.py | 4 +++- ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py | 2 +- .../tools/opt_lcao_bash/print_file.py | 18 ++++++++------- ABACUS.1.0.0/tools/opt_lcao_bash/utils.py | 6 +++-- .../tools/opt_orb_pytorch/IO/read_json.py | 3 ++- ABACUS.1.0.0/tools/opt_orb_pytorch/main.py | 3 ++- 16 files changed, 54 insertions(+), 66 deletions(-) diff --git a/ABACUS.1.0.0/source/Makefile.system b/ABACUS.1.0.0/source/Makefile.system index 012283fcba..66bfa4caeb 100644 --- a/ABACUS.1.0.0/source/Makefile.system +++ b/ABACUS.1.0.0/source/Makefile.system @@ -20,7 +20,7 @@ FFTW_LIB_DIR = ${FFTW_DIR}/lib FFTW_LIB = -L${FFTW_LIB_DIR} -lfftw3 -Wl,-rpath=${FFTW_LIB_DIR} ELPA_LIB_DIR = ${ELPA_DIR}/lib -ELPA_LIB = -L${ELPA_LIB_DIR} -lelpa -Wl,-rpath=${ELPA_LIB_DIR} +ELPA_LIB = -L${ELPA_LIB_DIR} -lelpa_openmp -Wl,-rpath=${ELPA_LIB_DIR} LIBXC_INCLUDE_DIR = ${LIBXC_DIR}/include LIBXC_LIB_DIR = ${LIBXC_DIR}/lib diff --git a/ABACUS.1.0.0/source/Makefile.vars b/ABACUS.1.0.0/source/Makefile.vars index b66e4f4c83..aae4620447 100644 --- a/ABACUS.1.0.0/source/Makefile.vars +++ b/ABACUS.1.0.0/source/Makefile.vars @@ -1,7 +1,7 @@ CPLUSPLUS = icpc CPLUSPLUS_MPI = mpiicpc -BOOST_DIR = /home/linpz/software/boost_1_66_0 +BOOST_DIR = /home/linpz/software/boost-1.70 LAPACK_DIR = /opt/intel/mkl FFTW_DIR = /home/linpz/software/fftw-3.3.8 -ELPA_DIR = /home/linpz/software/elpa-2016.05.004 -LIBXC_DIR = /home/linpz/software/libxc-4.0.4 +ELPA_DIR = /home/linpz/software/elpa-2016.05.004-openmp +LIBXC_DIR = /home/linpz/software/libxc-4.3.4 diff --git a/ABACUS.1.0.0/source/input.cpp b/ABACUS.1.0.0/source/input.cpp index d441e36bef..af15c1fe9b 100644 --- a/ABACUS.1.0.0/source/input.cpp +++ b/ABACUS.1.0.0/source/input.cpp @@ -435,9 +435,6 @@ void Input::Default(void) exx_distribute_type = "htime"; - exx_h_mixing_mode = "no"; - exx_h_mixing_beta = 0.7; - exx_opt_orb_lmax = 0; exx_opt_orb_ecut = 0.0; exx_opt_orb_tolerence = 0.0; @@ -1545,14 +1542,6 @@ bool Input::Read(const string &fn) { read_value(ifs, exx_distribute_type); } - else if (strcmp("exx_h_mixing_mode", word) == 0) - { - read_value(ifs, exx_h_mixing_mode); - } - else if (strcmp("exx_h_mixing_beta", word) == 0) - { - read_value(ifs, exx_h_mixing_beta); - } else if (strcmp("exx_opt_orb_lmax", word) == 0) { read_value(ifs, exx_opt_orb_lmax); @@ -1965,8 +1954,6 @@ void Input::Bcast() Parallel_Common::bcast_double( exx_schwarz_threshold ); Parallel_Common::bcast_double( exx_cauchy_threshold ); Parallel_Common::bcast_string( exx_distribute_type ); - Parallel_Common::bcast_string( exx_h_mixing_mode ); - Parallel_Common::bcast_double( exx_h_mixing_beta ); Parallel_Common::bcast_int( exx_opt_orb_lmax ); Parallel_Common::bcast_double( exx_opt_orb_ecut ); Parallel_Common::bcast_double( exx_opt_orb_tolerence ); @@ -2589,14 +2576,6 @@ void Input::Check(void) { WARNING_QUIT("INPUT","exx_distribute_type must be htime or kmeans"); } - if(exx_h_mixing_mode!="no" && exx_h_mixing_mode!="plain" && exx_h_mixing_mode!="pulay") - { - WARNING_QUIT("INPUT","exx_h_mixing_mode must be no, plain or pulay"); - } - if(exx_h_mixing_beta<0 || exx_h_mixing_beta>1) - { - WARNING_QUIT("INPUT","must 0 < exx_h_mixing_beta < 1"); - } } if(exx_hybrid_type=="opt_orb") { @@ -2969,8 +2948,6 @@ void Input::Print(const string &fn)const OUTP(ofs,"exx_schwarz_threshold",exx_schwarz_threshold,""); OUTP(ofs,"exx_cauchy_threshold",exx_cauchy_threshold,""); OUTP(ofs,"exx_distribute_type",exx_distribute_type,"htime or kmeans"); - OUTP(ofs,"exx_h_mixing_mode",exx_h_mixing_mode,"no, plain or pulay"); - OUTP(ofs,"exx_h_mixing_beta",exx_h_mixing_beta,""); OUTP(ofs,"exx_opt_orb_lmax",exx_opt_orb_lmax,""); OUTP(ofs,"exx_opt_orb_ecut",exx_opt_orb_ecut,""); OUTP(ofs,"exx_opt_orb_tolerence",exx_opt_orb_tolerence,""); diff --git a/ABACUS.1.0.0/source/input.h b/ABACUS.1.0.0/source/input.h index 82792002a7..c2e04bcddd 100644 --- a/ABACUS.1.0.0/source/input.h +++ b/ABACUS.1.0.0/source/input.h @@ -334,9 +334,6 @@ class Input string exx_distribute_type; - string exx_h_mixing_mode; // "no", "plain" - double exx_h_mixing_beta; - int exx_opt_orb_lmax; double exx_opt_orb_ecut; double exx_opt_orb_tolerence; diff --git a/ABACUS.1.0.0/source/input_conv.cpp b/ABACUS.1.0.0/source/input_conv.cpp index df1680f551..f1ec3cda5d 100644 --- a/ABACUS.1.0.0/source/input_conv.cpp +++ b/ABACUS.1.0.0/source/input_conv.cpp @@ -422,13 +422,6 @@ void Input_Conv::Convert(void) exx_lcao.info.distribute_type = Exx_Lcao::Distribute_Type::Htime; else if(INPUT.exx_distribute_type=="kmeans") exx_lcao.info.distribute_type = Exx_Lcao::Distribute_Type::Kmeans; - if(INPUT.exx_h_mixing_mode=="no") - exx_lcao.info.H_mixing_mode = Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode::No; - else if(INPUT.exx_h_mixing_mode=="plain") - exx_lcao.info.H_mixing_mode = Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode::Plain; - else if(INPUT.exx_h_mixing_mode=="pulay") - exx_lcao.info.H_mixing_mode = Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode::Pulay; - exx_lcao.info.H_mixing_beta = INPUT.exx_h_mixing_beta; Exx_Abfs::Jle::Lmax = INPUT.exx_opt_orb_lmax; Exx_Abfs::Jle::Ecut_exx = INPUT.exx_opt_orb_ecut; Exx_Abfs::Jle::tolerence = INPUT.exx_opt_orb_tolerence; diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp index ab685afca7..d8a3c33b88 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp @@ -430,8 +430,21 @@ gettimeofday( &t_start_all, NULL); // DM.flag_mix = info.separate_loop ? false : true; // DM.flag_mix = false; // Peize Lin test - Hexx_para.mixing_mode = info.H_mixing_mode; - Hexx_para.mixing_beta = info.H_mixing_beta; + if(exx_global.info.separate_loop) + { + Hexx_para.mixing_mode = Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode::No; + Hexx_para.mixing_beta = 0; + } + else + { + if("plain"==chr.mixing_mode) + Hexx_para.mixing_mode = Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode::Plain; + else if("pulay"==chr.mixing_mode) + Hexx_para.mixing_mode = Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode::Pulay; + else + throw invalid_argument("exx mixing error. exx_separate_loop==false, mixing_mode!=plain or pulay"); + Hexx_para.mixing_beta = chr.mixing_beta; + } gettimeofday( &t_start, NULL); this->lcaos = Exx_Abfs::Construct_Orbs::change_orbs( ORB, this->kmesh_times ); @@ -1317,8 +1330,11 @@ gettimeofday( &t_start_all, NULL); vector,matrix>>>> HexxR_tmp(NSPIN); - while(const size_t i_atom_pair_now = i_atom_pair++ < atom_pairs_core.size() ) + while(true) { + const size_t i_atom_pair_now = i_atom_pair++; + if( i_atom_pair_now >= atom_pairs_core.size() ) break; + const size_t iat1 = atom_pairs_core[i_atom_pair_now].first; const size_t iat2 = atom_pairs_core[i_atom_pair_now].second; diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.h b/ABACUS.1.0.0/source/src_lcao/exx_lcao.h index c12e16cc93..71a22c8829 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.h +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.h @@ -104,9 +104,6 @@ class Exx_Lcao double cauchy_threshold = 0; Exx_Lcao::Distribute_Type distribute_type; - - Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode H_mixing_mode; - double H_mixing_beta; Exx_Info( const Exx_Global::Exx_Info &info_global ); }; diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py b/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py index c0a1368066..f37b55a81a 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py @@ -39,7 +39,7 @@ def cal(): with open(f"{utils.folder_exx}/sub.sh","w") as file: file.write(textwrap.dedent(f"""\ #!/bin/bash - #PBS -q batch + #PBS -q gold5120 #PBS -l nodes=1:ppn=28 #PBS -l walltime=24:00:00 #PBS -o job.log @@ -47,7 +47,7 @@ def cal(): ulimit -s unlimited cd $PBS_O_WORKDIR EXEC={info["ABACUS"]} - mpirun -n 1 $EXEC + mpirun -n 1 -env OMP_NUM_THREADS=28 $EXEC """)) elif utils.sub=="bsub": with open(f"{utils.folder_exx}/sub.sh","w") as file: @@ -56,8 +56,7 @@ def cal(): #BSUB -q renxg #BSUB -o job.log -e job.err #BSUB -n 6 - export OMP_NUM_THREADS=6 - mpirun -n 1 {info['ABACUS']} + mpirun -n 1 -env OMP_NUM_THREADS=6 {info['ABACUS']} """)) os.chdir(utils.folder_exx) diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py b/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py index 71317c78b2..3a86ed9fce 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py @@ -42,7 +42,8 @@ def set_input(folders_matrix): "weight": [weight for weight,nbands in folders_matrix.values()], "Rcut": read_stru.get_Rcut(), "dr": {T:utils.dr for T in Ts}, - "Ecut": {T:Ecut for T in Ts} + "Ecut": {T:Ecut for T in Ts}, + "lr": utils.lr }, "C_init_info":{ "init_from_file": False }, "V_info": @@ -68,6 +69,7 @@ def cal(input): #PBS -e job.err ulimit -s unlimited cd $PBS_O_WORKDIR + export OMP_NUM_THREADS=1 EXEC={info["opt_orb"]} python3 -u $EXEC """)) diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py b/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py index 166f085b08..7b172e83d7 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py @@ -88,7 +88,7 @@ def cal_ABACUS(T1,T2,i_dis): with open(folder/"sub.sh","w") as file: file.write(textwrap.dedent(f"""\ #!/bin/bash - #PBS -q batch + #PBS -q gold5120 #PBS -l nodes=1:ppn=1 #PBS -l walltime=1:00:00 #PBS -o job.log @@ -96,7 +96,7 @@ def cal_ABACUS(T1,T2,i_dis): ulimit -s unlimited cd $PBS_O_WORKDIR EXEC={info["ABACUS"]} - mpirun -n 1 $EXEC + mpirun -n 1 -env OMP_NUM_THREADS=1 $EXEC """)) elif utils.sub=="bsub": with open(folder/"sub.sh","w") as file: @@ -105,9 +105,8 @@ def cal_ABACUS(T1,T2,i_dis): #BSUB -q renxg #BSUB -o job.log -e job.err #BSUB -n 1 - export OMP_NUM_THREADS=1 EXEC={info["ABACUS"]} - mpirun -n 1 $EXEC + mpirun -n 1 -env OMP_NUM_THREADS=1 $EXEC """)) os.chdir(folder) diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/utils.py b/ABACUS.1.0.0/tools/opt_abfs_bash/utils.py index eb96cc24c0..d8e02be74a 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/utils.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/utils.py @@ -28,7 +28,9 @@ def floatlist_str(l): return "-".join(list(map(str,l))) sub = "qsub" -dr = 0.01 +dr = 0.01 +lr = 1 + def folder_name(T1,T2,i_dis): return f"{T1}-{T2}_{i_dis}" try: diff --git a/ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py b/ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py index d9f72578dd..9bc8691b5c 100644 --- a/ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py +++ b/ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py @@ -4,6 +4,7 @@ from read_info import read_info from print_file import print_file_pw, print_file_opt from dis import dis +import utils def cal_pw(): info = read_info("info.json") @@ -25,7 +26,6 @@ def cal_opt(): pathlib.Path("opt_orb").mkdir(parents=True,exist_ok=False) os.chdir("opt_orb") print_file_opt(info,dis) - os.system("qsub sub.sh") if utils.sub=="qsub": os.system("qsub sub.sh") elif utils.sub=="bsub": diff --git a/ABACUS.1.0.0/tools/opt_lcao_bash/print_file.py b/ABACUS.1.0.0/tools/opt_lcao_bash/print_file.py index c04803f5e2..6e3a88b952 100644 --- a/ABACUS.1.0.0/tools/opt_lcao_bash/print_file.py +++ b/ABACUS.1.0.0/tools/opt_lcao_bash/print_file.py @@ -98,11 +98,12 @@ def print_file_pw(info,dis): - elif utils.sub=="qsub": + if utils.sub=="qsub": with open("sub.sh","w") as file: + core = info["exe"]["qsub"][0]*info["exe"]["qsub"][1] file.write(textwrap.dedent(f"""\ #!/bin/bash - #PBS -q batch + #PBS -q gold5120 #PBS -l nodes={info["exe"]["qsub"][0]}:ppn={info["exe"]["qsub"][1]} #PBS -l walltime=1:00:00 #PBS -o job.log @@ -110,7 +111,7 @@ def print_file_pw(info,dis): ulimit -s unlimited cd $PBS_O_WORKDIR EXEC={info["exe"]["exe_pw"]} - mpirun -n {info["exe"]["qsub"][0]*info["exe"]["qsub"][1]} $EXEC + mpirun -n {core} -env OMP_NUM_THREADS=1 $EXEC """)) elif utils.sub=="bsub": with open("sub.sh","w") as file: @@ -120,9 +121,8 @@ def print_file_pw(info,dis): #BSUB -q renxg #BSUB -o job.log -e job.err #BSUB -n {core} - export OMP_NUM_THREADS=1 EXEC={info["exe"]["exe_pw"]} - mpirun -n {core} $EXEC + mpirun -n {core} -env OMP_NUM_THREADS=1 $EXEC """)) else: raise KeyError("utils.sub = ",utils.sub) @@ -143,7 +143,8 @@ def print_file_opt(info,dis): "weight": [1] * len(dis[info["input"]["element"]]), "Rcut": {info["input"]["element"] : info["input"]["rcut"]}, "dr": {info["input"]["element"] : utils.dr}, - "Ecut": {info["input"]["element"] : info["input"]["ecut"]} + "Ecut": {info["input"]["element"] : info["input"]["ecut"]}, + "lr": utils.lr }, "C_init_info": { "init_from_file": False @@ -156,17 +157,18 @@ def print_file_opt(info,dis): file.write(json.dumps(input,indent=4)) - elif utils.sub=="qsub": + if utils.sub=="qsub": with open("sub.sh","w") as file: file.write(textwrap.dedent(f"""\ #!/bin/bash - #PBS -q batch + #PBS -q gold5120 #PBS -l nodes=1:ppn=1 #PBS -l walltime=1:00:00 #PBS -o job.log #PBS -e job.err ulimit -s unlimited cd $PBS_O_WORKDIR + export OMP_NUM_THREADS=1 EXEC={info["exe"]["exe_orbital"]} python3 $EXEC """)) diff --git a/ABACUS.1.0.0/tools/opt_lcao_bash/utils.py b/ABACUS.1.0.0/tools/opt_lcao_bash/utils.py index 2348f947ed..d085415fb2 100644 --- a/ABACUS.1.0.0/tools/opt_lcao_bash/utils.py +++ b/ABACUS.1.0.0/tools/opt_lcao_bash/utils.py @@ -1,2 +1,4 @@ -lat0 = 20 -dr = 0.01 \ No newline at end of file +lat0 = 20 +dr = 0.01 +lr = 1 +sub = "qsub" \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_json.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_json.py index b5bc5735c4..929e670532 100644 --- a/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_json.py +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_json.py @@ -30,7 +30,8 @@ def read_json(file_name): "weight": [2,3,1.5], "Rcut": {"S":10,"O":10}, "dr": {"S":0.01,"O":0.01}, - "Ecut": {"S":100,"O":100} + "Ecut": {"S":100,"O":100}, + "lr": 0.01 }, "C_init_info": { diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/main.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/main.py index 54a1912a66..6dbaa5d870 100644 --- a/ABACUS.1.0.0/tools/opt_orb_pytorch/main.py +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/main.py @@ -10,6 +10,7 @@ import numpy as np import time +print("seed:",torch.initial_seed()) time_start = time.time() file_list, info, C_init_info, V_info = IO.read_json.read_json("input.json") @@ -61,7 +62,7 @@ #opt_orb_old = opt_orbital_old.Opt_Orbital() #opt = torch.optim.Adam(sum( ([c.real,c.imag] for c in sum(C,[])), []), lr=1e-1, eps=1e-8) -opt = torch.optim.Adam( sum(C.values(),[]), lr=1E-2, eps=1e-20) +opt = torch.optim.Adam( sum(C.values(),[]), lr=info.lr, eps=1e-20) with open("Spillage.dat","w") as S_file: From 872d5c3187f3aceeae74f53c6edc3a3029e5dbfa Mon Sep 17 00:00:00 2001 From: linpz Date: Thu, 25 Jul 2019 03:54:27 +0800 Subject: [PATCH 009/233] 1. update opt_orb_pytorch to pytorch v1.1.0 1.1 tools/opt_orb_pytorch/IO/func_C.py 1.2 tools/opt_orb_pytorch/IO/print_QSV.py 1.3 tools/opt_orb_pytorch/IO/read_QSV.py 1.4 tools/opt_orb_pytorch/IO/read_json.py 1.5 tools/opt_orb_pytorch/main.py 1.6 tools/opt_orb_pytorch/opt_orbital.py 1.7 tools/opt_orb_pytorch/orbital.py 1.8 tools/opt_orb_pytorch/util.py --- ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py | 2 +- .../tools/opt_lcao_bash/print_file.py | 2 +- ABACUS.1.0.0/tools/opt_lcao_bash/utils.py | 6 +- .../tools/opt_orb_pytorch/IO/func_C.py | 6 +- .../tools/opt_orb_pytorch/IO/print_QSV.py | 56 +++++++-------- .../tools/opt_orb_pytorch/IO/read_QSV.py | 41 ++++++----- .../tools/opt_orb_pytorch/IO/read_json.py | 1 + ABACUS.1.0.0/tools/opt_orb_pytorch/main.py | 70 ++----------------- .../tools/opt_orb_pytorch/opt_orbital.py | 8 +-- ABACUS.1.0.0/tools/opt_orb_pytorch/orbital.py | 4 +- ABACUS.1.0.0/tools/opt_orb_pytorch/util.py | 2 - 11 files changed, 74 insertions(+), 124 deletions(-) diff --git a/ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py b/ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py index d9f72578dd..9bc8691b5c 100644 --- a/ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py +++ b/ABACUS.1.0.0/tools/opt_lcao_bash/opt_orb.py @@ -4,6 +4,7 @@ from read_info import read_info from print_file import print_file_pw, print_file_opt from dis import dis +import utils def cal_pw(): info = read_info("info.json") @@ -25,7 +26,6 @@ def cal_opt(): pathlib.Path("opt_orb").mkdir(parents=True,exist_ok=False) os.chdir("opt_orb") print_file_opt(info,dis) - os.system("qsub sub.sh") if utils.sub=="qsub": os.system("qsub sub.sh") elif utils.sub=="bsub": diff --git a/ABACUS.1.0.0/tools/opt_lcao_bash/print_file.py b/ABACUS.1.0.0/tools/opt_lcao_bash/print_file.py index 22766c2cba..6e3a88b952 100644 --- a/ABACUS.1.0.0/tools/opt_lcao_bash/print_file.py +++ b/ABACUS.1.0.0/tools/opt_lcao_bash/print_file.py @@ -144,7 +144,7 @@ def print_file_opt(info,dis): "Rcut": {info["input"]["element"] : info["input"]["rcut"]}, "dr": {info["input"]["element"] : utils.dr}, "Ecut": {info["input"]["element"] : info["input"]["ecut"]}, - "lr": 0.01 + "lr": utils.lr }, "C_init_info": { "init_from_file": False diff --git a/ABACUS.1.0.0/tools/opt_lcao_bash/utils.py b/ABACUS.1.0.0/tools/opt_lcao_bash/utils.py index 2348f947ed..d085415fb2 100644 --- a/ABACUS.1.0.0/tools/opt_lcao_bash/utils.py +++ b/ABACUS.1.0.0/tools/opt_lcao_bash/utils.py @@ -1,2 +1,4 @@ -lat0 = 20 -dr = 0.01 \ No newline at end of file +lat0 = 20 +dr = 0.01 +lr = 1 +sub = "qsub" \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/func_C.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/func_C.py index ea18f13db2..2e28b1c3df 100644 --- a/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/func_C.py +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/func_C.py @@ -1,5 +1,6 @@ from util import * import torch +import numpy as np def random_C_init(info): """ C[it][il][ie,iu] """ @@ -7,8 +8,7 @@ def random_C_init(info): for it in info.Nt_all: C[it] = ND_list(info.Nl[it]) for il in range(info.Nl[it]): - C_tmp = torch.randn( info.Ne[it], info.Nu[it][il] )*2-1 #[-1,1] - C[it][il] = torch.autograd.Variable( C_tmp, requires_grad = True ) + C[it][il] = torch.tensor(np.random.uniform(-1,1, (info.Ne[it], info.Nu[it][il])), dtype=torch.float32, requires_grad=True) return C @@ -62,7 +62,7 @@ def write_C(file_name,info,C): print("\tType\tL\tZeta-Orbital", file=file) print(f"\t {info.Nt_all.index(it)+1} \t{il}\t {iu+1}", file=file) for ie in range(C_tl.size()[0]): - print("\t", C_tl.data[ie,iu], file=file) + print("\t", C_tl[ie,iu].item(), file=file) print("", file=file) diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/print_QSV.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/print_QSV.py index 750f29c49c..1b0f88c59e 100644 --- a/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/print_QSV.py +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/print_QSV.py @@ -1,29 +1,29 @@ -def print_V(V,file_name): - """ V[ist][ib] """ - with open(file_name,"w") as file: - for V_s in V: - for V_sb in V_s: - print(1-V_sb.data[0],end="\t",file=file) - print(file=file) - -def print_S(S,file_name): - """ S[ist][it1,it2][il1][il2][ia1*im1*in1,ia2*im2*in2] """ - with open(file_name,"w") as file: - for ist,S_s in enumerate(S): - for (it1,it2),S_tt in S_s.items(): - for il1,S_ttl in enumerate(S_tt): - for il2,S_ttll in enumerate(S_ttl): - print(ist,it1,it2,il1,il2,file=file) - print(S_ttll.real.data.numpy(),file=file) - print(S_ttll.imag.data.numpy(),"\n",file=file) - -def print_Q(Q,file_name): - """ Q[ist][it][il][ib,ia*im*iu] """ - with open(file_name,"w") as file: - for ist,Q_s in enumerate(Q): - for it,Q_st in Q_s.items(): - for il,Q_stl in enumerate(Q_st): - print(ist,it,il,file=file) - print(Q_stl.real.data.numpy(),file=file) - print(Q_stl.imag.data.numpy(),"\n",file=file) +def print_V(V,file_name): + """ V[ist][ib] """ + with open(file_name,"w") as file: + for V_s in V: + for V_sb in V_s: + print(1-V_sb.item(),end="\t",file=file) + print(file=file) + +def print_S(S,file_name): + """ S[ist][it1,it2][il1][il2][ia1*im1*in1,ia2*im2*in2] """ + with open(file_name,"w") as file: + for ist,S_s in enumerate(S): + for (it1,it2),S_tt in S_s.items(): + for il1,S_ttl in enumerate(S_tt): + for il2,S_ttll in enumerate(S_ttl): + print(ist,it1,it2,il1,il2,file=file) + print(S_ttll.real.numpy(),file=file) + print(S_ttll.imag.numpy(),"\n",file=file) + +def print_Q(Q,file_name): + """ Q[ist][it][il][ib,ia*im*iu] """ + with open(file_name,"w") as file: + for ist,Q_s in enumerate(Q): + for it,Q_st in Q_s.items(): + for il,Q_stl in enumerate(Q_st): + print(ist,it,il,file=file) + print(Q_stl.real.numpy(),file=file) + print(Q_stl.imag.numpy(),"\n",file=file) \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_QSV.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_QSV.py index 00e3c09259..761e407e71 100644 --- a/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_QSV.py +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_QSV.py @@ -4,6 +4,8 @@ import itertools import numpy as np +import time + def read_file(info,file_list,V_info): """ QI[ist][it][il][ib*ia*im,ie] """ """ SI[ist][it1][it2][il1][il2][ie1,ia1,im1,ia2,im2,ie2] """ @@ -87,9 +89,8 @@ def read_QI(info,ist,file,line=None): QI[it] = ND_list(info.Nl[it]) for il in range(info.Nl[it]): QI[it][il] = torch_complex.ComplexTensor( - torch.autograd.Variable(torch.Tensor(info.Nb[ist],info.Na[ist][it],info.Nm(il),info.Ne[it])), - torch.autograd.Variable(torch.Tensor(info.Nb[ist],info.Na[ist][it],info.Nm(il),info.Ne[it])) ) - + np.empty((info.Nb[ist],info.Na[ist][it],info.Nm(il),info.Ne[it]),dtype=np.float32), + np.empty((info.Nb[ist],info.Na[ist][it],info.Nm(il),info.Ne[it]),dtype=np.float32) ) for ib in range(info.Nb[ist]): for it in info.Nt[ist]: for ia in range(info.Na[ist][it]): @@ -97,12 +98,14 @@ def read_QI(info,ist,file,line=None): for im in range(info.Nm(il)): for ie in range(info.Ne[it]): if not line: line = file.readline().split() - QI[it][il].real.data[ib,ia,im,ie] = float(line.pop(0)) + QI[it][il].real[ib,ia,im,ie] = float(line.pop(0)) if not line: line = file.readline().split() - QI[it][il].imag.data[ib,ia,im,ie] = float(line.pop(0)) + QI[it][il].imag[ib,ia,im,ie] = float(line.pop(0)) for it in info.Nt[ist]: for il in range(info.Nl[it]): - QI[it][il] = QI[it][il].view(-1,info.Ne[it]) + QI[it][il] = torch_complex.ComplexTensor( + torch.from_numpy(QI[it][il].real).view(-1,info.Ne[it]), + torch.from_numpy(QI[it][il].imag).view(-1,info.Ne[it])) return QI,line @@ -114,9 +117,8 @@ def read_SI(info,ist,file,line=None): SI[it1,it2] = ND_list(info.Nl[it1],info.Nl[it2]) for il1,il2 in itertools.product( range(info.Nl[it1]), range(info.Nl[it2]) ): SI[it1,it2][il1][il2] = torch_complex.ComplexTensor( - torch.autograd.Variable(torch.Tensor(info.Na[ist][it1],info.Nm(il1),info.Ne[it1],info.Na[ist][it2],info.Nm(il2),info.Ne[it2])), - torch.autograd.Variable(torch.Tensor(info.Na[ist][it1],info.Nm(il1),info.Ne[it1],info.Na[ist][it2],info.Nm(il2),info.Ne[it2])) ) - + np.empty((info.Na[ist][it1],info.Nm(il1),info.Ne[it1],info.Na[ist][it2],info.Nm(il2),info.Ne[it2]),dtype=np.float32), + np.empty((info.Na[ist][it1],info.Nm(il1),info.Ne[it1],info.Na[ist][it2],info.Nm(il2),info.Ne[it2]),dtype=np.float32) ) for it1 in info.Nt[ist]: for ia1 in range(info.Na[ist][it1]): for il1 in range(info.Nl[it1]): @@ -128,9 +130,14 @@ def read_SI(info,ist,file,line=None): for ie1 in range(info.Ne[it1]): for ie2 in range(info.Ne[it2]): if not line: line = file.readline().split() - SI[it1,it2][il1][il2].real.data[ia1,im1,ie1,ia2,im2,ie2] = float(line.pop(0)) + SI[it1,it2][il1][il2].real[ia1,im1,ie1,ia2,im2,ie2] = float(line.pop(0)) if not line: line = file.readline().split() - SI[it1,it2][il1][il2].imag.data[ia1,im1,ie1,ia2,im2,ie2] = float(line.pop(0)) + SI[it1,it2][il1][il2].imag[ia1,im1,ie1,ia2,im2,ie2] = float(line.pop(0)) + for it1,it2 in itertools.product( info.Nt[ist], info.Nt[ist] ): + for il1,il2 in itertools.product( range(info.Nl[it1]), range(info.Nl[it2]) ): + SI[it1,it2][il1][il2] = torch_complex.ComplexTensor( + torch.from_numpy(SI[it1,it2][il1][il2].real), + torch.from_numpy(SI[it1,it2][il1][il2].imag)) return SI,line @@ -139,19 +146,19 @@ def read_VI(info,V_info,ist,file,line=None): if V_info["same_band"]: """ VI[ib] """ if V_info["init_from_file"]: - VI = torch.autograd.Variable(torch.Tensor(info.Nb[ist])) + VI = np.empty(info.Nb[ist],dtype=np.float32) for ib in range(info.Nb[ist]): if not line: line = file.readline().split() VI.data[ib] = float(line.pop(0)) else: - VI = torch.autograd.Variable(torch.ones(info.Nb[ist])) + VI = np.ones(info.Nb[ist],dtype=np.float32) else: """ VI[ib1,ib2] """ if V_info["init_from_file"]: - VI = torch.autograd.Variable(torch.Tensor(info.Nb[ist],info.Nb[ist])) + VI = np.empty((info.Nb[ist],info.Nb[ist]),dtype=np.float32) for ib1,ib2 in itertools.product( range(info.Nb[ist]), range(info.Nb[ist]) ): if not line: line = file.readline().split() - VI.data[ib1,ib2] = float(line.pop(0)) + VI[ib1,ib2] = float(line.pop(0)) else: - VI = torch.autograd.Variable(torch.eye(info.Nb[ist],info.Nb[ist])) - return VI,line \ No newline at end of file + VI = np.eye(info.Nb[ist],info.Nb[ist],dtype=np.float32) + return torch.from_numpy(VI),line diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_json.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_json.py index 929e670532..52887f9775 100644 --- a/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_json.py +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/IO/read_json.py @@ -54,6 +54,7 @@ def read_json(file_name): Rcut {"S":10, "O":10} dr {"S":0.01, "O":0.01} Ecut {"S":100, "O":100} + lr 0.01 Nl {"S":2, "O":2} Nst 3 Nt [["S"], ["S","O"], ["S","O"]] diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/main.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/main.py index 134ffd5574..49d8753e6b 100644 --- a/ABACUS.1.0.0/tools/opt_orb_pytorch/main.py +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/main.py @@ -4,12 +4,12 @@ import IO.read_json import IO.print_orbital import opt_orbital -#import opt_orbital_old import orbital import torch import numpy as np import time +print("seed:",torch.initial_seed()) time_start = time.time() file_list, info, C_init_info, V_info = IO.read_json.read_json("input.json") @@ -17,10 +17,6 @@ QI,SI,VI = IO.read_QSV.read_file(info,file_list,V_info) print(info) -#print("QI:\t",QI) -#print("SI:\t",SI) -#print("VI:\t",VI) - if C_init_info["init_from_file"]: C = IO.func_C.read_C_init( C_init_info["C_init_file"], info ) else: @@ -28,39 +24,9 @@ E = orbital.set_E(info,info.Rcut) orbital.normalize( orbital.generate_orbital(info,C,E,info.Rcut,info.dr), info.dr,C,flag_norm_C=True) -""" -Q = opt_orb.cal_Q(QI,C,info) -S = opt_orb.cal_S(SI,C,info) -V = opt_orb.cal_V(Q,S,info) -IO.print_QSV.print_Q(Q,"Q.dat") -IO.print_QSV.print_Q(QI,"QI.dat") -IO.print_QSV.print_S(S,"S.dat") -IO.print_QSV.print_S(SI,"SI.dat") -IO.print_QSV.print_V(V,"V.dat") - -Spillage = V_true-sum((sum(Vi[:info.Nb_true[ist]]) for ist,Vi in enumerate(V) ))/sum(info.Nb_true,0) -T = opt_orb.cal_T(C,E) -Loss = Spillage + 0.01*T - -orb = orbital.generate_orbital(info,C,E,info.Rcut,info.dr) -orbital.smooth_orbital(orb,info.Rcut,info.dr,0.1) -orbital.orth(orb,info.dr) -IO.print_orbital.print_orbital(orb) -IO.print_orbital.print_orbital_plot(orb,info.Rcut,info.dr) - -with open("Spillage.dat","w") as S_file, open("C.dat","w") as C_file: - print(Spillage.data[0],T.data[0],Loss.data[0],file=S_file) - print(C,file=C_file) - print("time:\t",time.time()-time_start) - -exit() -""" - - opt_orb = opt_orbital.Opt_Orbital() -#opt_orb_old = opt_orbital_old.Opt_Orbital() -#opt = torch.optim.Adam(sum( ([c.real,c.imag] for c in sum(C,[])), []), lr=1e-1, eps=1e-8) +#opt = torch.optim.Adam(sum( ([c.real,c.imag] for c in sum(C,[])), []), lr=info.lr, eps=1e-8) opt = torch.optim.Adam( sum(C.values(),[]), lr=info.lr, eps=1e-20) with open("Spillage.dat","w") as S_file: @@ -70,31 +36,7 @@ for i in range(20000): Q = opt_orb.cal_Q(QI,C,info) S = opt_orb.cal_S(SI,C,info) - V = opt_orb.cal_V(Q,S,info,V_info) -# V_old = opt_orb_old.cal_V(Q,S,info) - - """ - with open("V_old.dat","w") as file: - for v_old in V_old: - for vi in v_old: - print(vi.data[0],end="\t",file=file) - print(file=file) - with open("V.dat","w") as file: - for v in V: - for i in range(v.size()[0]): - for j in range(v.size()[1]): - print(v.data[i,j],end="\t",file=file) - print(file=file) - print(file=file) - with open("VI.dat","w") as file: - for v in VI: - for i in range(v.size()[0]): - for j in range(v.size()[1]): - print(v.data[i,j],end="\t",file=file) - print(file=file) - print(file=file) - """ - + V = opt_orb.cal_V(Q,S,info,V_info) V_delta = ( torch.abs(VIi-Vi) for VIi,Vi in zip(VI,V) ) # abs or **2? if V_info["same_band"]: @@ -105,9 +47,9 @@ if not "TSrate" in vars(): TSrate = torch.abs(0.002*Spillage/T).data[0] Loss = Spillage + TSrate*T - print(Spillage.data[0],T.data[0],Loss.data[0],file=S_file) - if Loss.data[0] < loss_old: - loss_old = Loss.data[0] + print(Spillage.item(),T.item(),Loss.item(),file=S_file) + if Loss.item() < loss_old: + loss_old = Loss.item() C_old = IO.func_C.copy_C(C,info) flag_finish = 0 else: diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/opt_orbital.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/opt_orbital.py index 6c35f496f2..6f3a357982 100644 --- a/ABACUS.1.0.0/tools/opt_orb_pytorch/opt_orbital.py +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/opt_orbital.py @@ -97,7 +97,7 @@ def cal_V(self,Q,S,info,V_info): Q_s[it] = torch_complex.cat(Q_ts) # Q_cat[it*il*ia*im*iu] Q_cat = torch_complex.cat(list(Q_s.values())) - V_s[ib] = torch_complex.dot( Q_cat.conj(), torch_complex.mv( S_I, Q_cat ) ).real + V_s[ib] = torch_complex.dot( Q_cat.conj(), torch_complex.mv( S_I, Q_cat ) ).real.view(-1) # V[ist][ib] V[ist] = torch.cat(V_s) else: @@ -121,16 +121,16 @@ def cal_V(self,Q,S,info,V_info): def cal_T(self,C,E): """ T = 0.5* sum_{it,il,iu} sum_{ie} ( E[it][il,ie] * C[it][il][ie,iu] )**2 """ - T = torch.autograd.Variable(torch.zeros(1)) + T = torch.zeros(1) num = 0 for it,C_t in C.items(): for il,C_tl in enumerate(C_t): for iu in range(C_tl.size()[1]): - T_tlu = torch.autograd.Variable(torch.zeros(1)) + T_tlu = torch.zeros(1) Z_tlu = 0 for ie in range(C_tl.size()[0]): T_tlu = T_tlu + ( E[it][il,ie] * C_tl[ie,iu] )**2 - Z_tlu = Z_tlu + E[it].data[il,ie]**2 + Z_tlu = Z_tlu + E[it][il,ie].item()**2 T = T + T_tlu/Z_tlu num += C_tl.size()[1] T = 0.5 * T / num diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/orbital.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/orbital.py index 220e3c1461..14c127a0d5 100644 --- a/ABACUS.1.0.0/tools/opt_orb_pytorch/orbital.py +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/orbital.py @@ -20,7 +20,7 @@ def generate_orbital(info,C,E,Rcut,dr): for ir in range(Nr): r = ir * dr[it] for ie in range(info.Ne[it]): - orb[it][il][iu][ir] += C[it][il].data[ie,iu] * spherical_jn(il,E[it].data[il,ie]*r) + orb[it][il][iu][ir] += C[it][il][ie,iu].item() * spherical_jn(il,E[it][il,ie].item()*r) return orb @@ -76,5 +76,5 @@ def set_E(info,Rcut): eigenvalue = { it:find_eigenvalue(info.Nl[it],info.Ne[it]) for it in info.Nt_all } E = dict() for it in Rcut: - E[it] = torch.autograd.Variable(torch.from_numpy(( eigenvalue[it]/Rcut[it] ).astype("float32"))) + E[it] = torch.from_numpy(( eigenvalue[it]/Rcut[it] ).astype("float32")) return E \ No newline at end of file diff --git a/ABACUS.1.0.0/tools/opt_orb_pytorch/util.py b/ABACUS.1.0.0/tools/opt_orb_pytorch/util.py index ea435309a1..ac05ae2034 100644 --- a/ABACUS.1.0.0/tools/opt_orb_pytorch/util.py +++ b/ABACUS.1.0.0/tools/opt_orb_pytorch/util.py @@ -29,8 +29,6 @@ def change_to_cuda(s): return {i:change_to_cuda(x) for i,x in s.items()} elif isinstance(s,torch.Tensor): return s.cuda() - elif isinstance(s,torch.autograd.Variable): - return s.cuda() elif isinstance(s,torch_complex.ComplexTensor): return torch_complex.ComplexTensor( change_to_cuda(s.real), change_to_cuda(s.imag) ) else: From d3cbbf2982fd679a46c03d42df501f86eabb25c7 Mon Sep 17 00:00:00 2001 From: linpz Date: Tue, 30 Jul 2019 03:09:41 +0800 Subject: [PATCH 010/233] 1. update Conv_Coulomb_Pot_K parameter 1.1 src_lcao/conv_coulomb_pot_k.h 1.2 src_lcao/conv_coulomb_pot_k.cpp 1.3 src_lcao/conv_coulomb_pot_k-template.h 1.4 src_lcao/exx_lcao.cpp 2. Conv_Coulomb_Pot_K output rmesh_times 2.1 src_lcao/conv_coulomb_pot_k.h 2.2 src_lcao/conv_coulomb_pot_k.cpp 2.3 src_lcao/conv_coulomb_pot_k-template.h 2.4 src_lcao/exx_lcao.h 2.5 src_lcao/exx_lcao.cpp 2.6 src_lcao/abfs.h 2.7 src_lcao/abfs.cpp --- ABACUS.1.0.0/source/src_lcao/abfs.cpp | 2 +- ABACUS.1.0.0/source/src_lcao/abfs.h | 2 +- .../src_lcao/conv_coulomb_pot_k-template.h | 47 ++++++++++++++++--- .../source/src_lcao/conv_coulomb_pot_k.cpp | 22 +++++++-- .../source/src_lcao/conv_coulomb_pot_k.h | 26 +++++++--- ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 13 ++--- ABACUS.1.0.0/source/src_lcao/exx_lcao.h | 2 +- 7 files changed, 85 insertions(+), 29 deletions(-) diff --git a/ABACUS.1.0.0/source/src_lcao/abfs.cpp b/ABACUS.1.0.0/source/src_lcao/abfs.cpp index 3ec1c2b826..0a081ff981 100644 --- a/ABACUS.1.0.0/source/src_lcao/abfs.cpp +++ b/ABACUS.1.0.0/source/src_lcao/abfs.cpp @@ -148,7 +148,7 @@ map,shared_ptr>>> Abfs::c const vector> &Coulomb_potential_boxes, const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, const Element_Basis_Index::IndexLNM &index_abfs, - const int rmesh_times, + const double rmesh_times, const double threshold, map,weak_ptr>>> &Vws ) { diff --git a/ABACUS.1.0.0/source/src_lcao/abfs.h b/ABACUS.1.0.0/source/src_lcao/abfs.h index b19f329d0f..cee26a639a 100644 --- a/ABACUS.1.0.0/source/src_lcao/abfs.h +++ b/ABACUS.1.0.0/source/src_lcao/abfs.h @@ -36,7 +36,7 @@ class Abfs const vector> &Coulomb_potential_boxes, const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, const Element_Basis_Index::IndexLNM &index_abfs, - const int rmesh_times, + const double rmesh_times, const double threshold, map,weak_ptr>>> &Vws ); diff --git a/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k-template.h b/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k-template.h index f720326134..870dda4a4c 100644 --- a/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k-template.h +++ b/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k-template.h @@ -5,17 +5,33 @@ #include #include +template +T Conv_Coulomb_Pot_K::cal_orbs_ccp_rmesh( + const T & orbs, + const Ccp_Type &ccp_type, + const std::map ¶meter, + double &rmesh_times) +{ + const double rmesh_times_trial = 10; // Peize Lin test + const double psi_threshold = 1E-8; // Peize Lin test + const T orbs_ccp_trial = cal_orbs_ccp(orbs, ccp_type, parameter, rmesh_times_trial); + rmesh_times = get_rmesh_proportion(orbs_ccp_trial, psi_threshold) * rmesh_times_trial; + const T orbs_ccp = cal_orbs_ccp(orbs, ccp_type, parameter, rmesh_times); + return orbs_ccp; +} + + + template< typename T > T Conv_Coulomb_Pot_K::cal_orbs_ccp( const T & orbs, const Ccp_Type &ccp_type, - const double rmesh_times, - const double omega, - const double Rcut) + const std::map ¶meter, + const double rmesh_times) { T orbs_ccp(orbs.size()); for( size_t i=0; i!=orbs.size(); ++i ) - orbs_ccp[i] = cal_orbs_ccp( orbs[i], ccp_type, rmesh_times, omega, Rcut ); + orbs_ccp[i] = cal_orbs_ccp( orbs[i], ccp_type, parameter, rmesh_times ); return orbs_ccp; } @@ -23,8 +39,25 @@ extern template Numerical_Orbital_Lm Conv_Coulomb_Pot_K::cal_orbs_ccp( const Numerical_Orbital_Lm & orbs, const Ccp_Type &ccp_type, - const double rmesh_times, - const double omega, - const double Rcut); + const std::map ¶meter, + const double rmesh_times); + + + +template< typename T > +double Conv_Coulomb_Pot_K::get_rmesh_proportion( + const T & orbs, + const double psi_threshold) +{ + double rmesh_proportion=0; + for( const auto &orb : orbs ) + rmesh_proportion = std::max(rmesh_proportion, get_rmesh_proportion(orb,psi_threshold)); + return rmesh_proportion; +} + +extern template +double Conv_Coulomb_Pot_K::get_rmesh_proportion( + const Numerical_Orbital_Lm & orbs, + const double psi_threshold); #endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.cpp b/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.cpp index b6d2984722..71e5bd07ca 100644 --- a/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.cpp +++ b/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.cpp @@ -25,11 +25,10 @@ std::vector Conv_Coulomb_Pot_K::cal_psi_hse( template<> Numerical_Orbital_Lm Conv_Coulomb_Pot_K::cal_orbs_ccp( - const Numerical_Orbital_Lm & orbs, + const Numerical_Orbital_Lm &orbs, const Ccp_Type &ccp_type, - const double rmesh_times, - const double omega, - const double Rcut) + const std::map ¶meter, + const double rmesh_times) { std::vector psik2_ccp; switch(ccp_type) @@ -37,7 +36,7 @@ Numerical_Orbital_Lm Conv_Coulomb_Pot_K::cal_orbs_ccp( case Ccp_Type::Ccp: psik2_ccp = cal_psi_ccp( orbs.get_psif() ); break; case Ccp_Type::Hse: - psik2_ccp = cal_psi_hse( orbs.get_psif(), orbs.get_k_radial(), omega ); break; + psik2_ccp = cal_psi_hse( orbs.get_psif(), orbs.get_k_radial(), parameter.at("hse_omega") ); break; default: throw( TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__) ); break; } @@ -72,4 +71,17 @@ Numerical_Orbital_Lm Conv_Coulomb_Pot_K::cal_orbs_ccp( false, true); return orbs_ccp; +} + +template<> +double Conv_Coulomb_Pot_K::get_rmesh_proportion( + const Numerical_Orbital_Lm &orbs, + const double psi_threshold) +{ + for(int ir=orbs.getNr()-1; ir>=0; --ir) + { + if(std::abs(orbs.getPsi(ir))>=psi_threshold) + return static_cast(ir)/orbs.getNr(); + } + throw runtime_error("psi_threshold too small. "+TO_STRING(__FILE__)+TO_STRING(__LINE__)); } \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.h b/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.h index 046d8231e7..e2286d5f0f 100644 --- a/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.h +++ b/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.h @@ -2,21 +2,35 @@ #define CONV_COULOMB_POT_K_H #include -#include +#include +#include class Conv_Coulomb_Pot_K { public: - enum class Ccp_Type{ Ccp, Hse }; + enum class Ccp_Type{ // parameter: + Ccp, // + Hse}; // "hse_omega" - template static T cal_orbs_ccp( + template static T cal_orbs_ccp_rmesh( const T & orbs, const Ccp_Type &ccp_type, - const double rmesh_times = 1, - const double omega = std::numeric_limits::min(), - const double Rcut = std::numeric_limits::max()); + const std::map ¶meter, + double &rmesh_times); +private: + + template static T cal_orbs_ccp( + const T &orbs, + const Ccp_Type &ccp_type, + const std::map ¶meter, + const double rmesh_times); + + template< typename T > static double get_rmesh_proportion( + const T &orbs, + const double psi_threshold); + private: static std::vector cal_psi_ccp( const std::vector & psif ); diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp index d8a3c33b88..23ae3674ed 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp @@ -54,8 +54,7 @@ static matrix transform ( // Peize Lin test Exx_Lcao::Exx_Lcao( const Exx_Global::Exx_Info &info_global ) - :rmesh_times(10), - kmesh_times(4), + :kmesh_times(4), info(info_global) { auto test_gemm = []() @@ -517,13 +516,14 @@ gettimeofday( &t_start, NULL); { case Exx_Global::Hybrid_Type::HF: case Exx_Global::Hybrid_Type::PBE0: - abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp( this->abfs, Conv_Coulomb_Pot_K::Ccp_Type::Ccp, this->rmesh_times ); break; + abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp_rmesh( this->abfs, Conv_Coulomb_Pot_K::Ccp_Type::Ccp, {}, this->rmesh_times ); break; case Exx_Global::Hybrid_Type::HSE: - abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp( this->abfs, Conv_Coulomb_Pot_K::Ccp_Type::Hse, this->rmesh_times, info.hse_omega ); break; + abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp_rmesh( this->abfs, Conv_Coulomb_Pot_K::Ccp_Type::Hse, {{"hse_omega",info.hse_omega}}, this->rmesh_times ); break; default: throw domain_error(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; } -ofs_mpi<<"TIME@ Conv_Coulomb_Pot_K::cal_orbs_ccp\t"< Date: Thu, 22 Aug 2019 00:36:28 +0800 Subject: [PATCH 011/233] 1. Conv_Coulomb_Pot_K input psi_threshold 1.1 input.h 1.2 input.cpp 1.3 input_conv.cpp 1.4 src_lcao/conv_coulomb_pot_k.h 1.5 src_lcao/conv_coulomb_pot_k-template.h 1.6 src_lcao/conv_coulomb_pot_k.cpp 1.7 src_lcao/exx_lcao.h 1.8 src_lcao/exx_lcao.cpp 1.9 src_external/src_test/src_lcao/exx_abfs-construct_orbs-test.h --- ABACUS.1.0.0/source/input.cpp | 6 ++++++ ABACUS.1.0.0/source/input.h | 1 + ABACUS.1.0.0/source/input_conv.cpp | 1 + .../src_lcao/exx_abfs-construct_orbs-test.h | 17 ++++++++++++++++- .../src_lcao/conv_coulomb_pot_k-template.h | 6 ++++-- .../source/src_lcao/conv_coulomb_pot_k.cpp | 2 +- .../source/src_lcao/conv_coulomb_pot_k.h | 1 + ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 6 +++--- ABACUS.1.0.0/source/src_lcao/exx_lcao.h | 1 + 9 files changed, 34 insertions(+), 7 deletions(-) diff --git a/ABACUS.1.0.0/source/input.cpp b/ABACUS.1.0.0/source/input.cpp index af15c1fe9b..6c51386164 100644 --- a/ABACUS.1.0.0/source/input.cpp +++ b/ABACUS.1.0.0/source/input.cpp @@ -432,6 +432,7 @@ void Input::Default(void) exx_dm_threshold = 0; exx_schwarz_threshold = 0; exx_cauchy_threshold = 0; + exx_ccp_threshold = 1E-8; exx_distribute_type = "htime"; @@ -1538,6 +1539,10 @@ bool Input::Read(const string &fn) { read_value(ifs, exx_cauchy_threshold); } + else if (strcmp("exx_ccp_threshold", word) == 0) + { + read_value(ifs, exx_ccp_threshold); + } else if (strcmp("exx_distribute_type", word) == 0) { read_value(ifs, exx_distribute_type); @@ -2947,6 +2952,7 @@ void Input::Print(const string &fn)const OUTP(ofs,"exx_dm_threshold",exx_dm_threshold,""); OUTP(ofs,"exx_schwarz_threshold",exx_schwarz_threshold,""); OUTP(ofs,"exx_cauchy_threshold",exx_cauchy_threshold,""); + OUTP(ofs,"exx_ccp_threshold",exx_ccp_threshold,""); OUTP(ofs,"exx_distribute_type",exx_distribute_type,"htime or kmeans"); OUTP(ofs,"exx_opt_orb_lmax",exx_opt_orb_lmax,""); OUTP(ofs,"exx_opt_orb_ecut",exx_opt_orb_ecut,""); diff --git a/ABACUS.1.0.0/source/input.h b/ABACUS.1.0.0/source/input.h index c2e04bcddd..8ad726d9c7 100644 --- a/ABACUS.1.0.0/source/input.h +++ b/ABACUS.1.0.0/source/input.h @@ -331,6 +331,7 @@ class Input double exx_dm_threshold; double exx_schwarz_threshold; double exx_cauchy_threshold; + double exx_ccp_threshold; string exx_distribute_type; diff --git a/ABACUS.1.0.0/source/input_conv.cpp b/ABACUS.1.0.0/source/input_conv.cpp index f1ec3cda5d..aa8f863455 100644 --- a/ABACUS.1.0.0/source/input_conv.cpp +++ b/ABACUS.1.0.0/source/input_conv.cpp @@ -418,6 +418,7 @@ void Input_Conv::Convert(void) exx_lcao.info.dm_threshold = INPUT.exx_dm_threshold ; exx_lcao.info.schwarz_threshold = INPUT.exx_schwarz_threshold ; exx_lcao.info.cauchy_threshold = INPUT.exx_cauchy_threshold ; + exx_lcao.info.ccp_threshold = INPUT.exx_ccp_threshold ; if(INPUT.exx_distribute_type=="htime") exx_lcao.info.distribute_type = Exx_Lcao::Distribute_Type::Htime; else if(INPUT.exx_distribute_type=="kmeans") diff --git a/ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_abfs-construct_orbs-test.h b/ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_abfs-construct_orbs-test.h index 568173c0c6..4d139fce04 100644 --- a/ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_abfs-construct_orbs-test.h +++ b/ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_abfs-construct_orbs-test.h @@ -5,7 +5,7 @@ #include #include -void print_orbs( const vector>>> & orbs, const std::string & file_name ) +static void print_orbs( const vector>>> & orbs, const std::string & file_name ) { std::ofstream ofsN(file_name); for( size_t T=0; T!=orbs.size(); ++T ) @@ -20,4 +20,19 @@ void print_orbs( const vector>>> & orbs, const std: ofsN.close(); } +static void print_orbs( const vector>> & orbs, const std::string & file_name ) +{ + std::ofstream ofsN(file_name); + for( size_t T=0; T!=orbs.size(); ++T ) + for( size_t L=0; L!=orbs[T].size(); ++L ) + for( size_t N=0; N!=orbs[T][L].size(); ++N ) + { + ofsN< #include +#include "src_external/src_test/src_lcao/exx_abfs-construct_orbs-test.h" + template T Conv_Coulomb_Pot_K::cal_orbs_ccp_rmesh( const T & orbs, const Ccp_Type &ccp_type, const std::map ¶meter, + const double psi_threshold, double &rmesh_times) { const double rmesh_times_trial = 10; // Peize Lin test - const double psi_threshold = 1E-8; // Peize Lin test const T orbs_ccp_trial = cal_orbs_ccp(orbs, ccp_type, parameter, rmesh_times_trial); - rmesh_times = get_rmesh_proportion(orbs_ccp_trial, psi_threshold) * rmesh_times_trial; + rmesh_times = std::max(1.0, get_rmesh_proportion(orbs_ccp_trial, psi_threshold) * rmesh_times_trial); const T orbs_ccp = cal_orbs_ccp(orbs, ccp_type, parameter, rmesh_times); return orbs_ccp; } diff --git a/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.cpp b/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.cpp index 71e5bd07ca..e5b65762b7 100644 --- a/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.cpp +++ b/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.cpp @@ -83,5 +83,5 @@ double Conv_Coulomb_Pot_K::get_rmesh_proportion( if(std::abs(orbs.getPsi(ir))>=psi_threshold) return static_cast(ir)/orbs.getNr(); } - throw runtime_error("psi_threshold too small. "+TO_STRING(__FILE__)+TO_STRING(__LINE__)); + return 0.0; } \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.h b/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.h index e2286d5f0f..e659146337 100644 --- a/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.h +++ b/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.h @@ -17,6 +17,7 @@ class Conv_Coulomb_Pot_K const T & orbs, const Ccp_Type &ccp_type, const std::map ¶meter, + const double psi_threshold, double &rmesh_times); private: diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp index 23ae3674ed..d276adb7b3 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp @@ -516,9 +516,9 @@ gettimeofday( &t_start, NULL); { case Exx_Global::Hybrid_Type::HF: case Exx_Global::Hybrid_Type::PBE0: - abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp_rmesh( this->abfs, Conv_Coulomb_Pot_K::Ccp_Type::Ccp, {}, this->rmesh_times ); break; + abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp_rmesh( this->abfs, Conv_Coulomb_Pot_K::Ccp_Type::Ccp, {}, info.ccp_threshold, this->rmesh_times ); break; case Exx_Global::Hybrid_Type::HSE: - abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp_rmesh( this->abfs, Conv_Coulomb_Pot_K::Ccp_Type::Hse, {{"hse_omega",info.hse_omega}}, this->rmesh_times ); break; + abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp_rmesh( this->abfs, Conv_Coulomb_Pot_K::Ccp_Type::Hse, {{"hse_omega",info.hse_omega}}, info.ccp_threshold, this->rmesh_times ); break; default: throw domain_error(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; } @@ -580,7 +580,7 @@ gettimeofday( &t_start, NULL); m_abfs_abfs.init( 2, this->kmesh_times, (1+this->rmesh_times)/2.0 ); ofs_mpi<<"TIME@ m_abfs_abfs.init\t"< Date: Mon, 2 Sep 2019 21:24:24 +0800 Subject: [PATCH 012/233] 1. add Exx_Abfs::Parallel::Distribute::Kmeans::distribute_kmeans1 1.1 src_lcao/exx_abfs-parallel-distribute-kmeans.h 1.2 src_lcao/exx_abfs-parallel-distribute-kmeans.cpp 1.3 src_lcao/exx_lcao.h 1.4 src_lcao/exx_lcao.cpp 1.5 input.cpp 1.6 input_conv.cpp --- ABACUS.1.0.0/source/input.cpp | 4 +- ABACUS.1.0.0/source/input_conv.cpp | 6 +- .../src_external/src_test/test_function.h | 4 +- .../exx_abfs-parallel-distribute-kmeans.cpp | 108 +++++++++++++++--- .../exx_abfs-parallel-distribute-kmeans.h | 6 +- ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 6 +- ABACUS.1.0.0/source/src_lcao/exx_lcao.h | 2 +- 7 files changed, 112 insertions(+), 24 deletions(-) diff --git a/ABACUS.1.0.0/source/input.cpp b/ABACUS.1.0.0/source/input.cpp index 6c51386164..47345c746a 100644 --- a/ABACUS.1.0.0/source/input.cpp +++ b/ABACUS.1.0.0/source/input.cpp @@ -2577,9 +2577,9 @@ void Input::Check(void) { WARNING_QUIT("INPUT","must exx_hybrid_step > 0"); } - if(exx_distribute_type!="htime" && exx_distribute_type!="kmeans") + if(exx_distribute_type!="htime" && exx_distribute_type!="kmeans2" && exx_distribute_type!="kmeans1") { - WARNING_QUIT("INPUT","exx_distribute_type must be htime or kmeans"); + WARNING_QUIT("INPUT","exx_distribute_type must be htime or kmeans2 or kmeans1"); } } if(exx_hybrid_type=="opt_orb") diff --git a/ABACUS.1.0.0/source/input_conv.cpp b/ABACUS.1.0.0/source/input_conv.cpp index aa8f863455..b5301db272 100644 --- a/ABACUS.1.0.0/source/input_conv.cpp +++ b/ABACUS.1.0.0/source/input_conv.cpp @@ -421,8 +421,10 @@ void Input_Conv::Convert(void) exx_lcao.info.ccp_threshold = INPUT.exx_ccp_threshold ; if(INPUT.exx_distribute_type=="htime") exx_lcao.info.distribute_type = Exx_Lcao::Distribute_Type::Htime; - else if(INPUT.exx_distribute_type=="kmeans") - exx_lcao.info.distribute_type = Exx_Lcao::Distribute_Type::Kmeans; + else if(INPUT.exx_distribute_type=="kmeans2") + exx_lcao.info.distribute_type = Exx_Lcao::Distribute_Type::Kmeans2; + else if(INPUT.exx_distribute_type=="kmeans1") + exx_lcao.info.distribute_type = Exx_Lcao::Distribute_Type::Kmeans1; Exx_Abfs::Jle::Lmax = INPUT.exx_opt_orb_lmax; Exx_Abfs::Jle::Ecut_exx = INPUT.exx_opt_orb_ecut; Exx_Abfs::Jle::tolerence = INPUT.exx_opt_orb_tolerence; diff --git a/ABACUS.1.0.0/source/src_external/src_test/test_function.h b/ABACUS.1.0.0/source/src_external/src_test/test_function.h index 2eebd7c09e..a1da45f49c 100644 --- a/ABACUS.1.0.0/source/src_external/src_test/test_function.h +++ b/ABACUS.1.0.0/source/src_external/src_test/test_function.h @@ -28,7 +28,7 @@ template static std::ostream & operator<<( std::ostream & os, const std::vector &v ) { for( const T &i : v ) - os< &v ) template static std::ostream & operator<<( std::ostream & os, const std::pair &p ) { - os< -vector +#include "src_external/src_test/test_function.h" + +pair< vector, vector > Exx_Abfs::Parallel::Distribute::Kmeans::cluster( const int Nc ) { TITLE("Exx_Abfs::Parallel::Distribute::Kmeans::cluster"); @@ -139,14 +141,14 @@ ofs_mpi<> -Exx_Abfs::Parallel::Distribute::Kmeans::distribute( const MPI_Comm & mpi_comm, const int multiple_core ) +Exx_Abfs::Parallel::Distribute::Kmeans::distribute_kmeans2( const MPI_Comm & mpi_comm, const int multiple_core ) { TITLE("Exx_Abfs::Parallel::Distribute::Kmeans::distribute"); @@ -154,10 +156,7 @@ Exx_Abfs::Parallel::Distribute::Kmeans::distribute( const MPI_Comm & mpi_comm, c int comm_size; MPI_Comm_size( mpi_comm, &comm_size ); int my_rank; MPI_Comm_rank( mpi_comm, &my_rank ); const int comm_size_nominal = comm_size * multiple_core; - -//for( int N=2; N<=20; ++N ) -// cluster(N); - + { auto classify_atom = []( const int Ng, const vector &atoms ) -> vector> { @@ -189,7 +188,7 @@ Exx_Abfs::Parallel::Distribute::Kmeans::distribute( const MPI_Comm & mpi_comm, c { vector> rank_work; - const vector atoms = cluster(Ng); + const vector atoms = cluster(Ng).first; const vector> clusters_atoms = classify_atom(Ng,atoms); for( size_t ig1=0, rank_tmp=0; ig1 atoms = cluster(N1); + const vector atoms = cluster(N1).first; return f(atoms,atoms); } else { - const vector atoms1 = cluster(N1); - const vector atoms2 = cluster(N2); + const vector atoms1 = cluster(N1).first; + const vector atoms2 = cluster(N2).first; return f(atoms1,atoms2); } } - - } + + +vector> +Exx_Abfs::Parallel::Distribute::Kmeans::distribute_kmeans1( const MPI_Comm & mpi_comm, const double rmesh_times ) +{ + int comm_size; MPI_Comm_size( mpi_comm, &comm_size ); + int my_rank; MPI_Comm_rank( mpi_comm, &my_rank ); +ofstream ofs_mpi(exx_lcao.test_dir.process+"kmeans_"+TO_STRING(my_rank),ofstream::app); + + auto classify_atom = []( const int Ng, const vector &atoms ) -> vector> + { + vector> clusters_atoms(Ng); + for( size_t iat=0; iat> boxes; + for(const int ix:{-1,0,1}) + for(const int iy:{-1,0,1}) + for(const int iz:{-1,0,1}) + boxes.push_back({ix,iy,iz}); + + const auto atoms_clusters_tmp = Exx_Abfs::Parallel::Distribute::Kmeans::cluster(comm_size); + const vector &atoms = atoms_clusters_tmp.first; + const vector &clusters = atoms_clusters_tmp.second; + const vector> clusters_atoms = classify_atom(comm_size,atoms); + +for(const auto cluster_atoms : clusters_atoms) + ofs_mpi<> rank_work; + for(const size_t iat1 : clusters_atoms[my_rank]) + { + const int it1 = ucell.iat2it[iat1]; + const Vector3 tau1 = ucell.atoms[it1].tau[ucell.iat2ia[iat1]]; + const int ic1 = atoms[iat1].center; + for(size_t iat2=0; iat2!=ucell.nat; ++iat2) + { + const int it2 = ucell.iat2it[iat2]; + const Vector3 tau2 = ucell.atoms[it2].tau[ucell.iat2ia[iat2]]; + const int ic2 = atoms[iat2].center; + + double R_min = std::numeric_limits::max(); + Vector3 tau2_box2_min; + Vector3 box2_min; // test + for(const Vector3 box2 : boxes) + { + const Vector3 tau2_box2 = tau2 + box2 * ucell.latvec; + const double R = (-tau1 + tau2_box2).norm(); + if(R middle = (tau1 + tau2_box2_min)/2.0; + if( (middle-clusters[ic1].tau).norm() < (middle-clusters[ic2].tau).norm() ) + rank_work.push_back({iat1,iat2}); + else if( (middle-clusters[ic1].tau).norm() == (middle-clusters[ic2].tau).norm() ) + if(iat1> distribute( const MPI_Comm & mpi_comm, const int multiple_core=1 ); + static vector> distribute_kmeans2( const MPI_Comm & mpi_comm, const int multiple_core=1 ); + static vector> distribute_kmeans1( const MPI_Comm & mpi_comm, const double rmesh_times ); private: @@ -29,7 +30,8 @@ class Exx_Abfs::Parallel::Distribute::Kmeans double distance; }; - static vector cluster( const int Nc ); + static pair< vector, vector > + cluster( const int Nc ); }; #endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp index d276adb7b3..9b126540c0 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp @@ -682,8 +682,10 @@ gettimeofday( &t_start, NULL); { case Exx_Lcao::Distribute_Type::Htime: atom_pairs_core_origin = Exx_Abfs::Parallel::Distribute::Htime::distribute( Born_von_Karman_period ); break; - case Exx_Lcao::Distribute_Type::Kmeans: - atom_pairs_core_origin = Exx_Abfs::Parallel::Distribute::Kmeans::distribute( MPI_COMM_WORLD ); break; + case Exx_Lcao::Distribute_Type::Kmeans2: + atom_pairs_core_origin = Exx_Abfs::Parallel::Distribute::Kmeans::distribute_kmeans2( MPI_COMM_WORLD ); break; + case Exx_Lcao::Distribute_Type::Kmeans1: + atom_pairs_core_origin = Exx_Abfs::Parallel::Distribute::Kmeans::distribute_kmeans1( MPI_COMM_WORLD, rmesh_times ); break; default: throw domain_error(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; //throw domain_error(TO_STRING(static_cast::type>(info.distribute_type))+"\t"+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.h b/ABACUS.1.0.0/source/src_lcao/exx_lcao.h index a7886e2cd2..8791915ae9 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.h +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.h @@ -45,7 +45,7 @@ class Exx_Lcao void init_radial_table_ions( const set &atom_centres_core, const vector> &atom_pairs_core ); public: - enum class Distribute_Type {Htime,Kmeans}; + enum class Distribute_Type {Htime,Kmeans2,Kmeans1}; public: double get_energy() const { return energy; } From 2b5beaccaba9a101e08f982ab7e2c9fe762af67f Mon Sep 17 00:00:00 2001 From: linpz Date: Mon, 2 Sep 2019 21:31:50 +0800 Subject: [PATCH 013/233] 1. fix bug matrix_wrapper_tianhe2.h Matrix_Wrapper::operator= 1.1 src_global/matrix_wrapper_tianhe2.h --- .../src_global/matrix_wrapper_tianhe2.h | 104 +++++++++--------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/ABACUS.1.0.0/source/src_global/matrix_wrapper_tianhe2.h b/ABACUS.1.0.0/source/src_global/matrix_wrapper_tianhe2.h index 7761b893ac..ccf11728f3 100644 --- a/ABACUS.1.0.0/source/src_global/matrix_wrapper_tianhe2.h +++ b/ABACUS.1.0.0/source/src_global/matrix_wrapper_tianhe2.h @@ -1,52 +1,52 @@ -//========================================================== -// AUTHOR : Peize Lin -// DATE : 2018-07-31 -//========================================================== - -#ifndef MATRIX_WRAPPER_H -#define MATRIX_WRAPPER_H - -#include "src_global/matrix.h" -#include - -// !!! Attention: c is very dangerous, may point to somewhere deleted - -class Matrix_Wrapper -{ -public: - double *c; - int nr; - int nc; - - Matrix_Wrapper(): nr(0), nc(0), c(nullptr){} - Matrix_Wrapper( const matrix &m ): nr(m.nr), nc(m.nc), c(m.c){} - inline void create( const int nr_in, const int nc_in, const bool flag_zero ); - inline matrix to_matrix(); - Matrix_Wrapper( const Matrix_Wrapper &m ): nr(m.nr), nc(m.nc), c(m.c){} - Matrix_Wrapper( Matrix_Wrapper &m ): nr(m.nr), nc(m.nc), c(m.c){} - Matrix_Wrapper( Matrix_Wrapper &&m ): nr(m.nr), nc(m.nc), c(m.c){} - inline Matrix_Wrapper&operator=( const Matrix_Wrapper&m ){ nr=m.nr; nc=m.nc; c=m.c; }; - inline Matrix_Wrapper&operator=( Matrix_Wrapper&m ){ nr=m.nr; nc=m.nc; c=m.c; }; - inline Matrix_Wrapper&operator=( Matrix_Wrapper&&m ){ nr=m.nr; nc=m.nc; c=m.c; }; -}; - - -inline void Matrix_Wrapper::create( const int nr_in, const int nc_in, const bool flag_zero ) -{ - nr = nr_in; nc = nc_in; - c = new double[nr*nc]; - if(flag_zero) - memset( c, 0, sizeof(double)*nr*nc ); -} - -inline matrix Matrix_Wrapper::to_matrix() -{ - matrix m; - m.nr = nr; m.nc = nc; - m.c = c; - nr = nc = 0; - c = nullptr; - return m; -} - -#endif +//========================================================== +// AUTHOR : Peize Lin +// DATE : 2018-07-31 +//========================================================== + +#ifndef MATRIX_WRAPPER_H +#define MATRIX_WRAPPER_H + +#include "src_global/matrix.h" +#include + +// !!! Attention: c is very dangerous, may point to somewhere deleted + +class Matrix_Wrapper +{ +public: + double *c; + int nr; + int nc; + + Matrix_Wrapper(): nr(0), nc(0), c(nullptr){} + Matrix_Wrapper( const matrix &m ): nr(m.nr), nc(m.nc), c(m.c){} + inline void create( const int nr_in, const int nc_in, const bool flag_zero ); + inline matrix to_matrix(); + Matrix_Wrapper( const Matrix_Wrapper &m ): nr(m.nr), nc(m.nc), c(m.c){} + Matrix_Wrapper( Matrix_Wrapper &m ): nr(m.nr), nc(m.nc), c(m.c){} + Matrix_Wrapper( Matrix_Wrapper &&m ): nr(m.nr), nc(m.nc), c(m.c){} + inline Matrix_Wrapper&operator=( const Matrix_Wrapper&m ){ nr=m.nr; nc=m.nc; c=m.c; return *this; }; + inline Matrix_Wrapper&operator=( Matrix_Wrapper&m ){ nr=m.nr; nc=m.nc; c=m.c; return *this; }; + inline Matrix_Wrapper&operator=( Matrix_Wrapper&&m ){ nr=m.nr; nc=m.nc; c=m.c; return *this; }; +}; + + +inline void Matrix_Wrapper::create( const int nr_in, const int nc_in, const bool flag_zero ) +{ + nr = nr_in; nc = nc_in; + c = new double[nr*nc]; + if(flag_zero) + memset( c, 0, sizeof(double)*nr*nc ); +} + +inline matrix Matrix_Wrapper::to_matrix() +{ + matrix m; + m.nr = nr; m.nc = nc; + m.c = c; + nr = nc = 0; + c = nullptr; + return m; +} + +#endif From 1e17c59248e0efc89fc03513f1c889a4187efa0b Mon Sep 17 00:00:00 2001 From: linpz Date: Fri, 6 Sep 2019 18:19:36 +0800 Subject: [PATCH 014/233] 1. add htimes distribution Rcut check 1.1 src_lcao\exx_abfs-parallel-distribute-htime.h 1.2 src_lcao\exx_abfs-parallel-distribute-htime.cpp 1.3 src_lcao\exx_lcao.cpp 2. add radial_R Rcut check 2.1 src_lcao\exx_lcao.cpp 3. fix bug realArrayAlloc handler 3.1 src_global\realarray.cpp 4. fix bug Charge_Mixing::rhog_dot_product switch {} 4.1 src_pw\charge_mixing.cpp --- ABACUS.1.0.0/source/input.cpp | 2 +- ABACUS.1.0.0/source/src_global/realarray.cpp | 8 +-- .../exx_abfs-parallel-distribute-htime.cpp | 35 +++++++++-- .../exx_abfs-parallel-distribute-htime.h | 4 +- .../exx_abfs-parallel-distribute-kmeans.cpp | 61 +++++++++---------- ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 15 +++-- ABACUS.1.0.0/source/src_pw/charge_mixing.cpp | 4 +- 7 files changed, 80 insertions(+), 49 deletions(-) diff --git a/ABACUS.1.0.0/source/input.cpp b/ABACUS.1.0.0/source/input.cpp index 47345c746a..b98d25b45e 100644 --- a/ABACUS.1.0.0/source/input.cpp +++ b/ABACUS.1.0.0/source/input.cpp @@ -2953,7 +2953,7 @@ void Input::Print(const string &fn)const OUTP(ofs,"exx_schwarz_threshold",exx_schwarz_threshold,""); OUTP(ofs,"exx_cauchy_threshold",exx_cauchy_threshold,""); OUTP(ofs,"exx_ccp_threshold",exx_ccp_threshold,""); - OUTP(ofs,"exx_distribute_type",exx_distribute_type,"htime or kmeans"); + OUTP(ofs,"exx_distribute_type",exx_distribute_type,"htime or kmeans1 or kmeans2"); OUTP(ofs,"exx_opt_orb_lmax",exx_opt_orb_lmax,""); OUTP(ofs,"exx_opt_orb_ecut",exx_opt_orb_ecut,""); OUTP(ofs,"exx_opt_orb_tolerence",exx_opt_orb_tolerence,""); diff --git a/ABACUS.1.0.0/source/src_global/realarray.cpp b/ABACUS.1.0.0/source/src_global/realarray.cpp index c7813d59d1..9f9546f3a5 100644 --- a/ABACUS.1.0.0/source/src_global/realarray.cpp +++ b/ABACUS.1.0.0/source/src_global/realarray.cpp @@ -21,11 +21,11 @@ realArray::realArray(const int d1,const int d2,const int d3) bound3 = (d3 <= 0) ? 1 : d3; bound4 = 0; - set_new_handler(realArrayAlloc); - size = bound1 * bound2 * bound3 ; //* sizeof(float); + auto handler_old = set_new_handler(realArrayAlloc); ptr = new double[size]; + set_new_handler(handler_old); zero_out(); assert(ptr != 0); @@ -40,11 +40,11 @@ realArray::realArray(const int d1,const int d2,const int d3,const int d4) bound3 = (d3 <= 0) ? 1 : d3; bound4 = (d4 <= 0) ? 1 : d4; - set_new_handler(realArrayAlloc); - size = bound1 * bound2 * bound3 * bound4 ; //* sizeof(float); + auto handler_old = set_new_handler(realArrayAlloc); ptr = new double[size]; + set_new_handler(handler_old); zero_out(); ++arrayCount; diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-htime.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-htime.cpp index 0fd301f06c..4ebc7193eb 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-htime.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-htime.cpp @@ -4,7 +4,8 @@ #include "src_lcao/abfs.h" #include -vector> Exx_Abfs::Parallel::Distribute::Htime::distribute( const Abfs::Vector3_Order & Born_von_Karman_period ) +vector> Exx_Abfs::Parallel::Distribute::Htime::distribute( + const Abfs::Vector3_Order & Born_von_Karman_period, const double rmesh_times ) { TITLE("Exx_Abfs::Parallel::distribute"); const vector Nadj = cal_Nadj(Born_von_Karman_period); @@ -12,7 +13,7 @@ vector> Exx_Abfs::Parallel::Distribute::Htime::distribute( c //for( const size_t & i : Nadj ) // cout<>> pair_costs = cal_pair_costs(Nadj); + const vector>> pair_costs = cal_pair_costs(Nadj,rmesh_times); //for( const auto & i : pair_costs ) // cout< Exx_Abfs::Parallel::Distribute::Htime::cal_Nadj( const Abfs::Vect } // { Ni*Nj, {i,j} } -vector>> Exx_Abfs::Parallel::Distribute::Htime::cal_pair_costs( const vector &Nadj ) +vector>> Exx_Abfs::Parallel::Distribute::Htime::cal_pair_costs( + const vector &Nadj, const double rmesh_times ) { TITLE("Exx_Abfs::Parallel::cal_pair_costs"); + + vector> boxes; + for(const int ix:{-1,0,1}) + for(const int iy:{-1,0,1}) + for(const int iz:{-1,0,1}) + boxes.push_back({ix,iy,iz}); + + auto neighbour = [&](const size_t iat1, const size_t iat2) -> bool + { + const int it1 = ucell.iat2it[iat1]; + const int it2 = ucell.iat2it[iat2]; + const Vector3 tau1 = ucell.atoms[it1].tau[ucell.iat2ia[iat1]]; + const Vector3 tau2 = ucell.atoms[it2].tau[ucell.iat2ia[iat2]]; + double R_min = std::numeric_limits::max(); + for(const Vector3 box2 : boxes) + { + const double R = (-tau1 + tau2 + box2 * ucell.latvec).norm(); + if(R>> pair_costs; for( size_t iat1=0; iat1> & pair_cost1, diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-htime.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-htime.h index e80b4bcbfb..a66be40fc4 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-htime.h +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-htime.h @@ -11,10 +11,10 @@ class Exx_Abfs::Parallel::Distribute::Htime { public: - static vector> distribute( const Abfs::Vector3_Order & Born_von_Karman_period ); + static vector> distribute( const Abfs::Vector3_Order & Born_von_Karman_period, const double rmesh_times ); private: static vector cal_Nadj( const Abfs::Vector3_Order & Born_von_Karman_period ); - static vector>> cal_pair_costs( const vector &Nadj ); + static vector>> cal_pair_costs( const vector &Nadj, const double rmesh_times ); static vector>> cal_rank_work( const vector>> & pair_costs ); }; diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-kmeans.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-kmeans.cpp index 2bd1250860..29eed00a84 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-kmeans.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-kmeans.cpp @@ -12,21 +12,21 @@ Exx_Abfs::Parallel::Distribute::Kmeans::cluster( const int Nc ) vector clusters(Nc+1); // clusters[Nc] just for atoms init vector atoms(ucell.nat); -ofstream ofs_mpi(exx_lcao.test_dir.process+"kmeans_"+TO_STRING(Nc)+"_"+TO_STRING(MY_RANK),ofstream::app); +//ofstream ofs_mpi(exx_lcao.test_dir.process+"kmeans_"+TO_STRING(Nc)+"_"+TO_STRING(MY_RANK),ofstream::app); auto init = [&]() -> void { -ofs_mpi< flag_is_center(Nx*Ny*Nz,true); for( int ic_big=Nc/2; ic_big taud_max = {0,0,0}, taud_min = {1,1,1}; @@ -58,7 +58,7 @@ ofs_mpi<::max(); } -for( int ic=0; ic(cluster.size); -for( int ic=0; ic &atoms ) -> vector> { @@ -275,8 +275,8 @@ ofstream ofs_mpi(exx_lcao.test_dir.process+"kmeans_"+TO_STRING(my_rank),ofstream const vector &clusters = atoms_clusters_tmp.second; const vector> clusters_atoms = classify_atom(comm_size,atoms); -for(const auto cluster_atoms : clusters_atoms) - ofs_mpi<> rank_work; for(const size_t iat1 : clusters_atoms[my_rank]) @@ -298,7 +298,6 @@ for(const auto cluster_atoms : clusters_atoms) const Vector3 tau2_box2 = tau2 + box2 * ucell.latvec; const double R = (-tau1 + tau2_box2).norm(); if(Rinfo.distribute_type) { case Exx_Lcao::Distribute_Type::Htime: - atom_pairs_core_origin = Exx_Abfs::Parallel::Distribute::Htime::distribute( Born_von_Karman_period ); break; + atom_pairs_core_origin = Exx_Abfs::Parallel::Distribute::Htime::distribute( Born_von_Karman_period, rmesh_times ); break; case Exx_Lcao::Distribute_Type::Kmeans2: atom_pairs_core_origin = Exx_Abfs::Parallel::Distribute::Kmeans::distribute_kmeans2( MPI_COMM_WORLD ); break; case Exx_Lcao::Distribute_Type::Kmeans1: @@ -1046,9 +1046,10 @@ gettimeofday( &t_start, NULL); energy *= 2.0/NSPIN; // ? energy /= 2; // /2 for Ry -ofs_mpi<<"TIME@ Exx_Lcao::cal_energy_cal\t"< Date: Sun, 8 Sep 2019 05:18:42 +0800 Subject: [PATCH 015/233] 1. add schwarz DP 1.1 src_lcao/exx_abfs-screen-schwarz.h 1.2 src_lcao/exx_abfs-screen-schwarz.cpp --- .../exx_abfs-inverse_matrix_double.cpp | 6 - .../src_lcao/exx_abfs-matrix_orbs21.cpp | 4 - .../src_lcao/exx_abfs-screen-schwarz.cpp | 117 ++++++------------ .../source/src_lcao/exx_abfs-screen-schwarz.h | 16 +-- 4 files changed, 36 insertions(+), 107 deletions(-) diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-inverse_matrix_double.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-inverse_matrix_double.cpp index a67a24bbce..b5e1d0a4bf 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-inverse_matrix_double.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-inverse_matrix_double.cpp @@ -15,8 +15,6 @@ void Exx_Abfs::Inverse_Matrix_Double::init(const int &dim_in) void Exx_Abfs::Inverse_Matrix_Double::cal_inverse( const Method &method ) { - TITLE("Exx_Abfs::Inverse_Matrix_Double::cal_inverse"); - #if TEST_EXX_LCAO==1 static int i=0; ofstream ofs("inverse_matrix_"+TO_STRING(i)); @@ -36,8 +34,6 @@ void Exx_Abfs::Inverse_Matrix_Double::cal_inverse( const Method &method ) void Exx_Abfs::Inverse_Matrix_Double::using_dpotrf() { - TITLE("Exx_Abfs::Inverse_Matrix_Double::using_dpotrf"); - LapackConnector::dpotrf('U',dim,A,dim,&info); if(info!=0) @@ -61,8 +57,6 @@ void Exx_Abfs::Inverse_Matrix_Double::using_dpotrf() void Exx_Abfs::Inverse_Matrix_Double::using_dsyev( const double &threshold_condition_number ) { - TITLE("Exx_Abfs::Inverse_Matrix_Double::using_dsyev"); - vector eigen_value(A.nr); LapackConnector::dsyev('V','U',A,VECTOR_TO_PTR(eigen_value),info); diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs21.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs21.cpp index 4d69b1d944..3585957650 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs21.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs21.cpp @@ -264,8 +264,6 @@ matrix Exx_Abfs::Matrix_Orbs21::cal_overlap_matrix( const Element_Basis_Index::IndexLNM &index_B, const Matrix_Order &matrix_order) const { - TITLE("Exx_Abfs::Matrix_Orbs21","cal_overlap_matrix"); - matrix m; switch(matrix_order) { @@ -341,8 +339,6 @@ vector Exx_Abfs::Matrix_Orbs21::cal_overlap_matrix( const Element_Basis_Index::IndexLNM &index_A2, const Element_Basis_Index::IndexLNM &index_B) const { - TITLE("Exx_Abfs::Matrix_Orbs21","cal_overlap_matrix"); - matrix m_A2B_A1( index_A2[TA].count_size*index_B[TB].count_size, index_A1[TA].count_size ); matrix m_BA2_A1( index_B[TB].count_size*index_A2[TA].count_size, index_A1[TA].count_size ); diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.cpp index bee0f7b473..b0cca7d26a 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.cpp @@ -33,59 +33,11 @@ void Exx_Abfs::Screen::Schwarz::cal_max_pair_fock( if(!flag_screen_schwarz) return; TITLE("Exx_Abfs::Screen::Schwarz::cal_max_pair_fock"); - const vector>>> adjs = Abfs::get_adjs(); - const vector atom_centers_v( atom_centres.begin(), atom_centres.end() ); - // pre-cal Vws on same atom, speed up DPcal_V() vector> Vs_same_atom(ucell.ntype); for(size_t it=0; it!=ucell.ntype; ++it) Vs_same_atom[it] = Abfs::DPcal_V( it,it,{0,0,0}, m_abfs_abfs, index_abfs, 0,true,Vws ); - const int mkl_threads = mkl_get_max_threads(); - mkl_set_num_threads(1); - - atomic i_atom_centre = 0; - atomic_flag lock_max_pair_fock = ATOMIC_FLAG_INIT; - - vector ts; - for( int it=0; it &atom_centres, - const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, - const Exx_Abfs::Matrix_Orbs21 &m_abfslcaos_lcaos, - const Element_Basis_Index::IndexLNM &index_abfs, - const Element_Basis_Index::IndexLNM &index_lcaos, - const Abfs::Vector3_Order &Born_von_Karman_period, - map,weak_ptr>>> &Cws, - map,weak_ptr>>> &Vws, - const vector>>> &adjs, - atomic &i_atom_centre, - atomic_flag &lock_max_pair_fock) -{ - TITLE("Exx_Abfs::Screen::Schwarz::cal_max_pair_fock_thread"); - // m_out( i1, i2, i3 ) = m_in( i2, i1, i3 ) auto change_matrix_order =[]( const matrix &m_in, const size_t n1 ) -> matrix { @@ -123,20 +75,15 @@ void Exx_Abfs::Screen::Schwarz::cal_max_pair_fock_thread( LapackConnector::gemm( 'N','T', m1.nr,m2.nr,m1.nc, 1, m1.c,m1.nc, m2.c,m2.nc, 0, mm.c,mm.nc ); return mm; }; - - while(true) - { - const size_t i_atom_centre_now = i_atom_centre++; - if( i_atom_centre_now >= atom_centres.size() ) return; - - map,double>> max_pair_fock_thread; - - const size_t iat1 = atom_centres[i_atom_centre_now]; + + map,double>>> max_pair_fock_DP; + for(const size_t iat1 : atom_centres) + { const size_t it1 = ucell.iat2it[iat1]; const size_t ia1 = ucell.iat2ia[iat1]; const Abfs::Vector3_Order tau1( ucell.atoms[it1].tau[ia1] ); - const map>> adj = adjs[iat1]; + const map>> adj = Abfs::get_adjs(iat1); for( const auto & atom2 : adj ) { const int iat2 = atom2.first; @@ -145,40 +92,46 @@ void Exx_Abfs::Screen::Schwarz::cal_max_pair_fock_thread( const Abfs::Vector3_Order tau2( ucell.atoms[it2].tau[ia2] ); map,shared_ptr> pair_fock_s; - for( const Vector3 &box2 : atom2.second ) + for( const Abfs::Vector3_Order &box2 : atom2.second ) { - const Abfs::Vector3_Order R = -tau1+(tau2+box2*ucell.latvec); - - const matrix C_12 = *Abfs::DPcal_C( it1,it2,R, m_abfs_abfs,m_abfslcaos_lcaos, index_abfs,index_lcaos, 0,false,Cws,Vws ); - const matrix C_21 = change_matrix_order( - *Abfs::DPcal_C( it2,it1,-R, m_abfs_abfs,m_abfslcaos_lcaos, index_abfs,index_lcaos, 0,false,Cws,Vws ), - index_lcaos[it1].count_size); - - const matrix V_11 = *Abfs::DPcal_V(it1,it1,{0,0,0},m_abfs_abfs,index_abfs,0,false,Vws); - const matrix V_12 = *Abfs::DPcal_V(it1,it2,R, m_abfs_abfs,index_abfs,0,false,Vws); - const matrix V_21 = *Abfs::DPcal_V(it2,it1,-R, m_abfs_abfs,index_abfs,0,false,Vws); - const matrix V_22 = *Abfs::DPcal_V(it2,it2,{0,0,0},m_abfs_abfs,index_abfs,0,false,Vws); - - pair_fock_s[box2] = make_shared( - m_mT( C_12 * V_11, C_12 ) - + m_mT( C_12 * V_12, C_21 ) - + m_mT( C_21 * V_21, C_12 ) - + m_mT( C_21 * V_22, C_21 )); + const Abfs::Vector3_Order box2p = box2%Born_von_Karman_period; + if(const double*max_pair_fock_ptr=static_cast(MAP_EXIST(max_pair_fock_DP,it1,it2,-tau1+tau2+box2p*ucell.latvec))) + max_pair_fock[iat1][iat2][box2p] = *max_pair_fock_ptr; + else + { + const Abfs::Vector3_Order R = -tau1+tau2+box2*ucell.latvec; + const matrix C_12 = *Abfs::DPcal_C( it1,it2,R, m_abfs_abfs,m_abfslcaos_lcaos, index_abfs,index_lcaos, 0,false,Cws,Vws ); + const matrix C_21 = change_matrix_order( + *Abfs::DPcal_C( it2,it1,-R, m_abfs_abfs,m_abfslcaos_lcaos, index_abfs,index_lcaos, 0,false,Cws,Vws ), + index_lcaos[it1].count_size); + + const matrix V_11 = *Abfs::DPcal_V(it1,it1,{0,0,0},m_abfs_abfs,index_abfs,0,false,Vws); + const matrix V_12 = *Abfs::DPcal_V(it1,it2,R, m_abfs_abfs,index_abfs,0,false,Vws); + const matrix V_21 = *Abfs::DPcal_V(it2,it1,-R, m_abfs_abfs,index_abfs,0,false,Vws); + const matrix V_22 = *Abfs::DPcal_V(it2,it2,{0,0,0},m_abfs_abfs,index_abfs,0,false,Vws); + + pair_fock_s[box2] = make_shared( + m_mT( C_12 * V_11, C_12 ) + + m_mT( C_12 * V_12, C_21 ) + + m_mT( C_21 * V_21, C_12 ) + + m_mT( C_21 * V_22, C_21 )); + } } const map,shared_ptr> pair_fock_ps = Abfs::cal_mps( Born_von_Karman_period, pair_fock_s ); for( const auto & pair_fock_p : pair_fock_ps ) { - const Abfs::Vector3_Order & box2 = pair_fock_p.first; - max_pair_fock_thread[iat2][box2] = max_diagnal(*pair_fock_p.second); + const Abfs::Vector3_Order & box2p = pair_fock_p.first; + max_pair_fock[iat1][iat2][box2p] = max_pair_fock_DP[it1][it2][-tau1+tau2+box2p*ucell.latvec] = max_diagnal(*pair_fock_p.second); } } - - while( lock_max_pair_fock.test_and_set() ); - max_pair_fock[iat1] = std::move(max_pair_fock_thread); - lock_max_pair_fock.clear(); } + + Vs_same_atom.clear(); + Abfs::delete_empty_ptrs( Vws ); + +//test_screen("schwarz-max_pair_fock.dat",max_pair_fock); } bool Exx_Abfs::Screen::Schwarz::screen( diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.h index 3e1d4ad297..948a72d337 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.h +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.h @@ -27,21 +27,7 @@ class Exx_Abfs::Screen::Schwarz bool screen( const size_t iat1, const size_t iat2, const size_t iat3, const size_t iat4, const Abfs::Vector3_Order & box3, const Abfs::Vector3_Order & box4 ) const; - -private: - void cal_max_pair_fock_thread( - const vector &atom_centres, - const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, - const Exx_Abfs::Matrix_Orbs21 &m_abfslcaos_lcaos, - const Element_Basis_Index::IndexLNM &index_abfs, - const Element_Basis_Index::IndexLNM &index_lcaos, - const Abfs::Vector3_Order &Born_von_Karman_period, - map,weak_ptr>>> &Cws, - map,weak_ptr>>> &Vws, - const vector>>> &adjs, - atomic &i_atom_centre, - atomic_flag &lock_max_pair_fock); - + private: bool flag_screen_schwarz = false; double threshold = 0; From 91a9c56eb3eebb7721fc220e3a2863ff6f619fa5 Mon Sep 17 00:00:00 2001 From: linpz Date: Sun, 8 Sep 2019 18:36:57 +0800 Subject: [PATCH 016/233] 1. update Vector3 normalize and reverse return 1.1 src_global/vector3.h 2. add auto cal Coulomb_potential_boxes 2.1 src_lcao/abfs.h 2.2 src_lcao/abfs.cpp 2.3 src_lcao/exx_lcao.h 2.4 src_lcao/exx_lcao.cpp 2.5 src_lcao/exx_abfs-parallel-distribute-htime.cpp 3. fix omit ucell.lat0 bug 3.1 src_lcao/abfs.cpp 3.2 src_lcao/exx_abfs-parallel-distribute-htime.cpp 3.3 src_lcao/exx_abfs-parallel-distribute-kmeans.cpp 3.4 src_lcao/exx_lcao.cpp 4. update htime box2 4.1 src_lcao/exx_abfs-parallel-distribute-htime.cpp 5. fix bug 5.1 input.cpp 5.2 src_lcao/exx_abfs-parallel-distribute-kmeans.cpp 5.3 src_lcao/center2_orb-orb22_ccp.h 5.4 src_lcao/exx_abfs-matrix_orbs11.cpp 5.5 src_lcao/exx_abfs-matrix_orbs21.cpp --- ABACUS.1.0.0/source/input.cpp | 1 + ABACUS.1.0.0/source/src_global/vector3.h | 4 +- ABACUS.1.0.0/source/src_lcao/abfs.cpp | 31 +++++-- ABACUS.1.0.0/source/src_lcao/abfs.h | 2 +- .../source/src_lcao/center2_orb-orb22_ccp.h | 2 +- .../src_lcao/exx_abfs-matrix_orbs11.cpp | 72 ++++++++-------- .../src_lcao/exx_abfs-matrix_orbs21.cpp | 82 +++++++++---------- .../exx_abfs-parallel-distribute-htime.cpp | 61 +++++++------- .../exx_abfs-parallel-distribute-htime.h | 14 +++- .../exx_abfs-parallel-distribute-kmeans.cpp | 34 +++++--- ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 15 ++-- ABACUS.1.0.0/source/src_lcao/exx_lcao.h | 1 - 12 files changed, 172 insertions(+), 147 deletions(-) diff --git a/ABACUS.1.0.0/source/input.cpp b/ABACUS.1.0.0/source/input.cpp index b98d25b45e..f3cde6df11 100644 --- a/ABACUS.1.0.0/source/input.cpp +++ b/ABACUS.1.0.0/source/input.cpp @@ -1958,6 +1958,7 @@ void Input::Bcast() Parallel_Common::bcast_double( exx_dm_threshold ); Parallel_Common::bcast_double( exx_schwarz_threshold ); Parallel_Common::bcast_double( exx_cauchy_threshold ); + Parallel_Common::bcast_double( exx_ccp_threshold ); Parallel_Common::bcast_string( exx_distribute_type ); Parallel_Common::bcast_int( exx_opt_orb_lmax ); Parallel_Common::bcast_double( exx_opt_orb_ecut ); diff --git a/ABACUS.1.0.0/source/src_global/vector3.h b/ABACUS.1.0.0/source/src_global/vector3.h index 12ff05c951..a80c3d03b7 100644 --- a/ABACUS.1.0.0/source/src_global/vector3.h +++ b/ABACUS.1.0.0/source/src_global/vector3.h @@ -36,8 +36,8 @@ class Vector3 T norm2(void) const { return x*x + y*y + z*z; } T norm(void) const { return sqrt(norm2()); } - void normalize(void){ const T m=norm(); x/=m; y/=m; z/=m; } - void reverse(void) { x=-x; y=-y; z=-z; } + Vector3& normalize(void){ const T m=norm(); x/=m; y/=m; z/=m; return *this; } // Peize Lin update return 2019-09-08 + Vector3& reverse(void){ x=-x; y=-y; z=-z; return *this; } // Peize Lin update return 2019-09-08 void print(void)const ; // mohan add 2009-11-29 }; diff --git a/ABACUS.1.0.0/source/src_lcao/abfs.cpp b/ABACUS.1.0.0/source/src_lcao/abfs.cpp index 0a081ff981..20b61eb5dc 100644 --- a/ABACUS.1.0.0/source/src_lcao/abfs.cpp +++ b/ABACUS.1.0.0/source/src_lcao/abfs.cpp @@ -145,7 +145,6 @@ cout<<"cal_Vs\t"<,shared_ptr>>> Abfs::cal_Vs( const vector> &atom_pairs, - const vector> &Coulomb_potential_boxes, const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, const Element_Basis_Index::IndexLNM &index_abfs, const double rmesh_times, @@ -153,6 +152,7 @@ map,shared_ptr>>> Abfs::c map,weak_ptr>>> &Vws ) { TITLE("Abfs","cal_Vs"); + vector> Coulomb_potential_boxes = get_Coulomb_potential_boxes(rmesh_times); map,shared_ptr>>> Vs; for( const pair & atom_pair : atom_pairs ) { @@ -164,18 +164,19 @@ map,shared_ptr>>> Abfs::c const size_t ia2 = ucell.iat2ia[iat2]; const Vector3_Order tau1 = ucell.atoms[it1].tau[ia1]; const Vector3_Order tau2 = ucell.atoms[it2].tau[ia2]; + const double Rcut = std::min( ORB.Phi[it1].getRcut()*rmesh_times+ORB.Phi[it2].getRcut(), ORB.Phi[it1].getRcut()+ORB.Phi[it2].getRcut()*rmesh_times ); for( const Vector3_Order &box2 : Coulomb_potential_boxes ) { const Vector3_Order delta_R = -tau1+tau2+(box2*ucell.latvec); - if( delta_R.norm()*ucell.lat0 > ORB.Phi[it1].getRcut()*rmesh_times + ORB.Phi[it2].getRcut() ) - continue; + if( delta_R.norm()*ucell.lat0 < Rcut ) + { //cout<<"cal_Vs\t"<> Abfs::get_H_pairs_core( const vector> Abfs::get_Coulomb_potential_boxes( const double rmesh_times ) +{ + vector> Coulomb_potential_boxes; + const double Rcut = ORB.get_Rmax() * rmesh_times; + const int nx = std::ceil(Rcut/std::abs((ucell.a2^ucell.a3).normalize()*ucell.a1*ucell.lat0)); + const int ny = std::ceil(Rcut/std::abs((ucell.a1^ucell.a3).normalize()*ucell.a2*ucell.lat0)); + const int nz = std::ceil(Rcut/std::abs((ucell.a1^ucell.a2).normalize()*ucell.a3*ucell.lat0)); + for(int x=-nx; x<=nx; ++x) + for(int y=-ny; y<=ny; ++y) + for(int z=-nz; z<=nz; ++z) + Coulomb_potential_boxes.push_back({x,y,z}); + return Coulomb_potential_boxes; +} + shared_ptr Abfs::cal_I( const shared_ptr &m ) { // TITLE("Abfs","cal_I1"); diff --git a/ABACUS.1.0.0/source/src_lcao/abfs.h b/ABACUS.1.0.0/source/src_lcao/abfs.h index cee26a639a..f8758c72f3 100644 --- a/ABACUS.1.0.0/source/src_lcao/abfs.h +++ b/ABACUS.1.0.0/source/src_lcao/abfs.h @@ -33,7 +33,6 @@ class Abfs // Vws[it1,0][it2,R] static map,shared_ptr>>> cal_Vs( const vector> &atom_pairs, - const vector> &Coulomb_potential_boxes, const Exx_Abfs::Matrix_Orbs11 &m_abfs_abfs, const Element_Basis_Index::IndexLNM &index_abfs, const double rmesh_times, @@ -80,6 +79,7 @@ class Abfs static map>> get_adjs( const size_t &iat ); static vector>>> get_adjs(); static set> get_H_pairs_core( const vector> &atom_pairs ); + static vector> get_Coulomb_potential_boxes( const double rmesh_times ); static shared_ptr cal_I( const shared_ptr &m ); static vector>> cal_I( const vector>> &ms ); diff --git a/ABACUS.1.0.0/source/src_lcao/center2_orb-orb22_ccp.h b/ABACUS.1.0.0/source/src_lcao/center2_orb-orb22_ccp.h index f083a5031c..51a0fcd96d 100644 --- a/ABACUS.1.0.0/source/src_lcao/center2_orb-orb22_ccp.h +++ b/ABACUS.1.0.0/source/src_lcao/center2_orb-orb22_ccp.h @@ -17,7 +17,7 @@ class Center2_Orb::Orb22_Ccp: public Center2_Orb::Orb22 : Orb22( nA1_in, nA2_in, nB1_in, nB2_in, MOT_in, MGT_in ){} void init_radial_table(); - Orb22_Ccp &set_rmesh_times( double rmesh_times_in ){ rmesh_times = rmesh_times; return *this; } + Orb22_Ccp &set_rmesh_times( double rmesh_times_in ){ rmesh_times = rmesh_times_in; return *this; } private: double rmesh_times = 1.0; }; diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs11.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs11.cpp index d68d4641a1..da4e38629e 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs11.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs11.cpp @@ -22,9 +22,9 @@ void Exx_Abfs::Matrix_Orbs11::init( // (1) MOT: make overlap table. //========================================= -ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); -timeval t_start; -gettimeofday( &t_start, NULL); +//ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +//timeval t_start; +//gettimeofday( &t_start, NULL); MOT.allocate( ORB.get_ntype(), // number of atom types std::max( ORB.get_lmax(), Exx_Abfs::Lmax ), // max L used to calculate overlap @@ -33,39 +33,39 @@ gettimeofday( &t_start, NULL); ORB.get_dR(), // delta R, for making radial table // ORB.get_dk() / kmesh_times); // delta k, for integration in k space ORB.get_dk()); // Peize Lin change 2017-04-16 -ofs<<"TIME@Exx_Abfs::Matrix_Orbs11::init::MOT.allocate\t"<>> &orb_A, const vector>> &orb_B) { -ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); -timeval t_start; -gettimeofday( &t_start, NULL); +//ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +//timeval t_start; +//gettimeofday( &t_start, NULL); TITLE("Exx_Abfs::Matrix_Orbs11","init_radial"); for( size_t TA = 0; TA!=orb_A.size(); ++TA ) for( size_t TB=0; TB!=orb_B.size(); ++TB ) @@ -78,17 +78,17 @@ gettimeofday( &t_start, NULL); orb_A[TA][LA][NA], orb_B[TB][LB][NB], MOT, MGT))); -ofs<<"TIME@Exx_Abfs::Matrix_Orbs11::init_radial\t"<>> &Rs ) { -ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); -timeval t_start; -gettimeofday( &t_start, NULL); +//ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +//timeval t_start; +//gettimeofday( &t_start, NULL); TITLE("Exx_Abfs::Matrix_Orbs11","init_radial_table_Rs"); for( const auto &RsA : Rs ) for( const auto &RsB : RsA.second ) @@ -134,8 +134,8 @@ gettimeofday( &t_start, NULL); if( auto* const center2_orb11_sAB = static_cast>>>*const>( MAP_EXIST(center2_orb11_s, RsA.first, RsB.first)) ) { -timeval t_small; -gettimeofday(&t_small, NULL); +//timeval t_small; +//gettimeofday(&t_small, NULL); set radials; for( const double &R : RsB.second ) { @@ -144,18 +144,18 @@ gettimeofday(&t_small, NULL); for( size_t i=0; i!=4; ++i ) radials.insert(iq+i); } -ofs<<"\t"<>> &orb_A2, const vector>> &orb_B ) { -ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); -timeval t_start; -gettimeofday( &t_start, NULL); +//ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +//timeval t_start; +//gettimeofday( &t_start, NULL); TITLE("Exx_Abfs::Matrix_Orbs21","init_radial"); @@ -87,8 +87,8 @@ gettimeofday( &t_start, NULL); orb_A2[TA][LA2][NA2], orb_B[TB][LB][NB], MOT, MGT))); -ofs<<"TIME@Exx_Abfs::Matrix_Orbs21::init_radial\t"<>> &Rs ) { -ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); -timeval t_start; -gettimeofday(&t_start, NULL); +//ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +//timeval t_start; +//gettimeofday(&t_start, NULL); TITLE("Exx_Abfs::Matrix_Orbs21","init_radial_table_Rs"); @@ -158,8 +158,8 @@ gettimeofday(&t_start, NULL); if( auto* const center2_orb21_sAB = static_cast>>>>>*const>( MAP_EXIST(center2_orb21_s, RsA.first, RsB.first)) ) { -timeval t_small; -gettimeofday(&t_small, NULL); +//timeval t_small; +//gettimeofday(&t_small, NULL); set radials; for( const double &R : RsB.second ) { @@ -168,8 +168,8 @@ gettimeofday(&t_small, NULL); for( size_t i=0; i!=4; ++i ) radials.insert(iq+i); } -ofs<<"\t"<>>>> Exx_Abfs::Matrix_ const Element_Basis_Index::IndexLNM &index_A2, const Element_Basis_Index::IndexLNM &index_B) const { -ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); -timeval t_start; -gettimeofday( &t_start, NULL); +//ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +//timeval t_start; +//gettimeofday( &t_start, NULL); TITLE("Exx_Abfs::Matrix_Orbs21","cal_overlap_matrix"); @@ -517,8 +517,8 @@ gettimeofday( &t_start, NULL); matrixes[T][I][T][I].resize(1); } } -ofs<<"TIME@Exx_Abfs::Matrix_Orbs21::cal_overlap_matrix\t"< vector> Exx_Abfs::Parallel::Distribute::Htime::distribute( - const Abfs::Vector3_Order & Born_von_Karman_period, const double rmesh_times ) + const Abfs::Vector3_Order & Born_von_Karman_period, + const double rmesh_times ) { +//ofstream ofs("htime_"+TO_STRING(MY_RANK)); +//ofs< Nadj = cal_Nadj(Born_von_Karman_period); +//ofs<>> pair_costs = cal_pair_costs(Nadj,rmesh_times); - -//for( const auto & i : pair_costs ) -// cout<>> pair_costs = cal_pair_costs(Nadj, rmesh_times); +//ofs<>> rank_work = cal_rank_work(pair_costs); - //for( size_t irank=0; irank!=rank_work.size(); ++irank ) -//{ -// cout< Exx_Abfs::Parallel::Distribute::Htime::cal_Nadj( const Abfs::Vector3_Order & Born_von_Karman_period ) +vector Exx_Abfs::Parallel::Distribute::Htime::cal_Nadj( + const Abfs::Vector3_Order & Born_von_Karman_period ) { TITLE("Exx_Abfs::Parallel::cal_Nadj"); vector Nadj(ucell.nat); @@ -52,38 +49,37 @@ vector Exx_Abfs::Parallel::Distribute::Htime::cal_Nadj( const Abfs::Vect // { Ni*Nj, {i,j} } vector>> Exx_Abfs::Parallel::Distribute::Htime::cal_pair_costs( - const vector &Nadj, const double rmesh_times ) + const vector &Nadj, + const double rmesh_times ) { TITLE("Exx_Abfs::Parallel::cal_pair_costs"); - - vector> boxes; - for(const int ix:{-1,0,1}) - for(const int iy:{-1,0,1}) - for(const int iz:{-1,0,1}) - boxes.push_back({ix,iy,iz}); - auto neighbour = [&](const size_t iat1, const size_t iat2) -> bool + const vector> Coulomb_potential_boxes = Abfs::get_Coulomb_potential_boxes(rmesh_times); + auto neighbour = [&](const size_t iat1, const size_t iat2) -> int { const int it1 = ucell.iat2it[iat1]; const int it2 = ucell.iat2it[iat2]; const Vector3 tau1 = ucell.atoms[it1].tau[ucell.iat2ia[iat1]]; const Vector3 tau2 = ucell.atoms[it2].tau[ucell.iat2ia[iat2]]; - double R_min = std::numeric_limits::max(); - for(const Vector3 box2 : boxes) + const double Rcut = std::min( ORB.Phi[it1].getRcut()*rmesh_times+ORB.Phi[it2].getRcut(), ORB.Phi[it1].getRcut()+ORB.Phi[it2].getRcut()*rmesh_times ); + int Nadj_box = 0; + for(const Vector3 box2 : Coulomb_potential_boxes) { const double R = (-tau1 + tau2 + box2 * ucell.latvec).norm(); - if(R>> pair_costs; for( size_t iat1=0; iat1> & pair_cost1, @@ -93,7 +89,8 @@ vector>> Exx_Abfs::Parallel::Distribute::Htime:: return pair_costs; } -vector>> Exx_Abfs::Parallel::Distribute::Htime::cal_rank_work( const vector>> & pair_costs ) +vector>> Exx_Abfs::Parallel::Distribute::Htime::cal_rank_work( + const vector>> & pair_costs ) { TITLE("Exx_Abfs::Parallel::cal_rank_work"); vector> rank_cost(NPROC); // rank_cost[i] = { irank, cost } diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-htime.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-htime.h index a66be40fc4..8ef727a77b 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-htime.h +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-htime.h @@ -11,11 +11,17 @@ class Exx_Abfs::Parallel::Distribute::Htime { public: - static vector> distribute( const Abfs::Vector3_Order & Born_von_Karman_period, const double rmesh_times ); + static vector> distribute( + const Abfs::Vector3_Order & Born_von_Karman_period, + const double rmesh_times ); private: - static vector cal_Nadj( const Abfs::Vector3_Order & Born_von_Karman_period ); - static vector>> cal_pair_costs( const vector &Nadj, const double rmesh_times ); - static vector>> cal_rank_work( const vector>> & pair_costs ); + static vector cal_Nadj( + const Abfs::Vector3_Order & Born_von_Karman_period ); + static vector>> cal_pair_costs( + const vector &Nadj, + const double rmesh_times ); + static vector>> cal_rank_work( + const vector>> & pair_costs ); }; #endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-kmeans.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-kmeans.cpp index 29eed00a84..5c99e689d4 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-kmeans.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-kmeans.cpp @@ -255,7 +255,7 @@ Exx_Abfs::Parallel::Distribute::Kmeans::distribute_kmeans1( const MPI_Comm & mpi { int comm_size; MPI_Comm_size( mpi_comm, &comm_size ); int my_rank; MPI_Comm_rank( mpi_comm, &my_rank ); -//ofstream ofs_mpi(exx_lcao.test_dir.process+"kmeans_"+TO_STRING(my_rank),ofstream::app); +ofstream ofs_mpi(exx_lcao.test_dir.process+"kmeans_"+TO_STRING(my_rank),ofstream::app); auto classify_atom = []( const int Ng, const vector &atoms ) -> vector> { @@ -275,8 +275,10 @@ Exx_Abfs::Parallel::Distribute::Kmeans::distribute_kmeans1( const MPI_Comm & mpi const vector &clusters = atoms_clusters_tmp.second; const vector> clusters_atoms = classify_atom(comm_size,atoms); -//for(const auto cluster_atoms : clusters_atoms) -// ofs_mpi<> rank_work; for(const size_t iat1 : clusters_atoms[my_rank]) @@ -296,7 +298,7 @@ Exx_Abfs::Parallel::Distribute::Kmeans::distribute_kmeans1( const MPI_Comm & mpi for(const Vector3 box2 : boxes) { const Vector3 tau2_box2 = tau2 + box2 * ucell.latvec; - const double R = (-tau1 + tau2_box2).norm(); + const double R = (-tau1+tau2_box2).norm(); if(R middle = (tau1 + tau2_box2_min)/2.0; - if( (middle-clusters[ic1].tau).norm() < (middle-clusters[ic2].tau).norm() ) + if( (middle-clusters[ic1].tau).norm() < (middle-clusters[ic2].tau-box2_min*ucell.latvec).norm() - epsilon ) + { rank_work.push_back({iat1,iat2}); - else if( (middle-clusters[ic1].tau).norm() == (middle-clusters[ic2].tau).norm() ) + } + else if( std::abs( (middle-clusters[ic1].tau).norm() - (middle-clusters[ic2].tau-box2_min*ucell.latvec).norm() )<=epsilon ) + { if(iat1{kv.nmp[0],kv.nmp[1],kv.nmp[2]}; ofs_mpi<<"TIME@ Exx_Lcao::init\t"< atom_centres_core = cal_atom_centres_core(atom_pairs_core); +ofs_mpi<<"atom_centres_core\t"<> Coulomb_potential_boxes = Abfs::get_Coulomb_potential_boxes(rmesh_times); for( const pair & atom_pair : atom_pairs_core ) { const size_t iat1 = atom_pair.first; @@ -1176,6 +1173,7 @@ gettimeofday( &t_start, NULL); const size_t ia2 = ucell.iat2ia[iat2]; const Vector3 &tau1 = ucell.atoms[it1].tau[ia1]; const Vector3 &tau2 = ucell.atoms[it2].tau[ia2]; + const double Rcut = std::min( ORB.Phi[it1].getRcut()*rmesh_times+ORB.Phi[it2].getRcut(), ORB.Phi[it1].getRcut()+ORB.Phi[it2].getRcut()*rmesh_times ); for( const Vector3 &box2 : Coulomb_potential_boxes ) { @@ -1187,8 +1185,7 @@ gettimeofday( &t_start, NULL); #error "TEST_EXX_LCAO" #endif - if( delta_R*ucell.lat0 < ORB.Phi[it1].getRcut()*rmesh_times + ORB.Phi[it2].getRcut() && - delta_R*ucell.lat0 < ORB.Phi[it1].getRcut() + ORB.Phi[it2].getRcut()*rmesh_times ) + if( delta_R*ucell.lat0 < Rcut ) { radial_R[it1][it2].insert( delta_R ); radial_R[it2][it1].insert( delta_R ); diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.h b/ABACUS.1.0.0/source/src_lcao/exx_lcao.h index 8791915ae9..f462c4ce70 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.h +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.h @@ -82,7 +82,6 @@ class Exx_Lcao vector> atom_pairs_core_origin; vector> atom_pairs_core; set> H_atom_pairs_core; - vector> Coulomb_potential_boxes; Abfs::Vector3_Order Born_von_Karman_period; Exx_Abfs::Screen::Schwarz schwarz; From 175159321509b64be500e60e3ddc105c233b6c72 Mon Sep 17 00:00:00 2001 From: linpz Date: Sat, 26 Oct 2019 23:22:09 +0800 Subject: [PATCH 017/233] 1. some small function updates 1.1 source/src_lcao/exx_lcao.cpp 1.2 source/src_external/src_test/test_function.h 1.3 source/src_pw/potential_libxc.cpp 1.4 tools/opt_lcao_bash/utils.py --- .../src_external/src_test/test_function.h | 8 ++++++ ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 25 +++++++++++++++++++ .../source/src_pw/potential_libxc.cpp | 10 ++++---- ABACUS.1.0.0/tools/opt_lcao_bash/utils.py | 4 +-- 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/ABACUS.1.0.0/source/src_external/src_test/test_function.h b/ABACUS.1.0.0/source/src_external/src_test/test_function.h index a1da45f49c..a90ac9a22e 100644 --- a/ABACUS.1.0.0/source/src_external/src_test/test_function.h +++ b/ABACUS.1.0.0/source/src_external/src_test/test_function.h @@ -57,5 +57,13 @@ static double cal_time( const timeval &t_begin ) return (double)(t_end.tv_sec-t_begin.tv_sec) + (double)(t_end.tv_usec-t_begin.tv_usec)/1000000.0; } +// Peize Lin add 2016-10-10 +static double cut_time( timeval &t ) +{ + const double time = cal_time(t); + gettimeofday( &t, NULL); + return time; +} + #endif // TEST_FUNCTION_H \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp index 37d1cdec26..b58e328a7c 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp @@ -137,6 +137,31 @@ Exx_Lcao::Exx_Lcao( const Exx_Global::Exx_Info &info_global ) print_matrix(m1,m2,m3); } }; + + auto test_gemm_2 = []() + { + constexpr int S=10000; + constexpr int N=1000; + matrix m1(N,N), m2(N,N), m3(N,N); + timeval time; + gettimeofday(&time, NULL); + + for(int s=0; sfamily ="+TO_STRING(func.info->family)+" unfinished "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + throw domain_error("func.info->family ="+TO_STRING(func.info->family)+" unfinished in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; } @@ -147,7 +147,7 @@ std::vector Potential_Libxc::init_func() }; if( 6==xcf.iexch_now && 8==xcf.igcx_now && 4==xcf.icorr_now && 4==xcf.igcc_now ) - { + { add_func( XC_HYB_GGA_XC_PBEH ); double parameter_hse[3] = { exx_global.info.hybrid_alpha, exx_global.info.hse_omega, exx_global.info.hse_omega }; xc_func_set_ext_params(&funcs.back(), parameter_hse); @@ -166,14 +166,14 @@ std::vector Potential_Libxc::init_func() else if( 1==xcf.iexch_now && 3==xcf.igcx_now ) add_func( XC_GGA_X_PBE ); else - throw domain_error("iexch="+TO_STRING(xcf.iexch_now)+", igcx="+TO_STRING(xcf.igcx_now)+" unfinished"); + throw domain_error("iexch="+TO_STRING(xcf.iexch_now)+", igcx="+TO_STRING(xcf.igcx_now)+" unfinished in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); if( 1==xcf.icorr_now && 0==xcf.igcc_now ) add_func( XC_LDA_C_PZ ); else if( 4==xcf.icorr_now && 4==xcf.igcc_now ) add_func( XC_GGA_C_PBE ); else - throw domain_error("icorr="+TO_STRING(xcf.icorr_now)+", igcc="+TO_STRING(xcf.igcc_now)+" unfinished"); + throw domain_error("icorr="+TO_STRING(xcf.icorr_now)+", igcc="+TO_STRING(xcf.igcc_now)+" unfinished in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); return funcs; } @@ -267,7 +267,7 @@ Potential_Libxc::cal_input( cal_sigma(); break; default: - throw domain_error("func.info->family ="+TO_STRING(func.info->family)+" unfinished "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + throw domain_error("func.info->family ="+TO_STRING(func.info->family)+" unfinished in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; } } diff --git a/ABACUS.1.0.0/tools/opt_lcao_bash/utils.py b/ABACUS.1.0.0/tools/opt_lcao_bash/utils.py index d085415fb2..57713d026f 100644 --- a/ABACUS.1.0.0/tools/opt_lcao_bash/utils.py +++ b/ABACUS.1.0.0/tools/opt_lcao_bash/utils.py @@ -1,4 +1,4 @@ -lat0 = 20 +lat0 = 30 dr = 0.01 -lr = 1 +lr = 0.01 sub = "qsub" \ No newline at end of file From 5cd9242ff32ce8ba4ff8bbd2103732357ddf4b10 Mon Sep 17 00:00:00 2001 From: linpz Date: Sun, 27 Oct 2019 21:29:29 +0800 Subject: [PATCH 018/233] 1. add openmp for calculating C and V 1.1 src_lcao/abfs.h 1.2 src_lcao/abfs.cpp 1.3 src_lcao/exx_abfs-screen-schwarz.cpp --- ABACUS.1.0.0/source/src_lcao/abfs.cpp | 106 +++++++++++++----- ABACUS.1.0.0/source/src_lcao/abfs.h | 4 + .../src_lcao/exx_abfs-screen-schwarz.cpp | 18 +-- ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 8 ++ 4 files changed, 101 insertions(+), 35 deletions(-) diff --git a/ABACUS.1.0.0/source/src_lcao/abfs.cpp b/ABACUS.1.0.0/source/src_lcao/abfs.cpp index 20b61eb5dc..6dab687b47 100644 --- a/ABACUS.1.0.0/source/src_lcao/abfs.cpp +++ b/ABACUS.1.0.0/source/src_lcao/abfs.cpp @@ -5,9 +5,11 @@ #include "exx_abfs-inverse_matrix_double.h" #include "src_pw/global.h" #include "src_global/global_function.h" +#include +#include #include // Peize Lin test -#include // Peize Lin test +#include // Peize Lin test #include "src_external/src_test/src_global/matrix-test.h" // Peize Lin test map,shared_ptr>>> Abfs::cal_Cs( @@ -21,21 +23,30 @@ map,shared_ptr>>> Abfs::c map,weak_ptr>>> &Vws ) { TITLE("Abfs","cal_Cs"); + pthread_rwlock_t rwlock_Cw; pthread_rwlock_init(&rwlock_Cw,NULL); + pthread_rwlock_t rwlock_Vw; pthread_rwlock_init(&rwlock_Vw,NULL); + + const vector atom_centres_vector( atom_centres.begin(), atom_centres.end() ); + const vector>>> adjs = get_adjs(); // pre-cal Vws on same atom, speed up DPcal_V() in DPcal_C() vector> Vs_same_atom(ucell.ntype); for(size_t it=0; it!=ucell.ntype; ++it) - Vs_same_atom[it] = DPcal_V( it,it,{0,0,0}, m_abfs_abfs, index_abfs, 0,true,Vws ); + Vs_same_atom[it] = DPcal_V( it,it,{0,0,0}, m_abfs_abfs, index_abfs, 0,true, rwlock_Vw,Vws ); + + const int mkl_threads = mkl_get_max_threads(); + mkl_set_num_threads(1); map,shared_ptr>>> Cs; - for( const int iat1 : atom_centres ) + #pragma omp parallel for + for( int i_iat1=0; i_iat1 tau1( ucell.atoms[it1].tau[ia1] ); - const map>> adjs = get_adjs(iat1); - for( const auto & atom2 : adjs ) + for( const auto & atom2 : adjs[iat1] ) { const int iat2 = atom2.first; const int it2 = ucell.iat2it[iat2]; @@ -43,17 +54,22 @@ map,shared_ptr>>> Abfs::c const Vector3_Order tau2( ucell.atoms[it2].tau[ia2] ); for( const Vector3 &box2 : atom2.second ) { -//cout<<"cal_Cs\t"< C = DPcal_C( it1, it2, -tau1+tau2+(box2*ucell.latvec), m_abfs_abfs, m_abfslcaos_lcaos, index_abfs, index_lcaos, - threshold, true, Cws, Vws ); + threshold, true, rwlock_Cw, rwlock_Vw, Cws, Vws ); + #pragma omp critical(Abfs_cal_Cs) + Cs[iat1][iat2][box2] = C; } } } + mkl_set_num_threads(mkl_threads); Abfs::delete_threshold_ptrs( Cs, threshold ); Vs_same_atom.clear(); Abfs::delete_empty_ptrs( Vws ); + pthread_rwlock_destroy(&rwlock_Cw); + pthread_rwlock_destroy(&rwlock_Vw); return Cs; } @@ -151,13 +167,16 @@ map,shared_ptr>>> Abfs::c const double threshold, map,weak_ptr>>> &Vws ) { - TITLE("Abfs","cal_Vs"); + TITLE("Abfs","cal_Vs"); + pthread_rwlock_t rwlock_Vw; pthread_rwlock_init(&rwlock_Vw,NULL); vector> Coulomb_potential_boxes = get_Coulomb_potential_boxes(rmesh_times); + map,shared_ptr>>> Vs; - for( const pair & atom_pair : atom_pairs ) + #pragma omp parallel for + for( int i_atom_pair=0; i_atom_pair,shared_ptr>>> Abfs::c const Vector3_Order delta_R = -tau1+tau2+(box2*ucell.latvec); if( delta_R.norm()*ucell.lat0 < Rcut ) { -//cout<<"cal_Vs\t"< V = DPcal_V( it1, it2, delta_R, m_abfs_abfs, index_abfs, - threshold, true, Vws ); + threshold, true, rwlock_Vw, Vws ); + #pragma omp critical(Abfs_cal_Vs) + Vs[iat1][iat2][box2] = V; } } } Abfs::delete_threshold_ptrs( Vs, threshold ); + pthread_rwlock_destroy(&rwlock_Vw); return Vs; } @@ -251,6 +273,8 @@ shared_ptr Abfs::DPcal_C( const Element_Basis_Index::IndexLNM &index_lcaos, const double threshold, const bool writable, + pthread_rwlock_t &rwlock_Cw, + pthread_rwlock_t &rwlock_Vw, map,weak_ptr>>> &Cws, map,weak_ptr>>> &Vws ) { @@ -269,21 +293,29 @@ shared_ptr Abfs::DPcal_C( // æ ¹æ®åŽç»­æƒ…况选择æƒè¡¡ã€‚ // TITLE("Abfs","DPcal_C"); + pthread_rwlock_rdlock(&rwlock_Cw); const weak_ptr * const Cws_ptr = static_cast * const>( MAP_EXIST( Cws, it1, it2, R ) ); + pthread_rwlock_unlock(&rwlock_Cw); + if( Cws_ptr && !Cws_ptr->expired() ) - return Cws[it1][it2][R].lock(); + return Cws_ptr->lock(); else { -//cout<<"DPcal_C\t"<(0,0,0)==R) && (it1==it2) ) { const shared_ptr A = make_shared( m_abfslcaos_lcaos.cal_overlap_matrix( it1,it2,0,0,index_abfs,index_lcaos,index_lcaos,Exx_Abfs::Matrix_Orbs21::Matrix_Order::A2B_A1 ) ); - const shared_ptr V = DPcal_V(it1,it2,{0,0,0},m_abfs_abfs,index_abfs,0,false,Vws); + const shared_ptr V = DPcal_V(it1,it2,{0,0,0}, m_abfs_abfs,index_abfs, 0,false, rwlock_Vw,Vws); const shared_ptr L = cal_I(V); shared_ptr C = make_shared( 0.5 * *A * *L ); if(C->absmax()<=threshold) C->create(0,0); - if(writable) Cws[it1][it2][R] = C; + if(writable) + { + pthread_rwlock_wrlock(&rwlock_Cw); + Cws[it1][it2][R] = C; + pthread_rwlock_unlock(&rwlock_Cw); + } return C; } else @@ -292,10 +324,10 @@ shared_ptr Abfs::DPcal_C( { make_shared( m_abfslcaos_lcaos.cal_overlap_matrix(it1,it2,0,R ,index_abfs,index_lcaos,index_lcaos,Exx_Abfs::Matrix_Orbs21::Matrix_Order::A2B_A1) ) , make_shared( m_abfslcaos_lcaos.cal_overlap_matrix(it2,it1,0,-R,index_abfs,index_lcaos,index_lcaos,Exx_Abfs::Matrix_Orbs21::Matrix_Order::BA2_A1) ) }; - const shared_ptr V_00 = DPcal_V(it1,it1,{0,0,0},m_abfs_abfs,index_abfs,0,false,Vws); - const shared_ptr V_01 = DPcal_V(it1,it2,R, m_abfs_abfs,index_abfs,0,false,Vws); - const shared_ptr V_10 = DPcal_V(it2,it1,-R, m_abfs_abfs,index_abfs,0,false,Vws); - const shared_ptr V_11 = DPcal_V(it2,it2,{0,0,0},m_abfs_abfs,index_abfs,0,false,Vws); + const shared_ptr V_00 = DPcal_V(it1,it1,{0,0,0}, m_abfs_abfs,index_abfs, 0,false, rwlock_Vw,Vws); + const shared_ptr V_01 = DPcal_V(it1,it2,R, m_abfs_abfs,index_abfs, 0,false, rwlock_Vw,Vws); + const shared_ptr V_10 = DPcal_V(it2,it1,-R, m_abfs_abfs,index_abfs, 0,false, rwlock_Vw,Vws); + const shared_ptr V_11 = DPcal_V(it2,it2,{0,0,0}, m_abfs_abfs,index_abfs, 0,false, rwlock_Vw,Vws); const vector>> V = {{ V_00, V_01 }, { V_10, V_11 }}; @@ -304,7 +336,12 @@ shared_ptr Abfs::DPcal_C( shared_ptr C = make_shared( *A[0] * *L[0][0] + *A[1] * *L[1][0] ); if(C->absmax()<=threshold) C->create(0,0); - if(writable) Cws[it1][it2][R] = C; + if(writable) + { + pthread_rwlock_wrlock(&rwlock_Cw); + Cws[it1][it2][R] = C; + pthread_rwlock_unlock(&rwlock_Cw); + } return C; } } @@ -318,27 +355,40 @@ shared_ptr Abfs::DPcal_V( const Element_Basis_Index::IndexLNM &index_abfs, const double threshold, const bool writable, + pthread_rwlock_t &rwlock_Vw, map,weak_ptr>>> &Vws) { // TITLE("Abfs","DPcal_V"); - + pthread_rwlock_rdlock(&rwlock_Vw); const weak_ptr * const Vws12_ptr = static_cast * const>( MAP_EXIST( Vws, it1, it2, R ) ); const weak_ptr * const Vws21_ptr = static_cast * const>( MAP_EXIST( Vws, it2, it1, -R ) ); + pthread_rwlock_unlock(&rwlock_Vw); + if( Vws12_ptr && !Vws12_ptr->expired() ) return Vws12_ptr->lock(); else if( Vws21_ptr && !Vws21_ptr->expired() ) { shared_ptr VT = make_shared( transpose(*Vws21_ptr->lock()) ); if(VT->absmax()<=threshold) VT->create(0,0); - if(writable) Vws[it1][it2][R] = VT; + if(writable) + { + pthread_rwlock_wrlock(&rwlock_Vw); + Vws[it1][it2][R] = VT; + pthread_rwlock_unlock(&rwlock_Vw); + } return VT; } else { -//cout<<"DPcal_V\t"< V = make_shared( m_abfs_abfs.cal_overlap_matrix(it1,it2,0,R,index_abfs,index_abfs) ); if(V->absmax()<=threshold) V->create(0,0); - if(writable) Vws[it1][it2][R] = V; + if(writable) + { + pthread_rwlock_wrlock(&rwlock_Vw); + Vws[it1][it2][R] = V; + pthread_rwlock_unlock(&rwlock_Vw); + } return V; } } diff --git a/ABACUS.1.0.0/source/src_lcao/abfs.h b/ABACUS.1.0.0/source/src_lcao/abfs.h index f8758c72f3..ecd4824666 100644 --- a/ABACUS.1.0.0/source/src_lcao/abfs.h +++ b/ABACUS.1.0.0/source/src_lcao/abfs.h @@ -9,6 +9,7 @@ #include #include #include +#include class Abfs { @@ -61,6 +62,8 @@ class Abfs const Element_Basis_Index::IndexLNM &index_lcaos, const double threshold, const bool writable, + pthread_rwlock_t &rwlock_Cw, + pthread_rwlock_t &rwlock_Vw, map,weak_ptr>>> &Cws, map,weak_ptr>>> &Vws ); @@ -73,6 +76,7 @@ class Abfs const Element_Basis_Index::IndexLNM &index_abfs, const double threshold, const bool writable, + pthread_rwlock_t &rwlock_Vw, map,weak_ptr>>> &Vws ); // static map>> get_adjs( const size_t &T, const Vector3 &tau_cartesian ); diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.cpp index b0cca7d26a..ede5741de6 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-screen-schwarz.cpp @@ -32,11 +32,13 @@ void Exx_Abfs::Screen::Schwarz::cal_max_pair_fock( { if(!flag_screen_schwarz) return; TITLE("Exx_Abfs::Screen::Schwarz::cal_max_pair_fock"); + pthread_rwlock_t rwlock_Cw; pthread_rwlock_init(&rwlock_Cw,NULL); + pthread_rwlock_t rwlock_Vw; pthread_rwlock_init(&rwlock_Vw,NULL); // pre-cal Vws on same atom, speed up DPcal_V() vector> Vs_same_atom(ucell.ntype); for(size_t it=0; it!=ucell.ntype; ++it) - Vs_same_atom[it] = Abfs::DPcal_V( it,it,{0,0,0}, m_abfs_abfs, index_abfs, 0,true,Vws ); + Vs_same_atom[it] = Abfs::DPcal_V( it,it,{0,0,0}, m_abfs_abfs, index_abfs, 0,true, rwlock_Vw,Vws ); // m_out( i1, i2, i3 ) = m_in( i2, i1, i3 ) auto change_matrix_order =[]( const matrix &m_in, const size_t n1 ) -> matrix @@ -100,15 +102,15 @@ void Exx_Abfs::Screen::Schwarz::cal_max_pair_fock( else { const Abfs::Vector3_Order R = -tau1+tau2+box2*ucell.latvec; - const matrix C_12 = *Abfs::DPcal_C( it1,it2,R, m_abfs_abfs,m_abfslcaos_lcaos, index_abfs,index_lcaos, 0,false,Cws,Vws ); + const matrix C_12 = *Abfs::DPcal_C( it1,it2,R, m_abfs_abfs,m_abfslcaos_lcaos, index_abfs,index_lcaos, 0,false, rwlock_Cw,rwlock_Vw,Cws,Vws ); const matrix C_21 = change_matrix_order( - *Abfs::DPcal_C( it2,it1,-R, m_abfs_abfs,m_abfslcaos_lcaos, index_abfs,index_lcaos, 0,false,Cws,Vws ), + *Abfs::DPcal_C( it2,it1,-R, m_abfs_abfs,m_abfslcaos_lcaos, index_abfs,index_lcaos, 0,false, rwlock_Cw,rwlock_Vw,Cws,Vws ), index_lcaos[it1].count_size); - const matrix V_11 = *Abfs::DPcal_V(it1,it1,{0,0,0},m_abfs_abfs,index_abfs,0,false,Vws); - const matrix V_12 = *Abfs::DPcal_V(it1,it2,R, m_abfs_abfs,index_abfs,0,false,Vws); - const matrix V_21 = *Abfs::DPcal_V(it2,it1,-R, m_abfs_abfs,index_abfs,0,false,Vws); - const matrix V_22 = *Abfs::DPcal_V(it2,it2,{0,0,0},m_abfs_abfs,index_abfs,0,false,Vws); + const matrix V_11 = *Abfs::DPcal_V(it1,it1,{0,0,0}, m_abfs_abfs,index_abfs, 0,false, rwlock_Vw,Vws); + const matrix V_12 = *Abfs::DPcal_V(it1,it2,R, m_abfs_abfs,index_abfs, 0,false, rwlock_Vw,Vws); + const matrix V_21 = *Abfs::DPcal_V(it2,it1,-R, m_abfs_abfs,index_abfs, 0,false, rwlock_Vw,Vws); + const matrix V_22 = *Abfs::DPcal_V(it2,it2,{0,0,0}, m_abfs_abfs,index_abfs, 0,false, rwlock_Vw,Vws); pair_fock_s[box2] = make_shared( m_mT( C_12 * V_11, C_12 ) @@ -130,6 +132,8 @@ void Exx_Abfs::Screen::Schwarz::cal_max_pair_fock( Vs_same_atom.clear(); Abfs::delete_empty_ptrs( Vws ); + pthread_rwlock_destroy(&rwlock_Cw); + pthread_rwlock_destroy(&rwlock_Vw); //test_screen("schwarz-max_pair_fock.dat",max_pair_fock); } diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp index b58e328a7c..3f27ad4cbb 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp @@ -636,6 +636,9 @@ ofs_mpi.close(); m_abfslcaos_lcaos.init( 1, this->kmesh_times, 1 ); m_abfslcaos_lcaos.init_radial( abfs, lcaos, lcaos ); m_abfslcaos_lcaos.init_radial_table(); + + pthread_rwlock_t rwlock_Cw; pthread_rwlock_init(&rwlock_Cw,NULL); + pthread_rwlock_t rwlock_Vw; pthread_rwlock_init(&rwlock_Vw,NULL); map,weak_ptr>>> Cws; map,weak_ptr>>> Vws; @@ -649,9 +652,14 @@ ofs_mpi.close(); index_lcaos, 0, true, + rwlock_Cw, + rwlock_Vw, Cws, Vws); cout<<*C< Date: Tue, 10 Dec 2019 02:25:40 +0800 Subject: [PATCH 019/233] 1. add explicit in ComplexMatrix(const matrix &m) 1.1 complexmatrix.h 2. change 0.25 to exx_global.info.hybrid_alpha in Use_Hamilt_Matrix::calculate_Hk 2.1 src_lcao/use_hamilt_matrix.cpp --- .../src_test/src_lcao/exx_lcao-test.h | 1 - .../source/src_global/complexmatrix.h | 2 +- ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 198 +++++++++++------- .../source/src_lcao/use_hamilt_matrix.cpp | 4 +- ABACUS.1.0.0/source/src_pw/exx_lip.cpp | 6 +- ABACUS.1.0.0/tools/opt_abfs_bash/opt_orb.py | 2 +- ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py | 2 +- 7 files changed, 129 insertions(+), 86 deletions(-) diff --git a/ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_lcao-test.h b/ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_lcao-test.h index d901086890..4132d88f69 100644 --- a/ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_lcao-test.h +++ b/ABACUS.1.0.0/source/src_external/src_test/src_lcao/exx_lcao-test.h @@ -114,7 +114,6 @@ static void ofs_matrixes( const string & file_name, const ComplexMatrix & ms, co ofs.close(); } - /* template static void ofs_matrixes( const string & file_name, const map>>> & ms, const bool flag_print_content=true ) diff --git a/ABACUS.1.0.0/source/src_global/complexmatrix.h b/ABACUS.1.0.0/source/src_global/complexmatrix.h index 79f618646d..b98e7465a5 100644 --- a/ABACUS.1.0.0/source/src_global/complexmatrix.h +++ b/ABACUS.1.0.0/source/src_global/complexmatrix.h @@ -29,7 +29,7 @@ class ComplexMatrix ComplexMatrix(const int nrows,const int ncols,const bool flag_zero=true); // Peize Lin add flag_zero 2019-05-13 ComplexMatrix(const ComplexMatrix &m1); ComplexMatrix(ComplexMatrix && m1); // Peize Lin add 2016-08-05 - ComplexMatrix(const matrix &m); // Peize Lin add 2017-03-29 + explicit ComplexMatrix(const matrix &m); // Peize Lin add 2017-03-29 ~ComplexMatrix(); void create(const int nrow,const int ncol,const bool flag_zero=true); // Peize Lin add flag_zero 2019-05-13 diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp index 3f27ad4cbb..ae814adf48 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp @@ -56,7 +56,7 @@ static matrix transform ( Exx_Lcao::Exx_Lcao( const Exx_Global::Exx_Info &info_global ) :kmesh_times(4), info(info_global) -{ +{ auto test_gemm = []() { auto init_matrix = [](const int nr, const int nc, const double add) -> matrix @@ -803,8 +803,8 @@ void Exx_Lcao::cal_exx_elec() { TITLE("Exx_Lcao","cal_exx_elec"); +static int istep=0; #if TEST_EXX_LCAO==1 - static int istep=0; // ofs_matrixes("Cws_"+TO_STRING(istep)+"_before.dat",Cws); // ofs_matrixes("Vws_"+TO_STRING(istep)+"_before.dat",Vws); // ofs_matrixes("Cs_"+TO_STRING(istep)+"_before.dat",Cs); @@ -871,119 +871,165 @@ ofs_mpi.close(); ofs_matrixes("DMk_"+TO_STRING(istep)+".dat",DM.DMk); ofs_matrixes("DMr_"+TO_STRING(istep)+".dat",DM.DMr); ofs_matrixes("Hexx_"+TO_STRING(istep)+".dat",Hexx); + #elif TEST_EXX_LCAO==-1 + #error "TEST_EXX_LCAO" + #endif - auto print_LOCDM = []() + auto print_LOCDM = [&]() + { + if(GAMMA_ONLY_LOCAL) { - if(GAMMA_ONLY_LOCAL) - { - ofstream ofs("LOC.DM.dat",ofstream::app); - const int it1=0, it2=0; - for( size_t ia1=0; ia1!=ucell.atoms[it1].na; ++ia1 ) - for( size_t ia2=0; ia2!=ucell.atoms[it2].na; ++ia2 ) - for( size_t is=0; is!=NSPIN; ++is ) + ofstream ofs("LOC.DM.dat",ofstream::app); + const int it1=0, it2=0; + for( size_t ia1=0; ia1!=ucell.atoms[it1].na; ++ia1 ) + for( size_t ia2=0; ia2!=ucell.atoms[it2].na; ++ia2 ) + for( size_t is=0; is!=NSPIN; ++is ) + { + ofs<<"@\t"< & box2 : atom2.second ) { - const size_t iat2 = atom2.first; - for( const Abfs::Vector3_Order & box2 : atom2.second ) + ofs<<"@\t"< Date: Fri, 13 Dec 2019 10:22:04 +0800 Subject: [PATCH 020/233] 1. add openmp 1.1 Numerical_Orbital_Lm::cal_kradial_sbpool 1.2 Numerical_Orbital_Lm::extra_uniform 1.3 Mathzone_Add1::Cubic_Spline_Interpolation --- .../source/src_global/mathzone_add1.cpp | 53 +++++++++---------- .../source/src_global/mathzone_add1.h | 12 ++--- .../src_lcao/exx_abfs-matrix_orbs11.cpp | 20 +++---- .../src_lcao/exx_abfs-matrix_orbs21.cpp | 20 +++---- .../src_lcao/exx_abfs-matrix_orbs22.cpp | 2 +- .../source/src_lcao/numerical_orbital_lm.cpp | 13 +++-- 6 files changed, 61 insertions(+), 59 deletions(-) diff --git a/ABACUS.1.0.0/source/src_global/mathzone_add1.cpp b/ABACUS.1.0.0/source/src_global/mathzone_add1.cpp index 3407f349f0..d8714bd73b 100644 --- a/ABACUS.1.0.0/source/src_global/mathzone_add1.cpp +++ b/ABACUS.1.0.0/source/src_global/mathzone_add1.cpp @@ -18,6 +18,7 @@ typedef fftw_complex FFTW_COMPLEX; //#include //#include //#include +#include bool Mathzone_Add1::flag_jlx_expand_coef = false; double** Mathzone_Add1::c_ln_c = new double*[1]; @@ -1046,54 +1047,50 @@ void Mathzone_Add1::SplineD2 // modified by pengfei 13-8-8 add second derivative timer::tick("Mathzone_Add1","SplineD2"); } - +// Peize Lin add openmp 2019-12-13 void Mathzone_Add1::Cubic_Spline_Interpolation ( - const double *rad, - const double *rad_f, - const double *y2, + const double * const rad, + const double * const rad_f, + const double * const y2, const int& mesh, - const double* r, + const double * const r, const int& rsize, - double* y, - double* dy + double * const y, + double * const dy ) { timer::tick("Mathzone_Add1","Cubic_Spline_Interpolation"); - - //begin interpolation - int k, klo, khi, m; - double h, b, a; - for(m = 0; m < rsize ; m++) + #pragma omp parallel for schedule(static) + for(int m = 0; m < rsize ; m++) { - klo = 0; - khi = mesh-1; - + int klo = 0; + int khi = mesh-1; while (khi - klo > 1) { - k = (khi + klo) / 2 ; + const int k = (khi + klo) / 2 ; if(rad[k] > r[m]) khi = k; else klo = k; } - //if(klo==0 && khi==1) // extrapolation - //{ - // klo = 1; - // khi = 2; - //} + //if(klo==0 && khi==1) // extrapolation + //{ + // klo = 1; + // khi = 2; + //} - h = rad[khi] - rad[klo]; - + const double h = rad[khi] - rad[klo]; if(h == 0.0) WARNING_QUIT("Cubic_Spline_Interpolation","h == 0.0 so that cannot be divided"); - a = (rad[khi] - r[m]) / h; - b = (r[m] - rad[klo]) / h; + const double a = (rad[khi] - r[m]) / h; + const double b = (r[m] - rad[klo]) / h; - dy[m] = (rad_f[khi] - rad_f[klo]) / h - + const double dy_tmp = (rad_f[khi] - rad_f[klo]) / h - (3.0 * a * a - 1.0) / 6.0 * h * y2[klo] + ( 3.0 * b * b - 1.0) / 6.0 * h * y2[khi]; - - y[m] = a * rad_f[klo] + b * rad_f[khi] + ((a*a*a - a) * y2[klo] + (b*b*b - b) * y2[khi]) * (h*h) / 6.0; + dy[m] = dy_tmp; + const double y_tmp = a * rad_f[klo] + b * rad_f[khi] + ((a*a*a - a) * y2[klo] + (b*b*b - b) * y2[khi]) * (h*h) / 6.0; + y[m] = y_tmp; } timer::tick("Mathzone_Add1","Cubic_Spline_Interpolation"); diff --git a/ABACUS.1.0.0/source/src_global/mathzone_add1.h b/ABACUS.1.0.0/source/src_global/mathzone_add1.h index 634cbca3b9..310738d745 100644 --- a/ABACUS.1.0.0/source/src_global/mathzone_add1.h +++ b/ABACUS.1.0.0/source/src_global/mathzone_add1.h @@ -135,14 +135,14 @@ class Mathzone_Add1 static void Cubic_Spline_Interpolation ( - const double *rad, - const double *rad_f, - const double *y2, + const double * const rad, + const double * const rad_f, + const double * const y2, const int& mesh, - const double* r, + const double * const r, const int& rsize, - double* y, - double* dy + double * const y, + double * const dy ); static double RadialF diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs11.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs11.cpp index da4e38629e..baaa804c4b 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs11.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-matrix_orbs11.cpp @@ -124,9 +124,9 @@ void Exx_Abfs::Matrix_Orbs11::init_radial_table() void Exx_Abfs::Matrix_Orbs11::init_radial_table( const map>> &Rs ) { -//ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); -//timeval t_start; -//gettimeofday( &t_start, NULL); +ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; +gettimeofday( &t_start, NULL); TITLE("Exx_Abfs::Matrix_Orbs11","init_radial_table_Rs"); for( const auto &RsA : Rs ) for( const auto &RsB : RsA.second ) @@ -134,8 +134,8 @@ void Exx_Abfs::Matrix_Orbs11::init_radial_table( const map>>>*const>( MAP_EXIST(center2_orb11_s, RsA.first, RsB.first)) ) { -//timeval t_small; -//gettimeofday(&t_small, NULL); +timeval t_small; +gettimeofday(&t_small, NULL); set radials; for( const double &R : RsB.second ) { @@ -144,18 +144,18 @@ void Exx_Abfs::Matrix_Orbs11::init_radial_table( const map>> &Rs ) { -//ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); -//timeval t_start; -//gettimeofday(&t_start, NULL); +ofstream ofs(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); +timeval t_start; +gettimeofday(&t_start, NULL); TITLE("Exx_Abfs::Matrix_Orbs21","init_radial_table_Rs"); @@ -158,8 +158,8 @@ void Exx_Abfs::Matrix_Orbs21::init_radial_table( const map>>>>>*const>( MAP_EXIST(center2_orb21_s, RsA.first, RsB.first)) ) { -//timeval t_small; -//gettimeofday(&t_small, NULL); +timeval t_small; +gettimeofday(&t_small, NULL); set radials; for( const double &R : RsB.second ) { @@ -168,8 +168,8 @@ void Exx_Abfs::Matrix_Orbs21::init_radial_table( const map Numerical_Orbital_Lm::Numerical_Orbital_Lm() { @@ -214,9 +215,11 @@ void Numerical_Orbital_Lm::extra_uniform(const double &dr_uniform_in) this->psi_uniform.resize(nr_uniform,0); // do interpolation here to make grid more dense + #pragma omp parallel for schedule(static) for (int ir = 0; ir < this->nr_uniform; ir++) { - this->psi_uniform[ir] = Mathzone_Add1::Uni_RadialF(VECTOR_TO_PTR(this->psi), this->nr, this->rab[0], ir * dr_uniform); + const double psi_uniform_tmp = Mathzone_Add1::Uni_RadialF(VECTOR_TO_PTR(this->psi), this->nr, this->rab[0], ir * dr_uniform); + this->psi_uniform[ir] = psi_uniform_tmp; // this->psi_uniform[ir] = Mathzone::Polynomial_Interpolation(this->psi, this->nr, this->rab[0], ir * dr_uniform); } @@ -492,11 +495,13 @@ void Numerical_Orbital_Lm::cal_kradial_sbpool(void) for( size_t ir=1; ir!=nr-1; ++ir ) r_tmp[ir] *= (ir&1) ? four_three : two_three; + #pragma omp parallel for schedule(static) for (int ik = 0; ik < nk; ik++) { - this->psif[ik] = pref * LapackConnector::dot( this->nr, VECTOR_TO_PTR(r_tmp), 1, VECTOR_TO_PTR(jl[ik]), 1 ) ; - this->psik[ik] = this->psif[ik] * k_radial[ik]; - this->psik2[ik] = this->psik[ik] * k_radial[ik]; + const double psi_f_tmp = pref * LapackConnector::dot( this->nr, VECTOR_TO_PTR(r_tmp), 1, VECTOR_TO_PTR(jl[ik]), 1 ) ; + this->psif[ik] = psi_f_tmp; + this->psik[ik] = psi_f_tmp * k_radial[ik]; + this->psik2[ik] = psi_f_tmp * k_radial[ik]; } } From e5cc5407680328ededea232cd31f36e1a82e50a5 Mon Sep 17 00:00:00 2001 From: linpz Date: Sat, 14 Dec 2019 17:11:22 +0800 Subject: [PATCH 021/233] 1. optimize src_lcao/exx_opt_orb.cpp memory 1.1 src_lcao/exx_opt_orb.cpp 1.2 src_external/src_test/test_function.h --- .../src_external/src_test/test_function.h | 18 +- ABACUS.1.0.0/source/src_lcao/exx_opt_orb.cpp | 162 ++++++++++-------- 2 files changed, 111 insertions(+), 69 deletions(-) diff --git a/ABACUS.1.0.0/source/src_external/src_test/test_function.h b/ABACUS.1.0.0/source/src_external/src_test/test_function.h index a90ac9a22e..1c9584a52d 100644 --- a/ABACUS.1.0.0/source/src_external/src_test/test_function.h +++ b/ABACUS.1.0.0/source/src_external/src_test/test_function.h @@ -16,7 +16,7 @@ static void MPI_RANK_OFSTREAM( const std::string& file_name, std::stringstream & int my_rank; MPI_Comm_rank(MPI_COMM_WORLD,&my_rank); file< get_memory(const int N) +{ + vector m; + string s; + ifstream ifs("/proc/meminfo"); + ifs>>s>>s; + m.push_back(stoi(s)/1024); + for(int i=1; i>s>>s>>s; + m.push_back(stoi(s)/1024); + } + ifs.close(); + return m; +} #endif // TEST_FUNCTION_H \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_opt_orb.cpp b/ABACUS.1.0.0/source/src_lcao/exx_opt_orb.cpp index b9d20f90da..b6ab65e532 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_opt_orb.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_opt_orb.cpp @@ -14,20 +14,26 @@ #include "src_external/src_test/src_lcao/exx_abfs-unittest.h" #include "src_external/src_test/src_lcao/exx_lcao-test.h" #include "src_external/src_test/src_global/element_basis_index-test.h" +#include "src_external/src_test/test_function.h" void Exx_Opt_Orb::generate_matrix() const { ofstream ofs_mpi(exx_lcao.test_dir.process+"time_"+TO_STRING(MY_RANK),ofstream::app); TITLE("Exx_Opt_Orb::generate_matrix"); +ofs_mpi<<"memory:\t"<>> lcaos = Exx_Abfs::Construct_Orbs::change_orbs( ORB, this->kmesh_times ); const vector>> abfs = Exx_Abfs::Construct_Orbs::abfs_same_atom( lcaos, this->kmesh_times, exx_lcao.info.pca_threshold ); +ofs_mpi<<"memory:\t"<kmesh_times ); +ofs_mpi<<"memory:\t"<(abfs[T].size())-1 ); @@ -51,91 +57,111 @@ ofs_mpi<kmesh_times, 1 ); - m_lcaoslcaos_lcaoslcaos.init_radial( lcaos, lcaos, lcaos, lcaos ); -#if TEST_EXX_RADIAL>=1 - m_lcaoslcaos_lcaoslcaos.init_radial_table(radial_R); -#else - m_lcaoslcaos_lcaoslcaos.init_radial_table(); -#endif - - Exx_Abfs::Matrix_Orbs21 m_jyslcaos_lcaos; - m_jyslcaos_lcaos.init( 1, this->kmesh_times, 1 ); - m_jyslcaos_lcaos.init_radial( jle.jle, lcaos, lcaos ); -#if TEST_EXX_RADIAL>=1 - m_jyslcaos_lcaos.init_radial_table(radial_R); -#else - m_jyslcaos_lcaos.init_radial_table(); -#endif - - Exx_Abfs::Matrix_Orbs11 m_jys_jys; - m_jys_jys.init( 2, this->kmesh_times, 1 ); - m_jys_jys.init_radial( jle.jle, jle.jle ); -#if TEST_EXX_RADIAL>=1 - m_jys_jys.init_radial_table(radial_R); -#else - m_jys_jys.init_radial_table(); -#endif - - Exx_Abfs::Matrix_Orbs11 m_abfs_abfs; - m_abfs_abfs.init( 2, this->kmesh_times, 1 ); - m_abfs_abfs.init_radial( abfs, abfs ); -#if TEST_EXX_RADIAL>=1 - m_abfs_abfs.init_radial_table(radial_R); -#else - m_abfs_abfs.init_radial_table(); -#endif - - Exx_Abfs::Matrix_Orbs21 m_abfslcaos_lcaos; - m_abfslcaos_lcaos.init( 1, this->kmesh_times, 1 ); - m_abfslcaos_lcaos.init_radial( abfs, lcaos, lcaos ); -#if TEST_EXX_RADIAL>=1 - m_abfslcaos_lcaos.init_radial_table(radial_R); -#else - m_abfslcaos_lcaos.init_radial_table(); -#endif - - Exx_Abfs::Matrix_Orbs11 m_jys_abfs; - m_jys_abfs.init( 2, this->kmesh_times, 1 ); - m_jys_abfs.init_radial( jle.jle, abfs ); -#if TEST_EXX_RADIAL>=1 - m_jys_abfs.init_radial_table(radial_R); -#else - m_jys_abfs.init_radial_table(); -#endif +ofs_mpi<<"memory:\t"< - const map>>> - ms_lcaoslcaos_lcaoslcaos = m_lcaoslcaos_lcaoslcaos.cal_overlap_matrix( index_lcaos, index_lcaos, index_lcaos, index_lcaos); + const auto ms_lcaoslcaos_lcaoslcaos = [&]() -> map>>> + { + Exx_Abfs::Matrix_Orbs22 m_lcaoslcaos_lcaoslcaos; + m_lcaoslcaos_lcaoslcaos.init( 1, this->kmesh_times, 1 ); + m_lcaoslcaos_lcaoslcaos.init_radial( lcaos, lcaos, lcaos, lcaos ); + #if TEST_EXX_RADIAL>=1 + m_lcaoslcaos_lcaoslcaos.init_radial_table(radial_R); + #else + m_lcaoslcaos_lcaoslcaos.init_radial_table(); + #endif + return m_lcaoslcaos_lcaoslcaos.cal_overlap_matrix( index_lcaos, index_lcaos, index_lcaos, index_lcaos); + }(); + +ofs_mpi<<"memory:\t"< - const map>>>> - ms_lcaoslcaos_jys = m_jyslcaos_lcaos.cal_overlap_matrix( index_jys, index_lcaos, index_lcaos ); + const auto ms_lcaoslcaos_jys = [&]() -> map>>>> + { + Exx_Abfs::Matrix_Orbs21 m_jyslcaos_lcaos; + m_jyslcaos_lcaos.init( 1, this->kmesh_times, 1 ); + m_jyslcaos_lcaos.init_radial( jle.jle, lcaos, lcaos ); + #if TEST_EXX_RADIAL>=1 + m_jyslcaos_lcaos.init_radial_table(radial_R); + #else + m_jyslcaos_lcaos.init_radial_table(); + #endif + return m_jyslcaos_lcaos.cal_overlap_matrix( index_jys, index_lcaos, index_lcaos ); + }(); + +ofs_mpi<<"memory:\t"< - const map>>> - ms_jys_jys = m_jys_jys.cal_overlap_matrix( index_jys, index_jys ); + const auto ms_jys_jys = [&]() -> map>>> + { + Exx_Abfs::Matrix_Orbs11 m_jys_jys; + m_jys_jys.init( 2, this->kmesh_times, 1 ); + m_jys_jys.init_radial( jle.jle, jle.jle ); + #if TEST_EXX_RADIAL>=1 + m_jys_jys.init_radial_table(radial_R); + #else + m_jys_jys.init_radial_table(); + #endif + return m_jys_jys.cal_overlap_matrix( index_jys, index_jys ); + }(); + +ofs_mpi<<"memory:\t"< - const map>>> - ms_abfs_abfs = m_abfs_abfs.cal_overlap_matrix( index_abfs, index_abfs ); + const auto ms_abfs_abfs = [&]() -> map>>> + { + Exx_Abfs::Matrix_Orbs11 m_abfs_abfs; + m_abfs_abfs.init( 2, this->kmesh_times, 1 ); + m_abfs_abfs.init_radial( abfs, abfs ); + #if TEST_EXX_RADIAL>=1 + m_abfs_abfs.init_radial_table(radial_R); + #else + m_abfs_abfs.init_radial_table(); + #endif + return m_abfs_abfs.cal_overlap_matrix( index_abfs, index_abfs ); + }(); + +ofs_mpi<<"memory:\t"< - const map>>>> - ms_lcaoslcaos_abfs = m_abfslcaos_lcaos.cal_overlap_matrix( index_abfs, index_lcaos, index_lcaos ); + const auto ms_lcaoslcaos_abfs = [&]() -> map>>>> + { + Exx_Abfs::Matrix_Orbs21 m_abfslcaos_lcaos; + m_abfslcaos_lcaos.init( 1, this->kmesh_times, 1 ); + m_abfslcaos_lcaos.init_radial( abfs, lcaos, lcaos ); + #if TEST_EXX_RADIAL>=1 + m_abfslcaos_lcaos.init_radial_table(radial_R); + #else + m_abfslcaos_lcaos.init_radial_table(); + #endif + return m_abfslcaos_lcaos.cal_overlap_matrix( index_abfs, index_lcaos, index_lcaos ); + }(); + +ofs_mpi<<"memory:\t"< - const map>>> - ms_jys_abfs = m_jys_abfs.cal_overlap_matrix( index_jys, index_abfs ); + const auto ms_jys_abfs = [&]() -> map>>> + { + Exx_Abfs::Matrix_Orbs11 m_jys_abfs; + m_jys_abfs.init( 2, this->kmesh_times, 1 ); + m_jys_abfs.init_radial( jle.jle, abfs ); + #if TEST_EXX_RADIAL>=1 + m_jys_abfs.init_radial_table(radial_R); + #else + m_jys_abfs.init_radial_table(); + #endif + return m_jys_abfs.cal_overlap_matrix( index_jys, index_abfs ); + }(); + +ofs_mpi<<"memory:\t"< Date: Sat, 14 Dec 2019 17:56:47 +0800 Subject: [PATCH 022/233] 1. change exx_ccp_threshold to exx_ccp_rmesh_times 1.1 src_lcao/conv_coulomb_pot_k.h 1.2 src_lcao/exx_lcao.h 1.3 src_lcao/exx_lcao.cpp 1.4 input.h 1.5 input.cpp 1.6 input_conv.cpp --- ABACUS.1.0.0/source/input.cpp | 11 ++++++++++ ABACUS.1.0.0/source/input.h | 1 + ABACUS.1.0.0/source/input_conv.cpp | 1 + .../source/src_lcao/conv_coulomb_pot_k.h | 12 +++++------ ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 21 +++++++++---------- ABACUS.1.0.0/source/src_lcao/exx_lcao.h | 2 +- 6 files changed, 30 insertions(+), 18 deletions(-) diff --git a/ABACUS.1.0.0/source/input.cpp b/ABACUS.1.0.0/source/input.cpp index 1290e9b1c3..ee5ba9b9c6 100644 --- a/ABACUS.1.0.0/source/input.cpp +++ b/ABACUS.1.0.0/source/input.cpp @@ -433,6 +433,7 @@ void Input::Default(void) exx_schwarz_threshold = 0; exx_cauchy_threshold = 0; exx_ccp_threshold = 1E-8; + exx_ccp_rmesh_times = 10; exx_distribute_type = "htime"; @@ -1575,6 +1576,10 @@ bool Input::Read(const string &fn) { read_value(ifs, exx_ccp_threshold); } + else if (strcmp("exx_ccp_rmesh_times", word) == 0) + { + read_value(ifs, exx_ccp_rmesh_times); + } else if (strcmp("exx_distribute_type", word) == 0) { read_value(ifs, exx_distribute_type); @@ -1998,6 +2003,7 @@ void Input::Bcast() Parallel_Common::bcast_double( exx_schwarz_threshold ); Parallel_Common::bcast_double( exx_cauchy_threshold ); Parallel_Common::bcast_double( exx_ccp_threshold ); + Parallel_Common::bcast_double( exx_ccp_rmesh_times ); Parallel_Common::bcast_string( exx_distribute_type ); Parallel_Common::bcast_int( exx_opt_orb_lmax ); Parallel_Common::bcast_double( exx_opt_orb_ecut ); @@ -2617,6 +2623,10 @@ void Input::Check(void) { WARNING_QUIT("INPUT","must exx_hybrid_step > 0"); } + if(exx_ccp_rmesh_times<1) + { + WARNING_QUIT("INPUT","must exx_ccp_rmesh_times >= 1"); + } if(exx_distribute_type!="htime" && exx_distribute_type!="kmeans2" && exx_distribute_type!="kmeans1") { WARNING_QUIT("INPUT","exx_distribute_type must be htime or kmeans2 or kmeans1"); @@ -2999,6 +3009,7 @@ void Input::Print(const string &fn)const OUTP(ofs,"exx_schwarz_threshold",exx_schwarz_threshold,""); OUTP(ofs,"exx_cauchy_threshold",exx_cauchy_threshold,""); OUTP(ofs,"exx_ccp_threshold",exx_ccp_threshold,""); + OUTP(ofs,"exx_ccp_rmesh_times",exx_ccp_rmesh_times,""); OUTP(ofs,"exx_distribute_type",exx_distribute_type,"htime or kmeans1 or kmeans2"); OUTP(ofs,"exx_opt_orb_lmax",exx_opt_orb_lmax,""); OUTP(ofs,"exx_opt_orb_ecut",exx_opt_orb_ecut,""); diff --git a/ABACUS.1.0.0/source/input.h b/ABACUS.1.0.0/source/input.h index 94983e5e82..b6399494fc 100644 --- a/ABACUS.1.0.0/source/input.h +++ b/ABACUS.1.0.0/source/input.h @@ -335,6 +335,7 @@ class Input double exx_schwarz_threshold; double exx_cauchy_threshold; double exx_ccp_threshold; + double exx_ccp_rmesh_times; string exx_distribute_type; diff --git a/ABACUS.1.0.0/source/input_conv.cpp b/ABACUS.1.0.0/source/input_conv.cpp index fe0f1a8189..79d1654de3 100644 --- a/ABACUS.1.0.0/source/input_conv.cpp +++ b/ABACUS.1.0.0/source/input_conv.cpp @@ -426,6 +426,7 @@ void Input_Conv::Convert(void) exx_lcao.info.schwarz_threshold = INPUT.exx_schwarz_threshold ; exx_lcao.info.cauchy_threshold = INPUT.exx_cauchy_threshold ; exx_lcao.info.ccp_threshold = INPUT.exx_ccp_threshold ; + exx_lcao.info.ccp_rmesh_times = INPUT.exx_ccp_rmesh_times ; if(INPUT.exx_distribute_type=="htime") exx_lcao.info.distribute_type = Exx_Lcao::Distribute_Type::Htime; else if(INPUT.exx_distribute_type=="kmeans2") diff --git a/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.h b/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.h index e659146337..66e577b67e 100644 --- a/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.h +++ b/ABACUS.1.0.0/source/src_lcao/conv_coulomb_pot_k.h @@ -12,6 +12,12 @@ class Conv_Coulomb_Pot_K enum class Ccp_Type{ // parameter: Ccp, // Hse}; // "hse_omega" + + template static T cal_orbs_ccp( + const T &orbs, + const Ccp_Type &ccp_type, + const std::map ¶meter, + const double rmesh_times); template static T cal_orbs_ccp_rmesh( const T & orbs, @@ -21,12 +27,6 @@ class Conv_Coulomb_Pot_K double &rmesh_times); private: - - template static T cal_orbs_ccp( - const T &orbs, - const Ccp_Type &ccp_type, - const std::map ¶meter, - const double rmesh_times); template< typename T > static double get_rmesh_proportion( const T &orbs, diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp index ae814adf48..48fb8076ce 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp @@ -529,7 +529,7 @@ ofs_mpi<<"TIME@ Exx_Abfs::Construct_Orbs::abfs\t"<rmesh_times, 1 ); +// Conv_Coulomb_Pot::cal_orbs_ccp( abfs, abfs_ccp, info.ccp_rmesh_times, 1 ); //{ // ofstream ofs("exx_lcao"+TO_STRING(MY_RANK)); // ofs<::type>(exx_lcao.info.hybrid_type)<abfs, Conv_Coulomb_Pot_K::Ccp_Type::Ccp, {}, info.ccp_threshold, this->rmesh_times ); break; + abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp( this->abfs, Conv_Coulomb_Pot_K::Ccp_Type::Ccp, {}, info.ccp_rmesh_times ); break; case Exx_Global::Hybrid_Type::HSE: - abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp_rmesh( this->abfs, Conv_Coulomb_Pot_K::Ccp_Type::Hse, {{"hse_omega",info.hse_omega}}, info.ccp_threshold, this->rmesh_times ); break; + abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp( this->abfs, Conv_Coulomb_Pot_K::Ccp_Type::Hse, {{"hse_omega",info.hse_omega}}, info.ccp_rmesh_times ); break; default: throw domain_error(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; } -ofs_mpi<<"TIME@ Conv_Coulomb_Pot_K::cal_orbs_ccp_rmesh\t"<kmesh_times, (1+this->rmesh_times)/2.0 ); + m_abfs_abfs.init( 2, this->kmesh_times, (1+info.ccp_rmesh_times)/2.0 ); ofs_mpi<<"TIME@ m_abfs_abfs.init\t"<info.distribute_type) { case Exx_Lcao::Distribute_Type::Htime: - atom_pairs_core_origin = Exx_Abfs::Parallel::Distribute::Htime::distribute( Born_von_Karman_period, rmesh_times ); break; + atom_pairs_core_origin = Exx_Abfs::Parallel::Distribute::Htime::distribute( Born_von_Karman_period, info.ccp_rmesh_times ); break; case Exx_Lcao::Distribute_Type::Kmeans2: atom_pairs_core_origin = Exx_Abfs::Parallel::Distribute::Kmeans::distribute_kmeans2( MPI_COMM_WORLD ); break; case Exx_Lcao::Distribute_Type::Kmeans1: - atom_pairs_core_origin = Exx_Abfs::Parallel::Distribute::Kmeans::distribute_kmeans1( MPI_COMM_WORLD, rmesh_times ); break; + atom_pairs_core_origin = Exx_Abfs::Parallel::Distribute::Kmeans::distribute_kmeans1( MPI_COMM_WORLD, info.ccp_rmesh_times ); break; default: throw domain_error(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; //throw domain_error(TO_STRING(static_cast::type>(info.distribute_type))+"\t"+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; @@ -737,7 +736,7 @@ gettimeofday( &t_start, NULL); ofs_mpi<<"TIME@ init_radial_table_ions\t"<> Coulomb_potential_boxes = Abfs::get_Coulomb_potential_boxes(rmesh_times); + vector> Coulomb_potential_boxes = Abfs::get_Coulomb_potential_boxes(info.ccp_rmesh_times); for( const pair & atom_pair : atom_pairs_core ) { const size_t iat1 = atom_pair.first; @@ -1252,7 +1251,7 @@ gettimeofday( &t_start, NULL); const size_t ia2 = ucell.iat2ia[iat2]; const Vector3 &tau1 = ucell.atoms[it1].tau[ia1]; const Vector3 &tau2 = ucell.atoms[it2].tau[ia2]; - const double Rcut = std::min( ORB.Phi[it1].getRcut()*rmesh_times+ORB.Phi[it2].getRcut(), ORB.Phi[it1].getRcut()+ORB.Phi[it2].getRcut()*rmesh_times ); + const double Rcut = std::min( ORB.Phi[it1].getRcut()*info.ccp_rmesh_times+ORB.Phi[it2].getRcut(), ORB.Phi[it1].getRcut()+ORB.Phi[it2].getRcut()*info.ccp_rmesh_times ); for( const Vector3 &box2 : Coulomb_potential_boxes ) { diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.h b/ABACUS.1.0.0/source/src_lcao/exx_lcao.h index f462c4ce70..2b3914d321 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.h +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.h @@ -52,7 +52,6 @@ class Exx_Lcao private: - double rmesh_times; int kmesh_times = 4; // Peize Lin test #if EXX_DM==1 @@ -102,6 +101,7 @@ class Exx_Lcao double schwarz_threshold = 0; double cauchy_threshold = 0; double ccp_threshold = 0; + double ccp_rmesh_times = 10; Exx_Lcao::Distribute_Type distribute_type; From 7cc654057f2d14e6b235999601cfa8bc6fbd42e7 Mon Sep 17 00:00:00 2001 From: linpz Date: Sat, 14 Dec 2019 20:03:50 +0800 Subject: [PATCH 023/233] 1. fix bug in src_lcao/numerical_orbital_lm.cpp --- ABACUS.1.0.0/source/src_lcao/numerical_orbital_lm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ABACUS.1.0.0/source/src_lcao/numerical_orbital_lm.cpp b/ABACUS.1.0.0/source/src_lcao/numerical_orbital_lm.cpp index 1d0680a830..9bd06b47b9 100644 --- a/ABACUS.1.0.0/source/src_lcao/numerical_orbital_lm.cpp +++ b/ABACUS.1.0.0/source/src_lcao/numerical_orbital_lm.cpp @@ -501,7 +501,7 @@ void Numerical_Orbital_Lm::cal_kradial_sbpool(void) const double psi_f_tmp = pref * LapackConnector::dot( this->nr, VECTOR_TO_PTR(r_tmp), 1, VECTOR_TO_PTR(jl[ik]), 1 ) ; this->psif[ik] = psi_f_tmp; this->psik[ik] = psi_f_tmp * k_radial[ik]; - this->psik2[ik] = psi_f_tmp * k_radial[ik]; + this->psik2[ik] = this->psik[ik] * k_radial[ik]; } } From a9c24d897353ffbfd9ea273472b6895711ac3c40 Mon Sep 17 00:00:00 2001 From: linpz Date: Tue, 17 Dec 2019 04:13:37 +0800 Subject: [PATCH 024/233] 1. add exx parallel distribution: Order --- ABACUS.1.0.0/source/Makefile.Objects | 1 + ABACUS.1.0.0/source/input.cpp | 2 +- ABACUS.1.0.0/source/input_conv.cpp | 2 + .../exx_abfs-parallel-distribute-order.cpp | 37 +++++++++++++++++++ .../exx_abfs-parallel-distribute-order.h | 18 +++++++++ .../source/src_lcao/exx_abfs-parallel.h | 1 + ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 3 ++ ABACUS.1.0.0/source/src_lcao/exx_lcao.h | 2 +- 8 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-order.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-order.h diff --git a/ABACUS.1.0.0/source/Makefile.Objects b/ABACUS.1.0.0/source/Makefile.Objects index 528a042039..9fcb679484 100644 --- a/ABACUS.1.0.0/source/Makefile.Objects +++ b/ABACUS.1.0.0/source/Makefile.Objects @@ -195,6 +195,7 @@ exx_abfs-parallel-communicate-hexx.o \ exx_abfs-parallel-communicate-hexx-allreduce.o \ exx_abfs-parallel-distribute-htime.o \ exx_abfs-parallel-distribute-kmeans.o \ +exx_abfs-parallel-distribute-order.o \ exx_abfs-screen-schwarz.o \ exx_abfs-screen-cauchy.o \ exx_lcao.o \ diff --git a/ABACUS.1.0.0/source/input.cpp b/ABACUS.1.0.0/source/input.cpp index ee5ba9b9c6..8b884b8b21 100644 --- a/ABACUS.1.0.0/source/input.cpp +++ b/ABACUS.1.0.0/source/input.cpp @@ -2627,7 +2627,7 @@ void Input::Check(void) { WARNING_QUIT("INPUT","must exx_ccp_rmesh_times >= 1"); } - if(exx_distribute_type!="htime" && exx_distribute_type!="kmeans2" && exx_distribute_type!="kmeans1") + if(exx_distribute_type!="htime" && exx_distribute_type!="kmeans2" && exx_distribute_type!="kmeans1" && exx_distribute_type!="order") { WARNING_QUIT("INPUT","exx_distribute_type must be htime or kmeans2 or kmeans1"); } diff --git a/ABACUS.1.0.0/source/input_conv.cpp b/ABACUS.1.0.0/source/input_conv.cpp index 79d1654de3..f7103866f6 100644 --- a/ABACUS.1.0.0/source/input_conv.cpp +++ b/ABACUS.1.0.0/source/input_conv.cpp @@ -433,6 +433,8 @@ void Input_Conv::Convert(void) exx_lcao.info.distribute_type = Exx_Lcao::Distribute_Type::Kmeans2; else if(INPUT.exx_distribute_type=="kmeans1") exx_lcao.info.distribute_type = Exx_Lcao::Distribute_Type::Kmeans1; + else if(INPUT.exx_distribute_type=="order") + exx_lcao.info.distribute_type = Exx_Lcao::Distribute_Type::Order; Exx_Abfs::Jle::Lmax = INPUT.exx_opt_orb_lmax; Exx_Abfs::Jle::Ecut_exx = INPUT.exx_opt_orb_ecut; Exx_Abfs::Jle::tolerence = INPUT.exx_opt_orb_tolerence; diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-order.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-order.cpp new file mode 100644 index 0000000000..0ce40cd0e3 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-order.cpp @@ -0,0 +1,37 @@ +#include "exx_abfs-parallel-distribute-order.h" + +#include "src_pw/global.h" +#include "src_lcao/abfs.h" +#include + +vector> Exx_Abfs::Parallel::Distribute::Order::distribute( + const double rmesh_times ) +{ + const vector> Coulomb_potential_boxes = Abfs::get_Coulomb_potential_boxes(rmesh_times); + auto neighbour = [&](const size_t iat1, const size_t iat2) -> bool + { + const int it1 = ucell.iat2it[iat1]; + const int it2 = ucell.iat2it[iat2]; + const Vector3 tau1 = ucell.atoms[it1].tau[ucell.iat2ia[iat1]]; + const Vector3 tau2 = ucell.atoms[it2].tau[ucell.iat2ia[iat2]]; + const double Rcut = std::min( ORB.Phi[it1].getRcut()*rmesh_times+ORB.Phi[it2].getRcut(), ORB.Phi[it1].getRcut()+ORB.Phi[it2].getRcut()*rmesh_times ); + for(const Vector3 box2 : Coulomb_potential_boxes) + { + const double R = (-tau1 + tau2 + box2 * ucell.latvec).norm(); + if(R*ucell.lat0 < Rcut) + return true; + } + return false; + }; + + vector> pairs; + for( size_t iat1=0; iat1(pairs.size())/NPROC); + return vector>{ + std::min( pairs.begin()+ MY_RANK *work, pairs.end() ), + std::min( pairs.begin()+(MY_RANK+1)*work, pairs.end() )}; +} \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-order.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-order.h new file mode 100644 index 0000000000..6441ec5972 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-distribute-order.h @@ -0,0 +1,18 @@ +#ifndef EXX_ABFS_PARALLEL_DISTRIBUTE_ORDER_H +#define EXX_ABFS_PARALLEL_DISTRIBUTE_ORDER_H + +#include "exx_abfs-parallel.h" + +#include "src_lcao/abfs.h" + +#include +#include + +class Exx_Abfs::Parallel::Distribute::Order +{ +public: + static vector> distribute( + const double rmesh_times ); +}; + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel.h index 66f570ab2f..28a9579513 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel.h +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel.h @@ -12,6 +12,7 @@ class Exx_Abfs::Parallel public: class Htime; class Kmeans; + class Order; }; class Communicate diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp index 48fb8076ce..43ae8fd90c 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp @@ -18,6 +18,7 @@ #include "exx_abfs-parallel.h" #include "exx_abfs-parallel-distribute-htime.h" #include "exx_abfs-parallel-distribute-kmeans.h" +#include "exx_abfs-parallel-distribute-order.h" #include #include @@ -712,6 +713,8 @@ gettimeofday( &t_start, NULL); atom_pairs_core_origin = Exx_Abfs::Parallel::Distribute::Kmeans::distribute_kmeans2( MPI_COMM_WORLD ); break; case Exx_Lcao::Distribute_Type::Kmeans1: atom_pairs_core_origin = Exx_Abfs::Parallel::Distribute::Kmeans::distribute_kmeans1( MPI_COMM_WORLD, info.ccp_rmesh_times ); break; + case Exx_Lcao::Distribute_Type::Order: + atom_pairs_core_origin = Exx_Abfs::Parallel::Distribute::Order::distribute( info.ccp_rmesh_times ); break; default: throw domain_error(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; //throw domain_error(TO_STRING(static_cast::type>(info.distribute_type))+"\t"+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.h b/ABACUS.1.0.0/source/src_lcao/exx_lcao.h index 2b3914d321..a255080f65 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.h +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.h @@ -45,7 +45,7 @@ class Exx_Lcao void init_radial_table_ions( const set &atom_centres_core, const vector> &atom_pairs_core ); public: - enum class Distribute_Type {Htime,Kmeans2,Kmeans1}; + enum class Distribute_Type {Htime,Kmeans2,Kmeans1,Order}; public: double get_energy() const { return energy; } From 1f5aa90caad5c0d1846cf79c63f9a0a864198626 Mon Sep 17 00:00:00 2001 From: linpz Date: Sun, 22 Dec 2019 05:37:19 +0800 Subject: [PATCH 025/233] 1. add Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2 --- ABACUS.1.0.0/source/Makefile | 4 +- ABACUS.1.0.0/source/Makefile.Objects | 1 + .../source/src_global/global_function.cpp | 26 +- .../source/src_global/global_function.h | 9 + ...s-parallel-communicate-hexx-allreduce2.cpp | 380 ++++++++++++++++++ .../exx_abfs-parallel-communicate-hexx.cpp | 10 +- .../exx_abfs-parallel-communicate-hexx.h | 59 +++ ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 7 +- 8 files changed, 489 insertions(+), 7 deletions(-) create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp diff --git a/ABACUS.1.0.0/source/Makefile b/ABACUS.1.0.0/source/Makefile index 783c422635..80460a3662 100644 --- a/ABACUS.1.0.0/source/Makefile +++ b/ABACUS.1.0.0/source/Makefile @@ -20,7 +20,7 @@ HONG_SER_SELINV = -D__FP ${HONG_FFTW} -D__SELINV HONG_GDB = -g -D__FP ${HONG_FFTW} #(2)mpi HONG_MPI = -D__FP ${HONG_FFTW} -D__MPI -HONG_MPI_SELINV = -D__FP ${HONG_FFTW} -D__MPI -D__SELINV -DMETIS -DMKL_ILP64 -DEXX_DM=2 -DTEST_LIBXC=0 -DTEST_EXX_LCAO=0 -DTEST_EXX_RADIAL=1 +HONG_MPI_SELINV = -D__FP ${HONG_FFTW} -D__MPI -D__SELINV -DMETIS -DMKL_ILP64 -DEXX_DM=2 -DEXX_H_COMM=2 -DTEST_LIBXC=0 -DTEST_EXX_LCAO=0 -DTEST_EXX_RADIAL=1 #(3)memory HONG_MEM = ${HONG_FFTW} -D__FP -D_MCD_CHECK -DWIN32 -DMCD_VERBOSE @@ -61,7 +61,7 @@ PDIAG_OBJS=$(OBJS_PDIAG)\ # MAKING OPTIONS #========================== fp_mpi : ${FP_OBJS} ${PDIAG_MR} ${PDIAG_OBJS} ${HEADERS} - ${CPLUSPLUS_MPI} ${OPTS} ${OPTS_MPI} $(FP_OBJS) ${PDIAG_OBJS} ${PDIAG_MR} ${LIBS} -o ../bin/${VERSION}.mpi.1.0.0_exx + ${CPLUSPLUS_MPI} ${OPTS} ${OPTS_MPI} $(FP_OBJS) ${PDIAG_OBJS} ${PDIAG_MR} ${LIBS} -o ../bin/${VERSION}.mpi.1.0.0_exx_Hmpi fp : ${FP_OBJS} ${HEADERS} ${CPLUSPLUS} ${OPTS} $(FP_OBJS) ${LIBS} -o ${VERSION}.fp.x diff --git a/ABACUS.1.0.0/source/Makefile.Objects b/ABACUS.1.0.0/source/Makefile.Objects index 9fcb679484..20cb6e6137 100644 --- a/ABACUS.1.0.0/source/Makefile.Objects +++ b/ABACUS.1.0.0/source/Makefile.Objects @@ -193,6 +193,7 @@ exx_abfs-parallel-communicate-dm-allreduce.o \ exx_abfs-parallel-communicate-dm2.o \ exx_abfs-parallel-communicate-hexx.o \ exx_abfs-parallel-communicate-hexx-allreduce.o \ +exx_abfs-parallel-communicate-hexx-allreduce2.o \ exx_abfs-parallel-distribute-htime.o \ exx_abfs-parallel-distribute-kmeans.o \ exx_abfs-parallel-distribute-order.o \ diff --git a/ABACUS.1.0.0/source/src_global/global_function.cpp b/ABACUS.1.0.0/source/src_global/global_function.cpp index d7edd6792a..f7197aa671 100644 --- a/ABACUS.1.0.0/source/src_global/global_function.cpp +++ b/ABACUS.1.0.0/source/src_global/global_function.cpp @@ -23,7 +23,7 @@ using namespace std; //========================================================== void TITLE(const string &class_function_name) { - return;//no output +// return;//no output cout<<" ==> "< "<>label>>size>>kB; + if(label=="MemAvailable:") + return std::stol(size); + else if(label=="MemFree:" || label=="Buffers:" || label=="Cached:") + { + mem_sum += std::stol(size); + ++i; + } + if(i==3) + return mem_sum; + } + throw runtime_error("read /proc/meminfo error in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); +} \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_global/global_function.h b/ABACUS.1.0.0/source/src_global/global_function.h index 7d9775a5a5..17f3d51c01 100644 --- a/ABACUS.1.0.0/source/src_global/global_function.h +++ b/ABACUS.1.0.0/source/src_global/global_function.h @@ -261,4 +261,13 @@ inline const void* MAP_EXIST( const T_map &ms, const T_key1 &key1, const T_key_t return MAP_EXIST( ms1->second, key_tail... ); } +//========================================================== +// GLOBAL FUNCTION : +// NAME : MemAvailable +// read /proc/meminfo +// unit: kB +// Peize Lin add 2019-12-21 +//========================================================== +size_t MemAvailable(); + #endif diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp new file mode 100644 index 0000000000..a73845e525 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp @@ -0,0 +1,380 @@ +#include "exx_abfs-parallel-communicate-hexx.h" +#include "src_global/boost_serialization.h" + +#include "src_pw/global.h" +#include "src_lcao/global_fp.h" + +#include +#include + + +#include "src_external/src_test/test_function.h" + +void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::init( + const MPI_Comm &mpi_comm_in, + const set> &H_atom_pairs_core) +{ + TITLE("Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::init"); + + mpi_comm = mpi_comm_in; + MPI_Comm_size(mpi_comm, &comm_sz); + MPI_Comm_rank(mpi_comm, &my_rank); + + atom_in_2D_list = get_atom_in_2D_list(); + send_size_list = get_send_size_list(H_atom_pairs_core, atom_in_2D_list); + recv_size = ParaO.nrow * ParaO.ncol * sizeof(double); +} + +vector,matrix>>>> +Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::exx_to_a2D( + vector,matrix>>>> &data_local) +{ +ofstream ofs("Hmpi_"+TO_STRING(my_rank)); + + TITLE("Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::exx_to_a2D"); + + vector,matrix>>>> data_all(NSPIN); +ofs<<__LINE__<> flags_send(comm_sz); + vector> flags_recv(comm_sz); + init_elec(flags_send, flags_recv); +ofs<<__LINE__< oarps_isend(comm_sz,nullptr); + vector iarps_irecv(comm_sz,nullptr); +ofs<<__LINE__<int{ return (rank_send_now+1)%comm_sz; }; +ofs<<__LINE__< threads; + vectorrequests_isend(comm_sz); + vectorrequests_irecv(comm_sz); +ofs<<__LINE__<address(), oarps_isend[rank_send]->size(), MPI_PACKED, rank_send, 0, mpi_comm, &requests_isend[rank_send] )!=MPI_SUCCESS) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + flags_send[rank_send] = Flag_Send::begin_isend; + } + } + for(int rank_send=0; rank_send!=comm_sz; ++rank_send) + { + if( flags_send[rank_send] == Flag_Send::begin_isend ) + { +ofs<<__LINE__<<"\t"<resize(message_size); + if(MPI_Irecv( iarps_irecv[rank_recv]->address(), message_size, MPI_PACKED, rank_recv, 0, mpi_comm, &requests_irecv[rank_recv] )!=MPI_SUCCESS) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + flags_recv[rank_recv] = Flag_Recv::begin_irecv; + } + } + for(int rank_recv=0; rank_recv!=comm_sz; ++rank_recv) + { + if(flags_recv[rank_recv] == Flag_Recv::begin_irecv) + { + int flag_finish; + if(MPI_Test( &requests_irecv[rank_recv], &flag_finish, MPI_STATUS_IGNORE )!=MPI_SUCCESS) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + if(flag_finish) + { +ofs<<__LINE__<<"\t"<,vector>> +Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::get_atom_in_2D_list() const +{ + TITLE("Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::get_atom_in_2D_list"); + + bool atom_in_2D[ucell.nat*2]; + for(int i=0; i=0 ) + atom_in_2D[iat] = true; + if( ParaO.trace_loc_col[iwt]>=0 ) + atom_in_2D[ucell.nat+iat] = true; + } + + bool atom_in_2D_list_tmp[ucell.nat*2*comm_sz]; + if(MPI_Allgather( atom_in_2D, ucell.nat*2, MPI_BYTE, atom_in_2D_list_tmp, ucell.nat*2, MPI_BYTE, mpi_comm )!=MPI_SUCCESS) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + + vector,vector>> atom_in_2D_list(comm_sz, {vector(ucell.nat),vector(ucell.nat)}); + for(int rank=0; rank Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::get_send_size_list( + const set> &H_atom_pairs_core, + const vector,vector>> &atom_in_2D_list) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::get_send_size_list"); + vector send_size_list(comm_sz,0); + for(const auto &H_atom_pair : H_atom_pairs_core) + { + const size_t iat1 = H_atom_pair.first; + const size_t iat2 = H_atom_pair.second; + for(int rank_send=0; rank_send> &flags_send, + vector> &flags_recv) +{ + for(atomic &flag_send : flags_send) + flag_send = Flag_Send::undo; + flags_send[my_rank] = Flag_Send::finish_isend; + + for(atomic &flag_recv : flags_recv) + flag_recv = Flag_Recv::undo; + flags_recv[my_rank] = Flag_Recv::finish_iar; +} + +bool Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::finish_judge( + const vector> &flags_send, + const vector> &flags_recv) const +{ + for(int rank_send=0; rank_send!=comm_sz; ++rank_send) + if((flags_send[rank_send]!=Flag_Send::begin_isend) && (flags_send[rank_send]!=Flag_Send::finish_isend)) + return false; + for(int rank_recv=0; rank_recv!=comm_sz; ++rank_recv) + if(flags_recv[rank_recv]!=Flag_Recv::finish_iar) + return false; + return true; +} + +void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::send_data_process( + const int rank_send_now, + const vector,matrix>>>> &data_local, + vector &oarps_isend, + vector> &flags_send) +{ + const vector,Matrix_Wrapper>>>> + matrix_wrapped = get_data_local_wrapper(rank_send_now, data_local); + oarps_isend[rank_send_now] = new boost::mpi::packed_oarchive(MPI_COMM_WORLD); + *oarps_isend[rank_send_now] << matrix_wrapped; + flags_send[rank_send_now] = Flag_Send::finish_oar; +} + +void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::recv_data_process( + const int rank_recv, + vector,matrix>>>> &data_all, + vector &iarps_irecv, + vector> &flags_recv, + atomic_flag &lock_insert) +{ + auto vector_empty = []( const vector,Matrix_Wrapper>>>> & v ) -> bool + { + for( const auto &i : v ) + if(!i.empty()) return false; + return true; + }; + + vector,Matrix_Wrapper>>>> data_rank; + *iarps_irecv[rank_recv] >> data_rank; + delete iarps_irecv[rank_recv]; iarps_irecv[rank_recv]=nullptr; + flags_recv[rank_recv] = Flag_Recv::finish_iar; + + if(!vector_empty(data_rank)) + { + while( lock_insert.test_and_set() ); + insert_data(data_rank, data_all); + lock_insert.clear(); + } + + #ifdef MATRIX_WRAPPER_TIANHE2 + for( auto &data_rank_is : data_rank ) + for( auto &data_rank_A : data_rank_is ) + for( auto &data_rank_B : data_rank_A.second ) + for( auto &data_rank_C : data_rank_B.second ) + if(!data_rank_C.second.c) + delete[] data_rank_C.second.c; + #endif +} + + +bool Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::memory_enough( + const int rank_send_next, + const vector> &flags_send) const +{ + size_t memory_need = recv_size; + for(int rank_send=0; rank_sendsend_size_list[rank_send_next]) ? true : false; +} + +vector,Matrix_Wrapper>>>> +Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::get_data_local_wrapper( + const int rank_send_now, + const vector,matrix>>>> &data_local) const +{ + vector,Matrix_Wrapper>>>> mw(NSPIN); + for( int is=0; is!=NSPIN; ++is ) + { + auto &data_local_is = data_local[is]; + auto &mw_is = mw[is]; + for( auto &data_local_A : data_local_is ) + { + const size_t iat1 = data_local_A.first; + if( !atom_in_2D_list[rank_send_now].first[iat1] ) continue; + auto &mw_A = mw_is[iat1]; + for( auto &data_local_B : data_local_A.second ) + { + const size_t iat2 = data_local_B.first; + if( !atom_in_2D_list[rank_send_now].second[iat2] ) continue; + auto &mw_B = mw_A[iat2]; + for( auto &data_local_C : data_local_B.second ) + { + const Abfs::Vector3_Order &box2 = data_local_C.first; + mw_B[box2] = data_local_C.second; + } + } + } + } + return mw; +} + +void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::insert_data( + vector,matrix>>>> &data_local, + vector,matrix>>>> &data_all) +{ + for( int is=0; is!=NSPIN; ++is ) + { + auto &data_local_is = data_local[is]; + auto &data_all_is = data_all[is]; + for( auto &data_local_A : data_local_is ) + { + const size_t iat1 = data_local_A.first; + if( !atom_in_2D_list[my_rank].first[iat1] ) continue; + auto &data_all_A = data_all_is[iat1]; + for( auto &data_local_B : data_local_A.second ) + { + const size_t iat2 = data_local_B.first; + if( !atom_in_2D_list[my_rank].second[iat2] ) continue; + auto &data_all_B = data_all_A[iat2]; + for( auto &data_local_C : data_local_B.second ) + { + const Abfs::Vector3_Order &box2 = data_local_C.first; + auto &data_all_C = data_all_B[box2]; + if( data_all_C.c ) + data_all_C += data_local_C.second; + else + data_all_C = std::move(data_local_C.second); + } + } + } + } +} + +void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::insert_data( + vector,Matrix_Wrapper>>>> &data_rank, + vector,matrix>>>> &data_all) +{ + for( int is=0; is!=NSPIN; ++is ) + { + auto &data_rank_is = data_rank[is]; + auto &data_all_is = data_all[is]; + for( auto &data_rank_A : data_rank_is ) + { + const size_t iat1 = data_rank_A.first; + auto &data_all_A = data_all_is[iat1]; + for( auto &data_rank_B : data_rank_A.second ) + { + const size_t iat2 = data_rank_B.first; + auto &data_all_B = data_all_A[iat2]; + for( auto &data_rank_C : data_rank_B.second ) + { + const Abfs::Vector3_Order &box2 = data_rank_C.first; + auto &data_all_C = data_all_B[box2]; + if(data_all_C.c) + data_all_C += data_rank_C.second.to_matrix(); + else + data_all_C = data_rank_C.second.to_matrix(); + } + } + } + } +} diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp index ebc9ab2b5d..b472a6be6f 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp @@ -30,8 +30,14 @@ void Exx_Abfs::Parallel::Communicate::Hexx::Rexx_to_Km2D( global_out_dir+"HR_exx_"+TO_STRING(MY_RANK)); else { - Allreduce allreduce(MPI_COMM_WORLD,HR_exx); - HR_a2D = allreduce.exx_to_a2D(); + #if EXX_H_COMM==1 + Allreduce allreduce(MPI_COMM_WORLD,HR_exx); + HR_a2D = allreduce.exx_to_a2D(); + #elif EXX_H_COMM==2 + HR_a2D = allreduce2.exx_to_a2D(HR_exx); + #else + #error "EXX_H_COMM" + #endif } if(io_HR_a2D.second) Exx_Abfs::IO::output_binary( HR_a2D, global_out_dir+"HR_exx_"+TO_STRING(MY_RANK) ); diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.h index 4e6ba25205..d95602f821 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.h +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.h @@ -76,6 +76,63 @@ class Exx_Abfs::Parallel::Communicate::Hexx vector*> flags_ask_atom; boost::dynamic_bitset<> flags_recv_data; }; + + class Allreduce2 + { + public: + void init( + const MPI_Comm &mpi_comm_in, + const set> &H_atom_pairs_core); + vector,matrix>>>> exx_to_a2D( + vector,matrix>>>> &data_local); + + private: + enum class Flag_Send {undo, begin_oar, finish_oar, begin_isend, finish_isend}; + enum class Flag_Recv {undo, begin_irecv, begin_iar, finish_iar}; + + vector,vector>> get_atom_in_2D_list() const; + vector get_send_size_list( + const set> &H_atom_pairs_core, + const vector,vector>> &atom_in_2D_list) const; + void init_elec( + vector> &flags_send, + vector> &flags_recv); + void send_data_process( + const int rank_send_now, + const vector,matrix>>>> &data_local, + vector &oarps_isend, + vector> &flags_send); + void recv_data_process( + const int rank_recv, + vector,matrix>>>> &data_all, + vector &iarps_irecv, + vector> &flags_recv, + atomic_flag &lock_insert); + bool finish_judge( + const vector> &flags_send, + const vector> &flags_recv) const; + bool memory_enough( + const int rank_send_next, + const vector> &flags_send) const; + vector,Matrix_Wrapper>>>> get_data_local_wrapper( + const int rank_send_now, + const vector,matrix>>>> &data_local) const; + void insert_data( + vector,matrix>>>> &data_local, + vector,matrix>>>> &data_all); + void insert_data( + vector,Matrix_Wrapper>>>> &data_rank, + vector,matrix>>>> &data_all); + + private: + MPI_Comm mpi_comm; + int comm_sz; + int my_rank; + + vector,vector>> atom_in_2D_list; + vector send_size_list; + size_t recv_size; + }; public: vector HK_Gamma_m2D; @@ -86,6 +143,8 @@ class Exx_Abfs::Parallel::Communicate::Hexx enum class Mixing_Mode{ No, Plain, Pulay }; Mixing_Mode mixing_mode; double mixing_beta; + + Allreduce2 allreduce2; }; #endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp index 43ae8fd90c..6a0f4a4985 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp @@ -475,12 +475,13 @@ gettimeofday( &t_start, NULL); this->lcaos = Exx_Abfs::Construct_Orbs::change_orbs( ORB, this->kmesh_times ); ofs_mpi<<"TIME@ Exx_Abfs::Construct_Orbs::change_orbs\t"<>> abfs_same_atom = Exx_Abfs::Construct_Orbs::abfs_same_atom( lcaos, this->kmesh_times, info.pca_threshold ); // Peize Lin test -ofs_mpi<abfs = abfs_same_atom; else @@ -778,6 +779,10 @@ ofs_mpi<<"TIME@ cauchy::init\t"< Date: Fri, 3 Jan 2020 01:27:54 +0800 Subject: [PATCH 026/233] 1. update Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2 1.1 src_lcao/exx_abfs-parallel-communicate-hexx.h 1.2 src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp 1.3 src_global/global_function.h --- .../source/src_global/global_function.h | 11 + ...s-parallel-communicate-hexx-allreduce2.cpp | 235 +++++++++--------- .../exx_abfs-parallel-communicate-hexx.h | 35 ++- 3 files changed, 149 insertions(+), 132 deletions(-) diff --git a/ABACUS.1.0.0/source/src_global/global_function.h b/ABACUS.1.0.0/source/src_global/global_function.h index 17f3d51c01..6615025acc 100644 --- a/ABACUS.1.0.0/source/src_global/global_function.h +++ b/ABACUS.1.0.0/source/src_global/global_function.h @@ -7,6 +7,7 @@ #define GLOBAL_FUNCTION_H #include +#include #include #include #include @@ -199,12 +200,22 @@ static inline T * VECTOR_TO_PTR( std::vector & v ) { return &(v[0]); } +template +static inline T * VECTOR_TO_PTR( std::valarray & v ) +{ + return &(v[0]); +} template static inline const T * VECTOR_TO_PTR( const std::vector & v ) { return &(v[0]); } +template +static inline const T * VECTOR_TO_PTR( const std::valarray & v ) +{ + return &(v[0]); +} //========================================================== // GLOBAL FUNCTION : diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp index a73845e525..1149508895 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp @@ -1,5 +1,4 @@ #include "exx_abfs-parallel-communicate-hexx.h" -#include "src_global/boost_serialization.h" #include "src_pw/global.h" #include "src_lcao/global_fp.h" @@ -27,41 +26,44 @@ void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::init( vector,matrix>>>> Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::exx_to_a2D( - vector,matrix>>>> &data_local) + vector,matrix>>>> &data_local) const { -ofstream ofs("Hmpi_"+TO_STRING(my_rank)); +ofstream ofs(exx_lcao.test_dir.process+"Hmpi_"+TO_STRING(my_rank), ofstream::app); +timeval t_all; gettimeofday(&t_all,NULL); TITLE("Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::exx_to_a2D"); vector,matrix>>>> data_all(NSPIN); -ofs<<__LINE__<> flags_send(comm_sz); vector> flags_recv(comm_sz); init_elec(flags_send, flags_recv); -ofs<<__LINE__< oarps_isend(comm_sz,nullptr); - vector iarps_irecv(comm_sz,nullptr); -ofs<<__LINE__<> oarps_isend(comm_sz); + vector> iarps_irecv(comm_sz); +//ofs<<__LINE__<int{ return (rank_send_now+1)%comm_sz; }; -ofs<<__LINE__< threads; vectorrequests_isend(comm_sz); vectorrequests_irecv(comm_sz); -ofs<<__LINE__<t_send(comm_sz); +vectort_recv(comm_sz); while(!finish_judge(flags_send, flags_recv)) { -ofs<<__LINE__<address(), oarps_isend[rank_send]->size(), MPI_PACKED, rank_send, 0, mpi_comm, &requests_isend[rank_send] )!=MPI_SUCCESS) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); +//ofs<<__LINE__<<"\t"<resize(message_size); - if(MPI_Irecv( iarps_irecv[rank_recv]->address(), message_size, MPI_PACKED, rank_recv, 0, mpi_comm, &requests_irecv[rank_recv] )!=MPI_SUCCESS) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); +//ofs<<__LINE__<<"\t"< Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::get_send_size_ void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::init_elec( vector> &flags_send, - vector> &flags_recv) + vector> &flags_recv) const { for(atomic &flag_send : flags_send) flag_send = Flag_Send::undo; @@ -219,61 +230,11 @@ bool Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::finish_judge( if((flags_send[rank_send]!=Flag_Send::begin_isend) && (flags_send[rank_send]!=Flag_Send::finish_isend)) return false; for(int rank_recv=0; rank_recv!=comm_sz; ++rank_recv) - if(flags_recv[rank_recv]!=Flag_Recv::finish_iar) + if((flags_recv[rank_recv]!=Flag_Recv::begin_iar) && (flags_recv[rank_recv]!=Flag_Recv::finish_iar)) return false; return true; } -void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::send_data_process( - const int rank_send_now, - const vector,matrix>>>> &data_local, - vector &oarps_isend, - vector> &flags_send) -{ - const vector,Matrix_Wrapper>>>> - matrix_wrapped = get_data_local_wrapper(rank_send_now, data_local); - oarps_isend[rank_send_now] = new boost::mpi::packed_oarchive(MPI_COMM_WORLD); - *oarps_isend[rank_send_now] << matrix_wrapped; - flags_send[rank_send_now] = Flag_Send::finish_oar; -} - -void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::recv_data_process( - const int rank_recv, - vector,matrix>>>> &data_all, - vector &iarps_irecv, - vector> &flags_recv, - atomic_flag &lock_insert) -{ - auto vector_empty = []( const vector,Matrix_Wrapper>>>> & v ) -> bool - { - for( const auto &i : v ) - if(!i.empty()) return false; - return true; - }; - - vector,Matrix_Wrapper>>>> data_rank; - *iarps_irecv[rank_recv] >> data_rank; - delete iarps_irecv[rank_recv]; iarps_irecv[rank_recv]=nullptr; - flags_recv[rank_recv] = Flag_Recv::finish_iar; - - if(!vector_empty(data_rank)) - { - while( lock_insert.test_and_set() ); - insert_data(data_rank, data_all); - lock_insert.clear(); - } - - #ifdef MATRIX_WRAPPER_TIANHE2 - for( auto &data_rank_is : data_rank ) - for( auto &data_rank_A : data_rank_is ) - for( auto &data_rank_B : data_rank_A.second ) - for( auto &data_rank_C : data_rank_B.second ) - if(!data_rank_C.second.c) - delete[] data_rank_C.second.c; - #endif -} - - bool Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::memory_enough( const int rank_send_next, const vector> &flags_send) const @@ -286,14 +247,19 @@ bool Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::memory_enough( return (memory_available-memory_need>send_size_list[rank_send_next]) ? true : false; } -vector,Matrix_Wrapper>>>> -Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::get_data_local_wrapper( +void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::send_data_process( const int rank_send_now, - const vector,matrix>>>> &data_local) const + const vector,matrix>>>> &data_local, + vector> &oarps_isend, + vector> &flags_send) const { - vector,Matrix_Wrapper>>>> mw(NSPIN); +ofstream ofs(exx_lcao.test_dir.process+"Hmpi_"+TO_STRING(my_rank), ofstream::app); +timeval t; gettimeofday(&t, NULL); + valarray send_size(NSPIN); + vector,const matrix*>>>> mw(NSPIN); for( int is=0; is!=NSPIN; ++is ) { + send_size[is]=0; auto &data_local_is = data_local[is]; auto &mw_is = mw[is]; for( auto &data_local_A : data_local_is ) @@ -309,49 +275,92 @@ Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::get_data_local_wrapper( for( auto &data_local_C : data_local_B.second ) { const Abfs::Vector3_Order &box2 = data_local_C.first; - mw_B[box2] = data_local_C.second; + mw_B[box2] = &data_local_C.second; + send_size[is] += 7 + data_local_C.second.nr * data_local_C.second.nc; } } } } - return mw; -} - -void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::insert_data( - vector,matrix>>>> &data_local, - vector,matrix>>>> &data_all) -{ +ofs<<"get_send_data_wrapper\t"< &box2 = data_local_C.first; - auto &data_all_C = data_all_B[box2]; - if( data_all_C.c ) - data_all_C += data_local_C.second; - else - data_all_C = std::move(data_local_C.second); + ptr[0] = mw_A.first; + ptr[1] = mw_B.first; + ptr[2] = mw_C.first.x; ptr[3] = mw_C.first.y; ptr[4] = mw_C.first.z; + const matrix &m = *mw_C.second; + ptr[5] = m.nr; ptr[6] = m.nc; + memcpy( ptr+7, m.c, m.nr*m.nc*sizeof(double) ); + ptr += 7+m.nr*m.nc; } } } } + flags_send[rank_send_now] = Flag_Send::finish_oar; +ofs<<"oar<<\t"<,matrix>>>> &data_all, + vector> &iarps_irecv, + vector> &flags_recv, + atomic_flag &lock_insert) const +{ +ofstream ofs(exx_lcao.test_dir.process+"Hmpi_"+TO_STRING(my_rank), ofstream::app); +timeval t; gettimeofday(&t, NULL); + auto vector_empty = []( const vector,matrix>>>> &v ) -> bool + { + for( const auto &i : v ) + if(!i.empty()) return false; + return true; + }; + + vector,matrix>>>> data_rank(NSPIN); + double *ptr = VECTOR_TO_PTR(iarps_irecv[rank_recv]); + for( int is=0; is!=NSPIN; ++is ) + { + const size_t recv_size = ptr[0]; + ptr += 1; + const double * const ptr_end = ptr + recv_size; + while(ptr box2 = {ptr[2],ptr[3],ptr[4]}; + const int nr=ptr[5], nc=ptr[6]; + matrix &m = data_rank[is][iat1][iat2][box2]; + m.create(nr,nc); + memcpy( m.c, ptr+7, nr*nc*sizeof(double) ); + ptr += 7+nr*nc; + } + } + iarps_irecv[rank_recv].resize(0); + flags_recv[rank_recv] = Flag_Recv::finish_iar; +ofs<<"iar>>\t"<,Matrix_Wrapper>>>> &data_rank, - vector,matrix>>>> &data_all) + vector,matrix>>>> &data_rank, + vector,matrix>>>> &data_all) const { for( int is=0; is!=NSPIN; ++is ) { @@ -360,21 +369,23 @@ void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::insert_data( for( auto &data_rank_A : data_rank_is ) { const size_t iat1 = data_rank_A.first; + if( !atom_in_2D_list[my_rank].first[iat1] ) continue; auto &data_all_A = data_all_is[iat1]; for( auto &data_rank_B : data_rank_A.second ) { const size_t iat2 = data_rank_B.first; + if( !atom_in_2D_list[my_rank].second[iat2] ) continue; auto &data_all_B = data_all_A[iat2]; for( auto &data_rank_C : data_rank_B.second ) { const Abfs::Vector3_Order &box2 = data_rank_C.first; auto &data_all_C = data_all_B[box2]; - if(data_all_C.c) - data_all_C += data_rank_C.second.to_matrix(); + if( data_all_C.c ) + data_all_C += data_rank_C.second; else - data_all_C = data_rank_C.second.to_matrix(); + data_all_C = std::move(data_rank_C.second); } } } } -} +} \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.h index d95602f821..48f64cc259 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.h +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.h @@ -7,6 +7,7 @@ #include "src_global/complexmatrix.h" #include "src_lcao/abfs-vector3_order.h" #include +#include #include #include #include @@ -84,7 +85,7 @@ class Exx_Abfs::Parallel::Communicate::Hexx const MPI_Comm &mpi_comm_in, const set> &H_atom_pairs_core); vector,matrix>>>> exx_to_a2D( - vector,matrix>>>> &data_local); + vector,matrix>>>> &data_local) const; private: enum class Flag_Send {undo, begin_oar, finish_oar, begin_isend, finish_isend}; @@ -96,33 +97,27 @@ class Exx_Abfs::Parallel::Communicate::Hexx const vector,vector>> &atom_in_2D_list) const; void init_elec( vector> &flags_send, - vector> &flags_recv); - void send_data_process( - const int rank_send_now, - const vector,matrix>>>> &data_local, - vector &oarps_isend, - vector> &flags_send); - void recv_data_process( - const int rank_recv, - vector,matrix>>>> &data_all, - vector &iarps_irecv, - vector> &flags_recv, - atomic_flag &lock_insert); + vector> &flags_recv) const; bool finish_judge( const vector> &flags_send, const vector> &flags_recv) const; bool memory_enough( const int rank_send_next, const vector> &flags_send) const; - vector,Matrix_Wrapper>>>> get_data_local_wrapper( + void send_data_process( const int rank_send_now, - const vector,matrix>>>> &data_local) const; - void insert_data( - vector,matrix>>>> &data_local, - vector,matrix>>>> &data_all); + const vector,matrix>>>> &data_local, + vector> &oars_isend, + vector> &flags_send) const; + void recv_data_process( + const int rank_recv, + vector,matrix>>>> &data_all, + vector> &iarps_irecv, + vector> &flags_recv, + atomic_flag &lock_insert) const; void insert_data( - vector,Matrix_Wrapper>>>> &data_rank, - vector,matrix>>>> &data_all); + vector,matrix>>>> &data_rank, + vector,matrix>>>> &data_all) const; private: MPI_Comm mpi_comm; From aec0699242814d2428f5c228e8e51f396dd6b45e Mon Sep 17 00:00:00 2001 From: linpz Date: Tue, 7 Jan 2020 17:40:19 +0800 Subject: [PATCH 027/233] 1. some small function updates 1.1 source/src_lcao/exx_abfs-parallel-distribute-htime.cpp 1.2 tools/SIAB-v2/1_Source_CXX11/src_spillage/main.cpp --- ABACUS.1.0.0/source/src_global/global_function.cpp | 4 ++-- .../src_lcao/exx_abfs-parallel-distribute-htime.cpp | 8 ++++---- .../tools/SIAB-v2/1_Source_CXX11/src_spillage/main.cpp | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ABACUS.1.0.0/source/src_global/global_function.cpp b/ABACUS.1.0.0/source/src_global/global_function.cpp index f7197aa671..f45daffa20 100644 --- a/ABACUS.1.0.0/source/src_global/global_function.cpp +++ b/ABACUS.1.0.0/source/src_global/global_function.cpp @@ -23,7 +23,7 @@ using namespace std; //========================================================== void TITLE(const string &class_function_name) { -// return;//no output + return;//no output cout<<" ==> "< "<> Exx_Abfs::Parallel::Distribute::Htime::distribute( //ofstream ofs("htime_"+TO_STRING(MY_RANK)); //ofs< Nadj = cal_Nadj(Born_von_Karman_period); //ofs<> Exx_Abfs::Parallel::Distribute::Htime::distribute( vector Exx_Abfs::Parallel::Distribute::Htime::cal_Nadj( const Abfs::Vector3_Order & Born_von_Karman_period ) { - TITLE("Exx_Abfs::Parallel::cal_Nadj"); + TITLE("Exx_Abfs::Parallel::Distribute::Htime::cal_Nadj"); vector Nadj(ucell.nat); for( size_t iat=0; iat!=ucell.nat; ++iat ) { @@ -52,7 +52,7 @@ vector>> Exx_Abfs::Parallel::Distribute::Htime:: const vector &Nadj, const double rmesh_times ) { - TITLE("Exx_Abfs::Parallel::cal_pair_costs"); + TITLE("Exx_Abfs::Parallel::Distribute::Htime::cal_pair_costs"); const vector> Coulomb_potential_boxes = Abfs::get_Coulomb_potential_boxes(rmesh_times); auto neighbour = [&](const size_t iat1, const size_t iat2) -> int @@ -92,7 +92,7 @@ vector>> Exx_Abfs::Parallel::Distribute::Htime:: vector>> Exx_Abfs::Parallel::Distribute::Htime::cal_rank_work( const vector>> & pair_costs ) { - TITLE("Exx_Abfs::Parallel::cal_rank_work"); + TITLE("Exx_Abfs::Parallel::Distribute::Htime::cal_rank_work"); vector> rank_cost(NPROC); // rank_cost[i] = { irank, cost } for( size_t irank=0; irank!=NPROC; ++irank ) rank_cost[irank] = { irank, 0 }; diff --git a/ABACUS.1.0.0/tools/SIAB-v2/1_Source_CXX11/src_spillage/main.cpp b/ABACUS.1.0.0/tools/SIAB-v2/1_Source_CXX11/src_spillage/main.cpp index 5b9a271258..a5033b34f1 100644 --- a/ABACUS.1.0.0/tools/SIAB-v2/1_Source_CXX11/src_spillage/main.cpp +++ b/ABACUS.1.0.0/tools/SIAB-v2/1_Source_CXX11/src_spillage/main.cpp @@ -16,6 +16,7 @@ int main(int argc, char **argv) time_t time_start = time(NULL); timer::start(); cout <<" Start Time : " << ctime(&time_start); + std::srand(std::time(nullptr)); // (2) if parallel, prepare. cout << " First read in the parameters from INPUT." << endl; From fd145ff7367e1245f00b76250928f9b4a016767c Mon Sep 17 00:00:00 2001 From: linpz Date: Tue, 21 Jan 2020 23:01:02 +0800 Subject: [PATCH 028/233] 1. fix bug of pca 1.1 src_lcao/exx_abfs-pca.cpp --- ABACUS.1.0.0/source/src_lcao/exx_abfs-pca.cpp | 3 ++- ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-pca.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-pca.cpp index aaca74a6b8..a39101b3a4 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-pca.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-pca.cpp @@ -78,7 +78,8 @@ ofs< Date: Sat, 29 Feb 2020 03:37:17 +0800 Subject: [PATCH 029/233] 1. remove calling boost_serialization and boost_mpi 1.1 src_lcao/exx_abfs-util.h 1.2 src_lcao/exx_abfs-util.cpp 1.3 Makefile 1.4 Makefile.Objects 1.5 Makefile.system 1.6 src_lcao/exx_abfs.h 1.7 src_lcao/exx_abfs-io.h 1.8 src_lcao/exx_abfs-io.cpp 1.9 src_lcao/exx_abfs-parallel.h 1.10 src_lcao/exx_abfs-parallel-communicate-hexx.h 1.11 src_lcao/exx_abfs-parallel-communicate-hexx.cpp 1.12 src_lcao/exx_lcao.h 1.13 src_lcao/exx_lcao.cpp --- ABACUS.1.0.0/source/Makefile | 2 +- ABACUS.1.0.0/source/Makefile.Objects | 5 +-- ABACUS.1.0.0/source/Makefile.system | 6 +-- ABACUS.1.0.0/source/src_lcao/exx_abfs-io.cpp | 8 ++-- ABACUS.1.0.0/source/src_lcao/exx_abfs-io.h | 2 + .../exx_abfs-parallel-communicate-hexx.cpp | 22 ++++++++-- .../exx_abfs-parallel-communicate-hexx.h | 4 +- .../source/src_lcao/exx_abfs-parallel.h | 3 ++ .../source/src_lcao/exx_abfs-util.cpp | 42 +++++++++++++++++++ ABACUS.1.0.0/source/src_lcao/exx_abfs-util.h | 15 +++++++ ABACUS.1.0.0/source/src_lcao/exx_abfs.h | 1 + ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 5 ++- ABACUS.1.0.0/source/src_lcao/exx_lcao.h | 8 +++- 13 files changed, 102 insertions(+), 21 deletions(-) create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-util.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-util.h diff --git a/ABACUS.1.0.0/source/Makefile b/ABACUS.1.0.0/source/Makefile index 80460a3662..7fbbe4e215 100644 --- a/ABACUS.1.0.0/source/Makefile +++ b/ABACUS.1.0.0/source/Makefile @@ -61,7 +61,7 @@ PDIAG_OBJS=$(OBJS_PDIAG)\ # MAKING OPTIONS #========================== fp_mpi : ${FP_OBJS} ${PDIAG_MR} ${PDIAG_OBJS} ${HEADERS} - ${CPLUSPLUS_MPI} ${OPTS} ${OPTS_MPI} $(FP_OBJS) ${PDIAG_OBJS} ${PDIAG_MR} ${LIBS} -o ../bin/${VERSION}.mpi.1.0.0_exx_Hmpi + ${CPLUSPLUS_MPI} ${OPTS} ${OPTS_MPI} $(FP_OBJS) ${PDIAG_OBJS} ${PDIAG_MR} ${LIBS} -o ../bin/${VERSION}.mpi.1.0.0_exx_noboost fp : ${FP_OBJS} ${HEADERS} ${CPLUSPLUS} ${OPTS} $(FP_OBJS) ${LIBS} -o ${VERSION}.fp.x diff --git a/ABACUS.1.0.0/source/Makefile.Objects b/ABACUS.1.0.0/source/Makefile.Objects index 20cb6e6137..9b59607d13 100644 --- a/ABACUS.1.0.0/source/Makefile.Objects +++ b/ABACUS.1.0.0/source/Makefile.Objects @@ -187,16 +187,13 @@ exx_abfs-matrix_orbs21.o \ exx_abfs-matrix_orbs22.o \ exx_abfs-matrix_lcaoslcaos_lcaoslcaos.o \ exx_abfs-pca.o \ -exx_abfs-parallel-communicate-allreduce.o \ -exx_abfs-parallel-communicate-dm.o \ -exx_abfs-parallel-communicate-dm-allreduce.o \ exx_abfs-parallel-communicate-dm2.o \ exx_abfs-parallel-communicate-hexx.o \ -exx_abfs-parallel-communicate-hexx-allreduce.o \ exx_abfs-parallel-communicate-hexx-allreduce2.o \ exx_abfs-parallel-distribute-htime.o \ exx_abfs-parallel-distribute-kmeans.o \ exx_abfs-parallel-distribute-order.o \ +exx_abfs-util.o \ exx_abfs-screen-schwarz.o \ exx_abfs-screen-cauchy.o \ exx_lcao.o \ diff --git a/ABACUS.1.0.0/source/Makefile.system b/ABACUS.1.0.0/source/Makefile.system index 66bfa4caeb..df21d9e6b6 100644 --- a/ABACUS.1.0.0/source/Makefile.system +++ b/ABACUS.1.0.0/source/Makefile.system @@ -4,8 +4,8 @@ include Makefile.vars # LIB and INCLUDE #========================== BOOST_INCLUDE_DIR = ${BOOST_DIR}/include -BOOST_LIB_DIR = ${BOOST_DIR}/lib -BOOST_LIB = -L${BOOST_LIB_DIR} -lboost_serialization -lboost_mpi -Wl,-rpath=${BOOST_LIB_DIR} +#BOOST_LIB_DIR = ${BOOST_DIR}/lib +#BOOST_LIB = -L${BOOST_LIB_DIR} -lboost_serialization -lboost_mpi -Wl,-rpath=${BOOST_LIB_DIR} LAPACK_INCLUDE_DIR = ${LAPACK_DIR}/include LAPACK_LIB_DIR = ${LAPACK_DIR}/lib/intel64 @@ -29,7 +29,7 @@ LIBXC_LIB = -L${LIBXC_LIB_DIR} -lxc -Wl,-rpath=${LIBXC_LIB_DIR} #========================== # LIBS and INCLUDES #========================== -LIBS = -lifcore -lm -lpthread ${BOOST_LIB} ${LAPACK_LIB} ${FFTW_LIB} ${ELPA_LIB} ${LIBXC_LIB} +LIBS = -lifcore -lm -lpthread ${LAPACK_LIB} ${FFTW_LIB} ${ELPA_LIB} ${LIBXC_LIB} #LIBS = -liomp5 -lpthread -lm -ldl ${BOOST_LIB} ${LAPACK_LIB} ${FFTW_LIB} ${ELPA_LIB} ${LIBXC_LIB} INCLUDES = -I. -Icommands -I${BOOST_INCLUDE_DIR} -I${LAPACK_INCLUDE_DIR} -I${FFTW_INCLUDE_DIR} -I${LIBXC_INCLUDE_DIR} diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-io.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-io.cpp index 95edc26d45..8264c60d69 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-io.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-io.cpp @@ -2,12 +2,12 @@ #include #include "exx_abfs-io.h" -#include "exx_abfs-io-template.h" #include "exx_abfs-jle.h" #include "exx_abfs-abfs_index.h" -#include "../src_pw/global.h" -#include "lcao_orbitals.h" -#include "../src_global/global_function.h" +#include "src_pw/global.h" +#include "src_lcao/lcao_orbitals.h" +#include "src_global/global_function.h" + vector>> Exx_Abfs::IO::construct_abfs( const LCAO_Orbitals &orbs, diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-io.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-io.h index ae3a9e87c1..7d97311576 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-io.h +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-io.h @@ -35,6 +35,7 @@ class Exx_Abfs::IO const vector &files_abfs, const double kmesh_times=1 ); // close dK, keep Kcut + #ifdef USE_BOOST_SERIALIZATION template static void output_binary( const T &data, const string &file_name ); template @@ -45,6 +46,7 @@ class Exx_Abfs::IO static T input_text( const string &file_name ); template static void bcast( T &data, const int rank_src, MPI_Comm mpi_comm ); + #endif private: static vector> construct_abfs_T( diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp index b472a6be6f..8f8a3031a6 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp @@ -1,10 +1,16 @@ #include "exx_abfs-parallel-communicate-hexx.h" #include "exx_abfs-parallel-communicate-hexx-template.h" -#include "exx_abfs-parallel-communicate-allreduce-template.h" #include "src_pw/global.h" #include "src_global/global_function.h" #include "exx_abfs-io.h" + +#if EXX_H_COMM==1 +#include "exx_abfs-parallel-communicate-allreduce-template.h" +#endif + +#ifdef USE_BOOST_SERIALIZATION #include "exx_abfs-io-template.h" +#endif #include "src_external/src_test/src_lcao/exx_lcao-test.h" //#include @@ -26,8 +32,12 @@ void Exx_Abfs::Parallel::Communicate::Hexx::Rexx_to_Km2D( //gettimeofday( &t_start, NULL); vector,matrix>>>> HR_a2D; if(io_HR_a2D.first) - HR_a2D = Exx_Abfs::IO::input_binary,matrix>>>>>( - global_out_dir+"HR_exx_"+TO_STRING(MY_RANK)); + #ifdef USE_BOOST_SERIALIZATION + HR_a2D = Exx_Abfs::IO::input_binary,matrix>>>>>( + global_out_dir+"HR_exx_"+TO_STRING(MY_RANK)); + #else + throw invalid_argument(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + #endif else { #if EXX_H_COMM==1 @@ -40,7 +50,11 @@ void Exx_Abfs::Parallel::Communicate::Hexx::Rexx_to_Km2D( #endif } if(io_HR_a2D.second) - Exx_Abfs::IO::output_binary( HR_a2D, global_out_dir+"HR_exx_"+TO_STRING(MY_RANK) ); + #ifdef USE_BOOST_SERIALIZATION + Exx_Abfs::IO::output_binary( HR_a2D, global_out_dir+"HR_exx_"+TO_STRING(MY_RANK) ); + #else + throw invalid_argument(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + #endif //ofs_time<<"TIME@ Exx_Abfs::Parallel::Communicate::Hexx::Allreduce::exx_to_a2D\t"< T pulay_mixing( const T &H_pulay_old, deque &H_seq, const T &H_new ); + #if EXX_H_COMM==1 class Allreduce { public: @@ -77,7 +78,7 @@ class Exx_Abfs::Parallel::Communicate::Hexx vector*> flags_ask_atom; boost::dynamic_bitset<> flags_recv_data; }; - + #elif EXX_H_COMM==2 class Allreduce2 { public: @@ -128,6 +129,7 @@ class Exx_Abfs::Parallel::Communicate::Hexx vector send_size_list; size_t recv_size; }; + #endif public: vector HK_Gamma_m2D; diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel.h index 28a9579513..f21eee0b94 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel.h +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel.h @@ -20,8 +20,11 @@ class Exx_Abfs::Parallel public: class Allreduce; class Hexx; + #if EXX_DM==1 class DM; + #elif EXX_DM==2 class DM2; + #endif }; }; diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-util.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-util.cpp new file mode 100644 index 0000000000..fd9a5fd3fc --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-util.cpp @@ -0,0 +1,42 @@ +#include "exx_abfs-util.h" +#include +#include + +void Exx_Abfs::Util::bcast( vector &v, const int rank_src, const MPI_Comm &mpi_comm ) +{ + int my_rank; MPI_Comm_rank( mpi_comm, &my_rank ); + if(my_rank==rank_src) + { + int size_v = v.size(); + MPI_Bcast( &size_v, 1, MPI_INT, rank_src, mpi_comm ); + + vector size_s(size_v); + transform( v.begin(), v.end(), size_s.begin(), [](const string &s){return s.size();} ); + MPI_Bcast( VECTOR_TO_PTR(size_s), size_s.size(), MPI_INT, rank_src, mpi_comm ); + + string s_all = accumulate( v.begin(), v.end(), string() ); + MPI_Bcast( const_cast(s_all.c_str()), s_all.size(), MPI_CHAR, rank_src, mpi_comm ); + } + else + { + int size_v; + MPI_Bcast( &size_v, 1, MPI_INT, rank_src, mpi_comm ); + v.resize(size_v); + + vector size_s(size_v); + MPI_Bcast( VECTOR_TO_PTR(size_s), size_s.size(), MPI_INT, rank_src, mpi_comm ); + + const int size_all = accumulate( size_s.begin(), size_s.end(), 0 ); + char *s_all_tmp = new char[size_all]; + MPI_Bcast( s_all_tmp, size_all, MPI_CHAR, rank_src, mpi_comm ); + string s_all(s_all_tmp, size_all); + delete[]s_all_tmp; + + deque index_begin(size_v); + partial_sum( size_s.begin(), size_s.end(), index_begin.begin() ); + index_begin.push_front(0); + + for(int i=0; i +#include + +class Exx_Abfs::Util +{ +public: + static void bcast( vector &v, const int rank_src, const MPI_Comm &mpi_comm ); +}; + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs.h index 113466195a..3db9932fa7 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs.h +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs.h @@ -22,6 +22,7 @@ class Exx_Abfs void test_abfs2() const; void cal_exx() const; + class Util; class Abfs_Index; class Jle; class Inverse_Matrix_Double; diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp index 9e7b207aa6..e3b8371b5d 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp @@ -14,7 +14,8 @@ #include "exx_abfs-abfs_index.h" #include "exx_abfs-screen-schwarz.h" #include "exx_abfs-io.h" -#include "exx_abfs-io-template.h" +//#include "exx_abfs-io-template.h" +#include "exx_abfs-util.h" #include "exx_abfs-parallel.h" #include "exx_abfs-parallel-distribute-htime.h" #include "exx_abfs-parallel-distribute-kmeans.h" @@ -493,7 +494,7 @@ gettimeofday( &t_start, NULL); ofs_mpi<<"TIME@ Exx_Abfs::Construct_Orbs::change_orbs\t"< #include #include From ab15afb2c2644f8f32438d912e73e53088bd40ef Mon Sep 17 00:00:00 2001 From: linpz Date: Tue, 10 Mar 2020 08:28:51 +0800 Subject: [PATCH 030/233] 1. change Exx_Lcao::cal_Hexx from C++11_thread to OpenMP 1.1 src_lcao/exx_lcao.h 1.2 src_lcao/exx_lcao.cpp --- ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 573 +++++++++++----------- ABACUS.1.0.0/source/src_lcao/exx_lcao.h | 6 +- 2 files changed, 277 insertions(+), 302 deletions(-) diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp index e3b8371b5d..94285a4bb6 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp @@ -1328,357 +1328,336 @@ vector,matrix>>>> Exx_Lcao::c const int mkl_threads = mkl_get_max_threads(); mkl_set_num_threads(1); - atomic i_atom_pair = 0; - atomic_flag Hexx_lock = ATOMIC_FLAG_INIT; vector,matrix>>>> HexxR(NSPIN); + omp_lock_t Hexx_lock; + omp_init_lock(&Hexx_lock); - vector ts; -// for( int it=0; it & i_atom_pair, - atomic_flag & Hexx_lock, - vector,matrix>>>> & HexxR) const -{ - // m_new( i2, i1, i3 ) = m( i1, i2, i3 ) - auto transform = []( - const matrix & m, - const size_t n1, const size_t n2, const size_t n3 ) -> matrix + #pragma omp parallel { - assert( n1*n2*n3 == m.nr*m.nc ); - const auto length = sizeof(double)*n3; - const auto n13 = n1*n3; - const double *m_ptr = m.c; - matrix m_new( n1*n2, n3, false ); - for( size_t i1=0; i1!=n1; ++i1 ) + // m_new( i2, i1, i3 ) = m( i1, i2, i3 ) + auto transform = []( + const matrix & m, + const size_t n1, const size_t n2, const size_t n3 ) -> matrix { - double *m_new_ptr = m_new.c+i1*n3; - for( size_t i2=0; i2!=n2; ++i2, m_ptr+=n3, m_new_ptr+=n13 ) - memcpy( m_new_ptr, m_ptr, length ); - } - return m_new; - }; + assert( n1*n2*n3 == m.nr*m.nc ); + const auto length = sizeof(double)*n3; + const auto n13 = n1*n3; + const double *m_ptr = m.c; + matrix m_new( n1*n2, n3, false ); + for( size_t i1=0; i1!=n1; ++i1 ) + { + double *m_new_ptr = m_new.c+i1*n3; + for( size_t i2=0; i2!=n2; ++i2, m_ptr+=n3, m_new_ptr+=n13 ) + memcpy( m_new_ptr, m_ptr, length ); + } + return m_new; + }; - // C = alpha * A.? * B.? - auto gemm = []( - const char transA, // A / A.T / A.C - const char transB, // B / B.T / B.C - const int M, // A.?.nr = C.nr - const int N, // B.?.nc = C.nc - const int K, // A.?.nc = B.?.nr - const double alpha, - const matrix & A, - const matrix & B) -> matrix - { - matrix C(M,N,false); - LapackConnector::gemm( - transA, transB, - M, N, K, - alpha, - A.c, (transA=='N')?K:M, - B.c, (transB=='N')?N:K, - 0, - C.c, N ); - return C; - }; + // C = alpha * A.? * B.? + auto gemm = []( + const char transA, // A / A.T / A.C + const char transB, // B / B.T / B.C + const int M, // A.?.nr = C.nr + const int N, // B.?.nc = C.nc + const int K, // A.?.nc = B.?.nr + const double alpha, + const matrix & A, + const matrix & B) -> matrix + { + matrix C(M,N,false); + LapackConnector::gemm( + transA, transB, + M, N, K, + alpha, + A.c, (transA=='N')?K:M, + B.c, (transB=='N')?N:K, + 0, + C.c, N ); + return C; + }; - // insert m_tmp into m_all - auto insert_matrixes = []( - vector,matrix>>>> & m_all, - vector,matrix>>>> & m_tmp) - { - for( size_t is=0; is!=NSPIN; ++is ) + // insert m_tmp into m_all + auto insert_matrixes = []( + vector,matrix>>>> & m_all, + vector,matrix>>>> & m_tmp) { - for( auto & m_tmp1 : m_tmp[is] ) + for( size_t is=0; is!=NSPIN; ++is ) { - const size_t iat1 = m_tmp1.first; - for( auto & m_tmp2 : m_tmp1.second ) + for( auto & m_tmp1 : m_tmp[is] ) { - const size_t iat2 = m_tmp2.first; - for( auto & m_tmp3 : m_tmp2.second ) + const size_t iat1 = m_tmp1.first; + for( auto & m_tmp2 : m_tmp1.second ) { - const Abfs::Vector3_Order & box2 = m_tmp3.first; - if( matrix*const m_all_ptr = static_cast(MAP_EXIST( m_all[is], iat1, iat2, box2 )) ) - *m_all_ptr += m_tmp3.second; - else - m_all[is][iat1][iat2][box2] = std::move(m_tmp3.second); + const size_t iat2 = m_tmp2.first; + for( auto & m_tmp3 : m_tmp2.second ) + { + const Abfs::Vector3_Order & box2 = m_tmp3.first; + if( matrix*const m_all_ptr = static_cast(MAP_EXIST( m_all[is], iat1, iat2, box2 )) ) + *m_all_ptr += m_tmp3.second; + else + m_all[is][iat1][iat2][box2] = std::move(m_tmp3.second); + } } } + m_tmp[is].clear(); } - m_tmp[is].clear(); - } - }; - - auto vector_empty = []( const vector,matrix>>>> & v ) -> bool - { - for( const auto &i : v ) - if(!i.empty()) return false; - return true; - }; - -ofstream ofs_thread(test_dir.thread+"thread_"+TO_STRING(MY_RANK)+"_"+TO_STRING(std::this_thread::get_id())); - - TITLE("Exx_Lcao","cal_Hexx_thread"); - -timeval t_start, t_start_all; -gettimeofday( &t_start_all, NULL); + }; - vector,matrix>>>> HexxR_tmp(NSPIN); - - while(true) - { - const size_t i_atom_pair_now = i_atom_pair++; - if( i_atom_pair_now >= atom_pairs_core.size() ) break; - - const size_t iat1 = atom_pairs_core[i_atom_pair_now].first; - const size_t iat2 = atom_pairs_core[i_atom_pair_now].second; - -//ofs_thread<,matrix>>>> & v ) -> bool { - const size_t iat3 = Cp1s.first; - - for( const auto & Cp2s : Cps.at(iat2) ) + for( const auto &i : v ) + if(!i.empty()) return false; + return true; + }; + + vector,matrix>>>> HexxR_tmp(NSPIN); + + #pragma omp for + for(size_t i_atom_pair=0; i_atom_pair & box3 = Cp1.first; - const auto & Cp13 = Cp1.second; + const size_t iat4 = Cp2s.first; + + const size_t it1 = ucell.iat2it[iat1]; + const size_t it2 = ucell.iat2it[iat2]; + const size_t it3 = ucell.iat2it[iat3]; + const size_t it4 = ucell.iat2it[iat4]; - for( const auto & Cp2 : Cp2s.second ) + for( const auto & Cp1 : Cp1s.second ) { - const Abfs::Vector3_Order & box4 = Cp2.first; - const auto & Cp24 = Cp2.second; - - if( schwarz.screen( iat1,iat2,iat3,iat4, box3,box4 ) ) continue; + const Abfs::Vector3_Order & box3 = Cp1.first; + const auto & Cp13 = Cp1.second; - for( const auto &Vp : Vps.at(iat1).at(iat2) ) + for( const auto & Cp2 : Cp2s.second ) { - const Abfs::Vector3_Order & box2 = Vp.first; - - const matrix & C_13 = *Cp13, // iw1*iw3, \mu1 - & V = *Vp.second, // \mu1, \mu2 - & C_24 = *Cp24; // iw2*iw4, \mu2 - - const Exx_Abfs::Screen::Cauchy::Info_Step info_step = cauchy.input_info( iat1, iat2, iat3, iat4, box2, box3, box4 ); - int cauchy_postcal; - if(!( cauchy_postcal = cauchy.postcalA( info_step ) )) continue; - -// assert( V.nc==C_24.nc ); - const matrix VC_24 = gemm( // \mu1, iw2*iw4 - 'N', 'T', - index_abfs[it1].count_size, - index_lcaos[it2].count_size * index_lcaos[it4].count_size, - index_abfs[it2].count_size, - 1, V, C_24 ); - const matrix VC_24_T = transform( VC_24, // iw2*\mu1, iw4 - index_abfs[it1].count_size, - index_lcaos[it2].count_size, - index_lcaos[it4].count_size ); - if(!( cauchy_postcal = cauchy.postcalB( info_step, VC_24_T, index_lcaos[it2].count_size, index_abfs[it1].count_size, index_lcaos[it4].count_size, cauchy_postcal ) )) continue; - - const matrix C_13_T = transform( C_13, // iw3*iw1, \mu1 - index_lcaos[it1].count_size, - index_lcaos[it3].count_size, - index_abfs[it1].count_size ); - - for( size_t is=0; is!=NSPIN; ++is ) + const Abfs::Vector3_Order & box4 = Cp2.first; + const auto & Cp24 = Cp2.second; + + if( schwarz.screen( iat1,iat2,iat3,iat4, box3,box4 ) ) continue; + + for( const auto &Vp : Vps.at(iat1).at(iat2) ) { - switch( cauchy_postcal ) // Attention: case and go on calculating + const Abfs::Vector3_Order & box2 = Vp.first; + + const matrix & C_13 = *Cp13, // iw1*iw3, \mu1 + & V = *Vp.second, // \mu1, \mu2 + & C_24 = *Cp24; // iw2*iw4, \mu2 + + const Exx_Abfs::Screen::Cauchy::Info_Step info_step = cauchy.input_info( iat1, iat2, iat3, iat4, box2, box3, box4 ); + int cauchy_postcal; + if(!( cauchy_postcal = cauchy.postcalA( info_step ) )) continue; + + // assert( V.nc==C_24.nc ); + const matrix VC_24 = gemm( // \mu1, iw2*iw4 + 'N', 'T', + index_abfs[it1].count_size, + index_lcaos[it2].count_size * index_lcaos[it4].count_size, + index_abfs[it2].count_size, + 1, V, C_24 ); + const matrix VC_24_T = transform( VC_24, // iw2*\mu1, iw4 + index_abfs[it1].count_size, + index_lcaos[it2].count_size, + index_lcaos[it4].count_size ); + if(!( cauchy_postcal = cauchy.postcalB( info_step, VC_24_T, index_lcaos[it2].count_size, index_abfs[it1].count_size, index_lcaos[it4].count_size, cauchy_postcal ) )) continue; + + const matrix C_13_T = transform( C_13, // iw3*iw1, \mu1 + index_lcaos[it1].count_size, + index_lcaos[it3].count_size, + index_abfs[it1].count_size ); + + for( size_t is=0; is!=NSPIN; ++is ) { - case 4: + switch( cauchy_postcal ) // Attention: case and go on calculating { - const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat3, iat4, Abfs::Vector3_Order(box2-box3+box4)%Born_von_Karman_period )); - if( DM_ptr ) + case 4: { - const matrix DVC_32 = gemm( // iw3, \mu1*iw2 - 'N', 'T', - index_lcaos[it3].count_size, - index_abfs[it1].count_size * index_lcaos[it2].count_size, - index_lcaos[it4].count_size, - 1, - *DM_ptr, - VC_24 ); - if( cauchy.postcalC( info_step, DVC_32, index_lcaos[it3].count_size, index_abfs[it1].count_size, index_lcaos[it2].count_size, 1 ) ) + const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat3, iat4, Abfs::Vector3_Order(box2-box3+box4)%Born_von_Karman_period )); + if( DM_ptr ) { - const matrix Hexx_12 = gemm( // iw1, iw2 - 'N', 'N', - index_lcaos[it1].count_size, - index_lcaos[it2].count_size, - index_lcaos[it3].count_size * index_abfs[it1].count_size, - -2, C_13, DVC_32 ); - if( cauchy.postcalD( Hexx_12 ) ) + const matrix DVC_32 = gemm( // iw3, \mu1*iw2 + 'N', 'T', + index_lcaos[it3].count_size, + index_abfs[it1].count_size * index_lcaos[it2].count_size, + index_lcaos[it4].count_size, + 1, + *DM_ptr, + VC_24 ); + if( cauchy.postcalC( info_step, DVC_32, index_lcaos[it3].count_size, index_abfs[it1].count_size, index_lcaos[it2].count_size, 1 ) ) { - if(iat1!=iat2) + const matrix Hexx_12 = gemm( // iw1, iw2 + 'N', 'N', + index_lcaos[it1].count_size, + index_lcaos[it2].count_size, + index_lcaos[it3].count_size * index_abfs[it1].count_size, + -2, C_13, DVC_32 ); + if( cauchy.postcalD( Hexx_12 ) ) { - const matrix Hexx_21 = transpose(Hexx_12); - if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat2, iat1, Abfs::Vector3_Order(-box2)%Born_von_Karman_period )) ) - *HexxR_ptr += Hexx_21; + if(iat1!=iat2) + { + const matrix Hexx_21 = transpose(Hexx_12); + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat2, iat1, Abfs::Vector3_Order(-box2)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_21; + else + HexxR_tmp[is][iat2][iat1][Abfs::Vector3_Order(-box2)%Born_von_Karman_period] = std::move(Hexx_21); + } + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat1, iat2, Abfs::Vector3_Order(box2)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_12; else - HexxR_tmp[is][iat2][iat1][Abfs::Vector3_Order(-box2)%Born_von_Karman_period] = std::move(Hexx_21); + HexxR_tmp[is][iat1][iat2][Abfs::Vector3_Order(box2)%Born_von_Karman_period] = std::move(Hexx_12); } - if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat1, iat2, Abfs::Vector3_Order(box2)%Born_von_Karman_period )) ) - *HexxR_ptr += Hexx_12; - else - HexxR_tmp[is][iat1][iat2][Abfs::Vector3_Order(box2)%Born_von_Karman_period] = std::move(Hexx_12); } } - } - } // end case 4 - case 3: - { - if( const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat1, iat4, Abfs::Vector3_Order(box2+box4)%Born_von_Karman_period )) ) + } // end case 4 + case 3: { - const matrix DVC_12 = gemm( // iw1, \mu1*iw2 - 'N', 'T', - index_lcaos[it1].count_size, - index_abfs[it1].count_size * index_lcaos[it2].count_size, - index_lcaos[it4].count_size, - 1, - *DM_ptr, - VC_24 ); - if( cauchy.postcalC( info_step, DVC_12, index_lcaos[it1].count_size, index_abfs[it1].count_size, index_lcaos[it2].count_size, 3 ) ) + if( const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat1, iat4, Abfs::Vector3_Order(box2+box4)%Born_von_Karman_period )) ) { - const matrix Hexx_32 = gemm( // iw3, iw2 - 'N', 'N', - index_lcaos[it3].count_size, - index_lcaos[it2].count_size, - index_lcaos[it1].count_size * index_abfs[it1].count_size, - -2, C_13_T, DVC_12 ); - if( cauchy.postcalD( Hexx_32 ) ) + const matrix DVC_12 = gemm( // iw1, \mu1*iw2 + 'N', 'T', + index_lcaos[it1].count_size, + index_abfs[it1].count_size * index_lcaos[it2].count_size, + index_lcaos[it4].count_size, + 1, + *DM_ptr, + VC_24 ); + if( cauchy.postcalC( info_step, DVC_12, index_lcaos[it1].count_size, index_abfs[it1].count_size, index_lcaos[it2].count_size, 3 ) ) { - if(iat1!=iat2) + const matrix Hexx_32 = gemm( // iw3, iw2 + 'N', 'N', + index_lcaos[it3].count_size, + index_lcaos[it2].count_size, + index_lcaos[it1].count_size * index_abfs[it1].count_size, + -2, C_13_T, DVC_12 ); + if( cauchy.postcalD( Hexx_32 ) ) { - const matrix Hexx_23 = transpose(Hexx_32); - if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat2, iat3, Abfs::Vector3_Order(-box2+box3)%Born_von_Karman_period )) ) - *HexxR_ptr += Hexx_23; + if(iat1!=iat2) + { + const matrix Hexx_23 = transpose(Hexx_32); + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat2, iat3, Abfs::Vector3_Order(-box2+box3)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_23; + else + HexxR_tmp[is][iat2][iat3][Abfs::Vector3_Order(-box2+box3)%Born_von_Karman_period] = std::move(Hexx_23); + } + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat3, iat2, Abfs::Vector3_Order(box2-box3)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_32; else - HexxR_tmp[is][iat2][iat3][Abfs::Vector3_Order(-box2+box3)%Born_von_Karman_period] = std::move(Hexx_23); + HexxR_tmp[is][iat3][iat2][Abfs::Vector3_Order(box2-box3)%Born_von_Karman_period] = std::move(Hexx_32); } - if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat3, iat2, Abfs::Vector3_Order(box2-box3)%Born_von_Karman_period )) ) - *HexxR_ptr += Hexx_32; - else - HexxR_tmp[is][iat3][iat2][Abfs::Vector3_Order(box2-box3)%Born_von_Karman_period] = std::move(Hexx_32); } } - } - } // end case 3 - case 2: - { - if( const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat3, iat2, Abfs::Vector3_Order(box2-box3)%Born_von_Karman_period )) ) + } // end case 3 + case 2: { - const matrix DVC_34 = gemm( // iw3, \mu1*iw4 - 'N', 'N', - index_lcaos[it3].count_size, - index_abfs[it1].count_size * index_lcaos[it4].count_size, - index_lcaos[it2].count_size, - 1, - *DM_ptr, - VC_24_T ); - if( cauchy.postcalC( info_step, DVC_34, index_lcaos[it3].count_size, index_abfs[it1].count_size, index_lcaos[it4].count_size, 1 ) ) + if( const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat3, iat2, Abfs::Vector3_Order(box2-box3)%Born_von_Karman_period )) ) { - const matrix Hexx_14 = gemm( // iw1, iw4 + const matrix DVC_34 = gemm( // iw3, \mu1*iw4 'N', 'N', - index_lcaos[it1].count_size, - index_lcaos[it4].count_size, - index_lcaos[it3].count_size * index_abfs[it1].count_size, - -2, C_13, DVC_34 ); - if( cauchy.postcalD( Hexx_14 ) ) + index_lcaos[it3].count_size, + index_abfs[it1].count_size * index_lcaos[it4].count_size, + index_lcaos[it2].count_size, + 1, + *DM_ptr, + VC_24_T ); + if( cauchy.postcalC( info_step, DVC_34, index_lcaos[it3].count_size, index_abfs[it1].count_size, index_lcaos[it4].count_size, 1 ) ) { - if(iat1!=iat2) + const matrix Hexx_14 = gemm( // iw1, iw4 + 'N', 'N', + index_lcaos[it1].count_size, + index_lcaos[it4].count_size, + index_lcaos[it3].count_size * index_abfs[it1].count_size, + -2, C_13, DVC_34 ); + if( cauchy.postcalD( Hexx_14 ) ) { - const matrix Hexx_41 = transpose(Hexx_14); - if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat4, iat1, Abfs::Vector3_Order(-box2-box4)%Born_von_Karman_period )) ) - *HexxR_ptr += Hexx_41; + if(iat1!=iat2) + { + const matrix Hexx_41 = transpose(Hexx_14); + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat4, iat1, Abfs::Vector3_Order(-box2-box4)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_41; + else + HexxR_tmp[is][iat4][iat1][Abfs::Vector3_Order(-box2-box4)%Born_von_Karman_period] = std::move(Hexx_41); + } + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat1, iat4, Abfs::Vector3_Order(box2+box4)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_14; else - HexxR_tmp[is][iat4][iat1][Abfs::Vector3_Order(-box2-box4)%Born_von_Karman_period] = std::move(Hexx_41); - } - if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat1, iat4, Abfs::Vector3_Order(box2+box4)%Born_von_Karman_period )) ) - *HexxR_ptr += Hexx_14; - else - HexxR_tmp[is][iat1][iat4][Abfs::Vector3_Order(box2+box4)%Born_von_Karman_period] = std::move(Hexx_14); - } + HexxR_tmp[is][iat1][iat4][Abfs::Vector3_Order(box2+box4)%Born_von_Karman_period] = std::move(Hexx_14); + } + } } - } - } // end case 2 - case 1: - { - if( const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat1, iat2, Abfs::Vector3_Order(box2)%Born_von_Karman_period )) ) + } // end case 2 + case 1: { - const matrix DVC_14 = gemm( // iw1, \mu1*iw4 - 'N', 'N', - index_lcaos[it1].count_size, - index_abfs[it1].count_size * index_lcaos[it4].count_size, - index_lcaos[it2].count_size, - 1, - *DM_ptr, - VC_24_T ); - if( cauchy.postcalC( info_step, DVC_14, index_lcaos[it1].count_size, index_abfs[it1].count_size, index_lcaos[it4].count_size, 3 ) ) + if( const matrix * const DM_ptr = static_cast(MAP_EXIST( DM_para.DMr[is], iat1, iat2, Abfs::Vector3_Order(box2)%Born_von_Karman_period )) ) { - const matrix Hexx_34 = gemm( // iw3, iw4 + const matrix DVC_14 = gemm( // iw1, \mu1*iw4 'N', 'N', - index_lcaos[it3].count_size, - index_lcaos[it4].count_size, - index_lcaos[it1].count_size * index_abfs[it1].count_size, - -2, C_13_T, DVC_14 ); - if( cauchy.postcalD( Hexx_34 ) ) + index_lcaos[it1].count_size, + index_abfs[it1].count_size * index_lcaos[it4].count_size, + index_lcaos[it2].count_size, + 1, + *DM_ptr, + VC_24_T ); + if( cauchy.postcalC( info_step, DVC_14, index_lcaos[it1].count_size, index_abfs[it1].count_size, index_lcaos[it4].count_size, 3 ) ) { - if(iat1!=iat2) + const matrix Hexx_34 = gemm( // iw3, iw4 + 'N', 'N', + index_lcaos[it3].count_size, + index_lcaos[it4].count_size, + index_lcaos[it1].count_size * index_abfs[it1].count_size, + -2, C_13_T, DVC_14 ); + if( cauchy.postcalD( Hexx_34 ) ) { - const matrix Hexx_43 = transpose(Hexx_34); - if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat4, iat3, Abfs::Vector3_Order(-box2+box3-box4)%Born_von_Karman_period )) ) - *HexxR_ptr += Hexx_43; + if(iat1!=iat2) + { + const matrix Hexx_43 = transpose(Hexx_34); + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat4, iat3, Abfs::Vector3_Order(-box2+box3-box4)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_43; + else + HexxR_tmp[is][iat4][iat3][Abfs::Vector3_Order(-box2+box3-box4)%Born_von_Karman_period] = std::move(Hexx_43); + } + if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat3, iat4, Abfs::Vector3_Order(box2-box3+box4)%Born_von_Karman_period )) ) + *HexxR_ptr += Hexx_34; else - HexxR_tmp[is][iat4][iat3][Abfs::Vector3_Order(-box2+box3-box4)%Born_von_Karman_period] = std::move(Hexx_43); - } - if( matrix * const HexxR_ptr = static_cast(MAP_EXIST( HexxR_tmp[is], iat3, iat4, Abfs::Vector3_Order(box2-box3+box4)%Born_von_Karman_period )) ) - *HexxR_ptr += Hexx_34; - else - HexxR_tmp[is][iat3][iat4][Abfs::Vector3_Order(box2-box3+box4)%Born_von_Karman_period] = std::move(Hexx_34); + HexxR_tmp[is][iat3][iat4][Abfs::Vector3_Order(box2-box3+box4)%Born_von_Karman_period] = std::move(Hexx_34); + } } } - } - } // end case 1 - case 0: ; - } // end switch cauchy_postcal - } // end for is - } // end for box2 - } // end for box4 - } // end for box3 - - if( !vector_empty(HexxR_tmp) && !Hexx_lock.test_and_set() ) - { - insert_matrixes(HexxR,HexxR_tmp); - Hexx_lock.clear(); - } - } // end for iat4 - } // end for iat3 - } // end while - - if(!vector_empty(HexxR_tmp)) - { - while( Hexx_lock.test_and_set() ); - insert_matrixes(HexxR,HexxR_tmp); - Hexx_lock.clear(); - } -ofs_thread<<"TIME@ Exx_Lcao::cal_Hexx_thread\t"< #include #include -#include +#include class Exx_Lcao { @@ -40,10 +40,6 @@ class Exx_Lcao void add_Hexx(const size_t ik, const double alpha) const; private: vector,matrix>>>> cal_Hexx() const; - void cal_Hexx_thread( - atomic & i_atom_pair, - atomic_flag & Hexx_lock, - vector,matrix>>>> & HexxR) const; double cal_energy( const vector,matrix>>>> &HexxR ) const; void init_radial_table_ions( const set &atom_centres_core, const vector> &atom_pairs_core ); From 19fe2c2411b9b4b68aefe88ca289fa58459d5ca3 Mon Sep 17 00:00:00 2001 From: linpz Date: Mon, 6 Apr 2020 21:10:27 +0800 Subject: [PATCH 031/233] 1. add exx restart src_lcao/local_orbital_ions.cpp src_lcao/local_orbital_elec.cpp input_conv.cpp --- ABACUS.1.0.0/source/input_conv.cpp | 4 ++-- ABACUS.1.0.0/source/src_lcao/local_orbital_elec.cpp | 9 +++++++++ ABACUS.1.0.0/source/src_lcao/local_orbital_ions.cpp | 11 +++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ABACUS.1.0.0/source/input_conv.cpp b/ABACUS.1.0.0/source/input_conv.cpp index 309f7b5693..d5147417bb 100644 --- a/ABACUS.1.0.0/source/input_conv.cpp +++ b/ABACUS.1.0.0/source/input_conv.cpp @@ -468,7 +468,7 @@ void Input_Conv::Convert(void) const string command0 = "test -d " + restart.folder + " || mkdir " + restart.folder; if(MY_RANK==0) system( command0.c_str() ); - if(true) + if(INPUT.exx_hybrid_type=="no") { restart.info_save.save_charge = true; } @@ -481,7 +481,7 @@ void Input_Conv::Convert(void) if(INPUT.restart_load) { restart.folder = global_out_dir + "restart/"; - if(true) + if(INPUT.exx_hybrid_type=="no") { restart.info_load.load_charge = true; } diff --git a/ABACUS.1.0.0/source/src_lcao/local_orbital_elec.cpp b/ABACUS.1.0.0/source/src_lcao/local_orbital_elec.cpp index 6440abc1b9..d4fbcc8f84 100644 --- a/ABACUS.1.0.0/source/src_lcao/local_orbital_elec.cpp +++ b/ABACUS.1.0.0/source/src_lcao/local_orbital_elec.cpp @@ -346,6 +346,15 @@ void Local_Orbital_Elec::scf(const int &istep) // add exx en.set_exx(); // Peize Lin add 2016-12-03 + + // Peize Lin add 2020.04.04 + if(Exx_Global::Hybrid_Type::HF==exx_lcao.info.hybrid_type || Exx_Global::Hybrid_Type::PBE0==exx_lcao.info.hybrid_type || Exx_Global::Hybrid_Type::HSE==exx_lcao.info.hybrid_type) + if(restart.info_load.load_H && restart.info_load.load_H_finish && !restart.info_load.restart_exx) + { + exx_global.info.set_xcfunc(xcf); + exx_lcao.cal_exx_elec(); + restart.info_load.restart_exx = true; + } // (4) mohan add 2010-06-24 // using new charge density. diff --git a/ABACUS.1.0.0/source/src_lcao/local_orbital_ions.cpp b/ABACUS.1.0.0/source/src_lcao/local_orbital_ions.cpp index c047c23e29..fccf2f93b7 100644 --- a/ABACUS.1.0.0/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.1.0.0/source/src_lcao/local_orbital_ions.cpp @@ -288,21 +288,20 @@ void Local_Orbital_Ions::opt_ions(void) } else // Peize Lin add 2016-12-03 { + LOE.scf(istep-1); if( exx_global.info.separate_loop ) { for( size_t hybrid_step=0; hybrid_step!=exx_global.info.hybrid_step; ++hybrid_step ) { - LOE.scf(istep-1); - - if( Local_Orbital_Elec::iter==1 || hybrid_step==exx_global.info.hybrid_step-1 ) // exx converge - break; exx_global.info.set_xcfunc(xcf); - exx_lcao.cal_exx_elec(); + exx_lcao.cal_exx_elec(); + LOE.scf(istep-1); + if(LOE.iter==1) // exx converge + break; } } else { - LOE.scf(istep-1); exx_global.info.set_xcfunc(xcf); LOE.scf(istep-1); } From d154c07d87df772d6cfc926d048ab035a8e4b1fe Mon Sep 17 00:00:00 2001 From: linpz Date: Tue, 5 May 2020 19:57:30 +0800 Subject: [PATCH 032/233] 1. add exx communicate dm3 src_lcao/exx_abfs-parallel-communicate-dm3.h src_lcao/exx_abfs-parallel-communicate-dm3.cpp src_lcao/exx_abfs-parallel-communicate-dm3-allreduce.cpp Makefile Makefile.Objects src_lcao/exx_lcao.h src_lcao/exx_lcao.cpp src_lcao/exx_abfs-parallel.h src_lcao/exx_abfs-parallel-communicate-hexx.h src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp src_lcao/abfs.h src_lcao/abfs.cpp src_lcao/abfs-template.h --- ABACUS.1.0.0/source/Makefile | 4 +- ABACUS.1.0.0/source/Makefile.Objects | 3 +- .../src_external/src_test/test_function.h | 17 +- ABACUS.1.0.0/source/src_lcao/abfs-template.h | 29 +- ABACUS.1.0.0/source/src_lcao/abfs.cpp | 57 +- ABACUS.1.0.0/source/src_lcao/abfs.h | 8 +- ...bfs-parallel-communicate-dm3-allreduce.cpp | 541 ++++++++++++++++++ .../exx_abfs-parallel-communicate-dm3.cpp | 91 +++ .../exx_abfs-parallel-communicate-dm3.h | 90 +++ ...s-parallel-communicate-hexx-allreduce2.cpp | 4 +- .../exx_abfs-parallel-communicate-hexx.h | 2 +- .../source/src_lcao/exx_abfs-parallel.h | 2 + ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp | 6 + ABACUS.1.0.0/source/src_lcao/exx_lcao.h | 4 + 14 files changed, 843 insertions(+), 15 deletions(-) create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm3-allreduce.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm3.cpp create mode 100644 ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm3.h diff --git a/ABACUS.1.0.0/source/Makefile b/ABACUS.1.0.0/source/Makefile index 4387ed18de..7c016b2e43 100644 --- a/ABACUS.1.0.0/source/Makefile +++ b/ABACUS.1.0.0/source/Makefile @@ -20,7 +20,7 @@ HONG_SER_SELINV = -D__FP ${HONG_FFTW} -D__SELINV HONG_GDB = -g -D__FP ${HONG_FFTW} #(2)mpi HONG_MPI = -D__FP ${HONG_FFTW} -D__MPI -HONG_MPI_SELINV = -D__FP ${HONG_FFTW} -D__MPI -D__SELINV -DMETIS -DMKL_ILP64 -DEXX_DM=2 -DEXX_H_COMM=2 -DTEST_LIBXC=0 -DTEST_EXX_LCAO=0 -DTEST_EXX_RADIAL=1 +HONG_MPI_SELINV = -D__FP ${HONG_FFTW} -D__MPI -D__SELINV -DMETIS -DMKL_ILP64 -DEXX_DM=3 -DEXX_H_COMM=2 -DTEST_LIBXC=0 -DTEST_EXX_LCAO=0 -DTEST_EXX_RADIAL=1 #(3)memory HONG_MEM = ${HONG_FFTW} -D__FP -D_MCD_CHECK -DWIN32 -DMCD_VERBOSE @@ -61,7 +61,7 @@ PDIAG_OBJS=$(OBJS_PDIAG)\ # MAKING OPTIONS #========================== fp_mpi : ${FP_OBJS} ${PDIAG_MR} ${PDIAG_OBJS} ${HEADERS} - ${CPLUSPLUS_MPI} ${OPTS} ${OPTS_MPI} $(FP_OBJS) ${PDIAG_OBJS} ${PDIAG_MR} ${LIBS} -o ../bin/${VERSION}.mpi.1.0.0_exx_noboost + ${CPLUSPLUS_MPI} ${OPTS} ${OPTS_MPI} $(FP_OBJS) ${PDIAG_OBJS} ${PDIAG_MR} ${LIBS} -o ../bin/${VERSION}.mpi.1.0.0_exx fp : ${FP_OBJS} ${HEADERS} ${CPLUSPLUS} ${OPTS} $(FP_OBJS) ${LIBS} -o ${VERSION}.fp.x diff --git a/ABACUS.1.0.0/source/Makefile.Objects b/ABACUS.1.0.0/source/Makefile.Objects index 593b8374f8..8f04d73e41 100644 --- a/ABACUS.1.0.0/source/Makefile.Objects +++ b/ABACUS.1.0.0/source/Makefile.Objects @@ -191,7 +191,8 @@ exx_abfs-matrix_orbs21.o \ exx_abfs-matrix_orbs22.o \ exx_abfs-matrix_lcaoslcaos_lcaoslcaos.o \ exx_abfs-pca.o \ -exx_abfs-parallel-communicate-dm2.o \ +exx_abfs-parallel-communicate-dm3.o \ +exx_abfs-parallel-communicate-dm3-allreduce.o \ exx_abfs-parallel-communicate-hexx.o \ exx_abfs-parallel-communicate-hexx-allreduce2.o \ exx_abfs-parallel-distribute-htime.o \ diff --git a/ABACUS.1.0.0/source/src_external/src_test/test_function.h b/ABACUS.1.0.0/source/src_external/src_test/test_function.h index 1c9584a52d..0b4c29beaf 100644 --- a/ABACUS.1.0.0/source/src_external/src_test/test_function.h +++ b/ABACUS.1.0.0/source/src_external/src_test/test_function.h @@ -27,8 +27,10 @@ static void MPI_RANK_OFSTREAM( const std::string& file_name, std::stringstream & template static std::ostream & operator<<( std::ostream & os, const std::vector &v ) { + os<<"["; for( const T &i : v ) os< &v ) template static std::ostream & operator<<( std::ostream & os, const std::set &v ) { + os<<"("; for( const T &i : v ) - os< +static std::ostream & operator<<( std::ostream & os, const std::map &v ) +{ + for( const auto &i : v ) + os<<"{"< &v ) template static std::ostream & operator<<( std::ostream & os, const std::pair &p ) { - os<<"("<"; return os; } diff --git a/ABACUS.1.0.0/source/src_lcao/abfs-template.h b/ABACUS.1.0.0/source/src_lcao/abfs-template.h index 105aad4664..618fb58aa8 100644 --- a/ABACUS.1.0.0/source/src_lcao/abfs-template.h +++ b/ABACUS.1.0.0/source/src_lcao/abfs-template.h @@ -3,8 +3,8 @@ #include "abfs.h" -template -void Abfs::delete_empty_ptrs( map>>> &ptrs ) +template +void Abfs::delete_empty_ptrs( map>>> &ptrs ) { TITLE("Abfs","delete_empty_ptrs"); for( auto iter1=ptrs.begin(); iter1!=ptrs.end(); ) @@ -24,8 +24,8 @@ void Abfs::delete_empty_ptrs( map>>> &ptrs ) } } -template -void Abfs::delete_threshold_ptrs( map>>> &ptrs, const double threshold) +template +void Abfs::delete_threshold_ptrs( map>>> &ptrs, const double threshold) { TITLE("Abfs","delete_threshold_ptrs"); for( auto iter1=ptrs.begin(); iter1!=ptrs.end(); ) @@ -45,6 +45,27 @@ void Abfs::delete_threshold_ptrs( map>>> &ptrs, } } +template +void Abfs::delete_threshold_ptrs( map>> &ptrs, const double threshold) +{ + TITLE("Abfs","delete_threshold_ptrs"); + for( auto iter1=ptrs.begin(); iter1!=ptrs.end(); ) + { + for( auto iter2=iter1->second.begin(); iter2!=iter1->second.end(); ) + { + for( auto iter3=iter2->second.begin(); iter3!=iter2->second.end(); ) + { + if( iter3->second.absmax()<=threshold ) iter2->second.erase(iter3++); + else ++iter3; + } + if( iter2->second.empty() ) iter1->second.erase(iter2++); + else ++iter2; + } + if( iter1->second.empty() ) ptrs.erase(iter1++); + else ++iter1; + } +} + template vector> Abfs::get_atom_pair(const map> &m) { diff --git a/ABACUS.1.0.0/source/src_lcao/abfs.cpp b/ABACUS.1.0.0/source/src_lcao/abfs.cpp index 6dab687b47..e34dfb715f 100644 --- a/ABACUS.1.0.0/source/src_lcao/abfs.cpp +++ b/ABACUS.1.0.0/source/src_lcao/abfs.cpp @@ -11,6 +11,7 @@ #include // Peize Lin test #include // Peize Lin test #include "src_external/src_test/src_global/matrix-test.h" // Peize Lin test +#include"src_external/src_test/test_function.h" map,shared_ptr>>> Abfs::cal_Cs( const set &atom_centres, @@ -455,9 +456,53 @@ set> Abfs::get_H_pairs_core( const vector,set> Abfs::get_H_pairs_core_group( const vector> &atom_pairs ) +{ + TITLE("Abfs","get_H_pairs_core_group"); + + const vector>>> adjs = Abfs::get_adjs(); + + auto get_set_adjs = [&adjs]( const set &as ) -> set + { + set aRs; + for( const size_t a : as ) + for( const auto &aR : adjs[a] ) + aRs.insert(aR.first); + return aRs; + }; + + // {(0,1),(3,5),(0,4),(7,8),(6,5)} + const vector> & a1_a2 = atom_pairs; + + // => {1:{0}, 5:{3,6}, 4:{0}, 8:{7}} + map> a2_a1s; + for( const auto & a1_a2_i : a1_a2 ) + a2_a1s[ a1_a2_i.second ].insert( a1_a2_i.first ); + + // => {{0}:{1,4}, {3,6}:{5}, {7}:{8}} + map,set> a1s_a2s; + for( const auto & a2_a1s_i : a2_a1s ) + a1s_a2s[ a2_a1s_i.second ].insert( a2_a1s_i.first ); + a2_a1s.clear(); + + // => {R(0):R(1)UR(4), R(3)UR(6):R(5), R(7):R(8)} + // imaging R(0)==R(3)UR(6): + // => {R(0):R(1)UR(4)UR(5), R(7):R(8)} + map,set> a1Rs_a2s; + for( const auto & a1s_a2s_i : a1s_a2s ) + { + const set a1Rs_i = get_set_adjs(a1s_a2s_i.first); + const set a2Rs_i = get_set_adjs(a1s_a2s_i.second); + a1Rs_a2s[a1Rs_i].insert(a2Rs_i.begin(), a2Rs_i.end()); + } + a1s_a2s.clear(); + + return a1Rs_a2s; +} + set> Abfs::get_H_pairs_core( const vector> &atom_pairs ) { - TITLE("Exx_Lcao","allocate_Hexx"); + TITLE("Exx_Lcao","get_H_pairs_core"); const vector>>> adjs = Abfs::get_adjs(); @@ -523,6 +568,16 @@ vector> Abfs::get_Coulomb_potential_boxes( const double return Coulomb_potential_boxes; } +vector> Abfs::get_Born_von_Karmen_boxes( const Abfs::Vector3_Order &Born_von_Karman_period ) +{ + vector> Born_von_Karman_boxes; + for( int ix=0; ix{ix,iy,iz} % Born_von_Karman_period ); + return Born_von_Karman_boxes; +} + shared_ptr Abfs::cal_I( const shared_ptr &m ) { // TITLE("Abfs","cal_I1"); diff --git a/ABACUS.1.0.0/source/src_lcao/abfs.h b/ABACUS.1.0.0/source/src_lcao/abfs.h index ecd4824666..e9b5658edd 100644 --- a/ABACUS.1.0.0/source/src_lcao/abfs.h +++ b/ABACUS.1.0.0/source/src_lcao/abfs.h @@ -82,16 +82,20 @@ class Abfs // static map>> get_adjs( const size_t &T, const Vector3 &tau_cartesian ); static map>> get_adjs( const size_t &iat ); static vector>>> get_adjs(); + static map,set> get_H_pairs_core_group( const vector> &atom_pairs ); static set> get_H_pairs_core( const vector> &atom_pairs ); static vector> get_Coulomb_potential_boxes( const double rmesh_times ); + static vector> get_Born_von_Karmen_boxes( const Abfs::Vector3_Order &Born_von_Karman_period ); static shared_ptr cal_I( const shared_ptr &m ); static vector>> cal_I( const vector>> &ms ); template static void delete_empty_ptrs( map>>> &ptrs ); - template - static void delete_threshold_ptrs( map>>> &ptrs, const double threshold); + template + static void delete_threshold_ptrs( map>>> &ptrs, const double threshold); + template + static void delete_threshold_ptrs( map>> &ptrs, const double threshold); template static vector> get_atom_pair(const map> &m); diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm3-allreduce.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm3-allreduce.cpp new file mode 100644 index 0000000000..e3de9f1621 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm3-allreduce.cpp @@ -0,0 +1,541 @@ +#include "exx_abfs-parallel-communicate-dm3.h" + +#include "src_pw/global.h" +#include "src_global/global_function.h" + +#include +#include +#include + +#include "src_external/src_test/test_function.h" + + +void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::init( + const MPI_Comm &mpi_comm_in, + const map,set> &H_atom_pairs_group) +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM3::Allreduce::init"); + + mpi_comm = mpi_comm_in; + MPI_Comm_size(mpi_comm, &comm_sz); + MPI_Comm_rank(mpi_comm, &my_rank); + + const vector> atom_in_2D = get_atom_in_2D(); + H_atom_pairs_group_rank = get_H_atom_pairs_group_rank(H_atom_pairs_group, atom_in_2D); + get_send_recv_size(H_atom_pairs_group_rank, H_atom_pairs_group, send_size_list, recv_size); + +ofstream ofs(exx_lcao.test_dir.process+"dm3_"+TO_STRING(my_rank)); +//ofs<,matrix>>>> + Exx_Abfs::Parallel::Communicate::DM3::Allreduce::a2D_to_exx( + vector,matrix>>>> &data_local) const +{ +ofstream ofs(exx_lcao.test_dir.process+"dm3_"+TO_STRING(my_rank), ofstream::app); +//ofs<,matrix>>>> data_all(NSPIN); + + vector> flags_send(comm_sz); + vector> flags_recv(comm_sz); + init_flags(flags_send, flags_recv); + + vector> oarps_isend(comm_sz); + vector> iarps_irecv(comm_sz); + + int rank_send_now = my_rank; + auto rank_send_next = [&]()->int{ return (rank_send_now+1)%comm_sz; }; + + atomic_flag lock_insert = ATOMIC_FLAG_INIT; + vector threads; + vectorrequests_isend(comm_sz); + vectorrequests_irecv(comm_sz); +ofs<<__LINE__<,matrix*>>>> data_intersection = get_intersection(my_rank, data_local); + while( lock_insert.test_and_set() ); + insert_data(data_intersection, data_all); + lock_insert.clear(); +ofs<<__LINE__<> Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_atom_in_2D() const +{ + vector> atom_in_2D(ucell.nat,{false,false}); + for(int iwt=0; iwt=0) + atom_in_2D[iat].first = true; + if(ParaO.trace_loc_col[iwt]>=0) + atom_in_2D[iat].second = true; + } + return atom_in_2D; +} + + +vector>>> Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_H_atom_pairs_group_rank( + const map,set> &H_atom_pairs_group, + const vector> &atom_in_2D) const +{ + vector H_atom_pairs_group_vector; + for(const auto &pairs : H_atom_pairs_group) + { + H_atom_pairs_group_vector.push_back(pairs.first.size()); + H_atom_pairs_group_vector.push_back(pairs.second.size()); + H_atom_pairs_group_vector.insert(H_atom_pairs_group_vector.end(), pairs.first.begin(), pairs.first.end()); + H_atom_pairs_group_vector.insert(H_atom_pairs_group_vector.end(), pairs.second.begin(), pairs.second.end()); + } + + vector rank_size(comm_sz); + vector rank_index(comm_sz); + for(size_t i=0; i(comm_sz,1)), VECTOR_TO_PTR(rank_index), MPI_INT, + mpi_comm ); + + size_t index_accumulate = 0; + for(size_t i=0; i H_atom_pairs_group_rank_vector(index_accumulate); + MPI_Allgatherv( + VECTOR_TO_PTR(H_atom_pairs_group_vector), H_atom_pairs_group_vector.size(), MPI_INT, + VECTOR_TO_PTR(H_atom_pairs_group_rank_vector), VECTOR_TO_PTR(rank_size), VECTOR_TO_PTR(rank_index), MPI_INT, + mpi_comm); + + vector>>> H_atom_pairs_group_rank(comm_sz); + auto ptr = H_atom_pairs_group_rank_vector.begin(); + for(int rank=0; rank!=comm_sz; ++rank) + { + const auto ptr_begin = ptr; + while(ptr < ptr_begin+rank_size[rank]) + { + const size_t atoms1_size = *ptr++; + const size_t atoms2_size = *ptr++; + if(atoms1_size&&atoms2_size) + { + shared_ptr> atoms2 = make_shared>(); + for(int i=0; iinsert(atom_require); + } + } + else + { + ptr += atoms1_size + atoms2_size; + } + } + } + return H_atom_pairs_group_rank; +} + + +void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_send_recv_size( + const vector>>> &H_atom_pairs_group_rank, + const map,set> &H_atom_pairs_group, + vector &send_size_list, size_t &recv_size) const +{ + send_size_list.resize(comm_sz,0); + for(int rank=0; rank!=comm_sz; ++rank) + { + for(const auto &H_pairs_tmp : H_atom_pairs_group_rank[rank]) + { + const size_t iat1 = H_pairs_tmp.first; + for(const size_t iat2 : *H_pairs_tmp.second) + send_size_list[rank] += ucell.atoms[ucell.iat2it[iat1]].nw * ucell.atoms[ucell.iat2it[iat2]].nw; + } + send_size_list[rank] *= sizeof(double); + } + + recv_size = 0; + for(const auto &pairs : H_atom_pairs_group) + { + size_t nw1=0, nw2=0; + for(size_t iat1 : pairs.first) + nw1 += ucell.atoms[ucell.iat2it[iat1]].nw; + for(size_t iat2 : pairs.second) + nw2 += ucell.atoms[ucell.iat2it[iat2]].nw; + recv_size += nw1*nw1; + } + recv_size *= sizeof(double); +} + + +void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::init_flags( + vector> &flags_send, + vector> &flags_recv) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM3::Allreduce::init_flags"); + + for(atomic &flag_send : flags_send) + flag_send = Flag_Send::undo; + flags_send[my_rank] = Flag_Send::finish_isend; + + for(atomic &flag_recv : flags_recv) + flag_recv = Flag_Recv::undo; + flags_recv[my_rank] = Flag_Recv::finish_iar; +} + + +bool Exx_Abfs::Parallel::Communicate::DM3::Allreduce::finish_judge( + const vector> &flags_send, + const vector> &flags_recv) const +{ + for(int rank_send=0; rank_send!=comm_sz; ++rank_send) + if((flags_send[rank_send]!=Flag_Send::begin_isend) && (flags_send[rank_send]!=Flag_Send::finish_isend)) + return false; + for(int rank_recv=0; rank_recv!=comm_sz; ++rank_recv) + if((flags_recv[rank_recv]!=Flag_Recv::begin_iar) && (flags_recv[rank_recv]!=Flag_Recv::finish_iar)) + return false; + return true; +} + + +bool Exx_Abfs::Parallel::Communicate::DM3::Allreduce::memory_enough( + const int rank_send_next, + const vector> &flags_send) const +{ + size_t memory_need = recv_size; + for(int rank_send=0; rank_sendsend_size_list[rank_send_next]) ? true : false; +} + + +/* +void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::send_data_process( + const int rank_send_now, + const vector,matrix>>>> &data_local, + vector> &oarps_isend, + vector> &flags_send) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM3::Allreduce::send_data_process"); + + vector &oarp = oarps_isend[rank_send_now]; + for( int is=0; is!=NSPIN; ++is ) + { + oarp.push_back(-999); const size_t index_size = oarp.size()-1; + auto ptr_data_A = data_local[is].begin(); + auto ptr_atom_A = H_atom_pairs_group_rank[rank_send_now].begin(); + while(ptr_data_A!=data_local[is].end() && ptr_atom_A!=H_atom_pairs_group_rank[rank_send_now].end()) + { + if(ptr_data_A->first < ptr_atom_A->first) ++ptr_data_A; + else if(ptr_data_A->first > ptr_atom_A->first) ++ptr_atom_A; + else + { + const size_t iat1 = ptr_data_A->first; + auto ptr_data_B = ptr_data_A->second.begin(); + auto ptr_atom_B = ptr_atom_A->second->begin(); + while(ptr_data_B!=ptr_data_A->second.end() && ptr_atom_B!=ptr_atom_A->second->end()) + { + const size_t iat2 = ptr_data_B->first; + if(ptr_data_B->first < *ptr_atom_B) ++ptr_data_B; + else if(ptr_data_B->first > *ptr_atom_B) ++ptr_atom_B; + else + { + for(const auto &data_C : ptr_data_B->second) + { + const Abfs::Vector3_Order &box2 = data_C.first; + const matrix &m = data_C.second; + oarp.push_back(iat1); + oarp.push_back(iat2); + oarp.push_back(box2.x); oarp.push_back(box2.y); oarp.push_back(box2.z); + oarp.push_back(m.nr); oarp.push_back(m.nc); + oarp.insert(oarp.end(), m.c, m.c+m.nr*m.nc); + } + ++ptr_data_B; ++ptr_atom_B; + } + } + ++ptr_data_A; ++ptr_atom_A; + } + } + oarp[index_size] = oarp.size() - (index_size+1); + } + flags_send[rank_send_now] = Flag_Send::finish_oar; +} +*/ + +void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::send_data_process( + const int rank_send_now, + const vector,matrix>>>> &data_local, + vector> &oarps_isend, + vector> &flags_send) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM3::Allreduce::send_data_process"); + + const vector,matrix*>>>> data_intersection = get_intersection( + rank_send_now, + const_cast,matrix>>>>&>(data_local)); + + vector &oarp = oarps_isend[rank_send_now]; + for( int is=0; is!=NSPIN; ++is ) + { + oarp.push_back(-999); const size_t index_size = oarp.size()-1; + for(const auto data_A : data_intersection[is]) + { + const size_t iat1 = data_A.first; + for(const auto data_B : data_A.second) + { + const size_t iat2 = data_B.first; + for(const auto data_C : data_B.second) + { + const Abfs::Vector3_Order &box2 = data_C.first; + const matrix &m = *data_C.second; + oarp.push_back(iat1); + oarp.push_back(iat2); + oarp.push_back(box2.x); oarp.push_back(box2.y); oarp.push_back(box2.z); + oarp.push_back(m.nr); oarp.push_back(m.nc); + oarp.insert(oarp.end(), m.c, m.c+m.nr*m.nc); + } + } + } + oarp[index_size] = oarp.size() - (index_size+1); + } + flags_send[rank_send_now] = Flag_Send::finish_oar; +} + +vector,matrix*>>>> Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_intersection( + const int rank_send_now, + vector,matrix>>>> &data_local) const +{ + vector,matrix*>>>> data_intersection(NSPIN); + for( int is=0; is!=NSPIN; ++is ) + { + auto ptr_data_A = data_local[is].begin(); + auto ptr_atom_A = H_atom_pairs_group_rank[rank_send_now].begin(); + while(ptr_data_A!=data_local[is].end() && ptr_atom_A!=H_atom_pairs_group_rank[rank_send_now].end()) + { + if(ptr_data_A->first < ptr_atom_A->first) ++ptr_data_A; + else if(ptr_data_A->first > ptr_atom_A->first) ++ptr_atom_A; + else + { + const size_t iat1 = ptr_data_A->first; + auto ptr_data_B = ptr_data_A->second.begin(); + auto ptr_atom_B = ptr_atom_A->second->begin(); + while(ptr_data_B!=ptr_data_A->second.end() && ptr_atom_B!=ptr_atom_A->second->end()) + { + const size_t iat2 = ptr_data_B->first; + if(ptr_data_B->first < *ptr_atom_B) ++ptr_data_B; + else if(ptr_data_B->first > *ptr_atom_B) ++ptr_atom_B; + else + { + for(auto &data_C : ptr_data_B->second) + { + const Abfs::Vector3_Order &box2 = data_C.first; + data_intersection[is][iat1][iat2][box2] = &data_C.second; + } + ++ptr_data_B; ++ptr_atom_B; + } + } + ++ptr_data_A; ++ptr_atom_A; + } + } + } + return data_intersection; +} + +void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::recv_data_process( + const int rank_recv, + vector,matrix>>>> &data_all, + vector> &iarps_irecv, + vector> &flags_recv, + atomic_flag &lock_insert) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM3::Allreduce::recv_data_process"); + + auto vector_empty = []( const vector,matrix>>>> &v ) -> bool + { + for( const auto &i : v ) + if(!i.empty()) return false; + return true; + }; + + vector,matrix>>>> data_rank(NSPIN); + auto ptr = iarps_irecv[rank_recv].begin(); + for( int is=0; is!=NSPIN; ++is ) + { + const size_t recv_size = ptr[0]; + ptr += 1; + auto ptr_end = ptr + recv_size; + while(ptr box2 = {ptr[2],ptr[3],ptr[4]}; + const int nr=ptr[5], nc=ptr[6]; + matrix &m = data_rank[is][iat1][iat2][box2]; + m.create(nr,nc); + copy( ptr+7, ptr+7+nr*nc, m.c ); + ptr += 7+nr*nc; + } + } + iarps_irecv[rank_recv].resize(0); iarps_irecv[rank_recv].shrink_to_fit(); + flags_recv[rank_recv] = Flag_Recv::finish_iar; + + if(!vector_empty(data_rank)) + { + while( lock_insert.test_and_set() ); + insert_data(data_rank, data_all); + lock_insert.clear(); + } +} + + +matrix& Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_matrix(matrix&m)const{ return m; } +matrix& Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_matrix(matrix*pm)const{ return *pm; } + + +template +void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::insert_data( + vector,M>>>> &data_rank, + vector,matrix>>>> &data_all) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM3::Allreduce::insert_data"); + for( int is=0; is!=NSPIN; ++is ) + { + auto &data_rank_is = data_rank[is]; + auto &data_all_is = data_all[is]; + for( auto &data_rank_A : data_rank_is ) + { + const size_t iat1 = data_rank_A.first; + auto &data_all_A = data_all_is[iat1]; + for( auto &data_rank_B : data_rank_A.second ) + { + const size_t iat2 = data_rank_B.first; + auto &data_all_B = data_all_A[iat2]; + for( auto &data_rank_C : data_rank_B.second ) + { + const Abfs::Vector3_Order &box2 = data_rank_C.first; + auto &data_all_C = data_all_B[box2]; + matrix &m = get_matrix(data_rank_C.second); + if( data_all_C.c ) + data_all_C += m; + else + data_all_C = std::move(m); + } + } + } + } +} diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm3.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm3.cpp new file mode 100644 index 0000000000..aa2df23c93 --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm3.cpp @@ -0,0 +1,91 @@ +#include "exx_abfs-parallel-communicate-dm3.h" +#include "src_pw/global.h" +#include "src_lcao/global_fp.h" +#include "src_global/matrix.h" +#include "src_global/complexmatrix.h" +#include "src_lcao/abfs-template.h" + +#include "src_external/src_test/test_function.h" + + +template<> vector,matrix>>>> +Exx_Abfs::Parallel::Communicate::DM3::K_to_R(const vector &DK_2D, const double threshold_D) const +{ + + TITLE("Exx_Abfs::Parallel::Communicate::DM3::K_to_R"); + assert(DK_2D.size()==NSPIN); + const double SPIN_multiple = 0.5*NSPIN; + + vector,matrix>>>> DR_a2D(NSPIN); + for(int is=0; is!=NSPIN; ++is) + { + for(int iwt1_local=0; iwt1_local!=DK_2D[is].nr; ++iwt1_local) + { + const int iwt1 = ParaO.MatrixInfo.col_set[iwt1_local]; + const int iat1 = ucell.iwt2iat[iwt1]; + const int iw1 = ucell.iwt2iw[iwt1]; + for(int iwt2_local=0; iwt2_local!=DK_2D[is].nc; ++iwt2_local) + { + const int iwt2 = ParaO.MatrixInfo.row_set[iwt2_local]; + const int iat2 = ucell.iwt2iat[iwt2]; + const int iw2 = ucell.iwt2iw[iwt2]; + const double dm = DK_2D[is](iwt1_local,iwt2_local); + if(abs(dm) > threshold_D) + { + matrix &DR_a2D_box2 = DR_a2D[is][iat1][iat2][{0,0,0}]; + if(!DR_a2D_box2.c) + DR_a2D_box2.create(ucell.atoms[ucell.iat2it[iat1]].nw, ucell.atoms[ucell.iat2it[iat2]].nw); + DR_a2D_box2(iw1,iw2) = DK_2D[is](iwt1_local,iwt2_local) * SPIN_multiple; + } + } + } + } + return DR_a2D; +} + +template<> vector,matrix>>>> +Exx_Abfs::Parallel::Communicate::DM3::K_to_R(const vector &DK_2D, const double threshold_D) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM3::K_to_R"); + const double SPIN_multiple = 0.5*NSPIN; + const Abfs::Vector3_Order Born_von_Karman_period = Vector3{kv.nmp[0],kv.nmp[1],kv.nmp[2]}; + const vector> supercell_boxes = Abfs::get_Born_von_Karmen_boxes(Born_von_Karman_period); + + vector,matrix>>>> DR_a2D(NSPIN); + for(int ik=0; ik!=DK_2D.size(); ++ik) + { + for(int iwt1_local=0; iwt1_local!=DK_2D[ik].nr; ++iwt1_local) + { + const int iwt1 = ParaO.MatrixInfo.col_set[iwt1_local]; + const int iat1 = ucell.iwt2iat[iwt1]; + const int iw1 = ucell.iwt2iw[iwt1]; + for(int iwt2_local=0; iwt2_local!=DK_2D[ik].nc; ++iwt2_local) + { + const int iwt2 = ParaO.MatrixInfo.row_set[iwt2_local]; + const int iat2 = ucell.iwt2iat[iwt2]; + const int iw2 = ucell.iwt2iw[iwt2]; + for(const Abfs::Vector3_Order &box2 : supercell_boxes) + { + matrix &DR_a2D_box2 = DR_a2D[kv.isk[ik]][iat1][iat2][box2]; + if(!DR_a2D_box2.c) + DR_a2D_box2.create(ucell.atoms[ucell.iat2it[iat1]].nw, ucell.atoms[ucell.iat2it[iat2]].nw); + DR_a2D_box2(iw1,iw2) += real( DK_2D[ik](iwt1_local,iwt2_local) * exp(-TWO_PI*IMAG_UNIT*(kv.kvec_c[ik]*(box2*ucell.latvec))) ) * SPIN_multiple; + } + } + } + } + for(auto &DR_a2D_is : DR_a2D) + Abfs::delete_threshold_ptrs(DR_a2D_is,threshold_D); + return DR_a2D; +} + + + +void Exx_Abfs::Parallel::Communicate::DM3::cal_DM(const double threshold_D) +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM3::cal_DM"); + vector,matrix>>>> DR_a2D = GAMMA_ONLY_LOCAL + ? K_to_R(LOC.wfc_dm_2d.dm_gamma, threshold_D) + : K_to_R(LOC.wfc_dm_2d.dm_k, threshold_D); + DMr = allreduce.a2D_to_exx(DR_a2D); +} \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm3.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm3.h new file mode 100644 index 0000000000..ec5bc0458d --- /dev/null +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm3.h @@ -0,0 +1,90 @@ +#ifndef EXX_ABFS_PARALLEL_COMMUNICATE_DM3_H +#define EXX_ABFS_PARALLEL_COMMUNICATE_DM3_H + +#include "src_lcao/exx_abfs-parallel.h" +#include "src_lcao/abfs-vector3_order.h" + +#include +#include +#include +#include + +using namespace std; + +class Exx_Abfs::Parallel::Communicate::DM3 +{ +public: + void cal_DM(const double threshold_D); + + vector,matrix>>>> DMr; + +private: + template vector,matrix>>>> + K_to_R(const vector &DK_2D, const double threshold_D) const; +// vector,matrix>>>> +// allreduce(const vector,matrix>>>> &DR_a2D); + + class Allreduce + { + public: + void init( + const MPI_Comm &mpi_comm_in, + const map,set> &H_atom_pairs_group); + vector,matrix>>>> a2D_to_exx( + vector,matrix>>>> &data_local) const; + + private: + vector>>> H_atom_pairs_group_rank; //H_atom_pairs_group_rank[rank][iat1][iat2] + vector send_size_list; + size_t recv_size; + + MPI_Comm mpi_comm; + int comm_sz; + int my_rank; + + enum class Flag_Send {undo, begin_oar, finish_oar, begin_isend, finish_isend}; + enum class Flag_Recv {undo, begin_irecv, begin_iar, finish_iar}; + + vector> get_atom_in_2D() const; + vector>>> get_H_atom_pairs_group_rank( + const map,set> &H_atom_pairs_group, + const vector> &atom_in_2D) const; + void get_send_recv_size( + const vector>>> &H_atom_pairs_group_rank, + const map,set> &H_atom_pairs_group, + vector &send_size_list, size_t &recv_size) const; + void init_flags( + vector> &flags_send, + vector> &flags_recv) const; + bool finish_judge( + const vector> &flags_send, + const vector> &flags_recv) const; + bool memory_enough( + const int rank_send_next, + const vector> &flags_send) const; + void send_data_process( + const int rank_send_now, + const vector,matrix>>>> &data_local, + vector> &oarps_isend, + vector> &flags_send) const; + vector,matrix*>>>> get_intersection( + const int rank_send_now, + vector,matrix>>>> &data_local) const; + void recv_data_process( + const int rank_recv, + vector,matrix>>>> &data_all, + vector> &iarps_irecv, + vector> &flags_recv, + atomic_flag &lock_insert) const; + template void insert_data( + vector,M>>>> &data_rank, + vector,matrix>>>> &data_all) const; + matrix& get_matrix(matrix&m) const; + matrix& get_matrix(matrix*pm) const; + }; + +public: + Allreduce allreduce; +}; + +#endif \ No newline at end of file diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp index 1149508895..ea65cfc88c 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp @@ -38,7 +38,7 @@ timeval t_all; gettimeofday(&t_all,NULL); vector> flags_send(comm_sz); vector> flags_recv(comm_sz); - init_elec(flags_send, flags_recv); + init_flags(flags_send, flags_recv); //ofs<<__LINE__<> oarps_isend(comm_sz); @@ -209,7 +209,7 @@ vector Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::get_send_size_ return send_size_list; } -void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::init_elec( +void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::init_flags( vector> &flags_send, vector> &flags_recv) const { diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.h index 59ecb949fd..63a527a4c3 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.h +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-hexx.h @@ -96,7 +96,7 @@ class Exx_Abfs::Parallel::Communicate::Hexx vector get_send_size_list( const set> &H_atom_pairs_core, const vector,vector>> &atom_in_2D_list) const; - void init_elec( + void init_flags( vector> &flags_send, vector> &flags_recv) const; bool finish_judge( diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel.h b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel.h index f21eee0b94..f3507d0442 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel.h +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel.h @@ -24,6 +24,8 @@ class Exx_Abfs::Parallel class DM; #elif EXX_DM==2 class DM2; + #elif EXX_DM==3 + class DM3; #endif }; }; diff --git a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp index 94285a4bb6..c05d8fb798 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_lcao.cpp @@ -795,6 +795,8 @@ ofs_mpi<<"TIME@ cauchy::init\t"<DM_para.cal_DM_k( Born_von_Karman_period, H_atom_pairs_core, info.dm_threshold ); ofs_mpi<<"TIME@ Exx_Lcao::cal_DM\t"<DM_para.cal_DM(info.dm_threshold); +ofs_mpi<<"TIME@ Exx_Lcao::cal_DM\t"< @@ -58,6 +60,8 @@ class Exx_Lcao Exx_Abfs::Parallel::Communicate::DM DM_para; #elif EXX_DM==2 Exx_Abfs::Parallel::Communicate::DM2 DM_para; +#elif EXX_DM==3 + Exx_Abfs::Parallel::Communicate::DM3 DM_para; #endif Exx_Abfs::Parallel::Communicate::Hexx Hexx_para; double energy = 0.0; From 49841f49b8a9249443b5d72d90fad1d3a9d6e897 Mon Sep 17 00:00:00 2001 From: jiyuyang Date: Tue, 8 Sep 2020 15:33:06 +0800 Subject: [PATCH 033/233] modified: src_pw/potential_libxc.cpp 1. add cutoff function for correlation functional 2. modify the old libxc interface to the new one --- .../source/src_pw/potential_libxc.cpp | 88 +++++++++++-------- 1 file changed, 51 insertions(+), 37 deletions(-) diff --git a/ABACUS.1.0.0/source/src_pw/potential_libxc.cpp b/ABACUS.1.0.0/source/src_pw/potential_libxc.cpp index f11455e5e3..c8d328371e 100644 --- a/ABACUS.1.0.0/source/src_pw/potential_libxc.cpp +++ b/ABACUS.1.0.0/source/src_pw/potential_libxc.cpp @@ -18,46 +18,48 @@ void Potential_Libxc::v_xc( vtxc = 0.0; v.zero_out(); - vector funcs = init_func(); + vector funcs = init_func(); const auto input_tmp = cal_input( funcs, rho_in ); const vector &rho = std::get<0>(input_tmp); const vector &sigma = std::get<1>(input_tmp); - for( XC(func_type) &func : funcs ) + for( xc_func_type &func : funcs ) { vector exc ( pw.nrxx ); vector vrho ( pw.nrxx * NSPIN ); vector vsigma( pw.nrxx * ((1==NSPIN)?1:3) ); - - auto process_exc = [&]() + + auto process_exc = [&](vector &sgn) { for( size_t is=0; is!=NSPIN; ++is ) for( size_t ir=0; ir!=pw.nrxx; ++ir ) - etxc += e2 * exc[ir] * rho[ir*NSPIN+is]; + etxc += e2 * exc[ir] * rho[ir*NSPIN+is] * sgn[ir*NSPIN+is]; }; - auto process_vrho = [&]() + auto process_vrho = [&](vector &sgn) { for( size_t is=0; is!=NSPIN; ++is ) + { for( size_t ir=0; ir!=pw.nrxx; ++ir ) { - v(is,ir) += e2 * vrho[ir*NSPIN+is]; - vtxc += e2 * vrho[ir*NSPIN+is] * rho_in[is][ir]; + v(is,ir) += e2 * vrho[ir*NSPIN+is] * sgn[ir*NSPIN+is]; + vtxc += e2 * vrho[ir*NSPIN+is] * sgn[ir*NSPIN+is] * rho_in[is][ir]; } + } }; - auto process_vsigma = [&]() + auto process_vsigma = [&](vector &sgn) { const std::vector>> &gdr = std::get<2>(input_tmp); vector>> h( NSPIN, vector>(pw.nrxx) ); if( 1==NSPIN ) for( size_t ir=0; ir!=pw.nrxx; ++ir ) - h[0][ir] = e2 * gdr[0][ir] * vsigma[ir]; + h[0][ir] = e2 * gdr[0][ir] * vsigma[ir] * 2.0 * sgn[ir]; else for( size_t ir=0; ir!=pw.nrxx; ++ir ) { - h[0][ir] = e2 * gdr[0][ir] * vsigma[ir*3 ] + gdr[1][ir] * vsigma[ir*3+1]; - h[1][ir] = e2 * gdr[1][ir] * vsigma[ir*3+2] + gdr[0][ir] * vsigma[ir*3+1]; + h[0][ir] = e2 * (gdr[0][ir] * vsigma[ir*3 ] * 2.0 * sgn[ir*2 ] + gdr[1][ir] * vsigma[ir*3+1] * sgn[ir*2] * sgn[ir*2+1]); + h[1][ir] = e2 * (gdr[1][ir] * vsigma[ir*3+2] * 2.0 * sgn[ir*2+1] + gdr[0][ir] * vsigma[ir*3+1] * sgn[ir*2] * sgn[ir*2+1]); } for( size_t is=0; is!=NSPIN; ++is ) { @@ -65,32 +67,44 @@ void Potential_Libxc::v_xc( GGA_PW::grad_dot( VECTOR_TO_PTR(h[is]), VECTOR_TO_PTR(dh) ); for( size_t ir=0; ir!=pw.nrxx; ++ir ) { - v(is,ir) -= e2 * dh[ir]; - vtxc -= e2 * dh[ir] * rho_in[is][ir]; + v(is,ir) -= dh[ir]; + vtxc -= dh[ir] * rho_in[is][ir]; } } }; + + constexpr double rho_threshold = 1E-6; + constexpr double grho_threshold = 1E-10; + xc_func_set_dens_threshold(&func, rho_threshold); + vector sgn( pw.nrxx * NSPIN, 1.0); + if(NSPIN==2 && func.info->family != XC_FAMILY_LDA && func.info->kind==XC_CORRELATION) + for( size_t ir=0; ir!=pw.nrxx; ++ir ) + { + if ( rho[ir*2]family ) { case XC_FAMILY_LDA: - XC(lda_exc_vxc)( &func, pw.nrxx,VECTOR_TO_PTR(rho), VECTOR_TO_PTR(exc), VECTOR_TO_PTR(vrho) ); - process_exc(); - process_vrho(); + xc_lda_exc_vxc( &func, pw.nrxx,VECTOR_TO_PTR(rho), VECTOR_TO_PTR(exc), VECTOR_TO_PTR(vrho) ); + process_exc(sgn); + process_vrho(sgn); break; case XC_FAMILY_GGA: case XC_FAMILY_HYB_GGA: - XC(gga_exc_vxc)( &func, pw.nrxx, VECTOR_TO_PTR(rho), VECTOR_TO_PTR(sigma), VECTOR_TO_PTR(exc), VECTOR_TO_PTR(vrho), VECTOR_TO_PTR(vsigma) ); - process_exc(); - process_vrho(); - process_vsigma(); + xc_gga_exc_vxc( &func, pw.nrxx, VECTOR_TO_PTR(rho), VECTOR_TO_PTR(sigma), VECTOR_TO_PTR(exc), VECTOR_TO_PTR(vrho), VECTOR_TO_PTR(vsigma) ); + process_exc(sgn); + process_vrho(sgn); + process_vsigma(sgn); break; default: throw domain_error("func.info->family ="+TO_STRING(func.info->family)+" unfinished in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; } - - XC(func_end)(&func); + xc_func_end(&func); } Parallel_Reduce::reduce_double_pool( etxc ); @@ -105,45 +119,45 @@ void Potential_Libxc::v_xc( -std::vector Potential_Libxc::init_func() +std::vector Potential_Libxc::init_func() { auto test_parameter_PBE0 = [&]() { TITLE("test_parameter_PBE0"); - XC(func_type) func; - XC(func_init)( &func, XC_HYB_GGA_XC_PBEH, XC_POLARIZED ); + xc_func_type func; + xc_func_init( &func, XC_HYB_GGA_XC_PBEH, XC_POLARIZED ); - cout< funcs; + std::vector funcs; const int xc_polarized = (1==NSPIN) ? XC_UNPOLARIZED : XC_POLARIZED; auto add_func = [&]( const int function ) { funcs.push_back({}); - XC(func_init)( &funcs.back(), function, xc_polarized ); + xc_func_init( &funcs.back(), function, xc_polarized ); }; if( 6==xcf.iexch_now && 8==xcf.igcx_now && 4==xcf.icorr_now && 4==xcf.igcc_now ) @@ -182,7 +196,7 @@ std::vector Potential_Libxc::init_func() std::tuple< std::vector, std::vector, std::vector>> > Potential_Libxc::cal_input( - const std::vector &funcs, + const std::vector &funcs, const double * const * const rho_in ) { // ..., ↑_{i},↓_{i}, ↑_{i+1},↓_{i+1}, ... @@ -253,7 +267,7 @@ Potential_Libxc::cal_input( }; - for( const XC(func_type) &func : funcs ) + for( const xc_func_type &func : funcs ) { switch( func.info->family ) { From ef3f1b3d936a1a0d142282f347e73fcf0887eac5 Mon Sep 17 00:00:00 2001 From: jiyuyang Date: Thu, 24 Sep 2020 20:08:51 +0800 Subject: [PATCH 034/233] modified: src_pw/potential_libxc.cpp modified: src_pw/potential_libxc.h 1. add #ifdef TEST_LIBXC and #endif --- ABACUS.1.0.0/source/src_pw/potential_libxc.cpp | 2 ++ ABACUS.1.0.0/source/src_pw/potential_libxc.h | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ABACUS.1.0.0/source/src_pw/potential_libxc.cpp b/ABACUS.1.0.0/source/src_pw/potential_libxc.cpp index c8d328371e..c950177485 100644 --- a/ABACUS.1.0.0/source/src_pw/potential_libxc.cpp +++ b/ABACUS.1.0.0/source/src_pw/potential_libxc.cpp @@ -1,3 +1,4 @@ +#ifdef TEST_LIBXC #include "potential_libxc.h" #include "src_pw/global.h" #include "src_lcao/global_fp.h" @@ -288,3 +289,4 @@ Potential_Libxc::cal_input( return std::make_tuple( rho, sigma, gdr ); } +#endif diff --git a/ABACUS.1.0.0/source/src_pw/potential_libxc.h b/ABACUS.1.0.0/source/src_pw/potential_libxc.h index c270dd47c2..8385e21a47 100644 --- a/ABACUS.1.0.0/source/src_pw/potential_libxc.h +++ b/ABACUS.1.0.0/source/src_pw/potential_libxc.h @@ -1,3 +1,4 @@ +#ifdef TEST_LIBXC #ifndef POTENTIAL_LIBXC_H #define POTENTIAL_LIBXC_H @@ -25,4 +26,5 @@ class Potential_Libxc const double * const * const rho_in ); }; -#endif \ No newline at end of file +#endif +#endif From 7638561212072010524a83dc4f451faaca9dd021 Mon Sep 17 00:00:00 2001 From: jiyuyang Date: Fri, 6 Nov 2020 15:18:20 +0800 Subject: [PATCH 035/233] add an argument "tag" in function print_input to specify if setting "nelec", "ocp", "ocp_set" in INPUT or not --- ABACUS.1.0.0/tools/opt_abfs_bash/exx.py | 12 ++++++------ ABACUS.1.0.0/tools/opt_abfs_bash/read_stru.py | 6 ++++-- ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py b/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py index f37b55a81a..9f0306a11e 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/exx.py @@ -14,7 +14,7 @@ def cal(): with open(f"{utils.folder_exx}/INPUT","w") as file: input_dict = read_stru.get_input_dict() input_dict["pseudo_dir"] = os.path.abspath(input_dict.get("pseudo_dir",r"./")) - read_stru.print_input(file,input_dict) + read_stru.print_input(file,input_dict,1) with open("STRU","r") as file: strus = re.compile("LATTICE_CONSTANT").split(file.read()) @@ -40,14 +40,14 @@ def cal(): file.write(textwrap.dedent(f"""\ #!/bin/bash #PBS -q gold5120 - #PBS -l nodes=1:ppn=28 - #PBS -l walltime=24:00:00 + #PBS -l nodes=2:ppn=28 + #PBS -l walltime=99:99:99 #PBS -o job.log #PBS -e job.err ulimit -s unlimited cd $PBS_O_WORKDIR EXEC={info["ABACUS"]} - mpirun -n 1 -env OMP_NUM_THREADS=28 $EXEC + mpirun -n 2 -env OMP_NUM_THREADS=28 $EXEC """)) elif utils.sub=="bsub": with open(f"{utils.folder_exx}/sub.sh","w") as file: @@ -56,7 +56,7 @@ def cal(): #BSUB -q renxg #BSUB -o job.log -e job.err #BSUB -n 6 - mpirun -n 1 -env OMP_NUM_THREADS=6 {info['ABACUS']} + mpirun -n 2 -env OMP_NUM_THREADS=28 {info['ABACUS']} """)) os.chdir(utils.folder_exx) @@ -71,4 +71,4 @@ def cal(): os.chdir("../") if __name__=="__main__": - cal() \ No newline at end of file + cal() diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/read_stru.py b/ABACUS.1.0.0/tools/opt_abfs_bash/read_stru.py index 2038e99867..da7cf3c34f 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/read_stru.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/read_stru.py @@ -28,10 +28,12 @@ def get_input_dict(): input_dict[label] = value return input_dict -def print_input(file,input_dict): +def print_input(file,input_dict,tag=0): print("INPUT_PARAMETERS",file=file) max_len = max([len(label) for label in input_dict]) for label,value in input_dict.items(): + if tag==0 and label in ["nelec", "ocp", "ocp_set"]: + continue print( label, " "*(max_len-len(label)+4), value, file=file) @@ -230,4 +232,4 @@ def print_folders(dis_weight): for i_dis,i_weight in dis_weight[T1,T2].items(): folders[utils.folder_name(T1,T2,i_dis)] = i_weight with open("folders","w") as file: - print(json.dumps(folders,indent=4), file=file) \ No newline at end of file + print(json.dumps(folders,indent=4), file=file) diff --git a/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py b/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py index b22c144566..a1db3cd042 100644 --- a/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py +++ b/ABACUS.1.0.0/tools/opt_abfs_bash/set_dimer.py @@ -25,7 +25,7 @@ def cal_ABACUS(T1,T2,i_dis): input_dict["gamma_only"] = 1 input_dict["pseudo_dir"] = os.path.abspath(input_dict.get("pseudo_dir",r"./")) input_dict["exx_opt_orb_lmax"] = len(info["Nu"])-1 - read_stru.print_input(file,input_dict) + read_stru.print_input(file,input_dict,0) with open(folder/"STRU","w") as file: Ts = (T1,) if T1==T2 else (T1,T2) @@ -174,4 +174,4 @@ def cal(): read_stru.print_folders(dis_weight) if __name__=="__main__": - cal() \ No newline at end of file + cal() From 9ab33f5644d91737ad37da3d2b23d0dbb5fd83ee Mon Sep 17 00:00:00 2001 From: linpz Date: Mon, 9 Nov 2020 15:56:47 +0800 Subject: [PATCH 036/233] 1. fix bug in exx_dm3 parallel. 1.1 src_lcao/exx_abfs-parallel-communicate-dm3-allreduce.cpp --- ...bfs-parallel-communicate-dm3-allreduce.cpp | 1087 +++++++++-------- 1 file changed, 546 insertions(+), 541 deletions(-) diff --git a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm3-allreduce.cpp b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm3-allreduce.cpp index e3de9f1621..f63f4cb2ed 100644 --- a/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm3-allreduce.cpp +++ b/ABACUS.1.0.0/source/src_lcao/exx_abfs-parallel-communicate-dm3-allreduce.cpp @@ -1,541 +1,546 @@ -#include "exx_abfs-parallel-communicate-dm3.h" - -#include "src_pw/global.h" -#include "src_global/global_function.h" - -#include -#include -#include - -#include "src_external/src_test/test_function.h" - - -void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::init( - const MPI_Comm &mpi_comm_in, - const map,set> &H_atom_pairs_group) -{ - TITLE("Exx_Abfs::Parallel::Communicate::DM3::Allreduce::init"); - - mpi_comm = mpi_comm_in; - MPI_Comm_size(mpi_comm, &comm_sz); - MPI_Comm_rank(mpi_comm, &my_rank); - - const vector> atom_in_2D = get_atom_in_2D(); - H_atom_pairs_group_rank = get_H_atom_pairs_group_rank(H_atom_pairs_group, atom_in_2D); - get_send_recv_size(H_atom_pairs_group_rank, H_atom_pairs_group, send_size_list, recv_size); - -ofstream ofs(exx_lcao.test_dir.process+"dm3_"+TO_STRING(my_rank)); -//ofs<,matrix>>>> - Exx_Abfs::Parallel::Communicate::DM3::Allreduce::a2D_to_exx( - vector,matrix>>>> &data_local) const -{ -ofstream ofs(exx_lcao.test_dir.process+"dm3_"+TO_STRING(my_rank), ofstream::app); -//ofs<,matrix>>>> data_all(NSPIN); - - vector> flags_send(comm_sz); - vector> flags_recv(comm_sz); - init_flags(flags_send, flags_recv); - - vector> oarps_isend(comm_sz); - vector> iarps_irecv(comm_sz); - - int rank_send_now = my_rank; - auto rank_send_next = [&]()->int{ return (rank_send_now+1)%comm_sz; }; - - atomic_flag lock_insert = ATOMIC_FLAG_INIT; - vector threads; - vectorrequests_isend(comm_sz); - vectorrequests_irecv(comm_sz); -ofs<<__LINE__<,matrix*>>>> data_intersection = get_intersection(my_rank, data_local); - while( lock_insert.test_and_set() ); - insert_data(data_intersection, data_all); - lock_insert.clear(); -ofs<<__LINE__<> Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_atom_in_2D() const -{ - vector> atom_in_2D(ucell.nat,{false,false}); - for(int iwt=0; iwt=0) - atom_in_2D[iat].first = true; - if(ParaO.trace_loc_col[iwt]>=0) - atom_in_2D[iat].second = true; - } - return atom_in_2D; -} - - -vector>>> Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_H_atom_pairs_group_rank( - const map,set> &H_atom_pairs_group, - const vector> &atom_in_2D) const -{ - vector H_atom_pairs_group_vector; - for(const auto &pairs : H_atom_pairs_group) - { - H_atom_pairs_group_vector.push_back(pairs.first.size()); - H_atom_pairs_group_vector.push_back(pairs.second.size()); - H_atom_pairs_group_vector.insert(H_atom_pairs_group_vector.end(), pairs.first.begin(), pairs.first.end()); - H_atom_pairs_group_vector.insert(H_atom_pairs_group_vector.end(), pairs.second.begin(), pairs.second.end()); - } - - vector rank_size(comm_sz); - vector rank_index(comm_sz); - for(size_t i=0; i(comm_sz,1)), VECTOR_TO_PTR(rank_index), MPI_INT, - mpi_comm ); - - size_t index_accumulate = 0; - for(size_t i=0; i H_atom_pairs_group_rank_vector(index_accumulate); - MPI_Allgatherv( - VECTOR_TO_PTR(H_atom_pairs_group_vector), H_atom_pairs_group_vector.size(), MPI_INT, - VECTOR_TO_PTR(H_atom_pairs_group_rank_vector), VECTOR_TO_PTR(rank_size), VECTOR_TO_PTR(rank_index), MPI_INT, - mpi_comm); - - vector>>> H_atom_pairs_group_rank(comm_sz); - auto ptr = H_atom_pairs_group_rank_vector.begin(); - for(int rank=0; rank!=comm_sz; ++rank) - { - const auto ptr_begin = ptr; - while(ptr < ptr_begin+rank_size[rank]) - { - const size_t atoms1_size = *ptr++; - const size_t atoms2_size = *ptr++; - if(atoms1_size&&atoms2_size) - { - shared_ptr> atoms2 = make_shared>(); - for(int i=0; iinsert(atom_require); - } - } - else - { - ptr += atoms1_size + atoms2_size; - } - } - } - return H_atom_pairs_group_rank; -} - - -void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_send_recv_size( - const vector>>> &H_atom_pairs_group_rank, - const map,set> &H_atom_pairs_group, - vector &send_size_list, size_t &recv_size) const -{ - send_size_list.resize(comm_sz,0); - for(int rank=0; rank!=comm_sz; ++rank) - { - for(const auto &H_pairs_tmp : H_atom_pairs_group_rank[rank]) - { - const size_t iat1 = H_pairs_tmp.first; - for(const size_t iat2 : *H_pairs_tmp.second) - send_size_list[rank] += ucell.atoms[ucell.iat2it[iat1]].nw * ucell.atoms[ucell.iat2it[iat2]].nw; - } - send_size_list[rank] *= sizeof(double); - } - - recv_size = 0; - for(const auto &pairs : H_atom_pairs_group) - { - size_t nw1=0, nw2=0; - for(size_t iat1 : pairs.first) - nw1 += ucell.atoms[ucell.iat2it[iat1]].nw; - for(size_t iat2 : pairs.second) - nw2 += ucell.atoms[ucell.iat2it[iat2]].nw; - recv_size += nw1*nw1; - } - recv_size *= sizeof(double); -} - - -void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::init_flags( - vector> &flags_send, - vector> &flags_recv) const -{ - TITLE("Exx_Abfs::Parallel::Communicate::DM3::Allreduce::init_flags"); - - for(atomic &flag_send : flags_send) - flag_send = Flag_Send::undo; - flags_send[my_rank] = Flag_Send::finish_isend; - - for(atomic &flag_recv : flags_recv) - flag_recv = Flag_Recv::undo; - flags_recv[my_rank] = Flag_Recv::finish_iar; -} - - -bool Exx_Abfs::Parallel::Communicate::DM3::Allreduce::finish_judge( - const vector> &flags_send, - const vector> &flags_recv) const -{ - for(int rank_send=0; rank_send!=comm_sz; ++rank_send) - if((flags_send[rank_send]!=Flag_Send::begin_isend) && (flags_send[rank_send]!=Flag_Send::finish_isend)) - return false; - for(int rank_recv=0; rank_recv!=comm_sz; ++rank_recv) - if((flags_recv[rank_recv]!=Flag_Recv::begin_iar) && (flags_recv[rank_recv]!=Flag_Recv::finish_iar)) - return false; - return true; -} - - -bool Exx_Abfs::Parallel::Communicate::DM3::Allreduce::memory_enough( - const int rank_send_next, - const vector> &flags_send) const -{ - size_t memory_need = recv_size; - for(int rank_send=0; rank_sendsend_size_list[rank_send_next]) ? true : false; -} - - -/* -void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::send_data_process( - const int rank_send_now, - const vector,matrix>>>> &data_local, - vector> &oarps_isend, - vector> &flags_send) const -{ - TITLE("Exx_Abfs::Parallel::Communicate::DM3::Allreduce::send_data_process"); - - vector &oarp = oarps_isend[rank_send_now]; - for( int is=0; is!=NSPIN; ++is ) - { - oarp.push_back(-999); const size_t index_size = oarp.size()-1; - auto ptr_data_A = data_local[is].begin(); - auto ptr_atom_A = H_atom_pairs_group_rank[rank_send_now].begin(); - while(ptr_data_A!=data_local[is].end() && ptr_atom_A!=H_atom_pairs_group_rank[rank_send_now].end()) - { - if(ptr_data_A->first < ptr_atom_A->first) ++ptr_data_A; - else if(ptr_data_A->first > ptr_atom_A->first) ++ptr_atom_A; - else - { - const size_t iat1 = ptr_data_A->first; - auto ptr_data_B = ptr_data_A->second.begin(); - auto ptr_atom_B = ptr_atom_A->second->begin(); - while(ptr_data_B!=ptr_data_A->second.end() && ptr_atom_B!=ptr_atom_A->second->end()) - { - const size_t iat2 = ptr_data_B->first; - if(ptr_data_B->first < *ptr_atom_B) ++ptr_data_B; - else if(ptr_data_B->first > *ptr_atom_B) ++ptr_atom_B; - else - { - for(const auto &data_C : ptr_data_B->second) - { - const Abfs::Vector3_Order &box2 = data_C.first; - const matrix &m = data_C.second; - oarp.push_back(iat1); - oarp.push_back(iat2); - oarp.push_back(box2.x); oarp.push_back(box2.y); oarp.push_back(box2.z); - oarp.push_back(m.nr); oarp.push_back(m.nc); - oarp.insert(oarp.end(), m.c, m.c+m.nr*m.nc); - } - ++ptr_data_B; ++ptr_atom_B; - } - } - ++ptr_data_A; ++ptr_atom_A; - } - } - oarp[index_size] = oarp.size() - (index_size+1); - } - flags_send[rank_send_now] = Flag_Send::finish_oar; -} -*/ - -void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::send_data_process( - const int rank_send_now, - const vector,matrix>>>> &data_local, - vector> &oarps_isend, - vector> &flags_send) const -{ - TITLE("Exx_Abfs::Parallel::Communicate::DM3::Allreduce::send_data_process"); - - const vector,matrix*>>>> data_intersection = get_intersection( - rank_send_now, - const_cast,matrix>>>>&>(data_local)); - - vector &oarp = oarps_isend[rank_send_now]; - for( int is=0; is!=NSPIN; ++is ) - { - oarp.push_back(-999); const size_t index_size = oarp.size()-1; - for(const auto data_A : data_intersection[is]) - { - const size_t iat1 = data_A.first; - for(const auto data_B : data_A.second) - { - const size_t iat2 = data_B.first; - for(const auto data_C : data_B.second) - { - const Abfs::Vector3_Order &box2 = data_C.first; - const matrix &m = *data_C.second; - oarp.push_back(iat1); - oarp.push_back(iat2); - oarp.push_back(box2.x); oarp.push_back(box2.y); oarp.push_back(box2.z); - oarp.push_back(m.nr); oarp.push_back(m.nc); - oarp.insert(oarp.end(), m.c, m.c+m.nr*m.nc); - } - } - } - oarp[index_size] = oarp.size() - (index_size+1); - } - flags_send[rank_send_now] = Flag_Send::finish_oar; -} - -vector,matrix*>>>> Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_intersection( - const int rank_send_now, - vector,matrix>>>> &data_local) const -{ - vector,matrix*>>>> data_intersection(NSPIN); - for( int is=0; is!=NSPIN; ++is ) - { - auto ptr_data_A = data_local[is].begin(); - auto ptr_atom_A = H_atom_pairs_group_rank[rank_send_now].begin(); - while(ptr_data_A!=data_local[is].end() && ptr_atom_A!=H_atom_pairs_group_rank[rank_send_now].end()) - { - if(ptr_data_A->first < ptr_atom_A->first) ++ptr_data_A; - else if(ptr_data_A->first > ptr_atom_A->first) ++ptr_atom_A; - else - { - const size_t iat1 = ptr_data_A->first; - auto ptr_data_B = ptr_data_A->second.begin(); - auto ptr_atom_B = ptr_atom_A->second->begin(); - while(ptr_data_B!=ptr_data_A->second.end() && ptr_atom_B!=ptr_atom_A->second->end()) - { - const size_t iat2 = ptr_data_B->first; - if(ptr_data_B->first < *ptr_atom_B) ++ptr_data_B; - else if(ptr_data_B->first > *ptr_atom_B) ++ptr_atom_B; - else - { - for(auto &data_C : ptr_data_B->second) - { - const Abfs::Vector3_Order &box2 = data_C.first; - data_intersection[is][iat1][iat2][box2] = &data_C.second; - } - ++ptr_data_B; ++ptr_atom_B; - } - } - ++ptr_data_A; ++ptr_atom_A; - } - } - } - return data_intersection; -} - -void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::recv_data_process( - const int rank_recv, - vector,matrix>>>> &data_all, - vector> &iarps_irecv, - vector> &flags_recv, - atomic_flag &lock_insert) const -{ - TITLE("Exx_Abfs::Parallel::Communicate::DM3::Allreduce::recv_data_process"); - - auto vector_empty = []( const vector,matrix>>>> &v ) -> bool - { - for( const auto &i : v ) - if(!i.empty()) return false; - return true; - }; - - vector,matrix>>>> data_rank(NSPIN); - auto ptr = iarps_irecv[rank_recv].begin(); - for( int is=0; is!=NSPIN; ++is ) - { - const size_t recv_size = ptr[0]; - ptr += 1; - auto ptr_end = ptr + recv_size; - while(ptr box2 = {ptr[2],ptr[3],ptr[4]}; - const int nr=ptr[5], nc=ptr[6]; - matrix &m = data_rank[is][iat1][iat2][box2]; - m.create(nr,nc); - copy( ptr+7, ptr+7+nr*nc, m.c ); - ptr += 7+nr*nc; - } - } - iarps_irecv[rank_recv].resize(0); iarps_irecv[rank_recv].shrink_to_fit(); - flags_recv[rank_recv] = Flag_Recv::finish_iar; - - if(!vector_empty(data_rank)) - { - while( lock_insert.test_and_set() ); - insert_data(data_rank, data_all); - lock_insert.clear(); - } -} - - -matrix& Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_matrix(matrix&m)const{ return m; } -matrix& Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_matrix(matrix*pm)const{ return *pm; } - - -template -void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::insert_data( - vector,M>>>> &data_rank, - vector,matrix>>>> &data_all) const -{ - TITLE("Exx_Abfs::Parallel::Communicate::DM3::Allreduce::insert_data"); - for( int is=0; is!=NSPIN; ++is ) - { - auto &data_rank_is = data_rank[is]; - auto &data_all_is = data_all[is]; - for( auto &data_rank_A : data_rank_is ) - { - const size_t iat1 = data_rank_A.first; - auto &data_all_A = data_all_is[iat1]; - for( auto &data_rank_B : data_rank_A.second ) - { - const size_t iat2 = data_rank_B.first; - auto &data_all_B = data_all_A[iat2]; - for( auto &data_rank_C : data_rank_B.second ) - { - const Abfs::Vector3_Order &box2 = data_rank_C.first; - auto &data_all_C = data_all_B[box2]; - matrix &m = get_matrix(data_rank_C.second); - if( data_all_C.c ) - data_all_C += m; - else - data_all_C = std::move(m); - } - } - } - } -} +#include "exx_abfs-parallel-communicate-dm3.h" + +#include "src_pw/global.h" +#include "src_global/global_function.h" + +#include +#include +#include + +#include "src_external/src_test/test_function.h" + + +void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::init( + const MPI_Comm &mpi_comm_in, + const map,set> &H_atom_pairs_group) +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM3::Allreduce::init"); + + mpi_comm = mpi_comm_in; + MPI_Comm_size(mpi_comm, &comm_sz); + MPI_Comm_rank(mpi_comm, &my_rank); + + const vector> atom_in_2D = get_atom_in_2D(); + H_atom_pairs_group_rank = get_H_atom_pairs_group_rank(H_atom_pairs_group, atom_in_2D); + get_send_recv_size(H_atom_pairs_group_rank, H_atom_pairs_group, send_size_list, recv_size); + +ofstream ofs(exx_lcao.test_dir.process+"dm3_"+TO_STRING(my_rank)); +//ofs<,matrix>>>> + Exx_Abfs::Parallel::Communicate::DM3::Allreduce::a2D_to_exx( + vector,matrix>>>> &data_local) const +{ +ofstream ofs(exx_lcao.test_dir.process+"dm3_"+TO_STRING(my_rank), ofstream::app); +//ofs<,matrix>>>> data_all(NSPIN); + + vector> flags_send(comm_sz); + vector> flags_recv(comm_sz); + init_flags(flags_send, flags_recv); + + vector> oarps_isend(comm_sz); + vector> iarps_irecv(comm_sz); + + int rank_send_now = my_rank; + auto rank_send_next = [&]()->int{ return (rank_send_now+1)%comm_sz; }; + + atomic_flag lock_insert = ATOMIC_FLAG_INIT; + vector threads; + vectorrequests_isend(comm_sz); + vectorrequests_irecv(comm_sz); +ofs<<__LINE__<,matrix*>>>> data_intersection = get_intersection(my_rank, data_local); + while( lock_insert.test_and_set() ); + insert_data(data_intersection, data_all); + lock_insert.clear(); +ofs<<__LINE__<> Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_atom_in_2D() const +{ + vector> atom_in_2D(ucell.nat,{false,false}); + for(int iwt=0; iwt=0) + atom_in_2D[iat].first = true; + if(ParaO.trace_loc_row[iwt]>=0) + atom_in_2D[iat].second = true; + } + else + throw domain_error(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + } + return atom_in_2D; +} + + +vector>>> Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_H_atom_pairs_group_rank( + const map,set> &H_atom_pairs_group, + const vector> &atom_in_2D) const +{ + vector H_atom_pairs_group_vector; + for(const auto &pairs : H_atom_pairs_group) + { + H_atom_pairs_group_vector.push_back(pairs.first.size()); + H_atom_pairs_group_vector.push_back(pairs.second.size()); + H_atom_pairs_group_vector.insert(H_atom_pairs_group_vector.end(), pairs.first.begin(), pairs.first.end()); + H_atom_pairs_group_vector.insert(H_atom_pairs_group_vector.end(), pairs.second.begin(), pairs.second.end()); + } + + vector rank_size(comm_sz); + vector rank_index(comm_sz); + for(size_t i=0; i(comm_sz,1)), VECTOR_TO_PTR(rank_index), MPI_INT, + mpi_comm ); + + size_t index_accumulate = 0; + for(size_t i=0; i H_atom_pairs_group_rank_vector(index_accumulate); + MPI_Allgatherv( + VECTOR_TO_PTR(H_atom_pairs_group_vector), H_atom_pairs_group_vector.size(), MPI_INT, + VECTOR_TO_PTR(H_atom_pairs_group_rank_vector), VECTOR_TO_PTR(rank_size), VECTOR_TO_PTR(rank_index), MPI_INT, + mpi_comm); + + vector>>> H_atom_pairs_group_rank(comm_sz); + auto ptr = H_atom_pairs_group_rank_vector.begin(); + for(int rank=0; rank!=comm_sz; ++rank) + { + const auto ptr_begin = ptr; + while(ptr < ptr_begin+rank_size[rank]) + { + const size_t atoms1_size = *ptr++; + const size_t atoms2_size = *ptr++; + if(atoms1_size&&atoms2_size) + { + shared_ptr> atoms2 = make_shared>(); + for(int i=0; iinsert(atom_require); + } + } + else + { + ptr += atoms1_size + atoms2_size; + } + } + } + return H_atom_pairs_group_rank; +} + + +void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_send_recv_size( + const vector>>> &H_atom_pairs_group_rank, + const map,set> &H_atom_pairs_group, + vector &send_size_list, size_t &recv_size) const +{ + send_size_list.resize(comm_sz,0); + for(int rank=0; rank!=comm_sz; ++rank) + { + for(const auto &H_pairs_tmp : H_atom_pairs_group_rank[rank]) + { + const size_t iat1 = H_pairs_tmp.first; + for(const size_t iat2 : *H_pairs_tmp.second) + send_size_list[rank] += ucell.atoms[ucell.iat2it[iat1]].nw * ucell.atoms[ucell.iat2it[iat2]].nw; + } + send_size_list[rank] *= sizeof(double); + } + + recv_size = 0; + for(const auto &pairs : H_atom_pairs_group) + { + size_t nw1=0, nw2=0; + for(size_t iat1 : pairs.first) + nw1 += ucell.atoms[ucell.iat2it[iat1]].nw; + for(size_t iat2 : pairs.second) + nw2 += ucell.atoms[ucell.iat2it[iat2]].nw; + recv_size += nw1*nw1; + } + recv_size *= sizeof(double); +} + + +void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::init_flags( + vector> &flags_send, + vector> &flags_recv) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM3::Allreduce::init_flags"); + + for(atomic &flag_send : flags_send) + flag_send = Flag_Send::undo; + flags_send[my_rank] = Flag_Send::finish_isend; + + for(atomic &flag_recv : flags_recv) + flag_recv = Flag_Recv::undo; + flags_recv[my_rank] = Flag_Recv::finish_iar; +} + + +bool Exx_Abfs::Parallel::Communicate::DM3::Allreduce::finish_judge( + const vector> &flags_send, + const vector> &flags_recv) const +{ + for(int rank_send=0; rank_send!=comm_sz; ++rank_send) + if((flags_send[rank_send]!=Flag_Send::begin_isend) && (flags_send[rank_send]!=Flag_Send::finish_isend)) + return false; + for(int rank_recv=0; rank_recv!=comm_sz; ++rank_recv) + if((flags_recv[rank_recv]!=Flag_Recv::begin_iar) && (flags_recv[rank_recv]!=Flag_Recv::finish_iar)) + return false; + return true; +} + + +bool Exx_Abfs::Parallel::Communicate::DM3::Allreduce::memory_enough( + const int rank_send_next, + const vector> &flags_send) const +{ + size_t memory_need = recv_size; + for(int rank_send=0; rank_sendsend_size_list[rank_send_next]) ? true : false; +} + + +/* +void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::send_data_process( + const int rank_send_now, + const vector,matrix>>>> &data_local, + vector> &oarps_isend, + vector> &flags_send) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM3::Allreduce::send_data_process"); + + vector &oarp = oarps_isend[rank_send_now]; + for( int is=0; is!=NSPIN; ++is ) + { + oarp.push_back(-999); const size_t index_size = oarp.size()-1; + auto ptr_data_A = data_local[is].begin(); + auto ptr_atom_A = H_atom_pairs_group_rank[rank_send_now].begin(); + while(ptr_data_A!=data_local[is].end() && ptr_atom_A!=H_atom_pairs_group_rank[rank_send_now].end()) + { + if(ptr_data_A->first < ptr_atom_A->first) ++ptr_data_A; + else if(ptr_data_A->first > ptr_atom_A->first) ++ptr_atom_A; + else + { + const size_t iat1 = ptr_data_A->first; + auto ptr_data_B = ptr_data_A->second.begin(); + auto ptr_atom_B = ptr_atom_A->second->begin(); + while(ptr_data_B!=ptr_data_A->second.end() && ptr_atom_B!=ptr_atom_A->second->end()) + { + const size_t iat2 = ptr_data_B->first; + if(ptr_data_B->first < *ptr_atom_B) ++ptr_data_B; + else if(ptr_data_B->first > *ptr_atom_B) ++ptr_atom_B; + else + { + for(const auto &data_C : ptr_data_B->second) + { + const Abfs::Vector3_Order &box2 = data_C.first; + const matrix &m = data_C.second; + oarp.push_back(iat1); + oarp.push_back(iat2); + oarp.push_back(box2.x); oarp.push_back(box2.y); oarp.push_back(box2.z); + oarp.push_back(m.nr); oarp.push_back(m.nc); + oarp.insert(oarp.end(), m.c, m.c+m.nr*m.nc); + } + ++ptr_data_B; ++ptr_atom_B; + } + } + ++ptr_data_A; ++ptr_atom_A; + } + } + oarp[index_size] = oarp.size() - (index_size+1); + } + flags_send[rank_send_now] = Flag_Send::finish_oar; +} +*/ + +void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::send_data_process( + const int rank_send_now, + const vector,matrix>>>> &data_local, + vector> &oarps_isend, + vector> &flags_send) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM3::Allreduce::send_data_process"); + + const vector,matrix*>>>> data_intersection = get_intersection( + rank_send_now, + const_cast,matrix>>>>&>(data_local)); + + vector &oarp = oarps_isend[rank_send_now]; + for( int is=0; is!=NSPIN; ++is ) + { + oarp.push_back(-999); const size_t index_size = oarp.size()-1; + for(const auto data_A : data_intersection[is]) + { + const size_t iat1 = data_A.first; + for(const auto data_B : data_A.second) + { + const size_t iat2 = data_B.first; + for(const auto data_C : data_B.second) + { + const Abfs::Vector3_Order &box2 = data_C.first; + const matrix &m = *data_C.second; + oarp.push_back(iat1); + oarp.push_back(iat2); + oarp.push_back(box2.x); oarp.push_back(box2.y); oarp.push_back(box2.z); + oarp.push_back(m.nr); oarp.push_back(m.nc); + oarp.insert(oarp.end(), m.c, m.c+m.nr*m.nc); + } + } + } + oarp[index_size] = oarp.size() - (index_size+1); + } + flags_send[rank_send_now] = Flag_Send::finish_oar; +} + +vector,matrix*>>>> Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_intersection( + const int rank_send_now, + vector,matrix>>>> &data_local) const +{ + vector,matrix*>>>> data_intersection(NSPIN); + for( int is=0; is!=NSPIN; ++is ) + { + auto ptr_data_A = data_local[is].begin(); + auto ptr_atom_A = H_atom_pairs_group_rank[rank_send_now].begin(); + while(ptr_data_A!=data_local[is].end() && ptr_atom_A!=H_atom_pairs_group_rank[rank_send_now].end()) + { + if(ptr_data_A->first < ptr_atom_A->first) ++ptr_data_A; + else if(ptr_data_A->first > ptr_atom_A->first) ++ptr_atom_A; + else + { + const size_t iat1 = ptr_data_A->first; + auto ptr_data_B = ptr_data_A->second.begin(); + auto ptr_atom_B = ptr_atom_A->second->begin(); + while(ptr_data_B!=ptr_data_A->second.end() && ptr_atom_B!=ptr_atom_A->second->end()) + { + const size_t iat2 = ptr_data_B->first; + if(ptr_data_B->first < *ptr_atom_B) ++ptr_data_B; + else if(ptr_data_B->first > *ptr_atom_B) ++ptr_atom_B; + else + { + for(auto &data_C : ptr_data_B->second) + { + const Abfs::Vector3_Order &box2 = data_C.first; + data_intersection[is][iat1][iat2][box2] = &data_C.second; + } + ++ptr_data_B; ++ptr_atom_B; + } + } + ++ptr_data_A; ++ptr_atom_A; + } + } + } + return data_intersection; +} + +void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::recv_data_process( + const int rank_recv, + vector,matrix>>>> &data_all, + vector> &iarps_irecv, + vector> &flags_recv, + atomic_flag &lock_insert) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM3::Allreduce::recv_data_process"); + + auto vector_empty = []( const vector,matrix>>>> &v ) -> bool + { + for( const auto &i : v ) + if(!i.empty()) return false; + return true; + }; + + vector,matrix>>>> data_rank(NSPIN); + auto ptr = iarps_irecv[rank_recv].begin(); + for( int is=0; is!=NSPIN; ++is ) + { + const size_t recv_size = ptr[0]; + ptr += 1; + auto ptr_end = ptr + recv_size; + while(ptr box2 = {ptr[2],ptr[3],ptr[4]}; + const int nr=ptr[5], nc=ptr[6]; + matrix &m = data_rank[is][iat1][iat2][box2]; + m.create(nr,nc); + copy( ptr+7, ptr+7+nr*nc, m.c ); + ptr += 7+nr*nc; + } + } + iarps_irecv[rank_recv].resize(0); iarps_irecv[rank_recv].shrink_to_fit(); + flags_recv[rank_recv] = Flag_Recv::finish_iar; + + if(!vector_empty(data_rank)) + { + while( lock_insert.test_and_set() ); + insert_data(data_rank, data_all); + lock_insert.clear(); + } +} + + +matrix& Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_matrix(matrix&m)const{ return m; } +matrix& Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_matrix(matrix*pm)const{ return *pm; } + + +template +void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::insert_data( + vector,M>>>> &data_rank, + vector,matrix>>>> &data_all) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM3::Allreduce::insert_data"); + for( int is=0; is!=NSPIN; ++is ) + { + auto &data_rank_is = data_rank[is]; + auto &data_all_is = data_all[is]; + for( auto &data_rank_A : data_rank_is ) + { + const size_t iat1 = data_rank_A.first; + auto &data_all_A = data_all_is[iat1]; + for( auto &data_rank_B : data_rank_A.second ) + { + const size_t iat2 = data_rank_B.first; + auto &data_all_B = data_all_A[iat2]; + for( auto &data_rank_C : data_rank_B.second ) + { + const Abfs::Vector3_Order &box2 = data_rank_C.first; + auto &data_all_C = data_all_B[box2]; + matrix &m = get_matrix(data_rank_C.second); + if( data_all_C.c ) + data_all_C += m; + else + data_all_C = std::move(m); + } + } + } + } +} From 3545ea8a049116b8a970b26c707d4fd4bb523225 Mon Sep 17 00:00:00 2001 From: linpz Date: Sun, 22 Nov 2020 17:39:20 +0800 Subject: [PATCH 037/233] 1. add soc in potential_libxc 1.1 src_pw/potential_libxc.h 1.2 src_pw/potential_libxc.cpp 1.3 src_pw/potential.cpp --- .../src_test/src_pw/potentail_libxc-test.h | 30 ++++ ABACUS.develop/source/src_pw/potential.cpp | 7 +- .../source/src_pw/potential_libxc.cpp | 152 ++++++++++-------- .../source/src_pw/potential_libxc.h | 9 ++ 4 files changed, 131 insertions(+), 67 deletions(-) create mode 100644 ABACUS.develop/source/src_external/src_test/src_pw/potentail_libxc-test.h diff --git a/ABACUS.develop/source/src_external/src_test/src_pw/potentail_libxc-test.h b/ABACUS.develop/source/src_external/src_test/src_pw/potentail_libxc-test.h new file mode 100644 index 0000000000..2e21867dd1 --- /dev/null +++ b/ABACUS.develop/source/src_external/src_test/src_pw/potentail_libxc-test.h @@ -0,0 +1,30 @@ +void test_libxc_parameter() +{ + auto test_parameter_PBE0 = [&]() + { + TITLE("test_parameter_PBE0"); + xc_func_type func; + xc_func_init( &func, XC_HYB_GGA_XC_PBEH, XC_POLARIZED ); + + cout< vanishing_charge ) { for(int ipol = 1;ipol< 4;ipol++) @@ -519,8 +522,6 @@ void potential::v_xc vtxc += v(ipol,ir) * rho_in[ipol][ir]; }//end do }//end if - etxc += e2 * ( ex + ec ) * rhox; - vtxc += v(0,ir) * rho_in[0][ir]; }//end if }//end do }//end if diff --git a/ABACUS.develop/source/src_pw/potential_libxc.cpp b/ABACUS.develop/source/src_pw/potential_libxc.cpp index c950177485..b75a8dc8b3 100644 --- a/ABACUS.develop/source/src_pw/potential_libxc.cpp +++ b/ABACUS.develop/source/src_pw/potential_libxc.cpp @@ -12,7 +12,7 @@ void Potential_Libxc::v_xc( double &vtxc, matrix &v) { - TITLE("potential","v_xc"); + TITLE("Potential_Libxc","v_xc"); timer::tick("Potential_Libxc","v_xc"); etxc = 0.0; @@ -27,33 +27,55 @@ void Potential_Libxc::v_xc( for( xc_func_type &func : funcs ) { - vector exc ( pw.nrxx ); - vector vrho ( pw.nrxx * NSPIN ); - vector vsigma( pw.nrxx * ((1==NSPIN)?1:3) ); + vector exc ( pw.nrxx ); + vector vrho ( pw.nrxx * nspin0() ); + vector vsigma( pw.nrxx * ((1==nspin0())?1:3) ); auto process_exc = [&](vector &sgn) { - for( size_t is=0; is!=NSPIN; ++is ) + for( size_t is=0; is!=nspin0(); ++is ) for( size_t ir=0; ir!=pw.nrxx; ++ir ) - etxc += e2 * exc[ir] * rho[ir*NSPIN+is] * sgn[ir*NSPIN+is]; + etxc += e2 * exc[ir] * rho[ir*nspin0()+is] * sgn[ir*nspin0()+is]; }; auto process_vrho = [&](vector &sgn) { - for( size_t is=0; is!=NSPIN; ++is ) + if(nspin0()==1 || NSPIN==2) { + for( size_t is=0; is!=nspin0(); ++is ) + for( size_t ir=0; ir!=pw.nrxx; ++ir ) + { + const double v_tmp = e2 * vrho[ir*nspin0()+is] * sgn[ir*nspin0()+is]; + v(is,ir) += v_tmp; + vtxc += v_tmp * rho_in[is][ir]; + } + } + else + { + constexpr double vanishing_charge = 1.0e-12; for( size_t ir=0; ir!=pw.nrxx; ++ir ) { - v(is,ir) += e2 * vrho[ir*NSPIN+is] * sgn[ir*NSPIN+is]; - vtxc += e2 * vrho[ir*NSPIN+is] * sgn[ir*NSPIN+is] * rho_in[is][ir]; + vector v_tmp(4); + v_tmp[0] = e2 * (0.5 * (vrho[ir*2] + vrho[ir*2+1])); + const double vs = 0.5 * (vrho[ir*2] - vrho[ir*2+1]); + const double amag = sqrt( pow(rho_in[1][ir],2) + pow(rho_in[2][ir],2) + pow(rho_in[3][ir],2) ); + if(amag>vanishing_charge) + for(int ipol=1; ipol<4; ++ipol) + v_tmp[ipol] = e2 * vs * rho_in[ipol][ir] / amag; + for(int ipol=0; ipol<4; ++ipol) + { + v(ipol, ir) += v_tmp[ipol]; + vtxc += v_tmp[ipol] * rho_in[ipol][ir]; + } } } + }; auto process_vsigma = [&](vector &sgn) { const std::vector>> &gdr = std::get<2>(input_tmp); - vector>> h( NSPIN, vector>(pw.nrxx) ); - if( 1==NSPIN ) + vector>> h( nspin0(), vector>(pw.nrxx) ); + if( 1==nspin0() ) for( size_t ir=0; ir!=pw.nrxx; ++ir ) h[0][ir] = e2 * gdr[0][ir] * vsigma[ir] * 2.0 * sgn[ir]; else @@ -62,14 +84,32 @@ void Potential_Libxc::v_xc( h[0][ir] = e2 * (gdr[0][ir] * vsigma[ir*3 ] * 2.0 * sgn[ir*2 ] + gdr[1][ir] * vsigma[ir*3+1] * sgn[ir*2] * sgn[ir*2+1]); h[1][ir] = e2 * (gdr[1][ir] * vsigma[ir*3+2] * 2.0 * sgn[ir*2+1] + gdr[0][ir] * vsigma[ir*3+1] * sgn[ir*2] * sgn[ir*2+1]); } - for( size_t is=0; is!=NSPIN; ++is ) + + vector> dh(nspin0(), vector(pw.nrxx)); + for( size_t is=0; is!=nspin0(); ++is ) + GGA_PW::grad_dot( VECTOR_TO_PTR(h[is]), VECTOR_TO_PTR(dh[is]) ); + + for( size_t is=0; is!=nspin0(); ++is ) + for( size_t ir=0; ir!=pw.nrxx; ++ir ) + vtxc -= dh[is][ir] * rho[ir*nspin0()+is]; + + if(nspin0()==1 || NSPIN==2) { - vector dh(pw.nrxx); - GGA_PW::grad_dot( VECTOR_TO_PTR(h[is]), VECTOR_TO_PTR(dh) ); + for( size_t is=0; is!=nspin0(); ++is ) + for( size_t ir=0; ir!=pw.nrxx; ++ir ) + v(is,ir) -= dh[is][ir]; + } + else + { + constexpr double vanishing_charge = 1.0e-12; for( size_t ir=0; ir!=pw.nrxx; ++ir ) { - v(is,ir) -= dh[ir]; - vtxc -= dh[ir] * rho_in[is][ir]; + v(0,ir) -= 0.5 * (dh[0][ir] + dh[1][ir]); + const double amag = sqrt( pow(rho_in[1][ir],2) + pow(rho_in[2][ir],2) + pow(rho_in[3][ir],2) ); + const double neg = (soc.lsign && rho_in[1][ir]*soc.ux[0]+rho_in[2][ir]*soc.ux[1]+rho_in[3][ir]*soc.ux[2]<=0) ? -1 : 1; + if(amag > vanishing_charge) + for(int i=1;i<4;i++) + v(i,ir) -= neg * 0.5 * (dh[0][ir]-dh[1][ir]) * rho_in[i][ir] / amag; } } }; @@ -77,8 +117,8 @@ void Potential_Libxc::v_xc( constexpr double rho_threshold = 1E-6; constexpr double grho_threshold = 1E-10; xc_func_set_dens_threshold(&func, rho_threshold); - vector sgn( pw.nrxx * NSPIN, 1.0); - if(NSPIN==2 && func.info->family != XC_FAMILY_LDA && func.info->kind==XC_CORRELATION) + vector sgn( pw.nrxx * nspin0(), 1.0); + if(nspin0()==2 && func.info->family != XC_FAMILY_LDA && func.info->kind==XC_CORRELATION) for( size_t ir=0; ir!=pw.nrxx; ++ir ) { if ( rho[ir*2] Potential_Libxc::init_func() { - auto test_parameter_PBE0 = [&]() - { - TITLE("test_parameter_PBE0"); - xc_func_type func; - xc_func_init( &func, XC_HYB_GGA_XC_PBEH, XC_POLARIZED ); - - cout< funcs; - const int xc_polarized = (1==NSPIN) ? XC_UNPOLARIZED : XC_POLARIZED; + const int xc_polarized = (1==nspin0()) ? XC_UNPOLARIZED : XC_POLARIZED; auto add_func = [&]( const int function ) { @@ -215,12 +226,25 @@ Potential_Libxc::cal_input( { if(!finished_rho) { - rho.resize( pw.nrxx * NSPIN ); - for( size_t is=0; is!=NSPIN; ++is ) + rho.resize(pw.nrxx*nspin0()); + if(nspin0()==1 || NSPIN==2) + { + for( size_t is=0; is!=nspin0(); ++is ) + for( size_t ir=0; ir!=pw.nrxx; ++ir ) + rho[ir*nspin0()+is] = rho_in[is][ir] + 1.0/nspin0()*chr.rho_core[ir]; + } + else + { + if(xcf.igcx||xcf.igcc) + soc.cal_ux(ucell.ntype); for( size_t ir=0; ir!=pw.nrxx; ++ir ) { - rho[ir*NSPIN+is] = rho_in[is][ir] + 1.0/NSPIN*chr.rho_core[ir]; + const double amag = sqrt( pow(rho_in[1][ir],2) + pow(rho_in[2][ir],2) + pow(rho_in[3][ir],2) ); + const double neg = (soc.lsign && rho_in[1][ir]*soc.ux[0]+rho_in[2][ir]*soc.ux[1]+rho_in[3][ir]*soc.ux[2]<=0) ? -1 : 1; + rho[ir*2] = 0.5 * (rho_in[0][ir] + neg * amag) + 0.5 * chr.rho_core[ir]; + rho[ir*2+1] = 0.5 * (rho_in[0][ir] - neg * amag) + 0.5 * chr.rho_core[ir]; } + } } finished_rho = true; }; @@ -229,19 +253,17 @@ Potential_Libxc::cal_input( { if(!finished_gdr) { - for( size_t is=0; is!=NSPIN; ++is ) - chr.set_rhog(chr.rho[is], chr.rhog[is]); - chr.set_rhog(chr.rho_core, chr.rhog_core); - - gdr.resize( NSPIN ); - for( size_t is=0; is!=NSPIN; ++is ) + gdr.resize( nspin0() ); + for( size_t is=0; is!=nspin0(); ++is ) { - vector>rhog(pw.ngmc); - for(int ig=0; ig rhor(pw.nrxx); + for(int ir=0; ir> rhog(pw.ngmc); + chr.set_rhog(rhor.data(), rhog.data()); gdr[is].resize(pw.nrxx); - GGA_PW::grad_rho( VECTOR_TO_PTR(rhog), VECTOR_TO_PTR(gdr[is]) ); + GGA_PW::grad_rho(rhog.data(), gdr[is].data()); } } finished_gdr = true; @@ -251,9 +273,9 @@ Potential_Libxc::cal_input( { if(!finished_sigma) { - sigma.resize( pw.nrxx * ((1==NSPIN)?1:3) ); + sigma.resize( pw.nrxx * ((1==nspin0())?1:3) ); - if( 1==NSPIN ) + if( 1==nspin0() ) for( size_t ir=0; ir!=pw.nrxx; ++ir ) sigma[ir] = gdr[0][ir]*gdr[0][ir]; else @@ -267,7 +289,6 @@ Potential_Libxc::cal_input( finished_sigma = true; }; - for( const xc_func_type &func : funcs ) { switch( func.info->family ) @@ -289,4 +310,7 @@ Potential_Libxc::cal_input( return std::make_tuple( rho, sigma, gdr ); } + + + #endif diff --git a/ABACUS.develop/source/src_pw/potential_libxc.h b/ABACUS.develop/source/src_pw/potential_libxc.h index 8385e21a47..d10d1c263c 100644 --- a/ABACUS.develop/source/src_pw/potential_libxc.h +++ b/ABACUS.develop/source/src_pw/potential_libxc.h @@ -4,6 +4,8 @@ #include "src_global/matrix.h" #include "src_global/vector3.h" +#include "src_global/global_variable.h" +#include "src_global/global_function.h" #include #include #include @@ -24,6 +26,13 @@ class Potential_Libxc cal_input( const std::vector &funcs, const double * const * const rho_in ); + + static int nspin0() + { + if (NSPIN==1 || (NSPIN==4 && (!DOMAG && !DOMAG_Z))) return 1; + else if(NSPIN==2 || (NSPIN==4 && ( DOMAG || DOMAG_Z))) return 2; + else throw runtime_error(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + } }; #endif From dd108fc32d4d36da11514604f4baf7ad26b5289a Mon Sep 17 00:00:00 2001 From: linpz Date: Thu, 26 Nov 2020 20:37:52 +0800 Subject: [PATCH 038/233] 1. add soc in exx --- .../src_external/src_pdiag/pdiag_double.cpp | 53 +++++++ .../src_test/src_global/complexmatrix-test.h | 10 +- .../src_external/src_test/test_function.h | 5 +- ABACUS.develop/source/src_global/matrix.h | 4 +- .../source/src_lcao/abfs-template.h | 34 +++++ ABACUS.develop/source/src_lcao/abfs.h | 16 ++- ...x_abfs-parallel-communicate-dm3-template.h | 96 +++++++++++++ .../exx_abfs-parallel-communicate-dm3.cpp | 30 +++- .../exx_abfs-parallel-communicate-dm3.h | 6 +- ..._abfs-parallel-communicate-hexx-template.h | 131 +++++++++++++++++- .../exx_abfs-parallel-communicate-hexx.cpp | 93 ++++--------- .../exx_abfs-parallel-communicate-hexx.h | 26 ++-- ABACUS.develop/source/src_lcao/exx_lcao.cpp | 3 +- .../source/src_lcao/numerical_nonlocal.cpp | 6 +- ABACUS.develop/source/src_lcao/wfc_dm_2d.cpp | 18 ++- 15 files changed, 433 insertions(+), 98 deletions(-) create mode 100644 ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3-template.h diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp b/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp index caa3417198..8d5fd96a7e 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp +++ b/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp @@ -771,6 +771,59 @@ void Pdiag_Double::diago_double_begin(const int &ik, double **wfc, matrix &wfc_2 void Pdiag_Double::diago_complex_begin(const int &ik, complex **wfc, ComplexMatrix &wfc_2d, complex* ch_mat, complex* cs_mat, double *ekb) { + #ifdef TEST_DIAG + { + static int istep = 0; + auto print_matrix_C = [&](const string &file_name, complex*m) + { + ofstream ofs(file_name+"-C_"+TO_STRING(istep)+"_"+TO_STRING(MY_RANK)); + for(int ic=0; ic1E-10) + { + if(std::imag(m[index])>1E-10) + ofs<*m) + { + ofstream ofs(file_name+"-F_"+TO_STRING(istep)+"_"+TO_STRING(MY_RANK)); + for(int ir=0; ir1E-10) + { + if(std::imag(m[index])>1E-10) + ofs<1E-10) + { + if(std::imag(m(ir,ic))>1E-10) + os< &v ) { os<<"["; for( const T &i : v ) - os< static std::ostream & operator<<( std::ostream & os, const std::map &v ) { for( const auto &i : v ) - os<<"{"<=0); assert(ir=0); assert(ic=0); assert(ir=0); assert(ic=0); assert(ir=0); assert(ic=0); assert(ir=0); assert(ic>>> &ptrs ) } } +template +void Abfs::delete_threshold_ptrs( map &ptrs, const double threshold ) +{ + for( auto iter=ptrs.begin(); iter!=ptrs.end(); ) + { + if( iter->second.absmax()<=threshold ) ptrs.erase(iter++); + else ++iter; + } +} + +template +void Abfs::delete_threshold_ptrs( map> &ptrs, const double threshold ) +{ + for( auto iter=ptrs.begin(); iter!=ptrs.end(); ) + { + if( iter->second->absmax()<=threshold ) ptrs.erase(iter++); + else ++iter; + } +} + + +template +void Abfs::delete_threshold_ptrs( map> &ptrs, const double threshold ) +{ + for( auto iter=ptrs.begin(); iter!=ptrs.end(); ) + { + delete_threshold_ptrs(iter->second, threshold); + if( iter->second.empty() ) ptrs.erase(iter++); + else ++iter; + } +} + +/* template void Abfs::delete_threshold_ptrs( map>>> &ptrs, const double threshold) { @@ -65,6 +98,7 @@ void Abfs::delete_threshold_ptrs( map>> &ptrs, const d else ++iter1; } } +*/ template vector> Abfs::get_atom_pair(const map> &m) diff --git a/ABACUS.develop/source/src_lcao/abfs.h b/ABACUS.develop/source/src_lcao/abfs.h index e9b5658edd..4a072e2140 100644 --- a/ABACUS.develop/source/src_lcao/abfs.h +++ b/ABACUS.develop/source/src_lcao/abfs.h @@ -92,10 +92,18 @@ class Abfs template static void delete_empty_ptrs( map>>> &ptrs ); - template - static void delete_threshold_ptrs( map>>> &ptrs, const double threshold); - template - static void delete_threshold_ptrs( map>> &ptrs, const double threshold); +// template +// static void delete_threshold_ptrs( map>>> &ptrs, const double threshold); +// template +// static void delete_threshold_ptrs( map>> &ptrs, const double threshold); + template + static void delete_threshold_ptrs( map &ptrs, const double threshold ); + template + static void delete_threshold_ptrs( map> &ptrs, const double threshold ); + template + static void delete_threshold_ptrs( map> &ptrs, const double threshold ); +// template +// static void delete_threshold_ptrs( map &ptrs, const double threshold ); template static vector> get_atom_pair(const map> &m); diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3-template.h b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3-template.h new file mode 100644 index 0000000000..7e838730bc --- /dev/null +++ b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3-template.h @@ -0,0 +1,96 @@ +#include "exx_abfs-parallel-communicate-dm3.h" +#include "src_pw/global.h" + +const matrix &Exx_Abfs::Parallel::Communicate::DM3::D_phase( + const matrix &DK, const int ik, const Abfs::Vector3_Order &box2) const +{ + assert(box2 == Abfs::Vector3_Order(0,0,0)); + return DK; +} + +matrix Exx_Abfs::Parallel::Communicate::DM3::D_phase( + const ComplexMatrix &DK, const int ik, const Abfs::Vector3_Order &box2) const +{ + return (DK * exp( -TWO_PI*IMAG_UNIT * (kv.kvec_c[ik] * (box2*ucell.latvec)) )).real(); +} + + +template vector,matrix>>>> +Exx_Abfs::Parallel::Communicate::DM3::K_to_R(const vector &DK_2D, const double threshold_D) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::DM3::K_to_R"); + + /*{ + static int istep=0; + ofstream ofs("DK_2D_"+TO_STRING(istep++)+"_"+TO_STRING(MY_RANK)); + ofs<,matrix>>>> DR_a2D(NSPIN); + + const map nspin_2D = {{1,1}, {2,2}, {4,1}}; + const map SPIN_multiple = {{1,0.5}, {2,1}, {4,1}}; // ??? + const Abfs::Vector3_Order Born_von_Karman_period = Vector3{kv.nmp[0],kv.nmp[1],kv.nmp[2]}; + const vector> supercell_boxes = Abfs::get_Born_von_Karmen_boxes(Born_von_Karman_period); + for(const Abfs::Vector3_Order &box2 : supercell_boxes) + { + vector DR_2D( nspin_2D.at(NSPIN), + {DK_2D[0].nr, DK_2D[0].nc} ); + for(int ik=0; ik!=DK_2D.size(); ++ik) + DR_2D[kv.isk[ik]] += D_phase( DK_2D[ik], ik, box2); + + // C++: 0 1 + // 2 3 + vector>> DR_a2D_box2(NSPIN); + for(int is_2D=0; is_2D!=nspin_2D.at(NSPIN); ++is_2D) + { + for(int iwt1_local=0; iwt1_local!=DR_2D[is_2D].nr; ++iwt1_local) + { + const int iwt1 = ParaO.MatrixInfo.col_set[iwt1_local]; + const int iat1 = ucell.iwt2iat[iwt1]; + const int iw1 = ucell.iwt2iw[iwt1]; + for(int iwt2_local=0; iwt2_local!=DR_2D[is_2D].nc; ++iwt2_local) + { + const int iwt2 = ParaO.MatrixInfo.row_set[iwt2_local]; + const int iat2 = ucell.iwt2iat[iwt2]; + const int iw2 = ucell.iwt2iw[iwt2]; + + int is_R=is_2D, iw1_R=iw1, iw2_R=iw2; + if(NSPIN==4) + { + iw1_R = iw1/2; + iw2_R = iw2/2; + is_R = iw1%2*2 + iw2%2; + } + matrix &DR_a2D_tmp = DR_a2D_box2[is_R][iat1][iat2]; + if(!DR_a2D_tmp.c) + DR_a2D_tmp.create(ucell.atoms[ucell.iat2it[iat1]].nw, ucell.atoms[ucell.iat2it[iat2]].nw); + DR_a2D_tmp(iw1_R,iw2_R) = DR_2D[is_2D](iwt1_local,iwt2_local) * SPIN_multiple.at(NSPIN); + } + } + } + + for(auto &DR_a2D_box2_is : DR_a2D_box2) + Abfs::delete_threshold_ptrs(DR_a2D_box2_is,threshold_D); + + for(int is=0; is!=NSPIN; ++is) + { + for(auto & DR_a2D_box2_A : DR_a2D_box2[is]) + { + const size_t iat1 = DR_a2D_box2_A.first; + for(auto & DR_a2D_box2_B : DR_a2D_box2_A.second) + { + const size_t iat2 = DR_a2D_box2_B.first; + DR_a2D[is][iat1][iat2][box2] = std::move(DR_a2D_box2_B.second); + } + } + } + } + + /*{ + static int istep=0; + ofstream ofs("DR_a2D_"+TO_STRING(istep++)+"_"+TO_STRING(MY_RANK)); + ofs< vector,matrix>>>> Exx_Abfs::Parallel::Communicate::DM3::K_to_R(const vector &DK_2D, const double threshold_D) const { @@ -42,10 +42,18 @@ Exx_Abfs::Parallel::Communicate::DM3::K_to_R(const vector &DK_2D, const } return DR_a2D; } +*/ +/* template<> vector,matrix>>>> Exx_Abfs::Parallel::Communicate::DM3::K_to_R(const vector &DK_2D, const double threshold_D) const { + { + static int istep=0; + ofstream ofs("DK_2D_"+TO_STRING(istep++)+"_"+TO_STRING(MY_RANK)); + ofs< Born_von_Karman_period = Vector3{kv.nmp[0],kv.nmp[1],kv.nmp[2]}; @@ -76,9 +84,15 @@ Exx_Abfs::Parallel::Communicate::DM3::K_to_R(const vector &DK_2D, } for(auto &DR_a2D_is : DR_a2D) Abfs::delete_threshold_ptrs(DR_a2D_is,threshold_D); + + { + static int istep=0; + ofstream ofs("DR_a2D_"+TO_STRING(istep++)+"_"+TO_STRING(MY_RANK)); + ofs<,matrix>>>> DMr; private: - template vector,matrix>>>> - K_to_R(const vector &DK_2D, const double threshold_D) const; + template vector,matrix>>>> + K_to_R(const vector &DK_2D, const double threshold_D) const; + const matrix &D_phase( const matrix &DK, const int ik, const Abfs::Vector3_Order &box2) const; + matrix D_phase( const ComplexMatrix &DK, const int ik, const Abfs::Vector3_Order &box2) const; // vector,matrix>>>> // allreduce(const vector,matrix>>>> &DR_a2D); diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx-template.h b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx-template.h index d3955f1929..aabfd27277 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx-template.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx-template.h @@ -2,10 +2,11 @@ #define EXX_ABFS_PARALLEL_COMMUNICATE_HEXX_TEMPLATE_H #include "exx_abfs-parallel-communicate-hexx.h" - #include "src_pw/global.h" #include "src_lcao/global_fp.h" +#include +/* template< typename T > T Exx_Abfs::Parallel::Communicate::Hexx::a2D_to_m2D( const map> & H_a2D ) const { @@ -47,15 +48,135 @@ T Exx_Abfs::Parallel::Communicate::Hexx::a2D_to_m2D( const map +matrix Exx_Abfs::Parallel::Communicate::Hexx::H_phase( + matrix &&HR, const int ik, const Abfs::Vector3_Order &box2) const +{ + assert(box2 == Abfs::Vector3_Order(0,0,0)); + return std::forward(HR); +} + +template<> +ComplexMatrix Exx_Abfs::Parallel::Communicate::Hexx::H_phase( + matrix &&HR, const int ik, const Abfs::Vector3_Order &box2) const +{ + return ComplexMatrix(HR) * exp( TWO_PI*IMAG_UNIT * (kv.kvec_c[ik] * (box2*ucell.latvec)) ); +} + +template +Tmatrix Exx_Abfs::Parallel::Communicate::Hexx::Ra2D_to_Km2D( + vector,matrix>>>> &HR_a2D, const int ik) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::Hexx::Ra2D_to_Km2D"); + + Tmatrix HK_m2D; + if(KS_SOLVER=="genelpa") + HK_m2D.create( ParaO.ncol, ParaO.nrow ); + else + HK_m2D.create( ParaO.nrow, ParaO.ncol ); + + const int is_begin = (NSPIN==4) ? 0 : kv.isk[ik]; + const int is_end = (NSPIN==4) ? 4 : kv.isk[ik]+1; + for(int is=is_begin; is!=is_end; ++is) + { + for(auto & HR_a2D_A : HR_a2D[is]) + { + const size_t iat1 = HR_a2D_A.first; + const size_t it1 = ucell.iat2it[iat1]; + const size_t ia1 = ucell.iat2ia[iat1]; + for(auto & HR_a2D_B : HR_a2D_A.second) + { + const size_t iat2 = HR_a2D_B.first; + const size_t it2 = ucell.iat2it[iat2]; + const size_t ia2 = ucell.iat2ia[iat2]; + + Tmatrix HK_a2D; + for(auto & HR_a2D_C : HR_a2D_B.second) + { + const Abfs::Vector3_Order &box2 = HR_a2D_C.first; + if(HK_a2D.c) + HK_a2D += H_phase(std::forward(HR_a2D_C.second), ik, box2); + else + HK_a2D = H_phase(std::forward(HR_a2D_C.second), ik, box2); + } + + for(int iw1=0; iw1!=HK_a2D.nr; ++iw1) + { + const int iw1_tmp = (NSPIN==4) + ? (iw1*2+is/2) + : iw1; + const int iwt1 = ucell.itiaiw2iwt(it1,ia1,iw1_tmp); + const int iwt1_m2D = ParaO.trace_loc_row[iwt1]; + if(iwt1_m2D<0) continue; + for(int iw2=0; iw2!=HK_a2D.nc; ++iw2) + { + const int iw2_tmp = (NSPIN==4) + ? (iw2*2+is%2) + : iw2; + const int iwt2 = ucell.itiaiw2iwt(it2,ia2,iw2_tmp); + const int iwt2_m2D = ParaO.trace_loc_col[iwt2]; + if(iwt2_m2D<0) continue; + + if(KS_SOLVER=="genelpa" || KS_SOLVER=="scalapack_gvx") + HK_m2D(iwt2_m2D,iwt1_m2D) = HK_a2D(iw1,iw2); + else + HK_m2D(iwt1_m2D,iwt2_m2D) = HK_a2D(iw1,iw2); + } + } + } + } + } + return HK_m2D; +} +template +void Exx_Abfs::Parallel::Communicate::Hexx::Ra2D_to_Km2D_mixing( + vector,matrix>>>> &HR_a2D, + vector &HK_m2D, + vector> &HK_m2D_pulay_seq) const +{ + TITLE("Exx_Abfs::Parallel::Communicate::Hexx::Ra2D_to_Km2D_mixing"); -template -T Exx_Abfs::Parallel::Communicate::Hexx::pulay_mixing( const T &H_pulay_old, deque &H_seq, const T &H_new ) + HK_m2D.resize(kv.nks); + HK_m2D_pulay_seq.resize(kv.nks); + for( int ik=0; ik!=kv.nks; ++ik ) + { +//gettimeofday( &t_start, NULL); +// const map> HK_a2D = R_to_K(HR_a2D[ik]); +//ofs_time<<"TIME@ Exx_Abfs::Parallel::Communicate::Hexx::R_to_K\t"<(HR_a2D, ik); + break; + case Mixing_Mode::Plain: + if( HK_m2D[ik].nr && HK_m2D[ik].nc ) + HK_m2D[ik] = (1-mixing_beta) * HK_m2D[ik] + mixing_beta * Ra2D_to_Km2D(HR_a2D, ik); + else + HK_m2D[ik] = Ra2D_to_Km2D(HR_a2D, ik); + break; + case Mixing_Mode::Pulay: + HK_m2D[ik] = pulay_mixing( HK_m2D[ik], HK_m2D_pulay_seq[ik], Ra2D_to_Km2D(HR_a2D, ik) ); + break; + default: + throw domain_error(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; + } +//ofs_time<<"TIME@ Exx_Abfs::Parallel::Communicate::Hexx::a2D_to_m2D\t"< +Tmatrix Exx_Abfs::Parallel::Communicate::Hexx::pulay_mixing( + const Tmatrix &H_pulay_old, deque &H_seq, const Tmatrix &H_new ) const { TITLE("Exx_Abfs::Parallel::Communicate::Hexx::pulay_mixing"); - - T H_pulay; + Tmatrix H_pulay; if( 0==chr.totstep ) { H_seq.clear(); diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp index 8f8a3031a6..fa240d5747 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp +++ b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp @@ -13,12 +13,19 @@ #endif #include "src_external/src_test/src_lcao/exx_lcao-test.h" +#include "src_external/src_test/test_function.h" //#include void Exx_Abfs::Parallel::Communicate::Hexx::Rexx_to_Km2D( vector,matrix>>>> &HR_exx, const pair &io_HR_a2D ) { + /*{ + static int istep=0; + ofstream ofs("HR_exx_"+TO_STRING(istep++)+"_"+TO_STRING(MY_RANK)); + ofs<> HK_a2D = R_to_K(HR_a2D[is]); -//ofs_time<<"TIME@ Exx_Abfs::Parallel::Communicate::Hexx::R_to_K\t"<> HK_a2D = R_to_K(HR_a2D[kv.isk[ik]],ik); -//ofs_time<<"TIME@ Exx_Abfs::Parallel::Communicate::Hexx::R_to_K\t"<> Exx_Abfs::Parallel::Communicate::Hexx::R_to_K( map,matrix>>> & HR) const { @@ -141,8 +106,9 @@ map> Exx_Abfs::Parallel::Communicate::Hexx::R_to_K( } return HK; } +*/ - +/* map> Exx_Abfs::Parallel::Communicate::Hexx::R_to_K( const map,matrix>>> & HR, const size_t ik) const @@ -170,6 +136,5 @@ map> Exx_Abfs::Parallel::Communicate::Hexx::R_t } return HK; } - - +*/ diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.h b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.h index 63a527a4c3..48c699e5d2 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.h @@ -23,15 +23,25 @@ class Exx_Abfs::Parallel::Communicate::Hexx const pair &io_HR_a2D ); private: - map> R_to_K( - map,matrix>>> & HR) const; - map> R_to_K( - const map,matrix>>> & HR, - const size_t ik) const; - template< typename T > - T a2D_to_m2D( const map> & H_a2D ) const; +// map> R_to_K( +// map,matrix>>> & HR) const; +// map> R_to_K( +// const map,matrix>>> & HR, +// const size_t ik) const; +// template< typename T > +// T a2D_to_m2D( const map> & H_a2D ) const; template - T pulay_mixing( const T &H_pulay_old, deque &H_seq, const T &H_new ); + inline T H_phase(matrix &&HR, const int ik, const Abfs::Vector3_Order &box2) const; + template + Tmatrix Ra2D_to_Km2D( + vector,matrix>>>> &HR_a2D, const int ik) const; + template + void Ra2D_to_Km2D_mixing( + vector,matrix>>>> &HR_a2D, + vector &HK_m2D, + vector> &HK_m2D_pulay_seq) const; + template + T pulay_mixing( const T &H_pulay_old, deque &H_seq, const T &H_new ) const; #if EXX_H_COMM==1 class Allreduce diff --git a/ABACUS.develop/source/src_lcao/exx_lcao.cpp b/ABACUS.develop/source/src_lcao/exx_lcao.cpp index c05d8fb798..cd9859ec23 100644 --- a/ABACUS.develop/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/exx_lcao.cpp @@ -1149,7 +1149,8 @@ gettimeofday( &t_start, NULL); } } } - energy *= 2.0/NSPIN; // ? + const map SPIN_multiple = {{1,2}, {2,1}, {4,1}}; // ??? + energy *= SPIN_multiple.at(NSPIN); // ? energy /= 2; // /2 for Ry ofs_mpi<<"TIME@ Exx_Lcao::cal_energy_cal\t"<non_zero_count_soc, 4); if(lmax_in > -1) //LiuXh add 20180328, fix bug of Hydrogen element with single projector pseudopot { //LiuXh add 20180328 - for (int L1 = 0; L1 < nproj + 1; L1++) +// for (int L1 = 0; L1 < nproj + 1; L1++) + for (int L1 = 0; L1 < min(this->Coefficient_D.nr, Coefficient_D_in.nr); L1++) { - for (int L2 = 0; L2 < nproj + 1; L2++) +// for (int L2 = 0; L2 < nproj + 1; L2++) + for (int L2 = 0; L2 < min(this->Coefficient_D.nc, Coefficient_D_in.nc); L2++) { this->Coefficient_D(L1, L2) = Coefficient_D_in(L1, L2); } diff --git a/ABACUS.develop/source/src_lcao/wfc_dm_2d.cpp b/ABACUS.develop/source/src_lcao/wfc_dm_2d.cpp index e843bb458a..87d31a7059 100644 --- a/ABACUS.develop/source/src_lcao/wfc_dm_2d.cpp +++ b/ABACUS.develop/source/src_lcao/wfc_dm_2d.cpp @@ -11,6 +11,7 @@ #include "src_pw/global.h" #include "src_external/src_test/test_function.h" +#include "src_external/src_test/src_global/complexmatrix-test.h" void Wfc_Dm_2d::init() { @@ -28,6 +29,17 @@ void Wfc_Dm_2d::init() void Wfc_Dm_2d::cal_dm(const matrix &wg) { + #ifdef TEST_DIAG + { + static int istep=0; + ofstream ofs("wfc_"+TO_STRING(istep++)+"_"+TO_STRING(MY_RANK)); + if(GAMMA_ONLY_LOCAL) + ofs< Date: Sun, 6 Dec 2020 17:05:49 +0800 Subject: [PATCH 039/233] 1. add cereal serialization 1.1 src_global/serialization_cereal.h 1.2 Makefile.system 1.3 Makefile.vars 1.4 src_global/serialization_boost.h 1.5 src_lcao/exx_abfs-io.h 1.6 src_lcao/exx_abfs-io-template.h 1.7 src_lcao/exx_abfs-parallel-communicate-allreduce-template.h 1.8 src_lcao/exx_abfs-parallel-communicate-dm-allreduce.cpp 1.9 src_lcao/exx_abfs-parallel-communicate-hexx.cpp 1.10 src_lcao/exx_abfs-parallel-communicate-hexx-allreduce.cpp --- ABACUS.develop/source/Makefile.system | 6 +- ABACUS.develop/source/Makefile.vars | 1 + ..._serialization.h => serialization_boost.h} | 4 +- .../source/src_global/serialization_cereal.h | 31 +++++++ .../source/src_lcao/exx_abfs-io-template.h | 93 +++++++++++++------ ABACUS.develop/source/src_lcao/exx_abfs-io.h | 2 - ...-parallel-communicate-allreduce-template.h | 2 +- ...abfs-parallel-communicate-dm-allreduce.cpp | 2 +- ...fs-parallel-communicate-hexx-allreduce.cpp | 2 +- .../exx_abfs-parallel-communicate-hexx.cpp | 16 +--- 10 files changed, 109 insertions(+), 50 deletions(-) rename ABACUS.develop/source/src_global/{boost_serialization.h => serialization_boost.h} (97%) create mode 100644 ABACUS.develop/source/src_global/serialization_cereal.h diff --git a/ABACUS.develop/source/Makefile.system b/ABACUS.develop/source/Makefile.system index df21d9e6b6..3f25add61b 100644 --- a/ABACUS.develop/source/Makefile.system +++ b/ABACUS.develop/source/Makefile.system @@ -26,16 +26,18 @@ LIBXC_INCLUDE_DIR = ${LIBXC_DIR}/include LIBXC_LIB_DIR = ${LIBXC_DIR}/lib LIBXC_LIB = -L${LIBXC_LIB_DIR} -lxc -Wl,-rpath=${LIBXC_LIB_DIR} +#CEREAL_INCLUDE_DIR = ${CEREAL_DIR}/include + #========================== # LIBS and INCLUDES #========================== LIBS = -lifcore -lm -lpthread ${LAPACK_LIB} ${FFTW_LIB} ${ELPA_LIB} ${LIBXC_LIB} #LIBS = -liomp5 -lpthread -lm -ldl ${BOOST_LIB} ${LAPACK_LIB} ${FFTW_LIB} ${ELPA_LIB} ${LIBXC_LIB} -INCLUDES = -I. -Icommands -I${BOOST_INCLUDE_DIR} -I${LAPACK_INCLUDE_DIR} -I${FFTW_INCLUDE_DIR} -I${LIBXC_INCLUDE_DIR} +INCLUDES = -I. -Icommands -I${BOOST_INCLUDE_DIR} -I${LAPACK_INCLUDE_DIR} -I${FFTW_INCLUDE_DIR} -I${LIBXC_INCLUDE_DIR} #-I${CEREAL_INCLUDE_DIR} #========================== # OPTIMIZE OPTIONS #========================== -OPTS = ${INCLUDES} -Ofast -g -traceback -xHost -std=c++11 -simd -march=native -m64 -qopenmp -Werror -Wall -pedantic +OPTS = ${INCLUDES} -Ofast -traceback -std=c++11 -simd -march=native -xHost -m64 -qopenmp -Werror -Wall -pedantic -g OPTS_MPI = -cxx=${CPLUSPLUS} diff --git a/ABACUS.develop/source/Makefile.vars b/ABACUS.develop/source/Makefile.vars index ff75605519..521f2ebfca 100644 --- a/ABACUS.develop/source/Makefile.vars +++ b/ABACUS.develop/source/Makefile.vars @@ -6,3 +6,4 @@ LAPACK_DIR = /opt/intel/mkl FFTW_DIR = /home/linpz/software/fftw-3.3.8 ELPA_DIR = /home/linpz/software/elpa-2016.05.004-openmp LIBXC_DIR = /home/linpz/software/libxc-4.3.4 +#CEREAL_DIR = /home/linpz/software/cereal-master \ No newline at end of file diff --git a/ABACUS.develop/source/src_global/boost_serialization.h b/ABACUS.develop/source/src_global/serialization_boost.h similarity index 97% rename from ABACUS.develop/source/src_global/boost_serialization.h rename to ABACUS.develop/source/src_global/serialization_boost.h index d2c0c6d0b9..c6cd30af42 100644 --- a/ABACUS.develop/source/src_global/boost_serialization.h +++ b/ABACUS.develop/source/src_global/serialization_boost.h @@ -1,5 +1,5 @@ -#ifndef BOOST_SERIALIZATION_H -#define BOOST_SERIALIZATION_H +#ifndef SERIALIZATION_BOOST_H +#define SERIALIZATION_BOOST_H #include #include diff --git a/ABACUS.develop/source/src_global/serialization_cereal.h b/ABACUS.develop/source/src_global/serialization_cereal.h new file mode 100644 index 0000000000..9a141a722b --- /dev/null +++ b/ABACUS.develop/source/src_global/serialization_cereal.h @@ -0,0 +1,31 @@ +#ifndef SERIALIZATION_CEREAL_H +#define SERIALIZATION_CEREAL_H + +#include + +#include +#include + +#include "src_global/vector3.h" +#include "src_lcao/abfs-vector3_order.h" +#include "src_global/matrix.h" + + +template void serialize( Archive & ar, Vector3 & v ){ ar(v.x); ar(v.y); ar(v.z); } +template void serialize( Archive & ar, Abfs::Vector3_Order & v ){ ar(v.x); ar(v.y); ar(v.z); } + + +template void save( Archive & ar, const matrix & m ) +{ + ar(m.nr); ar(m.nc); + ar(cereal::binary_data(m.c, m.nr*m.nc*sizeof(double))); +} +template void load( Archive & ar, matrix & m ) +{ + int nr, nc; + ar(nr); ar(nc); + m.create(nr,nc); + ar(cereal::binary_data(m.c, m.nr*m.nc*sizeof(double))); +} + +#endif \ No newline at end of file diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-io-template.h b/ABACUS.develop/source/src_lcao/exx_abfs-io-template.h index bf57e37d87..0d078c8396 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-io-template.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs-io-template.h @@ -2,26 +2,45 @@ #define EXX_ABFS_IO_TEMPLATE_H #include "src_lcao/exx_abfs-io.h" -#include "src_global/boost_serialization.h" #include #include +#ifdef USE_BOOST_SERIALIZATION + #include "src_global/serialization_boost.h" +#elif defined USE_CEREAL_SERIALIZATION + #include "src_global/serialization_cereal.h" +#endif + template void Exx_Abfs::IO::output_binary( const T &data, const std::string &file_name ) { std::ofstream ofs(file_name,std::ios::binary); - boost::archive::binary_oarchive oa(ofs); - oa << data; + #ifdef USE_BOOST_SERIALIZATION + boost::archive::binary_oarchive oa(ofs); + oa << data; + #elif defined USE_CEREAL_SERIALIZATION + cereal::BinaryOutputArchive ar(ofs); + ar(data); + #else + throw invalid_argument(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + #endif ofs.close(); } template T Exx_Abfs::IO::input_binary( const std::string &file_name ) { - std::ifstream ifs(file_name,std::ios::binary); - boost::archive::binary_iarchive ia(ifs); T data; - ia >> data; + std::ifstream ifs(file_name,std::ios::binary); + #ifdef USE_BOOST_SERIALIZATION + boost::archive::binary_iarchive ia(ifs); + ia >> data; + #elif defined USE_CEREAL_SERIALIZATION + cereal::BinaryInputArchive ar(ifs); + ar(data); + #else + throw invalid_argument(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + #endif ifs.close(); return data; } @@ -30,18 +49,32 @@ template void Exx_Abfs::IO::output_text( const T &data, const std::string &file_name ) { std::ofstream ofs(file_name); - boost::archive::text_oarchive oa(ofs); - oa << std::move(data); + #ifdef USE_BOOST_SERIALIZATION + boost::archive::text_oarchive oa(ofs); + oa << std::move(data); + #elif defined USE_CEREAL_SERIALIZATION + cereal::JSONOutputArchive ar(ofs); + ar(data); + #else + throw invalid_argument(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + #endif ofs.close(); } template T Exx_Abfs::IO::input_text( const std::string &file_name ) { - std::ifstream ifs(file_name); - boost::archive::text_iarchive ia(ifs); T data; - ia >> data; + std::ifstream ifs(file_name); + #ifdef USE_BOOST_SERIALIZATION + boost::archive::text_iarchive ia(ifs); + ia >> data; + #elif defined USE_CEREAL_SERIALIZATION + cereal::JSONInputArchive ar(ifs); + ar(data); + #else + throw invalid_argument(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + #endif ifs.close(); return data; } @@ -50,23 +83,27 @@ template void Exx_Abfs::IO::bcast( T &data, const int rank_src, MPI_Comm mpi_comm ) { int my_rank; MPI_Comm_rank( mpi_comm, &my_rank ); - if(MY_RANK==rank_src) - { - boost::mpi::packed_oarchive oar(mpi_comm); - oar << data; - const int data_size = oar.size(); - MPI_Bcast( const_cast(&data_size), 1, MPI_INT, rank_src, mpi_comm ); - MPI_Bcast( const_cast(oar.address()), oar.size(), MPI_PACKED, rank_src, mpi_comm ); - } - else - { - int data_size; - MPI_Bcast( &data_size, 1, MPI_INT, rank_src, mpi_comm ); - boost::mpi::packed_iarchive iar(mpi_comm); - iar.resize(data_size); - MPI_Bcast( iar.address(), data_size, MPI_PACKED, rank_src, mpi_comm ); - iar >> data; - } + #ifdef USE_BOOST_SERIALIZATION + if(MY_RANK==rank_src) + { + boost::mpi::packed_oarchive oar(mpi_comm); + oar << data; + const int data_size = oar.size(); + MPI_Bcast( const_cast(&data_size), 1, MPI_INT, rank_src, mpi_comm ); + MPI_Bcast( const_cast(oar.address()), oar.size(), MPI_PACKED, rank_src, mpi_comm ); + } + else + { + int data_size; + MPI_Bcast( &data_size, 1, MPI_INT, rank_src, mpi_comm ); + boost::mpi::packed_iarchive iar(mpi_comm); + iar.resize(data_size); + MPI_Bcast( iar.address(), data_size, MPI_PACKED, rank_src, mpi_comm ); + iar >> data; + } + #else + throw invalid_argument(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + #endif } #endif \ No newline at end of file diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-io.h b/ABACUS.develop/source/src_lcao/exx_abfs-io.h index 7d97311576..ae3a9e87c1 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-io.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs-io.h @@ -35,7 +35,6 @@ class Exx_Abfs::IO const vector &files_abfs, const double kmesh_times=1 ); // close dK, keep Kcut - #ifdef USE_BOOST_SERIALIZATION template static void output_binary( const T &data, const string &file_name ); template @@ -46,7 +45,6 @@ class Exx_Abfs::IO static T input_text( const string &file_name ); template static void bcast( T &data, const int rank_src, MPI_Comm mpi_comm ); - #endif private: static vector> construct_abfs_T( diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-allreduce-template.h b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-allreduce-template.h index 0b628bbaab..e781bb6e5a 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-allreduce-template.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-allreduce-template.h @@ -7,7 +7,7 @@ #include #include -#include "src_global/boost_serialization.h" +#include "src_global/serialization_boost.h" #include #include diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm-allreduce.cpp b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm-allreduce.cpp index 5de737e839..d06f9fc128 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm-allreduce.cpp +++ b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm-allreduce.cpp @@ -1,5 +1,5 @@ #include "exx_abfs-parallel-communicate-dm.h" -#include "src_global/boost_serialization.h" +#include "src_global/serialization_boost.h" #include #ifdef _OPENMP diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce.cpp b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce.cpp index 7de8938f7e..32235375b3 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce.cpp +++ b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce.cpp @@ -1,5 +1,5 @@ #include "exx_abfs-parallel-communicate-hexx.h" -#include "src_global/boost_serialization.h" +#include "src_global/serialization_boost.h" #include "src_pw/global.h" #include "src_lcao/global_fp.h" diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp index 8f8a3031a6..a560e94254 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp +++ b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp @@ -8,9 +8,7 @@ #include "exx_abfs-parallel-communicate-allreduce-template.h" #endif -#ifdef USE_BOOST_SERIALIZATION #include "exx_abfs-io-template.h" -#endif #include "src_external/src_test/src_lcao/exx_lcao-test.h" //#include @@ -32,12 +30,8 @@ void Exx_Abfs::Parallel::Communicate::Hexx::Rexx_to_Km2D( //gettimeofday( &t_start, NULL); vector,matrix>>>> HR_a2D; if(io_HR_a2D.first) - #ifdef USE_BOOST_SERIALIZATION - HR_a2D = Exx_Abfs::IO::input_binary,matrix>>>>>( - global_out_dir+"HR_exx_"+TO_STRING(MY_RANK)); - #else - throw invalid_argument(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); - #endif + HR_a2D = Exx_Abfs::IO::input_binary,matrix>>>>>( + global_out_dir+"HR_exx_"+TO_STRING(MY_RANK)); else { #if EXX_H_COMM==1 @@ -50,11 +44,7 @@ void Exx_Abfs::Parallel::Communicate::Hexx::Rexx_to_Km2D( #endif } if(io_HR_a2D.second) - #ifdef USE_BOOST_SERIALIZATION - Exx_Abfs::IO::output_binary( HR_a2D, global_out_dir+"HR_exx_"+TO_STRING(MY_RANK) ); - #else - throw invalid_argument(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); - #endif + Exx_Abfs::IO::output_binary( HR_a2D, global_out_dir+"HR_exx_"+TO_STRING(MY_RANK) ); //ofs_time<<"TIME@ Exx_Abfs::Parallel::Communicate::Hexx::Allreduce::exx_to_a2D\t"< Date: Thu, 24 Dec 2020 23:37:09 +0800 Subject: [PATCH 040/233] 1. fix bug of exx_dm3 1.1 src_lcao/exx_abfs-parallel.h 1.2 src_lcao/exx_abfs-parallel-communicate-function.h 1.3 src_lcao/exx_abfs-parallel-communicate-function.cpp 1.4 src_lcao/exx_abfs-parallel-communicate-dm3.h 1.5 src_lcao/exx_abfs-parallel-communicate-dm3-allreduce.cpp 1.6 src_lcao/exx_abfs-parallel-communicate-hexx.h 1.7 src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp 1.8 src_global/serialization_cereal.h 1.9 Makefile.Objects 1.10 Makefile.system 1.11 Makefile.vars --- ABACUS.develop/source/Makefile | 2 +- ABACUS.develop/source/Makefile.Objects | 1 + ABACUS.develop/source/Makefile.system | 4 +- ABACUS.develop/source/Makefile.vars | 2 +- .../source/src_global/serialization_cereal.h | 1 + ...bfs-parallel-communicate-dm3-allreduce.cpp | 71 +++++++++++++++++-- .../exx_abfs-parallel-communicate-dm3.h | 11 ++- ...exx_abfs-parallel-communicate-function.cpp | 34 +++++++++ .../exx_abfs-parallel-communicate-function.h | 16 +++++ ...s-parallel-communicate-hexx-allreduce2.cpp | 33 +-------- .../exx_abfs-parallel-communicate-hexx.h | 2 +- .../source/src_lcao/exx_abfs-parallel.h | 1 + ABACUS.develop/source/src_lcao/exx_lcao.cpp | 2 +- 13 files changed, 130 insertions(+), 50 deletions(-) create mode 100644 ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-function.cpp create mode 100644 ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-function.h diff --git a/ABACUS.develop/source/Makefile b/ABACUS.develop/source/Makefile index 7c016b2e43..5544810270 100644 --- a/ABACUS.develop/source/Makefile +++ b/ABACUS.develop/source/Makefile @@ -20,7 +20,7 @@ HONG_SER_SELINV = -D__FP ${HONG_FFTW} -D__SELINV HONG_GDB = -g -D__FP ${HONG_FFTW} #(2)mpi HONG_MPI = -D__FP ${HONG_FFTW} -D__MPI -HONG_MPI_SELINV = -D__FP ${HONG_FFTW} -D__MPI -D__SELINV -DMETIS -DMKL_ILP64 -DEXX_DM=3 -DEXX_H_COMM=2 -DTEST_LIBXC=0 -DTEST_EXX_LCAO=0 -DTEST_EXX_RADIAL=1 +HONG_MPI_SELINV = -D__FP ${HONG_FFTW} -D__MPI -D__SELINV -DMETIS -DMKL_ILP64 -DEXX_DM=3 -DEXX_H_COMM=2 -DTEST_LIBXC=0 -DTEST_EXX_LCAO=0 -DTEST_EXX_RADIAL=1 -DUSE_CEREAL_SERIALIZATION #(3)memory HONG_MEM = ${HONG_FFTW} -D__FP -D_MCD_CHECK -DWIN32 -DMCD_VERBOSE diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 614ad96523..515d2d8b6d 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -191,6 +191,7 @@ exx_abfs-matrix_orbs21.o \ exx_abfs-matrix_orbs22.o \ exx_abfs-matrix_lcaoslcaos_lcaoslcaos.o \ exx_abfs-pca.o \ +exx_abfs-parallel-communicate-function.o \ exx_abfs-parallel-communicate-dm3.o \ exx_abfs-parallel-communicate-dm3-allreduce.o \ exx_abfs-parallel-communicate-hexx.o \ diff --git a/ABACUS.develop/source/Makefile.system b/ABACUS.develop/source/Makefile.system index 3f25add61b..47af841663 100644 --- a/ABACUS.develop/source/Makefile.system +++ b/ABACUS.develop/source/Makefile.system @@ -26,7 +26,7 @@ LIBXC_INCLUDE_DIR = ${LIBXC_DIR}/include LIBXC_LIB_DIR = ${LIBXC_DIR}/lib LIBXC_LIB = -L${LIBXC_LIB_DIR} -lxc -Wl,-rpath=${LIBXC_LIB_DIR} -#CEREAL_INCLUDE_DIR = ${CEREAL_DIR}/include +CEREAL_INCLUDE_DIR = ${CEREAL_DIR}/include #========================== # LIBS and INCLUDES @@ -34,7 +34,7 @@ LIBXC_LIB = -L${LIBXC_LIB_DIR} -lxc -Wl,-rpath=${LIBXC_LIB_DIR} LIBS = -lifcore -lm -lpthread ${LAPACK_LIB} ${FFTW_LIB} ${ELPA_LIB} ${LIBXC_LIB} #LIBS = -liomp5 -lpthread -lm -ldl ${BOOST_LIB} ${LAPACK_LIB} ${FFTW_LIB} ${ELPA_LIB} ${LIBXC_LIB} -INCLUDES = -I. -Icommands -I${BOOST_INCLUDE_DIR} -I${LAPACK_INCLUDE_DIR} -I${FFTW_INCLUDE_DIR} -I${LIBXC_INCLUDE_DIR} #-I${CEREAL_INCLUDE_DIR} +INCLUDES = -I. -Icommands -I${BOOST_INCLUDE_DIR} -I${LAPACK_INCLUDE_DIR} -I${FFTW_INCLUDE_DIR} -I${LIBXC_INCLUDE_DIR} -I${CEREAL_INCLUDE_DIR} #========================== # OPTIMIZE OPTIONS diff --git a/ABACUS.develop/source/Makefile.vars b/ABACUS.develop/source/Makefile.vars index 521f2ebfca..ef82609fd2 100644 --- a/ABACUS.develop/source/Makefile.vars +++ b/ABACUS.develop/source/Makefile.vars @@ -6,4 +6,4 @@ LAPACK_DIR = /opt/intel/mkl FFTW_DIR = /home/linpz/software/fftw-3.3.8 ELPA_DIR = /home/linpz/software/elpa-2016.05.004-openmp LIBXC_DIR = /home/linpz/software/libxc-4.3.4 -#CEREAL_DIR = /home/linpz/software/cereal-master \ No newline at end of file +CEREAL_DIR = /home/linpz/software/cereal-master \ No newline at end of file diff --git a/ABACUS.develop/source/src_global/serialization_cereal.h b/ABACUS.develop/source/src_global/serialization_cereal.h index 9a141a722b..2b9949d554 100644 --- a/ABACUS.develop/source/src_global/serialization_cereal.h +++ b/ABACUS.develop/source/src_global/serialization_cereal.h @@ -5,6 +5,7 @@ #include #include +#include #include "src_global/vector3.h" #include "src_lcao/abfs-vector3_order.h" diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3-allreduce.cpp b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3-allreduce.cpp index f63f4cb2ed..8fe40b92a4 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3-allreduce.cpp +++ b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3-allreduce.cpp @@ -1,12 +1,15 @@ #include "exx_abfs-parallel-communicate-dm3.h" +#include "exx_abfs-parallel-communicate-function.h" #include "src_pw/global.h" #include "src_global/global_function.h" +#include "src_global/serialization_cereal.h" #include #include #include + #include "src_external/src_test/test_function.h" @@ -20,13 +23,13 @@ void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::init( MPI_Comm_size(mpi_comm, &comm_sz); MPI_Comm_rank(mpi_comm, &my_rank); - const vector> atom_in_2D = get_atom_in_2D(); - H_atom_pairs_group_rank = get_H_atom_pairs_group_rank(H_atom_pairs_group, atom_in_2D); +// const vector> atom_in_2D = get_atom_in_2D(); + H_atom_pairs_group_rank = get_H_atom_pairs_group_rank(H_atom_pairs_group); get_send_recv_size(H_atom_pairs_group_rank, H_atom_pairs_group, send_size_list, recv_size); ofstream ofs(exx_lcao.test_dir.process+"dm3_"+TO_STRING(my_rank)); //ofs<> Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_atom_in_2D() const { vector> atom_in_2D(ucell.nat,{false,false}); @@ -184,8 +188,10 @@ vector> Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_ato } return atom_in_2D; } +*/ +/* vector>>> Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_H_atom_pairs_group_rank( const map,set> &H_atom_pairs_group, const vector> &atom_in_2D) const @@ -254,10 +260,61 @@ vector>>> Exx_Abfs::Parallel::Communicate::DM3 } return H_atom_pairs_group_rank; } +*/ + + +vector>> Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_H_atom_pairs_group_rank( + const map,set> &H_atom_pairs_group) const +{ + constexpr int tag = 0; + + const vector,vector>> atom_in_2D_list = Exx_Abfs::Parallel::Communicate::Function::get_atom_in_2D_list(mpi_comm); + + vector request(comm_sz); + vector atom_send_str(comm_sz); + for(int rank_tmp=my_rank; rank_tmp!=comm_sz+my_rank; ++rank_tmp) + { + const int rank = rank_tmp%comm_sz; + map> atom_required; + for(const auto & H_atom_pairs : H_atom_pairs_group) + for(const size_t iat1 : H_atom_pairs.first) + if(atom_in_2D_list[rank].first[iat1]) + for(const size_t iat2 : H_atom_pairs.second) + if(atom_in_2D_list[rank].second[iat2]) + atom_required[iat1].insert(iat2); + { + stringstream atom_send_ss; + cereal::BinaryOutputArchive ar(atom_send_ss); + ar(atom_required); + atom_send_str[rank] = atom_send_ss.str(); + } + if( MPI_Isend( atom_send_str[rank].c_str(), atom_send_str[rank].size(), MPI_CHAR, rank, tag, mpi_comm, &request[rank] ) !=MPI_SUCCESS) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + } + vector>> H_atom_pairs_group_rank(comm_sz); + for(int i=0; i!=comm_sz; ++i) + { + MPI_Status status; + if( MPI_Probe( MPI_ANY_SOURCE, tag, mpi_comm, &status ) !=MPI_SUCCESS) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + int size_recv; + if( MPI_Get_count( &status, MPI_CHAR, &size_recv) !=MPI_SUCCESS) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + + vector ss_buffer(size_recv); + if( MPI_Recv( ss_buffer.data(), size_recv, MPI_CHAR, status.MPI_SOURCE, tag, mpi_comm, MPI_STATUS_IGNORE ) !=MPI_SUCCESS) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + stringstream atom_recv_ss; + atom_recv_ss.rdbuf()->pubsetbuf(ss_buffer.data(),size_recv); + { + cereal::BinaryInputArchive ar(atom_recv_ss); + ar(H_atom_pairs_group_rank[status.MPI_SOURCE]); + } + } + + if( MPI_Waitall( comm_sz, request.data(), MPI_STATUSES_IGNORE ) !=MPI_SUCCESS) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + return H_atom_pairs_group_rank; +} void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_send_recv_size( - const vector>>> &H_atom_pairs_group_rank, + const vector>> &H_atom_pairs_group_rank, const map,set> &H_atom_pairs_group, vector &send_size_list, size_t &recv_size) const { @@ -267,7 +324,7 @@ void Exx_Abfs::Parallel::Communicate::DM3::Allreduce::get_send_recv_size( for(const auto &H_pairs_tmp : H_atom_pairs_group_rank[rank]) { const size_t iat1 = H_pairs_tmp.first; - for(const size_t iat2 : *H_pairs_tmp.second) + for(const size_t iat2 : H_pairs_tmp.second) send_size_list[rank] += ucell.atoms[ucell.iat2it[iat1]].nw * ucell.atoms[ucell.iat2it[iat2]].nw; } send_size_list[rank] *= sizeof(double); @@ -439,8 +496,8 @@ vector,matrix*>>>> Exx_Abfs:: { const size_t iat1 = ptr_data_A->first; auto ptr_data_B = ptr_data_A->second.begin(); - auto ptr_atom_B = ptr_atom_A->second->begin(); - while(ptr_data_B!=ptr_data_A->second.end() && ptr_atom_B!=ptr_atom_A->second->end()) + auto ptr_atom_B = ptr_atom_A->second.begin(); + while(ptr_data_B!=ptr_data_A->second.end() && ptr_atom_B!=ptr_atom_A->second.end()) { const size_t iat2 = ptr_data_B->first; if(ptr_data_B->first < *ptr_atom_B) ++ptr_data_B; diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3.h b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3.h index d41c6cc25b..b2e59aa9ec 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3.h @@ -36,7 +36,7 @@ class Exx_Abfs::Parallel::Communicate::DM3 vector,matrix>>>> &data_local) const; private: - vector>>> H_atom_pairs_group_rank; //H_atom_pairs_group_rank[rank][iat1][iat2] + vector>> H_atom_pairs_group_rank; //H_atom_pairs_group_rank[rank][iat1][iat2] vector send_size_list; size_t recv_size; @@ -47,12 +47,11 @@ class Exx_Abfs::Parallel::Communicate::DM3 enum class Flag_Send {undo, begin_oar, finish_oar, begin_isend, finish_isend}; enum class Flag_Recv {undo, begin_irecv, begin_iar, finish_iar}; - vector> get_atom_in_2D() const; - vector>>> get_H_atom_pairs_group_rank( - const map,set> &H_atom_pairs_group, - const vector> &atom_in_2D) const; + //vector> get_atom_in_2D() const; + vector>> get_H_atom_pairs_group_rank( + const map,set> &H_atom_pairs_group) const; void get_send_recv_size( - const vector>>> &H_atom_pairs_group_rank, + const vector>> &H_atom_pairs_group_rank, const map,set> &H_atom_pairs_group, vector &send_size_list, size_t &recv_size) const; void init_flags( diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-function.cpp b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-function.cpp new file mode 100644 index 0000000000..d504337a97 --- /dev/null +++ b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-function.cpp @@ -0,0 +1,34 @@ +#include "exx_abfs-parallel-communicate-function.h" +#include "src_pw/global.h" +#include "src_lcao/global_fp.h" + +vector,vector>> +Exx_Abfs::Parallel::Communicate::Function::get_atom_in_2D_list(const MPI_Comm &mpi_comm) +{ + TITLE("Exx_Abfs::Parallel::Communicate::Functions::get_atom_in_2D_list"); + int comm_sz; MPI_Comm_size(mpi_comm, &comm_sz); + + bool atom_in_2D[ucell.nat*2]; + for(int i=0; i=0 ) + atom_in_2D[iat] = true; + if( ParaO.trace_loc_col[iwt]>=0 ) + atom_in_2D[ucell.nat+iat] = true; + } + + bool atom_in_2D_list_tmp[ucell.nat*2*comm_sz]; + if(MPI_Allgather( atom_in_2D, ucell.nat*2, MPI_BYTE, atom_in_2D_list_tmp, ucell.nat*2, MPI_BYTE, mpi_comm )!=MPI_SUCCESS) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + + vector,vector>> atom_in_2D_list(comm_sz, {vector(ucell.nat),vector(ucell.nat)}); + for(int rank=0; rank +#include +#include +using namespace std; + +class Exx_Abfs::Parallel::Communicate::Function +{ +public: + static vector,vector>> get_atom_in_2D_list(const MPI_Comm &mpi_comm); +}; + +#endif \ No newline at end of file diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp index ea65cfc88c..af9192925a 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp +++ b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp @@ -1,4 +1,5 @@ #include "exx_abfs-parallel-communicate-hexx.h" +#include "exx_abfs-parallel-communicate-function.h" #include "src_pw/global.h" #include "src_lcao/global_fp.h" @@ -19,7 +20,7 @@ void Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::init( MPI_Comm_size(mpi_comm, &comm_sz); MPI_Comm_rank(mpi_comm, &my_rank); - atom_in_2D_list = get_atom_in_2D_list(); + atom_in_2D_list = Exx_Abfs::Parallel::Communicate::Function::get_atom_in_2D_list(mpi_comm); send_size_list = get_send_size_list(H_atom_pairs_core, atom_in_2D_list); recv_size = ParaO.nrow * ParaO.ncol * sizeof(double); } @@ -159,36 +160,6 @@ ofs<<"all\t\t"<,vector>> -Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::get_atom_in_2D_list() const -{ - TITLE("Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::get_atom_in_2D_list"); - - bool atom_in_2D[ucell.nat*2]; - for(int i=0; i=0 ) - atom_in_2D[iat] = true; - if( ParaO.trace_loc_col[iwt]>=0 ) - atom_in_2D[ucell.nat+iat] = true; - } - - bool atom_in_2D_list_tmp[ucell.nat*2*comm_sz]; - if(MPI_Allgather( atom_in_2D, ucell.nat*2, MPI_BYTE, atom_in_2D_list_tmp, ucell.nat*2, MPI_BYTE, mpi_comm )!=MPI_SUCCESS) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); - - vector,vector>> atom_in_2D_list(comm_sz, {vector(ucell.nat),vector(ucell.nat)}); - for(int rank=0; rank Exx_Abfs::Parallel::Communicate::Hexx::Allreduce2::get_send_size_list( const set> &H_atom_pairs_core, diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.h b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.h index 48c699e5d2..ab3166a2a0 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.h @@ -102,7 +102,7 @@ class Exx_Abfs::Parallel::Communicate::Hexx enum class Flag_Send {undo, begin_oar, finish_oar, begin_isend, finish_isend}; enum class Flag_Recv {undo, begin_irecv, begin_iar, finish_iar}; - vector,vector>> get_atom_in_2D_list() const; + //vector,vector>> get_atom_in_2D_list() const; vector get_send_size_list( const set> &H_atom_pairs_core, const vector,vector>> &atom_in_2D_list) const; diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel.h b/ABACUS.develop/source/src_lcao/exx_abfs-parallel.h index f3507d0442..a95b71d4a0 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs-parallel.h @@ -19,6 +19,7 @@ class Exx_Abfs::Parallel { public: class Allreduce; + class Function; class Hexx; #if EXX_DM==1 class DM; diff --git a/ABACUS.develop/source/src_lcao/exx_lcao.cpp b/ABACUS.develop/source/src_lcao/exx_lcao.cpp index cd9859ec23..7b37dc6432 100644 --- a/ABACUS.develop/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/exx_lcao.cpp @@ -865,13 +865,13 @@ ofs_mpi<<"TIME@ Exx_Lcao::cal_DM\t"<,matrix>>>> HexxR = cal_Hexx(); ofs_mpi<<"TIME@ Exx_Lcao::cal_Hexx\t"< Date: Wed, 20 Jan 2021 16:22:28 +0800 Subject: [PATCH 041/233] 1. change mkl_set_num_threads 1.1 src_lcao/abfs.cpp 1.2 src_lcao/exx_lcao.cpp 1.3 src_lcao/gint_gamma_rho.cpp 1.4 src_lcao/gint_gamma_vl.cpp --- ABACUS.develop/source/src_lcao/abfs.cpp | 2 +- ABACUS.develop/source/src_lcao/exx_lcao.cpp | 2 +- ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp | 2 +- ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/abfs.cpp b/ABACUS.develop/source/src_lcao/abfs.cpp index e34dfb715f..9de7dd25c2 100644 --- a/ABACUS.develop/source/src_lcao/abfs.cpp +++ b/ABACUS.develop/source/src_lcao/abfs.cpp @@ -36,7 +36,7 @@ map,shared_ptr>>> Abfs::c Vs_same_atom[it] = DPcal_V( it,it,{0,0,0}, m_abfs_abfs, index_abfs, 0,true, rwlock_Vw,Vws ); const int mkl_threads = mkl_get_max_threads(); - mkl_set_num_threads(1); + mkl_set_num_threads(std::max(1UL,mkl_threads/atom_centres_vector.size())); map,shared_ptr>>> Cs; #pragma omp parallel for diff --git a/ABACUS.develop/source/src_lcao/exx_lcao.cpp b/ABACUS.develop/source/src_lcao/exx_lcao.cpp index 7b37dc6432..0d2db34365 100644 --- a/ABACUS.develop/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/exx_lcao.cpp @@ -1333,7 +1333,7 @@ ofs_mpi.close(); vector,matrix>>>> Exx_Lcao::cal_Hexx() const { const int mkl_threads = mkl_get_max_threads(); - mkl_set_num_threads(1); + mkl_set_num_threads(std::max(1UL,mkl_threads/atom_pairs_core.size())); vector,matrix>>>> HexxR(NSPIN); omp_lock_t Hexx_lock; diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp index c830774498..d1e4b43eb5 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp @@ -711,7 +711,7 @@ double Gint_Gamma::gamma_charge(void) // Peize Lin update OpenMP 2020.09.28 if(max_size) { const int mkl_threads = mkl_get_max_threads(); - mkl_set_num_threads(1); + mkl_set_num_threads(std::max(1,mkl_threads/GridT.nbx)); // Peize Lin update 2021.01.20 #pragma omp parallel { diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp index a8f2b541fb..f2c5510988 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp @@ -866,7 +866,7 @@ void Gint_Gamma::gamma_vlocal(void) // Peize Lin update OpenMP 2020.09.27 } const int mkl_threads = mkl_get_max_threads(); - mkl_set_num_threads(1); + mkl_set_num_threads(std::max(1,mkl_threads/GridT.nbx)); // Peize Lin update 2021.01.20 #pragma omp parallel From 4afd457a2e908e9e74d9147b5f9edec5926d64b4 Mon Sep 17 00:00:00 2001 From: qianrui <1962242031@qq.com> Date: Sat, 30 Jan 2021 16:22:37 +0800 Subject: [PATCH 042/233] add output descriptor function in pw_line --- .../examples/H2O-deepks/H_ONCV_PBE-1.0.upf | 897 ++++++++++++ .../H2O-deepks/H_gga_8au_60Ry_2s1p.orb | 621 +++++++++ ABACUS.develop/examples/H2O-deepks/INPUT | 29 + ABACUS.develop/examples/H2O-deepks/INPUTs | 8 + ABACUS.develop/examples/H2O-deepks/KPT | 4 + .../examples/H2O-deepks/O_ONCV_PBE-1.0.upf | 1224 +++++++++++++++++ .../H2O-deepks/O_gga_7au_60Ry_2s2p1d.orb | 903 ++++++++++++ ABACUS.develop/examples/H2O-deepks/STRU | 28 + .../examples/H2O-deepks/descriptor.dat | 48 + .../examples/H2O-deepks/descriptor.dat.bak | 48 + ABACUS.develop/examples/H2O-deepks/logout.bak | 73 + ABACUS.develop/source/Makefile.Objects | 1 + ABACUS.develop/source/Makefile.vars | 26 +- ABACUS.develop/source/input.cpp | 17 + ABACUS.develop/source/input.h | 7 + ABACUS.develop/source/run_frag.cpp | 12 + ABACUS.develop/source/src_pw/algorithms.h | 1 + ABACUS.develop/source/src_pw/bessel_basis.cpp | 7 +- ABACUS.develop/source/src_pw/bessel_basis.h | 11 +- .../source/src_pw/numerical_basis.cpp | 20 +- .../source/src_pw/numerical_descriptor.cpp | 358 +++++ .../source/src_pw/numerical_descriptor.h | 42 + 22 files changed, 4367 insertions(+), 18 deletions(-) create mode 100644 ABACUS.develop/examples/H2O-deepks/H_ONCV_PBE-1.0.upf create mode 100644 ABACUS.develop/examples/H2O-deepks/H_gga_8au_60Ry_2s1p.orb create mode 100644 ABACUS.develop/examples/H2O-deepks/INPUT create mode 100644 ABACUS.develop/examples/H2O-deepks/INPUTs create mode 100644 ABACUS.develop/examples/H2O-deepks/KPT create mode 100644 ABACUS.develop/examples/H2O-deepks/O_ONCV_PBE-1.0.upf create mode 100644 ABACUS.develop/examples/H2O-deepks/O_gga_7au_60Ry_2s2p1d.orb create mode 100644 ABACUS.develop/examples/H2O-deepks/STRU create mode 100644 ABACUS.develop/examples/H2O-deepks/descriptor.dat create mode 100644 ABACUS.develop/examples/H2O-deepks/descriptor.dat.bak create mode 100644 ABACUS.develop/examples/H2O-deepks/logout.bak create mode 100644 ABACUS.develop/source/src_pw/numerical_descriptor.cpp create mode 100644 ABACUS.develop/source/src_pw/numerical_descriptor.h diff --git a/ABACUS.develop/examples/H2O-deepks/H_ONCV_PBE-1.0.upf b/ABACUS.develop/examples/H2O-deepks/H_ONCV_PBE-1.0.upf new file mode 100644 index 0000000000..f8b1ebb63c --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks/H_ONCV_PBE-1.0.upf @@ -0,0 +1,897 @@ + + + + This pseudopotential file has been produced using the code + ONCVPSP (Optimized Norm-Conservinng Vanderbilt PSeudopotential) + scalar-relativistic version 2.1.1, 03/26/2014 by D. R. Hamann + The code is available through a link at URL www.mat-simresearch.com. + Documentation with the package provides a full discription of the + input data below. + + + While it is not required under the terms of the GNU GPL, it is + suggested that you cite D. R. Hamann, Phys. Rev. B 88, 085117 (2013) + in any publication using these pseudopotentials. + + + Copyright 2015 The Regents of the University of California + + This work is licensed under the Creative Commons Attribution-ShareAlike + 4.0 International License. To view a copy of this license, visit + http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to + Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + + This pseudopotential is part of the Schlipf-Gygi norm-conserving + pseudopotential library. Its construction parameters were tuned to + reproduce materials of a training set with very high accuracy and + should be suitable as a general purpose pseudopotential to treat a + variety of different compounds. For details of the construction and + testing of the pseudopotential please refer to: + + [insert reference to paper here] + + We kindly ask that you include this reference in all publications + associated to this pseudopotential. + + + +# ATOM AND REFERENCE CONFIGURATION +# atsym z nc nv iexc psfile + H 1.00 0 1 4 upf +# +# n l f energy (Ha) + 1 0 1.00 +# +# PSEUDOPOTENTIAL AND OPTIMIZATION +# lmax + 0 +# +# l, rc, ep, ncon, nbas, qcut + 0 1.13748 -0.23860 5 8 9.72141 +# +# LOCAL POTENTIAL +# lloc, lpopt, rc(5), dvloc0 + 4 5 0.49352 0.00000 +# +# VANDERBILT-KLEINMAN-BYLANDER PROJECTORs +# l, nproj, debl + 0 2 1.27464 +# +# MODEL CORE CHARGE +# icmod, fcfact + 0 0.00000 +# +# LOG DERIVATIVE ANALYSIS +# epsh1, epsh2, depsh + -5.00 3.00 0.02 +# +# OUTPUT GRID +# rlmax, drl + 6.00 0.01 +# +# TEST CONFIGURATIONS +# ncnf + 0 +# nvcnf +# n l f + + + + + + + + + 0.0000 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600 0.0700 + 0.0800 0.0900 0.1000 0.1100 0.1200 0.1300 0.1400 0.1500 + 0.1600 0.1700 0.1800 0.1900 0.2000 0.2100 0.2200 0.2300 + 0.2400 0.2500 0.2600 0.2700 0.2800 0.2900 0.3000 0.3100 + 0.3200 0.3300 0.3400 0.3500 0.3600 0.3700 0.3800 0.3900 + 0.4000 0.4100 0.4200 0.4300 0.4400 0.4500 0.4600 0.4700 + 0.4800 0.4900 0.5000 0.5100 0.5200 0.5300 0.5400 0.5500 + 0.5600 0.5700 0.5800 0.5900 0.6000 0.6100 0.6200 0.6300 + 0.6400 0.6500 0.6600 0.6700 0.6800 0.6900 0.7000 0.7100 + 0.7200 0.7300 0.7400 0.7500 0.7600 0.7700 0.7800 0.7900 + 0.8000 0.8100 0.8200 0.8300 0.8400 0.8500 0.8600 0.8700 + 0.8800 0.8900 0.9000 0.9100 0.9200 0.9300 0.9400 0.9500 + 0.9600 0.9700 0.9800 0.9900 1.0000 1.0100 1.0200 1.0300 + 1.0400 1.0500 1.0600 1.0700 1.0800 1.0900 1.1000 1.1100 + 1.1200 1.1300 1.1400 1.1500 1.1600 1.1700 1.1800 1.1900 + 1.2000 1.2100 1.2200 1.2300 1.2400 1.2500 1.2600 1.2700 + 1.2800 1.2900 1.3000 1.3100 1.3200 1.3300 1.3400 1.3500 + 1.3600 1.3700 1.3800 1.3900 1.4000 1.4100 1.4200 1.4300 + 1.4400 1.4500 1.4600 1.4700 1.4800 1.4900 1.5000 1.5100 + 1.5200 1.5300 1.5400 1.5500 1.5600 1.5700 1.5800 1.5900 + 1.6000 1.6100 1.6200 1.6300 1.6400 1.6500 1.6600 1.6700 + 1.6800 1.6900 1.7000 1.7100 1.7200 1.7300 1.7400 1.7500 + 1.7600 1.7700 1.7800 1.7900 1.8000 1.8100 1.8200 1.8300 + 1.8400 1.8500 1.8600 1.8700 1.8800 1.8900 1.9000 1.9100 + 1.9200 1.9300 1.9400 1.9500 1.9600 1.9700 1.9800 1.9900 + 2.0000 2.0100 2.0200 2.0300 2.0400 2.0500 2.0600 2.0700 + 2.0800 2.0900 2.1000 2.1100 2.1200 2.1300 2.1400 2.1500 + 2.1600 2.1700 2.1800 2.1900 2.2000 2.2100 2.2200 2.2300 + 2.2400 2.2500 2.2600 2.2700 2.2800 2.2900 2.3000 2.3100 + 2.3200 2.3300 2.3400 2.3500 2.3600 2.3700 2.3800 2.3900 + 2.4000 2.4100 2.4200 2.4300 2.4400 2.4500 2.4600 2.4700 + 2.4800 2.4900 2.5000 2.5100 2.5200 2.5300 2.5400 2.5500 + 2.5600 2.5700 2.5800 2.5900 2.6000 2.6100 2.6200 2.6300 + 2.6400 2.6500 2.6600 2.6700 2.6800 2.6900 2.7000 2.7100 + 2.7200 2.7300 2.7400 2.7500 2.7600 2.7700 2.7800 2.7900 + 2.8000 2.8100 2.8200 2.8300 2.8400 2.8500 2.8600 2.8700 + 2.8800 2.8900 2.9000 2.9100 2.9200 2.9300 2.9400 2.9500 + 2.9600 2.9700 2.9800 2.9900 3.0000 3.0100 3.0200 3.0300 + 3.0400 3.0500 3.0600 3.0700 3.0800 3.0900 3.1000 3.1100 + 3.1200 3.1300 3.1400 3.1500 3.1600 3.1700 3.1800 3.1900 + 3.2000 3.2100 3.2200 3.2300 3.2400 3.2500 3.2600 3.2700 + 3.2800 3.2900 3.3000 3.3100 3.3200 3.3300 3.3400 3.3500 + 3.3600 3.3700 3.3800 3.3900 3.4000 3.4100 3.4200 3.4300 + 3.4400 3.4500 3.4600 3.4700 3.4800 3.4900 3.5000 3.5100 + 3.5200 3.5300 3.5400 3.5500 3.5600 3.5700 3.5800 3.5900 + 3.6000 3.6100 3.6200 3.6300 3.6400 3.6500 3.6600 3.6700 + 3.6800 3.6900 3.7000 3.7100 3.7200 3.7300 3.7400 3.7500 + 3.7600 3.7700 3.7800 3.7900 3.8000 3.8100 3.8200 3.8300 + 3.8400 3.8500 3.8600 3.8700 3.8800 3.8900 3.9000 3.9100 + 3.9200 3.9300 3.9400 3.9500 3.9600 3.9700 3.9800 3.9900 + 4.0000 4.0100 4.0200 4.0300 4.0400 4.0500 4.0600 4.0700 + 4.0800 4.0900 4.1000 4.1100 4.1200 4.1300 4.1400 4.1500 + 4.1600 4.1700 4.1800 4.1900 4.2000 4.2100 4.2200 4.2300 + 4.2400 4.2500 4.2600 4.2700 4.2800 4.2900 4.3000 4.3100 + 4.3200 4.3300 4.3400 4.3500 4.3600 4.3700 4.3800 4.3900 + 4.4000 4.4100 4.4200 4.4300 4.4400 4.4500 4.4600 4.4700 + 4.4800 4.4900 4.5000 4.5100 4.5200 4.5300 4.5400 4.5500 + 4.5600 4.5700 4.5800 4.5900 4.6000 4.6100 4.6200 4.6300 + 4.6400 4.6500 4.6600 4.6700 4.6800 4.6900 4.7000 4.7100 + 4.7200 4.7300 4.7400 4.7500 4.7600 4.7700 4.7800 4.7900 + 4.8000 4.8100 4.8200 4.8300 4.8400 4.8500 4.8600 4.8700 + 4.8800 4.8900 4.9000 4.9100 4.9200 4.9300 4.9400 4.9500 + 4.9600 4.9700 4.9800 4.9900 5.0000 5.0100 5.0200 5.0300 + 5.0400 5.0500 5.0600 5.0700 5.0800 5.0900 5.1000 5.1100 + 5.1200 5.1300 5.1400 5.1500 5.1600 5.1700 5.1800 5.1900 + 5.2000 5.2100 5.2200 5.2300 5.2400 5.2500 5.2600 5.2700 + 5.2800 5.2900 5.3000 5.3100 5.3200 5.3300 5.3400 5.3500 + 5.3600 5.3700 5.3800 5.3900 5.4000 5.4100 5.4200 5.4300 + 5.4400 5.4500 5.4600 5.4700 5.4800 5.4900 5.5000 5.5100 + 5.5200 5.5300 5.5400 5.5500 5.5600 5.5700 5.5800 5.5900 + 5.6000 5.6100 5.6200 5.6300 5.6400 5.6500 5.6600 5.6700 + 5.6800 5.6900 5.7000 5.7100 5.7200 5.7300 5.7400 5.7500 + 5.7600 5.7700 5.7800 5.7900 5.8000 5.8100 5.8200 5.8300 + 5.8400 5.8500 5.8600 5.8700 5.8800 5.8900 5.9000 5.9100 + 5.9200 5.9300 5.9400 5.9500 5.9600 5.9700 5.9800 5.9900 + 6.0000 6.0100 + + + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 + + + + -9.0610437558E+00 -9.0568179440E+00 -9.0440368423E+00 -9.0228074240E+00 + -8.9932366622E+00 -8.9554713856E+00 -8.9096955089E+00 -8.8561267684E+00 + -8.7950131219E+00 -8.7266289853E+00 -8.6512714714E+00 -8.5692567717E+00 + -8.4809167973E+00 -8.3865961577E+00 -8.2866495257E+00 -8.1814394040E+00 + -8.0713342805E+00 -7.9567071423E+00 -7.8379342970E+00 -7.7153944473E+00 + -7.5894679553E+00 -7.4605362378E+00 -7.3289812341E+00 -7.1951848958E+00 + -7.0595286560E+00 -6.9223928378E+00 -6.7841559816E+00 -6.6451940571E+00 + -6.5058795596E+00 -6.3665804704E+00 -6.2276590796E+00 -6.0894706704E+00 + -5.9523620796E+00 -5.8166700798E+00 -5.6827196991E+00 -5.5508223633E+00 + -5.4212739530E+00 -5.2943527007E+00 -5.1703170897E+00 -5.0494035400E+00 + -4.9318240186E+00 -4.8177636487E+00 -4.7073781566E+00 -4.6007912591E+00 + -4.4980919767E+00 -4.3993318735E+00 -4.3045222275E+00 -4.2136312137E+00 + -4.1265808607E+00 -4.0432438377E+00 -3.9634411592E+00 -3.8869595066E+00 + -3.8135916025E+00 -3.7431452942E+00 -3.6754419749E+00 -3.6103158908E+00 + -3.5476125181E+00 -3.4871882092E+00 -3.4289088467E+00 -3.3726496295E+00 + -3.3182938607E+00 -3.2657329154E+00 -3.2148652694E+00 -3.1655961918E+00 + -3.1178374334E+00 -3.0715065944E+00 -3.0265268914E+00 -2.9828269546E+00 + -2.9403403441E+00 -2.8990053187E+00 -2.8587646530E+00 -2.8195654255E+00 + -2.7813586956E+00 -2.7440993328E+00 -2.7077458096E+00 -2.6722599695E+00 + -2.6376068987E+00 -2.6037546665E+00 -2.5706741108E+00 -2.5383386428E+00 + -2.5067240362E+00 -2.4758082142E+00 -2.4455710353E+00 -2.4159940785E+00 + -2.3870604303E+00 -2.3587544755E+00 -2.3310616932E+00 -2.3039684604E+00 + -2.2774618664E+00 -2.2515295388E+00 -2.2261594843E+00 -2.2013399461E+00 + -2.1770592791E+00 -2.1533058441E+00 -2.1300679226E+00 -2.1073336580E+00 + -2.0850909954E+00 -2.0633276674E+00 -2.0420311892E+00 -2.0211888715E+00 + -2.0007878496E+00 -1.9808151272E+00 -1.9612576275E+00 -1.9421022557E+00 + -1.9233359852E+00 -1.9049459279E+00 -1.8869194114E+00 -1.8692440280E+00 + -1.8519077546E+00 -1.8348990301E+00 -1.8182067760E+00 -1.8018204402E+00 + -1.7857300225E+00 -1.7699262307E+00 -1.7544003587E+00 -1.7391444068E+00 + -1.7241513910E+00 -1.7094149041E+00 -1.6949283914E+00 -1.6806851418E+00 + -1.6666793118E+00 -1.6529050288E+00 -1.6393565372E+00 -1.6260283354E+00 + -1.6129151224E+00 -1.6000117236E+00 -1.5873131231E+00 -1.5748145186E+00 + -1.5625112075E+00 -1.5503986290E+00 -1.5384724172E+00 -1.5267282808E+00 + -1.5151620774E+00 -1.5037698221E+00 -1.4925475838E+00 -1.4814916063E+00 + -1.4705982343E+00 -1.4598638619E+00 -1.4492850817E+00 -1.4388585096E+00 + -1.4285808834E+00 -1.4184490612E+00 -1.4084599113E+00 -1.3986104920E+00 + -1.3888978631E+00 -1.3793192008E+00 -1.3698717674E+00 -1.3605528496E+00 + -1.3513598874E+00 -1.3422902990E+00 -1.3333416549E+00 -1.3245115294E+00 + -1.3157975913E+00 -1.3071975681E+00 -1.2987092220E+00 -1.2903304217E+00 + -1.2820590200E+00 -1.2738930123E+00 -1.2658303454E+00 -1.2578691201E+00 + -1.2500073905E+00 -1.2422433402E+00 -1.2345751282E+00 -1.2270010179E+00 + -1.2195192646E+00 -1.2121282090E+00 -1.2048261947E+00 -1.1976116375E+00 + -1.1904829614E+00 -1.1834386556E+00 -1.1764772175E+00 -1.1695972076E+00 + -1.1627971899E+00 -1.1560757951E+00 -1.1494316470E+00 -1.1428634453E+00 + -1.1363698679E+00 -1.1299496816E+00 -1.1236016133E+00 -1.1173244954E+00 + -1.1111170992E+00 -1.1049783153E+00 -1.0989069715E+00 -1.0929019971E+00 + -1.0869622832E+00 -1.0810867896E+00 -1.0752744716E+00 -1.0695243151E+00 + -1.0638353388E+00 -1.0582065507E+00 -1.0526370315E+00 -1.0471258093E+00 + -1.0416720144E+00 -1.0362747227E+00 -1.0309330806E+00 -1.0256462248E+00 + -1.0204133106E+00 -1.0152335359E+00 -1.0101060634E+00 -1.0050301401E+00 + -1.0000049637E+00 -9.9502979509E-01 -9.9010388850E-01 -9.8522650356E-01 + -9.8039695184E-01 -9.7561449875E-01 -9.7087848953E-01 -9.6618823633E-01 + -9.6154307709E-01 -9.5694238357E-01 -9.5238548542E-01 -9.4787179443E-01 + -9.4340068216E-01 -9.3897154786E-01 -9.3458382085E-01 -9.3023689119E-01 + -9.2593022219E-01 -9.2166324612E-01 -9.1743540867E-01 -9.1324619440E-01 + -9.0909505086E-01 -9.0498147929E-01 -9.0090497409E-01 -8.9686501466E-01 + -8.9286113809E-01 -8.8889284780E-01 -8.8495967058E-01 -8.8106115837E-01 + -8.7719683072E-01 -8.7336625731E-01 -8.6956900186E-01 -8.6580460671E-01 + -8.6207267364E-01 -8.5837277569E-01 -8.5470449112E-01 -8.5106743638E-01 + -8.4746119942E-01 -8.4388539099E-01 -8.4033964140E-01 -8.3682355391E-01 + -8.3333676803E-01 -8.2987892766E-01 -8.2644965155E-01 -8.2304860442E-01 + -8.1967544372E-01 -8.1632980376E-01 -8.1301137110E-01 -8.0971981657E-01 + -8.0645479078E-01 -8.0321599828E-01 -8.0000312317E-01 -7.9681583368E-01 + -7.9365384812E-01 -7.9051686526E-01 -7.8740456836E-01 -7.8431668932E-01 + -7.8125294167E-01 -7.7821302127E-01 -7.7519667347E-01 -7.7220362543E-01 + -7.6923358691E-01 -7.6628631304E-01 -7.6336154485E-01 -7.6045900684E-01 + -7.5757846086E-01 -7.5471966218E-01 -7.5188235009E-01 -7.4906629106E-01 + -7.4627125457E-01 -7.4349699489E-01 -7.4074328111E-01 -7.3800989688E-01 + -7.3529661160E-01 -7.3260319525E-01 -7.2992944541E-01 -7.2727514676E-01 + -7.2464006883E-01 -7.2202402266E-01 -7.1942680330E-01 -7.1684819373E-01 + -7.1428800302E-01 -7.1174604062E-01 -7.0922210469E-01 -7.0671599945E-01 + -7.0422754882E-01 -7.0175656648E-01 -6.9930285090E-01 -6.9686623967E-01 + -6.9444655518E-01 -6.9204361057E-01 -6.8965723548E-01 -6.8728726731E-01 + -6.8493353479E-01 -6.8259585830E-01 -6.8027408946E-01 -6.7796806685E-01 + -6.7567761966E-01 -6.7340259451E-01 -6.7114284334E-01 -6.6889821110E-01 + -6.6666853234E-01 -6.6445367341E-01 -6.6225348756E-01 -6.6006782094E-01 + -6.5789652969E-01 -6.5573948134E-01 -6.5359653600E-01 -6.5146754198E-01 + -6.4935237457E-01 -6.4725090244E-01 -6.4516298961E-01 -6.4308849538E-01 + -6.4102730352E-01 -6.3897928686E-01 -6.3694431188E-01 -6.3492225321E-01 + -6.3291299679E-01 -6.3091642140E-01 -6.2893239660E-01 -6.2696081023E-01 + -6.2500155065E-01 -6.2305450228E-01 -6.2111953833E-01 -6.1919655775E-01 + -6.1728545168E-01 -6.1538610939E-01 -6.1349840980E-01 -6.1162225937E-01 + -6.0975755301E-01 -6.0790418385E-01 -6.0606203900E-01 -6.0423102850E-01 + -6.0241105218E-01 -6.0060200743E-01 -5.9880378789E-01 -5.9701630748E-01 + -5.9523947068E-01 -5.9347317955E-01 -5.9171733268E-01 -5.8997184815E-01 + -5.8823663490E-01 -5.8651159997E-01 -5.8479664543E-01 -5.8309169382E-01 + -5.8139665833E-01 -5.7971145131E-01 -5.7803597694E-01 -5.7637016247E-01 + -5.7471392514E-01 -5.7306718215E-01 -5.7142984084E-01 -5.6980183110E-01 + -5.6818307475E-01 -5.6657349289E-01 -5.6497299873E-01 -5.6338152110E-01 + -5.6179898754E-01 -5.6022532279E-01 -5.5866044633E-01 -5.5710428471E-01 + -5.5555677140E-01 -5.5401783464E-01 -5.5248740049E-01 -5.5096539222E-01 + -5.4945174929E-01 -5.4794640331E-01 -5.4644928588E-01 -5.4496032010E-01 + -5.4347944752E-01 -5.4200660421E-01 -5.4054172497E-01 -5.3908473990E-01 + -5.3763558480E-01 -5.3619420258E-01 -5.3476053107E-01 -5.3333450778E-01 + -5.3191606202E-01 -5.3050514339E-01 -5.2910169262E-01 -5.2770565043E-01 + -5.2631695259E-01 -5.2493554186E-01 -5.2356136607E-01 -5.2219436872E-01 + -5.2083449329E-01 -5.1948167463E-01 -5.1813586721E-01 -5.1679701734E-01 + -5.1546507114E-01 -5.1413997141E-01 -5.1282166293E-01 -5.1151009987E-01 + -5.1020523087E-01 -5.0890700456E-01 -5.0761536348E-01 -5.0633026144E-01 + -5.0505165203E-01 -5.0377948626E-01 -5.0251371517E-01 -5.0125428164E-01 + -5.0000114694E-01 -4.9875426449E-01 -4.9751358757E-01 -4.9627906774E-01 + -4.9505065408E-01 -4.9382830847E-01 -4.9261198641E-01 -4.9140164337E-01 + -4.9019723176E-01 -4.8899870589E-01 -4.8780602831E-01 -4.8661915658E-01 + -4.8543804824E-01 -4.8426265702E-01 -4.8309294118E-01 -4.8192886432E-01 + -4.8077038597E-01 -4.7961746566E-01 -4.7847005879E-01 -4.7732812642E-01 + -4.7619163356E-01 -4.7506054163E-01 -4.7393481203E-01 -4.7281440223E-01 + -4.7169927496E-01 -4.7058939701E-01 -4.6948473158E-01 -4.6838524190E-01 + -4.6729088781E-01 -4.6620163267E-01 -4.6511744539E-01 -4.6403829091E-01 + -4.6296413415E-01 -4.6189493768E-01 -4.6083066451E-01 -4.5977128600E-01 + -4.5871676870E-01 -4.5766707919E-01 -4.5662218308E-01 -4.5558204211E-01 + -4.5454663035E-01 -4.5351591594E-01 -4.5248986699E-01 -4.5146845163E-01 + -4.5045163204E-01 -4.4943938274E-01 -4.4843167416E-01 -4.4742847591E-01 + -4.4642975759E-01 -4.4543548505E-01 -4.4444562951E-01 -4.4346016491E-01 + -4.4247906228E-01 -4.4150229265E-01 -4.4052982584E-01 -4.3956162903E-01 + -4.3859767986E-01 -4.3763795070E-01 -4.3668241393E-01 -4.3573104192E-01 + -4.3478380238E-01 -4.3384067158E-01 -4.3290162488E-01 -4.3196663593E-01 + -4.3103567840E-01 -4.3010872454E-01 -4.2918574490E-01 -4.2826671914E-01 + -4.2735162215E-01 -4.2644042882E-01 -4.2553311405E-01 -4.2462964878E-01 + -4.2373001042E-01 -4.2283417718E-01 -4.2194212512E-01 -4.2105383031E-01 + -4.2016926876E-01 -4.1928841078E-01 -4.1841123932E-01 -4.1753773154E-01 + -4.1666786462E-01 -4.1580161574E-01 -4.1493896037E-01 -4.1407987359E-01 + -4.1322433773E-01 -4.1237233102E-01 -4.1152383170E-01 -4.1067881801E-01 + -4.0983726529E-01 -4.0899915239E-01 -4.0816446135E-01 -4.0733317141E-01 + -4.0650526184E-01 -4.0568071187E-01 -4.0485949712E-01 -4.0404159922E-01 + -4.0322700028E-01 -4.0241568050E-01 -4.0160762012E-01 -4.0080279935E-01 + -4.0000119443E-01 -3.9920278882E-01 -3.9840756506E-01 -3.9761550429E-01 + -3.9682658765E-01 -3.9604079630E-01 -3.9525810742E-01 -3.9447850542E-01 + -3.9370197363E-01 -3.9292849408E-01 -3.9215804879E-01 -3.9139061977E-01 + -3.9062618552E-01 -3.8986473052E-01 -3.8910623925E-01 -3.8835069457E-01 + -3.8759807933E-01 -3.8684837639E-01 -3.8610156584E-01 -3.8535763147E-01 + -3.8461655919E-01 -3.8387833266E-01 -3.8314293554E-01 -3.8241035148E-01 + -3.8168056246E-01 -3.8095355083E-01 -3.8022930425E-01 -3.7950780711E-01 + -3.7878904385E-01 -3.7807299889E-01 -3.7735965635E-01 -3.7664899651E-01 + -3.7594100897E-01 -3.7523567887E-01 -3.7453299135E-01 -3.7383293156E-01 + -3.7313548465E-01 -3.7244063248E-01 -3.7174836252E-01 -3.7105866202E-01 + -3.7037151682E-01 -3.6968691275E-01 -3.6900483566E-01 -3.6832527016E-01 + -3.6764820011E-01 -3.6697361536E-01 -3.6630150240E-01 -3.6563184773E-01 + -3.6496463784E-01 -3.6429985924E-01 -3.6363749507E-01 -3.6297753451E-01 + -3.6231996581E-01 -3.6166477608E-01 -3.6101195247E-01 -3.6036148208E-01 + -3.5971335135E-01 -3.5906754455E-01 -3.5842405304E-01 -3.5778286454E-01 + -3.5714396678E-01 -3.5650734748E-01 -3.5587299437E-01 -3.5524089309E-01 + -3.5461103153E-01 -3.5398340017E-01 -3.5335798731E-01 -3.5273478124E-01 + -3.5211377027E-01 -3.5149494269E-01 -3.5087828373E-01 -3.5026378405E-01 + -3.4965143359E-01 -3.4904122118E-01 -3.4843313568E-01 -3.4782716591E-01 + -3.4722330074E-01 -3.4662152533E-01 -3.4602183228E-01 -3.4542421132E-01 + -3.4482865181E-01 -3.4423514312E-01 -3.4364367460E-01 -3.4305423563E-01 + -3.4246681166E-01 -3.4188139641E-01 -3.4129797977E-01 -3.4071655158E-01 + -3.4013710172E-01 -3.3955962003E-01 -3.3898409638E-01 -3.3841051679E-01 + -3.3783887542E-01 -3.3726916258E-01 -3.3670136861E-01 -3.3613548384E-01 + -3.3557149861E-01 -3.3500940324E-01 -3.3444918462E-01 -3.3389083661E-01 + -3.3333435031E-01 -3.3277971650E-01 + + + + 0.0000000000E+00 -2.6088547982E-01 -5.1833275472E-01 -7.6895641941E-01 + -1.0094757748E+00 -1.2367649640E+00 -1.4479004921E+00 -1.6402053307E+00 + -1.8112888675E+00 -1.9590820386E+00 -2.0818670611E+00 -2.1783012866E+00 + -2.2474347945E+00 -2.2887214604E+00 -2.3020233440E+00 -2.2876083718E+00 + -2.2461413919E+00 -2.1786688108E+00 -2.0865971283E+00 -1.9716657861E+00 + -1.8359148921E+00 -1.6816483354E+00 -1.5113931252E+00 -1.3278555788E+00 + -1.1338753152E+00 -9.3237750193E-01 -7.2632508798E-01 -5.1867053707E-01 + -3.1230935470E-01 -1.1003518382E-01 8.5502335005E-02 2.7183628053E-01 + 4.4671684037E-01 6.0814212888E-01 7.5438240005E-01 8.8400019998E-01 + 9.9586420814E-01 1.0891579569E+00 1.1633817902E+00 1.2183503968E+00 + 1.2541845008E+00 1.2712971870E+00 1.2703761390E+00 1.2523616859E+00 + 1.2184214326E+00 1.1699221627E+00 1.1083997635E+00 1.0355281365E+00 + 9.5308744579E-01 8.6293235820E-01 7.6696227219E-01 6.6708583573E-01 + 5.6517138232E-01 4.6301269339E-01 3.6230358110E-01 2.6460354791E-01 + 1.7132725391E-01 8.3714876259E-02 2.8300950036E-03 -7.0461868736E-02 + -1.3548566127E-01 -1.9177104351E-01 -2.3903864371E-01 -2.7719764878E-01 + -3.0633813688E-01 -3.2671240755E-01 -3.3872209753E-01 -3.4290134301E-01 + -3.3989414704E-01 -3.3043492034E-01 -3.1532726713E-01 -2.9542143883E-01 + -2.7159339422E-01 -2.4472437166E-01 -2.1568159041E-01 -1.8530141020E-01 + -1.5437121547E-01 -1.2361699029E-01 -9.3692510618E-02 -6.5170103885E-02 + -3.8534327148E-02 -1.4178178357E-02 7.5982219585E-03 2.6586599843E-02 + 4.2667321458E-02 5.5804230200E-02 6.6037784474E-02 7.3476782950E-02 + 7.8288985480E-02 8.0690950459E-02 8.0937413388E-02 7.9310526716E-02 + 7.6109267813E-02 7.1639300505E-02 6.6203546315E-02 6.0094670030E-02 + 5.3585181276E-02 4.6922886516E-02 4.0325965406E-02 3.3979459512E-02 + 2.8033278554E-02 2.2601546887E-02 1.7764693923E-02 1.3566271071E-02 + 1.0019934924E-02 7.1127553803E-03 4.8089618584E-03 3.0547066732E-03 + 1.7812642827E-03 9.1198278094E-04 3.6682674818E-04 6.5692263071E-05 + -6.8632527182E-05 -1.1027997757E-04 -8.4781932173E-05 -7.5466225625E-06 + 5.5046813283E-06 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 + + + 0.0000000000E+00 -6.6230384280E-02 -1.3227044522E-01 -1.9793408785E-01 + -2.6304354775E-01 -3.2743324392E-01 -3.9095326529E-01 -4.5347238282E-01 + -5.1488049086E-01 -5.7509039536E-01 -6.3403888294E-01 -6.9168702295E-01 + -7.4801967384E-01 -8.0304418574E-01 -8.5678831251E-01 -9.0929736637E-01 + -9.6063067143E-01 -1.0108573877E+00 -1.0600518025E+00 -1.1082881938E+00 + -1.1556354004E+00 -1.2021512134E+00 -1.2478767659E+00 -1.2928310462E+00 + -1.3370057140E+00 -1.3803603227E+00 -1.4228182118E+00 -1.4642630461E+00 + -1.5045363102E+00 -1.5434357567E+00 -1.5807149649E+00 -1.6160840886E+00 + -1.6492118605E+00 -1.6797288707E+00 -1.7072322005E+00 -1.7312913303E+00 + -1.7514553443E+00 -1.7672614056E+00 -1.7782442660E+00 -1.7839469588E+00 + -1.7839324513E+00 -1.7777959450E+00 -1.7651779669E+00 -1.7457779317E+00 + -1.7193680413E+00 -1.6858073499E+00 -1.6450558238E+00 -1.5971880652E+00 + -1.5424070527E+00 -1.4810575934E+00 -1.4136370872E+00 -1.3407629725E+00 + -1.2630862948E+00 -1.1812692944E+00 -1.0959852410E+00 -1.0079152517E+00 + -9.1774784801E-01 -8.2617381277E-01 -7.3388443997E-01 -6.4156480522E-01 + -5.4989159388E-01 -4.5952456379E-01 -3.7110347095E-01 -2.8524119151E-01 + -2.0251655480E-01 -1.2347058174E-01 -4.8599831493E-02 2.1650489647E-02 + 8.6889253952E-02 1.4678399897E-01 2.0106542651E-01 2.4953062217E-01 + 2.9204347185E-01 3.2853617819E-01 3.5900919836E-01 3.8352979134E-01 + 4.0223095680E-01 4.1530746441E-01 4.2301167574E-01 4.2564876217E-01 + 4.2357093422E-01 4.1717097424E-01 4.0687519421E-01 3.9313595295E-01 + 3.7642387716E-01 3.5721993688E-01 3.3600752955E-01 3.1326472631E-01 + 2.8945683082E-01 2.6502939400E-01 2.4040181789E-01 2.1596166863E-01 + 1.9205980225E-01 1.6900638782E-01 1.4706789081E-01 1.2646640479E-01 + 1.0737471459E-01 8.9919605583E-02 7.4182301027E-02 6.0200233461E-02 + 4.7969874788E-02 3.7450322138E-02 2.8568294126E-02 2.1219868525E-02 + 1.5278963151E-02 1.0602331228E-02 7.0348351713E-03 4.4142517848E-03 + 2.5774088544E-03 1.3667064349E-03 6.3345563442E-04 2.4137577893E-04 + 6.9281378302E-05 2.0772501814E-05 1.5017397331E-05 1.0881212294E-06 + -1.0503836267E-06 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 + + + -2.4016441487E+01 0.0000000000E+00 0.0000000000E+00 -1.0336462913E+00 + + + + + + 0.0000000000E+00 2.4794341471E-04 9.9091894057E-04 2.2263680628E-03 + 3.9500456984E-03 6.1560486329E-03 8.8368548808E-03 1.1983373531E-02 + 1.5585004525E-02 1.9629707710E-02 2.4104080427E-02 2.8993442803E-02 + 3.4281929867E-02 3.9952589544E-02 4.5987485557E-02 5.2367804247E-02 + 5.9073964300E-02 6.6085728409E-02 7.3382315882E-02 8.0942515274E-02 + 8.8744796138E-02 9.6767419086E-02 1.0498854333E-01 1.1338633103E-01 + 1.2193904783E-01 1.3062515893E-01 1.3942342031E-01 1.4831296458E-01 + 1.5727338117E-01 1.6628479066E-01 1.7532791282E-01 1.8438412840E-01 + 1.9343553473E-01 2.0246499428E-01 2.1145617765E-01 2.2039359948E-01 + 2.2926264851E-01 2.3804961085E-01 2.4674168841E-01 2.5532701021E-01 + 2.6379463827E-01 2.7213456885E-01 2.8033772768E-01 2.8839596035E-01 + 2.9630201805E-01 3.0404953869E-01 3.1163302393E-01 3.1904781286E-01 + 3.2629005077E-01 3.3335665407E-01 3.4024527527E-01 3.4695426557E-01 + 3.5348262690E-01 3.5982997159E-01 3.6599648316E-01 3.7198285339E-01 + 3.7779025613E-01 3.8342027746E-01 3.8887488964E-01 3.9415637933E-01 + 3.9926732777E-01 4.0421053528E-01 4.0898900016E-01 4.1360586662E-01 + 4.1806437563E-01 4.2236784139E-01 4.2651960765E-01 4.3052300623E-01 + 4.3438133902E-01 4.3809784793E-01 4.4167568640E-01 4.4511789734E-01 + 4.4842740211E-01 4.5160698378E-01 4.5465927654E-01 4.5758675943E-01 + 4.6039174939E-01 4.6307640307E-01 4.6564271888E-01 4.6809254111E-01 + 4.7042756695E-01 4.7264935579E-01 4.7475934017E-01 4.7675883847E-01 + 4.7864906862E-01 4.8043116285E-01 4.8210618286E-01 4.8367513530E-01 + 4.8513898716E-01 4.8649868075E-01 4.8775514807E-01 4.8890932424E-01 + 4.8996215983E-01 4.9091463191E-01 4.9176775358E-01 4.9252257613E-01 + 4.9318021185E-01 4.9374182540E-01 4.9420863911E-01 4.9458193531E-01 + 4.9486305613E-01 4.9505340201E-01 4.9515442062E-01 4.9516762730E-01 + 4.9509458085E-01 4.9493687901E-01 4.9469615451E-01 4.9437406196E-01 + 4.9397228868E-01 4.9349254046E-01 4.9293652709E-01 4.9230595866E-01 + 4.9160253929E-01 4.9082798382E-01 4.8998398626E-01 4.8907222166E-01 + 4.8809434735E-01 4.8705202061E-01 4.8594687199E-01 4.8478050140E-01 + 4.8355451132E-01 4.8227048421E-01 4.8092996944E-01 4.7953450212E-01 + 4.7808561574E-01 4.7658480457E-01 4.7503353906E-01 4.7343329913E-01 + 4.7178551873E-01 4.7009160857E-01 4.6835299066E-01 4.6657103314E-01 + 4.6474709403E-01 4.6288253276E-01 4.6097864623E-01 4.5903674889E-01 + 4.5705812988E-01 4.5504401645E-01 4.5299568348E-01 4.5091433129E-01 + 4.4880115759E-01 4.4665736345E-01 4.4448406520E-01 4.4228244437E-01 + 4.4005359528E-01 4.3779862199E-01 4.3551861800E-01 4.3321460984E-01 + 4.3088768122E-01 4.2853880795E-01 4.2616903012E-01 4.2377930732E-01 + 4.2137061147E-01 4.1894389471E-01 4.1650006236E-01 4.1404005773E-01 + 4.1156472312E-01 4.0907498816E-01 4.0657164288E-01 4.0405558773E-01 + 4.0152758537E-01 3.9898848719E-01 3.9643903481E-01 3.9388003353E-01 + 3.9131220208E-01 3.8873630343E-01 3.8615303095E-01 3.8356310956E-01 + 3.8096720441E-01 3.7836600704E-01 3.7576015114E-01 3.7315029989E-01 + 3.7053705201E-01 3.6792104757E-01 3.6530284664E-01 3.6268307155E-01 + 3.6006223998E-01 3.5744096187E-01 3.5481970890E-01 3.5219908368E-01 + 3.4957950873E-01 3.4696157326E-01 3.4434567985E-01 3.4173237209E-01 + 3.3912205408E-01 3.3651521191E-01 3.3391226115E-01 3.3131362397E-01 + 3.2871973492E-01 3.2613094713E-01 3.2354771963E-01 3.2097033407E-01 + 3.1839925340E-01 3.1583475732E-01 3.1327723928E-01 3.1072701520E-01 + 3.0818439374E-01 3.0564973754E-01 3.0312326636E-01 3.0060536753E-01 + 2.9809624731E-01 2.9559622996E-01 2.9310557269E-01 2.9062449750E-01 + 2.8815332279E-01 2.8569218837E-01 2.8324141465E-01 2.8080118028E-01 + 2.7837169267E-01 2.7595321500E-01 2.7354583751E-01 2.7114985674E-01 + 2.6876540189E-01 2.6639264465E-01 2.6403181011E-01 2.6168295407E-01 + 2.5934632864E-01 2.5702204381E-01 2.5471021239E-01 2.5241103884E-01 + 2.5012456127E-01 2.4785096372E-01 2.4559036883E-01 2.4334280687E-01 + 2.4110847696E-01 2.3888742000E-01 2.3667972467E-01 2.3448553732E-01 + 2.3230484695E-01 2.3013779622E-01 2.2798447164E-01 2.2584484162E-01 + 2.2371907224E-01 2.2160718423E-01 2.1950918491E-01 2.1742520274E-01 + 2.1535521910E-01 2.1329927590E-01 2.1125746569E-01 2.0922973692E-01 + 2.0721615973E-01 2.0521679417E-01 2.0323156191E-01 2.0126055392E-01 + 1.9930380230E-01 1.9736120736E-01 1.9543287344E-01 1.9351880846E-01 + 1.9161889992E-01 1.8973325450E-01 1.8786185993E-01 1.8600460254E-01 + 1.8416157699E-01 1.8233276208E-01 1.8051803620E-01 1.7871748583E-01 + 1.7693108606E-01 1.7515870043E-01 1.7340041110E-01 1.7165618863E-01 + 1.6992589269E-01 1.6820958701E-01 1.6650724345E-01 1.6481872662E-01 + 1.6314406985E-01 1.6148325248E-01 1.5983614921E-01 1.5820275480E-01 + 1.5658306061E-01 1.5497695691E-01 1.5338439180E-01 1.5180537259E-01 + 1.5023981072E-01 1.4868760030E-01 1.4714876754E-01 1.4562325032E-01 + 1.4411088316E-01 1.4261171261E-01 1.4112567980E-01 1.3965263949E-01 + 1.3819257554E-01 1.3674545831E-01 1.3531117665E-01 1.3388963650E-01 + 1.3248084168E-01 1.3108472136E-01 1.2970109889E-01 1.2833001076E-01 + 1.2697139008E-01 1.2562509939E-01 1.2429108335E-01 1.2296931894E-01 + 1.2165971717E-01 1.2036212317E-01 1.1907655698E-01 1.1780294648E-01 + 1.1654114810E-01 1.1529111045E-01 1.1405280258E-01 1.1282613765E-01 + 1.1161095024E-01 1.1040725990E-01 1.0921499300E-01 1.0803401854E-01 + 1.0686425527E-01 1.0570568262E-01 1.0455822148E-01 1.0342170539E-01 + 1.0229612790E-01 1.0118143008E-01 1.0007751189E-01 9.8984230691E-02 + 9.7901591614E-02 9.6829518883E-02 9.5767884597E-02 9.4716602554E-02 + 9.3675651345E-02 9.2644952595E-02 9.1624357062E-02 9.0613825474E-02 + 8.9613313452E-02 8.8622740963E-02 8.7641943554E-02 8.6670918562E-02 + 8.5709603256E-02 8.4757913158E-02 8.3815684928E-02 8.2882931486E-02 + 8.1959580376E-02 8.1045538566E-02 8.0140663081E-02 7.9244958367E-02 + 7.8358352085E-02 7.7480747512E-02 7.6612013484E-02 7.5752149816E-02 + 7.4901084880E-02 7.4058722878E-02 7.3224935982E-02 7.2399723308E-02 + 7.1583014448E-02 7.0774718909E-02 6.9974704043E-02 6.9182972050E-02 + 6.8399454182E-02 6.7624069401E-02 6.6856672591E-02 6.6097272493E-02 + 6.5345802386E-02 6.4602189287E-02 6.3866284591E-02 6.3138090627E-02 + 6.2417548303E-02 6.1704587356E-02 6.0999076474E-02 6.0300987164E-02 + 5.9610277067E-02 5.8926878874E-02 5.8250682553E-02 5.7581621736E-02 + 5.6919673704E-02 5.6264774278E-02 5.5616838504E-02 5.4975756187E-02 + 5.4341526243E-02 5.3714087760E-02 5.3093374958E-02 5.2479257060E-02 + 5.1871728058E-02 5.1270739451E-02 5.0676229134E-02 5.0088097362E-02 + 4.9506279485E-02 4.8930756928E-02 4.8361471290E-02 4.7798357672E-02 + 4.7241288817E-02 4.6690276084E-02 4.6145264773E-02 4.5606196203E-02 + 4.5072972721E-02 4.4545541444E-02 4.4023881815E-02 4.3507939101E-02 + 4.2997654834E-02 4.2492905991E-02 4.1993703269E-02 4.1499997132E-02 + 4.1011733250E-02 4.0528830544E-02 4.0051217904E-02 3.9578886841E-02 + 3.9111787057E-02 3.8649865000E-02 3.8193021326E-02 3.7741231625E-02 + 3.7294467263E-02 3.6852678829E-02 3.6415813870E-02 3.5983760247E-02 + 3.5556530198E-02 3.5134078994E-02 3.4716358396E-02 3.4303305080E-02 + 3.3894835682E-02 3.3490952616E-02 3.3091611670E-02 3.2696766006E-02 + 3.2306344980E-02 3.1920288091E-02 3.1538589081E-02 3.1161205154E-02 + 3.0788091067E-02 3.0419172782E-02 3.0054404780E-02 2.9693775584E-02 + 2.9337243976E-02 2.8984766463E-02 2.8636269166E-02 2.8291714111E-02 + 2.7951087999E-02 2.7614351317E-02 2.7281462438E-02 2.6952350866E-02 + 2.6626979290E-02 2.6305335782E-02 2.5987382630E-02 2.5673080163E-02 + 2.5362364216E-02 2.5055191839E-02 2.4751555386E-02 2.4451419017E-02 + 2.4154745071E-02 2.3861478444E-02 2.3571564847E-02 2.3285003479E-02 + 2.3001760410E-02 2.2721800031E-02 2.2445078789E-02 2.2171526061E-02 + 2.1901150013E-02 2.1633918647E-02 2.1369798413E-02 2.1108754197E-02 + 2.0850710883E-02 2.0595671221E-02 2.0343610458E-02 2.0094497098E-02 + 1.9848298202E-02 1.9604955310E-02 1.9364442566E-02 1.9126750436E-02 + 1.8891849457E-02 1.8659708833E-02 1.8430288872E-02 1.8203531688E-02 + 1.7979444001E-02 1.7757998342E-02 1.7539166017E-02 1.7322917097E-02 + 1.7109191383E-02 1.6897980399E-02 1.6689269114E-02 1.6483030879E-02 + 1.6279237912E-02 1.6077852629E-02 1.5878825755E-02 1.5682162720E-02 + 1.5487838857E-02 1.5295828455E-02 1.5106104755E-02 1.4918616206E-02 + 1.4733348857E-02 1.4550292886E-02 1.4369424576E-02 1.4190719249E-02 + 1.4014151128E-02 1.3839659221E-02 1.3667256683E-02 1.3496921706E-02 + 1.3328631601E-02 1.3162362793E-02 1.2998080875E-02 1.2835748138E-02 + 1.2675368275E-02 1.2516920489E-02 1.2360383178E-02 1.2205733920E-02 + 1.2052932833E-02 1.1901959252E-02 1.1752810004E-02 1.1605465350E-02 + 1.1459904808E-02 1.1316107146E-02 1.1174029833E-02 1.1033663349E-02 + 1.0895000275E-02 1.0758021954E-02 1.0622709048E-02 1.0489041530E-02 + 1.0356976695E-02 1.0226510813E-02 1.0097634680E-02 9.9703307378E-03 + 9.8445807986E-03 9.7203660474E-03 9.5976457522E-03 9.4764172062E-03 + 9.3566716576E-03 9.2383926415E-03 9.1215631207E-03 9.0061654822E-03 + 8.8921628626E-03 8.7795493594E-03 8.6683186485E-03 8.5584553503E-03 + 8.4499435627E-03 8.3427668572E-03 8.2368939208E-03 8.1323119604E-03 + 8.0290187790E-03 7.9270000634E-03 7.8262410234E-03 7.7267263895E-03 + 7.6284318873E-03 7.5313346684E-03 7.4354380585E-03 7.3407287840E-03 + 7.2471931373E-03 7.1548169739E-03 7.0635843287E-03 6.9734597403E-03 + 6.8844530956E-03 6.7965521281E-03 6.7097441767E-03 6.6240161831E-03 + 6.5393546899E-03 6.4557301699E-03 6.3731393266E-03 6.2915776433E-03 + 6.2110334645E-03 6.1314947748E-03 6.0529491959E-03 5.9753783320E-03 + 5.8987597471E-03 5.8230986296E-03 5.7483842858E-03 5.6746056953E-03 + 5.6017515092E-03 5.5298100485E-03 5.4587541386E-03 5.3885834526E-03 + 5.3192932870E-03 5.2508735670E-03 5.1833139204E-03 5.1166036764E-03 + 5.0507287806E-03 4.9856653379E-03 4.9214203547E-03 4.8579846503E-03 + 4.7953487751E-03 4.7335030098E-03 4.6724373639E-03 4.6121326368E-03 + 4.5525789599E-03 4.4937772672E-03 4.4357189771E-03 4.3783952646E-03 + 4.3217970601E-03 4.2659150477E-03 4.2107269600E-03 4.1562326781E-03 + 4.1024289394E-03 4.0493077557E-03 3.9968609188E-03 3.9450799988E-03 + 3.8939563432E-03 3.8434664007E-03 3.7936159723E-03 3.7443993547E-03 + 3.6958091420E-03 3.6478377293E-03 3.6004773117E-03 3.5537198828E-03 + 3.5075421006E-03 3.4619523711E-03 3.4169441116E-03 3.3725104825E-03 + 3.3286444647E-03 3.2853388583E-03 3.2425862821E-03 3.2003648485E-03 + 3.1586827452E-03 3.1175338565E-03 3.0769118893E-03 3.0368103888E-03 + 2.9972227375E-03 2.9581421546E-03 2.9195492532E-03 2.8814496160E-03 + 2.8438387299E-03 2.8067108257E-03 + + diff --git a/ABACUS.develop/examples/H2O-deepks/H_gga_8au_60Ry_2s1p.orb b/ABACUS.develop/examples/H2O-deepks/H_gga_8au_60Ry_2s1p.orb new file mode 100644 index 0000000000..48eaf466a1 --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks/H_gga_8au_60Ry_2s1p.orb @@ -0,0 +1,621 @@ +--------------------------------------------------------------------------- +Element H +Energy Cutoff(Ry) 60 +Radius Cutoff(a.u.) 8 +Lmax 1 +Number of Sorbital--> 2 +Number of Porbital--> 1 +--------------------------------------------------------------------------- +SUMMARY END + +Mesh 801 +dr 0.01 + Type L N + 0 0 0 + 1.837183001954e+00 1.836944589913e+00 1.836229654458e+00 1.835039096904e+00 + 1.833374417163e+00 1.831237710329e+00 1.828631661910e+00 1.825559541724e+00 + 1.822025196478e+00 1.818033041051e+00 1.813588048498e+00 1.808695738828e+00 + 1.803362166562e+00 1.797593907128e+00 1.791398042128e+00 1.784782143515e+00 + 1.777754256735e+00 1.770322882882e+00 1.762496959911e+00 1.754285842983e+00 + 1.745699283975e+00 1.736747410234e+00 1.727440702633e+00 1.717789972985e+00 + 1.707806340887e+00 1.697501210064e+00 1.686886244272e+00 1.675973342834e+00 + 1.664774615881e+00 1.653302359357e+00 1.641569029875e+00 1.629587219474e+00 + 1.617369630367e+00 1.604929049734e+00 1.592278324633e+00 1.579430337099e+00 + 1.566397979495e+00 1.553194130183e+00 1.539831629571e+00 1.526323256609e+00 + 1.512681705776e+00 1.498919564642e+00 1.485049292031e+00 1.471083196857e+00 + 1.457033417677e+00 1.442911903007e+00 1.428730392444e+00 1.414500398644e+00 + 1.400233190182e+00 1.385939775333e+00 1.371630886810e+00 1.357316967481e+00 + 1.343008157094e+00 1.328714280028e+00 1.314444834085e+00 1.300208980342e+00 + 1.286015534077e+00 1.271872956757e+00 1.257789349118e+00 1.243772445314e+00 + 1.229829608141e+00 1.215967825332e+00 1.202193706904e+00 1.188513483548e+00 + 1.174933006049e+00 1.161457745704e+00 1.148092795727e+00 1.134842873614e+00 + 1.121712324429e+00 1.108705124991e+00 1.095824888929e+00 1.083074872558e+00 + 1.070457981553e+00 1.057976778365e+00 1.045633490360e+00 1.033430018609e+00 + 1.021367947317e+00 1.009448553813e+00 9.976728190860e-01 9.860414387908e-01 + 9.745548346979e-01 9.632131665266e-01 9.520163441167e-01 9.409640398896e-01 + 9.300557015494e-01 9.192905649774e-01 9.086676672686e-01 8.981858598668e-01 + 8.878438217485e-01 8.776400726115e-01 8.675729860234e-01 8.576408024859e-01 + 8.478416423739e-01 8.381735187085e-01 8.286343497244e-01 8.192219711958e-01 + 8.099341484846e-01 8.007685882774e-01 7.917229499810e-01 7.827948567466e-01 + 7.739819060948e-01 7.652816801187e-01 7.566917552403e-01 7.482097115016e-01 + 7.398331413718e-01 7.315596580552e-01 7.233869032872e-01 7.153125546063e-01 + 7.073343320959e-01 6.994500045870e-01 6.916573953213e-01 6.839543870698e-01 + 6.763389267106e-01 6.688090292670e-01 6.613627814111e-01 6.539983444408e-01 + 6.467139567383e-01 6.395079357207e-01 6.323786792970e-01 6.253246668428e-01 + 6.183444597120e-01 6.114367012998e-01 6.046001166779e-01 5.978335118199e-01 + 5.911357724396e-01 5.845058624632e-01 5.779428221587e-01 5.714457659458e-01 + 5.650138799114e-01 5.586464190548e-01 5.523427042877e-01 5.461021192154e-01 + 5.399241067240e-01 5.338081653994e-01 5.277538458047e-01 5.217607466390e-01 + 5.158285108059e-01 5.099568214136e-01 5.041453977325e-01 4.983939911326e-01 + 4.927023810249e-01 4.870703708276e-01 4.814977839793e-01 4.759844600184e-01 + 4.705302507489e-01 4.651350165105e-01 4.597986225695e-01 4.545209356471e-01 + 4.493018205989e-01 4.441411372598e-01 4.390387374660e-01 4.339944622642e-01 + 4.290081393187e-01 4.240795805231e-01 4.192085798248e-01 4.143949112659e-01 + 4.096383272463e-01 4.049385570104e-01 4.002953053599e-01 3.957082515919e-01 + 3.911770486621e-01 3.867013225703e-01 3.822806719649e-01 3.779146679621e-01 + 3.736028541744e-01 3.693447469412e-01 3.651398357547e-01 3.609875838725e-01 + 3.568874291078e-01 3.528387847874e-01 3.488410408668e-01 3.448935651913e-01 + 3.409957048920e-01 3.371467879035e-01 3.333461245923e-01 3.295930094816e-01 + 3.258867230612e-01 3.222265336680e-01 3.186116994248e-01 3.150414702237e-01 + 3.115150897416e-01 3.080317974748e-01 3.045908307790e-01 3.011914269039e-01 + 2.978328250089e-01 2.945142681489e-01 2.912350052191e-01 2.879942928469e-01 + 2.847913972227e-01 2.816255958578e-01 2.784961792617e-01 2.754024525310e-01 + 2.723437368403e-01 2.693193708300e-01 2.663287118847e-01 2.633711372954e-01 + 2.604460453030e-01 2.575528560170e-01 2.546910122087e-01 2.518599799744e-01 + 2.490592492694e-01 2.462883343097e-01 2.435467738441e-01 2.408341312951e-01 + 2.381499947722e-01 2.354939769580e-01 2.328657148724e-01 2.302648695155e-01 + 2.276911253967e-01 2.251441899519e-01 2.226237928562e-01 2.201296852370e-01 + 2.176616387940e-01 2.152194448327e-01 2.128029132189e-01 2.104118712608e-01 + 2.080461625279e-01 2.057056456128e-01 2.033901928451e-01 2.010996889656e-01 + 1.988340297689e-01 1.965931207221e-01 1.943768755699e-01 1.921852149312e-01 + 1.900180648992e-01 1.878753556493e-01 1.857570200652e-01 1.836629923900e-01 + 1.815932069086e-01 1.795475966703e-01 1.775260922564e-01 1.755286206005e-01 + 1.735551038664e-01 1.716054583896e-01 1.696795936868e-01 1.677774115389e-01 + 1.658988051503e-01 1.640436583889e-01 1.622118451094e-01 1.604032285625e-01 + 1.586176608917e-01 1.568549827195e-01 1.551150228235e-01 1.533975979026e-01 + 1.517025124337e-01 1.500295586177e-01 1.483785164136e-01 1.467491536591e-01 + 1.451412262756e-01 1.435544785550e-01 1.419886435250e-01 1.404434433895e-01 + 1.389185900406e-01 1.374137856375e-01 1.359287232483e-01 1.344630875494e-01 + 1.330165555780e-01 1.315887975315e-01 1.301794776097e-01 1.287882548928e-01 + 1.274147842501e-01 1.260587172734e-01 1.247197032295e-01 1.233973900255e-01 + 1.220914251803e-01 1.208014567985e-01 1.195271345385e-01 1.182681105707e-01 + 1.170240405197e-01 1.157945843848e-01 1.145794074346e-01 1.133781810696e-01 + 1.121905836491e-01 1.110163012772e-01 1.098550285439e-01 1.087064692189e-01 + 1.075703368914e-01 1.064463555568e-01 1.053342601443e-01 1.042337969845e-01 + 1.031447242151e-01 1.020668121220e-01 1.009998434160e-01 9.994361344292e-02 + 9.889793032764e-02 9.786261505153e-02 9.683750146373e-02 9.582243622695e-02 + 9.481727869892e-02 9.382190075086e-02 9.283618652485e-02 9.186003213200e-02 + 9.089334529416e-02 8.993604493153e-02 8.898806069949e-02 8.804933247767e-02 + 8.711980981492e-02 8.619945133369e-02 8.528822409791e-02 8.438610294830e-02 + 8.349306980927e-02 8.260911297183e-02 8.173422635677e-02 8.086840876262e-02 + 8.001166310290e-02 7.916399563701e-02 7.832541519936e-02 7.749593243119e-02 + 7.667555901919e-02 7.586430694553e-02 7.506218775311e-02 7.426921183030e-02 + 7.348538771882e-02 7.271072144857e-02 7.194521590274e-02 7.118887021660e-02 + 7.044167921281e-02 6.970363287618e-02 6.897471587029e-02 6.825490709826e-02 + 6.754417930953e-02 6.684249875447e-02 6.614982488807e-02 6.546611012376e-02 + 6.479129963827e-02 6.412533122782e-02 6.346813521597e-02 6.281963441282e-02 + 6.217974412524e-02 6.154837221742e-02 6.092541922062e-02 6.031077849093e-02 + 5.970433641353e-02 5.910597265146e-02 5.851556043717e-02 5.793296690431e-02 + 5.735805345748e-02 5.679067617719e-02 5.623068625723e-02 5.567793047149e-02 + 5.513225166709e-02 5.459348928055e-02 5.406147987367e-02 5.353605768584e-02 + 5.301705519908e-02 5.250430371249e-02 5.199763392254e-02 5.149687650562e-02 + 5.100186269951e-02 5.051242488017e-02 5.002839713058e-02 4.954961579826e-02 + 4.907592003841e-02 4.860715233943e-02 4.814315902803e-02 4.768379075103e-02 + 4.722890293136e-02 4.677835619574e-02 4.633201677174e-02 4.588975685239e-02 + 4.545145492624e-02 4.501699607151e-02 4.458627221269e-02 4.415918233874e-02 + 4.373563268174e-02 4.331553685543e-02 4.289881595315e-02 4.248539860513e-02 + 4.207522099501e-02 4.166822683595e-02 4.126436730696e-02 4.086360095004e-02 + 4.046589352919e-02 4.007121785247e-02 3.967955355852e-02 3.929088686906e-02 + 3.890521030927e-02 3.852252239779e-02 3.814282730864e-02 3.776613450720e-02 + 3.739245836261e-02 3.702181773910e-02 3.665423556888e-02 3.628973840914e-02 + 3.592835598602e-02 3.557012072822e-02 3.521506729315e-02 3.486323208842e-02 + 3.451465279144e-02 3.416936787005e-02 3.382741610685e-02 3.348883613005e-02 + 3.315366595347e-02 3.282194252816e-02 3.249370130839e-02 3.216897583409e-02 + 3.184779733221e-02 3.153019433907e-02 3.121619234560e-02 3.090581346740e-02 + 3.059907614130e-02 3.029599484973e-02 2.999657987449e-02 2.970083708075e-02 + 2.940876773251e-02 2.912036833994e-02 2.883563053951e-02 2.855454100693e-02 + 2.827708140322e-02 2.800322835388e-02 2.773295346082e-02 2.746622334670e-02 + 2.720299973098e-02 2.694323953697e-02 2.668689502885e-02 2.643391397746e-02 + 2.618423985369e-02 2.593781204788e-02 2.569456611367e-02 2.545443403465e-02 + 2.521734451180e-02 2.498322326994e-02 2.475199338102e-02 2.452357560217e-02 + 2.429788872629e-02 2.407484994296e-02 2.385437520730e-02 2.363637961462e-02 + 2.342077777828e-02 2.320748420868e-02 2.299641369091e-02 2.278748165879e-02 + 2.258060456315e-02 2.237570023195e-02 2.217268822047e-02 2.197149014906e-02 + 2.177203002695e-02 2.157423455996e-02 2.137803344052e-02 2.118335961832e-02 + 2.099014955016e-02 2.079834342757e-02 2.060788538111e-02 2.041872366018e-02 + 2.023081078753e-02 2.004410368768e-02 1.985856378874e-02 1.967415709710e-02 + 1.949085424496e-02 1.930863051036e-02 1.912746581003e-02 1.894734466521e-02 + 1.876825614084e-02 1.859019375878e-02 1.841315538567e-02 1.823714309642e-02 + 1.806216301427e-02 1.788822512858e-02 1.771534309170e-02 1.754353399617e-02 + 1.737281813387e-02 1.720321873867e-02 1.703476171432e-02 1.686747534922e-02 + 1.670139002005e-02 1.653653788602e-02 1.637295257579e-02 1.621066886889e-02 + 1.604972237371e-02 1.589014920400e-02 1.573198565588e-02 1.557526788735e-02 + 1.542003160212e-02 1.526631173980e-02 1.511414217422e-02 1.496355542166e-02 + 1.481458236068e-02 1.466725196525e-02 1.452159105263e-02 1.437762404751e-02 + 1.423537276365e-02 1.409485620432e-02 1.395609038260e-02 1.381908816243e-02 + 1.368385912139e-02 1.355040943570e-02 1.341874178822e-02 1.328885529967e-02 + 1.316074548341e-02 1.303440422391e-02 1.290981977884e-02 1.278697680470e-02 + 1.266585640551e-02 1.254643620432e-02 1.242869043674e-02 1.231259006595e-02 + 1.219810291820e-02 1.208519383795e-02 1.197382486147e-02 1.186395540780e-02 + 1.175554248568e-02 1.164854091516e-02 1.154290356241e-02 1.143858158612e-02 + 1.133552469406e-02 1.123368140788e-02 1.113299933481e-02 1.103342544417e-02 + 1.093490634723e-02 1.083738857850e-02 1.074081887670e-02 1.064514446379e-02 + 1.055031332017e-02 1.045627445440e-02 1.036297816589e-02 1.027037629880e-02 + 1.017842248571e-02 1.008707237956e-02 9.996283872439e-03 9.906017299963e-03 + 9.816235629990e-03 9.726904634575e-03 9.637993044158e-03 9.549472683095e-03 + 9.461318585756e-03 9.373509092547e-03 9.286025925316e-03 9.198854241766e-03 + 9.111982668594e-03 9.025403313231e-03 8.939111754182e-03 8.853107010083e-03 + 8.767391487758e-03 8.681970909646e-03 8.596854221113e-03 8.512053478299e-03 + 8.427583717241e-03 8.343462805139e-03 8.259711274747e-03 8.176352142955e-03 + 8.093410714732e-03 8.010914373688e-03 7.928892360586e-03 7.847375541208e-03 + 7.766396165037e-03 7.685987616284e-03 7.606184158811e-03 7.527020676537e-03 + 7.448532410976e-03 7.370754697499e-03 7.293722701988e-03 7.217471159497e-03 + 7.142034116536e-03 7.067444678566e-03 6.993734764268e-03 6.920934868072e-03 + 6.849073832427e-03 6.778178631184e-03 6.708274165423e-03 6.639383072963e-03 + 6.571525552710e-03 6.504719204914e-03 6.438978888287e-03 6.374316594849e-03 + 6.310741343251e-03 6.248259091204e-03 6.186872667539e-03 6.126581724281e-03 + 6.067382709022e-03 6.009268857733e-03 5.952230208041e-03 5.896253632856e-03 + 5.841322894139e-03 5.787418716443e-03 5.734518879765e-03 5.682598331103e-03 + 5.631629314041e-03 5.581581515517e-03 5.532422228878e-03 5.484116532183e-03 + 5.436627480669e-03 5.389916312153e-03 5.343942664112e-03 5.298664801096e-03 + 5.254039851043e-03 5.210024049057e-03 5.166572987118e-03 5.123641868188e-03 + 5.081185763139e-03 5.039159868908e-03 4.997519766284e-03 4.956221675723e-03 + 4.915222709618e-03 4.874481119449e-03 4.833956536282e-03 4.793610203124e-03 + 4.753405197691e-03 4.713306644192e-03 4.673281912822e-03 4.633300805703e-03 + 4.593335728114e-03 4.553361843925e-03 4.513357214267e-03 4.473302918541e-03 + 4.433183156995e-03 4.392985334212e-03 4.352700122958e-03 4.312321507951e-03 + 4.271846809254e-03 4.231276685107e-03 4.190615114131e-03 4.149869356970e-03 + 4.109049897570e-03 4.068170364395e-03 4.027247432032e-03 3.986300703725e-03 + 3.945352575525e-03 3.904428082829e-03 3.863554730213e-03 3.822762305549e-03 + 3.782082679500e-03 3.741549591582e-03 3.701198424061e-03 3.661065965028e-03 + 3.621190162068e-03 3.581609868005e-03 3.542364580233e-03 3.503494175223e-03 + 3.465038639791e-03 3.427037800768e-03 3.389531054702e-03 3.352557099248e-03 + 3.316153667881e-03 3.280357269556e-03 3.245202934926e-03 3.210723970676e-03 + 3.176951723504e-03 3.143915355211e-03 3.111641630320e-03 3.080154717561e-03 + 3.049476006479e-03 3.019623940341e-03 2.990613866433e-03 2.962457904719e-03 + 2.935164835746e-03 2.908740008560e-03 2.883185269274e-03 2.858498910829e-03 + 2.834675644347e-03 2.811706592354e-03 2.789579304014e-03 2.768277792419e-03 + 2.747782593786e-03 2.728070848352e-03 2.709116402574e-03 2.690889932146e-03 + 2.673359085199e-03 2.656488644942e-03 2.640240710873e-03 2.624574897586e-03 + 2.609448550081e-03 2.594816974380e-03 2.580633682179e-03 2.566850648134e-03 + 2.553418578345e-03 2.540287188493e-03 2.527405490042e-03 2.514722082840e-03 + 2.502185452434e-03 2.489744270362e-03 2.477347695641e-03 2.464945675695e-03 + 2.452489244921e-03 2.439930819104e-03 2.427224483935e-03 2.414326275849e-03 + 2.401194453506e-03 2.387789758222e-03 2.374075661746e-03 2.360018599826e-03 + 2.345588190083e-03 2.330757432809e-03 2.315502893351e-03 2.299804864899e-03 + 2.283647510554e-03 2.267018983675e-03 2.249911525653e-03 2.232321540320e-03 + 2.214249644396e-03 2.195700693471e-03 2.176683783150e-03 2.157212225161e-03 + 2.137303498335e-03 2.116979174517e-03 2.096264819617e-03 2.075189870149e-03 + 2.053787485737e-03 2.032094378211e-03 2.010150618060e-03 1.987999419131e-03 + 1.965686902588e-03 1.943261841281e-03 1.920775385784e-03 1.898280773460e-03 + 1.875833022051e-03 1.853488609337e-03 1.831305140546e-03 1.809341005235e-03 + 1.787655025459e-03 1.766306097099e-03 1.745352826260e-03 1.724853162710e-03 + 1.704864032341e-03 1.685440970664e-03 1.666637759365e-03 1.648506067923e-03 + 1.631095102303e-03 1.614451262697e-03 1.598617812261e-03 1.583634558740e-03 + 1.569537550816e-03 1.556358790976e-03 1.544125966566e-03 1.532862200671e-03 + 1.522585824315e-03 1.513310171416e-03 1.505043397778e-03 1.497788325320e-03 + 1.491542312579e-03 1.486297152434e-03 1.482038997816e-03 1.478748316066e-03 + 1.476399872422e-03 1.474962742997e-03 1.474400357424e-03 1.474670571219e-03 + 1.475725767736e-03 1.477512989424e-03 1.479974097954e-03 1.483045962591e-03 + 1.486660676018e-03 1.490745796644e-03 1.495224616191e-03 1.500016451141e-03 + 1.505036956309e-03 1.510198458459e-03 1.515410307388e-03 1.520579241276e-03 + 1.525609762264e-03 1.530404517056e-03 1.534864675863e-03 1.538890300991e-03 + 1.542380693864e-03 1.545234706066e-03 1.547350996145e-03 1.548628209460e-03 + 1.548965053456e-03 1.548260235761e-03 1.546412228103e-03 1.543318816091e-03 + 1.538876394723e-03 1.532978973774e-03 1.525516867851e-03 1.516375065197e-03 + 1.505431299339e-03 1.492553890171e-03 1.477599476967e-03 1.460410834509e-03 + 1.440815042342e-03 1.418622360790e-03 1.393626247355e-03 1.365605011751e-03 + 1.334325642654e-03 1.299550327874e-03 1.261046115558e-03 1.218598012950e-03 + 1.172025582071e-03 1.121202767714e-03 1.066080293069e-03 1.006709506381e-03 + 9.432660968839e-04 8.760716716887e-04 8.056108587196e-04 7.325414389434e-04 + 6.576950741039e-04 5.820665294703e-04 5.067899161052e-04 4.331013826033e-04 + 3.622888231049e-04 2.956304490814e-04 2.343253757956e-04 1.794205564900e-04 + 1.317393073308e-04 9.181716538704e-05 5.985080447147e-05 3.566514426544e-05 + 1.870263515509e-05 8.037061819656e-06 2.412224729222e-06 3.037233152557e-07 + 0.000000000000e+00 + Type L N + 0 0 1 + -2.482045090982e+00 -2.481575045574e+00 -2.480165470569e+00 -2.477818048460e+00 + -2.474535579529e+00 -2.470321976047e+00 -2.465182254178e+00 -2.459122523607e+00 + -2.452149974922e+00 -2.444272864788e+00 -2.435500498945e+00 -2.425843213088e+00 + -2.415312351675e+00 -2.403920244720e+00 -2.391680182642e+00 -2.378606389230e+00 + -2.364713992806e+00 -2.350018995660e+00 -2.334538241841e+00 -2.318289383390e+00 + -2.301290845115e+00 -2.283561787985e+00 -2.265122071263e+00 -2.245992213466e+00 + -2.226193352253e+00 -2.205747203365e+00 -2.184676018704e+00 -2.163002543674e+00 + -2.140749973900e+00 -2.117941911420e+00 -2.094602320479e+00 -2.070755483035e+00 + -2.046425954085e+00 -2.021638516931e+00 -1.996418138491e+00 -1.970789924772e+00 + -1.944779076620e+00 -1.918410845833e+00 -1.891710491771e+00 -1.864703238550e+00 + -1.837414232921e+00 -1.809868502935e+00 -1.782090917498e+00 -1.754106146882e+00 + -1.725938624312e+00 -1.697612508679e+00 -1.669151648489e+00 -1.640579547098e+00 + -1.611919329315e+00 -1.583193709441e+00 -1.554424960789e+00 -1.525634886761e+00 + -1.496844793516e+00 -1.468075464277e+00 -1.439347135320e+00 -1.410679473678e+00 + -1.382091556583e+00 -1.353601852675e+00 -1.325228204995e+00 -1.296987815763e+00 + -1.268897232963e+00 -1.240972338727e+00 -1.213228339514e+00 -1.185679758069e+00 + -1.158340427166e+00 -1.131223485087e+00 -1.104341372837e+00 -1.077705833050e+00 + -1.051327910559e+00 -1.025217954588e+00 -9.993856225250e-01 -9.738398852256e-01 + -9.485890338035e-01 -9.236406878455e-01 -8.990018049992e-01 -8.746786918694e-01 + -8.506770161618e-01 -8.270018200069e-01 -8.036575343959e-01 -7.806479946579e-01 + -7.579764569072e-01 -7.356456153854e-01 -7.136576206255e-01 -6.920140983600e-01 + -6.707161690980e-01 -6.497644682943e-01 -6.291591670323e-01 -6.088999931456e-01 + -5.889862526999e-01 -5.694168517617e-01 -5.501903183760e-01 -5.313048246828e-01 + -5.127582090964e-01 -4.945479984792e-01 -4.766714302409e-01 -4.591254742947e-01 + -4.419068548071e-01 -4.250120716796e-01 -4.084374217002e-01 -3.921790193109e-01 + -3.762328169342e-01 -3.605946248099e-01 -3.452601302927e-01 -3.302249165662e-01 + -3.154844807329e-01 -3.010342512403e-01 -2.868696046111e-01 -2.729858814433e-01 + -2.593784016562e-01 -2.460424789550e-01 -2.329734344963e-01 -2.201666097361e-01 + -2.076173784471e-01 -1.953211578962e-01 -1.832734191754e-01 -1.714696966828e-01 + -1.599055967545e-01 -1.485768054503e-01 -1.374790955011e-01 -1.266083324259e-01 + -1.159604798325e-01 -1.055316039164e-01 -9.531787717658e-02 -8.531558136803e-02 + -7.552110971417e-02 -6.593096840459e-02 -5.654177740486e-02 -4.735027060758e-02 + -3.835329535547e-02 -2.954781136879e-02 -2.093088911078e-02 -1.249970762590e-02 + -4.251551886934e-03 3.816190312426e-03 1.170603188209e-02 1.942039033924e-02 + 2.696159205295e-02 3.433187679143e-02 4.153340253348e-02 4.856825050611e-02 + 5.543843041030e-02 6.214588579785e-02 6.869249956235e-02 7.508009950864e-02 + 8.131046396552e-02 8.738532740806e-02 9.330638605648e-02 9.907530342034e-02 + 1.046937157578e-01 1.101632374215e-01 1.154854660636e-01 1.206619876754e-01 + 1.256943814368e-01 1.305842243549e-01 1.353330956700e-01 1.399425810130e-01 + 1.444142762956e-01 1.487497913206e-01 1.529507530990e-01 1.570188088635e-01 + 1.609556287699e-01 1.647629082796e-01 1.684423702188e-01 1.719957665107e-01 + 1.754248795804e-01 1.787315234329e-01 1.819175444064e-01 1.849848216051e-01 + 1.879352670179e-01 1.907708253286e-01 1.934934734280e-01 1.961052196373e-01 + 1.986081026534e-01 2.010041902302e-01 2.032955776076e-01 2.054843857050e-01 + 2.075727590925e-01 2.095628637587e-01 2.114568846895e-01 2.132570232773e-01 + 2.149654945789e-01 2.165845244386e-01 2.181163464977e-01 2.195631991075e-01 + 2.209273221665e-01 2.222109538984e-01 2.234163275928e-01 2.245456683249e-01 + 2.256011896732e-01 2.265850904541e-01 2.274995514892e-01 2.283467324239e-01 + 2.291287686120e-01 2.298477680839e-01 2.305058086103e-01 2.311049348788e-01 + 2.316471557937e-01 2.321344419128e-01 2.325687230312e-01 2.329518859239e-01 + 2.332857722547e-01 2.335721766603e-01 2.338128450165e-01 2.340094728926e-01 + 2.341637041983e-01 2.342771300269e-01 2.343512876976e-01 2.343876599986e-01 + 2.343876746309e-01 2.343527038517e-01 2.342840643176e-01 2.341830171224e-01 + 2.340507680278e-01 2.338884678816e-01 2.336972132177e-01 2.334780470324e-01 + 2.332319597286e-01 2.329598902218e-01 2.326627271977e-01 2.323413105132e-01 + 2.319964327307e-01 2.316288407763e-01 2.312392377093e-01 2.308282845948e-01 + 2.303966024653e-01 2.299447743617e-01 2.294733474413e-01 2.289828351401e-01 + 2.284737193796e-01 2.279464528036e-01 2.274014610356e-01 2.268391449436e-01 + 2.262598829013e-01 2.256640330350e-01 2.250519354446e-01 2.244239143880e-01 + 2.237802804204e-01 2.231213324770e-01 2.224473598904e-01 2.217586443352e-01 + 2.210554616904e-01 2.203380838132e-01 2.196067802164e-01 2.188618196441e-01 + 2.181034715407e-01 2.173320074064e-01 2.165477020379e-01 2.157508346485e-01 + 2.149416898674e-01 2.141205586134e-01 2.132877388452e-01 2.124435361850e-01 + 2.115882644171e-01 2.107222458626e-01 2.098458116306e-01 2.089593017498e-01 + 2.080630651817e-01 2.071574597201e-01 2.062428517807e-01 2.053196160848e-01 + 2.043881352429e-01 2.034487992432e-01 2.025020048514e-01 2.015481549280e-01 + 2.005876576690e-01 1.996209257790e-01 1.986483755813e-01 1.976704260747e-01 + 1.966874979431e-01 1.957000125268e-01 1.947083907623e-01 1.937130520990e-01 + 1.927144134003e-01 1.917128878376e-01 1.907088837837e-01 1.897028037141e-01 + 1.886950431228e-01 1.876859894608e-01 1.866760211028e-01 1.856655063495e-01 + 1.846548024717e-01 1.836442548021e-01 1.826341958799e-01 1.816249446540e-01 + 1.806168057486e-01 1.796100687966e-01 1.786050078436e-01 1.776018808259e-01 + 1.766009291261e-01 1.756023772073e-01 1.746064323292e-01 1.736132843462e-01 + 1.726231055887e-01 1.716360508281e-01 1.706522573248e-01 1.696718449590e-01 + 1.686949164427e-01 1.677215576113e-01 1.667518377934e-01 1.657858102547e-01 + 1.648235127145e-01 1.638649679309e-01 1.629101843510e-01 1.619591568219e-01 + 1.610118673583e-01 1.600682859619e-01 1.591283714880e-01 1.581920725539e-01 + 1.572593284833e-01 1.563300702825e-01 1.554042216414e-01 1.544816999540e-01 + 1.535624173536e-01 1.526462817550e-01 1.517331979001e-01 1.508230683987e-01 + 1.499157947616e-01 1.490112784176e-01 1.481094217111e-01 1.472101288739e-01 + 1.463133069667e-01 1.454188667842e-01 1.445267237216e-01 1.436367985950e-01 + 1.427490184141e-01 1.418633171028e-01 1.409796361628e-01 1.400979252795e-01 + 1.392181428654e-01 1.383402565401e-01 1.374642435433e-01 1.365900910811e-01 + 1.357177966027e-01 1.348473680075e-01 1.339788237822e-01 1.331121930672e-01 + 1.322475156536e-01 1.313848419106e-01 1.305242326454e-01 1.296657588954e-01 + 1.288095016572e-01 1.279555515515e-01 1.271040084291e-01 1.262549809187e-01 + 1.254085859213e-01 1.245649480536e-01 1.237241990439e-01 1.228864770852e-01 + 1.220519261490e-01 1.212206952640e-01 1.203929377643e-01 1.195688105119e-01 + 1.187484730975e-01 1.179320870251e-01 1.171198148840e-01 1.163118195149e-01 + 1.155082631729e-01 1.147093066933e-01 1.139151086648e-01 1.131258246146e-01 + 1.123416062101e-01 1.115626004808e-01 1.107889490663e-01 1.100207874929e-01 + 1.092582444838e-01 1.085014413050e-01 1.077504911533e-01 1.070054985858e-01 + 1.062665589972e-01 1.055337581451e-01 1.048071717277e-01 1.040868650141e-01 + 1.033728925300e-01 1.026652978003e-01 1.019641131492e-01 1.012693595590e-01 + 1.005810465875e-01 9.989917234468e-02 9.922372352869e-02 9.855467551939e-02 + 9.789199253004e-02 9.723562781511e-02 9.658552393304e-02 9.594161306219e-02 + 9.530381736785e-02 9.467204941827e-02 9.404621264680e-02 9.342620185774e-02 + 9.281190377258e-02 9.220319761372e-02 9.159995572199e-02 9.100204420476e-02 + 9.040932361060e-02 8.982164962702e-02 8.923887379717e-02 8.866084425155e-02 + 8.808740645081e-02 8.751840393541e-02 8.695367907826e-02 8.639307383603e-02 + 8.583643049534e-02 8.528359240971e-02 8.473440472345e-02 8.418871507860e-02 + 8.364637430141e-02 8.310723706459e-02 8.257116252218e-02 8.203801491369e-02 + 8.150766413444e-02 8.097998626949e-02 8.045486408832e-02 7.993218749807e-02 + 7.941185395312e-02 7.889376881917e-02 7.837784569021e-02 7.786400665701e-02 + 7.735218252609e-02 7.684231298837e-02 7.633434673698e-02 7.582824153397e-02 + 7.532396422600e-02 7.482149070938e-02 7.432080584492e-02 7.382190332363e-02 + 7.332478548422e-02 7.282946308400e-02 7.233595502458e-02 7.184428803444e-02 + 7.135449631029e-02 7.086662111972e-02 7.038071036735e-02 6.989681812752e-02 + 6.941500414608e-02 6.893533331433e-02 6.845787511844e-02 6.798270306730e-02 + 6.750989410234e-02 6.703952799271e-02 6.657168671922e-02 6.610645385066e-02 + 6.564391391592e-02 6.518415177562e-02 6.472725199654e-02 6.427329823257e-02 + 6.382237261541e-02 6.337455515854e-02 6.292992317754e-02 6.248855073011e-02 + 6.205050807862e-02 6.161586117822e-02 6.118467119321e-02 6.075699404408e-02 + 6.033287998787e-02 5.991237323373e-02 5.949551159588e-02 5.908232618562e-02 + 5.867284114390e-02 5.826707341583e-02 5.786503256816e-02 5.746672065053e-02 + 5.707213210109e-02 5.668125369684e-02 5.629406454872e-02 5.591053614136e-02 + 5.553063241703e-02 5.515430990315e-02 5.478151788253e-02 5.441219860513e-02 + 5.404628754010e-02 5.368371366652e-02 5.332439980101e-02 5.296826296042e-02 + 5.261521475725e-02 5.226516182572e-02 5.191800627587e-02 5.157364617311e-02 + 5.123197604056e-02 5.089288738120e-02 5.055626921703e-02 5.022200864208e-02 + 4.988999138625e-02 4.956010238683e-02 4.923222636445e-02 4.890624840040e-02 + 4.858205451206e-02 4.825953222321e-02 4.793857112627e-02 4.761906343324e-02 + 4.730090451237e-02 4.698399340773e-02 4.666823333877e-02 4.635353217719e-02 + 4.603980289863e-02 4.572696400663e-02 4.541493992673e-02 4.510366136851e-02 + 4.479306565364e-02 4.448309700838e-02 4.417370681875e-02 4.386485384718e-02 + 4.355650440959e-02 4.324863251176e-02 4.294121994458e-02 4.263425633753e-02 + 4.232773917023e-02 4.202167374203e-02 4.171607309986e-02 4.141095792483e-02 + 4.110635637812e-02 4.080230390710e-02 4.049884301289e-02 4.019602298032e-02 + 3.989389957220e-02 3.959253468915e-02 3.929199599723e-02 3.899235652507e-02 + 3.869369423287e-02 3.839609155556e-02 3.809963492252e-02 3.780441425648e-02 + 3.751052245430e-02 3.721805485232e-02 3.692710867928e-02 3.663778249950e-02 + 3.635017564953e-02 3.606438767102e-02 3.578051774298e-02 3.549866411634e-02 + 3.521892355383e-02 3.494139077806e-02 3.466615793079e-02 3.439331404622e-02 + 3.412294454091e-02 3.385513072317e-02 3.358994932446e-02 3.332747205505e-02 + 3.306776518651e-02 3.281088916299e-02 3.255689824337e-02 3.230584017620e-02 + 3.205775590890e-02 3.181267933294e-02 3.157063706606e-02 3.133164827289e-02 + 3.109572452458e-02 3.086286969840e-02 3.063307991758e-02 3.040634353182e-02 + 3.018264113840e-02 2.996194564386e-02 2.974422236575e-02 2.952942917404e-02 + 2.931751667125e-02 2.910842841043e-02 2.890210114979e-02 2.869846514259e-02 + 2.849744446083e-02 2.829895735084e-02 2.810291661916e-02 2.790923004642e-02 + 2.771780082720e-02 2.752852803350e-02 2.734130709943e-02 2.715603032450e-02 + 2.697258739298e-02 2.679086590661e-02 2.661075192784e-02 2.643213053071e-02 + 2.625488635676e-02 2.607890417275e-02 2.590406942761e-02 2.573026880550e-02 + 2.555739077224e-02 2.538532611231e-02 2.521396845357e-02 2.504321477699e-02 + 2.487296590891e-02 2.470312699312e-02 2.453360794040e-02 2.436432385330e-02 + 2.419519542382e-02 2.402614930213e-02 2.385711843425e-02 2.368804236721e-02 + 2.351886751988e-02 2.334954741825e-02 2.318004289399e-02 2.301032224513e-02 + 2.284036135821e-02 2.267014379120e-02 2.249966081685e-02 2.232891142617e-02 + 2.215790229212e-02 2.198664769369e-02 2.181516940079e-02 2.164349652049e-02 + 2.147166530554e-02 2.129971892603e-02 2.112770720548e-02 2.095568632269e-02 + 2.078371848085e-02 2.061187154572e-02 2.044021865465e-02 2.026883779851e-02 + 2.009781137868e-02 1.992722574135e-02 1.975717069155e-02 1.958773898944e-02 + 1.941902583141e-02 1.925112831861e-02 1.908414491583e-02 1.891817490323e-02 + 1.875331782404e-02 1.858967293085e-02 1.842733863338e-02 1.826641195074e-02 + 1.810698797073e-02 1.794915931917e-02 1.779301564194e-02 1.763864310237e-02 + 1.748612389659e-02 1.733553578942e-02 1.718695167304e-02 1.704043915097e-02 + 1.689606014922e-02 1.675387055697e-02 1.661391989838e-02 1.647625103740e-02 + 1.634089991718e-02 1.620789533523e-02 1.607725875590e-02 1.594900416081e-02 + 1.582313793839e-02 1.569965881293e-02 1.557855781368e-02 1.545981828421e-02 + 1.534341593208e-02 1.522931891857e-02 1.511748798818e-02 1.500787663728e-02 + 1.490043132113e-02 1.479509169826e-02 1.469179091120e-02 1.459045590195e-02 + 1.449100776098e-02 1.439336210776e-02 1.429742950121e-02 1.420311587785e-02 + 1.411032301568e-02 1.401894902135e-02 1.392888883825e-02 1.384003477310e-02 + 1.375227703819e-02 1.366550430676e-02 1.357960427870e-02 1.349446425360e-02 + 1.340997170838e-02 1.332601487660e-02 1.324248332634e-02 1.315926853392e-02 + 1.307626445035e-02 1.299336805771e-02 1.291047991254e-02 1.282750467341e-02 + 1.274435160999e-02 1.266093509083e-02 1.257717504747e-02 1.249299741209e-02 + 1.240833452676e-02 1.232312552166e-02 1.223731666053e-02 1.215086165114e-02 + 1.206372191923e-02 1.197586684417e-02 1.188727395503e-02 1.179792908573e-02 + 1.170782648826e-02 1.161696890320e-02 1.152536758675e-02 1.143304229394e-02 + 1.134002121778e-02 1.124634088427e-02 1.115204600356e-02 1.105718927751e-02 + 1.096183116447e-02 1.086603960190e-02 1.076988968798e-02 1.067346332336e-02 + 1.057684881457e-02 1.048014044056e-02 1.038343798427e-02 1.028684623118e-02 + 1.019047443688e-02 1.009443576615e-02 9.998846705724e-03 9.903826453530e-03 + 9.809496287006e-03 9.715978913303e-03 9.623397804321e-03 9.531876519539e-03 + 9.441538019746e-03 9.352503974778e-03 9.264894068459e-03 9.178825303950e-03 + 9.094411312729e-03 9.011761670447e-03 8.930981222860e-03 8.852169425054e-03 + 8.775419697083e-03 8.700818799153e-03 8.628446229346e-03 8.558373646848e-03 + 8.490664323513e-03 8.425372626521e-03 8.362543534709e-03 8.302212191092e-03 + 8.244403493880e-03 8.189131728173e-03 8.136400240352e-03 8.086201156981e-03 + 8.038515149877e-03 7.993311248794e-03 7.950546702980e-03 7.910166892631e-03 + 7.872105291106e-03 7.836283478488e-03 7.802611206900e-03 7.770986517756e-03 + 7.741295910874e-03 7.713414565203e-03 7.687206610635e-03 7.662525450201e-03 + 7.639214131691e-03 7.617105767535e-03 7.596024001566e-03 7.575783521055e-03 + 7.556190612210e-03 7.537043757089e-03 7.518134269667e-03 7.499246968516e-03 + 7.480160883308e-03 7.460649991956e-03 7.440483984796e-03 7.419429051600e-03 + 7.397248686374e-03 7.373704503755e-03 7.348557059180e-03 7.321566662708e-03 + 7.292494173217e-03 7.261101755343e-03 7.227153575754e-03 7.190416407734e-03 + 7.150660103394e-03 7.107657880901e-03 7.061186359963e-03 7.011025262750e-03 + 6.956956680516e-03 6.898763789795e-03 6.836228889030e-03 6.769130620249e-03 + 6.697240246048e-03 6.620316875679e-03 6.538101582408e-03 6.450310435006e-03 + 6.356626585950e-03 6.256691722479e-03 6.150097395357e-03 6.036376989510e-03 + 5.914999378528e-03 5.785365589660e-03 5.646810065247e-03 5.498608297878e-03 + 5.339992688839e-03 5.170178377035e-03 4.988400454703e-03 4.793963383463e-03 + 4.586302526504e-03 4.365056527676e-03 4.130147843723e-03 3.881867166025e-03 + 3.620955894071e-03 3.348679427361e-03 3.066883035448e-03 2.778021663412e-03 + 2.485155425306e-03 2.191903869409e-03 1.902354418680e-03 1.620923637512e-03 + 1.352173964869e-03 1.100592970927e-03 8.703466194766e-04 6.650219625807e-04 + 4.873776537196e-04 3.391221866623e-04 2.207395111312e-04 1.313794780193e-04 + 6.882647551390e-05 2.955391019338e-05 8.865353422468e-06 1.115867959482e-06 + 0.000000000000e+00 + Type L N + 0 1 0 + 0.000000000000e+00 -2.619148756396e-02 -5.236486301972e-02 -7.850203930165e-02 + -1.045849793771e-01 -1.305957211313e-01 -1.565164020954e-01 -1.823292839654e-01 + -2.080167768610e-01 -2.335614632739e-01 -2.589461216556e-01 -2.841537495958e-01 + -3.091675865449e-01 -3.339711360326e-01 -3.585481873377e-01 -3.828828365671e-01 + -4.069595070990e-01 -4.307629693521e-01 -4.542783598414e-01 -4.774911994832e-01 + -5.003874111144e-01 -5.229533361944e-01 -5.451757506572e-01 -5.670418798862e-01 + -5.885394127849e-01 -6.096565149199e-01 -6.303818407138e-01 -6.507045446704e-01 + -6.706142916133e-01 -6.901012659255e-01 -7.091561797781e-01 -7.277702803377e-01 + -7.459353559473e-01 -7.636437412768e-01 -7.808883214399e-01 -7.976625350814e-01 + -8.139603764356e-01 -8.297763963643e-01 -8.451057023818e-01 -8.599439576786e-01 + -8.742873791567e-01 -8.881327344938e-01 -9.014773382523e-01 -9.143190470556e-01 + -9.266562538533e-01 -9.384878812996e-01 -9.498133742720e-01 -9.606326915587e-01 + -9.709462967451e-01 -9.807551483301e-01 -9.900606891086e-01 -9.988648348517e-01 + -1.007169962324e+00 -1.014978896675e+00 -1.022294898241e+00 -1.029121648800e+00 + -1.035463237323e+00 -1.041324145256e+00 -1.046709231379e+00 -1.051623716287e+00 + -1.056073166534e+00 -1.060063478479e+00 -1.063600861885e+00 -1.066691823310e+00 + -1.069343149337e+00 -1.071561889677e+00 -1.073355340199e+00 -1.074731025928e+00 + -1.075696684036e+00 -1.076260246899e+00 -1.076429825220e+00 -1.076213691295e+00 + -1.075620262432e+00 -1.074658084579e+00 -1.073335816178e+00 -1.071662212300e+00 + -1.069646109077e+00 -1.067296408467e+00 -1.064622063390e+00 -1.061632063245e+00 + -1.058335419858e+00 -1.054741153859e+00 -1.050858281535e+00 -1.046695802159e+00 + -1.042262685832e+00 -1.037567861841e+00 -1.032620207550e+00 -1.027428537849e+00 + -1.022001595150e+00 -1.016348039963e+00 -1.010476442037e+00 -1.004395272089e+00 + -9.981128941084e-01 -9.916375582498e-01 -9.849773943052e-01 -9.781404057575e-01 + -9.711344644075e-01 -9.639673055695e-01 -9.566465238271e-01 -9.491795693387e-01 + -9.415737446814e-01 -9.338362022213e-01 -9.259739419936e-01 -9.179938100794e-01 + -9.099024974594e-01 -9.017065393285e-01 -8.934123148501e-01 -8.850260473314e-01 + -8.765538047966e-01 -8.680015009377e-01 -8.593748964187e-01 -8.506796005108e-01 + -8.419210730338e-01 -8.331046265803e-01 -8.242354289977e-01 -8.153185061029e-01 + -8.063587446057e-01 -7.973608952151e-01 -7.883295759049e-01 -7.792692753130e-01 + -7.701843562510e-01 -7.610790593002e-01 -7.519575064699e-01 -7.428237048973e-01 + -7.336815505648e-01 -7.245348320142e-01 -7.153872340388e-01 -7.062423413307e-01 + -6.971036420686e-01 -6.879745314249e-01 -6.788583149780e-01 -6.697582120136e-01 + -6.606773587007e-01 -6.516188111292e-01 -6.425855481983e-01 -6.335804743433e-01 + -6.246064220940e-01 -6.156661544547e-01 -6.067623670998e-01 -5.978976903813e-01 + -5.890746911408e-01 -5.802958743272e-01 -5.715636844155e-01 -5.628805066289e-01 + -5.542486679631e-01 -5.456704380175e-01 -5.371480296347e-01 -5.286835993539e-01 + -5.202792476838e-01 -5.119370192015e-01 -5.036589024851e-01 -4.954468298887e-01 + -4.873026771689e-01 -4.792282629741e-01 -4.712253482055e-01 -4.632956352638e-01 + -4.554407671916e-01 -4.476623267261e-01 -4.399618352735e-01 -4.323407518198e-01 + -4.248004717903e-01 -4.173423258741e-01 -4.099675788240e-01 -4.026774282498e-01 + -3.954730034156e-01 -3.883553640567e-01 -3.813254992302e-01 -3.743843262106e-01 + -3.675326894452e-01 -3.607713595818e-01 -3.541010325795e-01 -3.475223289158e-01 + -3.410357929000e-01 -3.346418921031e-01 -3.283410169145e-01 -3.221334802342e-01 + -3.160195173078e-01 -3.099992857124e-01 -3.040728654994e-01 -2.982402594992e-01 + -2.925013937933e-01 -2.868561183560e-01 -2.813042078699e-01 -2.758453627149e-01 + -2.704792101334e-01 -2.652053055693e-01 -2.600231341813e-01 -2.549321125271e-01 + -2.499315904153e-01 -2.450208529216e-01 -2.401991225640e-01 -2.354655616297e-01 + -2.308192746499e-01 -2.262593110115e-01 -2.217846677005e-01 -2.173942921658e-01 + -2.130870852947e-01 -2.088619044905e-01 -2.047175668396e-01 -2.006528523587e-01 + -1.966665073086e-01 -1.927572475643e-01 -1.889237620269e-01 -1.851647160666e-01 + -1.814787549827e-01 -1.778645074676e-01 -1.743205890629e-01 -1.708456055934e-01 + -1.674381565660e-01 -1.640968385230e-01 -1.608202483334e-01 -1.576069864139e-01 + -1.544556598647e-01 -1.513648855108e-01 -1.483332928356e-01 -1.453595267988e-01 + -1.424422505258e-01 -1.395801478620e-01 -1.367719257811e-01 -1.340163166408e-01 + -1.313120802780e-01 -1.286580059372e-01 -1.260529140265e-01 -1.234956576962e-01 + -1.209851242359e-01 -1.185202362876e-01 -1.160999528715e-01 -1.137232702242e-01 + -1.113892224481e-01 -1.090968819726e-01 -1.068453598284e-01 -1.046338057376e-01 + -1.024614080212e-01 -1.003273933296e-01 -9.823102619963e-02 -9.617160844355e-02 + -9.414847837716e-02 -9.216100989289e-02 -9.020861138608e-02 -8.829072454252e-02 + -8.640682299614e-02 -8.455641086620e-02 -8.273902118386e-02 -8.095421421852e-02 + -7.920157571451e-02 -7.748071504934e-02 -7.579126332469e-02 -7.413287140170e-02 + -7.250520789230e-02 -7.090795711826e-02 -6.934081704988e-02 -6.780349723588e-02 + -6.629571673653e-02 -6.481720207113e-02 -6.336768519157e-02 -6.194690149273e-02 + -6.055458787067e-02 -5.919048083885e-02 -5.785431471242e-02 -5.654581987003e-02 + -5.526472110210e-02 -5.401073605396e-02 -5.278357377167e-02 -5.158293335769e-02 + -5.040850274282e-02 -4.925995758026e-02 -4.813696026688e-02 -4.703915909588e-02 + -4.596618754460e-02 -4.491766369995e-02 -4.389318982382e-02 -4.289235205930e-02 + -4.191472027834e-02 -4.095984807036e-02 -4.002727287065e-02 -3.911651622664e-02 + -3.822708419924e-02 -3.735846789596e-02 -3.651014413154e-02 -3.568157621131e-02 + -3.487221483170e-02 -3.408149909199e-02 -3.330885761033e-02 -3.255370973701e-02 + -3.181546685714e-02 -3.109353377455e-02 -3.038731016832e-02 -2.969619211295e-02 + -2.901957365295e-02 -2.835684842224e-02 -2.770741129870e-02 -2.707066008394e-02 + -2.644599719833e-02 -2.583283138132e-02 -2.523057938696e-02 -2.463866766481e-02 + -2.405653401635e-02 -2.348362921731e-02 -2.291941859653e-02 -2.236338356226e-02 + -2.181502306709e-02 -2.127385500310e-02 -2.073941751929e-02 -2.021127025380e-02 + -1.968899547377e-02 -1.917219911649e-02 -1.866051172597e-02 -1.815358927943e-02 + -1.765111389923e-02 -1.715279444616e-02 -1.665836699064e-02 -1.616759515933e-02 + -1.568027035507e-02 -1.519621184885e-02 -1.471526674340e-02 -1.423730980846e-02 + -1.376224318856e-02 -1.328999598499e-02 -1.282052371411e-02 -1.235380764503e-02 + -1.188985402008e-02 -1.142869316246e-02 -1.097037847581e-02 -1.051498534107e-02 + -1.006260991666e-02 -9.613367848339e-03 -9.167392895743e-03 -8.724835483000e-03 + -8.285861181084e-03 -7.850649130099e-03 -7.419390409886e-03 -6.992286367608e-03 + -6.569546911217e-03 -6.151388777816e-03 -5.738033786074e-03 -5.329707081897e-03 + -4.926635386553e-03 -4.529045256425e-03 -4.137161363471e-03 -3.751204805299e-03 + -3.371391453621e-03 -2.997930349555e-03 -2.631022154026e-03 -2.270857661113e-03 + -1.917616381888e-03 -1.571465205837e-03 -1.232557146521e-03 -9.010301776598e-04 + -5.770061652889e-04 -2.605899011067e-04 4.813175843625e-05 3.490906433619e-04 + 6.422379083571e-04 9.275445552270e-04 1.205001837536e-03 1.474621546020e-03 + 1.736436173996e-03 1.990498962683e-03 2.236883826949e-03 2.475685162717e-03 + 2.707017537841e-03 2.931015268937e-03 3.147831887239e-03 3.357639497146e-03 + 3.560628031719e-03 3.757004409902e-03 3.946991600762e-03 4.130827600566e-03 + 4.308764328889e-03 4.481066450456e-03 4.648010129698e-03 4.809881725434e-03 + 4.966976433299e-03 5.119596883860e-03 5.268051704510e-03 5.412654053433e-03 + 5.553720134020e-03 5.691567698189e-03 5.826514547092e-03 5.958877037639e-03 + 6.088968603225e-03 6.217098296899e-03 6.343569365063e-03 6.468677859564e-03 + 6.592711295807e-03 6.715947364200e-03 6.838652701932e-03 6.961081731675e-03 + 7.083475573440e-03 7.206061035334e-03 7.329049688515e-03 7.452637031143e-03 + 7.577001745578e-03 7.702305052573e-03 7.828690165593e-03 7.956281847848e-03 + 8.085186074022e-03 8.215489798083e-03 8.347260827936e-03 8.480547807099e-03 + 8.615380302952e-03 8.751769000514e-03 8.889706000109e-03 9.029165216702e-03 + 9.170102878110e-03 9.312458118742e-03 9.456153665011e-03 9.601096608027e-03 + 9.747179258719e-03 9.894280080088e-03 1.004226469085e-02 1.019098693440e-02 + 1.034029000656e-02 1.049000763547e-02 1.063996530646e-02 1.078998152469e-02 + 1.093986910817e-02 1.108943650339e-02 1.123848911607e-02 1.138683064909e-02 + 1.153426443998e-02 1.168059479010e-02 1.182562827797e-02 1.196917504910e-02 + 1.211105007508e-02 1.225107437457e-02 1.238907618943e-02 1.252489210927e-02 + 1.265836813807e-02 1.278936069695e-02 1.291773755751e-02 1.304337870048e-02 + 1.316617709511e-02 1.328603939499e-02 1.340288654648e-02 1.351665430671e-02 + 1.362729366825e-02 1.373477118843e-02 1.383906922175e-02 1.394018605422e-02 + 1.403813593933e-02 1.413294903569e-02 1.422467124705e-02 1.431336396600e-02 + 1.439910372306e-02 1.448198174369e-02 1.456210341591e-02 1.463958767211e-02 + 1.471456628879e-02 1.478718310873e-02 1.485759319026e-02 1.492596188893e-02 + 1.499246387717e-02 1.505728210784e-02 1.512060672793e-02 1.518263394902e-02 + 1.524356488117e-02 1.530360433731e-02 1.536295961518e-02 1.542183926410e-02 + 1.548045184398e-02 1.553900468373e-02 1.559770264664e-02 1.565674690985e-02 + 1.571633376528e-02 1.577665344884e-02 1.583788900517e-02 1.590021519414e-02 + 1.596379744599e-02 1.602879087085e-02 1.609533932872e-02 1.616357456515e-02 + 1.623361541785e-02 1.630556709873e-02 1.637952055562e-02 1.645555191742e-02 + 1.653372202582e-02 1.661407605643e-02 1.669664323138e-02 1.678143662521e-02 + 1.686845306507e-02 1.695767312578e-02 1.704906121987e-02 1.714256578196e-02 + 1.723811954648e-02 1.733563991699e-02 1.743502942507e-02 1.753617627600e-02 + 1.763895497808e-02 1.774322705193e-02 1.784884181561e-02 1.795563724100e-02 + 1.806344087646e-02 1.817207083037e-02 1.828133680986e-02 1.839104120867e-02 + 1.850098023783e-02 1.861094509253e-02 1.872072314848e-02 1.883009918077e-02 + 1.893885659806e-02 1.904677868516e-02 1.915364984645e-02 1.925925684325e-02 + 1.936339001770e-02 1.946584449621e-02 1.956642136531e-02 1.966492881331e-02 + 1.976118323090e-02 1.985501026443e-02 1.994624581574e-02 2.003473698266e-02 + 2.012034293477e-02 2.020293571936e-02 2.028240099279e-02 2.035863867308e-02 + 2.043156350995e-02 2.050110556888e-02 2.056721062645e-02 2.062984047468e-02 + 2.068897313245e-02 2.074460296295e-02 2.079674069621e-02 2.084541335683e-02 + 2.089066409712e-02 2.093255193665e-02 2.097115140973e-02 2.100655212284e-02 + 2.103885822446e-02 2.106818779056e-02 2.109467212911e-02 2.111845500767e-02 + 2.113969180865e-02 2.115854861693e-02 2.117520124532e-02 2.118983420338e-02 + 2.120263961558e-02 2.121381609520e-02 2.122356758033e-02 2.123210213890e-02 + 2.123963074957e-02 2.124636606559e-02 2.125252116890e-02 2.125830832160e-02 + 2.126393772218e-02 2.126961627368e-02 2.127554637107e-02 2.128192471477e-02 + 2.128894115740e-02 2.129677759051e-02 2.130560687763e-02 2.131559184016e-02 + 2.132688430185e-02 2.133962419759e-02 2.135393875177e-02 2.136994173102e-02 + 2.138773277581e-02 2.140739681481e-02 2.142900356564e-02 2.145260712483e-02 + 2.147824564965e-02 2.150594113364e-02 2.153569927730e-02 2.156750945480e-02 + 2.160134477700e-02 2.163716225049e-02 2.167490303187e-02 2.171449277595e-02 + 2.175584207575e-02 2.179884699208e-02 2.184338966957e-02 2.188933903561e-02 + 2.193655157843e-02 2.198487219960e-02 2.203413513628e-02 2.208416494774e-02 + 2.213477756065e-02 2.218578136687e-02 2.223697836761e-02 2.228816535713e-02 + 2.233913513923e-02 2.238967776935e-02 2.243958181514e-02 2.248863562797e-02 + 2.253662861809e-02 2.258335252583e-02 2.262860268145e-02 2.267217924618e-02 + 2.271388842704e-02 2.275354365840e-02 2.279096674309e-02 2.282598894641e-02 + 2.285845203635e-02 2.288820926393e-02 2.291512627762e-02 2.293908196640e-02 + 2.295996922622e-02 2.297769564529e-02 2.299218410388e-02 2.300337328484e-02 + 2.301121809170e-02 2.301568997160e-02 2.301677714081e-02 2.301448471143e-02 + 2.300883471803e-02 2.299986604390e-02 2.298763424715e-02 2.297221128710e-02 + 2.295368515261e-02 2.293215939400e-02 2.290775256113e-02 2.288059755062e-02 + 2.285084086581e-02 2.281864179350e-02 2.278417150202e-02 2.274761206582e-02 + 2.270915542192e-02 2.266900226427e-02 2.262736088227e-02 2.258444595016e-02 + 2.254047727415e-02 2.249567850465e-02 2.245027582107e-02 2.240449659678e-02 + 2.235856805212e-02 2.231271590338e-02 2.226716301569e-02 2.222212806786e-02 + 2.217782423709e-02 2.213445791144e-02 2.209222743784e-02 2.205132191314e-02 + 2.201192002567e-02 2.197418895432e-02 2.193828333201e-02 2.190434427997e-02 + 2.187249851887e-02 2.184285756262e-02 2.181551699982e-02 2.179055586779e-02 + 2.176803612321e-02 2.174800221325e-02 2.173048074999e-02 2.171548029103e-02 + 2.170299122778e-02 2.169298578312e-02 2.168541811879e-02 2.168022455268e-02 + 2.167732388541e-02 2.167661783493e-02 2.167799157718e-02 2.168131439039e-02 + 2.168644039986e-02 2.169320941939e-02 2.170144788518e-02 2.171096987713e-02 + 2.172157822222e-02 2.173306567395e-02 2.174521616147e-02 2.175780610142e-02 + 2.177060576518e-02 2.178338069396e-02 2.179589315354e-02 2.180790362049e-02 + 2.181917229125e-02 2.182946060530e-02 2.183853277351e-02 2.184615730267e-02 + 2.185210850718e-02 2.185616799866e-02 2.185812614465e-02 2.185778348735e-02 + 2.185495211363e-02 2.184945696779e-02 2.184113709866e-02 2.182984683306e-02 + 2.181545686793e-02 2.179785527376e-02 2.177694840253e-02 2.175266169377e-02 + 2.172494037273e-02 2.169375003548e-02 2.165907711615e-02 2.162092923210e-02 + 2.157933540362e-02 2.153434614529e-02 2.148603342686e-02 2.143449050224e-02 + 2.137983160587e-02 2.132219151644e-02 2.126172498881e-02 2.119860605552e-02 + 2.113302720010e-02 2.106519840518e-02 2.099534607909e-02 2.092371186512e-02 + 2.085055133881e-02 2.077613259864e-02 2.070073475676e-02 2.062464633657e-02 + 2.054816358470e-02 2.047158870559e-02 2.039522802713e-02 2.031939010651e-02 + 2.024438378571e-02 2.017051620651e-02 2.009809079520e-02 2.002740522733e-02 + 1.995874938339e-02 1.989240330600e-02 1.982863516971e-02 1.976769927438e-02 + 1.970983407307e-02 1.965526024551e-02 1.960417882772e-02 1.955676940876e-02 + 1.951318840466e-02 1.947356741995e-02 1.943801170636e-02 1.940659872817e-02 + 1.937937684318e-02 1.935636410766e-02 1.933754721316e-02 1.932288056267e-02 + 1.931228549258e-02 1.930564964660e-02 1.930282650696e-02 1.930363508734e-02 + 1.930785979149e-02 1.931525044047e-02 1.932552247072e-02 1.933835730439e-02 + 1.935340289245e-02 1.937027443016e-02 1.938855524387e-02 1.940779784701e-02 + 1.942752516217e-02 1.944723190571e-02 1.946638612966e-02 1.948443091549e-02 + 1.950078621243e-02 1.951485081234e-02 1.952600445117e-02 1.953361002533e-02 + 1.953701590851e-02 1.953555835114e-02 1.952856393958e-02 1.951535208590e-02 + 1.949523750933e-02 1.946753265869e-02 1.943155000790e-02 1.938660413540e-02 + 1.933201347007e-02 1.926710155243e-02 1.919119761851e-02 1.910363626729e-02 + 1.900375592273e-02 1.889089575277e-02 1.876439066726e-02 1.862356399556e-02 + 1.846771745619e-02 1.829611809251e-02 1.810798198195e-02 1.790245475170e-02 + 1.767858927235e-02 1.743532136835e-02 1.717144498381e-02 1.688558896444e-02 + 1.657619842677e-02 1.624152452384e-02 1.587962718961e-02 1.548839602965e-02 + 1.506559477392e-02 1.460893445471e-02 1.411617955952e-02 1.358528970263e-02 + 1.301459678658e-02 1.240301420140e-02 1.175027046629e-02 1.105715512477e-02 + 1.032576006732e-02 9.559695308356e-03 8.764255204101e-03 7.946509802481e-03 + 7.115297042524e-03 6.281095287844e-03 5.455762355303e-03 4.652136625604e-03 + 3.883507462241e-03 3.162975109536e-03 2.502733260001e-03 1.913319137545e-03 + 1.402884747950e-03 9.765475531969e-04 6.358782201147e-04 3.785767743619e-04 + 1.983765869872e-04 8.519893699498e-05 2.556086363756e-05 3.217573100688e-06 + 0.000000000000e+00 \ No newline at end of file diff --git a/ABACUS.develop/examples/H2O-deepks/INPUT b/ABACUS.develop/examples/H2O-deepks/INPUT new file mode 100644 index 0000000000..4b334117b0 --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks/INPUT @@ -0,0 +1,29 @@ +INPUT_PARAMETERS +#Parameters (1.General) +suffix abacus +calculation scf +ntype 2 +nbands 6 +symmetry 0 + +#Parameters (2.Iteration) +ecutwfc 50 +dr2 1e-8 +niter 50 + +#Parameters (3.Basis) +basis_type pw +gamma_only 1 + +#Parameters (4.Smearing) +smearing gaussian +sigma 0.02 + +#Parameters (5.Mixing) +mixing_type pulay +mixing_beta 0.4 + +#Parameters (6.File) +out_band 0 +out_descriptor 1 +lmax_descriptor 2 diff --git a/ABACUS.develop/examples/H2O-deepks/INPUTs b/ABACUS.develop/examples/H2O-deepks/INPUTs new file mode 100644 index 0000000000..593f6e0ea7 --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks/INPUTs @@ -0,0 +1,8 @@ +INPUT_ORBITAL_INFORMATION + +1 // smooth or not +0.1 // sigma +50 // energy cutoff for spherical bessel functions(Ry) +6 // cutoff of wavefunctions(a.u.) +1.0e-12 // tolerence + diff --git a/ABACUS.develop/examples/H2O-deepks/KPT b/ABACUS.develop/examples/H2O-deepks/KPT new file mode 100644 index 0000000000..c289c0158a --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks/KPT @@ -0,0 +1,4 @@ +K_POINTS +0 +Gamma +1 1 1 0 0 0 diff --git a/ABACUS.develop/examples/H2O-deepks/O_ONCV_PBE-1.0.upf b/ABACUS.develop/examples/H2O-deepks/O_ONCV_PBE-1.0.upf new file mode 100644 index 0000000000..7e7db6d66f --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks/O_ONCV_PBE-1.0.upf @@ -0,0 +1,1224 @@ + + + + This pseudopotential file has been produced using the code + ONCVPSP (Optimized Norm-Conservinng Vanderbilt PSeudopotential) + scalar-relativistic version 2.1.1, 03/26/2014 by D. R. Hamann + The code is available through a link at URL www.mat-simresearch.com. + Documentation with the package provides a full discription of the + input data below. + + + While it is not required under the terms of the GNU GPL, it is + suggested that you cite D. R. Hamann, Phys. Rev. B 88, 085117 (2013) + in any publication using these pseudopotentials. + + + Copyright 2015 The Regents of the University of California + + This work is licensed under the Creative Commons Attribution-ShareAlike + 4.0 International License. To view a copy of this license, visit + http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to + Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + + This pseudopotential is part of the Schlipf-Gygi norm-conserving + pseudopotential library. Its construction parameters were tuned to + reproduce materials of a training set with very high accuracy and + should be suitable as a general purpose pseudopotential to treat a + variety of different compounds. For details of the construction and + testing of the pseudopotential please refer to: + + [insert reference to paper here] + + We kindly ask that you include this reference in all publications + associated to this pseudopotential. + + + +# ATOM AND REFERENCE CONFIGURATION +# atsym z nc nv iexc psfile + O 8.00 1 2 4 upf +# +# n l f energy (Ha) + 1 0 2.00 + 2 0 2.00 + 2 1 4.00 +# +# PSEUDOPOTENTIAL AND OPTIMIZATION +# lmax + 1 +# +# l, rc, ep, ncon, nbas, qcut + 0 1.29195 -0.88057 5 8 8.98916 + 1 1.47310 -0.33187 5 8 9.14990 +# +# LOCAL POTENTIAL +# lloc, lpopt, rc(5), dvloc0 + 4 5 0.90330 0.00000 +# +# VANDERBILT-KLEINMAN-BYLANDER PROJECTORs +# l, nproj, debl + 0 2 1.51851 + 1 2 1.53631 +# +# MODEL CORE CHARGE +# icmod, fcfact + 0 0.00000 +# +# LOG DERIVATIVE ANALYSIS +# epsh1, epsh2, depsh + -5.00 3.00 0.02 +# +# OUTPUT GRID +# rlmax, drl + 6.00 0.01 +# +# TEST CONFIGURATIONS +# ncnf + 0 +# nvcnf +# n l f + + + + + + + + + 0.0000 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600 0.0700 + 0.0800 0.0900 0.1000 0.1100 0.1200 0.1300 0.1400 0.1500 + 0.1600 0.1700 0.1800 0.1900 0.2000 0.2100 0.2200 0.2300 + 0.2400 0.2500 0.2600 0.2700 0.2800 0.2900 0.3000 0.3100 + 0.3200 0.3300 0.3400 0.3500 0.3600 0.3700 0.3800 0.3900 + 0.4000 0.4100 0.4200 0.4300 0.4400 0.4500 0.4600 0.4700 + 0.4800 0.4900 0.5000 0.5100 0.5200 0.5300 0.5400 0.5500 + 0.5600 0.5700 0.5800 0.5900 0.6000 0.6100 0.6200 0.6300 + 0.6400 0.6500 0.6600 0.6700 0.6800 0.6900 0.7000 0.7100 + 0.7200 0.7300 0.7400 0.7500 0.7600 0.7700 0.7800 0.7900 + 0.8000 0.8100 0.8200 0.8300 0.8400 0.8500 0.8600 0.8700 + 0.8800 0.8900 0.9000 0.9100 0.9200 0.9300 0.9400 0.9500 + 0.9600 0.9700 0.9800 0.9900 1.0000 1.0100 1.0200 1.0300 + 1.0400 1.0500 1.0600 1.0700 1.0800 1.0900 1.1000 1.1100 + 1.1200 1.1300 1.1400 1.1500 1.1600 1.1700 1.1800 1.1900 + 1.2000 1.2100 1.2200 1.2300 1.2400 1.2500 1.2600 1.2700 + 1.2800 1.2900 1.3000 1.3100 1.3200 1.3300 1.3400 1.3500 + 1.3600 1.3700 1.3800 1.3900 1.4000 1.4100 1.4200 1.4300 + 1.4400 1.4500 1.4600 1.4700 1.4800 1.4900 1.5000 1.5100 + 1.5200 1.5300 1.5400 1.5500 1.5600 1.5700 1.5800 1.5900 + 1.6000 1.6100 1.6200 1.6300 1.6400 1.6500 1.6600 1.6700 + 1.6800 1.6900 1.7000 1.7100 1.7200 1.7300 1.7400 1.7500 + 1.7600 1.7700 1.7800 1.7900 1.8000 1.8100 1.8200 1.8300 + 1.8400 1.8500 1.8600 1.8700 1.8800 1.8900 1.9000 1.9100 + 1.9200 1.9300 1.9400 1.9500 1.9600 1.9700 1.9800 1.9900 + 2.0000 2.0100 2.0200 2.0300 2.0400 2.0500 2.0600 2.0700 + 2.0800 2.0900 2.1000 2.1100 2.1200 2.1300 2.1400 2.1500 + 2.1600 2.1700 2.1800 2.1900 2.2000 2.2100 2.2200 2.2300 + 2.2400 2.2500 2.2600 2.2700 2.2800 2.2900 2.3000 2.3100 + 2.3200 2.3300 2.3400 2.3500 2.3600 2.3700 2.3800 2.3900 + 2.4000 2.4100 2.4200 2.4300 2.4400 2.4500 2.4600 2.4700 + 2.4800 2.4900 2.5000 2.5100 2.5200 2.5300 2.5400 2.5500 + 2.5600 2.5700 2.5800 2.5900 2.6000 2.6100 2.6200 2.6300 + 2.6400 2.6500 2.6600 2.6700 2.6800 2.6900 2.7000 2.7100 + 2.7200 2.7300 2.7400 2.7500 2.7600 2.7700 2.7800 2.7900 + 2.8000 2.8100 2.8200 2.8300 2.8400 2.8500 2.8600 2.8700 + 2.8800 2.8900 2.9000 2.9100 2.9200 2.9300 2.9400 2.9500 + 2.9600 2.9700 2.9800 2.9900 3.0000 3.0100 3.0200 3.0300 + 3.0400 3.0500 3.0600 3.0700 3.0800 3.0900 3.1000 3.1100 + 3.1200 3.1300 3.1400 3.1500 3.1600 3.1700 3.1800 3.1900 + 3.2000 3.2100 3.2200 3.2300 3.2400 3.2500 3.2600 3.2700 + 3.2800 3.2900 3.3000 3.3100 3.3200 3.3300 3.3400 3.3500 + 3.3600 3.3700 3.3800 3.3900 3.4000 3.4100 3.4200 3.4300 + 3.4400 3.4500 3.4600 3.4700 3.4800 3.4900 3.5000 3.5100 + 3.5200 3.5300 3.5400 3.5500 3.5600 3.5700 3.5800 3.5900 + 3.6000 3.6100 3.6200 3.6300 3.6400 3.6500 3.6600 3.6700 + 3.6800 3.6900 3.7000 3.7100 3.7200 3.7300 3.7400 3.7500 + 3.7600 3.7700 3.7800 3.7900 3.8000 3.8100 3.8200 3.8300 + 3.8400 3.8500 3.8600 3.8700 3.8800 3.8900 3.9000 3.9100 + 3.9200 3.9300 3.9400 3.9500 3.9600 3.9700 3.9800 3.9900 + 4.0000 4.0100 4.0200 4.0300 4.0400 4.0500 4.0600 4.0700 + 4.0800 4.0900 4.1000 4.1100 4.1200 4.1300 4.1400 4.1500 + 4.1600 4.1700 4.1800 4.1900 4.2000 4.2100 4.2200 4.2300 + 4.2400 4.2500 4.2600 4.2700 4.2800 4.2900 4.3000 4.3100 + 4.3200 4.3300 4.3400 4.3500 4.3600 4.3700 4.3800 4.3900 + 4.4000 4.4100 4.4200 4.4300 4.4400 4.4500 4.4600 4.4700 + 4.4800 4.4900 4.5000 4.5100 4.5200 4.5300 4.5400 4.5500 + 4.5600 4.5700 4.5800 4.5900 4.6000 4.6100 4.6200 4.6300 + 4.6400 4.6500 4.6600 4.6700 4.6800 4.6900 4.7000 4.7100 + 4.7200 4.7300 4.7400 4.7500 4.7600 4.7700 4.7800 4.7900 + 4.8000 4.8100 4.8200 4.8300 4.8400 4.8500 4.8600 4.8700 + 4.8800 4.8900 4.9000 4.9100 4.9200 4.9300 4.9400 4.9500 + 4.9600 4.9700 4.9800 4.9900 5.0000 5.0100 5.0200 5.0300 + 5.0400 5.0500 5.0600 5.0700 5.0800 5.0900 5.1000 5.1100 + 5.1200 5.1300 5.1400 5.1500 5.1600 5.1700 5.1800 5.1900 + 5.2000 5.2100 5.2200 5.2300 5.2400 5.2500 5.2600 5.2700 + 5.2800 5.2900 5.3000 5.3100 5.3200 5.3300 5.3400 5.3500 + 5.3600 5.3700 5.3800 5.3900 5.4000 5.4100 5.4200 5.4300 + 5.4400 5.4500 5.4600 5.4700 5.4800 5.4900 5.5000 5.5100 + 5.5200 5.5300 5.5400 5.5500 5.5600 5.5700 5.5800 5.5900 + 5.6000 5.6100 5.6200 5.6300 5.6400 5.6500 5.6600 5.6700 + 5.6800 5.6900 5.7000 5.7100 5.7200 5.7300 5.7400 5.7500 + 5.7600 5.7700 5.7800 5.7900 5.8000 5.8100 5.8200 5.8300 + 5.8400 5.8500 5.8600 5.8700 5.8800 5.8900 5.9000 5.9100 + 5.9200 5.9300 5.9400 5.9500 5.9600 5.9700 5.9800 5.9900 + 6.0000 6.0100 + + + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 + + + + -2.7605700345E+01 -3.0784865229E+01 -3.2349253618E+01 -3.2751366129E+01 + -3.2443703381E+01 -3.1938024293E+01 -3.1464309182E+01 -3.1081089156E+01 + -3.0780110534E+01 -3.0537539935E+01 -3.0331510013E+01 -3.0145737072E+01 + -2.9968950315E+01 -2.9793612997E+01 -2.9614858119E+01 -2.9429745358E+01 + -2.9236754295E+01 -2.9035419392E+01 -2.8826044018E+01 -2.8609460457E+01 + -2.8386823980E+01 -2.8159440471E+01 -2.7928630453E+01 -2.7695631454E+01 + -2.7461537210E+01 -2.7227268680E+01 -2.6993569183E+01 -2.6761015821E+01 + -2.6530039202E+01 -2.6300945472E+01 -2.6073936437E+01 -2.5849125236E+01 + -2.5626546546E+01 -2.5406161554E+01 -2.5187858066E+01 -2.4971448643E+01 + -2.4756666888E+01 -2.4543166280E+01 -2.4330521781E+01 -2.4118237688E+01 + -2.3905762462E+01 -2.3692510781E+01 -2.3477892157E+01 -2.3261343931E+01 + -2.3042365424E+01 -2.2820549497E+01 -2.2595607833E+01 -2.2367387034E+01 + -2.2135873927E+01 -2.1901189722E+01 -2.1663577130E+01 -2.1423377048E+01 + -2.1181003715E+01 -2.0936919717E+01 -2.0691610496E+01 -2.0445564221E+01 + -2.0199254652E+01 -1.9953130261E+01 -1.9707605286E+01 -1.9463057569E+01 + -1.9219826157E+01 -1.8978213343E+01 -1.8738487400E+01 -1.8500884660E+01 + -1.8265614596E+01 -1.8032862583E+01 -1.7802792920E+01 -1.7575552408E+01 + -1.7351272692E+01 -1.7130071760E+01 -1.6912056036E+01 -1.6697321537E+01 + -1.6485954716E+01 -1.6278033179E+01 -1.6073625719E+01 -1.5872792819E+01 + -1.5675586595E+01 -1.5482050684E+01 -1.5292220051E+01 -1.5106120725E+01 + -1.4923769479E+01 -1.4745173477E+01 -1.4570329881E+01 -1.4399225454E+01 + -1.4231836134E+01 -1.4068126609E+01 -1.3908049886E+01 -1.3751546850E+01 + -1.3598545829E+01 -1.3448962145E+01 -1.3302697611E+01 -1.3159640031E+01 + -1.3019669910E+01 -1.2882669787E+01 -1.2748527869E+01 -1.2617137724E+01 + -1.2488398068E+01 -1.2362212574E+01 -1.2238489692E+01 -1.2117142884E+01 + -1.1998090066E+01 -1.1881253628E+01 -1.1766560302E+01 -1.1653941032E+01 + -1.1543330569E+01 -1.1434668196E+01 -1.1327896756E+01 -1.1222962743E+01 + -1.1119816109E+01 -1.1018409929E+01 -1.0918701041E+01 -1.0820648952E+01 + -1.0724215912E+01 -1.0629366457E+01 -1.0536068056E+01 -1.0444290028E+01 + -1.0354003461E+01 -1.0265180964E+01 -1.0177796938E+01 -1.0091826632E+01 + -1.0007246112E+01 -9.9240322892E+00 -9.8421624187E+00 -9.7616139299E+00 + -9.6823643703E+00 -9.6043910435E+00 -9.5276710191E+00 -9.4521810563E+00 + -9.3778971539E+00 -9.3047950086E+00 -9.2328496504E+00 -9.1620363695E+00 + -9.0923305110E+00 -9.0237077361E+00 -8.9561431451E+00 -8.8896116158E+00 + -8.8240890211E+00 -8.7595512275E+00 -8.6959740871E+00 -8.6333343002E+00 + -8.5716086751E+00 -8.5107748378E+00 -8.4508110921E+00 -8.3916960209E+00 + -8.3334097570E+00 -8.2759323779E+00 -8.2192454990E+00 -8.1633312824E+00 + -8.1081727717E+00 -8.0537547331E+00 -8.0000623436E+00 -7.9470813275E+00 + -7.8947972321E+00 -7.8431966714E+00 -7.7922661900E+00 -7.7419928953E+00 + -7.6923641381E+00 -7.6433675558E+00 -7.5949912477E+00 -7.5472233618E+00 + -7.5000526824E+00 -7.4534678545E+00 -7.4074582876E+00 -7.3620131113E+00 + -7.3171223055E+00 -7.2727754717E+00 -7.2289631023E+00 -7.1856752817E+00 + -7.1429029518E+00 -7.1006366576E+00 -7.0588677730E+00 -7.0175872653E+00 + -6.9767869231E+00 -6.9364581153E+00 -6.8965930059E+00 -6.8571833718E+00 + -6.8182217002E+00 -6.7797001743E+00 -6.7416115702E+00 -6.7039484718E+00 + -6.6667039108E+00 -6.6298708673E+00 -6.5934425974E+00 -6.5574124728E+00 + -6.5217739457E+00 -6.4865207734E+00 -6.4516465808E+00 -6.4171455001E+00 + -6.3830113137E+00 -6.3492384567E+00 -6.3158210267E+00 -6.2827535725E+00 + -6.2500305645E+00 -6.2176466374E+00 -6.1855966333E+00 -6.1538752555E+00 + -6.1224776754E+00 -6.0913987519E+00 -6.0606338291E+00 -6.0301780858E+00 + -6.0000268845E+00 -5.9701757684E+00 -5.9406201055E+00 -5.9113557302E+00 + -5.8823781953E+00 -5.8536833983E+00 -5.8252672254E+00 -5.7971255362E+00 + -5.7692545325E+00 -5.7416501530E+00 -5.7143087187E+00 -5.6872264675E+00 + -5.6603996483E+00 -5.6338248102E+00 -5.6074982583E+00 -5.5814166408E+00 + -5.5555765569E+00 -5.5299745536E+00 -5.5046075112E+00 -5.4794720848E+00 + -5.4545651655E+00 -5.4298837212E+00 -5.4054245210E+00 -5.3811847580E+00 + -5.3571614267E+00 -5.3333515869E+00 -5.3097525260E+00 -5.2863613325E+00 + -5.2631753334E+00 -5.2401918998E+00 -5.2174082208E+00 -5.1948218607E+00 + -5.1724302389E+00 -5.1502307471E+00 -5.1282210592E+00 -5.1063986772E+00 + -5.0847611945E+00 -5.0633063698E+00 -5.0420317959E+00 -5.0209352464E+00 + -5.0000145619E+00 -4.9792674276E+00 -4.9586917756E+00 -4.9382855278E+00 + -4.9180464624E+00 -4.8979726494E+00 -4.8780620924E+00 -4.8583126624E+00 + -4.8387225484E+00 -4.8192898345E+00 -4.8000124892E+00 -4.7808887980E+00 + -4.7619169283E+00 -4.7430949440E+00 -4.7244212124E+00 -4.7058939893E+00 + -4.6875114188E+00 -4.6692719493E+00 -4.6511739183E+00 -4.6332155580E+00 + -4.6153953755E+00 -4.5977117925E+00 -4.5801631296E+00 -4.5627479386E+00 + -4.5454647266E+00 -4.5283119032E+00 -4.5112880519E+00 -4.4943917650E+00 + -4.4776215414E+00 -4.4609759844E+00 -4.4444537713E+00 -4.4280534916E+00 + -4.4117737574E+00 -4.3956133298E+00 -4.3795708900E+00 -4.3636450498E+00 + -4.3478346519E+00 -4.3321384475E+00 -4.3165551080E+00 -4.3010834883E+00 + -4.2857224193E+00 -4.2704706626E+00 -4.2553270471E+00 -4.2402904912E+00 + -4.2253598492E+00 -4.2105339172E+00 -4.1958116967E+00 -4.1811921057E+00 + -4.1666739956E+00 -4.1522563551E+00 -4.1379381819E+00 -4.1237184204E+00 + -4.1095960051E+00 -4.0955700209E+00 -4.0816394841E+00 -4.0678033425E+00 + -4.0540606926E+00 -4.0404106187E+00 -4.0268521620E+00 -4.0133843475E+00 + -4.0000063484E+00 -3.9867172703E+00 -3.9735161622E+00 -3.9604021828E+00 + -3.9473745101E+00 -3.9344322882E+00 -3.9215745909E+00 -3.9088006833E+00 + -3.8961097526E+00 -3.8835009538E+00 -3.8709734686E+00 -3.8585265734E+00 + -3.8461594934E+00 -3.8338713986E+00 -3.8216615661E+00 -3.8095292837E+00 + -3.7974738126E+00 -3.7854943426E+00 -3.7735902317E+00 -3.7617607813E+00 + -3.7500052762E+00 -3.7383229617E+00 -3.7267132311E+00 -3.7151754129E+00 + -3.7037088125E+00 -3.6923127373E+00 -3.6809865997E+00 -3.6697297595E+00 + -3.6585415452E+00 -3.6474213158E+00 -3.6363685045E+00 -3.6253825007E+00 + -3.6144626587E+00 -3.6036083788E+00 -3.5928191167E+00 -3.5820942902E+00 + -3.5714332815E+00 -3.5608355222E+00 -3.5503004929E+00 -3.5398276385E+00 + -3.5294163709E+00 -3.5190661440E+00 -3.5087764652E+00 -3.4985468053E+00 + -3.4883766076E+00 -3.4782653400E+00 -3.4682125383E+00 -3.4582176981E+00 + -3.4482802961E+00 -3.4383998061E+00 -3.4285757940E+00 -3.4188077789E+00 + -3.4090952728E+00 -3.3994377480E+00 -3.3898348019E+00 -3.3802859760E+00 + -3.3707908119E+00 -3.3613487964E+00 -3.3519595367E+00 -3.3426226031E+00 + -3.3333375585E+00 -3.3241039280E+00 -3.3149213002E+00 -3.3057892823E+00 + -3.2967074576E+00 -3.2876753919E+00 -3.2786926486E+00 -3.2697588729E+00 + -3.2608736674E+00 -3.2520366348E+00 -3.2432473253E+00 -3.2345054052E+00 + -3.2258105008E+00 -3.2171622335E+00 -3.2085601965E+00 -3.2000040171E+00 + -3.1914933640E+00 -3.1830278760E+00 -3.1746071920E+00 -3.1662308963E+00 + -3.1578986987E+00 -3.1496102547E+00 -3.1413652201E+00 -3.1331632249E+00 + -3.1250039281E+00 -3.1168870307E+00 -3.1088122044E+00 -3.1007791210E+00 + -3.0927874062E+00 -3.0848367838E+00 -3.0769269476E+00 -3.0690575847E+00 + -3.0612283700E+00 -3.0534389657E+00 -3.0456891132E+00 -3.0379785141E+00 + -3.0303068700E+00 -3.0226738555E+00 -3.0150791818E+00 -3.0075225888E+00 + -3.0000037918E+00 -2.9925225065E+00 -2.9850784103E+00 -2.9776712548E+00 + -2.9703007806E+00 -2.9629667163E+00 -2.9556687906E+00 -2.9484066870E+00 + -2.9411801890E+00 -2.9339890404E+00 -2.9268329824E+00 -2.9197117526E+00 + -2.9126250543E+00 -2.9055726836E+00 -2.8985543940E+00 -2.8915699388E+00 + -2.8846190644E+00 -2.8777014940E+00 -2.8708170314E+00 -2.8639654413E+00 + -2.8571464888E+00 -2.8503599315E+00 -2.8436055055E+00 -2.8368830243E+00 + -2.8301922637E+00 -2.8235329996E+00 -2.8169050030E+00 -2.8103080169E+00 + -2.8037418662E+00 -2.7972063374E+00 -2.7907012166E+00 -2.7842262903E+00 + -2.7777813024E+00 -2.7713660913E+00 -2.7649804532E+00 -2.7586241845E+00 + -2.7522970813E+00 -2.7459989054E+00 -2.7397294879E+00 -2.7334886419E+00 + -2.7272761732E+00 -2.7210918876E+00 -2.7149355663E+00 -2.7088070278E+00 + -2.7027061039E+00 -2.6966326094E+00 -2.6905863591E+00 -2.6845671557E+00 + -2.6785748003E+00 -2.6726091446E+00 -2.6666700119E+00 -2.6607572257E+00 + -2.6548706095E+00 -2.6490099504E+00 -2.6431751131E+00 -2.6373659318E+00 + -2.6315822382E+00 -2.6258238639E+00 -2.6200906210E+00 -2.6143823457E+00 + -2.6086988964E+00 -2.6030401127E+00 -2.5974058340E+00 -2.5917958991E+00 + -2.5862101123E+00 -2.5806483565E+00 -2.5751104788E+00 -2.5695963262E+00 + -2.5641057455E+00 -2.5586385667E+00 -2.5531946375E+00 -2.5477738314E+00 + -2.5423760028E+00 -2.5370010057E+00 -2.5316486943E+00 -2.5263188926E+00 + -2.5210114847E+00 -2.5157263372E+00 -2.5104633109E+00 -2.5052222669E+00 + -2.5000030605E+00 -2.4948055297E+00 -2.4896295712E+00 -2.4844750523E+00 + -2.4793418405E+00 -2.4742298031E+00 -2.4691387940E+00 -2.4640686757E+00 + -2.4590193426E+00 -2.4539906681E+00 -2.4489825259E+00 -2.4439947896E+00 + -2.4390273136E+00 -2.4340799794E+00 -2.4291526807E+00 -2.4242452972E+00 + -2.4193577083E+00 -2.4144897934E+00 -2.4096414103E+00 -2.4048124528E+00 + -2.4000028171E+00 -2.3952123882E+00 -2.3904410511E+00 -2.3856886909E+00 + -2.3809551705E+00 -2.3762403912E+00 -2.3715442531E+00 -2.3668666465E+00 + -2.3622074621E+00 -2.3575665900E+00 -2.3529439004E+00 -2.3483392967E+00 + -2.3437526852E+00 -2.3391839614E+00 -2.3346330208E+00 -2.3300997590E+00 + -2.3255840547E+00 -2.3210858091E+00 -2.3166049363E+00 -2.3121413368E+00 + -2.3076949109E+00 -2.3032655590E+00 -2.2988531707E+00 -2.2944576400E+00 + -2.2900788908E+00 -2.2857168282E+00 -2.2813713571E+00 -2.2770423826E+00 + -2.2727298068E+00 -2.2684335124E+00 -2.2641534347E+00 -2.2598894829E+00 + -2.2556415666E+00 -2.2514095953E+00 -2.2471934785E+00 -2.2429931038E+00 + -2.2388083992E+00 -2.2346392847E+00 -2.2304856742E+00 -2.2263474813E+00 + -2.2222246197E+00 -2.2181169931E+00 -2.2140245088E+00 -2.2099471023E+00 + -2.2058846913E+00 -2.2018371933E+00 -2.1978045263E+00 -2.1937866078E+00 + -2.1897833323E+00 -2.1857946406E+00 -2.1818204576E+00 -2.1778607050E+00 + -2.1739153043E+00 -2.1699841770E+00 -2.1660672366E+00 -2.1621643955E+00 + -2.1582755972E+00 -2.1544007668E+00 -2.1505398296E+00 -2.1466927107E+00 + -2.1428593354E+00 -2.1390396118E+00 -2.1352334757E+00 -2.1314408644E+00 + -2.1276617067E+00 -2.1238959313E+00 -2.1201434667E+00 -2.1164042418E+00 + -2.1126781618E+00 -2.1089651802E+00 -2.1052652307E+00 -2.1015782452E+00 + -2.0979041558E+00 -2.0942428944E+00 -2.0905943898E+00 -2.0869585565E+00 + -2.0833353508E+00 -2.0797247079E+00 -2.0761265629E+00 -2.0725408510E+00 + -2.0689675074E+00 -2.0654064613E+00 -2.0618576366E+00 -2.0583209894E+00 + -2.0547964579E+00 -2.0512839803E+00 -2.0477834948E+00 -2.0442949396E+00 + -2.0408182464E+00 -2.0373533437E+00 -2.0339001895E+00 -2.0304587249E+00 + -2.0270288910E+00 -2.0236106288E+00 -2.0202038794E+00 -2.0168085786E+00 + -2.0134246558E+00 -2.0100520723E+00 -2.0066907719E+00 -2.0033406985E+00 + -2.0000017959E+00 -1.9966740079E+00 + + + + 0.0000000000E+00 -8.2277987587E-02 -1.6449650094E-01 -2.4659331589E-01 + -3.2850076507E-01 -4.1014315697E-01 -4.9143436126E-01 -5.7227561145E-01 + -6.5255357242E-01 -7.3213871601E-01 -8.1088404273E-01 -8.8862418182E-01 + -9.6517489579E-01 -1.0403330086E+00 -1.1138767696E+00 -1.1855666583E+00 + -1.2551466268E+00 -1.3223457701E+00 -1.3868804065E+00 -1.4484565448E+00 + -1.5067727038E+00 -1.5615230499E+00 -1.6124008059E+00 -1.6591018874E+00 + -1.7013287065E+00 -1.7387940878E+00 -1.7712252542E+00 -1.7983677872E+00 + -1.8199895278E+00 -1.8358843512E+00 -1.8458757490E+00 -1.8498201626E+00 + -1.8476100093E+00 -1.8391763180E+00 -1.8244910913E+00 -1.8035689946E+00 + -1.7764688338E+00 -1.7432942635E+00 -1.7041941790E+00 -1.6593624450E+00 + -1.6090370910E+00 -1.5534989864E+00 -1.4930699667E+00 -1.4281104400E+00 + -1.3590165014E+00 -1.2862165869E+00 -1.2101677086E+00 -1.1313513155E+00 + -1.0502688403E+00 -9.6743710159E-01 -8.8338307362E-01 -7.9863905513E-01 + -7.1373774907E-01 -6.2920651981E-01 -5.4556280508E-01 -4.6330924845E-01 + -3.8292814427E-01 -3.0487830138E-01 -2.2958906110E-01 -1.5745833560E-01 + -8.8847539142E-02 -2.4079508545E-02 3.6563691834E-02 9.2844371601E-02 + 1.4456869600E-01 1.9158861786E-01 2.3380285278E-01 2.7115554880E-01 + 3.0363571638E-01 3.3127718718E-01 3.5415591151E-01 3.7238794759E-01 + 3.8612701355E-01 3.9556147997E-01 4.0091144918E-01 4.0242475349E-01 + 4.0037331823E-01 3.9504921005E-01 3.8676054393E-01 3.7582731451E-01 + 3.6257720433E-01 3.4734141910E-01 3.3045059692E-01 3.1223083453E-01 + 2.9299986887E-01 2.7306344758E-01 2.5271191615E-01 2.3221704416E-01 + 2.1182910699E-01 1.9177423337E-01 1.7225200095E-01 1.5343329037E-01 + 1.3546088278E-01 1.1845195585E-01 1.0249965400E-01 8.7673842851E-02 + 7.4022153762E-02 6.1571422473E-02 5.0329214779E-02 4.0284462837E-02 + 3.1410783526E-02 2.3667878040E-02 1.7003522416E-02 1.1355567187E-02 + 6.6538808501E-03 2.8220678737E-03 -2.2001240793E-04 -2.5547866842E-03 + -4.2654366871E-03 -5.4349451843E-03 -6.1429431867E-03 -6.4660691080E-03 + -6.4767064284E-03 -6.2432624449E-03 -5.8262992394E-03 -5.2807905609E-03 + -4.6556441299E-03 -3.9940297562E-03 -3.3299352117E-03 -2.6921631841E-03 + -2.1041805481E-03 -1.5819270303E-03 -1.1356467997E-03 -7.7141771203E-04 + -4.9002008278E-04 -2.8685599057E-04 -1.5440700844E-04 -8.1295680504E-05 + -5.2958831332E-05 -4.9024979272E-05 -2.2654023957E-05 2.0802206378E-06 + 1.6220072646E-06 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 + + + 0.0000000000E+00 -1.1723087215E-02 -2.2970588285E-02 -3.3277762775E-02 + -4.2201369170E-02 -4.9329936250E-02 -5.4293469599E-02 -5.6772419538E-02 + -5.6505748973E-02 -5.3297954463E-02 -4.7024911330E-02 -3.7638432778E-02 + -2.5169454710E-02 -9.7297804400E-03 8.4876559486E-03 2.9210025055E-02 + 5.2087327705E-02 7.6696576823E-02 1.0254737811E-01 1.2908882978E-01 + 1.5571763119E-01 1.8178728239E-01 2.0661822255E-01 2.2950875795E-01 + 2.4974659019E-01 2.6662075364E-01 2.7943382524E-01 2.8751410085E-01 + 2.9022762150E-01 2.8698983512E-01 2.7727667838E-01 2.6063490065E-01 + 2.3669144662E-01 2.0516162976E-01 1.6585646477E-01 1.1868792319E-01 + 6.3673539750E-02 9.3865644130E-04 -6.9282296205E-02 -1.4664653237E-01 + -2.3070525508E-01 -3.2090755014E-01 -4.1660590836E-01 -5.1706326588E-01 + -6.2146146368E-01 -7.2891100660E-01 -8.3846198150E-01 -9.4911597183E-01 + -1.0598387764E+00 -1.1695734189E+00 -1.2772547958E+00 -1.3818230208E+00 + -1.4822368409E+00 -1.5774891053E+00 -1.6666187728E+00 -1.7487234696E+00 + -1.8229735575E+00 -1.8886194365E+00 -1.9450060422E+00 -1.9915764523E+00 + -2.0278831780E+00 -2.0535914046E+00 -2.0684822557E+00 -2.0724589319E+00 + -2.0655426479E+00 -2.0478740211E+00 -2.0197115502E+00 -1.9814248238E+00 + -1.9334892505E+00 -1.8764808008E+00 -1.8110656211E+00 -1.7379906968E+00 + -1.6580733899E+00 -1.5721902388E+00 -1.4812642140E+00 -1.3862522622E+00 + -1.2881324457E+00 -1.1878908963E+00 -1.0865088556E+00 -9.8494996663E-01 + -8.8414798922E-01 -7.8499509134E-01 -6.8833085835E-01 -5.9493213952E-01 + -5.0550383294E-01 -4.2067068746E-01 -3.4097017799E-01 -2.6684648767E-01 + -1.9864560686E-01 -1.3661153627E-01 -8.0883449121E-02 -3.1493861467E-02 + 1.1620322833E-02 4.8599589644E-02 7.9650226738E-02 1.0503788587E-01 + 1.2508039801E-01 1.4013995079E-01 1.5061541504E-01 1.5693366067E-01 + 1.5954043230E-01 1.5889246200E-01 1.5544945597E-01 1.4966651822E-01 + 1.4199014613E-01 1.3284299597E-01 1.2262519169E-01 1.1170778401E-01 + 1.0042928223E-01 8.9095504256E-02 7.7963775928E-02 6.7255547029E-02 + 5.7152141457E-02 4.7799764163E-02 3.9294804857E-02 3.1701123437E-02 + 2.5050278343E-02 1.9344675342E-02 1.4551822257E-02 1.0621676019E-02 + 7.4866418173E-03 5.0616443312E-03 3.2542385947E-03 1.9673338834E-03 + 1.1012904675E-03 5.6303386455E-04 2.6418408232E-04 1.2416036016E-04 + 8.3638494781E-05 8.3445532246E-05 3.9712888830E-05 -3.5905440177E-06 + -2.7996494097E-06 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 + + + 0.0000000000E+00 3.5860269827E-03 1.4317078272E-02 3.2112256128E-02 + 5.6837367274E-02 8.8305873299E-02 1.2628021312E-01 1.7047348950E-01 + 2.2055150919E-01 2.7613516420E-01 3.3680313934E-01 4.0209492899E-01 + 4.7151414403E-01 5.4453208758E-01 6.2059157645E-01 6.9911098297E-01 + 7.7948847033E-01 8.6110639245E-01 9.4333582837E-01 1.0255412195E+00 + 1.1070850756E+00 1.1873327175E+00 1.2656570189E+00 1.3414431144E+00 + 1.4140930355E+00 1.4830302391E+00 1.5477039940E+00 1.6075935868E+00 + 1.6622123152E+00 1.7111112337E+00 1.7538826190E+00 1.7901631245E+00 + 1.8196365952E+00 1.8420365276E+00 1.8571481070E+00 1.8648098949E+00 + 1.8649150077E+00 1.8574119504E+00 1.8423049075E+00 1.8196536236E+00 + 1.7895728317E+00 1.7522312003E+00 1.7078498355E+00 1.6567003418E+00 + 1.5991024567E+00 1.5354212770E+00 1.4660641009E+00 1.3914769134E+00 + 1.3121405542E+00 1.2285667331E+00 1.1412932403E+00 1.0508797039E+00 + 9.5790298913E-01 8.6295169350E-01 7.6662172078E-01 6.6951129918E-01 + 5.7221537424E-01 4.7532181715E-01 3.7940524579E-01 2.8502383408E-01 + 1.9271369849E-01 1.0298539150E-01 1.6320224853E-02 -6.6834318537E-02 + -1.4606648327E-01 -2.2100368547E-01 -2.9131520005E-01 -3.5671342275E-01 + -4.1695549560E-01 -4.7184486654E-01 -5.2123135255E-01 -5.6501133337E-01 + -6.0312746230E-01 -6.3556796384E-01 -6.6236527842E-01 -6.8359449970E-01 + -6.9937142322E-01 -7.0985023488E-01 -7.1522090252E-01 -7.1570630926E-01 + -7.1155917402E-01 -7.0305880711E-01 -6.9050775058E-01 -6.7422835456E-01 + -6.5455934146E-01 -6.3185241011E-01 -6.0646893131E-01 -5.7877678564E-01 + -5.4914739239E-01 -5.1795297687E-01 -4.8556415192E-01 -4.5234782509E-01 + -4.1866194064E-01 -3.8484854594E-01 -3.5122924483E-01 -3.1810273720E-01 + -2.8574272301E-01 -2.5439648427E-01 -2.2428377777E-01 -1.9559309794E-01 + -1.6848457254E-01 -1.4308867914E-01 -1.1950650654E-01 -9.7810361217E-02 + -7.8045864567E-02 -6.0228944123E-02 -4.4352023434E-02 -3.0384350338E-02 + -1.8273960617E-02 -7.9495883994E-03 6.7759973479E-04 7.7099198058E-03 + 1.3261526160E-02 1.7457218324E-02 2.0427124578E-02 2.2305646179E-02 + 2.3229681315E-02 2.3338002873E-02 2.2762351834E-02 2.1631893993E-02 + 2.0072411241E-02 1.8198596607E-02 1.6115058374E-02 1.3919754929E-02 + 1.1698898123E-02 9.5228516845E-03 7.4546618226E-03 5.5452981103E-03 + 3.8288793415E-03 2.3331720374E-03 1.0736899984E-03 5.2926998136E-05 + -7.3149996906E-04 -1.2929678601E-03 -1.6511600028E-03 -1.8297965622E-03 + -1.8585360541E-03 -1.7678438403E-03 -1.5911002682E-03 -1.3586955246E-03 + -1.1019690505E-03 -8.4702839256E-04 -6.1497715279E-04 -4.2541468309E-04 + -2.8402093044E-04 -1.9725198792E-04 -1.6029137555E-04 -1.5177315345E-04 + -8.9838576118E-05 -5.4771430827E-06 9.6147639048E-06 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 + + + 0.0000000000E+00 9.2893242255E-04 3.7019764676E-03 8.2779769445E-03 + 1.4588689808E-02 2.2539302945E-02 3.2009163013E-02 4.2852705981E-02 + 5.4900588274E-02 6.7961014587E-02 8.1821257513E-02 9.6249363136E-02 + 1.1099603565E-01 1.2579669284E-01 1.4037368313E-01 1.5443865322E-01 + 1.6769505435E-01 1.7984077312E-01 1.9057087191E-01 1.9958042202E-01 + 2.0656741042E-01 2.1123570101E-01 2.1329802783E-01 2.1247899806E-01 + 2.0851807950E-01 2.0117254726E-01 1.9022036400E-01 1.7546296384E-01 + 1.5672791414E-01 1.3387142592E-01 1.0678068413E-01 7.5375969726E-02 + 3.9612545899E-02 -5.1771162367E-04 -4.4984990254E-02 -9.3720492346E-02 + -1.4661576728E-01 -2.0352233418E-01 -2.6425172921E-01 -3.2857590175E-01 + -3.9622799242E-01 -4.6690352048E-01 -5.4026196118E-01 -6.1592871460E-01 + -6.9349745874E-01 -7.7253287529E-01 -8.5257373131E-01 -9.3313629426E-01 + -1.0137180499E+00 -1.0938015836E+00 -1.1728591565E+00 -1.2503568716E+00 + -1.3257591460E+00 -1.3985339592E+00 -1.4681572088E+00 -1.5341175221E+00 + -1.5959215886E+00 -1.6530979289E+00 -1.7052026499E+00 -1.7518226198E+00 + -1.7925806287E+00 -1.8271386946E+00 -1.8552014319E+00 -1.8765200508E+00 + -1.8908940379E+00 -1.8981739659E+00 -1.8982634918E+00 -1.8911201167E+00 + -1.8767560905E+00 -1.8552388890E+00 -1.8266905450E+00 -1.7912868237E+00 + -1.7492558153E+00 -1.7008761570E+00 -1.6464740899E+00 -1.5864208426E+00 + -1.5211291980E+00 -1.4510496961E+00 -1.3766664971E+00 -1.2984929459E+00 + -1.2170668968E+00 -1.1329458601E+00 -1.0467020356E+00 -9.5891730044E-01 + -8.7017821889E-01 -7.8107114433E-01 -6.9217748077E-01 -6.0406917196E-01 + -5.1730448344E-01 -4.3242413992E-01 -3.4994793756E-01 -2.7037179974E-01 + -1.9415879235E-01 -1.2172780433E-01 -5.3447524144E-02 1.0365478214E-02 + 6.9448141778E-02 1.2359143475E-01 1.7264050244E-01 2.1649715017E-01 + 2.5511519340E-01 2.8850025641E-01 3.1670773256E-01 3.3984027408E-01 + 3.5804463559E-01 3.7150996533E-01 3.8046133188E-01 3.8515667437E-01 + 3.8588276317E-01 3.8295243350E-01 3.7669486668E-01 3.6745451357E-01 + 3.5558583975E-01 3.4145309072E-01 3.2541361978E-01 3.0782259726E-01 + 2.8902885306E-01 2.6937446596E-01 2.4917322584E-01 2.2872577817E-01 + 2.0831749242E-01 1.8820101658E-01 1.6860103788E-01 1.4972254242E-01 + 1.3173967350E-01 1.1478834281E-01 9.8985070983E-02 8.4416837992E-02 + 7.1132442003E-02 5.9164183104E-02 4.8515945607E-02 3.9162908641E-02 + 3.1067102133E-02 2.4166226359E-02 1.8383581049E-02 1.3631066681E-02 + 9.8082692597E-03 6.8108066814E-03 4.5261412594E-03 2.8479629339E-03 + 1.6647468801E-03 8.7544647586E-04 3.8748703362E-04 1.0892680591E-04 + -2.3425222903E-05 -7.7922079727E-05 -9.4002294959E-05 -9.5906384375E-05 + -5.6988379155E-05 -3.5463910332E-06 5.9608986436E-06 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 + + + 1.9514303897E+01 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 2.7522534413E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 -9.6137176497E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 -3.2324794045E+00 + + + + + + 0.0000000000E+00 2.4555322044E-04 9.9435596078E-04 2.2826802809E-03 + 4.1704577663E-03 6.7405039734E-03 1.0097446971E-02 1.4366374033E-02 + 1.9691214178E-02 2.6232877622E-02 3.4167176269E-02 4.3682552029E-02 + 5.4977642082E-02 6.8258712011E-02 8.3736989112E-02 1.0162592925E-01 + 1.2213845080E-01 1.4548416964E-01 1.7186666804E-01 2.0148082992E-01 + 2.3451027351E-01 2.7112491013E-01 3.1147865648E-01 3.5570732483E-01 + 4.0392671304E-01 4.5623091264E-01 5.1269085328E-01 5.7335309214E-01 + 6.3823886033E-01 7.0734337238E-01 7.8063540062E-01 8.5805711439E-01 + 9.3952417996E-01 1.0249261017E+00 1.1141268534E+00 1.2069656628E+00 + 1.3032581166E+00 1.4027973581E+00 1.5053555697E+00 1.6106855669E+00 + 1.7185225365E+00 1.8285859201E+00 1.9405813920E+00 2.0542029191E+00 + 2.1691348784E+00 2.2850542133E+00 2.4016326049E+00 2.5185386399E+00 + 2.6354399503E+00 2.7520052604E+00 2.8679065939E+00 2.9828210875E+00 + 3.0964328328E+00 3.2084348565E+00 3.3185305939E+00 3.4264354515E+00 + 3.5318783577E+00 3.6346027795E+00 3.7343681356E+00 3.8309505035E+00 + 3.9241436467E+00 4.0137595888E+00 4.0996291450E+00 4.1816023622E+00 + 4.2595486912E+00 4.3333571276E+00 4.4029361120E+00 4.4682134089E+00 + 4.5291358858E+00 4.5856689029E+00 4.6377959244E+00 4.6855179084E+00 + 4.7288525836E+00 4.7678337886E+00 4.8025102209E+00 4.8329448489E+00 + 4.8592138549E+00 4.8814055976E+00 4.8996195505E+00 4.9139652152E+00 + 4.9245610181E+00 4.9315332006E+00 4.9350147101E+00 4.9351441007E+00 + 4.9320644514E+00 4.9259223085E+00 4.9168666605E+00 4.9050479496E+00 + 4.8906171284E+00 4.8737247647E+00 4.8545202011E+00 4.8331507724E+00 + 4.8097610853E+00 4.7844923629E+00 4.7574818564E+00 4.7288623255E+00 + 4.6987615887E+00 4.6673022280E+00 4.6346013382E+00 4.6007695137E+00 + 4.5659116073E+00 4.5301262966E+00 4.4935060361E+00 4.4561370652E+00 + 4.4180998488E+00 4.3794678786E+00 4.3403092049E+00 4.3006862196E+00 + 4.2606559084E+00 4.2202701844E+00 4.1795755629E+00 4.1386143513E+00 + 4.0974246608E+00 4.0560406954E+00 4.0144930190E+00 3.9728092235E+00 + 3.9310140868E+00 3.8891296584E+00 3.8471763585E+00 3.8051727118E+00 + 3.7631353587E+00 3.7210801524E+00 3.6790222306E+00 3.6369754752E+00 + 3.5949532922E+00 3.5529695496E+00 3.5110371051E+00 3.4691686011E+00 + 3.4273777892E+00 3.3856773650E+00 3.3440802075E+00 3.3026002179E+00 + 3.2612500462E+00 3.2200431162E+00 3.1789931977E+00 3.1381126416E+00 + 3.0974153228E+00 3.0569141416E+00 3.0166213097E+00 2.9765501384E+00 + 2.9367121016E+00 2.8971193603E+00 2.8577833885E+00 2.8187144722E+00 + 2.7799237680E+00 2.7414203117E+00 2.7032138975E+00 2.6653129770E+00 + 2.6277254184E+00 2.5904592077E+00 2.5535203424E+00 2.5169161760E+00 + 2.4806515332E+00 2.4447325241E+00 2.4091633992E+00 2.3739487914E+00 + 2.3390925610E+00 2.3045979624E+00 2.2704685078E+00 2.2367061977E+00 + 2.2033142099E+00 2.1702934279E+00 2.1376466921E+00 2.1053739087E+00 + 2.0734775689E+00 2.0419567389E+00 2.0108135020E+00 1.9800463428E+00 + 1.9496568192E+00 1.9196429197E+00 1.8900057747E+00 1.8607428608E+00 + 1.8318549701E+00 1.8033391361E+00 1.7751957603E+00 1.7474216534E+00 + 1.7200166764E+00 1.6929775891E+00 1.6663036438E+00 1.6399916950E+00 + 1.6140403080E+00 1.5884465799E+00 1.5632083065E+00 1.5383229695E+00 + 1.5137875184E+00 1.4895999441E+00 1.4657562937E+00 1.4422551560E+00 + 1.4190916630E+00 1.3962646344E+00 1.3737695287E+00 1.3516041505E+00 + 1.3297648393E+00 1.3082482527E+00 1.2870517468E+00 1.2661707761E+00 + 1.2456035241E+00 1.2253449792E+00 1.2053930652E+00 1.1857436665E+00 + 1.1663933299E+00 1.1473392986E+00 1.1285766929E+00 1.1101036434E+00 + 1.0919153412E+00 1.0740090637E+00 1.0563813566E+00 1.0390278824E+00 + 1.0219464881E+00 1.0051322370E+00 9.8858273586E-01 9.7229433753E-01 + 9.5626288454E-01 9.4048618717E-01 9.2495945205E-01 9.0968023104E-01 + 8.9464515722E-01 8.7984988668E-01 8.6529242529E-01 8.5096836827E-01 + 8.3687483992E-01 8.2300917666E-01 8.0936653060E-01 7.9594527075E-01 + 7.8274162686E-01 7.6975194584E-01 7.5697415488E-01 7.4440404132E-01 + 7.3203906033E-01 7.1987668706E-01 7.0791241321E-01 6.9614463944E-01 + 6.8457015681E-01 6.7318513862E-01 6.6198789975E-01 6.5097491802E-01 + 6.4014312669E-01 6.2949060514E-01 6.1901366286E-01 6.0870987684E-01 + 5.9857713213E-01 5.8861165082E-01 5.7881152804E-01 5.6917450923E-01 + 5.5969679766E-01 5.5037688431E-01 5.4121243428E-01 5.3219968832E-01 + 5.2333742019E-01 5.1462325731E-01 5.0605357159E-01 4.9762726943E-01 + 4.8934201433E-01 4.8119433956E-01 4.7318319951E-01 4.6530638099E-01 + 4.5756049431E-01 4.4994457445E-01 4.4245651371E-01 4.3509310405E-01 + 4.2785330791E-01 4.2073518522E-01 4.1373575057E-01 4.0685380826E-01 + 4.0008762412E-01 3.9343446965E-01 3.8689291717E-01 3.8046146824E-01 + 3.7413768570E-01 3.6791984300E-01 3.6180669955E-01 3.5579614205E-01 + 3.4988609008E-01 3.4407557281E-01 3.3836282768E-01 3.3274538488E-01 + 3.2722254123E-01 3.2179272713E-01 3.1645359987E-01 3.1120418021E-01 + 3.0604318897E-01 3.0096867591E-01 2.9597910956E-01 2.9107357482E-01 + 2.8625054370E-01 2.8150791508E-01 2.7684511501E-01 2.7226081425E-01 + 2.6775306980E-01 2.6332090390E-01 2.5896332932E-01 2.5467885571E-01 + 2.5046582167E-01 2.4632363995E-01 2.4225111660E-01 2.3824645700E-01 + 2.3430890125E-01 2.3043753190E-01 2.2663103075E-01 2.2288787866E-01 + 2.1920758650E-01 2.1558909889E-01 2.1203087347E-01 2.0853209698E-01 + 2.0509203703E-01 2.0170965015E-01 1.9838332245E-01 1.9511274762E-01 + 1.9189700637E-01 1.8873489405E-01 1.8562532983E-01 1.8256784638E-01 + 1.7956156317E-01 1.7660516721E-01 1.7369802148E-01 1.7083951993E-01 + 1.6802882312E-01 1.6526455844E-01 1.6254643724E-01 1.5987374760E-01 + 1.5724562162E-01 1.5466088112E-01 1.5211928277E-01 1.4962011532E-01 + 1.4716247731E-01 1.4474543496E-01 1.4236869347E-01 1.4003158209E-01 + 1.3773319599E-01 1.3547277982E-01 1.3325001085E-01 1.3106425897E-01 + 1.2891464189E-01 1.2680052175E-01 1.2472157135E-01 1.2267720085E-01 + 1.2066657246E-01 1.1868911133E-01 1.1674450739E-01 1.1483221045E-01 + 1.1295144579E-01 1.1110165375E-01 1.0928256040E-01 1.0749365423E-01 + 1.0573423961E-01 1.0400373057E-01 1.0230190533E-01 1.0062828986E-01 + 9.8982281391E-02 9.7363232570E-02 9.5770986299E-02 9.4205104640E-02 + 9.2665089253E-02 9.1150203181E-02 8.9660362635E-02 8.8195164240E-02 + 8.6754184314E-02 8.5336692055E-02 8.3942565008E-02 8.2571471377E-02 + 8.1223022254E-02 7.9896618189E-02 7.8591960933E-02 7.7308833712E-02 + 7.6046880544E-02 7.4805642086E-02 7.3584629176E-02 7.2383740506E-02 + 7.1202651131E-02 7.0041020775E-02 6.8898242541E-02 6.7774247481E-02 + 6.6668765461E-02 6.5581486791E-02 6.4511958509E-02 6.3459869402E-02 + 6.2425088961E-02 6.1407336085E-02 6.0406316994E-02 5.9421479885E-02 + 5.8452822608E-02 5.7500090972E-02 5.6563019041E-02 5.5641218020E-02 + 5.4734411156E-02 5.3842496378E-02 5.2965233586E-02 5.2102372240E-02 + 5.1253457601E-02 5.0418435755E-02 4.9597119611E-02 4.8789283548E-02 + 4.7994643509E-02 4.7212852717E-02 4.6443878327E-02 4.5687517686E-02 + 4.4943559586E-02 4.4211678082E-02 4.3491681375E-02 4.2783483184E-02 + 4.2086894267E-02 4.1401717619E-02 4.0727603994E-02 4.0064476856E-02 + 3.9412211446E-02 3.8770631668E-02 3.8139554396E-02 3.7518622579E-02 + 3.6907839114E-02 3.6307055480E-02 3.5716108368E-02 3.5134814385E-02 + 3.4562862225E-02 3.4000262270E-02 3.3446869273E-02 3.2902532276E-02 + 3.2367070616E-02 3.1840217984E-02 3.1321976903E-02 3.0812213425E-02 + 3.0310788441E-02 2.9817533657E-02 2.9332204905E-02 2.8854805910E-02 + 2.8385213523E-02 2.7923299942E-02 2.7468917225E-02 2.7021823958E-02 + 2.6582032748E-02 2.6149430718E-02 2.5723900801E-02 2.5305321709E-02 + 2.4893439431E-02 2.4488280997E-02 2.4089743440E-02 2.3697719832E-02 + 2.3312099450E-02 2.2932666819E-02 2.2559404233E-02 2.2192239239E-02 + 2.1831074449E-02 2.1475809062E-02 2.1126270265E-02 2.0782385275E-02 + 2.0444115841E-02 2.0111373508E-02 1.9784066758E-02 1.9462068697E-02 + 1.9145243997E-02 1.8833590598E-02 1.8527028380E-02 1.8225474479E-02 + 1.7928843269E-02 1.7636952905E-02 1.7349817563E-02 1.7067371509E-02 + 1.6789539913E-02 1.6516245476E-02 1.6247359808E-02 1.5982811518E-02 + 1.5722581767E-02 1.5466603166E-02 1.5214806114E-02 1.4967116953E-02 + 1.4723378333E-02 1.4483616032E-02 1.4247769523E-02 1.4015776305E-02 + 1.3787571887E-02 1.3563051106E-02 1.3342146415E-02 1.3124847757E-02 + 1.2911099151E-02 1.2700842848E-02 1.2494019314E-02 1.2290502671E-02 + 1.2090293497E-02 1.1893354059E-02 1.1699632778E-02 1.1509076483E-02 + 1.1321619331E-02 1.1137157247E-02 1.0955705606E-02 1.0777218459E-02 + 1.0601648447E-02 1.0428946789E-02 1.0259036651E-02 1.0091856576E-02 + 9.9274061406E-03 9.7656432701E-03 9.6065246281E-03 9.4500056081E-03 + 9.2960048318E-03 9.1444890831E-03 8.9954481332E-03 8.8488435842E-03 + 8.7046359123E-03 8.5627844608E-03 8.4232085626E-03 8.2858909371E-03 + 8.1508168888E-03 8.0179514903E-03 7.8872588105E-03 7.7587019092E-03 + 7.6322050317E-03 7.5077566051E-03 7.3853419925E-03 7.2649295244E-03 + 7.1464866384E-03 7.0299798746E-03 6.9153417240E-03 6.8025579795E-03 + 6.6916177587E-03 6.5824924357E-03 6.4751525918E-03 6.3695680107E-03 + 6.2656820661E-03 6.1634712357E-03 6.0629312937E-03 5.9640364449E-03 + 5.8667601907E-03 5.7710753252E-03 5.6769381537E-03 5.5843106621E-03 + 5.4931974191E-03 5.4035752507E-03 5.3154203599E-03 5.2287083230E-03 + 5.1434098717E-03 5.0594687788E-03 4.9768997803E-03 4.8956821190E-03 + 4.8157944869E-03 4.7372150220E-03 4.6599213051E-03 4.5838621307E-03 + 4.5090375337E-03 4.4354374536E-03 4.3630428668E-03 4.2918342606E-03 + 4.2217916304E-03 4.1528822007E-03 4.0850770685E-03 4.0183813155E-03 + 3.9527780072E-03 3.8882497776E-03 3.8247788275E-03 3.7623469216E-03 + 3.7009082742E-03 3.6404704082E-03 3.5810223207E-03 3.5225486012E-03 + 3.4650334570E-03 3.4084607124E-03 3.3528049178E-03 3.2980391006E-03 + 3.2441697846E-03 3.1911833332E-03 3.1390657742E-03 3.0878027987E-03 + 3.0373797587E-03 2.9877641034E-03 2.9389511875E-03 2.8909379581E-03 + 2.8437120887E-03 2.7972609573E-03 2.7515716446E-03 2.7066309326E-03 + 2.6624026263E-03 2.6188968441E-03 2.5761042605E-03 2.5340137731E-03 + 2.4926140192E-03 2.4518933742E-03 2.4118369488E-03 2.3724166399E-03 + 2.3336420418E-03 2.2955034166E-03 2.2579907985E-03 2.2210939931E-03 + 2.1848025759E-03 2.1491007974E-03 2.1139679998E-03 2.0794109580E-03 + 2.0454209566E-03 2.0119890803E-03 1.9791062132E-03 1.9467630375E-03 + 1.9149447857E-03 1.8836339902E-03 1.8528364927E-03 1.8225445192E-03 + 1.7927501202E-03 1.7634451708E-03 1.7346213692E-03 1.7062663468E-03 + 1.6783624620E-03 1.6509161204E-03 1.6239204100E-03 1.5973682657E-03 + 1.5712524689E-03 1.5455656462E-03 + + diff --git a/ABACUS.develop/examples/H2O-deepks/O_gga_7au_60Ry_2s2p1d.orb b/ABACUS.develop/examples/H2O-deepks/O_gga_7au_60Ry_2s2p1d.orb new file mode 100644 index 0000000000..d36d9dc128 --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks/O_gga_7au_60Ry_2s2p1d.orb @@ -0,0 +1,903 @@ +--------------------------------------------------------------------------- +Element O +Energy Cutoff(Ry) 60 +Radius Cutoff(a.u.) 7 +Lmax 2 +Number of Sorbital--> 2 +Number of Porbital--> 2 +Number of Dorbital--> 1 +--------------------------------------------------------------------------- +SUMMARY END + +Mesh 701 +dr 0.01 + Type L N + 0 0 0 + 1.208504975904e+00 1.208605373194e+00 1.208906194767e+00 1.209406330839e+00 + 1.210103935461e+00 1.210996432051e+00 1.212080521101e+00 1.213352190052e+00 + 1.214806725286e+00 1.216438726214e+00 1.218242121389e+00 1.220210186617e+00 + 1.222335564979e+00 1.224610288719e+00 1.227025802911e+00 1.229572990826e+00 + 1.232242200930e+00 1.235023275402e+00 1.237905580090e+00 1.240878035806e+00 + 1.243929150853e+00 1.247047054671e+00 1.250219532508e+00 1.253434060986e+00 + 1.256677844454e+00 1.259937852003e+00 1.263200855037e+00 1.266453465260e+00 + 1.269682172967e+00 1.272873385522e+00 1.276013465884e+00 1.279088771074e+00 + 1.282085690452e+00 1.284990683687e+00 1.287790318310e+00 1.290471306712e+00 + 1.293020542503e+00 1.295425136090e+00 1.297672449397e+00 1.299750129595e+00 + 1.301646141768e+00 1.303348800401e+00 1.304846799603e+00 1.306129241995e+00 + 1.307185666154e+00 1.308006072568e+00 1.308580948012e+00 1.308901288291e+00 + 1.308958619289e+00 1.308745016279e+00 1.308253121443e+00 1.307476159565e+00 + 1.306407951870e+00 1.305042927985e+00 1.303376135990e+00 1.301403250569e+00 + 1.299120579241e+00 1.296525066675e+00 1.293614297106e+00 1.290386494856e+00 + 1.286840522984e+00 1.282975880102e+00 1.278792695375e+00 1.274291721751e+00 + 1.269474327479e+00 1.264342485932e+00 1.258898763833e+00 1.253146307905e+00 + 1.247088830035e+00 1.240730591016e+00 1.234076382930e+00 1.227131510258e+00 + 1.219901769801e+00 1.212393429485e+00 1.204613206140e+00 1.196568242341e+00 + 1.188266082409e+00 1.179714647648e+00 1.170922210923e+00 1.161897370672e+00 + 1.152649024441e+00 1.143186342040e+00 1.133518738417e+00 1.123655846335e+00 + 1.113607488958e+00 1.103383652425e+00 1.092994458510e+00 1.082450137452e+00 + 1.071761001046e+00 1.060937416076e+00 1.049989778166e+00 1.038928486134e+00 + 1.027763916923e+00 1.016506401179e+00 1.005166199535e+00 9.937534796822e-01 + 9.822782942738e-01 9.707505597186e-01 9.591800359220e-01 9.475763070136e-01 + 9.359487631082e-01 9.243065831335e-01 9.126587187607e-01 9.010138794629e-01 + 8.893805187255e-01 8.777668214270e-01 8.661806924029e-01 8.546297462024e-01 + 8.431212980407e-01 8.316623559477e-01 8.202596141073e-01 8.089194473785e-01 + 7.976479069842e-01 7.864507173504e-01 7.753332740738e-01 7.643006429933e-01 + 7.533575603347e-01 7.425084338983e-01 7.317573452518e-01 7.211080528917e-01 + 7.105639963300e-01 7.001283010647e-01 6.898037843852e-01 6.795929619667e-01 + 6.694980552026e-01 6.595209992230e-01 6.496634515475e-01 6.399268013169e-01 + 6.303121790507e-01 6.208204668741e-01 6.114523091586e-01 6.022081235218e-01 + 5.930881121293e-01 5.840922732453e-01 5.752204129759e-01 5.664721571522e-01 + 5.578469633004e-01 5.493441326481e-01 5.409628221155e-01 5.327020562452e-01 + 5.245607390221e-01 5.165376655400e-01 5.086315334724e-01 5.008409543065e-01 + 4.931644643036e-01 4.856005351488e-01 4.781475842592e-01 4.708039847180e-01 + 4.635680748085e-01 4.564381671224e-01 4.494125572203e-01 4.424895318251e-01 + 4.356673765315e-01 4.289443830186e-01 4.223188557530e-01 4.157891181767e-01 + 4.093535183714e-01 4.030104341987e-01 3.967582779147e-01 3.905955002616e-01 + 3.845205940408e-01 3.785320971754e-01 3.726285952702e-01 3.668087236816e-01 + 3.610711691103e-01 3.554146707323e-01 3.498380208855e-01 3.443400653306e-01 + 3.389197031063e-01 3.335758859998e-01 3.283076176573e-01 3.231139523559e-01 + 3.179939934625e-01 3.129468916064e-01 3.079718425888e-01 3.030680850586e-01 + 2.982348979789e-01 2.934715979121e-01 2.887775361507e-01 2.841520957194e-01 + 2.795946882761e-01 2.751047509369e-01 2.706817430510e-01 2.663251429500e-01 + 2.620344446963e-01 2.578091548528e-01 2.536487892964e-01 2.495528700973e-01 + 2.455209224821e-01 2.415524719021e-01 2.376470412212e-01 2.338041480425e-01 + 2.300233021857e-01 2.263040033303e-01 2.226457388361e-01 2.190479817496e-01 + 2.155101890086e-01 2.120317998477e-01 2.086122344148e-01 2.052508925998e-01 + 2.019471530796e-01 1.987003725803e-01 1.955098853571e-01 1.923750028889e-01 + 1.892950137867e-01 1.862691839096e-01 1.832967566851e-01 1.803769536250e-01 + 1.775089750316e-01 1.746920008827e-01 1.719251918891e-01 1.692076907110e-01 + 1.665386233243e-01 1.639171005238e-01 1.613422195507e-01 1.588130658323e-01 + 1.563287148189e-01 1.538882339058e-01 1.514906844251e-01 1.491351236934e-01 + 1.468206071016e-01 1.445461902321e-01 1.423109309892e-01 1.401138917296e-01 + 1.379541413781e-01 1.358307575162e-01 1.337428284304e-01 1.316894551079e-01 + 1.296697531672e-01 1.276828547140e-01 1.257279101100e-01 1.238040896459e-01 + 1.219105851096e-01 1.200466112407e-01 1.182114070645e-01 1.164042370988e-01 + 1.146243924273e-01 1.128711916364e-01 1.111439816100e-01 1.094421381794e-01 + 1.077650666286e-01 1.061122020509e-01 1.044830095586e-01 1.028769843465e-01 + 1.012936516098e-01 9.973256632027e-02 9.819331286249e-02 9.667550453586e-02 + 9.517878292592e-02 9.370281715131e-02 9.224730299217e-02 9.081196190712e-02 + 8.939653994588e-02 8.800080656572e-02 8.662455335980e-02 8.526759270643e-02 + 8.392975634798e-02 8.261089390905e-02 8.131087136337e-02 8.002956945904e-02 + 7.876688211206e-02 7.752271477787e-02 7.629698281079e-02 7.508960982105e-02 + 7.390052603893e-02 7.272966669554e-02 7.157697042927e-02 7.044237772677e-02 + 6.932582940704e-02 6.822726515656e-02 6.714662212340e-02 6.608383357718e-02 + 6.503882764188e-02 6.401152610749e-02 6.300184332609e-02 6.200968519741e-02 + 6.103494824820e-02 6.007751880923e-02 5.913727229295e-02 5.821407257435e-02 + 5.730777147672e-02 5.641820836358e-02 5.554520983723e-02 5.468858954372e-02 + 5.384814808351e-02 5.302367302641e-02 5.221493902883e-02 5.142170805062e-02 + 5.064372966853e-02 4.988074148247e-02 4.913246961043e-02 4.839862926751e-02 + 4.767892542381e-02 4.697305353581e-02 4.628070034542e-02 4.560154474050e-02 + 4.493525867035e-02 4.428150810968e-02 4.363995406407e-02 4.301025360991e-02 + 4.239206096181e-02 4.178502856019e-02 4.118880817199e-02 4.060305199725e-02 + 4.002741377451e-02 3.946154987805e-02 3.890512040018e-02 3.835779021189e-02 + 3.781922999550e-02 3.728911724314e-02 3.676713721524e-02 3.625298385349e-02 + 3.574636064312e-02 3.524698141971e-02 3.475457111613e-02 3.426886644573e-02 + 3.378961651814e-02 3.331658338482e-02 3.284954251156e-02 3.238828317602e-02 + 3.193260878856e-02 3.148233713535e-02 3.103730054297e-02 3.059734596456e-02 + 3.016233498765e-02 2.973214376455e-02 2.930666286665e-02 2.888579706416e-02 + 2.846946503363e-02 2.805759899565e-02 2.765014428579e-02 2.724705886194e-02 + 2.684831275201e-02 2.645388744558e-02 2.606377523410e-02 2.567797850399e-02 + 2.529650898744e-02 2.491938697590e-02 2.454664050137e-02 2.417830449066e-02 + 2.381441989815e-02 2.345503282229e-02 2.310019361138e-02 2.274995596414e-02 + 2.240437603029e-02 2.206351151675e-02 2.172742080447e-02 2.139616208118e-02 + 2.106979249494e-02 2.074836733334e-02 2.043193923274e-02 2.012055742218e-02 + 1.981426700573e-02 1.951310828723e-02 1.921711614086e-02 1.892631943068e-02 + 1.864074048204e-02 1.836039460721e-02 1.808528968752e-02 1.781542581363e-02 + 1.755079498530e-02 1.729138087183e-02 1.703715863360e-02 1.678809480501e-02 + 1.654414723879e-02 1.630526511103e-02 1.607138898614e-02 1.584245094054e-02 + 1.561837474341e-02 1.539907609281e-02 1.518446290469e-02 1.497443565255e-02 + 1.476888775479e-02 1.456770600680e-02 1.437077105450e-02 1.417795790576e-02 + 1.398913647618e-02 1.380417216524e-02 1.362292645883e-02 1.344525755419e-02 + 1.327102100294e-02 1.310007036795e-02 1.293225788984e-02 1.276743515871e-02 + 1.260545378691e-02 1.244616607850e-02 1.228942569134e-02 1.213508828758e-02 + 1.198301216878e-02 1.183305889161e-02 1.168509386064e-02 1.153898689466e-02 + 1.139461276322e-02 1.125185169038e-02 1.111058982280e-02 1.097071965960e-02 + 1.083214044170e-02 1.069475849851e-02 1.055848755032e-02 1.042324896481e-02 + 1.028897196663e-02 1.015559379908e-02 1.002305983731e-02 9.891323652895e-03 + 9.760347029730e-03 9.630099931587e-03 9.500560422003e-03 9.371714537409e-03 + 9.243556114682e-03 9.116086574612e-03 8.989314662992e-03 8.863256151309e-03 + 8.737933499234e-03 8.613375481320e-03 8.489616780520e-03 8.366697551320e-03 + 8.244662955423e-03 8.123562673085e-03 8.003450393317e-03 7.884383286246e-03 + 7.766421461045e-03 7.649627412869e-03 7.534065462274e-03 7.419801190628e-03 + 7.306900874994e-03 7.195430925942e-03 7.085457331716e-03 6.977045112075e-03 + 6.870257785082e-03 6.765156849958e-03 6.661801289045e-03 6.560247091721e-03 + 6.460546803002e-03 6.362749099347e-03 6.266898394024e-03 6.173034474181e-03 + 6.081192171547e-03 5.991401068471e-03 5.903685240785e-03 5.818063038717e-03 + 5.734546906854e-03 5.653143243903e-03 5.573852302742e-03 5.496668131005e-03 + 5.421578552205e-03 5.348565187130e-03 5.277603515021e-03 5.208662973798e-03 + 5.141707098353e-03 5.076693695733e-03 5.013575055786e-03 4.952298195673e-03 + 4.892805136420e-03 4.835033209538e-03 4.778915391542e-03 4.724380664074e-03 + 4.671354397171e-03 4.619758753123e-03 4.569513108242e-03 4.520534489798e-03 + 4.472738025270e-03 4.426037401063e-03 4.380345327754e-03 4.335574008947e-03 + 4.291635610817e-03 4.248442729424e-03 4.205908852936e-03 4.163948815945e-03 + 4.122479243134e-03 4.081418979636e-03 4.040689505537e-03 4.000215332093e-03 + 3.959924377344e-03 3.919748318979e-03 3.879622922454e-03 3.839488342509e-03 + 3.799289396459e-03 3.758975807751e-03 3.718502418544e-03 3.677829370213e-03 + 3.636922250914e-03 3.595752209542e-03 3.554296035627e-03 3.512536204937e-03 + 3.470460890733e-03 3.428063940894e-03 3.385344821255e-03 3.342308525792e-03 + 3.298965454405e-03 3.255331259306e-03 3.211426661165e-03 3.167277236356e-03 + 3.122913176816e-03 3.078369024163e-03 3.033683379905e-03 2.988898593658e-03 + 2.944060431442e-03 2.899217726215e-03 2.854422012908e-03 2.809727150291e-03 + 2.765188932058e-03 2.720864689603e-03 2.676812888925e-03 2.633092724193e-03 + 2.589763710440e-03 2.546885277886e-03 2.504516370328e-03 2.462715050026e-03 + 2.421538111419e-03 2.381040705966e-03 2.341275980300e-03 2.302294729807e-03 + 2.264145069601e-03 2.226872124780e-03 2.190517741691e-03 2.155120221810e-03 + 2.120714079669e-03 2.087329826143e-03 2.054993778194e-03 2.023727896059e-03 + 1.993549648638e-03 1.964471907708e-03 1.936502871376e-03 1.909646017015e-03 + 1.883900083759e-03 1.859259084424e-03 1.835712346564e-03 1.813244582206e-03 + 1.791835985597e-03 1.771462358179e-03 1.752095259818e-03 1.733702185159e-03 + 1.716246763861e-03 1.699688983301e-03 1.683985432221e-03 1.669089563689e-03 + 1.654951975612e-03 1.641520706971e-03 1.628741547856e-03 1.616558361306e-03 + 1.604913414903e-03 1.593747720042e-03 1.583001376732e-03 1.572613921806e-03 + 1.562524678386e-03 1.552673104465e-03 1.542999138498e-03 1.533443539901e-03 + 1.523948222454e-03 1.514456578601e-03 1.504913792757e-03 1.495267141793e-03 + 1.485466280966e-03 1.475463513657e-03 1.465214043408e-03 1.454676206835e-03 + 1.443811686166e-03 1.432585700244e-03 1.420967172999e-03 1.408928878533e-03 + 1.396447562101e-03 1.383504036449e-03 1.370083253078e-03 1.356174348211e-03 + 1.341770663359e-03 1.326869740553e-03 1.311473292454e-03 1.295587147713e-03 + 1.279221172095e-03 1.262389166021e-03 1.245108739338e-03 1.227401164224e-03 + 1.209291207305e-03 1.190806942140e-03 1.171979543369e-03 1.152843063897e-03 + 1.133434196599e-03 1.113792022102e-03 1.093957744276e-03 1.073974415121e-03 + 1.053886650808e-03 1.033740340637e-03 1.013582350744e-03 9.934602243832e-04 + 9.734218806000e-04 9.535153131592e-04 9.337882915143e-04 9.142880656187e-04 + 8.950610763245e-04 8.761526730687e-04 8.576068404897e-04 8.394659355465e-04 + 8.217704366397e-04 8.045587061422e-04 7.878667676593e-04 7.717280992330e-04 + 7.561734436003e-04 7.412306364994e-04 7.269244539011e-04 7.132764789180e-04 + 7.003049890184e-04 6.880248640422e-04 6.764475153823e-04 6.655808365672e-04 + 6.554291753423e-04 6.459933272172e-04 6.372705503164e-04 6.292546012396e-04 + 6.219357915110e-04 6.153010640793e-04 6.093340892045e-04 6.040153789622e-04 + 5.993224194821e-04 5.952298199426e-04 5.917094772441e-04 5.887307552009e-04 + 5.862606770110e-04 5.842641296934e-04 5.827040791224e-04 5.815417942331e-04 + 5.807370789334e-04 5.802485102196e-04 5.800336809728e-04 5.800494458981e-04 + 5.802521690611e-04 5.805979714881e-04 5.810429773026e-04 5.815435569042e-04 + 5.820565657210e-04 5.825395771157e-04 5.829511080708e-04 5.832508363431e-04 + 5.833998078379e-04 5.833606330338e-04 5.830976713629e-04 5.825772025437e-04 + 5.817675839497e-04 5.806393931961e-04 5.791655552238e-04 5.773214532596e-04 + 5.750850231309e-04 5.724368305124e-04 5.693601307693e-04 5.658409111446e-04 + 5.618679151054e-04 5.574326486993e-04 5.525293687938e-04 5.471550530319e-04 + 5.413093512624e-04 5.349945180493e-04 5.282153256417e-04 5.209789564670e-04 + 5.132948738062e-04 5.051746688210e-04 4.966318815478e-04 4.876817929151e-04 + 4.783411843418e-04 4.686280611573e-04 4.585613361105e-04 4.481604698002e-04 + 4.374450661976e-04 4.264344238016e-04 4.151470466072e-04 4.036001241663e-04 + 3.918089966647e-04 3.797866290408e-04 3.675431274054e-04 3.550853407791e-04 + 3.424166004890e-04 3.295366571895e-04 3.164418798350e-04 3.031257803019e-04 + 2.895799200289e-04 2.757952395507e-04 2.617638272220e-04 2.474811096748e-04 + 2.329484046492e-04 2.181757290843e-04 2.031847053963e-04 1.880113615581e-04 + 1.727085816573e-04 1.573479391175e-04 1.420206404514e-04 1.268373278303e-04 + 1.119265365508e-04 9.743167866898e-05 8.350652361154e-05 7.030926427376e-05 + 5.799538389723e-05 4.670966361885e-05 3.657778061112e-05 2.769802994764e-05 + 2.013374906341e-05 1.390702415828e-05 8.994209321926e-06 5.323692408431e-06 + 2.776202480590e-06 1.187782192828e-06 3.553586242532e-07 4.465396560257e-08 + 0.000000000000e+00 + Type L N + 0 0 1 + 7.254873428942e-01 7.256666701836e-01 7.262040651787e-01 7.270977689660e-01 + 7.283448557011e-01 7.299412411073e-01 7.318816943340e-01 7.341598531361e-01 + 7.367682423256e-01 7.396982954341e-01 7.429403795151e-01 7.464838230058e-01 + 7.503169465575e-01 7.544270967320e-01 7.588006824578e-01 7.634232141234e-01 + 7.682793451844e-01 7.733529161466e-01 7.786270007853e-01 7.840839544493e-01 + 7.897054642959e-01 7.954726012944e-01 8.013658738321e-01 8.073652827510e-01 + 8.134503776412e-01 8.196003142102e-01 8.257939125497e-01 8.320097161138e-01 + 8.382260512257e-01 8.444210869251e-01 8.505728949734e-01 8.566595098284e-01 + 8.626589884062e-01 8.685494694476e-01 8.743092323085e-01 8.799167549976e-01 + 8.853507712889e-01 8.905903267386e-01 8.956148334429e-01 9.004041233778e-01 + 9.049385001677e-01 9.091987891354e-01 9.131663854946e-01 9.168233005512e-01 + 9.201522057895e-01 9.231364747249e-01 9.257602224156e-01 9.280083425331e-01 + 9.298665419008e-01 9.313213724179e-01 9.323602602985e-01 9.329715325607e-01 + 9.331444407159e-01 9.328691816115e-01 9.321369153974e-01 9.309397805906e-01 + 9.292709062264e-01 9.271244210907e-01 9.244954600412e-01 9.213801674334e-01 + 9.177756976756e-01 9.136802129486e-01 9.090928781328e-01 9.040138529968e-01 + 8.984442817063e-01 8.923862797242e-01 8.858429181782e-01 8.788182057798e-01 + 8.713170683877e-01 8.633453263117e-01 8.549096694633e-01 8.460176304626e-01 + 8.366775558156e-01 8.268985752843e-01 8.166905695723e-01 8.060641364551e-01 + 7.950305554857e-01 7.836017514115e-01 7.717902564368e-01 7.596091714706e-01 + 7.470721264985e-01 7.341932402185e-01 7.209870790813e-01 7.074686158739e-01 + 6.936531879864e-01 6.795564554976e-01 6.651943592171e-01 6.505830788149e-01 + 6.357389911700e-01 6.206786290648e-01 6.054186403485e-01 5.899757476891e-01 + 5.743667090281e-01 5.586082788498e-01 5.427171703685e-01 5.267100187338e-01 + 5.106033453488e-01 4.944135233878e-01 4.781567445972e-01 4.618489874536e-01 + 4.455059867492e-01 4.291432046671e-01 4.127758034017e-01 3.964186193738e-01 + 3.800861390819e-01 3.637924766262e-01 3.475513529322e-01 3.313760766971e-01 + 3.152795270720e-01 2.992741380906e-01 2.833718848433e-01 2.675842713943e-01 + 2.519223204291e-01 2.363965646160e-01 2.210170396586e-01 2.057932790105e-01 + 1.907343102184e-01 1.758486528546e-01 1.611443179941e-01 1.466288091897e-01 + 1.323091248895e-01 1.181917622427e-01 1.042827222321e-01 9.058751606940e-02 + 7.711117278740e-02 6.385824796008e-02 5.083283347819e-02 3.803856830806e-02 + 2.547865015811e-02 1.315584797747e-02 1.072515209469e-03 -1.076939627721e-02 + -2.236832165731e-02 -3.372306809514e-02 -4.483279924503e-02 -5.569701938217e-02 + -6.631555723891e-02 -7.668854962018e-02 -8.681642487002e-02 -9.669988625927e-02 + -1.063398953624e-01 -1.157376554889e-01 -1.248945952324e-01 -1.338123521969e-01 + -1.424927569584e-01 -1.509378173145e-01 -1.591497028740e-01 -1.671307300327e-01 + -1.748833473792e-01 -1.824101215717e-01 -1.897137237212e-01 -1.967969163142e-01 + -2.036625407039e-01 -2.103135051948e-01 -2.167527737423e-01 -2.229833552850e-01 + -2.290082937227e-01 -2.348306585525e-01 -2.404535361667e-01 -2.458800218186e-01 + -2.511132122536e-01 -2.561561990045e-01 -2.610120623413e-01 -2.656838658696e-01 + -2.701746517613e-01 -2.744874366059e-01 -2.786252078613e-01 -2.825909208870e-01 + -2.863874965356e-01 -2.900178192788e-01 -2.934847358419e-01 -2.967910543192e-01 + -2.999395437417e-01 -3.029329340652e-01 -3.057739165503e-01 -3.084651444993e-01 + -3.110092343197e-01 -3.134087668802e-01 -3.156662891257e-01 -3.177843159192e-01 + -3.197653320763e-01 -3.216117945603e-01 -3.233261348050e-01 -3.249107611349e-01 + -3.263680612502e-01 -3.277004047483e-01 -3.289101456532e-01 -3.299996249235e-01 + -3.309711729154e-01 -3.318271117747e-01 -3.325697577341e-01 -3.332014232962e-01 + -3.337244192811e-01 -3.341410567201e-01 -3.344536485814e-01 -3.346645113114e-01 + -3.347759661800e-01 -3.347903404196e-01 -3.347099681484e-01 -3.345371910720e-01 + -3.342743589580e-01 -3.339238298800e-01 -3.334879702312e-01 -3.329691545064e-01 + -3.323697648556e-01 -3.316921904132e-01 -3.309388264076e-01 -3.301120730579e-01 + -3.292143342673e-01 -3.282480161213e-01 -3.272155252025e-01 -3.261192667336e-01 + -3.249616425617e-01 -3.237450489978e-01 -3.224718745253e-01 -3.211444973951e-01 + -3.197652831201e-01 -3.183365818881e-01 -3.168607259083e-01 -3.153400267090e-01 + -3.137767724032e-01 -3.121732249392e-01 -3.105316173529e-01 -3.088541510394e-01 + -3.071429930586e-01 -3.054002734930e-01 -3.036280828708e-01 -3.018284696709e-01 + -3.000034379238e-01 -2.981549449206e-01 -2.962848990445e-01 -2.943951577350e-01 + -2.924875255971e-01 -2.905637526640e-01 -2.886255328226e-01 -2.866745024101e-01 + -2.847122389875e-01 -2.827402602961e-01 -2.807600234008e-01 -2.787729240243e-01 + -2.767802960736e-01 -2.747834113602e-01 -2.727834795133e-01 -2.707816480860e-01 + -2.687790028506e-01 -2.667765682807e-01 -2.647753082159e-01 -2.627761267031e-01 + -2.607798690080e-01 -2.587873227913e-01 -2.567992194399e-01 -2.548162355453e-01 + -2.528389945197e-01 -2.508680683408e-01 -2.489039794130e-01 -2.469472025355e-01 + -2.449981669661e-01 -2.430572585677e-01 -2.411248220269e-01 -2.392011631321e-01 + -2.372865510986e-01 -2.353812209292e-01 -2.334853757975e-01 -2.315991894418e-01 + -2.297228085585e-01 -2.278563551823e-01 -2.259999290424e-01 -2.241536098838e-01 + -2.223174597432e-01 -2.204915251685e-01 -2.186758393743e-01 -2.168704243221e-01 + -2.150752927189e-01 -2.132904499255e-01 -2.115158957672e-01 -2.097516262416e-01 + -2.079976351174e-01 -2.062539154195e-01 -2.045204607963e-01 -2.027972667658e-01 + -2.010843318391e-01 -1.993816585181e-01 -1.976892541676e-01 -1.960071317613e-01 + -1.943353105025e-01 -1.926738163205e-01 -1.910226822449e-01 -1.893819486610e-01 + -1.877516634493e-01 -1.861318820128e-01 -1.845226671970e-01 -1.829240891082e-01 + -1.813362248350e-01 -1.797591580790e-01 -1.781929787019e-01 -1.766377821957e-01 + -1.750936690819e-01 -1.735607442486e-01 -1.720391162332e-01 -1.705288964560e-01 + -1.690301984164e-01 -1.675431368557e-01 -1.660678268972e-01 -1.646043831701e-01 + -1.631529189255e-01 -1.617135451510e-01 -1.602863696932e-01 -1.588714963937e-01 + -1.574690242455e-01 -1.560790465776e-01 -1.547016502729e-01 -1.533369150254e-01 + -1.519849126425e-01 -1.506457063969e-01 -1.493193504333e-01 -1.480058892333e-01 + -1.467053571418e-01 -1.454177779589e-01 -1.441431645988e-01 -1.428815188187e-01 + -1.416328310171e-01 -1.403970801058e-01 -1.391742334519e-01 -1.379642468930e-01 + -1.367670648229e-01 -1.355826203479e-01 -1.344108355108e-01 -1.332516215814e-01 + -1.321048794113e-01 -1.309704998483e-01 -1.298483642091e-01 -1.287383448054e-01 + -1.276403055193e-01 -1.265541024246e-01 -1.254795844485e-01 -1.244165940690e-01 + -1.233649680437e-01 -1.223245381637e-01 -1.212951320287e-01 -1.202765738365e-01 + -1.192686851828e-01 -1.182712858649e-01 -1.172841946847e-01 -1.163072302453e-01 + -1.153402117357e-01 -1.143829596997e-01 -1.134352967825e-01 -1.124970484522e-01 + -1.115680436898e-01 -1.106481156450e-01 -1.097371022529e-01 -1.088348468094e-01 + -1.079411984998e-01 -1.070560128798e-01 -1.061791523053e-01 -1.053104863089e-01 + -1.044498919210e-01 -1.035972539354e-01 -1.027524651161e-01 -1.019154263471e-01 + -1.010860467232e-01 -1.002642435825e-01 -9.944994248185e-02 -9.864307711501e-02 + -9.784358917552e-02 -9.705142816589e-02 -9.626655115497e-02 -9.548892248592e-02 + -9.471851343733e-02 -9.395530184054e-02 -9.319927165621e-02 -9.245041251371e-02 + -9.170871921683e-02 -9.097419121975e-02 -9.024683207723e-02 -8.952664887308e-02 + -8.881365163121e-02 -8.810785271354e-02 -8.740926620906e-02 -8.671790731849e-02 + -8.603379173875e-02 -8.535693505166e-02 -8.468735212103e-02 -8.402505650228e-02 + -8.337005986852e-02 -8.272237145706e-02 -8.208199753993e-02 -8.144894092187e-02 + -8.082320046907e-02 -8.020477067166e-02 -7.959364124268e-02 -7.898979675599e-02 + -7.839321632536e-02 -7.780387332648e-02 -7.722173516368e-02 -7.664676308235e-02 + -7.607891202816e-02 -7.551813055364e-02 -7.496436077230e-02 -7.441753836036e-02 + -7.387759260550e-02 -7.334444650219e-02 -7.281801689227e-02 -7.229821464967e-02 + -7.178494490761e-02 -7.127810732620e-02 -7.077759639858e-02 -7.028330179286e-02 + -6.979510872749e-02 -6.931289837697e-02 -6.883654830505e-02 -6.836593292207e-02 + -6.790092396314e-02 -6.744139098370e-02 -6.698720186881e-02 -6.653822335263e-02 + -6.609432154426e-02 -6.565536245638e-02 -6.522121253286e-02 -6.479173917170e-02 + -6.436681123969e-02 -6.394629957521e-02 -6.353007747576e-02 -6.311802116687e-02 + -6.271001024920e-02 -6.230592812088e-02 -6.190566237223e-02 -6.150910515026e-02 + -6.111615349049e-02 -6.072670961410e-02 -6.034068118830e-02 -5.995798154845e-02 + -5.957852988044e-02 -5.920225136233e-02 -5.882907726438e-02 -5.845894500696e-02 + -5.809179817626e-02 -5.772758649759e-02 -5.736626576701e-02 -5.700779774157e-02 + -5.665214998938e-02 -5.629929570062e-02 -5.594921346095e-02 -5.560188698908e-02 + -5.525730484048e-02 -5.491546007952e-02 -5.457634992227e-02 -5.423997535275e-02 + -5.390634071546e-02 -5.357545328686e-02 -5.324732282934e-02 -5.292196113045e-02 + -5.259938153099e-02 -5.227959844527e-02 -5.196262687686e-02 -5.164848193346e-02 + -5.133717834423e-02 -5.102872998301e-02 -5.072314940095e-02 -5.042044737174e-02 + -5.012063245275e-02 -4.982371056520e-02 -4.952968459635e-02 -4.923855402661e-02 + -4.895031458408e-02 -4.866495792929e-02 -4.838247137211e-02 -4.810283762315e-02 + -4.782603458131e-02 -4.755203515910e-02 -4.728080714718e-02 -4.701231311894e-02 + -4.674651037613e-02 -4.648335093590e-02 -4.622278155957e-02 -4.596474382297e-02 + -4.570917422813e-02 -4.545600435556e-02 -4.520516105632e-02 -4.495656668270e-02 + -4.471013935597e-02 -4.446579326960e-02 -4.422343902605e-02 -4.398298400479e-02 + -4.374433275935e-02 -4.350738744073e-02 -4.327204824428e-02 -4.303821387741e-02 + -4.280578204466e-02 -4.257464994722e-02 -4.234471479342e-02 -4.211587431678e-02 + -4.188802729821e-02 -4.166107408881e-02 -4.143491712971e-02 -4.120946146551e-02 + -4.098461524766e-02 -4.076029022453e-02 -4.053640221469e-02 -4.031287156008e-02 + -4.008962355603e-02 -3.986658885506e-02 -3.964370384156e-02 -3.942091097474e-02 + -3.919815909734e-02 -3.897540370783e-02 -3.875260719405e-02 -3.852973902653e-02 + -3.830677590993e-02 -3.808370189129e-02 -3.786050842416e-02 -3.763719438785e-02 + -3.741376606137e-02 -3.719023705192e-02 -3.696662817818e-02 -3.674296730868e-02 + -3.651928915615e-02 -3.629563502882e-02 -3.607205254002e-02 -3.584859527756e-02 + -3.562532243500e-02 -3.540229840658e-02 -3.517959234853e-02 -3.495727770905e-02 + -3.473543172998e-02 -3.451413492302e-02 -3.429347052373e-02 -3.407352392670e-02 + -3.385438210523e-02 -3.363613301929e-02 -3.341886501524e-02 -3.320266622131e-02 + -3.298762394241e-02 -3.277382405822e-02 -3.256135042847e-02 -3.235028430897e-02 + -3.214070378242e-02 -3.193268320750e-02 -3.172629268990e-02 -3.152159757872e-02 + -3.131865799163e-02 -3.111752837185e-02 -3.091825708000e-02 -3.072088602362e-02 + -3.052545032675e-02 -3.033197804211e-02 -3.014048990770e-02 -2.995099914979e-02 + -2.976351133363e-02 -2.957802426325e-02 -2.939452793110e-02 -2.921300451825e-02 + -2.903342844527e-02 -2.885576647395e-02 -2.867997785924e-02 -2.850601455098e-02 + -2.833382144417e-02 -2.816333667671e-02 -2.799449197269e-02 -2.782721302956e-02 + -2.766141994684e-02 -2.749702769383e-02 -2.733394661371e-02 -2.717208296080e-02 + -2.701133946797e-02 -2.685161594061e-02 -2.669280987347e-02 -2.653481708672e-02 + -2.637753237709e-02 -2.622085018006e-02 -2.606466523893e-02 -2.590887327648e-02 + -2.575337166480e-02 -2.559806008909e-02 -2.544284120097e-02 -2.528762125705e-02 + -2.513231073838e-02 -2.497682494674e-02 -2.482108457356e-02 -2.466501623762e-02 + -2.450855298765e-02 -2.435163476629e-02 -2.419420883202e-02 -2.403623013573e-02 + -2.387766164928e-02 -2.371847464307e-02 -2.355864891050e-02 -2.339817293711e-02 + -2.323704401269e-02 -2.307526828495e-02 -2.291286075357e-02 -2.274984520407e-02 + -2.258625408096e-02 -2.242212830027e-02 -2.225751700172e-02 -2.209247724135e-02 + -2.192707362565e-02 -2.176137788862e-02 -2.159546841364e-02 -2.142942970219e-02 + -2.126335179210e-02 -2.109732962799e-02 -2.093146238710e-02 -2.076585276399e-02 + -2.060060621782e-02 -2.043583018613e-02 -2.027163326949e-02 -2.010812439128e-02 + -1.994541193741e-02 -1.978360288077e-02 -1.962280189525e-02 -1.946311046452e-02 + -1.930462599078e-02 -1.914744090855e-02 -1.899164180891e-02 -1.883730857935e-02 + -1.868451356458e-02 -1.853332075332e-02 -1.838378499630e-02 -1.823595126041e-02 + -1.808985392377e-02 -1.794551611644e-02 -1.780294911118e-02 -1.766215176856e-02 + -1.752311004029e-02 -1.738579653452e-02 -1.725017014658e-02 -1.711617575804e-02 + -1.698374400709e-02 -1.685279113236e-02 -1.672321889232e-02 -1.659491456194e-02 + -1.646775100755e-02 -1.634158684107e-02 -1.621626665358e-02 -1.609162132846e-02 + -1.596746843346e-02 -1.584361269051e-02 -1.571984652213e-02 -1.559595067190e-02 + -1.547169489659e-02 -1.534683872624e-02 -1.522113228779e-02 -1.509431718645e-02 + -1.496612743749e-02 -1.483629043856e-02 -1.470452796987e-02 -1.457055720485e-02 + -1.443409170812e-02 -1.429484238992e-02 -1.415251837503e-02 -1.400682773128e-02 + -1.385747798508e-02 -1.370417633100e-02 -1.354662941759e-02 -1.338454256474e-02 + -1.321761823931e-02 -1.304555358959e-02 -1.286803681889e-02 -1.268474217206e-02 + -1.249532332271e-02 -1.229940499551e-02 -1.209657274723e-02 -1.188636097593e-02 + -1.166823943872e-02 -1.144159884417e-02 -1.120573644391e-02 -1.095984297292e-02 + -1.070299275375e-02 -1.043413925187e-02 -1.015211878805e-02 -9.855665409747e-03 + -9.543440008834e-03 -9.214076556271e-03 -8.866247718325e-03 -8.498751054188e-03 + -8.110615439050e-03 -7.701225329127e-03 -7.270458073131e-03 -6.818826842202e-03 + -6.347619139072e-03 -5.859018565355e-03 -5.356195924376e-03 -4.843355172226e-03 + -4.325720516624e-03 -3.809453321228e-03 -3.301491475836e-03 -2.809309425588e-03 + -2.340603789462e-03 -1.902916906830e-03 -1.503218023709e-03 -1.147468351328e-03 + -8.402010638750e-04 -5.841497027245e-04 -3.799578710602e-04 -2.259992769873e-04 + -1.183302128984e-04 -5.078691996859e-05 -1.522880477927e-05 -1.916246212603e-06 + 0.000000000000e+00 + Type L N + 0 1 0 + 0.000000000000e+00 4.626669306440e-02 9.247677643884e-02 1.385737661495e-01 + 1.845014292772e-01 2.302039085422e-01 2.756258457606e-01 3.207125038039e-01 + 3.654098866971e-01 4.096648574975e-01 4.534252536048e-01 4.966399991622e-01 + 5.392592142182e-01 5.812343203311e-01 6.225181423090e-01 6.630650057955e-01 + 7.028308304215e-01 7.417732182629e-01 7.798515373591e-01 8.170270000629e-01 + 8.532627360156e-01 8.885238595536e-01 9.227775313771e-01 9.559930143289e-01 + 9.881417231541e-01 1.019197268128e+00 1.049135492469e+00 1.077934503457e+00 + 1.105574697231e+00 1.132038777224e+00 1.157311766233e+00 1.181381012159e+00 + 1.204236187438e+00 1.225869282229e+00 1.246274591448e+00 1.265448695731e+00 + 1.283390436474e+00 1.300100885050e+00 1.315583306407e+00 1.329843117176e+00 + 1.342887838522e+00 1.354727043913e+00 1.365372302051e+00 1.374837115191e+00 + 1.383136853106e+00 1.390288682952e+00 1.396311495311e+00 1.401225826696e+00 + 1.405053778803e+00 1.407818934819e+00 1.409546273083e+00 1.410262078416e+00 + 1.409993851433e+00 1.408770216150e+00 1.406620826218e+00 1.403576270089e+00 + 1.399667975436e+00 1.394928113157e+00 1.389389501250e+00 1.383085508897e+00 + 1.376049961044e+00 1.368317043767e+00 1.359921210742e+00 1.350897091066e+00 + 1.341279398726e+00 1.331102843968e+00 1.320402046811e+00 1.309211452959e+00 + 1.297565252319e+00 1.285497300354e+00 1.273041042453e+00 1.260229441521e+00 + 1.247094908937e+00 1.233669239051e+00 1.219983547349e+00 1.206068212405e+00 + 1.191952821741e+00 1.177666121662e+00 1.163235971158e+00 1.148689299921e+00 + 1.134052070515e+00 1.119349244734e+00 1.104604754140e+00 1.089841474788e+00 + 1.075081206110e+00 1.060344653911e+00 1.045651417444e+00 1.031019980477e+00 + 1.016467706281e+00 1.002010836454e+00 9.876644934525e-01 9.734426867397e-01 + 9.593583224036e-01 9.454232161144e-01 9.316481092715e-01 9.180426881845e-01 + 9.046156061222e-01 8.913745080609e-01 8.783260579512e-01 8.654759683243e-01 + 8.528290320477e-01 8.403891560415e-01 8.281593967612e-01 8.161419972524e-01 + 8.043384255816e-01 7.927494144461e-01 7.813750017691e-01 7.702145720852e-01 + 7.592668985250e-01 7.485301852117e-01 7.380021098828e-01 7.276798665597e-01 + 7.175602080880e-01 7.076394883814e-01 6.979137042049e-01 6.883785363434e-01 + 6.790293900054e-01 6.698614343236e-01 6.608696408190e-01 6.520488207049e-01 + 6.433936609179e-01 6.348987587694e-01 6.265586551227e-01 6.183678660090e-01 + 6.103209126074e-01 6.024123495215e-01 5.946367912964e-01 5.869889371295e-01 + 5.794635937392e-01 5.720556963634e-01 5.647603278708e-01 5.575727359769e-01 + 5.504883485661e-01 5.435027871291e-01 5.366118783351e-01 5.298116637647e-01 + 5.230984078384e-01 5.164686039829e-01 5.099189790850e-01 5.034464962871e-01 + 4.970483561883e-01 4.907219965172e-01 4.844650903499e-01 4.782755429504e-01 + 4.721514873143e-01 4.660912785021e-01 4.600934868494e-01 4.541568901450e-01 + 4.482804648686e-01 4.424633765848e-01 4.367049695852e-01 4.310047558766e-01 + 4.253624036096e-01 4.197777250424e-01 4.142506641348e-01 4.087812838625e-01 + 4.033697533448e-01 3.980163348711e-01 3.927213709139e-01 3.874852712079e-01 + 3.823084999769e-01 3.771915633804e-01 3.721349972533e-01 3.671393552038e-01 + 3.622051971318e-01 3.573330782258e-01 3.525235384903e-01 3.477770928499e-01 + 3.430942218749e-01 3.384753631632e-01 3.339209034105e-01 3.294311711968e-01 + 3.250064305082e-01 3.206468750123e-01 3.163526230955e-01 3.121237136700e-01 + 3.079601027506e-01 3.038616607970e-01 2.998281708131e-01 2.958593271912e-01 + 2.919547352822e-01 2.881139116717e-01 2.843362851372e-01 2.806211982569e-01 + 2.769679096388e-01 2.733755967358e-01 2.698433592092e-01 2.663702228010e-01 + 2.629551436727e-01 2.595970131682e-01 2.562946629558e-01 2.530468705019e-01 + 2.498523648317e-01 2.467098325280e-01 2.436179239222e-01 2.405752594280e-01 + 2.375804359731e-01 2.346320334812e-01 2.317286213597e-01 2.288687649482e-01 + 2.260510318856e-01 2.232739983553e-01 2.205362551671e-01 2.178364136421e-01 + 2.151731112625e-01 2.125450170553e-01 2.099508366804e-01 2.073893171946e-01 + 2.048592514678e-01 2.023594822299e-01 1.998889057289e-01 1.974464749851e-01 + 1.950312026290e-01 1.926421633118e-01 1.902784956831e-01 1.879394039318e-01 + 1.856241588886e-01 1.833320986932e-01 1.810626290297e-01 1.788152229396e-01 + 1.765894202199e-01 1.743848264217e-01 1.722011114618e-01 1.700380078656e-01 + 1.678953086602e-01 1.657728649384e-01 1.636705831165e-01 1.615884219095e-01 + 1.595263890502e-01 1.574845377777e-01 1.554629631231e-01 1.534617980220e-01 + 1.514812092796e-01 1.495213934218e-01 1.475825724573e-01 1.456649895836e-01 + 1.437689048635e-01 1.418945909028e-01 1.400423285557e-01 1.382124026860e-01 + 1.364050980113e-01 1.346206950549e-01 1.328594662287e-01 1.311216720732e-01 + 1.294075576724e-01 1.277173492659e-01 1.260512510763e-01 1.244094423676e-01 + 1.227920747499e-01 1.211992697433e-01 1.196311166126e-01 1.180876704799e-01 + 1.165689507245e-01 1.150749396739e-01 1.136055815889e-01 1.121607819445e-01 + 1.107404070054e-01 1.093442836937e-01 1.079721997437e-01 1.066239041386e-01 + 1.052991078190e-01 1.039974846564e-01 1.027186726775e-01 1.014622755288e-01 + 1.002278641668e-01 9.901497875795e-02 9.782313077323e-02 9.665180525899e-02 + 9.550046326660e-02 9.436854442164e-02 9.325546961334e-02 9.216064378426e-02 + 9.108345880003e-02 9.002329637868e-02 8.897953105904e-02 8.795153318799e-02 + 8.693867190608e-02 8.594031811199e-02 8.495584738619e-02 8.398464285514e-02 + 8.302609797786e-02 8.207961923751e-02 8.114462872159e-02 8.022056657532e-02 + 7.930689331374e-02 7.840309197944e-02 7.750867013367e-02 7.662316167031e-02 + 7.574612844318e-02 7.487716169847e-02 7.401588330588e-02 7.316194678300e-02 + 7.231503810912e-02 7.147487632614e-02 7.064121392554e-02 6.981383702175e-02 + 6.899256531393e-02 6.817725183911e-02 6.736778252125e-02 6.656407552203e-02 + 6.576608040015e-02 6.497377708742e-02 6.418717469067e-02 6.340631012970e-02 + 6.263124662243e-02 6.186207202910e-02 6.109889706828e-02 6.034185341798e-02 + 5.959109171580e-02 5.884677947253e-02 5.810909891384e-02 5.737824476519e-02 + 5.665442199500e-02 5.593784353143e-02 5.522872796790e-02 5.452729727241e-02 + 5.383377451555e-02 5.314838163169e-02 5.247133722744e-02 5.180285445101e-02 + 5.114313893551e-02 5.049238682857e-02 4.985078291990e-02 4.921849887774e-02 + 4.859569160412e-02 4.798250171810e-02 4.737905217510e-02 4.678544702965e-02 + 4.620177034738e-02 4.562808527175e-02 4.506443324922e-02 4.451083341594e-02 + 4.396728214785e-02 4.343375277482e-02 4.291019545869e-02 4.239653723369e-02 + 4.189268220694e-02 4.139851191555e-02 4.091388583593e-02 4.043864204001e-02 + 3.997259799209e-02 3.951555147938e-02 3.906728166825e-02 3.862755027772e-02 + 3.819610286095e-02 3.777267018490e-02 3.735696969794e-02 3.694870707447e-02 + 3.654757782553e-02 3.615326896400e-02 3.576546071256e-02 3.538382824290e-02 + 3.500804343402e-02 3.463777663802e-02 3.427269844162e-02 3.391248141169e-02 + 3.355680181363e-02 3.320534129149e-02 3.285778849928e-02 3.251384067318e-02 + 3.217320513500e-02 3.183560071786e-02 3.150075910546e-02 3.116842607708e-02 + 3.083836265137e-02 3.051034612224e-02 3.018417098153e-02 2.985964972338e-02 + 2.953661352651e-02 2.921491281118e-02 2.889441766852e-02 2.857501816086e-02 + 2.825662449243e-02 2.793916705072e-02 2.762259631970e-02 2.730688266665e-02 + 2.699201600563e-02 2.667800534077e-02 2.636487819401e-02 2.605267992196e-02 + 2.574147292769e-02 2.543133577365e-02 2.512236220262e-02 2.481466007401e-02 + 2.450835022332e-02 2.420356525313e-02 2.390044826409e-02 2.359915153494e-02 + 2.329983516064e-02 2.300266565796e-02 2.270781454790e-02 2.241545692458e-02 + 2.212577001985e-02 2.183893177319e-02 2.155511941611e-02 2.127450808001e-02 + 2.099726943654e-02 2.072357037869e-02 2.045357175104e-02 2.018742713666e-02 + 1.992528170814e-02 1.966727114943e-02 1.941352065482e-02 1.916414401067e-02 + 1.891924276507e-02 1.867890548977e-02 1.844320713834e-02 1.821220850348e-02 + 1.798595577619e-02 1.776448020835e-02 1.754779787984e-02 1.733590957064e-02 + 1.712880073748e-02 1.692644159407e-02 1.672878729330e-02 1.653577820895e-02 + 1.634734031411e-02 1.616338565257e-02 1.598381289929e-02 1.580850800495e-02 + 1.563734491978e-02 1.547018639065e-02 1.530688482563e-02 1.514728321942e-02 + 1.499121613292e-02 1.483851071980e-02 1.468898779289e-02 1.454246292273e-02 + 1.439874756077e-02 1.425765017942e-02 1.411897742129e-02 1.398253524971e-02 + 1.384813009314e-02 1.371556997561e-02 1.358466562605e-02 1.345523155923e-02 + 1.332708712145e-02 1.320005749427e-02 1.307397465026e-02 1.294867825452e-02 + 1.282401650690e-02 1.269984691961e-02 1.257603702582e-02 1.245246501512e-02 + 1.232902029249e-02 1.220560395758e-02 1.208212920209e-02 1.195852162325e-02 + 1.183471945225e-02 1.171067369687e-02 1.158634819813e-02 1.146171960159e-02 + 1.133677724410e-02 1.121152295783e-02 1.108597079338e-02 1.096014666495e-02 + 1.083408792038e-02 1.070784283988e-02 1.058147006741e-02 1.045503797910e-02 + 1.032862399368e-02 1.020231383001e-02 1.007620071720e-02 9.950384563086e-03 + 9.824971087055e-03 9.700070923359e-03 9.575798701242e-03 9.452272108278e-03 + 9.329610943381e-03 9.207936165980e-03 9.087368947783e-03 8.968029733511e-03 + 8.850037316863e-03 8.733507937802e-03 8.618554407078e-03 8.505285263657e-03 + 8.393803970449e-03 8.284208153457e-03 8.176588889091e-03 8.071030044062e-03 + 7.967607671864e-03 7.866389469441e-03 7.767434297208e-03 7.670791765129e-03 + 7.576501887099e-03 7.484594805397e-03 7.395090586489e-03 7.307999088963e-03 + 7.223319903894e-03 7.141042367445e-03 7.061145645014e-03 6.983598885766e-03 + 6.908361445924e-03 6.835383178746e-03 6.764604788651e-03 6.695958246585e-03 + 6.629367263288e-03 6.564747816781e-03 6.502008730030e-03 6.441052294461e-03 + 6.381774934689e-03 6.324067909605e-03 6.267818044733e-03 6.212908490608e-03 + 6.159219501783e-03 6.106629230949e-03 6.055014532629e-03 6.004251770844e-03 + 5.954217625165e-03 5.904789889639e-03 5.855848259131e-03 5.807275097749e-03 + 5.758956184216e-03 5.710781429171e-03 5.662645559677e-03 5.614448766417e-03 + 5.566097309364e-03 5.517504078010e-03 5.468589102591e-03 5.419280013061e-03 + 5.369512443000e-03 5.319230375965e-03 5.268386432279e-03 5.216942094584e-03 + 5.164867870992e-03 5.112143395040e-03 5.058757462124e-03 5.004708002508e-03 + 4.950001991440e-03 4.894655297341e-03 4.838692469426e-03 4.782146466559e-03 + 4.725058329501e-03 4.667476799104e-03 4.609457883366e-03 4.551064376569e-03 + 4.492365334071e-03 4.433435506574e-03 4.374354737978e-03 4.315207331132e-03 + 4.256081386021e-03 4.197068115070e-03 4.138261140407e-03 4.079755777996e-03 + 4.021648313667e-03 3.964035276043e-03 3.907012711426e-03 3.850675465625e-03 + 3.795116477667e-03 3.740426090216e-03 3.686691381401e-03 3.633995522588e-03 + 3.582417166444e-03 3.532029869390e-03 3.482901552337e-03 3.435094003277e-03 + 3.388662425042e-03 3.343655031184e-03 3.300112692642e-03 3.258068637445e-03 + 3.217548205397e-03 3.178568659244e-03 3.141139053489e-03 3.105260161581e-03 + 3.070924461834e-03 3.038116182008e-03 3.006811402101e-03 2.976978214492e-03 + 2.948576940192e-03 2.921560399576e-03 2.895874235616e-03 2.871457287251e-03 + 2.848242010226e-03 2.826154942389e-03 2.805117210156e-03 2.785045072566e-03 + 2.765850499104e-03 2.747441777247e-03 2.729724145494e-03 2.712600447460e-03 + 2.695971802504e-03 2.679738288218e-03 2.663799630071e-03 2.648055893421e-03 + 2.632408173111e-03 2.616759275908e-03 2.601014391046e-03 2.585081744281e-03 + 2.568873230918e-03 2.552305023468e-03 2.535298149731e-03 2.517779037327e-03 + 2.499680020904e-03 2.480939808524e-03 2.461503903985e-03 2.441324982167e-03 + 2.420363214753e-03 2.398586544076e-03 2.375970903129e-03 2.352500380192e-03 + 2.328167326847e-03 2.302972408589e-03 2.276924597575e-03 2.250041107472e-03 + 2.222347270745e-03 2.193876359100e-03 2.164669348201e-03 2.134774628125e-03 + 2.104247661406e-03 2.073150590858e-03 2.041551799704e-03 2.009525426863e-03 + 1.977150840543e-03 1.944512073575e-03 1.911697224169e-03 1.878797826026e-03 + 1.845908191926e-03 1.813124735106e-03 1.780545272907e-03 1.748268317253e-03 + 1.716392356669e-03 1.685015134571e-03 1.654232928608e-03 1.624139835837e-03 + 1.594827068485e-03 1.566382264978e-03 1.538888820844e-03 1.512425243959e-03 + 1.487064538469e-03 1.462873621539e-03 1.439912776851e-03 1.418235148603e-03 + 1.397886279419e-03 1.378903695388e-03 1.361316541089e-03 1.345145267177e-03 + 1.330401372742e-03 1.317087204330e-03 1.305195813119e-03 1.294710871381e-03 + 1.285606648941e-03 1.277848049954e-03 1.271390709857e-03 1.266181151892e-03 + 1.262157002094e-03 1.259247261038e-03 1.257372629988e-03 1.256445888300e-03 + 1.256372317939e-03 1.257050169762e-03 1.258371164675e-03 1.260221020806e-03 + 1.262479995372e-03 1.265023426865e-03 1.267722259454e-03 1.270443527154e-03 + 1.273050770446e-03 1.275404352865e-03 1.277361640234e-03 1.278777001383e-03 + 1.279501587554e-03 1.279382849847e-03 1.278263761804e-03 1.275981729809e-03 + 1.272367199681e-03 1.267242005586e-03 1.260417558647e-03 1.251693037373e-03 + 1.240853818454e-03 1.227670470115e-03 1.211898713617e-03 1.193280830673e-03 + 1.171549041425e-03 1.146431382802e-03 1.117660563243e-03 1.084986141051e-03 + 1.048190158810e-03 1.007106061638e-03 9.616403401761e-04 9.117958912844e-04 + 8.576956167753e-04 7.996043336342e-04 7.379467099683e-04 6.733187363399e-04 + 6.064902563311e-04 5.383963642217e-04 4.701160591847e-04 4.028374193811e-04 + 3.378096816747e-04 2.762838987458e-04 2.194451740707e-04 1.683406996263e-04 + 1.238087845849e-04 8.641461945317e-05 5.639855469582e-05 3.364212299270e-05 + 1.765590279501e-05 7.591682743524e-06 2.279385157959e-06 2.870401658966e-07 + 0.000000000000e+00 + Type L N + 0 1 1 + 0.000000000000e+00 3.375340101333e-02 6.746796349822e-02 1.011049138555e-01 + 1.346256082234e-01 1.679915970424e-01 2.011646892560e-01 2.341070160275e-01 + 2.667810938520e-01 2.991498869451e-01 3.311768687900e-01 3.628260827265e-01 + 3.940622014666e-01 4.248505854211e-01 4.551573397281e-01 4.849493698694e-01 + 5.141944357697e-01 5.428612042712e-01 5.709192998796e-01 5.983393536821e-01 + 6.250930503389e-01 6.511531730530e-01 6.764936464275e-01 7.010895771214e-01 + 7.249172922209e-01 7.479543752446e-01 7.701796997065e-01 7.915734601660e-01 + 8.121172006957e-01 8.317938407052e-01 8.505876980641e-01 8.684845094698e-01 + 8.854714480139e-01 9.015371379059e-01 9.166716663176e-01 9.308665923177e-01 + 9.441149528744e-01 9.564112659059e-01 9.677515303693e-01 9.781332233824e-01 + 9.875552943794e-01 9.960181563106e-01 1.003523673900e+00 1.010075148982e+00 + 1.015677302955e+00 1.020336256368e+00 1.024059505710e+00 1.026855897434e+00 + 1.028735599272e+00 1.029710068925e+00 1.029792020169e+00 1.028995386487e+00 + 1.027335282286e+00 1.024827961803e+00 1.021490775799e+00 1.017342126138e+00 + 1.012401418364e+00 1.006689012392e+00 1.000226171440e+00 9.930350093166e-01 + 9.851384362041e-01 9.765601030744e-01 9.673243448728e-01 9.574561226182e-01 + 9.469809645661e-01 9.359249065863e-01 9.243144319084e-01 9.121764103924e-01 + 8.995380374803e-01 8.864267729912e-01 8.728702799165e-01 8.588963633783e-01 + 8.445329099101e-01 8.298078272199e-01 8.147489845939e-01 7.993841540983e-01 + 7.837409527334e-01 7.678467856909e-01 7.517287908658e-01 7.354137847644e-01 + 7.189282099516e-01 7.022980841725e-01 6.855489512787e-01 6.687058340848e-01 + 6.517931892735e-01 6.348348644627e-01 6.178540575378e-01 6.008732783497e-01 + 5.839143128664e-01 5.669981898627e-01 5.501451502191e-01 5.333746188975e-01 + 5.167051796490e-01 5.001545525002e-01 4.837395740569e-01 4.674761806538e-01 + 4.513793943678e-01 4.354633119048e-01 4.197410963605e-01 4.042249718435e-01 + 3.889262209421e-01 3.738551850050e-01 3.590212671974e-01 3.444329382852e-01 + 3.300977450887e-01 3.160223215414e-01 3.022124022789e-01 2.886728386745e-01 + 2.754076172314e-01 2.624198802337e-01 2.497119485487e-01 2.372853464705e-01 + 2.251408284840e-01 2.132784078267e-01 2.016973867172e-01 1.903963881162e-01 + 1.793733888809e-01 1.686257541706e-01 1.581502729567e-01 1.479431944907e-01 + 1.380002655774e-01 1.283167685047e-01 1.188875594752e-01 1.097071073890e-01 + 1.007695328252e-01 9.206864707152e-02 8.359799105358e-02 7.535087401652e-02 + 6.732041181622e-02 5.949956467938e-02 5.188117429660e-02 4.445800011708e-02 + 3.722275471825e-02 3.016813812988e-02 2.328687099752e-02 1.657172647727e-02 + 1.001556076019e-02 3.611342132348e-03 -2.647821516258e-03 -8.768656812552e-03 + -1.475770072170e-02 -2.062127813107e-02 -2.636548125059e-02 -3.199615087445e-02 + -3.751885954038e-02 -4.293889661385e-02 -4.826125531553e-02 -5.349062170172e-02 + -5.863136559834e-02 -6.368753348054e-02 -6.866284328140e-02 -7.356068110460e-02 + -7.838409980795e-02 -8.313581941656e-02 -8.781822931687e-02 -9.243339217524e-02 + -9.698304951803e-02 -1.014686289032e-01 -1.058912526074e-01 -1.102517477471e-01 + -1.145506577458e-01 -1.187882550557e-01 -1.229645550382e-01 -1.270793309018e-01 + -1.311321295940e-01 -1.351222885425e-01 -1.390489531347e-01 -1.429110948275e-01 + -1.467075297752e-01 -1.504369378627e-01 -1.540978820347e-01 -1.576888278065e-01 + -1.612081628491e-01 -1.646542165373e-01 -1.680252793568e-01 -1.713196220647e-01 + -1.745355145039e-01 -1.776712439735e-01 -1.807251330624e-01 -1.836955568580e-01 + -1.865809594450e-01 -1.893798696175e-01 -1.920909157293e-01 -1.947128396172e-01 + -1.972445095340e-01 -1.996849320388e-01 -2.020332627945e-01 -2.042888162310e-01 + -2.064510740412e-01 -2.085196924792e-01 -2.104945084419e-01 -2.123755443193e-01 + -2.141630116067e-01 -2.158573132777e-01 -2.174590449274e-01 -2.189689946957e-01 + -2.203881419935e-01 -2.217176550569e-01 -2.229588873615e-01 -2.241133729361e-01 + -2.251828206181e-01 -2.261691073020e-01 -2.270742702318e-01 -2.279004983992e-01 + -2.286501231081e-01 -2.293256077729e-01 -2.299295370205e-01 -2.304646051689e-01 + -2.309336041573e-01 -2.313394110069e-01 -2.316849748892e-01 -2.319733038842e-01 + -2.322074515083e-01 -2.323905030937e-01 -2.325255621004e-01 -2.326157364412e-01 + -2.326641248984e-01 -2.326738037117e-01 -2.326478134108e-01 -2.325891459689e-01 + -2.325007323449e-01 -2.323854304855e-01 -2.322460138479e-01 -2.320851605065e-01 + -2.319054428983e-01 -2.317093182599e-01 -2.314991198032e-01 -2.312770486727e-01 + -2.310451667226e-01 -2.308053901448e-01 -2.305594839771e-01 -2.303090575121e-01 + -2.300555606232e-01 -2.298002810200e-01 -2.295443424368e-01 -2.292887037559e-01 + -2.290341590589e-01 -2.287813385964e-01 -2.285307106594e-01 -2.282825843322e-01 + -2.280371130998e-01 -2.277942992806e-01 -2.275539992486e-01 -2.273159294059e-01 + -2.270796728624e-01 -2.268446867758e-01 -2.266103103025e-01 -2.263757731044e-01 + -2.261402043576e-01 -2.259026422030e-01 -2.256620435804e-01 -2.254172943820e-01 + -2.251672198643e-01 -2.249105952529e-01 -2.246461564765e-01 -2.243726109647e-01 + -2.240886484469e-01 -2.237929516866e-01 -2.234842070895e-01 -2.231611151244e-01 + -2.228224004966e-01 -2.224668220165e-01 -2.220931821080e-01 -2.217003359051e-01 + -2.212871998854e-01 -2.208527599957e-01 -2.203960792263e-01 -2.199163045941e-01 + -2.194126735000e-01 -2.188845194288e-01 -2.183312769643e-01 -2.177524860977e-01 + -2.171477958094e-01 -2.165169669117e-01 -2.158598741418e-01 -2.151765075019e-01 + -2.144669728436e-01 -2.137314917035e-01 -2.129704003968e-01 -2.121841483821e-01 + -2.113732959162e-01 -2.105385110171e-01 -2.096805657643e-01 -2.088003319618e-01 + -2.078987761994e-01 -2.069769543454e-01 -2.060360055126e-01 -2.050771455367e-01 + -2.041016600137e-01 -2.031108969411e-01 -2.021062590137e-01 -2.010891956219e-01 + -2.000611946063e-01 -1.990237738205e-01 -1.979784725550e-01 -1.969268428776e-01 + -1.958704409425e-01 -1.948108183233e-01 -1.937495134222e-01 -1.926880430083e-01 + -1.916278939346e-01 -1.905705150858e-01 -1.895173096023e-01 -1.884696274276e-01 + -1.874287582222e-01 -1.863959246844e-01 -1.853722763173e-01 -1.843588836761e-01 + -1.833567331280e-01 -1.823667221539e-01 -1.813896552157e-01 -1.804262402126e-01 + -1.794770855423e-01 -1.785426977825e-01 -1.776234800020e-01 -1.767197307079e-01 + -1.758316434314e-01 -1.749593069500e-01 -1.741027061414e-01 -1.732617234589e-01 + -1.724361410166e-01 -1.716256432660e-01 -1.708298202458e-01 -1.700481713799e-01 + -1.692801097974e-01 -1.685249671453e-01 -1.677819988611e-01 -1.670503898697e-01 + -1.663292606680e-01 -1.656176737570e-01 -1.649146403799e-01 -1.642191275233e-01 + -1.635300651373e-01 -1.628463535283e-01 -1.621668708785e-01 -1.614904808458e-01 + -1.608160401959e-01 -1.601424064214e-01 -1.594684452990e-01 -1.587930383416e-01 + -1.581150900972e-01 -1.574335352539e-01 -1.567473455058e-01 -1.560555361414e-01 + -1.553571723131e-01 -1.546513749544e-01 -1.539373263077e-01 -1.532142750324e-01 + -1.524815408637e-01 -1.517385187968e-01 -1.509846827728e-01 -1.502195888465e-01 + -1.494428778197e-01 -1.486542773268e-01 -1.478536033625e-01 -1.470407612462e-01 + -1.462157460186e-01 -1.453786422729e-01 -1.445296234235e-01 -1.436689504200e-01 + -1.427969699176e-01 -1.419141119176e-01 -1.410208868957e-01 -1.401178824382e-01 + -1.392057594094e-01 -1.382852476765e-01 -1.373571414199e-01 -1.364222940610e-01 + -1.354816128392e-01 -1.345360530754e-01 -1.335866121565e-01 -1.326343232816e-01 + -1.316802490079e-01 -1.307254746382e-01 -1.297711014920e-01 -1.288182401004e-01 + -1.278680033690e-01 -1.269214997512e-01 -1.259798264725e-01 -1.250440628491e-01 + -1.241152637407e-01 -1.231944531781e-01 -1.222826182036e-01 -1.213807029615e-01 + -1.204896030750e-01 -1.196101603416e-01 -1.187431577798e-01 -1.178893150558e-01 + -1.170492843167e-01 -1.162236464545e-01 -1.154129078230e-01 -1.146174974243e-01 + -1.138377645830e-01 -1.130739771182e-01 -1.123263200242e-01 -1.115948946659e-01 + -1.108797184913e-01 -1.101807252617e-01 -1.094977657963e-01 -1.088306092237e-01 + -1.081789447325e-01 -1.075423838067e-01 -1.069204629317e-01 -1.063126467520e-01 + -1.057183316588e-01 -1.051368497861e-01 -1.045674733867e-01 -1.040094195616e-01 + -1.034618553116e-01 -1.029239028794e-01 -1.023946453480e-01 -1.018731324599e-01 + -1.013583866214e-01 -1.008494090529e-01 -1.003451860488e-01 -9.984469530635e-02 + -9.934691228511e-02 -9.885081655779e-02 -9.835539811317e-02 -9.785966357267e-02 + -9.736264228232e-02 -9.686339224335e-02 -9.636100584524e-02 -9.585461536651e-02 + -9.534339821039e-02 -9.482658184372e-02 -9.430344840978e-02 -9.377333898760e-02 + -9.323565747272e-02 -9.268987405661e-02 -9.213552828457e-02 -9.157223167475e-02 + -9.099966988322e-02 -9.041760440345e-02 -8.982587379098e-02 -8.922439440716e-02 + -8.861316067895e-02 -8.799224487455e-02 -8.736179639766e-02 -8.672204060623e-02 + -8.607327716429e-02 -8.541587793847e-02 -8.475028445345e-02 -8.407700492325e-02 + -8.339661087801e-02 -8.270973340809e-02 -8.201705904985e-02 -8.131932533933e-02 + -8.061731606233e-02 -7.991185623101e-02 -7.920380681863e-02 -7.849405928578e-02 + -7.778352993221e-02 -7.707315410983e-02 -7.636388033277e-02 -7.565666432118e-02 + -7.495246301588e-02 -7.425222860060e-02 -7.355690256896e-02 -7.286740987259e-02 + -7.218465318639e-02 -7.150950732601e-02 -7.084281385174e-02 -7.018537589158e-02 + -6.953795321511e-02 -6.890125758787e-02 -6.827594843441e-02 -6.766262883596e-02 + -6.706184188687e-02 -6.647406743135e-02 -6.589971920003e-02 -6.533914236294e-02 + -6.479261151330e-02 -6.426032909359e-02 -6.374242427268e-02 -6.323895228008e-02 + -6.274989420036e-02 -6.227515722821e-02 -6.181457538156e-02 -6.136791066736e-02 + -6.093485469211e-02 -6.051503070615e-02 -6.010799606826e-02 -5.971324511462e-02 + -5.933021241354e-02 -5.895827638510e-02 -5.859676326279e-02 -5.824495137181e-02 + -5.790207569719e-02 -5.756733271290e-02 -5.723988544151e-02 -5.691886871294e-02 + -5.660339458914e-02 -5.629255792112e-02 -5.598544200347e-02 -5.568112429147e-02 + -5.537868214503e-02 -5.507719856411e-02 -5.477576787990e-02 -5.447350136674e-02 + -5.416953274002e-02 -5.386302350631e-02 -5.355316813253e-02 -5.323919900273e-02 + -5.292039113168e-02 -5.259606660662e-02 -5.226559872992e-02 -5.192841583729e-02 + -5.158400476822e-02 -5.123191396769e-02 -5.087175620014e-02 -5.050321085940e-02 + -5.012602586062e-02 -4.974001910291e-02 -4.934507949390e-02 -4.894116753052e-02 + -4.852831543246e-02 -4.810662682810e-02 -4.767627599506e-02 -4.723750666042e-02 + -4.679063036846e-02 -4.633602442617e-02 -4.587412943961e-02 -4.540544645667e-02 + -4.493053373399e-02 -4.445000314847e-02 -4.396451627563e-02 -4.347478015932e-02 + -4.298154279907e-02 -4.248558838326e-02 -4.198773229754e-02 -4.148881593965e-02 + -4.098970137276e-02 -4.049126585042e-02 -3.999439624720e-02 -3.949998342938e-02 + -3.900891660067e-02 -3.852207765799e-02 -3.804033559219e-02 -3.756454096847e-02 + -3.709552052070e-02 -3.663407189310e-02 -3.618095856188e-02 -3.573690496837e-02 + -3.530259189383e-02 -3.487865210461e-02 -3.446566629484e-02 -3.406415935180e-02 + -3.367459696729e-02 -3.329738261618e-02 -3.293285492101e-02 -3.258128541928e-02 + -3.224287674747e-02 -3.191776125334e-02 -3.160600004545e-02 -3.130758248621e-02 + -3.102242613197e-02 -3.075037712086e-02 -3.049121100666e-02 -3.024463403384e-02 + -3.001028484654e-02 -2.978773662133e-02 -2.957649961123e-02 -2.937602408583e-02 + -2.918570364980e-02 -2.900487891999e-02 -2.883284153897e-02 -2.866883850065e-02 + -2.851207676207e-02 -2.836172811322e-02 -2.821693427547e-02 -2.807681219758e-02 + -2.794045951709e-02 -2.780696015387e-02 -2.767539000166e-02 -2.754482268274e-02 + -2.741433533076e-02 -2.728301436604e-02 -2.714996122805e-02 -2.701429802975e-02 + -2.687517309904e-02 -2.673176637293e-02 -2.658329461132e-02 -2.642901639774e-02 + -2.626823689621e-02 -2.610031233427e-02 -2.592465418425e-02 -2.574073301636e-02 + -2.554808199911e-02 -2.534630002494e-02 -2.513505444066e-02 -2.491408336509e-02 + -2.468319757853e-02 -2.444228197111e-02 -2.419129654013e-02 -2.393027692850e-02 + -2.365933449986e-02 -2.337865594821e-02 -2.308850244281e-02 -2.278920831204e-02 + -2.248117927242e-02 -2.216489021197e-02 -2.184088253950e-02 -2.150976111438e-02 + -2.117219077357e-02 -2.082889247518e-02 -2.048063908047e-02 -2.012825079787e-02 + -1.977259031513e-02 -1.941455764743e-02 -1.905508473103e-02 -1.869512979362e-02 + -1.833567153412e-02 -1.797770314545e-02 -1.762222621544e-02 -1.727024454121e-02 + -1.692275789348e-02 -1.658075576729e-02 -1.624521115604e-02 -1.591707438558e-02 + -1.559726704482e-02 -1.528667604908e-02 -1.498614787135e-02 -1.469648297606e-02 + -1.441843048879e-02 -1.415268313393e-02 -1.389987247105e-02 -1.366056445881e-02 + -1.343525537381e-02 -1.322436810926e-02 -1.302824887671e-02 -1.284716433160e-02 + -1.268129914080e-02 -1.253075400823e-02 -1.239554417166e-02 -1.227559838124e-02 + -1.217075836756e-02 -1.208077880421e-02 -1.200532776672e-02 -1.194398768716e-02 + -1.189625680016e-02 -1.186155107347e-02 -1.183920661233e-02 -1.182848252393e-02 + -1.182856422366e-02 -1.183856716099e-02 -1.185754093687e-02 -1.188447377830e-02 + -1.191829732706e-02 -1.195789168909e-02 -1.200209067673e-02 -1.204968715833e-02 + -1.209943840630e-02 -1.215007130625e-02 -1.220028725426e-02 -1.224876652818e-02 + -1.229417187213e-02 -1.233515098480e-02 -1.237033755583e-02 -1.239835045939e-02 + -1.241779070038e-02 -1.242723573197e-02 -1.242523084214e-02 -1.241027746188e-02 + -1.238081850111e-02 -1.233522118866e-02 -1.227175839268e-02 -1.218859002675e-02 + -1.208374688581e-02 -1.195512006101e-02 -1.180045987933e-02 -1.161738899598e-02 + -1.140343469983e-02 -1.115608551522e-02 -1.087287663337e-02 -1.055150743420e-02 + -1.018999225887e-02 -9.786842636481e-03 -9.341275432695e-03 -8.853437083322e-03 + -8.324629554625e-03 -7.757519422508e-03 -7.156308076494e-03 -6.526839170932e-03 + -5.876619671647e-03 -5.214733660413e-03 -4.551633714403e-03 -3.898803112012e-03 + -3.268292897218e-03 -2.672150143947e-03 -2.121766438798e-03 -1.627187242489e-03 + -1.196431908000e-03 -8.348793414504e-04 -5.447745126481e-04 -3.249056704027e-04 + -1.704912337315e-04 -7.329963822255e-05 -2.200628869199e-05 -2.771091616120e-06 + 0.000000000000e+00 + Type L N + 0 2 0 + 0.000000000000e+00 -3.343626342662e-04 -1.336837154607e-03 -3.005584903671e-03 + -5.337546547975e-03 -8.328449682246e-03 -1.197281945274e-02 -1.626399216017e-02 + -2.119413180214e-02 -2.675424950468e-02 -3.293422578324e-02 -3.972283556741e-02 + -4.710777591292e-02 -5.507569631817e-02 -6.361223155362e-02 -7.270203690572e-02 + -8.232882572951e-02 -9.247540919759e-02 -1.031237381265e-01 -1.142549467555e-01 + -1.258493983485e-01 -1.378867324813e-01 -1.503459138772e-01 -1.632052826437e-01 + -1.764426057637e-01 -1.900351296900e-01 -2.039596338880e-01 -2.181924851715e-01 + -2.327096926724e-01 -2.474869632865e-01 -2.624997574346e-01 -2.777233449784e-01 + -2.931328611333e-01 -3.087033622181e-01 -3.244098810844e-01 -3.402274820706e-01 + -3.561313153280e-01 -3.720966703679e-01 -3.880990286845e-01 -4.041141153094e-01 + -4.201179491604e-01 -4.360868920511e-01 -4.519976962312e-01 -4.678275503368e-01 + -4.835541236322e-01 -4.991556084334e-01 -5.146107606085e-01 -5.298989380595e-01 + -5.450001370934e-01 -5.598950266029e-01 -5.745649799796e-01 -5.889921046952e-01 + -6.031592694904e-01 -6.170501291222e-01 -6.306491466272e-01 -6.439416130674e-01 + -6.569136647327e-01 -6.695522977849e-01 -6.818453803336e-01 -6.937816619452e-01 + -7.053507805935e-01 -7.165432670680e-01 -7.273505468671e-01 -7.377649396064e-01 + -7.477796559861e-01 -7.573887923636e-01 -7.665873229882e-01 -7.753710899610e-01 + -7.837367909893e-01 -7.916819650125e-01 -7.992049757811e-01 -8.063049934769e-01 + -8.129819744702e-01 -8.192366393094e-01 -8.250704490495e-01 -8.304855800252e-01 + -8.354848971804e-01 -8.400719260699e-01 -8.442508236491e-01 -8.480263479737e-01 + -8.514038269297e-01 -8.543891261192e-01 -8.569886160244e-01 -8.592091385765e-01 + -8.610579732544e-01 -8.625428028381e-01 -8.636716789393e-01 -8.644529874351e-01 + -8.648954139221e-01 -8.650079093126e-01 -8.647996556872e-01 -8.642800325178e-01 + -8.634585833709e-01 -8.623449831963e-01 -8.609490063045e-01 -8.592804951284e-01 + -8.573493298636e-01 -8.551653990737e-01 -8.527385713425e-01 -8.500786680519e-01 + -8.471954373523e-01 -8.440985293945e-01 -8.407974728780e-01 -8.373016529705e-01 + -8.336202906425e-01 -8.297624234571e-01 -8.257368878476e-01 -8.215523029081e-01 + -8.172170557172e-01 -8.127392882070e-01 -8.081268855835e-01 -8.033874662982e-01 + -7.985283735640e-01 -7.935566684020e-01 -7.884791242011e-01 -7.833022227637e-01 + -7.780321518080e-01 -7.726748038897e-01 -7.672357767027e-01 -7.617203747098e-01 + -7.561336120554e-01 -7.504802167010e-01 -7.447646357266e-01 -7.389910417321e-01 + -7.331633402733e-01 -7.272851782609e-01 -7.213599532512e-01 -7.153908235516e-01 + -7.093807190655e-01 -7.033323527959e-01 -6.972482329292e-01 -6.911306754180e-01 + -6.849818169812e-01 -6.788036284404e-01 -6.725979283113e-01 -6.663663965707e-01 + -6.601105885181e-01 -6.538319486556e-01 -6.475318245087e-01 -6.412114803151e-01 + -6.348721105083e-01 -6.285148529281e-01 -6.221408016911e-01 -6.157510196589e-01 + -6.093465504440e-01 -6.029284298983e-01 -5.964976970317e-01 -5.900554043133e-01 + -5.836026273123e-01 -5.771404736385e-01 -5.706700911490e-01 -5.641926753898e-01 + -5.577094762487e-01 -5.512218037973e-01 -5.447310333076e-01 -5.382386094324e-01 + -5.317460495410e-01 -5.252549462125e-01 -5.187669688857e-01 -5.122838646765e-01 + -5.058074583733e-01 -4.993396516261e-01 -4.928824213526e-01 -4.864378173819e-01 + -4.800079593679e-01 -4.735950330014e-01 -4.672012855581e-01 -4.608290208195e-01 + -4.544805934091e-01 -4.481584025867e-01 -4.418648855484e-01 -4.356025102794e-01 + -4.293737680101e-01 -4.231811653276e-01 -4.170272159956e-01 -4.109144325344e-01 + -4.048453176194e-01 -3.988223553477e-01 -3.928480024327e-01 -3.869246793767e-01 + -3.810547616785e-01 -3.752405711272e-01 -3.694843672348e-01 -3.637883388583e-01 + -3.581545960596e-01 -3.525851622505e-01 -3.470819666678e-01 -3.416468372203e-01 + -3.362814937487e-01 -3.309875417352e-01 -3.257664664965e-01 -3.206196278925e-01 + -3.155482555784e-01 -3.105534448246e-01 -3.056361529269e-01 -3.007971962230e-01 + -2.960372477322e-01 -2.913568354266e-01 -2.867563411432e-01 -2.822360001380e-01 + -2.777959012850e-01 -2.734359879143e-01 -2.691560592826e-01 -2.649557726669e-01 + -2.608346460667e-01 -2.567920614966e-01 -2.528272688523e-01 -2.489393903234e-01 + -2.451274253294e-01 -2.413902559506e-01 -2.377266528210e-01 -2.341352814527e-01 + -2.306147089543e-01 -2.271634111079e-01 -2.237797797652e-01 -2.204621305236e-01 + -2.172087106397e-01 -2.140177071397e-01 -2.108872550835e-01 -2.078154459384e-01 + -2.048003360207e-01 -2.018399549607e-01 -1.989323141484e-01 -1.960754151182e-01 + -1.932672578291e-01 -1.905058488019e-01 -1.877892090725e-01 -1.851153819227e-01 + -1.824824403534e-01 -1.798884942646e-01 -1.773316973091e-01 -1.748102533895e-01 + -1.723224227703e-01 -1.698665277787e-01 -1.674409580705e-01 -1.650441754402e-01 + -1.626747181578e-01 -1.603312048155e-01 -1.580123376728e-01 -1.557169054900e-01 + -1.534437858432e-01 -1.511919469166e-01 -1.489604487725e-01 -1.467484440982e-01 + -1.445551784381e-01 -1.423799899146e-01 -1.402223084519e-01 -1.380816545125e-01 + -1.359576373628e-01 -1.338499528870e-01 -1.317583809666e-01 -1.296827824501e-01 + -1.276230957362e-01 -1.255793329962e-01 -1.235515760637e-01 -1.215399720218e-01 + -1.195447285159e-01 -1.175661088266e-01 -1.156044267334e-01 -1.136600412031e-01 + -1.117333509371e-01 -1.098247888115e-01 -1.079348162442e-01 -1.060639175244e-01 + -1.042125941364e-01 -1.023813591143e-01 -1.005707314578e-01 -9.878123064275e-02 + -9.701337125784e-02 -9.526765779625e-02 -9.354457963214e-02 -9.184460620859e-02 + -9.016818246269e-02 -8.851572451171e-02 -8.688761562231e-02 -8.528420248277e-02 + -8.370579179616e-02 -8.215264721034e-02 -8.062498659825e-02 -7.912297969974e-02 + -7.764674613412e-02 -7.619635378974e-02 -7.477181759514e-02 -7.337309867347e-02 + -7.200010387990e-02 -7.065268571912e-02 -6.933064263796e-02 -6.803371968591e-02 + -6.676160953406e-02 -6.551395384105e-02 -6.429034495247e-02 -6.309032791849e-02 + -6.191340281251e-02 -6.075902733211e-02 -5.962661966204e-02 -5.851556157749e-02 + -5.742520176494e-02 -5.635485933641e-02 -5.530382751238e-02 -5.427137744758e-02 + -5.325676217347e-02 -5.225922063068e-02 -5.127798176446e-02 -5.031226865597e-02 + -4.936130266255e-02 -4.842430754004e-02 -4.750051352083e-02 -4.658916132185e-02 + -4.568950605718e-02 -4.480082103116e-02 -4.392240138864e-02 -4.305356760016e-02 + -4.219366876109e-02 -4.134208568535e-02 -4.049823377542e-02 -3.966156565219e-02 + -3.883157352997e-02 -3.800779132324e-02 -3.718979647415e-02 -3.637721149118e-02 + -3.556970519142e-02 -3.476699364092e-02 -3.396884078953e-02 -3.317505879834e-02 + -3.238550806028e-02 -3.160009691578e-02 -3.081878106792e-02 -3.004156270276e-02 + -2.926848932289e-02 -2.849965230358e-02 -2.773518518292e-02 -2.697526169857e-02 + -2.622009358570e-02 -2.546992815167e-02 -2.472504564458e-02 -2.398575643389e-02 + -2.325239802234e-02 -2.252533190942e-02 -2.180494032745e-02 -2.109162287172e-02 + -2.038579304718e-02 -1.968787475392e-02 -1.899829873448e-02 -1.831749900579e-02 + -1.764590929849e-02 -1.698395952636e-02 -1.633207230820e-02 -1.569065956384e-02 + -1.506011920558e-02 -1.444083194557e-02 -1.383315823866e-02 -1.323743537947e-02 + -1.265397477111e-02 -1.208305938198e-02 -1.152494140576e-02 -1.097984013816e-02 + -1.044794008281e-02 -9.929389296949e-03 -9.424297986017e-03 -8.932737354798e-03 + -8.454738720835e-03 -7.990292894352e-03 -7.539349827129e-03 -7.101818531054e-03 + -6.677567265404e-03 -6.266423990178e-03 -5.868177081158e-03 -5.482576300744e-03 + -5.109334017007e-03 -4.748126661889e-03 -4.398596418013e-03 -4.060353122176e-03 + -3.732976372278e-03 -3.416017823244e-03 -3.109003656357e-03 -2.811437205408e-03 + -2.522801722167e-03 -2.242563262875e-03 -1.970173676792e-03 -1.705073677284e-03 + -1.446695975487e-03 -1.194468456330e-03 -9.478173764667e-04 -7.061705636916e-04 + -4.689605974468e-04 -2.356279502815e-04 -5.624070443108e-06 2.215856137444e-04 + 4.465187864809e-04 6.696734521357e-04 8.915252751909e-04 1.112525068831e-03 + 1.333096447502e-03 1.553633657665e-03 1.774499599783e-03 1.996024053307e-03 + 2.218502115094e-03 2.442192860297e-03 2.667318233328e-03 2.894062174991e-03 + 3.122569990378e-03 3.352947960583e-03 3.585263199706e-03 3.819543757117e-03 + 4.055778963323e-03 4.293920016333e-03 4.533880803833e-03 4.775538955066e-03 + 5.018737114848e-03 5.263284430803e-03 5.508958243561e-03 5.755505968455e-03 + 6.002647156047e-03 6.250075717768e-03 6.497462301937e-03 6.744456804555e-03 + 6.990690998455e-03 7.235781263722e-03 7.479331401700e-03 7.720935514475e-03 + 7.960180931322e-03 8.196651163443e-03 8.429928868145e-03 8.659598803677e-03 + 8.885250756012e-03 9.106482419171e-03 9.322902210975e-03 9.534132006645e-03 + 9.739809773209e-03 9.939592088387e-03 1.013315652839e-02 1.032020390999e-02 + 1.050046037311e-02 1.067367929138e-02 1.083964299904e-02 1.099816432397e-02 + 1.114908791773e-02 1.129229137491e-02 1.142768613538e-02 1.155521816451e-02 + 1.167486840766e-02 1.178665301699e-02 1.189062334975e-02 1.198686573886e-02 + 1.207550103810e-02 1.215668394523e-02 1.223060210846e-02 1.229747502216e-02 + 1.235755271998e-02 1.241111427384e-02 1.245846610930e-02 1.249994014833e-02 + 1.253589179188e-02 1.256669775556e-02 1.259275377257e-02 1.261447217886e-02 + 1.263227939621e-02 1.264661332954e-02 1.265792069506e-02 1.266665429669e-02 + 1.267327026786e-02 1.267822529655e-02 1.268197385112e-02 1.268496542450e-02 + 1.268764181424e-02 1.269043445550e-02 1.269376182389e-02 1.269802692425e-02 + 1.270361488126e-02 1.271089064677e-02 1.272019683810e-02 1.273185172070e-02 + 1.274614734761e-02 1.276334786702e-02 1.278368800834e-02 1.280737175581e-02 + 1.283457121768e-02 1.286542569759e-02 1.290004097353e-02 1.293848878846e-02 + 1.298080655521e-02 1.302699727721e-02 1.307702968475e-02 1.313083858562e-02 + 1.318832542729e-02 1.324935906660e-02 1.331377674153e-02 1.338138523858e-02 + 1.345196224768e-02 1.352525789593e-02 1.360099644967e-02 1.367887817415e-02 + 1.375858133831e-02 1.383976435191e-02 1.392206802105e-02 1.400511790768e-02 + 1.408852677781e-02 1.417189712294e-02 1.425482373845e-02 1.433689634259e-02 + 1.441770221955e-02 1.449682886970e-02 1.457386665042e-02 1.464841139079e-02 + 1.472006696371e-02 1.478844779938e-02 1.485318132444e-02 1.491391031148e-02 + 1.497029512441e-02 1.502201584577e-02 1.506877427283e-02 1.511029577033e-02 + 1.514633096835e-02 1.517665729523e-02 1.520108033617e-02 1.521943500936e-02 + 1.523158655287e-02 1.523743131645e-02 1.523689735383e-02 1.522994481228e-02 + 1.521656611768e-02 1.519678595426e-02 1.517066104006e-02 1.513827969981e-02 + 1.509976123868e-02 1.505525512150e-02 1.500493996308e-02 1.494902233675e-02 + 1.488773540916e-02 1.482133741048e-02 1.475010995040e-02 1.467435619093e-02 + 1.459439888821e-02 1.451057831614e-02 1.442325008548e-02 1.433278287269e-02 + 1.423955607319e-02 1.414395739449e-02 1.404638040462e-02 1.394722205179e-02 + 1.384688017131e-02 1.374575099580e-02 1.364422668469e-02 1.354269288897e-02 + 1.344152636660e-02 1.334109266410e-02 1.324174387886e-02 1.314381651665e-02 + 1.304762945779e-02 1.295348204502e-02 1.286165230509e-02 1.277239531539e-02 + 1.268594172582e-02 1.260249644524e-02 1.252223750064e-02 1.244531507624e-02 + 1.237185073831e-02 1.230193685046e-02 1.223563618299e-02 1.217298171836e-02 + 1.211397665396e-02 1.205859460168e-02 1.200677998284e-02 1.195844861567e-02 + 1.191348849118e-02 1.187176073223e-02 1.183310072929e-02 1.179731944541e-02 + 1.176420488159e-02 1.173352369290e-02 1.170502294478e-02 1.167843199771e-02 + 1.165346450811e-02 1.162982053213e-02 1.160718871857e-02 1.158524857654e-02 + 1.156367280306e-02 1.154212965511e-02 1.152028535082e-02 1.149780648386e-02 + 1.147436243525e-02 1.144962776679e-02 1.142328458018e-02 1.139502482655e-02 + 1.136455255094e-02 1.133158605705e-02 1.129585997790e-02 1.125712723852e-02 + 1.121516089784e-02 1.116975585722e-02 1.112073042436e-02 1.106792772183e-02 + 1.101121693077e-02 1.095049436119e-02 1.088568434131e-02 1.081673991978e-02 + 1.074364337555e-02 1.066640653153e-02 1.058507086931e-02 1.049970744365e-02 + 1.041041659643e-02 1.031732747148e-02 1.022059733232e-02 1.012041068691e-02 + 1.001697822396e-02 9.910535567088e-03 9.801341854133e-03 9.689678149904e-03 + 9.575845701974e-03 9.460164049946e-03 9.342968999703e-03 9.224610474943e-03 + 9.105450259188e-03 8.985859642125e-03 8.866216984828e-03 8.746905218928e-03 + 8.628309295287e-03 8.510813598082e-03 8.394799340493e-03 8.280641958326e-03 + 8.168708518025e-03 8.059355155419e-03 7.952924561508e-03 7.849743531260e-03 + 7.750120591151e-03 7.654343720673e-03 7.562678182560e-03 7.475364475847e-03 + 7.392616425167e-03 7.314619418914e-03 7.241528808031e-03 7.173468476237e-03 + 7.110529591491e-03 7.052769547440e-03 7.000211102441e-03 6.952841722580e-03 + 6.910613133880e-03 6.873441087605e-03 6.841205341262e-03 6.813749856528e-03 + 6.790883213907e-03 6.772379242453e-03 6.757977861265e-03 6.747386127750e-03 + 6.740279485677e-03 6.736303203743e-03 6.735073992636e-03 6.736181785112e-03 + 6.739191659263e-03 6.743645879500e-03 6.749066022504e-03 6.754955146012e-03 + 6.760799946435e-03 6.766072836490e-03 6.770233856141e-03 6.772732309341e-03 + 6.773007995942e-03 6.770491884438e-03 6.764606049322e-03 6.754762681147e-03 + 6.740361973409e-03 6.720788705873e-03 6.695407387943e-03 6.663555908574e-03 + 6.624537771248e-03 6.577613182754e-03 6.521989517875e-03 6.456811997516e-03 + 6.381155784392e-03 6.294021095072e-03 6.194333312052e-03 6.080950401236e-03 + 5.952680131222e-03 5.808309573621e-03 5.646649058578e-03 5.466592095872e-03 + 5.267191701375e-03 5.047752081595e-03 4.807932768711e-03 4.547860173024e-03 + 4.268239306083e-03 3.970456368326e-03 3.656661280562e-03 3.329818380641e-03 + 2.993713697702e-03 2.652908684317e-03 2.312633146252e-03 1.978614320966e-03 + 1.656844398248e-03 1.353294841584e-03 1.073592084013e-03 8.226748497738e-04 + 6.044577664810e-04 4.215284098635e-04 2.749049451014e-04 1.638788182719e-04 + 8.596153714402e-05 3.694682421181e-05 1.109000226043e-05 1.396308876444e-06 + 0.000000000000e+00 \ No newline at end of file diff --git a/ABACUS.develop/examples/H2O-deepks/STRU b/ABACUS.develop/examples/H2O-deepks/STRU new file mode 100644 index 0000000000..3ffd869801 --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks/STRU @@ -0,0 +1,28 @@ +ATOMIC_SPECIES +H 1.008 H_ONCV_PBE-1.0.upf +O 15.9994 O_ONCV_PBE-1.0.upf + +NUMERICAL_ORBITAL +H_gga_6au_60Ry_2s1p.orb +O_gga_6au_60Ry_2s2p1d.orb + +LATTICE_CONSTANT +10 + +LATTICE_VECTORS +1 0 0 +0 1 0 +0 0 1 + +ATOMIC_POSITIONS +Cartesian + +H +0 +2 +0.2336137046291667 0.8630016418166666 0.7271997623458333 1 1 1 +0.23417266949166665 0.9245341895916668 0.7207232227333333 1 1 1 +O +0 +1 +0.20910677665833333 0.894927691625 0.7301984601833333 1 1 1 diff --git a/ABACUS.develop/examples/H2O-deepks/descriptor.dat b/ABACUS.develop/examples/H2O-deepks/descriptor.dat new file mode 100644 index 0000000000..843547ef0c --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks/descriptor.dat @@ -0,0 +1,48 @@ +H atom_index 1 n_descriptor 117 +8.6337 1.64286 0.335071 0.131771 0.0476684 0.0225226 0.0116164 0.00588298 +0.00324368 0.00153789 0.000798237 0.000364279 0.000169084 0.405463 0.774783 3.17103 +0.320238 0.401018 0.416599 0.14597 0.167703 0.171042 0.0557152 0.0694168 +0.0828051 0.0175949 0.0286645 0.0360523 0.0056741 0.0115018 0.0162086 0.00148592 +0.00484878 0.00673434 0.00040785 0.00193997 0.00298168 9.45225e-05 0.000774866 0.00111817 +4.80692e-05 0.000284433 0.00046522 3.31228e-05 9.92706e-05 0.000144674 2.49332e-05 3.36781e-05 +6.29598e-05 3.55959e-06 3.76563e-06 9.19828e-06 1.86463e-05 0.000495479 0.0158654 0.0164122 +0.131167 1.21854e-06 0.000498166 0.0170361 0.0182622 0.0229838 2.37349e-06 9.79136e-05 +0.0136992 0.0149038 0.0194728 1.80217e-06 5.19709e-05 0.00925381 0.0100169 0.0128096 +1.06341e-06 2.84027e-05 0.00556941 0.00600754 0.00883919 7.26986e-07 1.36759e-05 0.00323978 +0.00348365 0.00503592 3.53711e-07 8.26414e-06 0.0018024 0.00181919 0.00317192 2.11246e-07 +4.17861e-06 0.000941667 0.00095985 0.00160115 8.42441e-08 2.41634e-06 0.000409661 0.000474298 +0.000895715 3.5565e-08 1.34604e-06 0.000179148 0.000214292 0.000381697 8.8433e-09 7.5638e-07 +6.30949e-05 9.13342e-05 0.000190989 1.63448e-09 4.21859e-07 2.09944e-05 2.95453e-05 5.76515e-05 +2.52811e-11 1.59956e-08 9.63818e-08 1.87631e-07 3.57585e-06 +H atom_index 2 n_descriptor 117 +8.58629 1.64279 0.333321 0.131436 0.0468976 0.0222956 0.0113884 0.00582681 +0.00319229 0.00153173 0.000789979 0.000365163 0.000168024 0.428327 0.774951 3.22546 +0.323387 0.400148 0.416881 0.146513 0.167956 0.171337 0.055514 0.0696468 +0.084421 0.017907 0.0288043 0.0363163 0.0057377 0.0115866 0.0166051 0.00156437 +0.0048947 0.00681812 0.000422159 0.0019657 0.00307941 0.000100246 0.00078749 0.00113914 +4.58591e-05 0.00029052 0.000486945 2.9619e-05 0.000101678 0.000148827 2.33115e-05 3.48065e-05 +6.73526e-05 3.39956e-06 3.69115e-06 9.03414e-06 1.10973e-05 0.000561533 0.0158827 0.0160544 +0.10203 6.96469e-07 0.000543107 0.0165868 0.0179468 0.0209534 1.26938e-06 9.31636e-05 +0.0134988 0.0147624 0.0188412 3.49364e-07 5.21841e-05 0.00908559 0.00980599 0.0124494 +4.8741e-07 2.80017e-05 0.00548797 0.00595887 0.00872226 1.47042e-07 1.40112e-05 0.00319001 +0.00341412 0.00497452 1.55652e-07 8.11539e-06 0.00178868 0.00181172 0.00315219 4.1026e-08 +4.25747e-06 0.000928262 0.000949085 0.00159341 4.33366e-08 2.31115e-06 0.000414829 0.000471228 +0.000894336 6.82658e-09 1.32567e-06 0.000177523 0.00021326 0.000381831 8.50005e-09 6.9477e-07 +6.49545e-05 9.12906e-05 0.000191355 1.17968e-09 4.23974e-07 2.02826e-05 2.98077e-05 5.78414e-05 +1.08748e-09 1.83654e-08 6.91167e-08 2.28524e-07 2.85146e-06 +O atom_index 1 n_descriptor 117 +8.39927 1.74924 0.320158 0.112639 0.0233291 0.00835168 0.00230151 0.0010965 +0.000685832 0.000358311 0.000283113 0.000141987 0.000102514 0.382931 0.785038 3.18816 +0.325464 0.403513 0.435225 0.17871 0.182868 0.186876 0.081024 0.0943096 +0.0978905 0.0362042 0.0431748 0.0474245 0.0161162 0.0227891 0.0232373 0.00758905 +0.0103734 0.0116325 0.00351414 0.00558713 0.00573454 0.00161866 0.00241805 0.00274659 +0.000718772 0.00125817 0.00128576 0.000294225 0.000473332 0.000545205 0.000127139 0.00025082 +0.000258046 1.45077e-05 2.71564e-05 2.99321e-05 5.9403e-06 0.000288006 0.000502287 0.000630795 +0.184366 1.39968e-06 0.000332439 0.000510098 0.000734575 0.00738666 1.21917e-06 0.000269666 +0.000294478 0.000627856 0.00317448 8.51215e-07 0.000146432 0.000184091 0.000469511 0.000989314 +5.24365e-07 8.09823e-05 0.000142 0.000310221 0.000470881 2.93804e-07 4.30581e-05 8.14991e-05 +0.000204871 0.000233799 1.7751e-07 2.40895e-05 6.00404e-05 0.0001152 0.000138208 9.21282e-08 +1.2903e-05 3.32158e-05 6.96494e-05 8.43918e-05 5.36017e-08 7.13565e-06 2.17522e-05 3.78762e-05 +5.14935e-05 2.54311e-08 3.67034e-06 1.15774e-05 2.31958e-05 2.95982e-05 1.37544e-08 1.98643e-06 +6.89745e-06 1.34907e-05 1.75484e-05 5.01753e-09 8.71328e-07 3.17905e-06 8.07677e-06 8.7924e-06 +3.33246e-11 5.102e-09 4.27705e-08 5.0544e-08 4.80027e-06 diff --git a/ABACUS.develop/examples/H2O-deepks/descriptor.dat.bak b/ABACUS.develop/examples/H2O-deepks/descriptor.dat.bak new file mode 100644 index 0000000000..843547ef0c --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks/descriptor.dat.bak @@ -0,0 +1,48 @@ +H atom_index 1 n_descriptor 117 +8.6337 1.64286 0.335071 0.131771 0.0476684 0.0225226 0.0116164 0.00588298 +0.00324368 0.00153789 0.000798237 0.000364279 0.000169084 0.405463 0.774783 3.17103 +0.320238 0.401018 0.416599 0.14597 0.167703 0.171042 0.0557152 0.0694168 +0.0828051 0.0175949 0.0286645 0.0360523 0.0056741 0.0115018 0.0162086 0.00148592 +0.00484878 0.00673434 0.00040785 0.00193997 0.00298168 9.45225e-05 0.000774866 0.00111817 +4.80692e-05 0.000284433 0.00046522 3.31228e-05 9.92706e-05 0.000144674 2.49332e-05 3.36781e-05 +6.29598e-05 3.55959e-06 3.76563e-06 9.19828e-06 1.86463e-05 0.000495479 0.0158654 0.0164122 +0.131167 1.21854e-06 0.000498166 0.0170361 0.0182622 0.0229838 2.37349e-06 9.79136e-05 +0.0136992 0.0149038 0.0194728 1.80217e-06 5.19709e-05 0.00925381 0.0100169 0.0128096 +1.06341e-06 2.84027e-05 0.00556941 0.00600754 0.00883919 7.26986e-07 1.36759e-05 0.00323978 +0.00348365 0.00503592 3.53711e-07 8.26414e-06 0.0018024 0.00181919 0.00317192 2.11246e-07 +4.17861e-06 0.000941667 0.00095985 0.00160115 8.42441e-08 2.41634e-06 0.000409661 0.000474298 +0.000895715 3.5565e-08 1.34604e-06 0.000179148 0.000214292 0.000381697 8.8433e-09 7.5638e-07 +6.30949e-05 9.13342e-05 0.000190989 1.63448e-09 4.21859e-07 2.09944e-05 2.95453e-05 5.76515e-05 +2.52811e-11 1.59956e-08 9.63818e-08 1.87631e-07 3.57585e-06 +H atom_index 2 n_descriptor 117 +8.58629 1.64279 0.333321 0.131436 0.0468976 0.0222956 0.0113884 0.00582681 +0.00319229 0.00153173 0.000789979 0.000365163 0.000168024 0.428327 0.774951 3.22546 +0.323387 0.400148 0.416881 0.146513 0.167956 0.171337 0.055514 0.0696468 +0.084421 0.017907 0.0288043 0.0363163 0.0057377 0.0115866 0.0166051 0.00156437 +0.0048947 0.00681812 0.000422159 0.0019657 0.00307941 0.000100246 0.00078749 0.00113914 +4.58591e-05 0.00029052 0.000486945 2.9619e-05 0.000101678 0.000148827 2.33115e-05 3.48065e-05 +6.73526e-05 3.39956e-06 3.69115e-06 9.03414e-06 1.10973e-05 0.000561533 0.0158827 0.0160544 +0.10203 6.96469e-07 0.000543107 0.0165868 0.0179468 0.0209534 1.26938e-06 9.31636e-05 +0.0134988 0.0147624 0.0188412 3.49364e-07 5.21841e-05 0.00908559 0.00980599 0.0124494 +4.8741e-07 2.80017e-05 0.00548797 0.00595887 0.00872226 1.47042e-07 1.40112e-05 0.00319001 +0.00341412 0.00497452 1.55652e-07 8.11539e-06 0.00178868 0.00181172 0.00315219 4.1026e-08 +4.25747e-06 0.000928262 0.000949085 0.00159341 4.33366e-08 2.31115e-06 0.000414829 0.000471228 +0.000894336 6.82658e-09 1.32567e-06 0.000177523 0.00021326 0.000381831 8.50005e-09 6.9477e-07 +6.49545e-05 9.12906e-05 0.000191355 1.17968e-09 4.23974e-07 2.02826e-05 2.98077e-05 5.78414e-05 +1.08748e-09 1.83654e-08 6.91167e-08 2.28524e-07 2.85146e-06 +O atom_index 1 n_descriptor 117 +8.39927 1.74924 0.320158 0.112639 0.0233291 0.00835168 0.00230151 0.0010965 +0.000685832 0.000358311 0.000283113 0.000141987 0.000102514 0.382931 0.785038 3.18816 +0.325464 0.403513 0.435225 0.17871 0.182868 0.186876 0.081024 0.0943096 +0.0978905 0.0362042 0.0431748 0.0474245 0.0161162 0.0227891 0.0232373 0.00758905 +0.0103734 0.0116325 0.00351414 0.00558713 0.00573454 0.00161866 0.00241805 0.00274659 +0.000718772 0.00125817 0.00128576 0.000294225 0.000473332 0.000545205 0.000127139 0.00025082 +0.000258046 1.45077e-05 2.71564e-05 2.99321e-05 5.9403e-06 0.000288006 0.000502287 0.000630795 +0.184366 1.39968e-06 0.000332439 0.000510098 0.000734575 0.00738666 1.21917e-06 0.000269666 +0.000294478 0.000627856 0.00317448 8.51215e-07 0.000146432 0.000184091 0.000469511 0.000989314 +5.24365e-07 8.09823e-05 0.000142 0.000310221 0.000470881 2.93804e-07 4.30581e-05 8.14991e-05 +0.000204871 0.000233799 1.7751e-07 2.40895e-05 6.00404e-05 0.0001152 0.000138208 9.21282e-08 +1.2903e-05 3.32158e-05 6.96494e-05 8.43918e-05 5.36017e-08 7.13565e-06 2.17522e-05 3.78762e-05 +5.14935e-05 2.54311e-08 3.67034e-06 1.15774e-05 2.31958e-05 2.95982e-05 1.37544e-08 1.98643e-06 +6.89745e-06 1.34907e-05 1.75484e-05 5.01753e-09 8.71328e-07 3.17905e-06 8.07677e-06 8.7924e-06 +3.33246e-11 5.102e-09 4.27705e-08 5.0544e-08 4.80027e-06 diff --git a/ABACUS.develop/examples/H2O-deepks/logout.bak b/ABACUS.develop/examples/H2O-deepks/logout.bak new file mode 100644 index 0000000000..bc638446e8 --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks/logout.bak @@ -0,0 +1,73 @@ + ********************************************************* + * * + * WELCOME TO ABACUS * + * * + * 'Atomic-orbital Based Ab-initio * + * Computation at UStc' * + * * + * Website: http://abacus.ustc.edu.cn/ * + * * + ********************************************************* + Sat Jan 30 16:21:16 2021 + MAKE THE DIR : OUT.abacus/ + DONE(0.0508616 SEC) : SETUP UNITCELL + DONE(0.0510054 SEC) : INIT K-POINTS + --------------------------------------------------------- + This calculation is self-consistent + --------------------------------------------------------- + SPIN KPOINTS PROCESSORS + 1 1 1 + --------------------------------------------------------- + Use plane wave basis + --------------------------------------------------------- + ELEMENT NATOM XC + H 2 PBE + O 1 PBE + --------------------------------------------------------- + Initial plane wave basis and FFT box + --------------------------------------------------------- + DONE(0.128295 SEC) : INIT PLANEWAVE + UNIFORM GRID DIM : 48 * 48 * 48 + UNIFORM GRID DIM(BIG): 48 * 48 * 48 + MEMORY FOR PSI (MB) : 0.552155 + DONE(0.142381 SEC) : LOCAL POTENTIAL + DONE(0.147029 SEC) : NON-LOCAL POTENTIAL + START POTENTIAL : atomic + DONE(0.220855 SEC) : INIT POTENTIAL + DONE(0.25472 SEC) : INIT BASIS + ------------------------------------------- + SELF-CONSISTENT : + ------------------------------------------- + ITER ETOT(eV) EDIFF(eV) DRHO2 CG_ITER TIME(S) + CG1 -2.835018e+01 0.000000e+00 5.192e+00 1.000e+01 3.332e-01 + CG2 -2.718276e+01 1.167415e+00 6.586e-01 3.000e+00 1.672e-01 + CG3 -2.922537e+01 -2.042603e+00 3.547e-02 2.667e+00 1.576e-01 + CG4 -2.927314e+01 -4.777474e-02 5.820e-02 4.000e+00 1.858e-01 + CG5 -2.937300e+01 -9.986165e-02 1.613e-03 2.667e+00 1.610e-01 + CG6 -2.937923e+01 -6.231003e-03 1.783e-05 5.500e+00 2.225e-01 + CG7 -2.937924e+01 -3.778364e-06 8.821e-06 5.000e+00 2.062e-01 + CG8 -2.937925e+01 -9.245653e-06 6.311e-07 2.667e+00 1.563e-01 + CG9 -2.937925e+01 -1.147022e-06 5.296e-08 4.667e+00 2.033e-01 + CG10 -2.937925e+01 -1.211570e-07 9.727e-09 5.167e+00 2.038e-01 + DONE(2.398e+00 SEC) : jlq3d_overlap + DONE(2.399e+00 SEC) : GENERATE DESCRIPTOR FOR DEEPKS + + |CLASS_NAME---------|NAME---------------|TIME(Sec)-----|CALLS----|AVG------|PER%------- + A DC_Driv solve_eachf 2.3 1 2.3 95 % + B Run_Frag frag_pw_line 2.3 1 2.3 95 % + X FFT FFT3D 1.2 879 0.0014 50 % + E potential v_of_rho 0.56 11 0.051 23 % + G Hamilt_PW cinitcgg 0.26 11 0.023 11 % + H Hamilt_PW h_psi 1.1 338 0.0034 47 % + C Ions opt_ions_pw 2 1 2 83 % + D electrons self_consistent 2 1 2 83 % + E electrons c_bands 1.2 10 0.12 51 % + F Hamilt diago 1.2 10 0.12 51 % + G Diago_CG diag 0.98 10 0.098 41 % + E Charge mix_rho 0.13 10 0.013 5.5 % + ---------------------------------------------------------------------------------------- + + START Time : Sat Jan 30 16:21:16 2021 + FINISH Time : Sat Jan 30 16:21:18 2021 + TOTAL Time : 2 + SEE INFORMATION IN : OUT.abacus/ diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 20f60ae9bb..7866a9e5ab 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -181,6 +181,7 @@ cal_r_overlap_R.o \ OBJS_WANNIER=wan_global.o\ bessel_basis.o\ numerical_basis.o\ +numerical_descriptor.o\ wavefunc_in_pw.o\ OBJS_EPM=run_epm.o\ diff --git a/ABACUS.develop/source/Makefile.vars b/ABACUS.develop/source/Makefile.vars index e1c8800df9..31d2341967 100644 --- a/ABACUS.develop/source/Makefile.vars +++ b/ABACUS.develop/source/Makefile.vars @@ -1,15 +1,25 @@ FORTRAN = ifort -#CPLUSPLUS = icpc -#CPLUSPLUS_MPI = mpiicpc -CPLUSPLUS = /public/intel2017/bin/icpc -CPLUSPLUS_MPI = /public/intel2017/impi/2017.1.132/intel64/bin/mpiicpc + +CPLUSPLUS = icpc +#CPLUSPLUS = /public/intel2017/bin/icpc + +CPLUSPLUS_MPI = mpiicpc +#CPLUSPLUS_MPI = /public/intel2017/impi/2017.1.132/intel64/bin/mpiicpc + +LAPACK_DIR = $(MKLROOT) #LAPACK_DIR = /public/intel2017/compilers_and_libraries_2017.1.132/linux/mkl #LAPACK_DIR = $(MKLROOT) -LAPACK_DIR = /public/intel2017/mkl +#LAPACK_DIR = /public/intel2017/mkl + +FFTW_DIR = /home/qianrui/intelcompile/impi_fftw #FFTW_DIR = /public/udata/xiaohui/software/fftw2 #FFTW_DIR =/opt/fftw/3.3.6-p12/intel/2017.update4 -FFTW_DIR = /public/fftw-3.3.8 -BOOST_DIR = /public/udata/xiaohui/software/boost_1_39_0 +#FFTW_DIR = /public/fftw-3.3.8 + +BOOST_DIR = /home/qianrui/intelcompile/impi_boost +#BOOST_DIR = /public/udata/xiaohui/software/boost_1_39_0 #BOOST_DIR = /opt/boost/1.64.0 -ELPA_DIR = /public/udata/xiaohui/ELPA-2016.05.004 + +ELPA_DIR=/home/qianrui/intelcompile/test/soft_epla +#ELPA_DIR = /public/udata/xiaohui/ELPA-2016.05.004 #ELPA_DIR = /opt/elpa/intel_2017_update4 diff --git a/ABACUS.develop/source/input.cpp b/ABACUS.develop/source/input.cpp index e058ca7ced..a550ec8bdb 100644 --- a/ABACUS.develop/source/input.cpp +++ b/ABACUS.develop/source/input.cpp @@ -287,6 +287,10 @@ void Input::Default(void) charge_extrap = "atomic";//xiaohui modify 2015-02-01 out_charge = 0; out_dm = 0; + + out_descriptor = 0; // caoyu added 2020-11-24, mohan added 2021-01-03 + lmax_descriptor = 2; // mohan added 2021-01-03 + out_potential = 0; out_wf = false; out_dos = 0; @@ -1065,6 +1069,14 @@ bool Input::Read(const string &fn) { read_value(ifs, out_dm); } + else if (strcmp("out_descriptor", word) == 0) // caoyu added 2020-11-24, mohan modified 2021-01-03 + { + read_value(ifs, out_descriptor); + } + else if (strcmp("lmax_descriptor", word) == 0)// mohan added 2021-01-03 + { + read_value(ifs, lmax_descriptor); + } else if (strcmp("out_potential", word) == 0) { read_value(ifs, out_potential); @@ -2078,6 +2090,9 @@ void Input::Bcast() Parallel_Common::bcast_string( charge_extrap );//xiaohui modify 2015-02-01 Parallel_Common::bcast_int( out_charge ); Parallel_Common::bcast_int( out_dm ); + Parallel_Common::bcast_int( out_descriptor ); // caoyu added 2020-11-24, mohan modified 2021-01-03 + Parallel_Common::bcast_int( lmax_descriptor ); // mohan modified 2021-01-03 + Parallel_Common::bcast_int( out_potential ); Parallel_Common::bcast_bool( out_wf ); Parallel_Common::bcast_int( out_dos ); @@ -3088,6 +3103,8 @@ void Input::Print(const string &fn)const OUTP(ofs,"move_method",ion_dynamics,"bfgs; sd; cg; cg_bfgs;"); //pengfei add 2013-08-15 OUTP(ofs,"out_level",out_level,"ie(for electrons); i(for ions);"); OUTP(ofs,"out_dm",out_dm,">0 output density matrix"); + OUTP(ofs,"out_descriptor",out_descriptor,">0 compute descriptor for deepks");//caoyu added 2020-11-24, mohan added 2021-01-03 + OUTP(ofs,"lmax_descriptor",lmax_descriptor,">0 lmax used in descriptor for deepks");//caoyu added 2020-11-24, mohan added 2021-01-03 ofs << "\n#Parameters (4.LCAO)" << endl; //OUTP(ofs,"local_basis",local_basis,"0:PW; 1:LO in pw; 4:LCAO"); xiaohui modify 2013-09-01 diff --git a/ABACUS.develop/source/input.h b/ABACUS.develop/source/input.h index c69108d113..b7df9e6049 100644 --- a/ABACUS.develop/source/input.h +++ b/ABACUS.develop/source/input.h @@ -388,6 +388,13 @@ class Input //The two parameters below are not usable currently int dftu_type; //1:rotationally invarient formalism; 2:simplified form(default) int double_counting; // 1:FLL(fully localized limit)(default); 2:AMF(around mean field) + + + // for deepks + int out_descriptor; // output descritpor for deepks. caoyu added 2020-11-24, mohan modified 2021-01-03 + int lmax_descriptor; // lmax used in descriptor, mohan added 2021-01-03 + + private: //========================================================== // MEMBER FUNCTIONS : diff --git a/ABACUS.develop/source/run_frag.cpp b/ABACUS.develop/source/run_frag.cpp index 7955c12fb1..ab31937378 100644 --- a/ABACUS.develop/source/run_frag.cpp +++ b/ABACUS.develop/source/run_frag.cpp @@ -134,6 +134,9 @@ void Run_Frag::pw_line(void) Ions ions; ions.opt_ions_pw(); + + + //if (MLWF_FLAG) //{ // mlwf_optimize op; @@ -364,6 +367,15 @@ void Run_Frag::frag_pw_line(void) Ions ions; ions.opt_ions_pw(); + + // caoyu added 2020-11-24, mohan updated 2021-01-03 + if(BASIS_TYPE=="pw" && INPUT.out_descriptor==1) + { + Numerical_Descriptor nc; + nc.output_descriptor(wf.evc, INPUT.lmax_descriptor); + DONE(ofs_running,"GENERATE DESCRIPTOR FOR DEEPKS"); + } + // } //if (LOCAL_BASIS==0 && winput::out_spillage) xiaohui modify 2013-09-01 if(BASIS_TYPE=="pw" && winput::out_spillage) //xiaohui add 2013-09-01 diff --git a/ABACUS.develop/source/src_pw/algorithms.h b/ABACUS.develop/source/src_pw/algorithms.h index b11cd0c04b..122f6558fa 100644 --- a/ABACUS.develop/source/src_pw/algorithms.h +++ b/ABACUS.develop/source/src_pw/algorithms.h @@ -9,6 +9,7 @@ #include "../src_pw/myfunc.h" #include "numerical_basis.h" +#include "numerical_descriptor.h" // mohan added 2021-01-04 #include "bessel_basis.h" //#include "../src_algorithms/spillage.h" //#include "../src_algorithms/mymath.h" diff --git a/ABACUS.develop/source/src_pw/bessel_basis.cpp b/ABACUS.develop/source/src_pw/bessel_basis.cpp index a0c12f1fb7..6a3f49df6c 100644 --- a/ABACUS.develop/source/src_pw/bessel_basis.cpp +++ b/ABACUS.develop/source/src_pw/bessel_basis.cpp @@ -18,6 +18,7 @@ void Bessel_Basis::init( const bool start_from_file, const double &ecutwfc, const int &ntype, + const int &lmax_in, const double &dk, const double &dr) { @@ -42,7 +43,7 @@ void Bessel_Basis::init( //------------------ // Making a table //------------------ - this->init_TableOne( this->smooth, this->sigma, ecutwfc, rcut, dr, Dk, ucell.lmax, Ecut_number, tolerence); + this->init_TableOne( this->smooth, this->sigma, ecutwfc, rcut, dr, Dk, lmax_in, Ecut_number, tolerence); //----------------------------------------------- // for test. @@ -56,14 +57,14 @@ void Bessel_Basis::init( if( start_from_file ) { // setup C4 - this->allocate_C4(ntype, ucell.lmax, ucell.nmax, Ecut_number); + this->allocate_C4(ntype, lmax_in, ucell.nmax, Ecut_number); // check tolerence this->readin_C4("INPUTs", ntype, ecut, rcut, Ecut_number, tolerence); #ifdef __MPI Parallel_Common::bcast_double( C4.ptr, C4.getSize() ); #endif - this->init_Faln(ntype, ucell.lmax, ucell.nmax, Ecut_number); + this->init_Faln(ntype, lmax_in, ucell.nmax, Ecut_number); } return; diff --git a/ABACUS.develop/source/src_pw/bessel_basis.h b/ABACUS.develop/source/src_pw/bessel_basis.h index 03887730fa..c69b9a992b 100644 --- a/ABACUS.develop/source/src_pw/bessel_basis.h +++ b/ABACUS.develop/source/src_pw/bessel_basis.h @@ -1,7 +1,7 @@ //========================================================== // AUTHOR : mohan // DATE : 2009-3-29 -// Last Modify : 2009-08-28 +// Last Modify : 2021-01-04 //========================================================== #ifndef BESSEL_BASIS_H #define BESSEL_BASIS_H @@ -17,11 +17,20 @@ class Bessel_Basis Bessel_Basis(); ~Bessel_Basis(); + //-------------------------------------------------------------------------- // used for a specific group of C4 coefficients. + // mohan updated 2021-01-04, + // mohan added a new input parameter lmax_in, + // if we only generate numerical atomic orbitals based on + // spherical Bessel functions, lmax_in = ucell.lmax + // However, if we want to generate spherical Bessel functions for descriptor, + // then the lmax_in is controlled by user. + //-------------------------------------------------------------------------- void init( const bool start_from_file, const double &ecutwfc, const int &ntype, + const int &lmax_in, const double &dk = 0.01, const double &dr = 0.01); diff --git a/ABACUS.develop/source/src_pw/numerical_basis.cpp b/ABACUS.develop/source/src_pw/numerical_basis.cpp index eea53aecc3..fa2a29b5f7 100644 --- a/ABACUS.develop/source/src_pw/numerical_basis.cpp +++ b/ABACUS.develop/source/src_pw/numerical_basis.cpp @@ -33,7 +33,7 @@ void Numerical_Basis::start_from_file_k( const int &ik, ComplexMatrix &psi) if (!Numerical_Basis::init_label) { // 1 stands for : start_from_file - Numerical_Basis::bessel_basis.init( 1, pw.ecutwfc, ucell.ntype ); + Numerical_Basis::bessel_basis.init( 1, pw.ecutwfc, ucell.ntype, ucell.lmax ); Numerical_Basis::init_mu_index(); Numerical_Basis::init_label = true; } @@ -41,11 +41,11 @@ void Numerical_Basis::start_from_file_k( const int &ik, ComplexMatrix &psi) return; } + // The function is called in run_fp.cpp. void Numerical_Basis::output_overlap( const ComplexMatrix *psi) { TITLE("Numerical_Basis","output_overlap"); - NEW_PART("Overlap Data For Spillage Minimization"); //--------------------------------------------------------- @@ -55,7 +55,7 @@ void Numerical_Basis::output_overlap( const ComplexMatrix *psi) if (!Numerical_Basis::init_label) { // 0 stands for : 'Faln' is not used. - Numerical_Basis::bessel_basis.init( 0, pw.ecutwfc, ucell.ntype ); + Numerical_Basis::bessel_basis.init( 0, pw.ecutwfc, ucell.ntype, ucell.lmax ); Numerical_Basis::init_mu_index(); Numerical_Basis::init_label = true; } @@ -357,7 +357,7 @@ void Numerical_Basis::output_overlap_Q( for (int i=0; i overlapQ = ZERO; + complex overlapQ = ZERO; for (int T1 = 0; T1 < ucell.ntype; T1++) { //OUT("T1",T1); @@ -597,6 +597,7 @@ void Numerical_Basis::jlq3d_overlap( void Numerical_Basis::init_mu_index(void) { + ofs_running << " Initialize the mu index" << endl; Numerical_Basis::mu_index = new IntArray[ucell.ntype]; int mu = 0; @@ -608,6 +609,13 @@ void Numerical_Basis::init_mu_index(void) ucell.nmax, 2*(ucell.atoms[it].nwl+1)+1); // m ==> 2*l+1 + // mohan added 2021-01-03 + ofs_running << "Type " << it+1 + << " number_of_atoms " << ucell.atoms[it].na + << " number_of_L " << ucell.atoms[it].nwl+1 + << " number_of_n " << ucell.nmax + << " number_of_m " << 2*(ucell.atoms[it].nwl+1)+1 << endl; + for (int ia=0; iainit_label = false; + this->lmax = -1; + this->nmax = -1; +} + +Numerical_Descriptor::~Numerical_Descriptor() +{ + if(init_label==true) + { + delete[] mu_index; + } + return; +} + + +void Numerical_Descriptor::output_descriptor(const ComplexMatrix *psi, const int &lmax_in) +{ + TITLE("Numerical_Descriptor","output_descriptor"); + NEW_PART("DeepKS descriptor: D_{Inl}"); + + //----------------------------------- + // 1. Initialize parameters + //----------------------------------- + + //ofs_running << "D_{Inl}_m_m'=sum_{i}" << endl; + ofs_running << "input lmax = " << lmax << endl; + this->lmax = lmax_in; + assert(lmax>=0); + + const int nks = kv.nks; + int ne = 0; + + // 0 stands for : 'Faln' is not used. + this->bessel_basis.init( 0, pw.ecutwfc, ucell.ntype, this->lmax ); + this->nmax = Numerical_Descriptor::bessel_basis.get_ecut_number(); + this->init_mu_index(); + this->init_label = true; + + assert(nmax>0); + + + //----------------------------------- + // 2. Open the file + //----------------------------------- + ofstream ofs; + stringstream ss; + // the parameter 'winput::spillage_outdir' is read from INPUTw. + ss << winput::spillage_outdir << "/" << "descriptor.dat"; + if (MY_RANK==0) + { + ofs.open(ss.str().c_str()); + } + + + //------------------------------------- + // 3. Initialize overlap_Q1 and Q2 + //------------------------------------- + // OVERLAP : < J_mu | Psi > + realArray overlap_Q1(nks, NBANDS, this->nlocal ); + realArray overlap_Q2(nks, NBANDS, this->nlocal ); + + ZEROS(overlap_Q1.ptr, overlap_Q1.getSize() ); + ZEROS(overlap_Q2.ptr, overlap_Q2.getSize() ); + + OUT(ofs_running,"number of k points",overlap_Q1.getBound1()); + OUT(ofs_running,"number of bands",overlap_Q1.getBound2()); + OUT(ofs_running,"number of local orbitals",overlap_Q1.getBound3()); + + + //------------------------------------- + // 4. Compute overlap_Q1 and Q2 + //------------------------------------- + // nks now is the reduced k-points. + for (int ik=0; ikjlq3d_overlap(overlap_Q1, overlap_Q2, ik, ik, npw, psi[ik]); + DONE(ofs_running,"jlq3d_overlap"); + } + +#ifdef __MPI + Parallel_Reduce::reduce_double_pool( overlap_Q1.ptr, overlap_Q1.getSize() ); + Parallel_Reduce::reduce_double_pool( overlap_Q2.ptr, overlap_Q2.getSize() ); +#endif + + // do not need to output here + //this->output_overlap_Q( ofs, overlap_Q1, overlap_Q2 ); + + + + //------------------------------------- + // 5. Generate descriptors for each atom + //------------------------------------- + + for (int it=0; itgenerate_descriptor(overlap_Q1, overlap_Q2, it ,ia, d, nd); + + ofs << ucell.atoms[it].label << " atom_index " << ia+1 << " n_descriptor " << nd << endl; + for(int id=0; id0 && id%8==0) ofs << endl; + // if(abs(d[id]>1.0e-9)) ofs << d[id] << " "; + // else ofs << "0 "; + ofs << d[id] << " "; + } + ofs << endl; + + delete[] d; + } + } + + + + if (MY_RANK==0) ofs.close(); + return; +} + + +void Numerical_Descriptor::generate_descriptor(realArray &overlap_Q1, realArray &overlap_Q2, +const int &it, const int &ia, double *d, const int &nd) +{ + int nbands = overlap_Q1.getBound2(); + // nwfc = nd * ne + int nwfc = overlap_Q1.getBound3(); + int start0 = mu_index[it](ia, 0, 0, 0); //min mu_index for each atom + + + // for 1 k-point only now + int ik=0; + + + ofs_running << " print out each descriptor" << endl; + int id=0; + for (int l=0; l c1(overlap_Q1(ik, ib, ii), overlap_Q2(ik, ib, ii)); + complex c2(overlap_Q1(ik, ib, jj), -overlap_Q2(ik, ib, jj)); + des(m,m2) += c1*c2; + } + // ofs_running << setw(15) << des(m,m2); + } + // ofs_running << endl; + } + ofs_running << "dimension of des is " << 2*l+1 << endl; + + if(l==0) + { + d[id]=des(0,0).real(); + ++id; + } + else + { + // diagonalizae + // assume des matrix is Hermitian + char jobz = 'N'; // eigenvalues only + char uplo = 'U'; // upper matrix is stored + int ndim = des.nr; + double* tmpd = new double[ndim](); + const int lwork = 2*ndim; + complex* work = new complex[lwork](); + double* rwork = new double[3 * ndim - 2](); + int infor = 0; + // diag by calling zheev + LapackConnector::zheev(jobz, uplo, ndim, des, ndim, tmpd, work, lwork, rwork, &infor); + // put the eigenvalues into d (descriptor) + for(int idim=0; idim1) TITLE("Numerical_Descriptor","jlq3d_overlap"); + timer::tick("Numerical_Descriptor","jlq3d_overlap"); + + ofs_running << " OUTPUT THE OVERLAP BETWEEN SPHERICAL BESSEL FUNCTIONS AND BLOCH WAVE FUNCTIONS" << endl; + ofs_running << " Q = < J_it_ia_il_in_im | Psi_n, k > " << endl; + + const double normalization = (4 * PI) / sqrt(ucell.omega);// Peize Lin add normalization 2015-12-29 + + const int total_lm = ( this->lmax + 1) * ( this->lmax + 1); + matrix ylm(total_lm, np); + + Vector3 *gk = new Vector3 [np]; + for (int ig=0; ig overlapQ = ZERO; + for (int T1 = 0; T1 < ucell.ntype; T1++) + { + for (int I1 = 0; I1 < ucell.atoms[T1].na; I1++) + { + complex *sk = wf.get_sk(ik, T1, I1); + for (int L=0; L< lmax+1; L++) + { + ofs_running << " " << setw(5) << ik+1 + << setw(8) << ucell.atoms[T1].label + << setw(8) << I1+1 + << setw(8) << L + << endl; + //OUT("l",l); + complex lphase = normalization * pow(IMAG_UNIT, L); // Peize Lin add normalization 2015-12-29 + for (int ie=0; ie < nmax; ie++) + { + for (int ig=0; ig overlap_tmp = ZERO; + for (int ig=0; ig local_tmp = lphase * sk[ig] * ylm(lm, ig) * flq[ig]; + overlap_tmp += conj( local_tmp ) * psi(ib, ig); // psi is bloch orbitals + } + overlap_Q1(ik_ibz, ib, mu_index[T1](I1, L, ie, m)) = overlap_tmp.real(); + overlap_Q2(ik_ibz, ib, mu_index[T1](I1, L, ie, m)) = overlap_tmp.imag(); + } + } + }//end ie + }//end l + delete[] sk; + } + } + + delete[] flq; + delete[] gk; + timer::tick("Numerical_Descriptor","jlq3d_overlap"); + return; +} + + +void Numerical_Descriptor::init_mu_index(void) +{ + ofs_running << " Initialize the mu index for deepks" << endl; + ofs_running << " lmax = " << this->lmax << endl; + ofs_running << " nmax = " << this->nmax << endl; + Numerical_Descriptor::mu_index = new IntArray[ucell.ntype]; + + assert(lmax>=0); + assert(nmax>0); + + int mu=0; + for (int it=0; itmu_index[it].create( + ucell.atoms[it].na, + lmax+1, // l starts from 0 + nmax, + 2*lmax+1); // m ==> 2*l+1 + + ofs_running << "Type " << it+1 + << " number_of_atoms " << ucell.atoms[it].na + << " number_of_L " << lmax+1 + << " number_of_n " << nmax + << " number_of_m " << 2*lmax+1 << endl; + + for (int ia=0; iamu_index[it](ia,l,n,m) = mu; + mu++; + } + } + } + } + + } + + this->nlocal = mu; + ofs_running << " total number of atomic orbitals " << nlocal << endl; + + return; +} diff --git a/ABACUS.develop/source/src_pw/numerical_descriptor.h b/ABACUS.develop/source/src_pw/numerical_descriptor.h new file mode 100644 index 0000000000..92c31e15bd --- /dev/null +++ b/ABACUS.develop/source/src_pw/numerical_descriptor.h @@ -0,0 +1,42 @@ +//========================================================== +// AUTHOR : mohan +// DATE : 2021-01-04 +//========================================================== +#ifndef NUMERICAL_DESCRIPTOR_H +#define NUMERICAL_DESCRIPTOR_H +#include "../src_pw/tools.h" +#include "bessel_basis.h" +//========================================================== +// CLASS : +// NAME : Numerical_Descriptor +//========================================================== +class Numerical_Descriptor +{ + public: + Numerical_Descriptor(); + ~Numerical_Descriptor(); + + void output_descriptor( const ComplexMatrix *psi, const int &lmax_in); // mohan added 2021-01-03 + + private: + + bool init_label; + + int lmax; // lmax for descriptor + int nmax; // nmax for descriptor + int nlocal; // total number of atomic orbitals + + Bessel_Basis bessel_basis; + + IntArray *mu_index; + void init_mu_index(void);//mohan added 2021-01-03 + + void jlq3d_overlap(realArray &overlap_Q1, realArray &overlap_Q2, + const int &ik_ibz, const int &ik, const int &np, const ComplexMatrix &psi); + + void generate_descriptor(realArray &overlap_Q1, realArray &overlap_Q2, + const int &it, const int &ia, double *d, const int &nd); + +}; + +#endif From 6da3c69ef2b94f30224177b7e48fcad3650fe31c Mon Sep 17 00:00:00 2001 From: mohanchen Date: Sat, 30 Jan 2021 17:29:38 +0800 Subject: [PATCH 043/233] delete clean.sh --- ABACUS.develop/source/src_lcao/clean.sh | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 ABACUS.develop/source/src_lcao/clean.sh diff --git a/ABACUS.develop/source/src_lcao/clean.sh b/ABACUS.develop/source/src_lcao/clean.sh deleted file mode 100644 index 2184a1ee9b..0000000000 --- a/ABACUS.develop/source/src_lcao/clean.sh +++ /dev/null @@ -1,4 +0,0 @@ -rm cal_reduce_rho.o -rm get_pole.o -rm selinv.o -rm siao_interf.o From f4660c074c97c8e109108623922b988af30dcff5 Mon Sep 17 00:00:00 2001 From: mohanchen Date: Sun, 31 Jan 2021 08:34:35 +0800 Subject: [PATCH 044/233] divide the H2O-deepks example into pw and lcao two cases --- .../H_ONCV_PBE-1.0.upf | 0 .../H_gga_8au_60Ry_2s1p.orb | 0 ABACUS.develop/examples/H2O-deepks-lcao/INPUT | 29 + .../{H2O-deepks => H2O-deepks-lcao}/KPT | 0 .../O_ONCV_PBE-1.0.upf | 0 .../O_gga_7au_60Ry_2s2p1d.orb | 0 ABACUS.develop/examples/H2O-deepks-lcao/STRU | 28 + .../examples/H2O-deepks-lcao/logout.bak | 82 ++ .../examples/H2O-deepks-pw/H_ONCV_PBE-1.0.upf | 897 ++++++++++++ .../H2O-deepks-pw/H_gga_8au_60Ry_2s1p.orb | 621 +++++++++ .../{H2O-deepks => H2O-deepks-pw}/INPUT | 0 .../{H2O-deepks => H2O-deepks-pw}/INPUTs | 0 ABACUS.develop/examples/H2O-deepks-pw/KPT | 4 + .../examples/H2O-deepks-pw/O_ONCV_PBE-1.0.upf | 1224 +++++++++++++++++ .../H2O-deepks-pw/O_gga_7au_60Ry_2s2p1d.orb | 903 ++++++++++++ .../{H2O-deepks => H2O-deepks-pw}/STRU | 0 .../descriptor.dat | 0 .../descriptor.dat.bak | 0 .../{H2O-deepks => H2O-deepks-pw}/logout.bak | 0 19 files changed, 3788 insertions(+) rename ABACUS.develop/examples/{H2O-deepks => H2O-deepks-lcao}/H_ONCV_PBE-1.0.upf (100%) rename ABACUS.develop/examples/{H2O-deepks => H2O-deepks-lcao}/H_gga_8au_60Ry_2s1p.orb (100%) create mode 100644 ABACUS.develop/examples/H2O-deepks-lcao/INPUT rename ABACUS.develop/examples/{H2O-deepks => H2O-deepks-lcao}/KPT (100%) rename ABACUS.develop/examples/{H2O-deepks => H2O-deepks-lcao}/O_ONCV_PBE-1.0.upf (100%) rename ABACUS.develop/examples/{H2O-deepks => H2O-deepks-lcao}/O_gga_7au_60Ry_2s2p1d.orb (100%) create mode 100644 ABACUS.develop/examples/H2O-deepks-lcao/STRU create mode 100644 ABACUS.develop/examples/H2O-deepks-lcao/logout.bak create mode 100644 ABACUS.develop/examples/H2O-deepks-pw/H_ONCV_PBE-1.0.upf create mode 100644 ABACUS.develop/examples/H2O-deepks-pw/H_gga_8au_60Ry_2s1p.orb rename ABACUS.develop/examples/{H2O-deepks => H2O-deepks-pw}/INPUT (100%) rename ABACUS.develop/examples/{H2O-deepks => H2O-deepks-pw}/INPUTs (100%) create mode 100644 ABACUS.develop/examples/H2O-deepks-pw/KPT create mode 100644 ABACUS.develop/examples/H2O-deepks-pw/O_ONCV_PBE-1.0.upf create mode 100644 ABACUS.develop/examples/H2O-deepks-pw/O_gga_7au_60Ry_2s2p1d.orb rename ABACUS.develop/examples/{H2O-deepks => H2O-deepks-pw}/STRU (100%) rename ABACUS.develop/examples/{H2O-deepks => H2O-deepks-pw}/descriptor.dat (100%) rename ABACUS.develop/examples/{H2O-deepks => H2O-deepks-pw}/descriptor.dat.bak (100%) rename ABACUS.develop/examples/{H2O-deepks => H2O-deepks-pw}/logout.bak (100%) diff --git a/ABACUS.develop/examples/H2O-deepks/H_ONCV_PBE-1.0.upf b/ABACUS.develop/examples/H2O-deepks-lcao/H_ONCV_PBE-1.0.upf similarity index 100% rename from ABACUS.develop/examples/H2O-deepks/H_ONCV_PBE-1.0.upf rename to ABACUS.develop/examples/H2O-deepks-lcao/H_ONCV_PBE-1.0.upf diff --git a/ABACUS.develop/examples/H2O-deepks/H_gga_8au_60Ry_2s1p.orb b/ABACUS.develop/examples/H2O-deepks-lcao/H_gga_8au_60Ry_2s1p.orb similarity index 100% rename from ABACUS.develop/examples/H2O-deepks/H_gga_8au_60Ry_2s1p.orb rename to ABACUS.develop/examples/H2O-deepks-lcao/H_gga_8au_60Ry_2s1p.orb diff --git a/ABACUS.develop/examples/H2O-deepks-lcao/INPUT b/ABACUS.develop/examples/H2O-deepks-lcao/INPUT new file mode 100644 index 0000000000..e9253e2028 --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks-lcao/INPUT @@ -0,0 +1,29 @@ +INPUT_PARAMETERS +#Parameters (1.General) +suffix abacus +calculation scf +ntype 2 +nbands 6 +symmetry 0 + +#Parameters (2.Iteration) +ecutwfc 50 +dr2 1e-8 +niter 50 + +#Parameters (3.Basis) +basis_type lcao +gamma_only 1 + +#Parameters (4.Smearing) +smearing gaussian +sigma 0.02 + +#Parameters (5.Mixing) +mixing_type pulay +mixing_beta 0.4 + +#Parameters (6.File) +out_band 0 +out_descriptor 1 +lmax_descriptor 2 diff --git a/ABACUS.develop/examples/H2O-deepks/KPT b/ABACUS.develop/examples/H2O-deepks-lcao/KPT similarity index 100% rename from ABACUS.develop/examples/H2O-deepks/KPT rename to ABACUS.develop/examples/H2O-deepks-lcao/KPT diff --git a/ABACUS.develop/examples/H2O-deepks/O_ONCV_PBE-1.0.upf b/ABACUS.develop/examples/H2O-deepks-lcao/O_ONCV_PBE-1.0.upf similarity index 100% rename from ABACUS.develop/examples/H2O-deepks/O_ONCV_PBE-1.0.upf rename to ABACUS.develop/examples/H2O-deepks-lcao/O_ONCV_PBE-1.0.upf diff --git a/ABACUS.develop/examples/H2O-deepks/O_gga_7au_60Ry_2s2p1d.orb b/ABACUS.develop/examples/H2O-deepks-lcao/O_gga_7au_60Ry_2s2p1d.orb similarity index 100% rename from ABACUS.develop/examples/H2O-deepks/O_gga_7au_60Ry_2s2p1d.orb rename to ABACUS.develop/examples/H2O-deepks-lcao/O_gga_7au_60Ry_2s2p1d.orb diff --git a/ABACUS.develop/examples/H2O-deepks-lcao/STRU b/ABACUS.develop/examples/H2O-deepks-lcao/STRU new file mode 100644 index 0000000000..8dc2ac2824 --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks-lcao/STRU @@ -0,0 +1,28 @@ +ATOMIC_SPECIES +H 1.008 H_ONCV_PBE-1.0.upf +O 15.9994 O_ONCV_PBE-1.0.upf + +NUMERICAL_ORBITAL +H_gga_8au_60Ry_2s1p.orb +O_gga_7au_60Ry_2s2p1d.orb + +LATTICE_CONSTANT +10 + +LATTICE_VECTORS +1 0 0 +0 1 0 +0 0 1 + +ATOMIC_POSITIONS +Cartesian + +H +0 +2 +0.2336137046291667 0.8630016418166666 0.7271997623458333 1 1 1 +0.23417266949166665 0.9245341895916668 0.7207232227333333 1 1 1 +O +0 +1 +0.20910677665833333 0.894927691625 0.7301984601833333 1 1 1 diff --git a/ABACUS.develop/examples/H2O-deepks-lcao/logout.bak b/ABACUS.develop/examples/H2O-deepks-lcao/logout.bak new file mode 100644 index 0000000000..90753c0739 --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks-lcao/logout.bak @@ -0,0 +1,82 @@ + ********************************************************* + * * + * WELCOME TO ABACUS * + * * + * 'Atomic-orbital Based Ab-initio * + * Computation at UStc' * + * * + * Website: http://abacus.ustc.edu.cn/ * + * * + ********************************************************* + Sun Jan 31 08:33:37 2021 + MAKE THE DIR : OUT.abacus/ + DONE(0.0260551 SEC) : SETUP UNITCELL + DONE(0.0263662 SEC) : INIT K-POINTS + Set NonLocal Pseudopotential Projectors + Set NonLocal Pseudopotential Projectors + --------------------------------------------------------- + This calculation is self-consistent + --------------------------------------------------------- + SPIN KPOINTS PROCESSORS NBASE VNA + 1 Gamma 1 23 No + --------------------------------------------------------- + Use Systematically Improvable Atomic bases + --------------------------------------------------------- + ELEMENT ORBITALS NBASE NATOM XC + H 2s1p-8au 5 2 PBE + O 2s2p1d-7au 13 1 PBE + --------------------------------------------------------- + Initial plane wave basis and FFT box + --------------------------------------------------------- + DONE(2.05283 SEC) : INIT PLANEWAVE + UNIFORM GRID DIM : 48 * 48 * 48 + UNIFORM GRID DIM(BIG): 24 * 24 * 24 + DONE(2.05708 SEC) : INIT CHARGE + DONE(2.05915 SEC) : INIT POTENTIAL + START POTENTIAL : atomic + --------------------------------------------------------- + SELF-CONSISTENT : + --------------------------------------------------------- + ITER ETOT(eV) EDIFF(eV) DRHO2 TIME(s) + GE1 -3.134306e+01 0.000000e+00 5.723e-01 2.655e+00 + GE2 -2.781937e+01 3.523688e+00 2.294e-01 2.212e+00 + GE3 -2.983035e+01 -2.010973e+00 6.208e-02 2.218e+00 + GE4 -2.986621e+01 -3.586508e-02 5.733e-02 2.227e+00 + GE5 -2.995450e+01 -8.828721e-02 5.451e-03 2.181e+00 + GE6 -2.995491e+01 -4.083400e-04 5.742e-04 2.256e+00 + GE7 -2.995495e+01 -3.913860e-05 1.328e-04 2.219e+00 + GE8 -2.995494e+01 5.743730e-06 2.460e-05 2.356e+00 + GE9 -2.995494e+01 -1.697013e-06 6.807e-06 2.237e+00 + GE10 -2.995494e+01 -6.295011e-07 2.400e-07 2.240e+00 + GE11 -2.995494e+01 2.095797e-08 3.145e-08 2.236e+00 + GE12 -2.995494e+01 3.105281e-09 2.690e-09 2.086e+00 + + |CLASS_NAME---------|NAME---------------|TIME(Sec)-----|CALLS----|AVG------|PER%------- + A DC_Driv reading 2 1 2 50 % + B Hamilt_Linear set_orb_tables 1.9 1 1.9 49 % + C LCAO_Orbitals Read_Orbitals 1.2 1 1.2 29 % + C Use_Overlap_Table gen_tables 0.78 1 0.78 20 % + D Make_Overlap_Table init_Table 0.46 1 0.46 11 % + D Make_Overlap_Table init_Table_Beta 0.17 1 0.17 4.3 % + A DC_Driv solve_eachf 1.9 1 1.9 48 % + B Run_Frag frag_LCAO_line 1.9 1 1.9 48 % + X FFT FFT3D 0.36 169 0.0021 9.1 % + E potential v_of_rho 0.91 13 0.07 23 % + C Local_Orbital_Ions opt_ions 1.8 1 1.8 46 % + D Local_Orbital_Elec scf 1.7 1 1.7 43 % + E Local_Orbital_Elec cal_bands 0.32 12 0.026 8 % + F Use_Hamilt_Matrix cal_Hgamma 0.3 12 0.025 7.7 % + J Gint_Gamma cal_vlocal 0.3 12 0.025 7.7 % + K Gint_Gamma gamma_vlocal 0.3 12 0.025 7.7 % + E Local_Orbital_Cha sum_bands 0.35 12 0.029 8.8 % + F Gint_Gamma cal_rho 0.34 12 0.029 8.6 % + I Gint_Gamma gamma_charge 0.34 12 0.029 8.6 % + J Gint_Gamma rho_psir_ylm 0.98 164631 5.9e-06 25 % + J Gint_Gamma cal_band_rho 1.5 159095 9.7e-06 39 % + E Charge mix_rho 0.19 12 0.016 4.7 % + ---------------------------------------------------------------------------------------- + + START Time : Sun Jan 31 08:33:37 2021 + FINISH Time : Sun Jan 31 08:33:41 2021 + TOTAL Time : 4 + SEE INFORMATION IN : OUT.abacus/ diff --git a/ABACUS.develop/examples/H2O-deepks-pw/H_ONCV_PBE-1.0.upf b/ABACUS.develop/examples/H2O-deepks-pw/H_ONCV_PBE-1.0.upf new file mode 100644 index 0000000000..f8b1ebb63c --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks-pw/H_ONCV_PBE-1.0.upf @@ -0,0 +1,897 @@ + + + + This pseudopotential file has been produced using the code + ONCVPSP (Optimized Norm-Conservinng Vanderbilt PSeudopotential) + scalar-relativistic version 2.1.1, 03/26/2014 by D. R. Hamann + The code is available through a link at URL www.mat-simresearch.com. + Documentation with the package provides a full discription of the + input data below. + + + While it is not required under the terms of the GNU GPL, it is + suggested that you cite D. R. Hamann, Phys. Rev. B 88, 085117 (2013) + in any publication using these pseudopotentials. + + + Copyright 2015 The Regents of the University of California + + This work is licensed under the Creative Commons Attribution-ShareAlike + 4.0 International License. To view a copy of this license, visit + http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to + Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + + This pseudopotential is part of the Schlipf-Gygi norm-conserving + pseudopotential library. Its construction parameters were tuned to + reproduce materials of a training set with very high accuracy and + should be suitable as a general purpose pseudopotential to treat a + variety of different compounds. For details of the construction and + testing of the pseudopotential please refer to: + + [insert reference to paper here] + + We kindly ask that you include this reference in all publications + associated to this pseudopotential. + + + +# ATOM AND REFERENCE CONFIGURATION +# atsym z nc nv iexc psfile + H 1.00 0 1 4 upf +# +# n l f energy (Ha) + 1 0 1.00 +# +# PSEUDOPOTENTIAL AND OPTIMIZATION +# lmax + 0 +# +# l, rc, ep, ncon, nbas, qcut + 0 1.13748 -0.23860 5 8 9.72141 +# +# LOCAL POTENTIAL +# lloc, lpopt, rc(5), dvloc0 + 4 5 0.49352 0.00000 +# +# VANDERBILT-KLEINMAN-BYLANDER PROJECTORs +# l, nproj, debl + 0 2 1.27464 +# +# MODEL CORE CHARGE +# icmod, fcfact + 0 0.00000 +# +# LOG DERIVATIVE ANALYSIS +# epsh1, epsh2, depsh + -5.00 3.00 0.02 +# +# OUTPUT GRID +# rlmax, drl + 6.00 0.01 +# +# TEST CONFIGURATIONS +# ncnf + 0 +# nvcnf +# n l f + + + + + + + + + 0.0000 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600 0.0700 + 0.0800 0.0900 0.1000 0.1100 0.1200 0.1300 0.1400 0.1500 + 0.1600 0.1700 0.1800 0.1900 0.2000 0.2100 0.2200 0.2300 + 0.2400 0.2500 0.2600 0.2700 0.2800 0.2900 0.3000 0.3100 + 0.3200 0.3300 0.3400 0.3500 0.3600 0.3700 0.3800 0.3900 + 0.4000 0.4100 0.4200 0.4300 0.4400 0.4500 0.4600 0.4700 + 0.4800 0.4900 0.5000 0.5100 0.5200 0.5300 0.5400 0.5500 + 0.5600 0.5700 0.5800 0.5900 0.6000 0.6100 0.6200 0.6300 + 0.6400 0.6500 0.6600 0.6700 0.6800 0.6900 0.7000 0.7100 + 0.7200 0.7300 0.7400 0.7500 0.7600 0.7700 0.7800 0.7900 + 0.8000 0.8100 0.8200 0.8300 0.8400 0.8500 0.8600 0.8700 + 0.8800 0.8900 0.9000 0.9100 0.9200 0.9300 0.9400 0.9500 + 0.9600 0.9700 0.9800 0.9900 1.0000 1.0100 1.0200 1.0300 + 1.0400 1.0500 1.0600 1.0700 1.0800 1.0900 1.1000 1.1100 + 1.1200 1.1300 1.1400 1.1500 1.1600 1.1700 1.1800 1.1900 + 1.2000 1.2100 1.2200 1.2300 1.2400 1.2500 1.2600 1.2700 + 1.2800 1.2900 1.3000 1.3100 1.3200 1.3300 1.3400 1.3500 + 1.3600 1.3700 1.3800 1.3900 1.4000 1.4100 1.4200 1.4300 + 1.4400 1.4500 1.4600 1.4700 1.4800 1.4900 1.5000 1.5100 + 1.5200 1.5300 1.5400 1.5500 1.5600 1.5700 1.5800 1.5900 + 1.6000 1.6100 1.6200 1.6300 1.6400 1.6500 1.6600 1.6700 + 1.6800 1.6900 1.7000 1.7100 1.7200 1.7300 1.7400 1.7500 + 1.7600 1.7700 1.7800 1.7900 1.8000 1.8100 1.8200 1.8300 + 1.8400 1.8500 1.8600 1.8700 1.8800 1.8900 1.9000 1.9100 + 1.9200 1.9300 1.9400 1.9500 1.9600 1.9700 1.9800 1.9900 + 2.0000 2.0100 2.0200 2.0300 2.0400 2.0500 2.0600 2.0700 + 2.0800 2.0900 2.1000 2.1100 2.1200 2.1300 2.1400 2.1500 + 2.1600 2.1700 2.1800 2.1900 2.2000 2.2100 2.2200 2.2300 + 2.2400 2.2500 2.2600 2.2700 2.2800 2.2900 2.3000 2.3100 + 2.3200 2.3300 2.3400 2.3500 2.3600 2.3700 2.3800 2.3900 + 2.4000 2.4100 2.4200 2.4300 2.4400 2.4500 2.4600 2.4700 + 2.4800 2.4900 2.5000 2.5100 2.5200 2.5300 2.5400 2.5500 + 2.5600 2.5700 2.5800 2.5900 2.6000 2.6100 2.6200 2.6300 + 2.6400 2.6500 2.6600 2.6700 2.6800 2.6900 2.7000 2.7100 + 2.7200 2.7300 2.7400 2.7500 2.7600 2.7700 2.7800 2.7900 + 2.8000 2.8100 2.8200 2.8300 2.8400 2.8500 2.8600 2.8700 + 2.8800 2.8900 2.9000 2.9100 2.9200 2.9300 2.9400 2.9500 + 2.9600 2.9700 2.9800 2.9900 3.0000 3.0100 3.0200 3.0300 + 3.0400 3.0500 3.0600 3.0700 3.0800 3.0900 3.1000 3.1100 + 3.1200 3.1300 3.1400 3.1500 3.1600 3.1700 3.1800 3.1900 + 3.2000 3.2100 3.2200 3.2300 3.2400 3.2500 3.2600 3.2700 + 3.2800 3.2900 3.3000 3.3100 3.3200 3.3300 3.3400 3.3500 + 3.3600 3.3700 3.3800 3.3900 3.4000 3.4100 3.4200 3.4300 + 3.4400 3.4500 3.4600 3.4700 3.4800 3.4900 3.5000 3.5100 + 3.5200 3.5300 3.5400 3.5500 3.5600 3.5700 3.5800 3.5900 + 3.6000 3.6100 3.6200 3.6300 3.6400 3.6500 3.6600 3.6700 + 3.6800 3.6900 3.7000 3.7100 3.7200 3.7300 3.7400 3.7500 + 3.7600 3.7700 3.7800 3.7900 3.8000 3.8100 3.8200 3.8300 + 3.8400 3.8500 3.8600 3.8700 3.8800 3.8900 3.9000 3.9100 + 3.9200 3.9300 3.9400 3.9500 3.9600 3.9700 3.9800 3.9900 + 4.0000 4.0100 4.0200 4.0300 4.0400 4.0500 4.0600 4.0700 + 4.0800 4.0900 4.1000 4.1100 4.1200 4.1300 4.1400 4.1500 + 4.1600 4.1700 4.1800 4.1900 4.2000 4.2100 4.2200 4.2300 + 4.2400 4.2500 4.2600 4.2700 4.2800 4.2900 4.3000 4.3100 + 4.3200 4.3300 4.3400 4.3500 4.3600 4.3700 4.3800 4.3900 + 4.4000 4.4100 4.4200 4.4300 4.4400 4.4500 4.4600 4.4700 + 4.4800 4.4900 4.5000 4.5100 4.5200 4.5300 4.5400 4.5500 + 4.5600 4.5700 4.5800 4.5900 4.6000 4.6100 4.6200 4.6300 + 4.6400 4.6500 4.6600 4.6700 4.6800 4.6900 4.7000 4.7100 + 4.7200 4.7300 4.7400 4.7500 4.7600 4.7700 4.7800 4.7900 + 4.8000 4.8100 4.8200 4.8300 4.8400 4.8500 4.8600 4.8700 + 4.8800 4.8900 4.9000 4.9100 4.9200 4.9300 4.9400 4.9500 + 4.9600 4.9700 4.9800 4.9900 5.0000 5.0100 5.0200 5.0300 + 5.0400 5.0500 5.0600 5.0700 5.0800 5.0900 5.1000 5.1100 + 5.1200 5.1300 5.1400 5.1500 5.1600 5.1700 5.1800 5.1900 + 5.2000 5.2100 5.2200 5.2300 5.2400 5.2500 5.2600 5.2700 + 5.2800 5.2900 5.3000 5.3100 5.3200 5.3300 5.3400 5.3500 + 5.3600 5.3700 5.3800 5.3900 5.4000 5.4100 5.4200 5.4300 + 5.4400 5.4500 5.4600 5.4700 5.4800 5.4900 5.5000 5.5100 + 5.5200 5.5300 5.5400 5.5500 5.5600 5.5700 5.5800 5.5900 + 5.6000 5.6100 5.6200 5.6300 5.6400 5.6500 5.6600 5.6700 + 5.6800 5.6900 5.7000 5.7100 5.7200 5.7300 5.7400 5.7500 + 5.7600 5.7700 5.7800 5.7900 5.8000 5.8100 5.8200 5.8300 + 5.8400 5.8500 5.8600 5.8700 5.8800 5.8900 5.9000 5.9100 + 5.9200 5.9300 5.9400 5.9500 5.9600 5.9700 5.9800 5.9900 + 6.0000 6.0100 + + + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 + + + + -9.0610437558E+00 -9.0568179440E+00 -9.0440368423E+00 -9.0228074240E+00 + -8.9932366622E+00 -8.9554713856E+00 -8.9096955089E+00 -8.8561267684E+00 + -8.7950131219E+00 -8.7266289853E+00 -8.6512714714E+00 -8.5692567717E+00 + -8.4809167973E+00 -8.3865961577E+00 -8.2866495257E+00 -8.1814394040E+00 + -8.0713342805E+00 -7.9567071423E+00 -7.8379342970E+00 -7.7153944473E+00 + -7.5894679553E+00 -7.4605362378E+00 -7.3289812341E+00 -7.1951848958E+00 + -7.0595286560E+00 -6.9223928378E+00 -6.7841559816E+00 -6.6451940571E+00 + -6.5058795596E+00 -6.3665804704E+00 -6.2276590796E+00 -6.0894706704E+00 + -5.9523620796E+00 -5.8166700798E+00 -5.6827196991E+00 -5.5508223633E+00 + -5.4212739530E+00 -5.2943527007E+00 -5.1703170897E+00 -5.0494035400E+00 + -4.9318240186E+00 -4.8177636487E+00 -4.7073781566E+00 -4.6007912591E+00 + -4.4980919767E+00 -4.3993318735E+00 -4.3045222275E+00 -4.2136312137E+00 + -4.1265808607E+00 -4.0432438377E+00 -3.9634411592E+00 -3.8869595066E+00 + -3.8135916025E+00 -3.7431452942E+00 -3.6754419749E+00 -3.6103158908E+00 + -3.5476125181E+00 -3.4871882092E+00 -3.4289088467E+00 -3.3726496295E+00 + -3.3182938607E+00 -3.2657329154E+00 -3.2148652694E+00 -3.1655961918E+00 + -3.1178374334E+00 -3.0715065944E+00 -3.0265268914E+00 -2.9828269546E+00 + -2.9403403441E+00 -2.8990053187E+00 -2.8587646530E+00 -2.8195654255E+00 + -2.7813586956E+00 -2.7440993328E+00 -2.7077458096E+00 -2.6722599695E+00 + -2.6376068987E+00 -2.6037546665E+00 -2.5706741108E+00 -2.5383386428E+00 + -2.5067240362E+00 -2.4758082142E+00 -2.4455710353E+00 -2.4159940785E+00 + -2.3870604303E+00 -2.3587544755E+00 -2.3310616932E+00 -2.3039684604E+00 + -2.2774618664E+00 -2.2515295388E+00 -2.2261594843E+00 -2.2013399461E+00 + -2.1770592791E+00 -2.1533058441E+00 -2.1300679226E+00 -2.1073336580E+00 + -2.0850909954E+00 -2.0633276674E+00 -2.0420311892E+00 -2.0211888715E+00 + -2.0007878496E+00 -1.9808151272E+00 -1.9612576275E+00 -1.9421022557E+00 + -1.9233359852E+00 -1.9049459279E+00 -1.8869194114E+00 -1.8692440280E+00 + -1.8519077546E+00 -1.8348990301E+00 -1.8182067760E+00 -1.8018204402E+00 + -1.7857300225E+00 -1.7699262307E+00 -1.7544003587E+00 -1.7391444068E+00 + -1.7241513910E+00 -1.7094149041E+00 -1.6949283914E+00 -1.6806851418E+00 + -1.6666793118E+00 -1.6529050288E+00 -1.6393565372E+00 -1.6260283354E+00 + -1.6129151224E+00 -1.6000117236E+00 -1.5873131231E+00 -1.5748145186E+00 + -1.5625112075E+00 -1.5503986290E+00 -1.5384724172E+00 -1.5267282808E+00 + -1.5151620774E+00 -1.5037698221E+00 -1.4925475838E+00 -1.4814916063E+00 + -1.4705982343E+00 -1.4598638619E+00 -1.4492850817E+00 -1.4388585096E+00 + -1.4285808834E+00 -1.4184490612E+00 -1.4084599113E+00 -1.3986104920E+00 + -1.3888978631E+00 -1.3793192008E+00 -1.3698717674E+00 -1.3605528496E+00 + -1.3513598874E+00 -1.3422902990E+00 -1.3333416549E+00 -1.3245115294E+00 + -1.3157975913E+00 -1.3071975681E+00 -1.2987092220E+00 -1.2903304217E+00 + -1.2820590200E+00 -1.2738930123E+00 -1.2658303454E+00 -1.2578691201E+00 + -1.2500073905E+00 -1.2422433402E+00 -1.2345751282E+00 -1.2270010179E+00 + -1.2195192646E+00 -1.2121282090E+00 -1.2048261947E+00 -1.1976116375E+00 + -1.1904829614E+00 -1.1834386556E+00 -1.1764772175E+00 -1.1695972076E+00 + -1.1627971899E+00 -1.1560757951E+00 -1.1494316470E+00 -1.1428634453E+00 + -1.1363698679E+00 -1.1299496816E+00 -1.1236016133E+00 -1.1173244954E+00 + -1.1111170992E+00 -1.1049783153E+00 -1.0989069715E+00 -1.0929019971E+00 + -1.0869622832E+00 -1.0810867896E+00 -1.0752744716E+00 -1.0695243151E+00 + -1.0638353388E+00 -1.0582065507E+00 -1.0526370315E+00 -1.0471258093E+00 + -1.0416720144E+00 -1.0362747227E+00 -1.0309330806E+00 -1.0256462248E+00 + -1.0204133106E+00 -1.0152335359E+00 -1.0101060634E+00 -1.0050301401E+00 + -1.0000049637E+00 -9.9502979509E-01 -9.9010388850E-01 -9.8522650356E-01 + -9.8039695184E-01 -9.7561449875E-01 -9.7087848953E-01 -9.6618823633E-01 + -9.6154307709E-01 -9.5694238357E-01 -9.5238548542E-01 -9.4787179443E-01 + -9.4340068216E-01 -9.3897154786E-01 -9.3458382085E-01 -9.3023689119E-01 + -9.2593022219E-01 -9.2166324612E-01 -9.1743540867E-01 -9.1324619440E-01 + -9.0909505086E-01 -9.0498147929E-01 -9.0090497409E-01 -8.9686501466E-01 + -8.9286113809E-01 -8.8889284780E-01 -8.8495967058E-01 -8.8106115837E-01 + -8.7719683072E-01 -8.7336625731E-01 -8.6956900186E-01 -8.6580460671E-01 + -8.6207267364E-01 -8.5837277569E-01 -8.5470449112E-01 -8.5106743638E-01 + -8.4746119942E-01 -8.4388539099E-01 -8.4033964140E-01 -8.3682355391E-01 + -8.3333676803E-01 -8.2987892766E-01 -8.2644965155E-01 -8.2304860442E-01 + -8.1967544372E-01 -8.1632980376E-01 -8.1301137110E-01 -8.0971981657E-01 + -8.0645479078E-01 -8.0321599828E-01 -8.0000312317E-01 -7.9681583368E-01 + -7.9365384812E-01 -7.9051686526E-01 -7.8740456836E-01 -7.8431668932E-01 + -7.8125294167E-01 -7.7821302127E-01 -7.7519667347E-01 -7.7220362543E-01 + -7.6923358691E-01 -7.6628631304E-01 -7.6336154485E-01 -7.6045900684E-01 + -7.5757846086E-01 -7.5471966218E-01 -7.5188235009E-01 -7.4906629106E-01 + -7.4627125457E-01 -7.4349699489E-01 -7.4074328111E-01 -7.3800989688E-01 + -7.3529661160E-01 -7.3260319525E-01 -7.2992944541E-01 -7.2727514676E-01 + -7.2464006883E-01 -7.2202402266E-01 -7.1942680330E-01 -7.1684819373E-01 + -7.1428800302E-01 -7.1174604062E-01 -7.0922210469E-01 -7.0671599945E-01 + -7.0422754882E-01 -7.0175656648E-01 -6.9930285090E-01 -6.9686623967E-01 + -6.9444655518E-01 -6.9204361057E-01 -6.8965723548E-01 -6.8728726731E-01 + -6.8493353479E-01 -6.8259585830E-01 -6.8027408946E-01 -6.7796806685E-01 + -6.7567761966E-01 -6.7340259451E-01 -6.7114284334E-01 -6.6889821110E-01 + -6.6666853234E-01 -6.6445367341E-01 -6.6225348756E-01 -6.6006782094E-01 + -6.5789652969E-01 -6.5573948134E-01 -6.5359653600E-01 -6.5146754198E-01 + -6.4935237457E-01 -6.4725090244E-01 -6.4516298961E-01 -6.4308849538E-01 + -6.4102730352E-01 -6.3897928686E-01 -6.3694431188E-01 -6.3492225321E-01 + -6.3291299679E-01 -6.3091642140E-01 -6.2893239660E-01 -6.2696081023E-01 + -6.2500155065E-01 -6.2305450228E-01 -6.2111953833E-01 -6.1919655775E-01 + -6.1728545168E-01 -6.1538610939E-01 -6.1349840980E-01 -6.1162225937E-01 + -6.0975755301E-01 -6.0790418385E-01 -6.0606203900E-01 -6.0423102850E-01 + -6.0241105218E-01 -6.0060200743E-01 -5.9880378789E-01 -5.9701630748E-01 + -5.9523947068E-01 -5.9347317955E-01 -5.9171733268E-01 -5.8997184815E-01 + -5.8823663490E-01 -5.8651159997E-01 -5.8479664543E-01 -5.8309169382E-01 + -5.8139665833E-01 -5.7971145131E-01 -5.7803597694E-01 -5.7637016247E-01 + -5.7471392514E-01 -5.7306718215E-01 -5.7142984084E-01 -5.6980183110E-01 + -5.6818307475E-01 -5.6657349289E-01 -5.6497299873E-01 -5.6338152110E-01 + -5.6179898754E-01 -5.6022532279E-01 -5.5866044633E-01 -5.5710428471E-01 + -5.5555677140E-01 -5.5401783464E-01 -5.5248740049E-01 -5.5096539222E-01 + -5.4945174929E-01 -5.4794640331E-01 -5.4644928588E-01 -5.4496032010E-01 + -5.4347944752E-01 -5.4200660421E-01 -5.4054172497E-01 -5.3908473990E-01 + -5.3763558480E-01 -5.3619420258E-01 -5.3476053107E-01 -5.3333450778E-01 + -5.3191606202E-01 -5.3050514339E-01 -5.2910169262E-01 -5.2770565043E-01 + -5.2631695259E-01 -5.2493554186E-01 -5.2356136607E-01 -5.2219436872E-01 + -5.2083449329E-01 -5.1948167463E-01 -5.1813586721E-01 -5.1679701734E-01 + -5.1546507114E-01 -5.1413997141E-01 -5.1282166293E-01 -5.1151009987E-01 + -5.1020523087E-01 -5.0890700456E-01 -5.0761536348E-01 -5.0633026144E-01 + -5.0505165203E-01 -5.0377948626E-01 -5.0251371517E-01 -5.0125428164E-01 + -5.0000114694E-01 -4.9875426449E-01 -4.9751358757E-01 -4.9627906774E-01 + -4.9505065408E-01 -4.9382830847E-01 -4.9261198641E-01 -4.9140164337E-01 + -4.9019723176E-01 -4.8899870589E-01 -4.8780602831E-01 -4.8661915658E-01 + -4.8543804824E-01 -4.8426265702E-01 -4.8309294118E-01 -4.8192886432E-01 + -4.8077038597E-01 -4.7961746566E-01 -4.7847005879E-01 -4.7732812642E-01 + -4.7619163356E-01 -4.7506054163E-01 -4.7393481203E-01 -4.7281440223E-01 + -4.7169927496E-01 -4.7058939701E-01 -4.6948473158E-01 -4.6838524190E-01 + -4.6729088781E-01 -4.6620163267E-01 -4.6511744539E-01 -4.6403829091E-01 + -4.6296413415E-01 -4.6189493768E-01 -4.6083066451E-01 -4.5977128600E-01 + -4.5871676870E-01 -4.5766707919E-01 -4.5662218308E-01 -4.5558204211E-01 + -4.5454663035E-01 -4.5351591594E-01 -4.5248986699E-01 -4.5146845163E-01 + -4.5045163204E-01 -4.4943938274E-01 -4.4843167416E-01 -4.4742847591E-01 + -4.4642975759E-01 -4.4543548505E-01 -4.4444562951E-01 -4.4346016491E-01 + -4.4247906228E-01 -4.4150229265E-01 -4.4052982584E-01 -4.3956162903E-01 + -4.3859767986E-01 -4.3763795070E-01 -4.3668241393E-01 -4.3573104192E-01 + -4.3478380238E-01 -4.3384067158E-01 -4.3290162488E-01 -4.3196663593E-01 + -4.3103567840E-01 -4.3010872454E-01 -4.2918574490E-01 -4.2826671914E-01 + -4.2735162215E-01 -4.2644042882E-01 -4.2553311405E-01 -4.2462964878E-01 + -4.2373001042E-01 -4.2283417718E-01 -4.2194212512E-01 -4.2105383031E-01 + -4.2016926876E-01 -4.1928841078E-01 -4.1841123932E-01 -4.1753773154E-01 + -4.1666786462E-01 -4.1580161574E-01 -4.1493896037E-01 -4.1407987359E-01 + -4.1322433773E-01 -4.1237233102E-01 -4.1152383170E-01 -4.1067881801E-01 + -4.0983726529E-01 -4.0899915239E-01 -4.0816446135E-01 -4.0733317141E-01 + -4.0650526184E-01 -4.0568071187E-01 -4.0485949712E-01 -4.0404159922E-01 + -4.0322700028E-01 -4.0241568050E-01 -4.0160762012E-01 -4.0080279935E-01 + -4.0000119443E-01 -3.9920278882E-01 -3.9840756506E-01 -3.9761550429E-01 + -3.9682658765E-01 -3.9604079630E-01 -3.9525810742E-01 -3.9447850542E-01 + -3.9370197363E-01 -3.9292849408E-01 -3.9215804879E-01 -3.9139061977E-01 + -3.9062618552E-01 -3.8986473052E-01 -3.8910623925E-01 -3.8835069457E-01 + -3.8759807933E-01 -3.8684837639E-01 -3.8610156584E-01 -3.8535763147E-01 + -3.8461655919E-01 -3.8387833266E-01 -3.8314293554E-01 -3.8241035148E-01 + -3.8168056246E-01 -3.8095355083E-01 -3.8022930425E-01 -3.7950780711E-01 + -3.7878904385E-01 -3.7807299889E-01 -3.7735965635E-01 -3.7664899651E-01 + -3.7594100897E-01 -3.7523567887E-01 -3.7453299135E-01 -3.7383293156E-01 + -3.7313548465E-01 -3.7244063248E-01 -3.7174836252E-01 -3.7105866202E-01 + -3.7037151682E-01 -3.6968691275E-01 -3.6900483566E-01 -3.6832527016E-01 + -3.6764820011E-01 -3.6697361536E-01 -3.6630150240E-01 -3.6563184773E-01 + -3.6496463784E-01 -3.6429985924E-01 -3.6363749507E-01 -3.6297753451E-01 + -3.6231996581E-01 -3.6166477608E-01 -3.6101195247E-01 -3.6036148208E-01 + -3.5971335135E-01 -3.5906754455E-01 -3.5842405304E-01 -3.5778286454E-01 + -3.5714396678E-01 -3.5650734748E-01 -3.5587299437E-01 -3.5524089309E-01 + -3.5461103153E-01 -3.5398340017E-01 -3.5335798731E-01 -3.5273478124E-01 + -3.5211377027E-01 -3.5149494269E-01 -3.5087828373E-01 -3.5026378405E-01 + -3.4965143359E-01 -3.4904122118E-01 -3.4843313568E-01 -3.4782716591E-01 + -3.4722330074E-01 -3.4662152533E-01 -3.4602183228E-01 -3.4542421132E-01 + -3.4482865181E-01 -3.4423514312E-01 -3.4364367460E-01 -3.4305423563E-01 + -3.4246681166E-01 -3.4188139641E-01 -3.4129797977E-01 -3.4071655158E-01 + -3.4013710172E-01 -3.3955962003E-01 -3.3898409638E-01 -3.3841051679E-01 + -3.3783887542E-01 -3.3726916258E-01 -3.3670136861E-01 -3.3613548384E-01 + -3.3557149861E-01 -3.3500940324E-01 -3.3444918462E-01 -3.3389083661E-01 + -3.3333435031E-01 -3.3277971650E-01 + + + + 0.0000000000E+00 -2.6088547982E-01 -5.1833275472E-01 -7.6895641941E-01 + -1.0094757748E+00 -1.2367649640E+00 -1.4479004921E+00 -1.6402053307E+00 + -1.8112888675E+00 -1.9590820386E+00 -2.0818670611E+00 -2.1783012866E+00 + -2.2474347945E+00 -2.2887214604E+00 -2.3020233440E+00 -2.2876083718E+00 + -2.2461413919E+00 -2.1786688108E+00 -2.0865971283E+00 -1.9716657861E+00 + -1.8359148921E+00 -1.6816483354E+00 -1.5113931252E+00 -1.3278555788E+00 + -1.1338753152E+00 -9.3237750193E-01 -7.2632508798E-01 -5.1867053707E-01 + -3.1230935470E-01 -1.1003518382E-01 8.5502335005E-02 2.7183628053E-01 + 4.4671684037E-01 6.0814212888E-01 7.5438240005E-01 8.8400019998E-01 + 9.9586420814E-01 1.0891579569E+00 1.1633817902E+00 1.2183503968E+00 + 1.2541845008E+00 1.2712971870E+00 1.2703761390E+00 1.2523616859E+00 + 1.2184214326E+00 1.1699221627E+00 1.1083997635E+00 1.0355281365E+00 + 9.5308744579E-01 8.6293235820E-01 7.6696227219E-01 6.6708583573E-01 + 5.6517138232E-01 4.6301269339E-01 3.6230358110E-01 2.6460354791E-01 + 1.7132725391E-01 8.3714876259E-02 2.8300950036E-03 -7.0461868736E-02 + -1.3548566127E-01 -1.9177104351E-01 -2.3903864371E-01 -2.7719764878E-01 + -3.0633813688E-01 -3.2671240755E-01 -3.3872209753E-01 -3.4290134301E-01 + -3.3989414704E-01 -3.3043492034E-01 -3.1532726713E-01 -2.9542143883E-01 + -2.7159339422E-01 -2.4472437166E-01 -2.1568159041E-01 -1.8530141020E-01 + -1.5437121547E-01 -1.2361699029E-01 -9.3692510618E-02 -6.5170103885E-02 + -3.8534327148E-02 -1.4178178357E-02 7.5982219585E-03 2.6586599843E-02 + 4.2667321458E-02 5.5804230200E-02 6.6037784474E-02 7.3476782950E-02 + 7.8288985480E-02 8.0690950459E-02 8.0937413388E-02 7.9310526716E-02 + 7.6109267813E-02 7.1639300505E-02 6.6203546315E-02 6.0094670030E-02 + 5.3585181276E-02 4.6922886516E-02 4.0325965406E-02 3.3979459512E-02 + 2.8033278554E-02 2.2601546887E-02 1.7764693923E-02 1.3566271071E-02 + 1.0019934924E-02 7.1127553803E-03 4.8089618584E-03 3.0547066732E-03 + 1.7812642827E-03 9.1198278094E-04 3.6682674818E-04 6.5692263071E-05 + -6.8632527182E-05 -1.1027997757E-04 -8.4781932173E-05 -7.5466225625E-06 + 5.5046813283E-06 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 + + + 0.0000000000E+00 -6.6230384280E-02 -1.3227044522E-01 -1.9793408785E-01 + -2.6304354775E-01 -3.2743324392E-01 -3.9095326529E-01 -4.5347238282E-01 + -5.1488049086E-01 -5.7509039536E-01 -6.3403888294E-01 -6.9168702295E-01 + -7.4801967384E-01 -8.0304418574E-01 -8.5678831251E-01 -9.0929736637E-01 + -9.6063067143E-01 -1.0108573877E+00 -1.0600518025E+00 -1.1082881938E+00 + -1.1556354004E+00 -1.2021512134E+00 -1.2478767659E+00 -1.2928310462E+00 + -1.3370057140E+00 -1.3803603227E+00 -1.4228182118E+00 -1.4642630461E+00 + -1.5045363102E+00 -1.5434357567E+00 -1.5807149649E+00 -1.6160840886E+00 + -1.6492118605E+00 -1.6797288707E+00 -1.7072322005E+00 -1.7312913303E+00 + -1.7514553443E+00 -1.7672614056E+00 -1.7782442660E+00 -1.7839469588E+00 + -1.7839324513E+00 -1.7777959450E+00 -1.7651779669E+00 -1.7457779317E+00 + -1.7193680413E+00 -1.6858073499E+00 -1.6450558238E+00 -1.5971880652E+00 + -1.5424070527E+00 -1.4810575934E+00 -1.4136370872E+00 -1.3407629725E+00 + -1.2630862948E+00 -1.1812692944E+00 -1.0959852410E+00 -1.0079152517E+00 + -9.1774784801E-01 -8.2617381277E-01 -7.3388443997E-01 -6.4156480522E-01 + -5.4989159388E-01 -4.5952456379E-01 -3.7110347095E-01 -2.8524119151E-01 + -2.0251655480E-01 -1.2347058174E-01 -4.8599831493E-02 2.1650489647E-02 + 8.6889253952E-02 1.4678399897E-01 2.0106542651E-01 2.4953062217E-01 + 2.9204347185E-01 3.2853617819E-01 3.5900919836E-01 3.8352979134E-01 + 4.0223095680E-01 4.1530746441E-01 4.2301167574E-01 4.2564876217E-01 + 4.2357093422E-01 4.1717097424E-01 4.0687519421E-01 3.9313595295E-01 + 3.7642387716E-01 3.5721993688E-01 3.3600752955E-01 3.1326472631E-01 + 2.8945683082E-01 2.6502939400E-01 2.4040181789E-01 2.1596166863E-01 + 1.9205980225E-01 1.6900638782E-01 1.4706789081E-01 1.2646640479E-01 + 1.0737471459E-01 8.9919605583E-02 7.4182301027E-02 6.0200233461E-02 + 4.7969874788E-02 3.7450322138E-02 2.8568294126E-02 2.1219868525E-02 + 1.5278963151E-02 1.0602331228E-02 7.0348351713E-03 4.4142517848E-03 + 2.5774088544E-03 1.3667064349E-03 6.3345563442E-04 2.4137577893E-04 + 6.9281378302E-05 2.0772501814E-05 1.5017397331E-05 1.0881212294E-06 + -1.0503836267E-06 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 + + + -2.4016441487E+01 0.0000000000E+00 0.0000000000E+00 -1.0336462913E+00 + + + + + + 0.0000000000E+00 2.4794341471E-04 9.9091894057E-04 2.2263680628E-03 + 3.9500456984E-03 6.1560486329E-03 8.8368548808E-03 1.1983373531E-02 + 1.5585004525E-02 1.9629707710E-02 2.4104080427E-02 2.8993442803E-02 + 3.4281929867E-02 3.9952589544E-02 4.5987485557E-02 5.2367804247E-02 + 5.9073964300E-02 6.6085728409E-02 7.3382315882E-02 8.0942515274E-02 + 8.8744796138E-02 9.6767419086E-02 1.0498854333E-01 1.1338633103E-01 + 1.2193904783E-01 1.3062515893E-01 1.3942342031E-01 1.4831296458E-01 + 1.5727338117E-01 1.6628479066E-01 1.7532791282E-01 1.8438412840E-01 + 1.9343553473E-01 2.0246499428E-01 2.1145617765E-01 2.2039359948E-01 + 2.2926264851E-01 2.3804961085E-01 2.4674168841E-01 2.5532701021E-01 + 2.6379463827E-01 2.7213456885E-01 2.8033772768E-01 2.8839596035E-01 + 2.9630201805E-01 3.0404953869E-01 3.1163302393E-01 3.1904781286E-01 + 3.2629005077E-01 3.3335665407E-01 3.4024527527E-01 3.4695426557E-01 + 3.5348262690E-01 3.5982997159E-01 3.6599648316E-01 3.7198285339E-01 + 3.7779025613E-01 3.8342027746E-01 3.8887488964E-01 3.9415637933E-01 + 3.9926732777E-01 4.0421053528E-01 4.0898900016E-01 4.1360586662E-01 + 4.1806437563E-01 4.2236784139E-01 4.2651960765E-01 4.3052300623E-01 + 4.3438133902E-01 4.3809784793E-01 4.4167568640E-01 4.4511789734E-01 + 4.4842740211E-01 4.5160698378E-01 4.5465927654E-01 4.5758675943E-01 + 4.6039174939E-01 4.6307640307E-01 4.6564271888E-01 4.6809254111E-01 + 4.7042756695E-01 4.7264935579E-01 4.7475934017E-01 4.7675883847E-01 + 4.7864906862E-01 4.8043116285E-01 4.8210618286E-01 4.8367513530E-01 + 4.8513898716E-01 4.8649868075E-01 4.8775514807E-01 4.8890932424E-01 + 4.8996215983E-01 4.9091463191E-01 4.9176775358E-01 4.9252257613E-01 + 4.9318021185E-01 4.9374182540E-01 4.9420863911E-01 4.9458193531E-01 + 4.9486305613E-01 4.9505340201E-01 4.9515442062E-01 4.9516762730E-01 + 4.9509458085E-01 4.9493687901E-01 4.9469615451E-01 4.9437406196E-01 + 4.9397228868E-01 4.9349254046E-01 4.9293652709E-01 4.9230595866E-01 + 4.9160253929E-01 4.9082798382E-01 4.8998398626E-01 4.8907222166E-01 + 4.8809434735E-01 4.8705202061E-01 4.8594687199E-01 4.8478050140E-01 + 4.8355451132E-01 4.8227048421E-01 4.8092996944E-01 4.7953450212E-01 + 4.7808561574E-01 4.7658480457E-01 4.7503353906E-01 4.7343329913E-01 + 4.7178551873E-01 4.7009160857E-01 4.6835299066E-01 4.6657103314E-01 + 4.6474709403E-01 4.6288253276E-01 4.6097864623E-01 4.5903674889E-01 + 4.5705812988E-01 4.5504401645E-01 4.5299568348E-01 4.5091433129E-01 + 4.4880115759E-01 4.4665736345E-01 4.4448406520E-01 4.4228244437E-01 + 4.4005359528E-01 4.3779862199E-01 4.3551861800E-01 4.3321460984E-01 + 4.3088768122E-01 4.2853880795E-01 4.2616903012E-01 4.2377930732E-01 + 4.2137061147E-01 4.1894389471E-01 4.1650006236E-01 4.1404005773E-01 + 4.1156472312E-01 4.0907498816E-01 4.0657164288E-01 4.0405558773E-01 + 4.0152758537E-01 3.9898848719E-01 3.9643903481E-01 3.9388003353E-01 + 3.9131220208E-01 3.8873630343E-01 3.8615303095E-01 3.8356310956E-01 + 3.8096720441E-01 3.7836600704E-01 3.7576015114E-01 3.7315029989E-01 + 3.7053705201E-01 3.6792104757E-01 3.6530284664E-01 3.6268307155E-01 + 3.6006223998E-01 3.5744096187E-01 3.5481970890E-01 3.5219908368E-01 + 3.4957950873E-01 3.4696157326E-01 3.4434567985E-01 3.4173237209E-01 + 3.3912205408E-01 3.3651521191E-01 3.3391226115E-01 3.3131362397E-01 + 3.2871973492E-01 3.2613094713E-01 3.2354771963E-01 3.2097033407E-01 + 3.1839925340E-01 3.1583475732E-01 3.1327723928E-01 3.1072701520E-01 + 3.0818439374E-01 3.0564973754E-01 3.0312326636E-01 3.0060536753E-01 + 2.9809624731E-01 2.9559622996E-01 2.9310557269E-01 2.9062449750E-01 + 2.8815332279E-01 2.8569218837E-01 2.8324141465E-01 2.8080118028E-01 + 2.7837169267E-01 2.7595321500E-01 2.7354583751E-01 2.7114985674E-01 + 2.6876540189E-01 2.6639264465E-01 2.6403181011E-01 2.6168295407E-01 + 2.5934632864E-01 2.5702204381E-01 2.5471021239E-01 2.5241103884E-01 + 2.5012456127E-01 2.4785096372E-01 2.4559036883E-01 2.4334280687E-01 + 2.4110847696E-01 2.3888742000E-01 2.3667972467E-01 2.3448553732E-01 + 2.3230484695E-01 2.3013779622E-01 2.2798447164E-01 2.2584484162E-01 + 2.2371907224E-01 2.2160718423E-01 2.1950918491E-01 2.1742520274E-01 + 2.1535521910E-01 2.1329927590E-01 2.1125746569E-01 2.0922973692E-01 + 2.0721615973E-01 2.0521679417E-01 2.0323156191E-01 2.0126055392E-01 + 1.9930380230E-01 1.9736120736E-01 1.9543287344E-01 1.9351880846E-01 + 1.9161889992E-01 1.8973325450E-01 1.8786185993E-01 1.8600460254E-01 + 1.8416157699E-01 1.8233276208E-01 1.8051803620E-01 1.7871748583E-01 + 1.7693108606E-01 1.7515870043E-01 1.7340041110E-01 1.7165618863E-01 + 1.6992589269E-01 1.6820958701E-01 1.6650724345E-01 1.6481872662E-01 + 1.6314406985E-01 1.6148325248E-01 1.5983614921E-01 1.5820275480E-01 + 1.5658306061E-01 1.5497695691E-01 1.5338439180E-01 1.5180537259E-01 + 1.5023981072E-01 1.4868760030E-01 1.4714876754E-01 1.4562325032E-01 + 1.4411088316E-01 1.4261171261E-01 1.4112567980E-01 1.3965263949E-01 + 1.3819257554E-01 1.3674545831E-01 1.3531117665E-01 1.3388963650E-01 + 1.3248084168E-01 1.3108472136E-01 1.2970109889E-01 1.2833001076E-01 + 1.2697139008E-01 1.2562509939E-01 1.2429108335E-01 1.2296931894E-01 + 1.2165971717E-01 1.2036212317E-01 1.1907655698E-01 1.1780294648E-01 + 1.1654114810E-01 1.1529111045E-01 1.1405280258E-01 1.1282613765E-01 + 1.1161095024E-01 1.1040725990E-01 1.0921499300E-01 1.0803401854E-01 + 1.0686425527E-01 1.0570568262E-01 1.0455822148E-01 1.0342170539E-01 + 1.0229612790E-01 1.0118143008E-01 1.0007751189E-01 9.8984230691E-02 + 9.7901591614E-02 9.6829518883E-02 9.5767884597E-02 9.4716602554E-02 + 9.3675651345E-02 9.2644952595E-02 9.1624357062E-02 9.0613825474E-02 + 8.9613313452E-02 8.8622740963E-02 8.7641943554E-02 8.6670918562E-02 + 8.5709603256E-02 8.4757913158E-02 8.3815684928E-02 8.2882931486E-02 + 8.1959580376E-02 8.1045538566E-02 8.0140663081E-02 7.9244958367E-02 + 7.8358352085E-02 7.7480747512E-02 7.6612013484E-02 7.5752149816E-02 + 7.4901084880E-02 7.4058722878E-02 7.3224935982E-02 7.2399723308E-02 + 7.1583014448E-02 7.0774718909E-02 6.9974704043E-02 6.9182972050E-02 + 6.8399454182E-02 6.7624069401E-02 6.6856672591E-02 6.6097272493E-02 + 6.5345802386E-02 6.4602189287E-02 6.3866284591E-02 6.3138090627E-02 + 6.2417548303E-02 6.1704587356E-02 6.0999076474E-02 6.0300987164E-02 + 5.9610277067E-02 5.8926878874E-02 5.8250682553E-02 5.7581621736E-02 + 5.6919673704E-02 5.6264774278E-02 5.5616838504E-02 5.4975756187E-02 + 5.4341526243E-02 5.3714087760E-02 5.3093374958E-02 5.2479257060E-02 + 5.1871728058E-02 5.1270739451E-02 5.0676229134E-02 5.0088097362E-02 + 4.9506279485E-02 4.8930756928E-02 4.8361471290E-02 4.7798357672E-02 + 4.7241288817E-02 4.6690276084E-02 4.6145264773E-02 4.5606196203E-02 + 4.5072972721E-02 4.4545541444E-02 4.4023881815E-02 4.3507939101E-02 + 4.2997654834E-02 4.2492905991E-02 4.1993703269E-02 4.1499997132E-02 + 4.1011733250E-02 4.0528830544E-02 4.0051217904E-02 3.9578886841E-02 + 3.9111787057E-02 3.8649865000E-02 3.8193021326E-02 3.7741231625E-02 + 3.7294467263E-02 3.6852678829E-02 3.6415813870E-02 3.5983760247E-02 + 3.5556530198E-02 3.5134078994E-02 3.4716358396E-02 3.4303305080E-02 + 3.3894835682E-02 3.3490952616E-02 3.3091611670E-02 3.2696766006E-02 + 3.2306344980E-02 3.1920288091E-02 3.1538589081E-02 3.1161205154E-02 + 3.0788091067E-02 3.0419172782E-02 3.0054404780E-02 2.9693775584E-02 + 2.9337243976E-02 2.8984766463E-02 2.8636269166E-02 2.8291714111E-02 + 2.7951087999E-02 2.7614351317E-02 2.7281462438E-02 2.6952350866E-02 + 2.6626979290E-02 2.6305335782E-02 2.5987382630E-02 2.5673080163E-02 + 2.5362364216E-02 2.5055191839E-02 2.4751555386E-02 2.4451419017E-02 + 2.4154745071E-02 2.3861478444E-02 2.3571564847E-02 2.3285003479E-02 + 2.3001760410E-02 2.2721800031E-02 2.2445078789E-02 2.2171526061E-02 + 2.1901150013E-02 2.1633918647E-02 2.1369798413E-02 2.1108754197E-02 + 2.0850710883E-02 2.0595671221E-02 2.0343610458E-02 2.0094497098E-02 + 1.9848298202E-02 1.9604955310E-02 1.9364442566E-02 1.9126750436E-02 + 1.8891849457E-02 1.8659708833E-02 1.8430288872E-02 1.8203531688E-02 + 1.7979444001E-02 1.7757998342E-02 1.7539166017E-02 1.7322917097E-02 + 1.7109191383E-02 1.6897980399E-02 1.6689269114E-02 1.6483030879E-02 + 1.6279237912E-02 1.6077852629E-02 1.5878825755E-02 1.5682162720E-02 + 1.5487838857E-02 1.5295828455E-02 1.5106104755E-02 1.4918616206E-02 + 1.4733348857E-02 1.4550292886E-02 1.4369424576E-02 1.4190719249E-02 + 1.4014151128E-02 1.3839659221E-02 1.3667256683E-02 1.3496921706E-02 + 1.3328631601E-02 1.3162362793E-02 1.2998080875E-02 1.2835748138E-02 + 1.2675368275E-02 1.2516920489E-02 1.2360383178E-02 1.2205733920E-02 + 1.2052932833E-02 1.1901959252E-02 1.1752810004E-02 1.1605465350E-02 + 1.1459904808E-02 1.1316107146E-02 1.1174029833E-02 1.1033663349E-02 + 1.0895000275E-02 1.0758021954E-02 1.0622709048E-02 1.0489041530E-02 + 1.0356976695E-02 1.0226510813E-02 1.0097634680E-02 9.9703307378E-03 + 9.8445807986E-03 9.7203660474E-03 9.5976457522E-03 9.4764172062E-03 + 9.3566716576E-03 9.2383926415E-03 9.1215631207E-03 9.0061654822E-03 + 8.8921628626E-03 8.7795493594E-03 8.6683186485E-03 8.5584553503E-03 + 8.4499435627E-03 8.3427668572E-03 8.2368939208E-03 8.1323119604E-03 + 8.0290187790E-03 7.9270000634E-03 7.8262410234E-03 7.7267263895E-03 + 7.6284318873E-03 7.5313346684E-03 7.4354380585E-03 7.3407287840E-03 + 7.2471931373E-03 7.1548169739E-03 7.0635843287E-03 6.9734597403E-03 + 6.8844530956E-03 6.7965521281E-03 6.7097441767E-03 6.6240161831E-03 + 6.5393546899E-03 6.4557301699E-03 6.3731393266E-03 6.2915776433E-03 + 6.2110334645E-03 6.1314947748E-03 6.0529491959E-03 5.9753783320E-03 + 5.8987597471E-03 5.8230986296E-03 5.7483842858E-03 5.6746056953E-03 + 5.6017515092E-03 5.5298100485E-03 5.4587541386E-03 5.3885834526E-03 + 5.3192932870E-03 5.2508735670E-03 5.1833139204E-03 5.1166036764E-03 + 5.0507287806E-03 4.9856653379E-03 4.9214203547E-03 4.8579846503E-03 + 4.7953487751E-03 4.7335030098E-03 4.6724373639E-03 4.6121326368E-03 + 4.5525789599E-03 4.4937772672E-03 4.4357189771E-03 4.3783952646E-03 + 4.3217970601E-03 4.2659150477E-03 4.2107269600E-03 4.1562326781E-03 + 4.1024289394E-03 4.0493077557E-03 3.9968609188E-03 3.9450799988E-03 + 3.8939563432E-03 3.8434664007E-03 3.7936159723E-03 3.7443993547E-03 + 3.6958091420E-03 3.6478377293E-03 3.6004773117E-03 3.5537198828E-03 + 3.5075421006E-03 3.4619523711E-03 3.4169441116E-03 3.3725104825E-03 + 3.3286444647E-03 3.2853388583E-03 3.2425862821E-03 3.2003648485E-03 + 3.1586827452E-03 3.1175338565E-03 3.0769118893E-03 3.0368103888E-03 + 2.9972227375E-03 2.9581421546E-03 2.9195492532E-03 2.8814496160E-03 + 2.8438387299E-03 2.8067108257E-03 + + diff --git a/ABACUS.develop/examples/H2O-deepks-pw/H_gga_8au_60Ry_2s1p.orb b/ABACUS.develop/examples/H2O-deepks-pw/H_gga_8au_60Ry_2s1p.orb new file mode 100644 index 0000000000..48eaf466a1 --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks-pw/H_gga_8au_60Ry_2s1p.orb @@ -0,0 +1,621 @@ +--------------------------------------------------------------------------- +Element H +Energy Cutoff(Ry) 60 +Radius Cutoff(a.u.) 8 +Lmax 1 +Number of Sorbital--> 2 +Number of Porbital--> 1 +--------------------------------------------------------------------------- +SUMMARY END + +Mesh 801 +dr 0.01 + Type L N + 0 0 0 + 1.837183001954e+00 1.836944589913e+00 1.836229654458e+00 1.835039096904e+00 + 1.833374417163e+00 1.831237710329e+00 1.828631661910e+00 1.825559541724e+00 + 1.822025196478e+00 1.818033041051e+00 1.813588048498e+00 1.808695738828e+00 + 1.803362166562e+00 1.797593907128e+00 1.791398042128e+00 1.784782143515e+00 + 1.777754256735e+00 1.770322882882e+00 1.762496959911e+00 1.754285842983e+00 + 1.745699283975e+00 1.736747410234e+00 1.727440702633e+00 1.717789972985e+00 + 1.707806340887e+00 1.697501210064e+00 1.686886244272e+00 1.675973342834e+00 + 1.664774615881e+00 1.653302359357e+00 1.641569029875e+00 1.629587219474e+00 + 1.617369630367e+00 1.604929049734e+00 1.592278324633e+00 1.579430337099e+00 + 1.566397979495e+00 1.553194130183e+00 1.539831629571e+00 1.526323256609e+00 + 1.512681705776e+00 1.498919564642e+00 1.485049292031e+00 1.471083196857e+00 + 1.457033417677e+00 1.442911903007e+00 1.428730392444e+00 1.414500398644e+00 + 1.400233190182e+00 1.385939775333e+00 1.371630886810e+00 1.357316967481e+00 + 1.343008157094e+00 1.328714280028e+00 1.314444834085e+00 1.300208980342e+00 + 1.286015534077e+00 1.271872956757e+00 1.257789349118e+00 1.243772445314e+00 + 1.229829608141e+00 1.215967825332e+00 1.202193706904e+00 1.188513483548e+00 + 1.174933006049e+00 1.161457745704e+00 1.148092795727e+00 1.134842873614e+00 + 1.121712324429e+00 1.108705124991e+00 1.095824888929e+00 1.083074872558e+00 + 1.070457981553e+00 1.057976778365e+00 1.045633490360e+00 1.033430018609e+00 + 1.021367947317e+00 1.009448553813e+00 9.976728190860e-01 9.860414387908e-01 + 9.745548346979e-01 9.632131665266e-01 9.520163441167e-01 9.409640398896e-01 + 9.300557015494e-01 9.192905649774e-01 9.086676672686e-01 8.981858598668e-01 + 8.878438217485e-01 8.776400726115e-01 8.675729860234e-01 8.576408024859e-01 + 8.478416423739e-01 8.381735187085e-01 8.286343497244e-01 8.192219711958e-01 + 8.099341484846e-01 8.007685882774e-01 7.917229499810e-01 7.827948567466e-01 + 7.739819060948e-01 7.652816801187e-01 7.566917552403e-01 7.482097115016e-01 + 7.398331413718e-01 7.315596580552e-01 7.233869032872e-01 7.153125546063e-01 + 7.073343320959e-01 6.994500045870e-01 6.916573953213e-01 6.839543870698e-01 + 6.763389267106e-01 6.688090292670e-01 6.613627814111e-01 6.539983444408e-01 + 6.467139567383e-01 6.395079357207e-01 6.323786792970e-01 6.253246668428e-01 + 6.183444597120e-01 6.114367012998e-01 6.046001166779e-01 5.978335118199e-01 + 5.911357724396e-01 5.845058624632e-01 5.779428221587e-01 5.714457659458e-01 + 5.650138799114e-01 5.586464190548e-01 5.523427042877e-01 5.461021192154e-01 + 5.399241067240e-01 5.338081653994e-01 5.277538458047e-01 5.217607466390e-01 + 5.158285108059e-01 5.099568214136e-01 5.041453977325e-01 4.983939911326e-01 + 4.927023810249e-01 4.870703708276e-01 4.814977839793e-01 4.759844600184e-01 + 4.705302507489e-01 4.651350165105e-01 4.597986225695e-01 4.545209356471e-01 + 4.493018205989e-01 4.441411372598e-01 4.390387374660e-01 4.339944622642e-01 + 4.290081393187e-01 4.240795805231e-01 4.192085798248e-01 4.143949112659e-01 + 4.096383272463e-01 4.049385570104e-01 4.002953053599e-01 3.957082515919e-01 + 3.911770486621e-01 3.867013225703e-01 3.822806719649e-01 3.779146679621e-01 + 3.736028541744e-01 3.693447469412e-01 3.651398357547e-01 3.609875838725e-01 + 3.568874291078e-01 3.528387847874e-01 3.488410408668e-01 3.448935651913e-01 + 3.409957048920e-01 3.371467879035e-01 3.333461245923e-01 3.295930094816e-01 + 3.258867230612e-01 3.222265336680e-01 3.186116994248e-01 3.150414702237e-01 + 3.115150897416e-01 3.080317974748e-01 3.045908307790e-01 3.011914269039e-01 + 2.978328250089e-01 2.945142681489e-01 2.912350052191e-01 2.879942928469e-01 + 2.847913972227e-01 2.816255958578e-01 2.784961792617e-01 2.754024525310e-01 + 2.723437368403e-01 2.693193708300e-01 2.663287118847e-01 2.633711372954e-01 + 2.604460453030e-01 2.575528560170e-01 2.546910122087e-01 2.518599799744e-01 + 2.490592492694e-01 2.462883343097e-01 2.435467738441e-01 2.408341312951e-01 + 2.381499947722e-01 2.354939769580e-01 2.328657148724e-01 2.302648695155e-01 + 2.276911253967e-01 2.251441899519e-01 2.226237928562e-01 2.201296852370e-01 + 2.176616387940e-01 2.152194448327e-01 2.128029132189e-01 2.104118712608e-01 + 2.080461625279e-01 2.057056456128e-01 2.033901928451e-01 2.010996889656e-01 + 1.988340297689e-01 1.965931207221e-01 1.943768755699e-01 1.921852149312e-01 + 1.900180648992e-01 1.878753556493e-01 1.857570200652e-01 1.836629923900e-01 + 1.815932069086e-01 1.795475966703e-01 1.775260922564e-01 1.755286206005e-01 + 1.735551038664e-01 1.716054583896e-01 1.696795936868e-01 1.677774115389e-01 + 1.658988051503e-01 1.640436583889e-01 1.622118451094e-01 1.604032285625e-01 + 1.586176608917e-01 1.568549827195e-01 1.551150228235e-01 1.533975979026e-01 + 1.517025124337e-01 1.500295586177e-01 1.483785164136e-01 1.467491536591e-01 + 1.451412262756e-01 1.435544785550e-01 1.419886435250e-01 1.404434433895e-01 + 1.389185900406e-01 1.374137856375e-01 1.359287232483e-01 1.344630875494e-01 + 1.330165555780e-01 1.315887975315e-01 1.301794776097e-01 1.287882548928e-01 + 1.274147842501e-01 1.260587172734e-01 1.247197032295e-01 1.233973900255e-01 + 1.220914251803e-01 1.208014567985e-01 1.195271345385e-01 1.182681105707e-01 + 1.170240405197e-01 1.157945843848e-01 1.145794074346e-01 1.133781810696e-01 + 1.121905836491e-01 1.110163012772e-01 1.098550285439e-01 1.087064692189e-01 + 1.075703368914e-01 1.064463555568e-01 1.053342601443e-01 1.042337969845e-01 + 1.031447242151e-01 1.020668121220e-01 1.009998434160e-01 9.994361344292e-02 + 9.889793032764e-02 9.786261505153e-02 9.683750146373e-02 9.582243622695e-02 + 9.481727869892e-02 9.382190075086e-02 9.283618652485e-02 9.186003213200e-02 + 9.089334529416e-02 8.993604493153e-02 8.898806069949e-02 8.804933247767e-02 + 8.711980981492e-02 8.619945133369e-02 8.528822409791e-02 8.438610294830e-02 + 8.349306980927e-02 8.260911297183e-02 8.173422635677e-02 8.086840876262e-02 + 8.001166310290e-02 7.916399563701e-02 7.832541519936e-02 7.749593243119e-02 + 7.667555901919e-02 7.586430694553e-02 7.506218775311e-02 7.426921183030e-02 + 7.348538771882e-02 7.271072144857e-02 7.194521590274e-02 7.118887021660e-02 + 7.044167921281e-02 6.970363287618e-02 6.897471587029e-02 6.825490709826e-02 + 6.754417930953e-02 6.684249875447e-02 6.614982488807e-02 6.546611012376e-02 + 6.479129963827e-02 6.412533122782e-02 6.346813521597e-02 6.281963441282e-02 + 6.217974412524e-02 6.154837221742e-02 6.092541922062e-02 6.031077849093e-02 + 5.970433641353e-02 5.910597265146e-02 5.851556043717e-02 5.793296690431e-02 + 5.735805345748e-02 5.679067617719e-02 5.623068625723e-02 5.567793047149e-02 + 5.513225166709e-02 5.459348928055e-02 5.406147987367e-02 5.353605768584e-02 + 5.301705519908e-02 5.250430371249e-02 5.199763392254e-02 5.149687650562e-02 + 5.100186269951e-02 5.051242488017e-02 5.002839713058e-02 4.954961579826e-02 + 4.907592003841e-02 4.860715233943e-02 4.814315902803e-02 4.768379075103e-02 + 4.722890293136e-02 4.677835619574e-02 4.633201677174e-02 4.588975685239e-02 + 4.545145492624e-02 4.501699607151e-02 4.458627221269e-02 4.415918233874e-02 + 4.373563268174e-02 4.331553685543e-02 4.289881595315e-02 4.248539860513e-02 + 4.207522099501e-02 4.166822683595e-02 4.126436730696e-02 4.086360095004e-02 + 4.046589352919e-02 4.007121785247e-02 3.967955355852e-02 3.929088686906e-02 + 3.890521030927e-02 3.852252239779e-02 3.814282730864e-02 3.776613450720e-02 + 3.739245836261e-02 3.702181773910e-02 3.665423556888e-02 3.628973840914e-02 + 3.592835598602e-02 3.557012072822e-02 3.521506729315e-02 3.486323208842e-02 + 3.451465279144e-02 3.416936787005e-02 3.382741610685e-02 3.348883613005e-02 + 3.315366595347e-02 3.282194252816e-02 3.249370130839e-02 3.216897583409e-02 + 3.184779733221e-02 3.153019433907e-02 3.121619234560e-02 3.090581346740e-02 + 3.059907614130e-02 3.029599484973e-02 2.999657987449e-02 2.970083708075e-02 + 2.940876773251e-02 2.912036833994e-02 2.883563053951e-02 2.855454100693e-02 + 2.827708140322e-02 2.800322835388e-02 2.773295346082e-02 2.746622334670e-02 + 2.720299973098e-02 2.694323953697e-02 2.668689502885e-02 2.643391397746e-02 + 2.618423985369e-02 2.593781204788e-02 2.569456611367e-02 2.545443403465e-02 + 2.521734451180e-02 2.498322326994e-02 2.475199338102e-02 2.452357560217e-02 + 2.429788872629e-02 2.407484994296e-02 2.385437520730e-02 2.363637961462e-02 + 2.342077777828e-02 2.320748420868e-02 2.299641369091e-02 2.278748165879e-02 + 2.258060456315e-02 2.237570023195e-02 2.217268822047e-02 2.197149014906e-02 + 2.177203002695e-02 2.157423455996e-02 2.137803344052e-02 2.118335961832e-02 + 2.099014955016e-02 2.079834342757e-02 2.060788538111e-02 2.041872366018e-02 + 2.023081078753e-02 2.004410368768e-02 1.985856378874e-02 1.967415709710e-02 + 1.949085424496e-02 1.930863051036e-02 1.912746581003e-02 1.894734466521e-02 + 1.876825614084e-02 1.859019375878e-02 1.841315538567e-02 1.823714309642e-02 + 1.806216301427e-02 1.788822512858e-02 1.771534309170e-02 1.754353399617e-02 + 1.737281813387e-02 1.720321873867e-02 1.703476171432e-02 1.686747534922e-02 + 1.670139002005e-02 1.653653788602e-02 1.637295257579e-02 1.621066886889e-02 + 1.604972237371e-02 1.589014920400e-02 1.573198565588e-02 1.557526788735e-02 + 1.542003160212e-02 1.526631173980e-02 1.511414217422e-02 1.496355542166e-02 + 1.481458236068e-02 1.466725196525e-02 1.452159105263e-02 1.437762404751e-02 + 1.423537276365e-02 1.409485620432e-02 1.395609038260e-02 1.381908816243e-02 + 1.368385912139e-02 1.355040943570e-02 1.341874178822e-02 1.328885529967e-02 + 1.316074548341e-02 1.303440422391e-02 1.290981977884e-02 1.278697680470e-02 + 1.266585640551e-02 1.254643620432e-02 1.242869043674e-02 1.231259006595e-02 + 1.219810291820e-02 1.208519383795e-02 1.197382486147e-02 1.186395540780e-02 + 1.175554248568e-02 1.164854091516e-02 1.154290356241e-02 1.143858158612e-02 + 1.133552469406e-02 1.123368140788e-02 1.113299933481e-02 1.103342544417e-02 + 1.093490634723e-02 1.083738857850e-02 1.074081887670e-02 1.064514446379e-02 + 1.055031332017e-02 1.045627445440e-02 1.036297816589e-02 1.027037629880e-02 + 1.017842248571e-02 1.008707237956e-02 9.996283872439e-03 9.906017299963e-03 + 9.816235629990e-03 9.726904634575e-03 9.637993044158e-03 9.549472683095e-03 + 9.461318585756e-03 9.373509092547e-03 9.286025925316e-03 9.198854241766e-03 + 9.111982668594e-03 9.025403313231e-03 8.939111754182e-03 8.853107010083e-03 + 8.767391487758e-03 8.681970909646e-03 8.596854221113e-03 8.512053478299e-03 + 8.427583717241e-03 8.343462805139e-03 8.259711274747e-03 8.176352142955e-03 + 8.093410714732e-03 8.010914373688e-03 7.928892360586e-03 7.847375541208e-03 + 7.766396165037e-03 7.685987616284e-03 7.606184158811e-03 7.527020676537e-03 + 7.448532410976e-03 7.370754697499e-03 7.293722701988e-03 7.217471159497e-03 + 7.142034116536e-03 7.067444678566e-03 6.993734764268e-03 6.920934868072e-03 + 6.849073832427e-03 6.778178631184e-03 6.708274165423e-03 6.639383072963e-03 + 6.571525552710e-03 6.504719204914e-03 6.438978888287e-03 6.374316594849e-03 + 6.310741343251e-03 6.248259091204e-03 6.186872667539e-03 6.126581724281e-03 + 6.067382709022e-03 6.009268857733e-03 5.952230208041e-03 5.896253632856e-03 + 5.841322894139e-03 5.787418716443e-03 5.734518879765e-03 5.682598331103e-03 + 5.631629314041e-03 5.581581515517e-03 5.532422228878e-03 5.484116532183e-03 + 5.436627480669e-03 5.389916312153e-03 5.343942664112e-03 5.298664801096e-03 + 5.254039851043e-03 5.210024049057e-03 5.166572987118e-03 5.123641868188e-03 + 5.081185763139e-03 5.039159868908e-03 4.997519766284e-03 4.956221675723e-03 + 4.915222709618e-03 4.874481119449e-03 4.833956536282e-03 4.793610203124e-03 + 4.753405197691e-03 4.713306644192e-03 4.673281912822e-03 4.633300805703e-03 + 4.593335728114e-03 4.553361843925e-03 4.513357214267e-03 4.473302918541e-03 + 4.433183156995e-03 4.392985334212e-03 4.352700122958e-03 4.312321507951e-03 + 4.271846809254e-03 4.231276685107e-03 4.190615114131e-03 4.149869356970e-03 + 4.109049897570e-03 4.068170364395e-03 4.027247432032e-03 3.986300703725e-03 + 3.945352575525e-03 3.904428082829e-03 3.863554730213e-03 3.822762305549e-03 + 3.782082679500e-03 3.741549591582e-03 3.701198424061e-03 3.661065965028e-03 + 3.621190162068e-03 3.581609868005e-03 3.542364580233e-03 3.503494175223e-03 + 3.465038639791e-03 3.427037800768e-03 3.389531054702e-03 3.352557099248e-03 + 3.316153667881e-03 3.280357269556e-03 3.245202934926e-03 3.210723970676e-03 + 3.176951723504e-03 3.143915355211e-03 3.111641630320e-03 3.080154717561e-03 + 3.049476006479e-03 3.019623940341e-03 2.990613866433e-03 2.962457904719e-03 + 2.935164835746e-03 2.908740008560e-03 2.883185269274e-03 2.858498910829e-03 + 2.834675644347e-03 2.811706592354e-03 2.789579304014e-03 2.768277792419e-03 + 2.747782593786e-03 2.728070848352e-03 2.709116402574e-03 2.690889932146e-03 + 2.673359085199e-03 2.656488644942e-03 2.640240710873e-03 2.624574897586e-03 + 2.609448550081e-03 2.594816974380e-03 2.580633682179e-03 2.566850648134e-03 + 2.553418578345e-03 2.540287188493e-03 2.527405490042e-03 2.514722082840e-03 + 2.502185452434e-03 2.489744270362e-03 2.477347695641e-03 2.464945675695e-03 + 2.452489244921e-03 2.439930819104e-03 2.427224483935e-03 2.414326275849e-03 + 2.401194453506e-03 2.387789758222e-03 2.374075661746e-03 2.360018599826e-03 + 2.345588190083e-03 2.330757432809e-03 2.315502893351e-03 2.299804864899e-03 + 2.283647510554e-03 2.267018983675e-03 2.249911525653e-03 2.232321540320e-03 + 2.214249644396e-03 2.195700693471e-03 2.176683783150e-03 2.157212225161e-03 + 2.137303498335e-03 2.116979174517e-03 2.096264819617e-03 2.075189870149e-03 + 2.053787485737e-03 2.032094378211e-03 2.010150618060e-03 1.987999419131e-03 + 1.965686902588e-03 1.943261841281e-03 1.920775385784e-03 1.898280773460e-03 + 1.875833022051e-03 1.853488609337e-03 1.831305140546e-03 1.809341005235e-03 + 1.787655025459e-03 1.766306097099e-03 1.745352826260e-03 1.724853162710e-03 + 1.704864032341e-03 1.685440970664e-03 1.666637759365e-03 1.648506067923e-03 + 1.631095102303e-03 1.614451262697e-03 1.598617812261e-03 1.583634558740e-03 + 1.569537550816e-03 1.556358790976e-03 1.544125966566e-03 1.532862200671e-03 + 1.522585824315e-03 1.513310171416e-03 1.505043397778e-03 1.497788325320e-03 + 1.491542312579e-03 1.486297152434e-03 1.482038997816e-03 1.478748316066e-03 + 1.476399872422e-03 1.474962742997e-03 1.474400357424e-03 1.474670571219e-03 + 1.475725767736e-03 1.477512989424e-03 1.479974097954e-03 1.483045962591e-03 + 1.486660676018e-03 1.490745796644e-03 1.495224616191e-03 1.500016451141e-03 + 1.505036956309e-03 1.510198458459e-03 1.515410307388e-03 1.520579241276e-03 + 1.525609762264e-03 1.530404517056e-03 1.534864675863e-03 1.538890300991e-03 + 1.542380693864e-03 1.545234706066e-03 1.547350996145e-03 1.548628209460e-03 + 1.548965053456e-03 1.548260235761e-03 1.546412228103e-03 1.543318816091e-03 + 1.538876394723e-03 1.532978973774e-03 1.525516867851e-03 1.516375065197e-03 + 1.505431299339e-03 1.492553890171e-03 1.477599476967e-03 1.460410834509e-03 + 1.440815042342e-03 1.418622360790e-03 1.393626247355e-03 1.365605011751e-03 + 1.334325642654e-03 1.299550327874e-03 1.261046115558e-03 1.218598012950e-03 + 1.172025582071e-03 1.121202767714e-03 1.066080293069e-03 1.006709506381e-03 + 9.432660968839e-04 8.760716716887e-04 8.056108587196e-04 7.325414389434e-04 + 6.576950741039e-04 5.820665294703e-04 5.067899161052e-04 4.331013826033e-04 + 3.622888231049e-04 2.956304490814e-04 2.343253757956e-04 1.794205564900e-04 + 1.317393073308e-04 9.181716538704e-05 5.985080447147e-05 3.566514426544e-05 + 1.870263515509e-05 8.037061819656e-06 2.412224729222e-06 3.037233152557e-07 + 0.000000000000e+00 + Type L N + 0 0 1 + -2.482045090982e+00 -2.481575045574e+00 -2.480165470569e+00 -2.477818048460e+00 + -2.474535579529e+00 -2.470321976047e+00 -2.465182254178e+00 -2.459122523607e+00 + -2.452149974922e+00 -2.444272864788e+00 -2.435500498945e+00 -2.425843213088e+00 + -2.415312351675e+00 -2.403920244720e+00 -2.391680182642e+00 -2.378606389230e+00 + -2.364713992806e+00 -2.350018995660e+00 -2.334538241841e+00 -2.318289383390e+00 + -2.301290845115e+00 -2.283561787985e+00 -2.265122071263e+00 -2.245992213466e+00 + -2.226193352253e+00 -2.205747203365e+00 -2.184676018704e+00 -2.163002543674e+00 + -2.140749973900e+00 -2.117941911420e+00 -2.094602320479e+00 -2.070755483035e+00 + -2.046425954085e+00 -2.021638516931e+00 -1.996418138491e+00 -1.970789924772e+00 + -1.944779076620e+00 -1.918410845833e+00 -1.891710491771e+00 -1.864703238550e+00 + -1.837414232921e+00 -1.809868502935e+00 -1.782090917498e+00 -1.754106146882e+00 + -1.725938624312e+00 -1.697612508679e+00 -1.669151648489e+00 -1.640579547098e+00 + -1.611919329315e+00 -1.583193709441e+00 -1.554424960789e+00 -1.525634886761e+00 + -1.496844793516e+00 -1.468075464277e+00 -1.439347135320e+00 -1.410679473678e+00 + -1.382091556583e+00 -1.353601852675e+00 -1.325228204995e+00 -1.296987815763e+00 + -1.268897232963e+00 -1.240972338727e+00 -1.213228339514e+00 -1.185679758069e+00 + -1.158340427166e+00 -1.131223485087e+00 -1.104341372837e+00 -1.077705833050e+00 + -1.051327910559e+00 -1.025217954588e+00 -9.993856225250e-01 -9.738398852256e-01 + -9.485890338035e-01 -9.236406878455e-01 -8.990018049992e-01 -8.746786918694e-01 + -8.506770161618e-01 -8.270018200069e-01 -8.036575343959e-01 -7.806479946579e-01 + -7.579764569072e-01 -7.356456153854e-01 -7.136576206255e-01 -6.920140983600e-01 + -6.707161690980e-01 -6.497644682943e-01 -6.291591670323e-01 -6.088999931456e-01 + -5.889862526999e-01 -5.694168517617e-01 -5.501903183760e-01 -5.313048246828e-01 + -5.127582090964e-01 -4.945479984792e-01 -4.766714302409e-01 -4.591254742947e-01 + -4.419068548071e-01 -4.250120716796e-01 -4.084374217002e-01 -3.921790193109e-01 + -3.762328169342e-01 -3.605946248099e-01 -3.452601302927e-01 -3.302249165662e-01 + -3.154844807329e-01 -3.010342512403e-01 -2.868696046111e-01 -2.729858814433e-01 + -2.593784016562e-01 -2.460424789550e-01 -2.329734344963e-01 -2.201666097361e-01 + -2.076173784471e-01 -1.953211578962e-01 -1.832734191754e-01 -1.714696966828e-01 + -1.599055967545e-01 -1.485768054503e-01 -1.374790955011e-01 -1.266083324259e-01 + -1.159604798325e-01 -1.055316039164e-01 -9.531787717658e-02 -8.531558136803e-02 + -7.552110971417e-02 -6.593096840459e-02 -5.654177740486e-02 -4.735027060758e-02 + -3.835329535547e-02 -2.954781136879e-02 -2.093088911078e-02 -1.249970762590e-02 + -4.251551886934e-03 3.816190312426e-03 1.170603188209e-02 1.942039033924e-02 + 2.696159205295e-02 3.433187679143e-02 4.153340253348e-02 4.856825050611e-02 + 5.543843041030e-02 6.214588579785e-02 6.869249956235e-02 7.508009950864e-02 + 8.131046396552e-02 8.738532740806e-02 9.330638605648e-02 9.907530342034e-02 + 1.046937157578e-01 1.101632374215e-01 1.154854660636e-01 1.206619876754e-01 + 1.256943814368e-01 1.305842243549e-01 1.353330956700e-01 1.399425810130e-01 + 1.444142762956e-01 1.487497913206e-01 1.529507530990e-01 1.570188088635e-01 + 1.609556287699e-01 1.647629082796e-01 1.684423702188e-01 1.719957665107e-01 + 1.754248795804e-01 1.787315234329e-01 1.819175444064e-01 1.849848216051e-01 + 1.879352670179e-01 1.907708253286e-01 1.934934734280e-01 1.961052196373e-01 + 1.986081026534e-01 2.010041902302e-01 2.032955776076e-01 2.054843857050e-01 + 2.075727590925e-01 2.095628637587e-01 2.114568846895e-01 2.132570232773e-01 + 2.149654945789e-01 2.165845244386e-01 2.181163464977e-01 2.195631991075e-01 + 2.209273221665e-01 2.222109538984e-01 2.234163275928e-01 2.245456683249e-01 + 2.256011896732e-01 2.265850904541e-01 2.274995514892e-01 2.283467324239e-01 + 2.291287686120e-01 2.298477680839e-01 2.305058086103e-01 2.311049348788e-01 + 2.316471557937e-01 2.321344419128e-01 2.325687230312e-01 2.329518859239e-01 + 2.332857722547e-01 2.335721766603e-01 2.338128450165e-01 2.340094728926e-01 + 2.341637041983e-01 2.342771300269e-01 2.343512876976e-01 2.343876599986e-01 + 2.343876746309e-01 2.343527038517e-01 2.342840643176e-01 2.341830171224e-01 + 2.340507680278e-01 2.338884678816e-01 2.336972132177e-01 2.334780470324e-01 + 2.332319597286e-01 2.329598902218e-01 2.326627271977e-01 2.323413105132e-01 + 2.319964327307e-01 2.316288407763e-01 2.312392377093e-01 2.308282845948e-01 + 2.303966024653e-01 2.299447743617e-01 2.294733474413e-01 2.289828351401e-01 + 2.284737193796e-01 2.279464528036e-01 2.274014610356e-01 2.268391449436e-01 + 2.262598829013e-01 2.256640330350e-01 2.250519354446e-01 2.244239143880e-01 + 2.237802804204e-01 2.231213324770e-01 2.224473598904e-01 2.217586443352e-01 + 2.210554616904e-01 2.203380838132e-01 2.196067802164e-01 2.188618196441e-01 + 2.181034715407e-01 2.173320074064e-01 2.165477020379e-01 2.157508346485e-01 + 2.149416898674e-01 2.141205586134e-01 2.132877388452e-01 2.124435361850e-01 + 2.115882644171e-01 2.107222458626e-01 2.098458116306e-01 2.089593017498e-01 + 2.080630651817e-01 2.071574597201e-01 2.062428517807e-01 2.053196160848e-01 + 2.043881352429e-01 2.034487992432e-01 2.025020048514e-01 2.015481549280e-01 + 2.005876576690e-01 1.996209257790e-01 1.986483755813e-01 1.976704260747e-01 + 1.966874979431e-01 1.957000125268e-01 1.947083907623e-01 1.937130520990e-01 + 1.927144134003e-01 1.917128878376e-01 1.907088837837e-01 1.897028037141e-01 + 1.886950431228e-01 1.876859894608e-01 1.866760211028e-01 1.856655063495e-01 + 1.846548024717e-01 1.836442548021e-01 1.826341958799e-01 1.816249446540e-01 + 1.806168057486e-01 1.796100687966e-01 1.786050078436e-01 1.776018808259e-01 + 1.766009291261e-01 1.756023772073e-01 1.746064323292e-01 1.736132843462e-01 + 1.726231055887e-01 1.716360508281e-01 1.706522573248e-01 1.696718449590e-01 + 1.686949164427e-01 1.677215576113e-01 1.667518377934e-01 1.657858102547e-01 + 1.648235127145e-01 1.638649679309e-01 1.629101843510e-01 1.619591568219e-01 + 1.610118673583e-01 1.600682859619e-01 1.591283714880e-01 1.581920725539e-01 + 1.572593284833e-01 1.563300702825e-01 1.554042216414e-01 1.544816999540e-01 + 1.535624173536e-01 1.526462817550e-01 1.517331979001e-01 1.508230683987e-01 + 1.499157947616e-01 1.490112784176e-01 1.481094217111e-01 1.472101288739e-01 + 1.463133069667e-01 1.454188667842e-01 1.445267237216e-01 1.436367985950e-01 + 1.427490184141e-01 1.418633171028e-01 1.409796361628e-01 1.400979252795e-01 + 1.392181428654e-01 1.383402565401e-01 1.374642435433e-01 1.365900910811e-01 + 1.357177966027e-01 1.348473680075e-01 1.339788237822e-01 1.331121930672e-01 + 1.322475156536e-01 1.313848419106e-01 1.305242326454e-01 1.296657588954e-01 + 1.288095016572e-01 1.279555515515e-01 1.271040084291e-01 1.262549809187e-01 + 1.254085859213e-01 1.245649480536e-01 1.237241990439e-01 1.228864770852e-01 + 1.220519261490e-01 1.212206952640e-01 1.203929377643e-01 1.195688105119e-01 + 1.187484730975e-01 1.179320870251e-01 1.171198148840e-01 1.163118195149e-01 + 1.155082631729e-01 1.147093066933e-01 1.139151086648e-01 1.131258246146e-01 + 1.123416062101e-01 1.115626004808e-01 1.107889490663e-01 1.100207874929e-01 + 1.092582444838e-01 1.085014413050e-01 1.077504911533e-01 1.070054985858e-01 + 1.062665589972e-01 1.055337581451e-01 1.048071717277e-01 1.040868650141e-01 + 1.033728925300e-01 1.026652978003e-01 1.019641131492e-01 1.012693595590e-01 + 1.005810465875e-01 9.989917234468e-02 9.922372352869e-02 9.855467551939e-02 + 9.789199253004e-02 9.723562781511e-02 9.658552393304e-02 9.594161306219e-02 + 9.530381736785e-02 9.467204941827e-02 9.404621264680e-02 9.342620185774e-02 + 9.281190377258e-02 9.220319761372e-02 9.159995572199e-02 9.100204420476e-02 + 9.040932361060e-02 8.982164962702e-02 8.923887379717e-02 8.866084425155e-02 + 8.808740645081e-02 8.751840393541e-02 8.695367907826e-02 8.639307383603e-02 + 8.583643049534e-02 8.528359240971e-02 8.473440472345e-02 8.418871507860e-02 + 8.364637430141e-02 8.310723706459e-02 8.257116252218e-02 8.203801491369e-02 + 8.150766413444e-02 8.097998626949e-02 8.045486408832e-02 7.993218749807e-02 + 7.941185395312e-02 7.889376881917e-02 7.837784569021e-02 7.786400665701e-02 + 7.735218252609e-02 7.684231298837e-02 7.633434673698e-02 7.582824153397e-02 + 7.532396422600e-02 7.482149070938e-02 7.432080584492e-02 7.382190332363e-02 + 7.332478548422e-02 7.282946308400e-02 7.233595502458e-02 7.184428803444e-02 + 7.135449631029e-02 7.086662111972e-02 7.038071036735e-02 6.989681812752e-02 + 6.941500414608e-02 6.893533331433e-02 6.845787511844e-02 6.798270306730e-02 + 6.750989410234e-02 6.703952799271e-02 6.657168671922e-02 6.610645385066e-02 + 6.564391391592e-02 6.518415177562e-02 6.472725199654e-02 6.427329823257e-02 + 6.382237261541e-02 6.337455515854e-02 6.292992317754e-02 6.248855073011e-02 + 6.205050807862e-02 6.161586117822e-02 6.118467119321e-02 6.075699404408e-02 + 6.033287998787e-02 5.991237323373e-02 5.949551159588e-02 5.908232618562e-02 + 5.867284114390e-02 5.826707341583e-02 5.786503256816e-02 5.746672065053e-02 + 5.707213210109e-02 5.668125369684e-02 5.629406454872e-02 5.591053614136e-02 + 5.553063241703e-02 5.515430990315e-02 5.478151788253e-02 5.441219860513e-02 + 5.404628754010e-02 5.368371366652e-02 5.332439980101e-02 5.296826296042e-02 + 5.261521475725e-02 5.226516182572e-02 5.191800627587e-02 5.157364617311e-02 + 5.123197604056e-02 5.089288738120e-02 5.055626921703e-02 5.022200864208e-02 + 4.988999138625e-02 4.956010238683e-02 4.923222636445e-02 4.890624840040e-02 + 4.858205451206e-02 4.825953222321e-02 4.793857112627e-02 4.761906343324e-02 + 4.730090451237e-02 4.698399340773e-02 4.666823333877e-02 4.635353217719e-02 + 4.603980289863e-02 4.572696400663e-02 4.541493992673e-02 4.510366136851e-02 + 4.479306565364e-02 4.448309700838e-02 4.417370681875e-02 4.386485384718e-02 + 4.355650440959e-02 4.324863251176e-02 4.294121994458e-02 4.263425633753e-02 + 4.232773917023e-02 4.202167374203e-02 4.171607309986e-02 4.141095792483e-02 + 4.110635637812e-02 4.080230390710e-02 4.049884301289e-02 4.019602298032e-02 + 3.989389957220e-02 3.959253468915e-02 3.929199599723e-02 3.899235652507e-02 + 3.869369423287e-02 3.839609155556e-02 3.809963492252e-02 3.780441425648e-02 + 3.751052245430e-02 3.721805485232e-02 3.692710867928e-02 3.663778249950e-02 + 3.635017564953e-02 3.606438767102e-02 3.578051774298e-02 3.549866411634e-02 + 3.521892355383e-02 3.494139077806e-02 3.466615793079e-02 3.439331404622e-02 + 3.412294454091e-02 3.385513072317e-02 3.358994932446e-02 3.332747205505e-02 + 3.306776518651e-02 3.281088916299e-02 3.255689824337e-02 3.230584017620e-02 + 3.205775590890e-02 3.181267933294e-02 3.157063706606e-02 3.133164827289e-02 + 3.109572452458e-02 3.086286969840e-02 3.063307991758e-02 3.040634353182e-02 + 3.018264113840e-02 2.996194564386e-02 2.974422236575e-02 2.952942917404e-02 + 2.931751667125e-02 2.910842841043e-02 2.890210114979e-02 2.869846514259e-02 + 2.849744446083e-02 2.829895735084e-02 2.810291661916e-02 2.790923004642e-02 + 2.771780082720e-02 2.752852803350e-02 2.734130709943e-02 2.715603032450e-02 + 2.697258739298e-02 2.679086590661e-02 2.661075192784e-02 2.643213053071e-02 + 2.625488635676e-02 2.607890417275e-02 2.590406942761e-02 2.573026880550e-02 + 2.555739077224e-02 2.538532611231e-02 2.521396845357e-02 2.504321477699e-02 + 2.487296590891e-02 2.470312699312e-02 2.453360794040e-02 2.436432385330e-02 + 2.419519542382e-02 2.402614930213e-02 2.385711843425e-02 2.368804236721e-02 + 2.351886751988e-02 2.334954741825e-02 2.318004289399e-02 2.301032224513e-02 + 2.284036135821e-02 2.267014379120e-02 2.249966081685e-02 2.232891142617e-02 + 2.215790229212e-02 2.198664769369e-02 2.181516940079e-02 2.164349652049e-02 + 2.147166530554e-02 2.129971892603e-02 2.112770720548e-02 2.095568632269e-02 + 2.078371848085e-02 2.061187154572e-02 2.044021865465e-02 2.026883779851e-02 + 2.009781137868e-02 1.992722574135e-02 1.975717069155e-02 1.958773898944e-02 + 1.941902583141e-02 1.925112831861e-02 1.908414491583e-02 1.891817490323e-02 + 1.875331782404e-02 1.858967293085e-02 1.842733863338e-02 1.826641195074e-02 + 1.810698797073e-02 1.794915931917e-02 1.779301564194e-02 1.763864310237e-02 + 1.748612389659e-02 1.733553578942e-02 1.718695167304e-02 1.704043915097e-02 + 1.689606014922e-02 1.675387055697e-02 1.661391989838e-02 1.647625103740e-02 + 1.634089991718e-02 1.620789533523e-02 1.607725875590e-02 1.594900416081e-02 + 1.582313793839e-02 1.569965881293e-02 1.557855781368e-02 1.545981828421e-02 + 1.534341593208e-02 1.522931891857e-02 1.511748798818e-02 1.500787663728e-02 + 1.490043132113e-02 1.479509169826e-02 1.469179091120e-02 1.459045590195e-02 + 1.449100776098e-02 1.439336210776e-02 1.429742950121e-02 1.420311587785e-02 + 1.411032301568e-02 1.401894902135e-02 1.392888883825e-02 1.384003477310e-02 + 1.375227703819e-02 1.366550430676e-02 1.357960427870e-02 1.349446425360e-02 + 1.340997170838e-02 1.332601487660e-02 1.324248332634e-02 1.315926853392e-02 + 1.307626445035e-02 1.299336805771e-02 1.291047991254e-02 1.282750467341e-02 + 1.274435160999e-02 1.266093509083e-02 1.257717504747e-02 1.249299741209e-02 + 1.240833452676e-02 1.232312552166e-02 1.223731666053e-02 1.215086165114e-02 + 1.206372191923e-02 1.197586684417e-02 1.188727395503e-02 1.179792908573e-02 + 1.170782648826e-02 1.161696890320e-02 1.152536758675e-02 1.143304229394e-02 + 1.134002121778e-02 1.124634088427e-02 1.115204600356e-02 1.105718927751e-02 + 1.096183116447e-02 1.086603960190e-02 1.076988968798e-02 1.067346332336e-02 + 1.057684881457e-02 1.048014044056e-02 1.038343798427e-02 1.028684623118e-02 + 1.019047443688e-02 1.009443576615e-02 9.998846705724e-03 9.903826453530e-03 + 9.809496287006e-03 9.715978913303e-03 9.623397804321e-03 9.531876519539e-03 + 9.441538019746e-03 9.352503974778e-03 9.264894068459e-03 9.178825303950e-03 + 9.094411312729e-03 9.011761670447e-03 8.930981222860e-03 8.852169425054e-03 + 8.775419697083e-03 8.700818799153e-03 8.628446229346e-03 8.558373646848e-03 + 8.490664323513e-03 8.425372626521e-03 8.362543534709e-03 8.302212191092e-03 + 8.244403493880e-03 8.189131728173e-03 8.136400240352e-03 8.086201156981e-03 + 8.038515149877e-03 7.993311248794e-03 7.950546702980e-03 7.910166892631e-03 + 7.872105291106e-03 7.836283478488e-03 7.802611206900e-03 7.770986517756e-03 + 7.741295910874e-03 7.713414565203e-03 7.687206610635e-03 7.662525450201e-03 + 7.639214131691e-03 7.617105767535e-03 7.596024001566e-03 7.575783521055e-03 + 7.556190612210e-03 7.537043757089e-03 7.518134269667e-03 7.499246968516e-03 + 7.480160883308e-03 7.460649991956e-03 7.440483984796e-03 7.419429051600e-03 + 7.397248686374e-03 7.373704503755e-03 7.348557059180e-03 7.321566662708e-03 + 7.292494173217e-03 7.261101755343e-03 7.227153575754e-03 7.190416407734e-03 + 7.150660103394e-03 7.107657880901e-03 7.061186359963e-03 7.011025262750e-03 + 6.956956680516e-03 6.898763789795e-03 6.836228889030e-03 6.769130620249e-03 + 6.697240246048e-03 6.620316875679e-03 6.538101582408e-03 6.450310435006e-03 + 6.356626585950e-03 6.256691722479e-03 6.150097395357e-03 6.036376989510e-03 + 5.914999378528e-03 5.785365589660e-03 5.646810065247e-03 5.498608297878e-03 + 5.339992688839e-03 5.170178377035e-03 4.988400454703e-03 4.793963383463e-03 + 4.586302526504e-03 4.365056527676e-03 4.130147843723e-03 3.881867166025e-03 + 3.620955894071e-03 3.348679427361e-03 3.066883035448e-03 2.778021663412e-03 + 2.485155425306e-03 2.191903869409e-03 1.902354418680e-03 1.620923637512e-03 + 1.352173964869e-03 1.100592970927e-03 8.703466194766e-04 6.650219625807e-04 + 4.873776537196e-04 3.391221866623e-04 2.207395111312e-04 1.313794780193e-04 + 6.882647551390e-05 2.955391019338e-05 8.865353422468e-06 1.115867959482e-06 + 0.000000000000e+00 + Type L N + 0 1 0 + 0.000000000000e+00 -2.619148756396e-02 -5.236486301972e-02 -7.850203930165e-02 + -1.045849793771e-01 -1.305957211313e-01 -1.565164020954e-01 -1.823292839654e-01 + -2.080167768610e-01 -2.335614632739e-01 -2.589461216556e-01 -2.841537495958e-01 + -3.091675865449e-01 -3.339711360326e-01 -3.585481873377e-01 -3.828828365671e-01 + -4.069595070990e-01 -4.307629693521e-01 -4.542783598414e-01 -4.774911994832e-01 + -5.003874111144e-01 -5.229533361944e-01 -5.451757506572e-01 -5.670418798862e-01 + -5.885394127849e-01 -6.096565149199e-01 -6.303818407138e-01 -6.507045446704e-01 + -6.706142916133e-01 -6.901012659255e-01 -7.091561797781e-01 -7.277702803377e-01 + -7.459353559473e-01 -7.636437412768e-01 -7.808883214399e-01 -7.976625350814e-01 + -8.139603764356e-01 -8.297763963643e-01 -8.451057023818e-01 -8.599439576786e-01 + -8.742873791567e-01 -8.881327344938e-01 -9.014773382523e-01 -9.143190470556e-01 + -9.266562538533e-01 -9.384878812996e-01 -9.498133742720e-01 -9.606326915587e-01 + -9.709462967451e-01 -9.807551483301e-01 -9.900606891086e-01 -9.988648348517e-01 + -1.007169962324e+00 -1.014978896675e+00 -1.022294898241e+00 -1.029121648800e+00 + -1.035463237323e+00 -1.041324145256e+00 -1.046709231379e+00 -1.051623716287e+00 + -1.056073166534e+00 -1.060063478479e+00 -1.063600861885e+00 -1.066691823310e+00 + -1.069343149337e+00 -1.071561889677e+00 -1.073355340199e+00 -1.074731025928e+00 + -1.075696684036e+00 -1.076260246899e+00 -1.076429825220e+00 -1.076213691295e+00 + -1.075620262432e+00 -1.074658084579e+00 -1.073335816178e+00 -1.071662212300e+00 + -1.069646109077e+00 -1.067296408467e+00 -1.064622063390e+00 -1.061632063245e+00 + -1.058335419858e+00 -1.054741153859e+00 -1.050858281535e+00 -1.046695802159e+00 + -1.042262685832e+00 -1.037567861841e+00 -1.032620207550e+00 -1.027428537849e+00 + -1.022001595150e+00 -1.016348039963e+00 -1.010476442037e+00 -1.004395272089e+00 + -9.981128941084e-01 -9.916375582498e-01 -9.849773943052e-01 -9.781404057575e-01 + -9.711344644075e-01 -9.639673055695e-01 -9.566465238271e-01 -9.491795693387e-01 + -9.415737446814e-01 -9.338362022213e-01 -9.259739419936e-01 -9.179938100794e-01 + -9.099024974594e-01 -9.017065393285e-01 -8.934123148501e-01 -8.850260473314e-01 + -8.765538047966e-01 -8.680015009377e-01 -8.593748964187e-01 -8.506796005108e-01 + -8.419210730338e-01 -8.331046265803e-01 -8.242354289977e-01 -8.153185061029e-01 + -8.063587446057e-01 -7.973608952151e-01 -7.883295759049e-01 -7.792692753130e-01 + -7.701843562510e-01 -7.610790593002e-01 -7.519575064699e-01 -7.428237048973e-01 + -7.336815505648e-01 -7.245348320142e-01 -7.153872340388e-01 -7.062423413307e-01 + -6.971036420686e-01 -6.879745314249e-01 -6.788583149780e-01 -6.697582120136e-01 + -6.606773587007e-01 -6.516188111292e-01 -6.425855481983e-01 -6.335804743433e-01 + -6.246064220940e-01 -6.156661544547e-01 -6.067623670998e-01 -5.978976903813e-01 + -5.890746911408e-01 -5.802958743272e-01 -5.715636844155e-01 -5.628805066289e-01 + -5.542486679631e-01 -5.456704380175e-01 -5.371480296347e-01 -5.286835993539e-01 + -5.202792476838e-01 -5.119370192015e-01 -5.036589024851e-01 -4.954468298887e-01 + -4.873026771689e-01 -4.792282629741e-01 -4.712253482055e-01 -4.632956352638e-01 + -4.554407671916e-01 -4.476623267261e-01 -4.399618352735e-01 -4.323407518198e-01 + -4.248004717903e-01 -4.173423258741e-01 -4.099675788240e-01 -4.026774282498e-01 + -3.954730034156e-01 -3.883553640567e-01 -3.813254992302e-01 -3.743843262106e-01 + -3.675326894452e-01 -3.607713595818e-01 -3.541010325795e-01 -3.475223289158e-01 + -3.410357929000e-01 -3.346418921031e-01 -3.283410169145e-01 -3.221334802342e-01 + -3.160195173078e-01 -3.099992857124e-01 -3.040728654994e-01 -2.982402594992e-01 + -2.925013937933e-01 -2.868561183560e-01 -2.813042078699e-01 -2.758453627149e-01 + -2.704792101334e-01 -2.652053055693e-01 -2.600231341813e-01 -2.549321125271e-01 + -2.499315904153e-01 -2.450208529216e-01 -2.401991225640e-01 -2.354655616297e-01 + -2.308192746499e-01 -2.262593110115e-01 -2.217846677005e-01 -2.173942921658e-01 + -2.130870852947e-01 -2.088619044905e-01 -2.047175668396e-01 -2.006528523587e-01 + -1.966665073086e-01 -1.927572475643e-01 -1.889237620269e-01 -1.851647160666e-01 + -1.814787549827e-01 -1.778645074676e-01 -1.743205890629e-01 -1.708456055934e-01 + -1.674381565660e-01 -1.640968385230e-01 -1.608202483334e-01 -1.576069864139e-01 + -1.544556598647e-01 -1.513648855108e-01 -1.483332928356e-01 -1.453595267988e-01 + -1.424422505258e-01 -1.395801478620e-01 -1.367719257811e-01 -1.340163166408e-01 + -1.313120802780e-01 -1.286580059372e-01 -1.260529140265e-01 -1.234956576962e-01 + -1.209851242359e-01 -1.185202362876e-01 -1.160999528715e-01 -1.137232702242e-01 + -1.113892224481e-01 -1.090968819726e-01 -1.068453598284e-01 -1.046338057376e-01 + -1.024614080212e-01 -1.003273933296e-01 -9.823102619963e-02 -9.617160844355e-02 + -9.414847837716e-02 -9.216100989289e-02 -9.020861138608e-02 -8.829072454252e-02 + -8.640682299614e-02 -8.455641086620e-02 -8.273902118386e-02 -8.095421421852e-02 + -7.920157571451e-02 -7.748071504934e-02 -7.579126332469e-02 -7.413287140170e-02 + -7.250520789230e-02 -7.090795711826e-02 -6.934081704988e-02 -6.780349723588e-02 + -6.629571673653e-02 -6.481720207113e-02 -6.336768519157e-02 -6.194690149273e-02 + -6.055458787067e-02 -5.919048083885e-02 -5.785431471242e-02 -5.654581987003e-02 + -5.526472110210e-02 -5.401073605396e-02 -5.278357377167e-02 -5.158293335769e-02 + -5.040850274282e-02 -4.925995758026e-02 -4.813696026688e-02 -4.703915909588e-02 + -4.596618754460e-02 -4.491766369995e-02 -4.389318982382e-02 -4.289235205930e-02 + -4.191472027834e-02 -4.095984807036e-02 -4.002727287065e-02 -3.911651622664e-02 + -3.822708419924e-02 -3.735846789596e-02 -3.651014413154e-02 -3.568157621131e-02 + -3.487221483170e-02 -3.408149909199e-02 -3.330885761033e-02 -3.255370973701e-02 + -3.181546685714e-02 -3.109353377455e-02 -3.038731016832e-02 -2.969619211295e-02 + -2.901957365295e-02 -2.835684842224e-02 -2.770741129870e-02 -2.707066008394e-02 + -2.644599719833e-02 -2.583283138132e-02 -2.523057938696e-02 -2.463866766481e-02 + -2.405653401635e-02 -2.348362921731e-02 -2.291941859653e-02 -2.236338356226e-02 + -2.181502306709e-02 -2.127385500310e-02 -2.073941751929e-02 -2.021127025380e-02 + -1.968899547377e-02 -1.917219911649e-02 -1.866051172597e-02 -1.815358927943e-02 + -1.765111389923e-02 -1.715279444616e-02 -1.665836699064e-02 -1.616759515933e-02 + -1.568027035507e-02 -1.519621184885e-02 -1.471526674340e-02 -1.423730980846e-02 + -1.376224318856e-02 -1.328999598499e-02 -1.282052371411e-02 -1.235380764503e-02 + -1.188985402008e-02 -1.142869316246e-02 -1.097037847581e-02 -1.051498534107e-02 + -1.006260991666e-02 -9.613367848339e-03 -9.167392895743e-03 -8.724835483000e-03 + -8.285861181084e-03 -7.850649130099e-03 -7.419390409886e-03 -6.992286367608e-03 + -6.569546911217e-03 -6.151388777816e-03 -5.738033786074e-03 -5.329707081897e-03 + -4.926635386553e-03 -4.529045256425e-03 -4.137161363471e-03 -3.751204805299e-03 + -3.371391453621e-03 -2.997930349555e-03 -2.631022154026e-03 -2.270857661113e-03 + -1.917616381888e-03 -1.571465205837e-03 -1.232557146521e-03 -9.010301776598e-04 + -5.770061652889e-04 -2.605899011067e-04 4.813175843625e-05 3.490906433619e-04 + 6.422379083571e-04 9.275445552270e-04 1.205001837536e-03 1.474621546020e-03 + 1.736436173996e-03 1.990498962683e-03 2.236883826949e-03 2.475685162717e-03 + 2.707017537841e-03 2.931015268937e-03 3.147831887239e-03 3.357639497146e-03 + 3.560628031719e-03 3.757004409902e-03 3.946991600762e-03 4.130827600566e-03 + 4.308764328889e-03 4.481066450456e-03 4.648010129698e-03 4.809881725434e-03 + 4.966976433299e-03 5.119596883860e-03 5.268051704510e-03 5.412654053433e-03 + 5.553720134020e-03 5.691567698189e-03 5.826514547092e-03 5.958877037639e-03 + 6.088968603225e-03 6.217098296899e-03 6.343569365063e-03 6.468677859564e-03 + 6.592711295807e-03 6.715947364200e-03 6.838652701932e-03 6.961081731675e-03 + 7.083475573440e-03 7.206061035334e-03 7.329049688515e-03 7.452637031143e-03 + 7.577001745578e-03 7.702305052573e-03 7.828690165593e-03 7.956281847848e-03 + 8.085186074022e-03 8.215489798083e-03 8.347260827936e-03 8.480547807099e-03 + 8.615380302952e-03 8.751769000514e-03 8.889706000109e-03 9.029165216702e-03 + 9.170102878110e-03 9.312458118742e-03 9.456153665011e-03 9.601096608027e-03 + 9.747179258719e-03 9.894280080088e-03 1.004226469085e-02 1.019098693440e-02 + 1.034029000656e-02 1.049000763547e-02 1.063996530646e-02 1.078998152469e-02 + 1.093986910817e-02 1.108943650339e-02 1.123848911607e-02 1.138683064909e-02 + 1.153426443998e-02 1.168059479010e-02 1.182562827797e-02 1.196917504910e-02 + 1.211105007508e-02 1.225107437457e-02 1.238907618943e-02 1.252489210927e-02 + 1.265836813807e-02 1.278936069695e-02 1.291773755751e-02 1.304337870048e-02 + 1.316617709511e-02 1.328603939499e-02 1.340288654648e-02 1.351665430671e-02 + 1.362729366825e-02 1.373477118843e-02 1.383906922175e-02 1.394018605422e-02 + 1.403813593933e-02 1.413294903569e-02 1.422467124705e-02 1.431336396600e-02 + 1.439910372306e-02 1.448198174369e-02 1.456210341591e-02 1.463958767211e-02 + 1.471456628879e-02 1.478718310873e-02 1.485759319026e-02 1.492596188893e-02 + 1.499246387717e-02 1.505728210784e-02 1.512060672793e-02 1.518263394902e-02 + 1.524356488117e-02 1.530360433731e-02 1.536295961518e-02 1.542183926410e-02 + 1.548045184398e-02 1.553900468373e-02 1.559770264664e-02 1.565674690985e-02 + 1.571633376528e-02 1.577665344884e-02 1.583788900517e-02 1.590021519414e-02 + 1.596379744599e-02 1.602879087085e-02 1.609533932872e-02 1.616357456515e-02 + 1.623361541785e-02 1.630556709873e-02 1.637952055562e-02 1.645555191742e-02 + 1.653372202582e-02 1.661407605643e-02 1.669664323138e-02 1.678143662521e-02 + 1.686845306507e-02 1.695767312578e-02 1.704906121987e-02 1.714256578196e-02 + 1.723811954648e-02 1.733563991699e-02 1.743502942507e-02 1.753617627600e-02 + 1.763895497808e-02 1.774322705193e-02 1.784884181561e-02 1.795563724100e-02 + 1.806344087646e-02 1.817207083037e-02 1.828133680986e-02 1.839104120867e-02 + 1.850098023783e-02 1.861094509253e-02 1.872072314848e-02 1.883009918077e-02 + 1.893885659806e-02 1.904677868516e-02 1.915364984645e-02 1.925925684325e-02 + 1.936339001770e-02 1.946584449621e-02 1.956642136531e-02 1.966492881331e-02 + 1.976118323090e-02 1.985501026443e-02 1.994624581574e-02 2.003473698266e-02 + 2.012034293477e-02 2.020293571936e-02 2.028240099279e-02 2.035863867308e-02 + 2.043156350995e-02 2.050110556888e-02 2.056721062645e-02 2.062984047468e-02 + 2.068897313245e-02 2.074460296295e-02 2.079674069621e-02 2.084541335683e-02 + 2.089066409712e-02 2.093255193665e-02 2.097115140973e-02 2.100655212284e-02 + 2.103885822446e-02 2.106818779056e-02 2.109467212911e-02 2.111845500767e-02 + 2.113969180865e-02 2.115854861693e-02 2.117520124532e-02 2.118983420338e-02 + 2.120263961558e-02 2.121381609520e-02 2.122356758033e-02 2.123210213890e-02 + 2.123963074957e-02 2.124636606559e-02 2.125252116890e-02 2.125830832160e-02 + 2.126393772218e-02 2.126961627368e-02 2.127554637107e-02 2.128192471477e-02 + 2.128894115740e-02 2.129677759051e-02 2.130560687763e-02 2.131559184016e-02 + 2.132688430185e-02 2.133962419759e-02 2.135393875177e-02 2.136994173102e-02 + 2.138773277581e-02 2.140739681481e-02 2.142900356564e-02 2.145260712483e-02 + 2.147824564965e-02 2.150594113364e-02 2.153569927730e-02 2.156750945480e-02 + 2.160134477700e-02 2.163716225049e-02 2.167490303187e-02 2.171449277595e-02 + 2.175584207575e-02 2.179884699208e-02 2.184338966957e-02 2.188933903561e-02 + 2.193655157843e-02 2.198487219960e-02 2.203413513628e-02 2.208416494774e-02 + 2.213477756065e-02 2.218578136687e-02 2.223697836761e-02 2.228816535713e-02 + 2.233913513923e-02 2.238967776935e-02 2.243958181514e-02 2.248863562797e-02 + 2.253662861809e-02 2.258335252583e-02 2.262860268145e-02 2.267217924618e-02 + 2.271388842704e-02 2.275354365840e-02 2.279096674309e-02 2.282598894641e-02 + 2.285845203635e-02 2.288820926393e-02 2.291512627762e-02 2.293908196640e-02 + 2.295996922622e-02 2.297769564529e-02 2.299218410388e-02 2.300337328484e-02 + 2.301121809170e-02 2.301568997160e-02 2.301677714081e-02 2.301448471143e-02 + 2.300883471803e-02 2.299986604390e-02 2.298763424715e-02 2.297221128710e-02 + 2.295368515261e-02 2.293215939400e-02 2.290775256113e-02 2.288059755062e-02 + 2.285084086581e-02 2.281864179350e-02 2.278417150202e-02 2.274761206582e-02 + 2.270915542192e-02 2.266900226427e-02 2.262736088227e-02 2.258444595016e-02 + 2.254047727415e-02 2.249567850465e-02 2.245027582107e-02 2.240449659678e-02 + 2.235856805212e-02 2.231271590338e-02 2.226716301569e-02 2.222212806786e-02 + 2.217782423709e-02 2.213445791144e-02 2.209222743784e-02 2.205132191314e-02 + 2.201192002567e-02 2.197418895432e-02 2.193828333201e-02 2.190434427997e-02 + 2.187249851887e-02 2.184285756262e-02 2.181551699982e-02 2.179055586779e-02 + 2.176803612321e-02 2.174800221325e-02 2.173048074999e-02 2.171548029103e-02 + 2.170299122778e-02 2.169298578312e-02 2.168541811879e-02 2.168022455268e-02 + 2.167732388541e-02 2.167661783493e-02 2.167799157718e-02 2.168131439039e-02 + 2.168644039986e-02 2.169320941939e-02 2.170144788518e-02 2.171096987713e-02 + 2.172157822222e-02 2.173306567395e-02 2.174521616147e-02 2.175780610142e-02 + 2.177060576518e-02 2.178338069396e-02 2.179589315354e-02 2.180790362049e-02 + 2.181917229125e-02 2.182946060530e-02 2.183853277351e-02 2.184615730267e-02 + 2.185210850718e-02 2.185616799866e-02 2.185812614465e-02 2.185778348735e-02 + 2.185495211363e-02 2.184945696779e-02 2.184113709866e-02 2.182984683306e-02 + 2.181545686793e-02 2.179785527376e-02 2.177694840253e-02 2.175266169377e-02 + 2.172494037273e-02 2.169375003548e-02 2.165907711615e-02 2.162092923210e-02 + 2.157933540362e-02 2.153434614529e-02 2.148603342686e-02 2.143449050224e-02 + 2.137983160587e-02 2.132219151644e-02 2.126172498881e-02 2.119860605552e-02 + 2.113302720010e-02 2.106519840518e-02 2.099534607909e-02 2.092371186512e-02 + 2.085055133881e-02 2.077613259864e-02 2.070073475676e-02 2.062464633657e-02 + 2.054816358470e-02 2.047158870559e-02 2.039522802713e-02 2.031939010651e-02 + 2.024438378571e-02 2.017051620651e-02 2.009809079520e-02 2.002740522733e-02 + 1.995874938339e-02 1.989240330600e-02 1.982863516971e-02 1.976769927438e-02 + 1.970983407307e-02 1.965526024551e-02 1.960417882772e-02 1.955676940876e-02 + 1.951318840466e-02 1.947356741995e-02 1.943801170636e-02 1.940659872817e-02 + 1.937937684318e-02 1.935636410766e-02 1.933754721316e-02 1.932288056267e-02 + 1.931228549258e-02 1.930564964660e-02 1.930282650696e-02 1.930363508734e-02 + 1.930785979149e-02 1.931525044047e-02 1.932552247072e-02 1.933835730439e-02 + 1.935340289245e-02 1.937027443016e-02 1.938855524387e-02 1.940779784701e-02 + 1.942752516217e-02 1.944723190571e-02 1.946638612966e-02 1.948443091549e-02 + 1.950078621243e-02 1.951485081234e-02 1.952600445117e-02 1.953361002533e-02 + 1.953701590851e-02 1.953555835114e-02 1.952856393958e-02 1.951535208590e-02 + 1.949523750933e-02 1.946753265869e-02 1.943155000790e-02 1.938660413540e-02 + 1.933201347007e-02 1.926710155243e-02 1.919119761851e-02 1.910363626729e-02 + 1.900375592273e-02 1.889089575277e-02 1.876439066726e-02 1.862356399556e-02 + 1.846771745619e-02 1.829611809251e-02 1.810798198195e-02 1.790245475170e-02 + 1.767858927235e-02 1.743532136835e-02 1.717144498381e-02 1.688558896444e-02 + 1.657619842677e-02 1.624152452384e-02 1.587962718961e-02 1.548839602965e-02 + 1.506559477392e-02 1.460893445471e-02 1.411617955952e-02 1.358528970263e-02 + 1.301459678658e-02 1.240301420140e-02 1.175027046629e-02 1.105715512477e-02 + 1.032576006732e-02 9.559695308356e-03 8.764255204101e-03 7.946509802481e-03 + 7.115297042524e-03 6.281095287844e-03 5.455762355303e-03 4.652136625604e-03 + 3.883507462241e-03 3.162975109536e-03 2.502733260001e-03 1.913319137545e-03 + 1.402884747950e-03 9.765475531969e-04 6.358782201147e-04 3.785767743619e-04 + 1.983765869872e-04 8.519893699498e-05 2.556086363756e-05 3.217573100688e-06 + 0.000000000000e+00 \ No newline at end of file diff --git a/ABACUS.develop/examples/H2O-deepks/INPUT b/ABACUS.develop/examples/H2O-deepks-pw/INPUT similarity index 100% rename from ABACUS.develop/examples/H2O-deepks/INPUT rename to ABACUS.develop/examples/H2O-deepks-pw/INPUT diff --git a/ABACUS.develop/examples/H2O-deepks/INPUTs b/ABACUS.develop/examples/H2O-deepks-pw/INPUTs similarity index 100% rename from ABACUS.develop/examples/H2O-deepks/INPUTs rename to ABACUS.develop/examples/H2O-deepks-pw/INPUTs diff --git a/ABACUS.develop/examples/H2O-deepks-pw/KPT b/ABACUS.develop/examples/H2O-deepks-pw/KPT new file mode 100644 index 0000000000..c289c0158a --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks-pw/KPT @@ -0,0 +1,4 @@ +K_POINTS +0 +Gamma +1 1 1 0 0 0 diff --git a/ABACUS.develop/examples/H2O-deepks-pw/O_ONCV_PBE-1.0.upf b/ABACUS.develop/examples/H2O-deepks-pw/O_ONCV_PBE-1.0.upf new file mode 100644 index 0000000000..7e7db6d66f --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks-pw/O_ONCV_PBE-1.0.upf @@ -0,0 +1,1224 @@ + + + + This pseudopotential file has been produced using the code + ONCVPSP (Optimized Norm-Conservinng Vanderbilt PSeudopotential) + scalar-relativistic version 2.1.1, 03/26/2014 by D. R. Hamann + The code is available through a link at URL www.mat-simresearch.com. + Documentation with the package provides a full discription of the + input data below. + + + While it is not required under the terms of the GNU GPL, it is + suggested that you cite D. R. Hamann, Phys. Rev. B 88, 085117 (2013) + in any publication using these pseudopotentials. + + + Copyright 2015 The Regents of the University of California + + This work is licensed under the Creative Commons Attribution-ShareAlike + 4.0 International License. To view a copy of this license, visit + http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to + Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. + + This pseudopotential is part of the Schlipf-Gygi norm-conserving + pseudopotential library. Its construction parameters were tuned to + reproduce materials of a training set with very high accuracy and + should be suitable as a general purpose pseudopotential to treat a + variety of different compounds. For details of the construction and + testing of the pseudopotential please refer to: + + [insert reference to paper here] + + We kindly ask that you include this reference in all publications + associated to this pseudopotential. + + + +# ATOM AND REFERENCE CONFIGURATION +# atsym z nc nv iexc psfile + O 8.00 1 2 4 upf +# +# n l f energy (Ha) + 1 0 2.00 + 2 0 2.00 + 2 1 4.00 +# +# PSEUDOPOTENTIAL AND OPTIMIZATION +# lmax + 1 +# +# l, rc, ep, ncon, nbas, qcut + 0 1.29195 -0.88057 5 8 8.98916 + 1 1.47310 -0.33187 5 8 9.14990 +# +# LOCAL POTENTIAL +# lloc, lpopt, rc(5), dvloc0 + 4 5 0.90330 0.00000 +# +# VANDERBILT-KLEINMAN-BYLANDER PROJECTORs +# l, nproj, debl + 0 2 1.51851 + 1 2 1.53631 +# +# MODEL CORE CHARGE +# icmod, fcfact + 0 0.00000 +# +# LOG DERIVATIVE ANALYSIS +# epsh1, epsh2, depsh + -5.00 3.00 0.02 +# +# OUTPUT GRID +# rlmax, drl + 6.00 0.01 +# +# TEST CONFIGURATIONS +# ncnf + 0 +# nvcnf +# n l f + + + + + + + + + 0.0000 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600 0.0700 + 0.0800 0.0900 0.1000 0.1100 0.1200 0.1300 0.1400 0.1500 + 0.1600 0.1700 0.1800 0.1900 0.2000 0.2100 0.2200 0.2300 + 0.2400 0.2500 0.2600 0.2700 0.2800 0.2900 0.3000 0.3100 + 0.3200 0.3300 0.3400 0.3500 0.3600 0.3700 0.3800 0.3900 + 0.4000 0.4100 0.4200 0.4300 0.4400 0.4500 0.4600 0.4700 + 0.4800 0.4900 0.5000 0.5100 0.5200 0.5300 0.5400 0.5500 + 0.5600 0.5700 0.5800 0.5900 0.6000 0.6100 0.6200 0.6300 + 0.6400 0.6500 0.6600 0.6700 0.6800 0.6900 0.7000 0.7100 + 0.7200 0.7300 0.7400 0.7500 0.7600 0.7700 0.7800 0.7900 + 0.8000 0.8100 0.8200 0.8300 0.8400 0.8500 0.8600 0.8700 + 0.8800 0.8900 0.9000 0.9100 0.9200 0.9300 0.9400 0.9500 + 0.9600 0.9700 0.9800 0.9900 1.0000 1.0100 1.0200 1.0300 + 1.0400 1.0500 1.0600 1.0700 1.0800 1.0900 1.1000 1.1100 + 1.1200 1.1300 1.1400 1.1500 1.1600 1.1700 1.1800 1.1900 + 1.2000 1.2100 1.2200 1.2300 1.2400 1.2500 1.2600 1.2700 + 1.2800 1.2900 1.3000 1.3100 1.3200 1.3300 1.3400 1.3500 + 1.3600 1.3700 1.3800 1.3900 1.4000 1.4100 1.4200 1.4300 + 1.4400 1.4500 1.4600 1.4700 1.4800 1.4900 1.5000 1.5100 + 1.5200 1.5300 1.5400 1.5500 1.5600 1.5700 1.5800 1.5900 + 1.6000 1.6100 1.6200 1.6300 1.6400 1.6500 1.6600 1.6700 + 1.6800 1.6900 1.7000 1.7100 1.7200 1.7300 1.7400 1.7500 + 1.7600 1.7700 1.7800 1.7900 1.8000 1.8100 1.8200 1.8300 + 1.8400 1.8500 1.8600 1.8700 1.8800 1.8900 1.9000 1.9100 + 1.9200 1.9300 1.9400 1.9500 1.9600 1.9700 1.9800 1.9900 + 2.0000 2.0100 2.0200 2.0300 2.0400 2.0500 2.0600 2.0700 + 2.0800 2.0900 2.1000 2.1100 2.1200 2.1300 2.1400 2.1500 + 2.1600 2.1700 2.1800 2.1900 2.2000 2.2100 2.2200 2.2300 + 2.2400 2.2500 2.2600 2.2700 2.2800 2.2900 2.3000 2.3100 + 2.3200 2.3300 2.3400 2.3500 2.3600 2.3700 2.3800 2.3900 + 2.4000 2.4100 2.4200 2.4300 2.4400 2.4500 2.4600 2.4700 + 2.4800 2.4900 2.5000 2.5100 2.5200 2.5300 2.5400 2.5500 + 2.5600 2.5700 2.5800 2.5900 2.6000 2.6100 2.6200 2.6300 + 2.6400 2.6500 2.6600 2.6700 2.6800 2.6900 2.7000 2.7100 + 2.7200 2.7300 2.7400 2.7500 2.7600 2.7700 2.7800 2.7900 + 2.8000 2.8100 2.8200 2.8300 2.8400 2.8500 2.8600 2.8700 + 2.8800 2.8900 2.9000 2.9100 2.9200 2.9300 2.9400 2.9500 + 2.9600 2.9700 2.9800 2.9900 3.0000 3.0100 3.0200 3.0300 + 3.0400 3.0500 3.0600 3.0700 3.0800 3.0900 3.1000 3.1100 + 3.1200 3.1300 3.1400 3.1500 3.1600 3.1700 3.1800 3.1900 + 3.2000 3.2100 3.2200 3.2300 3.2400 3.2500 3.2600 3.2700 + 3.2800 3.2900 3.3000 3.3100 3.3200 3.3300 3.3400 3.3500 + 3.3600 3.3700 3.3800 3.3900 3.4000 3.4100 3.4200 3.4300 + 3.4400 3.4500 3.4600 3.4700 3.4800 3.4900 3.5000 3.5100 + 3.5200 3.5300 3.5400 3.5500 3.5600 3.5700 3.5800 3.5900 + 3.6000 3.6100 3.6200 3.6300 3.6400 3.6500 3.6600 3.6700 + 3.6800 3.6900 3.7000 3.7100 3.7200 3.7300 3.7400 3.7500 + 3.7600 3.7700 3.7800 3.7900 3.8000 3.8100 3.8200 3.8300 + 3.8400 3.8500 3.8600 3.8700 3.8800 3.8900 3.9000 3.9100 + 3.9200 3.9300 3.9400 3.9500 3.9600 3.9700 3.9800 3.9900 + 4.0000 4.0100 4.0200 4.0300 4.0400 4.0500 4.0600 4.0700 + 4.0800 4.0900 4.1000 4.1100 4.1200 4.1300 4.1400 4.1500 + 4.1600 4.1700 4.1800 4.1900 4.2000 4.2100 4.2200 4.2300 + 4.2400 4.2500 4.2600 4.2700 4.2800 4.2900 4.3000 4.3100 + 4.3200 4.3300 4.3400 4.3500 4.3600 4.3700 4.3800 4.3900 + 4.4000 4.4100 4.4200 4.4300 4.4400 4.4500 4.4600 4.4700 + 4.4800 4.4900 4.5000 4.5100 4.5200 4.5300 4.5400 4.5500 + 4.5600 4.5700 4.5800 4.5900 4.6000 4.6100 4.6200 4.6300 + 4.6400 4.6500 4.6600 4.6700 4.6800 4.6900 4.7000 4.7100 + 4.7200 4.7300 4.7400 4.7500 4.7600 4.7700 4.7800 4.7900 + 4.8000 4.8100 4.8200 4.8300 4.8400 4.8500 4.8600 4.8700 + 4.8800 4.8900 4.9000 4.9100 4.9200 4.9300 4.9400 4.9500 + 4.9600 4.9700 4.9800 4.9900 5.0000 5.0100 5.0200 5.0300 + 5.0400 5.0500 5.0600 5.0700 5.0800 5.0900 5.1000 5.1100 + 5.1200 5.1300 5.1400 5.1500 5.1600 5.1700 5.1800 5.1900 + 5.2000 5.2100 5.2200 5.2300 5.2400 5.2500 5.2600 5.2700 + 5.2800 5.2900 5.3000 5.3100 5.3200 5.3300 5.3400 5.3500 + 5.3600 5.3700 5.3800 5.3900 5.4000 5.4100 5.4200 5.4300 + 5.4400 5.4500 5.4600 5.4700 5.4800 5.4900 5.5000 5.5100 + 5.5200 5.5300 5.5400 5.5500 5.5600 5.5700 5.5800 5.5900 + 5.6000 5.6100 5.6200 5.6300 5.6400 5.6500 5.6600 5.6700 + 5.6800 5.6900 5.7000 5.7100 5.7200 5.7300 5.7400 5.7500 + 5.7600 5.7700 5.7800 5.7900 5.8000 5.8100 5.8200 5.8300 + 5.8400 5.8500 5.8600 5.8700 5.8800 5.8900 5.9000 5.9100 + 5.9200 5.9300 5.9400 5.9500 5.9600 5.9700 5.9800 5.9900 + 6.0000 6.0100 + + + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 0.0100 + 0.0100 0.0100 + + + + -2.7605700345E+01 -3.0784865229E+01 -3.2349253618E+01 -3.2751366129E+01 + -3.2443703381E+01 -3.1938024293E+01 -3.1464309182E+01 -3.1081089156E+01 + -3.0780110534E+01 -3.0537539935E+01 -3.0331510013E+01 -3.0145737072E+01 + -2.9968950315E+01 -2.9793612997E+01 -2.9614858119E+01 -2.9429745358E+01 + -2.9236754295E+01 -2.9035419392E+01 -2.8826044018E+01 -2.8609460457E+01 + -2.8386823980E+01 -2.8159440471E+01 -2.7928630453E+01 -2.7695631454E+01 + -2.7461537210E+01 -2.7227268680E+01 -2.6993569183E+01 -2.6761015821E+01 + -2.6530039202E+01 -2.6300945472E+01 -2.6073936437E+01 -2.5849125236E+01 + -2.5626546546E+01 -2.5406161554E+01 -2.5187858066E+01 -2.4971448643E+01 + -2.4756666888E+01 -2.4543166280E+01 -2.4330521781E+01 -2.4118237688E+01 + -2.3905762462E+01 -2.3692510781E+01 -2.3477892157E+01 -2.3261343931E+01 + -2.3042365424E+01 -2.2820549497E+01 -2.2595607833E+01 -2.2367387034E+01 + -2.2135873927E+01 -2.1901189722E+01 -2.1663577130E+01 -2.1423377048E+01 + -2.1181003715E+01 -2.0936919717E+01 -2.0691610496E+01 -2.0445564221E+01 + -2.0199254652E+01 -1.9953130261E+01 -1.9707605286E+01 -1.9463057569E+01 + -1.9219826157E+01 -1.8978213343E+01 -1.8738487400E+01 -1.8500884660E+01 + -1.8265614596E+01 -1.8032862583E+01 -1.7802792920E+01 -1.7575552408E+01 + -1.7351272692E+01 -1.7130071760E+01 -1.6912056036E+01 -1.6697321537E+01 + -1.6485954716E+01 -1.6278033179E+01 -1.6073625719E+01 -1.5872792819E+01 + -1.5675586595E+01 -1.5482050684E+01 -1.5292220051E+01 -1.5106120725E+01 + -1.4923769479E+01 -1.4745173477E+01 -1.4570329881E+01 -1.4399225454E+01 + -1.4231836134E+01 -1.4068126609E+01 -1.3908049886E+01 -1.3751546850E+01 + -1.3598545829E+01 -1.3448962145E+01 -1.3302697611E+01 -1.3159640031E+01 + -1.3019669910E+01 -1.2882669787E+01 -1.2748527869E+01 -1.2617137724E+01 + -1.2488398068E+01 -1.2362212574E+01 -1.2238489692E+01 -1.2117142884E+01 + -1.1998090066E+01 -1.1881253628E+01 -1.1766560302E+01 -1.1653941032E+01 + -1.1543330569E+01 -1.1434668196E+01 -1.1327896756E+01 -1.1222962743E+01 + -1.1119816109E+01 -1.1018409929E+01 -1.0918701041E+01 -1.0820648952E+01 + -1.0724215912E+01 -1.0629366457E+01 -1.0536068056E+01 -1.0444290028E+01 + -1.0354003461E+01 -1.0265180964E+01 -1.0177796938E+01 -1.0091826632E+01 + -1.0007246112E+01 -9.9240322892E+00 -9.8421624187E+00 -9.7616139299E+00 + -9.6823643703E+00 -9.6043910435E+00 -9.5276710191E+00 -9.4521810563E+00 + -9.3778971539E+00 -9.3047950086E+00 -9.2328496504E+00 -9.1620363695E+00 + -9.0923305110E+00 -9.0237077361E+00 -8.9561431451E+00 -8.8896116158E+00 + -8.8240890211E+00 -8.7595512275E+00 -8.6959740871E+00 -8.6333343002E+00 + -8.5716086751E+00 -8.5107748378E+00 -8.4508110921E+00 -8.3916960209E+00 + -8.3334097570E+00 -8.2759323779E+00 -8.2192454990E+00 -8.1633312824E+00 + -8.1081727717E+00 -8.0537547331E+00 -8.0000623436E+00 -7.9470813275E+00 + -7.8947972321E+00 -7.8431966714E+00 -7.7922661900E+00 -7.7419928953E+00 + -7.6923641381E+00 -7.6433675558E+00 -7.5949912477E+00 -7.5472233618E+00 + -7.5000526824E+00 -7.4534678545E+00 -7.4074582876E+00 -7.3620131113E+00 + -7.3171223055E+00 -7.2727754717E+00 -7.2289631023E+00 -7.1856752817E+00 + -7.1429029518E+00 -7.1006366576E+00 -7.0588677730E+00 -7.0175872653E+00 + -6.9767869231E+00 -6.9364581153E+00 -6.8965930059E+00 -6.8571833718E+00 + -6.8182217002E+00 -6.7797001743E+00 -6.7416115702E+00 -6.7039484718E+00 + -6.6667039108E+00 -6.6298708673E+00 -6.5934425974E+00 -6.5574124728E+00 + -6.5217739457E+00 -6.4865207734E+00 -6.4516465808E+00 -6.4171455001E+00 + -6.3830113137E+00 -6.3492384567E+00 -6.3158210267E+00 -6.2827535725E+00 + -6.2500305645E+00 -6.2176466374E+00 -6.1855966333E+00 -6.1538752555E+00 + -6.1224776754E+00 -6.0913987519E+00 -6.0606338291E+00 -6.0301780858E+00 + -6.0000268845E+00 -5.9701757684E+00 -5.9406201055E+00 -5.9113557302E+00 + -5.8823781953E+00 -5.8536833983E+00 -5.8252672254E+00 -5.7971255362E+00 + -5.7692545325E+00 -5.7416501530E+00 -5.7143087187E+00 -5.6872264675E+00 + -5.6603996483E+00 -5.6338248102E+00 -5.6074982583E+00 -5.5814166408E+00 + -5.5555765569E+00 -5.5299745536E+00 -5.5046075112E+00 -5.4794720848E+00 + -5.4545651655E+00 -5.4298837212E+00 -5.4054245210E+00 -5.3811847580E+00 + -5.3571614267E+00 -5.3333515869E+00 -5.3097525260E+00 -5.2863613325E+00 + -5.2631753334E+00 -5.2401918998E+00 -5.2174082208E+00 -5.1948218607E+00 + -5.1724302389E+00 -5.1502307471E+00 -5.1282210592E+00 -5.1063986772E+00 + -5.0847611945E+00 -5.0633063698E+00 -5.0420317959E+00 -5.0209352464E+00 + -5.0000145619E+00 -4.9792674276E+00 -4.9586917756E+00 -4.9382855278E+00 + -4.9180464624E+00 -4.8979726494E+00 -4.8780620924E+00 -4.8583126624E+00 + -4.8387225484E+00 -4.8192898345E+00 -4.8000124892E+00 -4.7808887980E+00 + -4.7619169283E+00 -4.7430949440E+00 -4.7244212124E+00 -4.7058939893E+00 + -4.6875114188E+00 -4.6692719493E+00 -4.6511739183E+00 -4.6332155580E+00 + -4.6153953755E+00 -4.5977117925E+00 -4.5801631296E+00 -4.5627479386E+00 + -4.5454647266E+00 -4.5283119032E+00 -4.5112880519E+00 -4.4943917650E+00 + -4.4776215414E+00 -4.4609759844E+00 -4.4444537713E+00 -4.4280534916E+00 + -4.4117737574E+00 -4.3956133298E+00 -4.3795708900E+00 -4.3636450498E+00 + -4.3478346519E+00 -4.3321384475E+00 -4.3165551080E+00 -4.3010834883E+00 + -4.2857224193E+00 -4.2704706626E+00 -4.2553270471E+00 -4.2402904912E+00 + -4.2253598492E+00 -4.2105339172E+00 -4.1958116967E+00 -4.1811921057E+00 + -4.1666739956E+00 -4.1522563551E+00 -4.1379381819E+00 -4.1237184204E+00 + -4.1095960051E+00 -4.0955700209E+00 -4.0816394841E+00 -4.0678033425E+00 + -4.0540606926E+00 -4.0404106187E+00 -4.0268521620E+00 -4.0133843475E+00 + -4.0000063484E+00 -3.9867172703E+00 -3.9735161622E+00 -3.9604021828E+00 + -3.9473745101E+00 -3.9344322882E+00 -3.9215745909E+00 -3.9088006833E+00 + -3.8961097526E+00 -3.8835009538E+00 -3.8709734686E+00 -3.8585265734E+00 + -3.8461594934E+00 -3.8338713986E+00 -3.8216615661E+00 -3.8095292837E+00 + -3.7974738126E+00 -3.7854943426E+00 -3.7735902317E+00 -3.7617607813E+00 + -3.7500052762E+00 -3.7383229617E+00 -3.7267132311E+00 -3.7151754129E+00 + -3.7037088125E+00 -3.6923127373E+00 -3.6809865997E+00 -3.6697297595E+00 + -3.6585415452E+00 -3.6474213158E+00 -3.6363685045E+00 -3.6253825007E+00 + -3.6144626587E+00 -3.6036083788E+00 -3.5928191167E+00 -3.5820942902E+00 + -3.5714332815E+00 -3.5608355222E+00 -3.5503004929E+00 -3.5398276385E+00 + -3.5294163709E+00 -3.5190661440E+00 -3.5087764652E+00 -3.4985468053E+00 + -3.4883766076E+00 -3.4782653400E+00 -3.4682125383E+00 -3.4582176981E+00 + -3.4482802961E+00 -3.4383998061E+00 -3.4285757940E+00 -3.4188077789E+00 + -3.4090952728E+00 -3.3994377480E+00 -3.3898348019E+00 -3.3802859760E+00 + -3.3707908119E+00 -3.3613487964E+00 -3.3519595367E+00 -3.3426226031E+00 + -3.3333375585E+00 -3.3241039280E+00 -3.3149213002E+00 -3.3057892823E+00 + -3.2967074576E+00 -3.2876753919E+00 -3.2786926486E+00 -3.2697588729E+00 + -3.2608736674E+00 -3.2520366348E+00 -3.2432473253E+00 -3.2345054052E+00 + -3.2258105008E+00 -3.2171622335E+00 -3.2085601965E+00 -3.2000040171E+00 + -3.1914933640E+00 -3.1830278760E+00 -3.1746071920E+00 -3.1662308963E+00 + -3.1578986987E+00 -3.1496102547E+00 -3.1413652201E+00 -3.1331632249E+00 + -3.1250039281E+00 -3.1168870307E+00 -3.1088122044E+00 -3.1007791210E+00 + -3.0927874062E+00 -3.0848367838E+00 -3.0769269476E+00 -3.0690575847E+00 + -3.0612283700E+00 -3.0534389657E+00 -3.0456891132E+00 -3.0379785141E+00 + -3.0303068700E+00 -3.0226738555E+00 -3.0150791818E+00 -3.0075225888E+00 + -3.0000037918E+00 -2.9925225065E+00 -2.9850784103E+00 -2.9776712548E+00 + -2.9703007806E+00 -2.9629667163E+00 -2.9556687906E+00 -2.9484066870E+00 + -2.9411801890E+00 -2.9339890404E+00 -2.9268329824E+00 -2.9197117526E+00 + -2.9126250543E+00 -2.9055726836E+00 -2.8985543940E+00 -2.8915699388E+00 + -2.8846190644E+00 -2.8777014940E+00 -2.8708170314E+00 -2.8639654413E+00 + -2.8571464888E+00 -2.8503599315E+00 -2.8436055055E+00 -2.8368830243E+00 + -2.8301922637E+00 -2.8235329996E+00 -2.8169050030E+00 -2.8103080169E+00 + -2.8037418662E+00 -2.7972063374E+00 -2.7907012166E+00 -2.7842262903E+00 + -2.7777813024E+00 -2.7713660913E+00 -2.7649804532E+00 -2.7586241845E+00 + -2.7522970813E+00 -2.7459989054E+00 -2.7397294879E+00 -2.7334886419E+00 + -2.7272761732E+00 -2.7210918876E+00 -2.7149355663E+00 -2.7088070278E+00 + -2.7027061039E+00 -2.6966326094E+00 -2.6905863591E+00 -2.6845671557E+00 + -2.6785748003E+00 -2.6726091446E+00 -2.6666700119E+00 -2.6607572257E+00 + -2.6548706095E+00 -2.6490099504E+00 -2.6431751131E+00 -2.6373659318E+00 + -2.6315822382E+00 -2.6258238639E+00 -2.6200906210E+00 -2.6143823457E+00 + -2.6086988964E+00 -2.6030401127E+00 -2.5974058340E+00 -2.5917958991E+00 + -2.5862101123E+00 -2.5806483565E+00 -2.5751104788E+00 -2.5695963262E+00 + -2.5641057455E+00 -2.5586385667E+00 -2.5531946375E+00 -2.5477738314E+00 + -2.5423760028E+00 -2.5370010057E+00 -2.5316486943E+00 -2.5263188926E+00 + -2.5210114847E+00 -2.5157263372E+00 -2.5104633109E+00 -2.5052222669E+00 + -2.5000030605E+00 -2.4948055297E+00 -2.4896295712E+00 -2.4844750523E+00 + -2.4793418405E+00 -2.4742298031E+00 -2.4691387940E+00 -2.4640686757E+00 + -2.4590193426E+00 -2.4539906681E+00 -2.4489825259E+00 -2.4439947896E+00 + -2.4390273136E+00 -2.4340799794E+00 -2.4291526807E+00 -2.4242452972E+00 + -2.4193577083E+00 -2.4144897934E+00 -2.4096414103E+00 -2.4048124528E+00 + -2.4000028171E+00 -2.3952123882E+00 -2.3904410511E+00 -2.3856886909E+00 + -2.3809551705E+00 -2.3762403912E+00 -2.3715442531E+00 -2.3668666465E+00 + -2.3622074621E+00 -2.3575665900E+00 -2.3529439004E+00 -2.3483392967E+00 + -2.3437526852E+00 -2.3391839614E+00 -2.3346330208E+00 -2.3300997590E+00 + -2.3255840547E+00 -2.3210858091E+00 -2.3166049363E+00 -2.3121413368E+00 + -2.3076949109E+00 -2.3032655590E+00 -2.2988531707E+00 -2.2944576400E+00 + -2.2900788908E+00 -2.2857168282E+00 -2.2813713571E+00 -2.2770423826E+00 + -2.2727298068E+00 -2.2684335124E+00 -2.2641534347E+00 -2.2598894829E+00 + -2.2556415666E+00 -2.2514095953E+00 -2.2471934785E+00 -2.2429931038E+00 + -2.2388083992E+00 -2.2346392847E+00 -2.2304856742E+00 -2.2263474813E+00 + -2.2222246197E+00 -2.2181169931E+00 -2.2140245088E+00 -2.2099471023E+00 + -2.2058846913E+00 -2.2018371933E+00 -2.1978045263E+00 -2.1937866078E+00 + -2.1897833323E+00 -2.1857946406E+00 -2.1818204576E+00 -2.1778607050E+00 + -2.1739153043E+00 -2.1699841770E+00 -2.1660672366E+00 -2.1621643955E+00 + -2.1582755972E+00 -2.1544007668E+00 -2.1505398296E+00 -2.1466927107E+00 + -2.1428593354E+00 -2.1390396118E+00 -2.1352334757E+00 -2.1314408644E+00 + -2.1276617067E+00 -2.1238959313E+00 -2.1201434667E+00 -2.1164042418E+00 + -2.1126781618E+00 -2.1089651802E+00 -2.1052652307E+00 -2.1015782452E+00 + -2.0979041558E+00 -2.0942428944E+00 -2.0905943898E+00 -2.0869585565E+00 + -2.0833353508E+00 -2.0797247079E+00 -2.0761265629E+00 -2.0725408510E+00 + -2.0689675074E+00 -2.0654064613E+00 -2.0618576366E+00 -2.0583209894E+00 + -2.0547964579E+00 -2.0512839803E+00 -2.0477834948E+00 -2.0442949396E+00 + -2.0408182464E+00 -2.0373533437E+00 -2.0339001895E+00 -2.0304587249E+00 + -2.0270288910E+00 -2.0236106288E+00 -2.0202038794E+00 -2.0168085786E+00 + -2.0134246558E+00 -2.0100520723E+00 -2.0066907719E+00 -2.0033406985E+00 + -2.0000017959E+00 -1.9966740079E+00 + + + + 0.0000000000E+00 -8.2277987587E-02 -1.6449650094E-01 -2.4659331589E-01 + -3.2850076507E-01 -4.1014315697E-01 -4.9143436126E-01 -5.7227561145E-01 + -6.5255357242E-01 -7.3213871601E-01 -8.1088404273E-01 -8.8862418182E-01 + -9.6517489579E-01 -1.0403330086E+00 -1.1138767696E+00 -1.1855666583E+00 + -1.2551466268E+00 -1.3223457701E+00 -1.3868804065E+00 -1.4484565448E+00 + -1.5067727038E+00 -1.5615230499E+00 -1.6124008059E+00 -1.6591018874E+00 + -1.7013287065E+00 -1.7387940878E+00 -1.7712252542E+00 -1.7983677872E+00 + -1.8199895278E+00 -1.8358843512E+00 -1.8458757490E+00 -1.8498201626E+00 + -1.8476100093E+00 -1.8391763180E+00 -1.8244910913E+00 -1.8035689946E+00 + -1.7764688338E+00 -1.7432942635E+00 -1.7041941790E+00 -1.6593624450E+00 + -1.6090370910E+00 -1.5534989864E+00 -1.4930699667E+00 -1.4281104400E+00 + -1.3590165014E+00 -1.2862165869E+00 -1.2101677086E+00 -1.1313513155E+00 + -1.0502688403E+00 -9.6743710159E-01 -8.8338307362E-01 -7.9863905513E-01 + -7.1373774907E-01 -6.2920651981E-01 -5.4556280508E-01 -4.6330924845E-01 + -3.8292814427E-01 -3.0487830138E-01 -2.2958906110E-01 -1.5745833560E-01 + -8.8847539142E-02 -2.4079508545E-02 3.6563691834E-02 9.2844371601E-02 + 1.4456869600E-01 1.9158861786E-01 2.3380285278E-01 2.7115554880E-01 + 3.0363571638E-01 3.3127718718E-01 3.5415591151E-01 3.7238794759E-01 + 3.8612701355E-01 3.9556147997E-01 4.0091144918E-01 4.0242475349E-01 + 4.0037331823E-01 3.9504921005E-01 3.8676054393E-01 3.7582731451E-01 + 3.6257720433E-01 3.4734141910E-01 3.3045059692E-01 3.1223083453E-01 + 2.9299986887E-01 2.7306344758E-01 2.5271191615E-01 2.3221704416E-01 + 2.1182910699E-01 1.9177423337E-01 1.7225200095E-01 1.5343329037E-01 + 1.3546088278E-01 1.1845195585E-01 1.0249965400E-01 8.7673842851E-02 + 7.4022153762E-02 6.1571422473E-02 5.0329214779E-02 4.0284462837E-02 + 3.1410783526E-02 2.3667878040E-02 1.7003522416E-02 1.1355567187E-02 + 6.6538808501E-03 2.8220678737E-03 -2.2001240793E-04 -2.5547866842E-03 + -4.2654366871E-03 -5.4349451843E-03 -6.1429431867E-03 -6.4660691080E-03 + -6.4767064284E-03 -6.2432624449E-03 -5.8262992394E-03 -5.2807905609E-03 + -4.6556441299E-03 -3.9940297562E-03 -3.3299352117E-03 -2.6921631841E-03 + -2.1041805481E-03 -1.5819270303E-03 -1.1356467997E-03 -7.7141771203E-04 + -4.9002008278E-04 -2.8685599057E-04 -1.5440700844E-04 -8.1295680504E-05 + -5.2958831332E-05 -4.9024979272E-05 -2.2654023957E-05 2.0802206378E-06 + 1.6220072646E-06 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 + + + 0.0000000000E+00 -1.1723087215E-02 -2.2970588285E-02 -3.3277762775E-02 + -4.2201369170E-02 -4.9329936250E-02 -5.4293469599E-02 -5.6772419538E-02 + -5.6505748973E-02 -5.3297954463E-02 -4.7024911330E-02 -3.7638432778E-02 + -2.5169454710E-02 -9.7297804400E-03 8.4876559486E-03 2.9210025055E-02 + 5.2087327705E-02 7.6696576823E-02 1.0254737811E-01 1.2908882978E-01 + 1.5571763119E-01 1.8178728239E-01 2.0661822255E-01 2.2950875795E-01 + 2.4974659019E-01 2.6662075364E-01 2.7943382524E-01 2.8751410085E-01 + 2.9022762150E-01 2.8698983512E-01 2.7727667838E-01 2.6063490065E-01 + 2.3669144662E-01 2.0516162976E-01 1.6585646477E-01 1.1868792319E-01 + 6.3673539750E-02 9.3865644130E-04 -6.9282296205E-02 -1.4664653237E-01 + -2.3070525508E-01 -3.2090755014E-01 -4.1660590836E-01 -5.1706326588E-01 + -6.2146146368E-01 -7.2891100660E-01 -8.3846198150E-01 -9.4911597183E-01 + -1.0598387764E+00 -1.1695734189E+00 -1.2772547958E+00 -1.3818230208E+00 + -1.4822368409E+00 -1.5774891053E+00 -1.6666187728E+00 -1.7487234696E+00 + -1.8229735575E+00 -1.8886194365E+00 -1.9450060422E+00 -1.9915764523E+00 + -2.0278831780E+00 -2.0535914046E+00 -2.0684822557E+00 -2.0724589319E+00 + -2.0655426479E+00 -2.0478740211E+00 -2.0197115502E+00 -1.9814248238E+00 + -1.9334892505E+00 -1.8764808008E+00 -1.8110656211E+00 -1.7379906968E+00 + -1.6580733899E+00 -1.5721902388E+00 -1.4812642140E+00 -1.3862522622E+00 + -1.2881324457E+00 -1.1878908963E+00 -1.0865088556E+00 -9.8494996663E-01 + -8.8414798922E-01 -7.8499509134E-01 -6.8833085835E-01 -5.9493213952E-01 + -5.0550383294E-01 -4.2067068746E-01 -3.4097017799E-01 -2.6684648767E-01 + -1.9864560686E-01 -1.3661153627E-01 -8.0883449121E-02 -3.1493861467E-02 + 1.1620322833E-02 4.8599589644E-02 7.9650226738E-02 1.0503788587E-01 + 1.2508039801E-01 1.4013995079E-01 1.5061541504E-01 1.5693366067E-01 + 1.5954043230E-01 1.5889246200E-01 1.5544945597E-01 1.4966651822E-01 + 1.4199014613E-01 1.3284299597E-01 1.2262519169E-01 1.1170778401E-01 + 1.0042928223E-01 8.9095504256E-02 7.7963775928E-02 6.7255547029E-02 + 5.7152141457E-02 4.7799764163E-02 3.9294804857E-02 3.1701123437E-02 + 2.5050278343E-02 1.9344675342E-02 1.4551822257E-02 1.0621676019E-02 + 7.4866418173E-03 5.0616443312E-03 3.2542385947E-03 1.9673338834E-03 + 1.1012904675E-03 5.6303386455E-04 2.6418408232E-04 1.2416036016E-04 + 8.3638494781E-05 8.3445532246E-05 3.9712888830E-05 -3.5905440177E-06 + -2.7996494097E-06 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 + + + 0.0000000000E+00 3.5860269827E-03 1.4317078272E-02 3.2112256128E-02 + 5.6837367274E-02 8.8305873299E-02 1.2628021312E-01 1.7047348950E-01 + 2.2055150919E-01 2.7613516420E-01 3.3680313934E-01 4.0209492899E-01 + 4.7151414403E-01 5.4453208758E-01 6.2059157645E-01 6.9911098297E-01 + 7.7948847033E-01 8.6110639245E-01 9.4333582837E-01 1.0255412195E+00 + 1.1070850756E+00 1.1873327175E+00 1.2656570189E+00 1.3414431144E+00 + 1.4140930355E+00 1.4830302391E+00 1.5477039940E+00 1.6075935868E+00 + 1.6622123152E+00 1.7111112337E+00 1.7538826190E+00 1.7901631245E+00 + 1.8196365952E+00 1.8420365276E+00 1.8571481070E+00 1.8648098949E+00 + 1.8649150077E+00 1.8574119504E+00 1.8423049075E+00 1.8196536236E+00 + 1.7895728317E+00 1.7522312003E+00 1.7078498355E+00 1.6567003418E+00 + 1.5991024567E+00 1.5354212770E+00 1.4660641009E+00 1.3914769134E+00 + 1.3121405542E+00 1.2285667331E+00 1.1412932403E+00 1.0508797039E+00 + 9.5790298913E-01 8.6295169350E-01 7.6662172078E-01 6.6951129918E-01 + 5.7221537424E-01 4.7532181715E-01 3.7940524579E-01 2.8502383408E-01 + 1.9271369849E-01 1.0298539150E-01 1.6320224853E-02 -6.6834318537E-02 + -1.4606648327E-01 -2.2100368547E-01 -2.9131520005E-01 -3.5671342275E-01 + -4.1695549560E-01 -4.7184486654E-01 -5.2123135255E-01 -5.6501133337E-01 + -6.0312746230E-01 -6.3556796384E-01 -6.6236527842E-01 -6.8359449970E-01 + -6.9937142322E-01 -7.0985023488E-01 -7.1522090252E-01 -7.1570630926E-01 + -7.1155917402E-01 -7.0305880711E-01 -6.9050775058E-01 -6.7422835456E-01 + -6.5455934146E-01 -6.3185241011E-01 -6.0646893131E-01 -5.7877678564E-01 + -5.4914739239E-01 -5.1795297687E-01 -4.8556415192E-01 -4.5234782509E-01 + -4.1866194064E-01 -3.8484854594E-01 -3.5122924483E-01 -3.1810273720E-01 + -2.8574272301E-01 -2.5439648427E-01 -2.2428377777E-01 -1.9559309794E-01 + -1.6848457254E-01 -1.4308867914E-01 -1.1950650654E-01 -9.7810361217E-02 + -7.8045864567E-02 -6.0228944123E-02 -4.4352023434E-02 -3.0384350338E-02 + -1.8273960617E-02 -7.9495883994E-03 6.7759973479E-04 7.7099198058E-03 + 1.3261526160E-02 1.7457218324E-02 2.0427124578E-02 2.2305646179E-02 + 2.3229681315E-02 2.3338002873E-02 2.2762351834E-02 2.1631893993E-02 + 2.0072411241E-02 1.8198596607E-02 1.6115058374E-02 1.3919754929E-02 + 1.1698898123E-02 9.5228516845E-03 7.4546618226E-03 5.5452981103E-03 + 3.8288793415E-03 2.3331720374E-03 1.0736899984E-03 5.2926998136E-05 + -7.3149996906E-04 -1.2929678601E-03 -1.6511600028E-03 -1.8297965622E-03 + -1.8585360541E-03 -1.7678438403E-03 -1.5911002682E-03 -1.3586955246E-03 + -1.1019690505E-03 -8.4702839256E-04 -6.1497715279E-04 -4.2541468309E-04 + -2.8402093044E-04 -1.9725198792E-04 -1.6029137555E-04 -1.5177315345E-04 + -8.9838576118E-05 -5.4771430827E-06 9.6147639048E-06 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 + + + 0.0000000000E+00 9.2893242255E-04 3.7019764676E-03 8.2779769445E-03 + 1.4588689808E-02 2.2539302945E-02 3.2009163013E-02 4.2852705981E-02 + 5.4900588274E-02 6.7961014587E-02 8.1821257513E-02 9.6249363136E-02 + 1.1099603565E-01 1.2579669284E-01 1.4037368313E-01 1.5443865322E-01 + 1.6769505435E-01 1.7984077312E-01 1.9057087191E-01 1.9958042202E-01 + 2.0656741042E-01 2.1123570101E-01 2.1329802783E-01 2.1247899806E-01 + 2.0851807950E-01 2.0117254726E-01 1.9022036400E-01 1.7546296384E-01 + 1.5672791414E-01 1.3387142592E-01 1.0678068413E-01 7.5375969726E-02 + 3.9612545899E-02 -5.1771162367E-04 -4.4984990254E-02 -9.3720492346E-02 + -1.4661576728E-01 -2.0352233418E-01 -2.6425172921E-01 -3.2857590175E-01 + -3.9622799242E-01 -4.6690352048E-01 -5.4026196118E-01 -6.1592871460E-01 + -6.9349745874E-01 -7.7253287529E-01 -8.5257373131E-01 -9.3313629426E-01 + -1.0137180499E+00 -1.0938015836E+00 -1.1728591565E+00 -1.2503568716E+00 + -1.3257591460E+00 -1.3985339592E+00 -1.4681572088E+00 -1.5341175221E+00 + -1.5959215886E+00 -1.6530979289E+00 -1.7052026499E+00 -1.7518226198E+00 + -1.7925806287E+00 -1.8271386946E+00 -1.8552014319E+00 -1.8765200508E+00 + -1.8908940379E+00 -1.8981739659E+00 -1.8982634918E+00 -1.8911201167E+00 + -1.8767560905E+00 -1.8552388890E+00 -1.8266905450E+00 -1.7912868237E+00 + -1.7492558153E+00 -1.7008761570E+00 -1.6464740899E+00 -1.5864208426E+00 + -1.5211291980E+00 -1.4510496961E+00 -1.3766664971E+00 -1.2984929459E+00 + -1.2170668968E+00 -1.1329458601E+00 -1.0467020356E+00 -9.5891730044E-01 + -8.7017821889E-01 -7.8107114433E-01 -6.9217748077E-01 -6.0406917196E-01 + -5.1730448344E-01 -4.3242413992E-01 -3.4994793756E-01 -2.7037179974E-01 + -1.9415879235E-01 -1.2172780433E-01 -5.3447524144E-02 1.0365478214E-02 + 6.9448141778E-02 1.2359143475E-01 1.7264050244E-01 2.1649715017E-01 + 2.5511519340E-01 2.8850025641E-01 3.1670773256E-01 3.3984027408E-01 + 3.5804463559E-01 3.7150996533E-01 3.8046133188E-01 3.8515667437E-01 + 3.8588276317E-01 3.8295243350E-01 3.7669486668E-01 3.6745451357E-01 + 3.5558583975E-01 3.4145309072E-01 3.2541361978E-01 3.0782259726E-01 + 2.8902885306E-01 2.6937446596E-01 2.4917322584E-01 2.2872577817E-01 + 2.0831749242E-01 1.8820101658E-01 1.6860103788E-01 1.4972254242E-01 + 1.3173967350E-01 1.1478834281E-01 9.8985070983E-02 8.4416837992E-02 + 7.1132442003E-02 5.9164183104E-02 4.8515945607E-02 3.9162908641E-02 + 3.1067102133E-02 2.4166226359E-02 1.8383581049E-02 1.3631066681E-02 + 9.8082692597E-03 6.8108066814E-03 4.5261412594E-03 2.8479629339E-03 + 1.6647468801E-03 8.7544647586E-04 3.8748703362E-04 1.0892680591E-04 + -2.3425222903E-05 -7.7922079727E-05 -9.4002294959E-05 -9.5906384375E-05 + -5.6988379155E-05 -3.5463910332E-06 5.9608986436E-06 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 + + + 1.9514303897E+01 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 2.7522534413E+00 0.0000000000E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 -9.6137176497E+00 0.0000000000E+00 + 0.0000000000E+00 0.0000000000E+00 0.0000000000E+00 -3.2324794045E+00 + + + + + + 0.0000000000E+00 2.4555322044E-04 9.9435596078E-04 2.2826802809E-03 + 4.1704577663E-03 6.7405039734E-03 1.0097446971E-02 1.4366374033E-02 + 1.9691214178E-02 2.6232877622E-02 3.4167176269E-02 4.3682552029E-02 + 5.4977642082E-02 6.8258712011E-02 8.3736989112E-02 1.0162592925E-01 + 1.2213845080E-01 1.4548416964E-01 1.7186666804E-01 2.0148082992E-01 + 2.3451027351E-01 2.7112491013E-01 3.1147865648E-01 3.5570732483E-01 + 4.0392671304E-01 4.5623091264E-01 5.1269085328E-01 5.7335309214E-01 + 6.3823886033E-01 7.0734337238E-01 7.8063540062E-01 8.5805711439E-01 + 9.3952417996E-01 1.0249261017E+00 1.1141268534E+00 1.2069656628E+00 + 1.3032581166E+00 1.4027973581E+00 1.5053555697E+00 1.6106855669E+00 + 1.7185225365E+00 1.8285859201E+00 1.9405813920E+00 2.0542029191E+00 + 2.1691348784E+00 2.2850542133E+00 2.4016326049E+00 2.5185386399E+00 + 2.6354399503E+00 2.7520052604E+00 2.8679065939E+00 2.9828210875E+00 + 3.0964328328E+00 3.2084348565E+00 3.3185305939E+00 3.4264354515E+00 + 3.5318783577E+00 3.6346027795E+00 3.7343681356E+00 3.8309505035E+00 + 3.9241436467E+00 4.0137595888E+00 4.0996291450E+00 4.1816023622E+00 + 4.2595486912E+00 4.3333571276E+00 4.4029361120E+00 4.4682134089E+00 + 4.5291358858E+00 4.5856689029E+00 4.6377959244E+00 4.6855179084E+00 + 4.7288525836E+00 4.7678337886E+00 4.8025102209E+00 4.8329448489E+00 + 4.8592138549E+00 4.8814055976E+00 4.8996195505E+00 4.9139652152E+00 + 4.9245610181E+00 4.9315332006E+00 4.9350147101E+00 4.9351441007E+00 + 4.9320644514E+00 4.9259223085E+00 4.9168666605E+00 4.9050479496E+00 + 4.8906171284E+00 4.8737247647E+00 4.8545202011E+00 4.8331507724E+00 + 4.8097610853E+00 4.7844923629E+00 4.7574818564E+00 4.7288623255E+00 + 4.6987615887E+00 4.6673022280E+00 4.6346013382E+00 4.6007695137E+00 + 4.5659116073E+00 4.5301262966E+00 4.4935060361E+00 4.4561370652E+00 + 4.4180998488E+00 4.3794678786E+00 4.3403092049E+00 4.3006862196E+00 + 4.2606559084E+00 4.2202701844E+00 4.1795755629E+00 4.1386143513E+00 + 4.0974246608E+00 4.0560406954E+00 4.0144930190E+00 3.9728092235E+00 + 3.9310140868E+00 3.8891296584E+00 3.8471763585E+00 3.8051727118E+00 + 3.7631353587E+00 3.7210801524E+00 3.6790222306E+00 3.6369754752E+00 + 3.5949532922E+00 3.5529695496E+00 3.5110371051E+00 3.4691686011E+00 + 3.4273777892E+00 3.3856773650E+00 3.3440802075E+00 3.3026002179E+00 + 3.2612500462E+00 3.2200431162E+00 3.1789931977E+00 3.1381126416E+00 + 3.0974153228E+00 3.0569141416E+00 3.0166213097E+00 2.9765501384E+00 + 2.9367121016E+00 2.8971193603E+00 2.8577833885E+00 2.8187144722E+00 + 2.7799237680E+00 2.7414203117E+00 2.7032138975E+00 2.6653129770E+00 + 2.6277254184E+00 2.5904592077E+00 2.5535203424E+00 2.5169161760E+00 + 2.4806515332E+00 2.4447325241E+00 2.4091633992E+00 2.3739487914E+00 + 2.3390925610E+00 2.3045979624E+00 2.2704685078E+00 2.2367061977E+00 + 2.2033142099E+00 2.1702934279E+00 2.1376466921E+00 2.1053739087E+00 + 2.0734775689E+00 2.0419567389E+00 2.0108135020E+00 1.9800463428E+00 + 1.9496568192E+00 1.9196429197E+00 1.8900057747E+00 1.8607428608E+00 + 1.8318549701E+00 1.8033391361E+00 1.7751957603E+00 1.7474216534E+00 + 1.7200166764E+00 1.6929775891E+00 1.6663036438E+00 1.6399916950E+00 + 1.6140403080E+00 1.5884465799E+00 1.5632083065E+00 1.5383229695E+00 + 1.5137875184E+00 1.4895999441E+00 1.4657562937E+00 1.4422551560E+00 + 1.4190916630E+00 1.3962646344E+00 1.3737695287E+00 1.3516041505E+00 + 1.3297648393E+00 1.3082482527E+00 1.2870517468E+00 1.2661707761E+00 + 1.2456035241E+00 1.2253449792E+00 1.2053930652E+00 1.1857436665E+00 + 1.1663933299E+00 1.1473392986E+00 1.1285766929E+00 1.1101036434E+00 + 1.0919153412E+00 1.0740090637E+00 1.0563813566E+00 1.0390278824E+00 + 1.0219464881E+00 1.0051322370E+00 9.8858273586E-01 9.7229433753E-01 + 9.5626288454E-01 9.4048618717E-01 9.2495945205E-01 9.0968023104E-01 + 8.9464515722E-01 8.7984988668E-01 8.6529242529E-01 8.5096836827E-01 + 8.3687483992E-01 8.2300917666E-01 8.0936653060E-01 7.9594527075E-01 + 7.8274162686E-01 7.6975194584E-01 7.5697415488E-01 7.4440404132E-01 + 7.3203906033E-01 7.1987668706E-01 7.0791241321E-01 6.9614463944E-01 + 6.8457015681E-01 6.7318513862E-01 6.6198789975E-01 6.5097491802E-01 + 6.4014312669E-01 6.2949060514E-01 6.1901366286E-01 6.0870987684E-01 + 5.9857713213E-01 5.8861165082E-01 5.7881152804E-01 5.6917450923E-01 + 5.5969679766E-01 5.5037688431E-01 5.4121243428E-01 5.3219968832E-01 + 5.2333742019E-01 5.1462325731E-01 5.0605357159E-01 4.9762726943E-01 + 4.8934201433E-01 4.8119433956E-01 4.7318319951E-01 4.6530638099E-01 + 4.5756049431E-01 4.4994457445E-01 4.4245651371E-01 4.3509310405E-01 + 4.2785330791E-01 4.2073518522E-01 4.1373575057E-01 4.0685380826E-01 + 4.0008762412E-01 3.9343446965E-01 3.8689291717E-01 3.8046146824E-01 + 3.7413768570E-01 3.6791984300E-01 3.6180669955E-01 3.5579614205E-01 + 3.4988609008E-01 3.4407557281E-01 3.3836282768E-01 3.3274538488E-01 + 3.2722254123E-01 3.2179272713E-01 3.1645359987E-01 3.1120418021E-01 + 3.0604318897E-01 3.0096867591E-01 2.9597910956E-01 2.9107357482E-01 + 2.8625054370E-01 2.8150791508E-01 2.7684511501E-01 2.7226081425E-01 + 2.6775306980E-01 2.6332090390E-01 2.5896332932E-01 2.5467885571E-01 + 2.5046582167E-01 2.4632363995E-01 2.4225111660E-01 2.3824645700E-01 + 2.3430890125E-01 2.3043753190E-01 2.2663103075E-01 2.2288787866E-01 + 2.1920758650E-01 2.1558909889E-01 2.1203087347E-01 2.0853209698E-01 + 2.0509203703E-01 2.0170965015E-01 1.9838332245E-01 1.9511274762E-01 + 1.9189700637E-01 1.8873489405E-01 1.8562532983E-01 1.8256784638E-01 + 1.7956156317E-01 1.7660516721E-01 1.7369802148E-01 1.7083951993E-01 + 1.6802882312E-01 1.6526455844E-01 1.6254643724E-01 1.5987374760E-01 + 1.5724562162E-01 1.5466088112E-01 1.5211928277E-01 1.4962011532E-01 + 1.4716247731E-01 1.4474543496E-01 1.4236869347E-01 1.4003158209E-01 + 1.3773319599E-01 1.3547277982E-01 1.3325001085E-01 1.3106425897E-01 + 1.2891464189E-01 1.2680052175E-01 1.2472157135E-01 1.2267720085E-01 + 1.2066657246E-01 1.1868911133E-01 1.1674450739E-01 1.1483221045E-01 + 1.1295144579E-01 1.1110165375E-01 1.0928256040E-01 1.0749365423E-01 + 1.0573423961E-01 1.0400373057E-01 1.0230190533E-01 1.0062828986E-01 + 9.8982281391E-02 9.7363232570E-02 9.5770986299E-02 9.4205104640E-02 + 9.2665089253E-02 9.1150203181E-02 8.9660362635E-02 8.8195164240E-02 + 8.6754184314E-02 8.5336692055E-02 8.3942565008E-02 8.2571471377E-02 + 8.1223022254E-02 7.9896618189E-02 7.8591960933E-02 7.7308833712E-02 + 7.6046880544E-02 7.4805642086E-02 7.3584629176E-02 7.2383740506E-02 + 7.1202651131E-02 7.0041020775E-02 6.8898242541E-02 6.7774247481E-02 + 6.6668765461E-02 6.5581486791E-02 6.4511958509E-02 6.3459869402E-02 + 6.2425088961E-02 6.1407336085E-02 6.0406316994E-02 5.9421479885E-02 + 5.8452822608E-02 5.7500090972E-02 5.6563019041E-02 5.5641218020E-02 + 5.4734411156E-02 5.3842496378E-02 5.2965233586E-02 5.2102372240E-02 + 5.1253457601E-02 5.0418435755E-02 4.9597119611E-02 4.8789283548E-02 + 4.7994643509E-02 4.7212852717E-02 4.6443878327E-02 4.5687517686E-02 + 4.4943559586E-02 4.4211678082E-02 4.3491681375E-02 4.2783483184E-02 + 4.2086894267E-02 4.1401717619E-02 4.0727603994E-02 4.0064476856E-02 + 3.9412211446E-02 3.8770631668E-02 3.8139554396E-02 3.7518622579E-02 + 3.6907839114E-02 3.6307055480E-02 3.5716108368E-02 3.5134814385E-02 + 3.4562862225E-02 3.4000262270E-02 3.3446869273E-02 3.2902532276E-02 + 3.2367070616E-02 3.1840217984E-02 3.1321976903E-02 3.0812213425E-02 + 3.0310788441E-02 2.9817533657E-02 2.9332204905E-02 2.8854805910E-02 + 2.8385213523E-02 2.7923299942E-02 2.7468917225E-02 2.7021823958E-02 + 2.6582032748E-02 2.6149430718E-02 2.5723900801E-02 2.5305321709E-02 + 2.4893439431E-02 2.4488280997E-02 2.4089743440E-02 2.3697719832E-02 + 2.3312099450E-02 2.2932666819E-02 2.2559404233E-02 2.2192239239E-02 + 2.1831074449E-02 2.1475809062E-02 2.1126270265E-02 2.0782385275E-02 + 2.0444115841E-02 2.0111373508E-02 1.9784066758E-02 1.9462068697E-02 + 1.9145243997E-02 1.8833590598E-02 1.8527028380E-02 1.8225474479E-02 + 1.7928843269E-02 1.7636952905E-02 1.7349817563E-02 1.7067371509E-02 + 1.6789539913E-02 1.6516245476E-02 1.6247359808E-02 1.5982811518E-02 + 1.5722581767E-02 1.5466603166E-02 1.5214806114E-02 1.4967116953E-02 + 1.4723378333E-02 1.4483616032E-02 1.4247769523E-02 1.4015776305E-02 + 1.3787571887E-02 1.3563051106E-02 1.3342146415E-02 1.3124847757E-02 + 1.2911099151E-02 1.2700842848E-02 1.2494019314E-02 1.2290502671E-02 + 1.2090293497E-02 1.1893354059E-02 1.1699632778E-02 1.1509076483E-02 + 1.1321619331E-02 1.1137157247E-02 1.0955705606E-02 1.0777218459E-02 + 1.0601648447E-02 1.0428946789E-02 1.0259036651E-02 1.0091856576E-02 + 9.9274061406E-03 9.7656432701E-03 9.6065246281E-03 9.4500056081E-03 + 9.2960048318E-03 9.1444890831E-03 8.9954481332E-03 8.8488435842E-03 + 8.7046359123E-03 8.5627844608E-03 8.4232085626E-03 8.2858909371E-03 + 8.1508168888E-03 8.0179514903E-03 7.8872588105E-03 7.7587019092E-03 + 7.6322050317E-03 7.5077566051E-03 7.3853419925E-03 7.2649295244E-03 + 7.1464866384E-03 7.0299798746E-03 6.9153417240E-03 6.8025579795E-03 + 6.6916177587E-03 6.5824924357E-03 6.4751525918E-03 6.3695680107E-03 + 6.2656820661E-03 6.1634712357E-03 6.0629312937E-03 5.9640364449E-03 + 5.8667601907E-03 5.7710753252E-03 5.6769381537E-03 5.5843106621E-03 + 5.4931974191E-03 5.4035752507E-03 5.3154203599E-03 5.2287083230E-03 + 5.1434098717E-03 5.0594687788E-03 4.9768997803E-03 4.8956821190E-03 + 4.8157944869E-03 4.7372150220E-03 4.6599213051E-03 4.5838621307E-03 + 4.5090375337E-03 4.4354374536E-03 4.3630428668E-03 4.2918342606E-03 + 4.2217916304E-03 4.1528822007E-03 4.0850770685E-03 4.0183813155E-03 + 3.9527780072E-03 3.8882497776E-03 3.8247788275E-03 3.7623469216E-03 + 3.7009082742E-03 3.6404704082E-03 3.5810223207E-03 3.5225486012E-03 + 3.4650334570E-03 3.4084607124E-03 3.3528049178E-03 3.2980391006E-03 + 3.2441697846E-03 3.1911833332E-03 3.1390657742E-03 3.0878027987E-03 + 3.0373797587E-03 2.9877641034E-03 2.9389511875E-03 2.8909379581E-03 + 2.8437120887E-03 2.7972609573E-03 2.7515716446E-03 2.7066309326E-03 + 2.6624026263E-03 2.6188968441E-03 2.5761042605E-03 2.5340137731E-03 + 2.4926140192E-03 2.4518933742E-03 2.4118369488E-03 2.3724166399E-03 + 2.3336420418E-03 2.2955034166E-03 2.2579907985E-03 2.2210939931E-03 + 2.1848025759E-03 2.1491007974E-03 2.1139679998E-03 2.0794109580E-03 + 2.0454209566E-03 2.0119890803E-03 1.9791062132E-03 1.9467630375E-03 + 1.9149447857E-03 1.8836339902E-03 1.8528364927E-03 1.8225445192E-03 + 1.7927501202E-03 1.7634451708E-03 1.7346213692E-03 1.7062663468E-03 + 1.6783624620E-03 1.6509161204E-03 1.6239204100E-03 1.5973682657E-03 + 1.5712524689E-03 1.5455656462E-03 + + diff --git a/ABACUS.develop/examples/H2O-deepks-pw/O_gga_7au_60Ry_2s2p1d.orb b/ABACUS.develop/examples/H2O-deepks-pw/O_gga_7au_60Ry_2s2p1d.orb new file mode 100644 index 0000000000..d36d9dc128 --- /dev/null +++ b/ABACUS.develop/examples/H2O-deepks-pw/O_gga_7au_60Ry_2s2p1d.orb @@ -0,0 +1,903 @@ +--------------------------------------------------------------------------- +Element O +Energy Cutoff(Ry) 60 +Radius Cutoff(a.u.) 7 +Lmax 2 +Number of Sorbital--> 2 +Number of Porbital--> 2 +Number of Dorbital--> 1 +--------------------------------------------------------------------------- +SUMMARY END + +Mesh 701 +dr 0.01 + Type L N + 0 0 0 + 1.208504975904e+00 1.208605373194e+00 1.208906194767e+00 1.209406330839e+00 + 1.210103935461e+00 1.210996432051e+00 1.212080521101e+00 1.213352190052e+00 + 1.214806725286e+00 1.216438726214e+00 1.218242121389e+00 1.220210186617e+00 + 1.222335564979e+00 1.224610288719e+00 1.227025802911e+00 1.229572990826e+00 + 1.232242200930e+00 1.235023275402e+00 1.237905580090e+00 1.240878035806e+00 + 1.243929150853e+00 1.247047054671e+00 1.250219532508e+00 1.253434060986e+00 + 1.256677844454e+00 1.259937852003e+00 1.263200855037e+00 1.266453465260e+00 + 1.269682172967e+00 1.272873385522e+00 1.276013465884e+00 1.279088771074e+00 + 1.282085690452e+00 1.284990683687e+00 1.287790318310e+00 1.290471306712e+00 + 1.293020542503e+00 1.295425136090e+00 1.297672449397e+00 1.299750129595e+00 + 1.301646141768e+00 1.303348800401e+00 1.304846799603e+00 1.306129241995e+00 + 1.307185666154e+00 1.308006072568e+00 1.308580948012e+00 1.308901288291e+00 + 1.308958619289e+00 1.308745016279e+00 1.308253121443e+00 1.307476159565e+00 + 1.306407951870e+00 1.305042927985e+00 1.303376135990e+00 1.301403250569e+00 + 1.299120579241e+00 1.296525066675e+00 1.293614297106e+00 1.290386494856e+00 + 1.286840522984e+00 1.282975880102e+00 1.278792695375e+00 1.274291721751e+00 + 1.269474327479e+00 1.264342485932e+00 1.258898763833e+00 1.253146307905e+00 + 1.247088830035e+00 1.240730591016e+00 1.234076382930e+00 1.227131510258e+00 + 1.219901769801e+00 1.212393429485e+00 1.204613206140e+00 1.196568242341e+00 + 1.188266082409e+00 1.179714647648e+00 1.170922210923e+00 1.161897370672e+00 + 1.152649024441e+00 1.143186342040e+00 1.133518738417e+00 1.123655846335e+00 + 1.113607488958e+00 1.103383652425e+00 1.092994458510e+00 1.082450137452e+00 + 1.071761001046e+00 1.060937416076e+00 1.049989778166e+00 1.038928486134e+00 + 1.027763916923e+00 1.016506401179e+00 1.005166199535e+00 9.937534796822e-01 + 9.822782942738e-01 9.707505597186e-01 9.591800359220e-01 9.475763070136e-01 + 9.359487631082e-01 9.243065831335e-01 9.126587187607e-01 9.010138794629e-01 + 8.893805187255e-01 8.777668214270e-01 8.661806924029e-01 8.546297462024e-01 + 8.431212980407e-01 8.316623559477e-01 8.202596141073e-01 8.089194473785e-01 + 7.976479069842e-01 7.864507173504e-01 7.753332740738e-01 7.643006429933e-01 + 7.533575603347e-01 7.425084338983e-01 7.317573452518e-01 7.211080528917e-01 + 7.105639963300e-01 7.001283010647e-01 6.898037843852e-01 6.795929619667e-01 + 6.694980552026e-01 6.595209992230e-01 6.496634515475e-01 6.399268013169e-01 + 6.303121790507e-01 6.208204668741e-01 6.114523091586e-01 6.022081235218e-01 + 5.930881121293e-01 5.840922732453e-01 5.752204129759e-01 5.664721571522e-01 + 5.578469633004e-01 5.493441326481e-01 5.409628221155e-01 5.327020562452e-01 + 5.245607390221e-01 5.165376655400e-01 5.086315334724e-01 5.008409543065e-01 + 4.931644643036e-01 4.856005351488e-01 4.781475842592e-01 4.708039847180e-01 + 4.635680748085e-01 4.564381671224e-01 4.494125572203e-01 4.424895318251e-01 + 4.356673765315e-01 4.289443830186e-01 4.223188557530e-01 4.157891181767e-01 + 4.093535183714e-01 4.030104341987e-01 3.967582779147e-01 3.905955002616e-01 + 3.845205940408e-01 3.785320971754e-01 3.726285952702e-01 3.668087236816e-01 + 3.610711691103e-01 3.554146707323e-01 3.498380208855e-01 3.443400653306e-01 + 3.389197031063e-01 3.335758859998e-01 3.283076176573e-01 3.231139523559e-01 + 3.179939934625e-01 3.129468916064e-01 3.079718425888e-01 3.030680850586e-01 + 2.982348979789e-01 2.934715979121e-01 2.887775361507e-01 2.841520957194e-01 + 2.795946882761e-01 2.751047509369e-01 2.706817430510e-01 2.663251429500e-01 + 2.620344446963e-01 2.578091548528e-01 2.536487892964e-01 2.495528700973e-01 + 2.455209224821e-01 2.415524719021e-01 2.376470412212e-01 2.338041480425e-01 + 2.300233021857e-01 2.263040033303e-01 2.226457388361e-01 2.190479817496e-01 + 2.155101890086e-01 2.120317998477e-01 2.086122344148e-01 2.052508925998e-01 + 2.019471530796e-01 1.987003725803e-01 1.955098853571e-01 1.923750028889e-01 + 1.892950137867e-01 1.862691839096e-01 1.832967566851e-01 1.803769536250e-01 + 1.775089750316e-01 1.746920008827e-01 1.719251918891e-01 1.692076907110e-01 + 1.665386233243e-01 1.639171005238e-01 1.613422195507e-01 1.588130658323e-01 + 1.563287148189e-01 1.538882339058e-01 1.514906844251e-01 1.491351236934e-01 + 1.468206071016e-01 1.445461902321e-01 1.423109309892e-01 1.401138917296e-01 + 1.379541413781e-01 1.358307575162e-01 1.337428284304e-01 1.316894551079e-01 + 1.296697531672e-01 1.276828547140e-01 1.257279101100e-01 1.238040896459e-01 + 1.219105851096e-01 1.200466112407e-01 1.182114070645e-01 1.164042370988e-01 + 1.146243924273e-01 1.128711916364e-01 1.111439816100e-01 1.094421381794e-01 + 1.077650666286e-01 1.061122020509e-01 1.044830095586e-01 1.028769843465e-01 + 1.012936516098e-01 9.973256632027e-02 9.819331286249e-02 9.667550453586e-02 + 9.517878292592e-02 9.370281715131e-02 9.224730299217e-02 9.081196190712e-02 + 8.939653994588e-02 8.800080656572e-02 8.662455335980e-02 8.526759270643e-02 + 8.392975634798e-02 8.261089390905e-02 8.131087136337e-02 8.002956945904e-02 + 7.876688211206e-02 7.752271477787e-02 7.629698281079e-02 7.508960982105e-02 + 7.390052603893e-02 7.272966669554e-02 7.157697042927e-02 7.044237772677e-02 + 6.932582940704e-02 6.822726515656e-02 6.714662212340e-02 6.608383357718e-02 + 6.503882764188e-02 6.401152610749e-02 6.300184332609e-02 6.200968519741e-02 + 6.103494824820e-02 6.007751880923e-02 5.913727229295e-02 5.821407257435e-02 + 5.730777147672e-02 5.641820836358e-02 5.554520983723e-02 5.468858954372e-02 + 5.384814808351e-02 5.302367302641e-02 5.221493902883e-02 5.142170805062e-02 + 5.064372966853e-02 4.988074148247e-02 4.913246961043e-02 4.839862926751e-02 + 4.767892542381e-02 4.697305353581e-02 4.628070034542e-02 4.560154474050e-02 + 4.493525867035e-02 4.428150810968e-02 4.363995406407e-02 4.301025360991e-02 + 4.239206096181e-02 4.178502856019e-02 4.118880817199e-02 4.060305199725e-02 + 4.002741377451e-02 3.946154987805e-02 3.890512040018e-02 3.835779021189e-02 + 3.781922999550e-02 3.728911724314e-02 3.676713721524e-02 3.625298385349e-02 + 3.574636064312e-02 3.524698141971e-02 3.475457111613e-02 3.426886644573e-02 + 3.378961651814e-02 3.331658338482e-02 3.284954251156e-02 3.238828317602e-02 + 3.193260878856e-02 3.148233713535e-02 3.103730054297e-02 3.059734596456e-02 + 3.016233498765e-02 2.973214376455e-02 2.930666286665e-02 2.888579706416e-02 + 2.846946503363e-02 2.805759899565e-02 2.765014428579e-02 2.724705886194e-02 + 2.684831275201e-02 2.645388744558e-02 2.606377523410e-02 2.567797850399e-02 + 2.529650898744e-02 2.491938697590e-02 2.454664050137e-02 2.417830449066e-02 + 2.381441989815e-02 2.345503282229e-02 2.310019361138e-02 2.274995596414e-02 + 2.240437603029e-02 2.206351151675e-02 2.172742080447e-02 2.139616208118e-02 + 2.106979249494e-02 2.074836733334e-02 2.043193923274e-02 2.012055742218e-02 + 1.981426700573e-02 1.951310828723e-02 1.921711614086e-02 1.892631943068e-02 + 1.864074048204e-02 1.836039460721e-02 1.808528968752e-02 1.781542581363e-02 + 1.755079498530e-02 1.729138087183e-02 1.703715863360e-02 1.678809480501e-02 + 1.654414723879e-02 1.630526511103e-02 1.607138898614e-02 1.584245094054e-02 + 1.561837474341e-02 1.539907609281e-02 1.518446290469e-02 1.497443565255e-02 + 1.476888775479e-02 1.456770600680e-02 1.437077105450e-02 1.417795790576e-02 + 1.398913647618e-02 1.380417216524e-02 1.362292645883e-02 1.344525755419e-02 + 1.327102100294e-02 1.310007036795e-02 1.293225788984e-02 1.276743515871e-02 + 1.260545378691e-02 1.244616607850e-02 1.228942569134e-02 1.213508828758e-02 + 1.198301216878e-02 1.183305889161e-02 1.168509386064e-02 1.153898689466e-02 + 1.139461276322e-02 1.125185169038e-02 1.111058982280e-02 1.097071965960e-02 + 1.083214044170e-02 1.069475849851e-02 1.055848755032e-02 1.042324896481e-02 + 1.028897196663e-02 1.015559379908e-02 1.002305983731e-02 9.891323652895e-03 + 9.760347029730e-03 9.630099931587e-03 9.500560422003e-03 9.371714537409e-03 + 9.243556114682e-03 9.116086574612e-03 8.989314662992e-03 8.863256151309e-03 + 8.737933499234e-03 8.613375481320e-03 8.489616780520e-03 8.366697551320e-03 + 8.244662955423e-03 8.123562673085e-03 8.003450393317e-03 7.884383286246e-03 + 7.766421461045e-03 7.649627412869e-03 7.534065462274e-03 7.419801190628e-03 + 7.306900874994e-03 7.195430925942e-03 7.085457331716e-03 6.977045112075e-03 + 6.870257785082e-03 6.765156849958e-03 6.661801289045e-03 6.560247091721e-03 + 6.460546803002e-03 6.362749099347e-03 6.266898394024e-03 6.173034474181e-03 + 6.081192171547e-03 5.991401068471e-03 5.903685240785e-03 5.818063038717e-03 + 5.734546906854e-03 5.653143243903e-03 5.573852302742e-03 5.496668131005e-03 + 5.421578552205e-03 5.348565187130e-03 5.277603515021e-03 5.208662973798e-03 + 5.141707098353e-03 5.076693695733e-03 5.013575055786e-03 4.952298195673e-03 + 4.892805136420e-03 4.835033209538e-03 4.778915391542e-03 4.724380664074e-03 + 4.671354397171e-03 4.619758753123e-03 4.569513108242e-03 4.520534489798e-03 + 4.472738025270e-03 4.426037401063e-03 4.380345327754e-03 4.335574008947e-03 + 4.291635610817e-03 4.248442729424e-03 4.205908852936e-03 4.163948815945e-03 + 4.122479243134e-03 4.081418979636e-03 4.040689505537e-03 4.000215332093e-03 + 3.959924377344e-03 3.919748318979e-03 3.879622922454e-03 3.839488342509e-03 + 3.799289396459e-03 3.758975807751e-03 3.718502418544e-03 3.677829370213e-03 + 3.636922250914e-03 3.595752209542e-03 3.554296035627e-03 3.512536204937e-03 + 3.470460890733e-03 3.428063940894e-03 3.385344821255e-03 3.342308525792e-03 + 3.298965454405e-03 3.255331259306e-03 3.211426661165e-03 3.167277236356e-03 + 3.122913176816e-03 3.078369024163e-03 3.033683379905e-03 2.988898593658e-03 + 2.944060431442e-03 2.899217726215e-03 2.854422012908e-03 2.809727150291e-03 + 2.765188932058e-03 2.720864689603e-03 2.676812888925e-03 2.633092724193e-03 + 2.589763710440e-03 2.546885277886e-03 2.504516370328e-03 2.462715050026e-03 + 2.421538111419e-03 2.381040705966e-03 2.341275980300e-03 2.302294729807e-03 + 2.264145069601e-03 2.226872124780e-03 2.190517741691e-03 2.155120221810e-03 + 2.120714079669e-03 2.087329826143e-03 2.054993778194e-03 2.023727896059e-03 + 1.993549648638e-03 1.964471907708e-03 1.936502871376e-03 1.909646017015e-03 + 1.883900083759e-03 1.859259084424e-03 1.835712346564e-03 1.813244582206e-03 + 1.791835985597e-03 1.771462358179e-03 1.752095259818e-03 1.733702185159e-03 + 1.716246763861e-03 1.699688983301e-03 1.683985432221e-03 1.669089563689e-03 + 1.654951975612e-03 1.641520706971e-03 1.628741547856e-03 1.616558361306e-03 + 1.604913414903e-03 1.593747720042e-03 1.583001376732e-03 1.572613921806e-03 + 1.562524678386e-03 1.552673104465e-03 1.542999138498e-03 1.533443539901e-03 + 1.523948222454e-03 1.514456578601e-03 1.504913792757e-03 1.495267141793e-03 + 1.485466280966e-03 1.475463513657e-03 1.465214043408e-03 1.454676206835e-03 + 1.443811686166e-03 1.432585700244e-03 1.420967172999e-03 1.408928878533e-03 + 1.396447562101e-03 1.383504036449e-03 1.370083253078e-03 1.356174348211e-03 + 1.341770663359e-03 1.326869740553e-03 1.311473292454e-03 1.295587147713e-03 + 1.279221172095e-03 1.262389166021e-03 1.245108739338e-03 1.227401164224e-03 + 1.209291207305e-03 1.190806942140e-03 1.171979543369e-03 1.152843063897e-03 + 1.133434196599e-03 1.113792022102e-03 1.093957744276e-03 1.073974415121e-03 + 1.053886650808e-03 1.033740340637e-03 1.013582350744e-03 9.934602243832e-04 + 9.734218806000e-04 9.535153131592e-04 9.337882915143e-04 9.142880656187e-04 + 8.950610763245e-04 8.761526730687e-04 8.576068404897e-04 8.394659355465e-04 + 8.217704366397e-04 8.045587061422e-04 7.878667676593e-04 7.717280992330e-04 + 7.561734436003e-04 7.412306364994e-04 7.269244539011e-04 7.132764789180e-04 + 7.003049890184e-04 6.880248640422e-04 6.764475153823e-04 6.655808365672e-04 + 6.554291753423e-04 6.459933272172e-04 6.372705503164e-04 6.292546012396e-04 + 6.219357915110e-04 6.153010640793e-04 6.093340892045e-04 6.040153789622e-04 + 5.993224194821e-04 5.952298199426e-04 5.917094772441e-04 5.887307552009e-04 + 5.862606770110e-04 5.842641296934e-04 5.827040791224e-04 5.815417942331e-04 + 5.807370789334e-04 5.802485102196e-04 5.800336809728e-04 5.800494458981e-04 + 5.802521690611e-04 5.805979714881e-04 5.810429773026e-04 5.815435569042e-04 + 5.820565657210e-04 5.825395771157e-04 5.829511080708e-04 5.832508363431e-04 + 5.833998078379e-04 5.833606330338e-04 5.830976713629e-04 5.825772025437e-04 + 5.817675839497e-04 5.806393931961e-04 5.791655552238e-04 5.773214532596e-04 + 5.750850231309e-04 5.724368305124e-04 5.693601307693e-04 5.658409111446e-04 + 5.618679151054e-04 5.574326486993e-04 5.525293687938e-04 5.471550530319e-04 + 5.413093512624e-04 5.349945180493e-04 5.282153256417e-04 5.209789564670e-04 + 5.132948738062e-04 5.051746688210e-04 4.966318815478e-04 4.876817929151e-04 + 4.783411843418e-04 4.686280611573e-04 4.585613361105e-04 4.481604698002e-04 + 4.374450661976e-04 4.264344238016e-04 4.151470466072e-04 4.036001241663e-04 + 3.918089966647e-04 3.797866290408e-04 3.675431274054e-04 3.550853407791e-04 + 3.424166004890e-04 3.295366571895e-04 3.164418798350e-04 3.031257803019e-04 + 2.895799200289e-04 2.757952395507e-04 2.617638272220e-04 2.474811096748e-04 + 2.329484046492e-04 2.181757290843e-04 2.031847053963e-04 1.880113615581e-04 + 1.727085816573e-04 1.573479391175e-04 1.420206404514e-04 1.268373278303e-04 + 1.119265365508e-04 9.743167866898e-05 8.350652361154e-05 7.030926427376e-05 + 5.799538389723e-05 4.670966361885e-05 3.657778061112e-05 2.769802994764e-05 + 2.013374906341e-05 1.390702415828e-05 8.994209321926e-06 5.323692408431e-06 + 2.776202480590e-06 1.187782192828e-06 3.553586242532e-07 4.465396560257e-08 + 0.000000000000e+00 + Type L N + 0 0 1 + 7.254873428942e-01 7.256666701836e-01 7.262040651787e-01 7.270977689660e-01 + 7.283448557011e-01 7.299412411073e-01 7.318816943340e-01 7.341598531361e-01 + 7.367682423256e-01 7.396982954341e-01 7.429403795151e-01 7.464838230058e-01 + 7.503169465575e-01 7.544270967320e-01 7.588006824578e-01 7.634232141234e-01 + 7.682793451844e-01 7.733529161466e-01 7.786270007853e-01 7.840839544493e-01 + 7.897054642959e-01 7.954726012944e-01 8.013658738321e-01 8.073652827510e-01 + 8.134503776412e-01 8.196003142102e-01 8.257939125497e-01 8.320097161138e-01 + 8.382260512257e-01 8.444210869251e-01 8.505728949734e-01 8.566595098284e-01 + 8.626589884062e-01 8.685494694476e-01 8.743092323085e-01 8.799167549976e-01 + 8.853507712889e-01 8.905903267386e-01 8.956148334429e-01 9.004041233778e-01 + 9.049385001677e-01 9.091987891354e-01 9.131663854946e-01 9.168233005512e-01 + 9.201522057895e-01 9.231364747249e-01 9.257602224156e-01 9.280083425331e-01 + 9.298665419008e-01 9.313213724179e-01 9.323602602985e-01 9.329715325607e-01 + 9.331444407159e-01 9.328691816115e-01 9.321369153974e-01 9.309397805906e-01 + 9.292709062264e-01 9.271244210907e-01 9.244954600412e-01 9.213801674334e-01 + 9.177756976756e-01 9.136802129486e-01 9.090928781328e-01 9.040138529968e-01 + 8.984442817063e-01 8.923862797242e-01 8.858429181782e-01 8.788182057798e-01 + 8.713170683877e-01 8.633453263117e-01 8.549096694633e-01 8.460176304626e-01 + 8.366775558156e-01 8.268985752843e-01 8.166905695723e-01 8.060641364551e-01 + 7.950305554857e-01 7.836017514115e-01 7.717902564368e-01 7.596091714706e-01 + 7.470721264985e-01 7.341932402185e-01 7.209870790813e-01 7.074686158739e-01 + 6.936531879864e-01 6.795564554976e-01 6.651943592171e-01 6.505830788149e-01 + 6.357389911700e-01 6.206786290648e-01 6.054186403485e-01 5.899757476891e-01 + 5.743667090281e-01 5.586082788498e-01 5.427171703685e-01 5.267100187338e-01 + 5.106033453488e-01 4.944135233878e-01 4.781567445972e-01 4.618489874536e-01 + 4.455059867492e-01 4.291432046671e-01 4.127758034017e-01 3.964186193738e-01 + 3.800861390819e-01 3.637924766262e-01 3.475513529322e-01 3.313760766971e-01 + 3.152795270720e-01 2.992741380906e-01 2.833718848433e-01 2.675842713943e-01 + 2.519223204291e-01 2.363965646160e-01 2.210170396586e-01 2.057932790105e-01 + 1.907343102184e-01 1.758486528546e-01 1.611443179941e-01 1.466288091897e-01 + 1.323091248895e-01 1.181917622427e-01 1.042827222321e-01 9.058751606940e-02 + 7.711117278740e-02 6.385824796008e-02 5.083283347819e-02 3.803856830806e-02 + 2.547865015811e-02 1.315584797747e-02 1.072515209469e-03 -1.076939627721e-02 + -2.236832165731e-02 -3.372306809514e-02 -4.483279924503e-02 -5.569701938217e-02 + -6.631555723891e-02 -7.668854962018e-02 -8.681642487002e-02 -9.669988625927e-02 + -1.063398953624e-01 -1.157376554889e-01 -1.248945952324e-01 -1.338123521969e-01 + -1.424927569584e-01 -1.509378173145e-01 -1.591497028740e-01 -1.671307300327e-01 + -1.748833473792e-01 -1.824101215717e-01 -1.897137237212e-01 -1.967969163142e-01 + -2.036625407039e-01 -2.103135051948e-01 -2.167527737423e-01 -2.229833552850e-01 + -2.290082937227e-01 -2.348306585525e-01 -2.404535361667e-01 -2.458800218186e-01 + -2.511132122536e-01 -2.561561990045e-01 -2.610120623413e-01 -2.656838658696e-01 + -2.701746517613e-01 -2.744874366059e-01 -2.786252078613e-01 -2.825909208870e-01 + -2.863874965356e-01 -2.900178192788e-01 -2.934847358419e-01 -2.967910543192e-01 + -2.999395437417e-01 -3.029329340652e-01 -3.057739165503e-01 -3.084651444993e-01 + -3.110092343197e-01 -3.134087668802e-01 -3.156662891257e-01 -3.177843159192e-01 + -3.197653320763e-01 -3.216117945603e-01 -3.233261348050e-01 -3.249107611349e-01 + -3.263680612502e-01 -3.277004047483e-01 -3.289101456532e-01 -3.299996249235e-01 + -3.309711729154e-01 -3.318271117747e-01 -3.325697577341e-01 -3.332014232962e-01 + -3.337244192811e-01 -3.341410567201e-01 -3.344536485814e-01 -3.346645113114e-01 + -3.347759661800e-01 -3.347903404196e-01 -3.347099681484e-01 -3.345371910720e-01 + -3.342743589580e-01 -3.339238298800e-01 -3.334879702312e-01 -3.329691545064e-01 + -3.323697648556e-01 -3.316921904132e-01 -3.309388264076e-01 -3.301120730579e-01 + -3.292143342673e-01 -3.282480161213e-01 -3.272155252025e-01 -3.261192667336e-01 + -3.249616425617e-01 -3.237450489978e-01 -3.224718745253e-01 -3.211444973951e-01 + -3.197652831201e-01 -3.183365818881e-01 -3.168607259083e-01 -3.153400267090e-01 + -3.137767724032e-01 -3.121732249392e-01 -3.105316173529e-01 -3.088541510394e-01 + -3.071429930586e-01 -3.054002734930e-01 -3.036280828708e-01 -3.018284696709e-01 + -3.000034379238e-01 -2.981549449206e-01 -2.962848990445e-01 -2.943951577350e-01 + -2.924875255971e-01 -2.905637526640e-01 -2.886255328226e-01 -2.866745024101e-01 + -2.847122389875e-01 -2.827402602961e-01 -2.807600234008e-01 -2.787729240243e-01 + -2.767802960736e-01 -2.747834113602e-01 -2.727834795133e-01 -2.707816480860e-01 + -2.687790028506e-01 -2.667765682807e-01 -2.647753082159e-01 -2.627761267031e-01 + -2.607798690080e-01 -2.587873227913e-01 -2.567992194399e-01 -2.548162355453e-01 + -2.528389945197e-01 -2.508680683408e-01 -2.489039794130e-01 -2.469472025355e-01 + -2.449981669661e-01 -2.430572585677e-01 -2.411248220269e-01 -2.392011631321e-01 + -2.372865510986e-01 -2.353812209292e-01 -2.334853757975e-01 -2.315991894418e-01 + -2.297228085585e-01 -2.278563551823e-01 -2.259999290424e-01 -2.241536098838e-01 + -2.223174597432e-01 -2.204915251685e-01 -2.186758393743e-01 -2.168704243221e-01 + -2.150752927189e-01 -2.132904499255e-01 -2.115158957672e-01 -2.097516262416e-01 + -2.079976351174e-01 -2.062539154195e-01 -2.045204607963e-01 -2.027972667658e-01 + -2.010843318391e-01 -1.993816585181e-01 -1.976892541676e-01 -1.960071317613e-01 + -1.943353105025e-01 -1.926738163205e-01 -1.910226822449e-01 -1.893819486610e-01 + -1.877516634493e-01 -1.861318820128e-01 -1.845226671970e-01 -1.829240891082e-01 + -1.813362248350e-01 -1.797591580790e-01 -1.781929787019e-01 -1.766377821957e-01 + -1.750936690819e-01 -1.735607442486e-01 -1.720391162332e-01 -1.705288964560e-01 + -1.690301984164e-01 -1.675431368557e-01 -1.660678268972e-01 -1.646043831701e-01 + -1.631529189255e-01 -1.617135451510e-01 -1.602863696932e-01 -1.588714963937e-01 + -1.574690242455e-01 -1.560790465776e-01 -1.547016502729e-01 -1.533369150254e-01 + -1.519849126425e-01 -1.506457063969e-01 -1.493193504333e-01 -1.480058892333e-01 + -1.467053571418e-01 -1.454177779589e-01 -1.441431645988e-01 -1.428815188187e-01 + -1.416328310171e-01 -1.403970801058e-01 -1.391742334519e-01 -1.379642468930e-01 + -1.367670648229e-01 -1.355826203479e-01 -1.344108355108e-01 -1.332516215814e-01 + -1.321048794113e-01 -1.309704998483e-01 -1.298483642091e-01 -1.287383448054e-01 + -1.276403055193e-01 -1.265541024246e-01 -1.254795844485e-01 -1.244165940690e-01 + -1.233649680437e-01 -1.223245381637e-01 -1.212951320287e-01 -1.202765738365e-01 + -1.192686851828e-01 -1.182712858649e-01 -1.172841946847e-01 -1.163072302453e-01 + -1.153402117357e-01 -1.143829596997e-01 -1.134352967825e-01 -1.124970484522e-01 + -1.115680436898e-01 -1.106481156450e-01 -1.097371022529e-01 -1.088348468094e-01 + -1.079411984998e-01 -1.070560128798e-01 -1.061791523053e-01 -1.053104863089e-01 + -1.044498919210e-01 -1.035972539354e-01 -1.027524651161e-01 -1.019154263471e-01 + -1.010860467232e-01 -1.002642435825e-01 -9.944994248185e-02 -9.864307711501e-02 + -9.784358917552e-02 -9.705142816589e-02 -9.626655115497e-02 -9.548892248592e-02 + -9.471851343733e-02 -9.395530184054e-02 -9.319927165621e-02 -9.245041251371e-02 + -9.170871921683e-02 -9.097419121975e-02 -9.024683207723e-02 -8.952664887308e-02 + -8.881365163121e-02 -8.810785271354e-02 -8.740926620906e-02 -8.671790731849e-02 + -8.603379173875e-02 -8.535693505166e-02 -8.468735212103e-02 -8.402505650228e-02 + -8.337005986852e-02 -8.272237145706e-02 -8.208199753993e-02 -8.144894092187e-02 + -8.082320046907e-02 -8.020477067166e-02 -7.959364124268e-02 -7.898979675599e-02 + -7.839321632536e-02 -7.780387332648e-02 -7.722173516368e-02 -7.664676308235e-02 + -7.607891202816e-02 -7.551813055364e-02 -7.496436077230e-02 -7.441753836036e-02 + -7.387759260550e-02 -7.334444650219e-02 -7.281801689227e-02 -7.229821464967e-02 + -7.178494490761e-02 -7.127810732620e-02 -7.077759639858e-02 -7.028330179286e-02 + -6.979510872749e-02 -6.931289837697e-02 -6.883654830505e-02 -6.836593292207e-02 + -6.790092396314e-02 -6.744139098370e-02 -6.698720186881e-02 -6.653822335263e-02 + -6.609432154426e-02 -6.565536245638e-02 -6.522121253286e-02 -6.479173917170e-02 + -6.436681123969e-02 -6.394629957521e-02 -6.353007747576e-02 -6.311802116687e-02 + -6.271001024920e-02 -6.230592812088e-02 -6.190566237223e-02 -6.150910515026e-02 + -6.111615349049e-02 -6.072670961410e-02 -6.034068118830e-02 -5.995798154845e-02 + -5.957852988044e-02 -5.920225136233e-02 -5.882907726438e-02 -5.845894500696e-02 + -5.809179817626e-02 -5.772758649759e-02 -5.736626576701e-02 -5.700779774157e-02 + -5.665214998938e-02 -5.629929570062e-02 -5.594921346095e-02 -5.560188698908e-02 + -5.525730484048e-02 -5.491546007952e-02 -5.457634992227e-02 -5.423997535275e-02 + -5.390634071546e-02 -5.357545328686e-02 -5.324732282934e-02 -5.292196113045e-02 + -5.259938153099e-02 -5.227959844527e-02 -5.196262687686e-02 -5.164848193346e-02 + -5.133717834423e-02 -5.102872998301e-02 -5.072314940095e-02 -5.042044737174e-02 + -5.012063245275e-02 -4.982371056520e-02 -4.952968459635e-02 -4.923855402661e-02 + -4.895031458408e-02 -4.866495792929e-02 -4.838247137211e-02 -4.810283762315e-02 + -4.782603458131e-02 -4.755203515910e-02 -4.728080714718e-02 -4.701231311894e-02 + -4.674651037613e-02 -4.648335093590e-02 -4.622278155957e-02 -4.596474382297e-02 + -4.570917422813e-02 -4.545600435556e-02 -4.520516105632e-02 -4.495656668270e-02 + -4.471013935597e-02 -4.446579326960e-02 -4.422343902605e-02 -4.398298400479e-02 + -4.374433275935e-02 -4.350738744073e-02 -4.327204824428e-02 -4.303821387741e-02 + -4.280578204466e-02 -4.257464994722e-02 -4.234471479342e-02 -4.211587431678e-02 + -4.188802729821e-02 -4.166107408881e-02 -4.143491712971e-02 -4.120946146551e-02 + -4.098461524766e-02 -4.076029022453e-02 -4.053640221469e-02 -4.031287156008e-02 + -4.008962355603e-02 -3.986658885506e-02 -3.964370384156e-02 -3.942091097474e-02 + -3.919815909734e-02 -3.897540370783e-02 -3.875260719405e-02 -3.852973902653e-02 + -3.830677590993e-02 -3.808370189129e-02 -3.786050842416e-02 -3.763719438785e-02 + -3.741376606137e-02 -3.719023705192e-02 -3.696662817818e-02 -3.674296730868e-02 + -3.651928915615e-02 -3.629563502882e-02 -3.607205254002e-02 -3.584859527756e-02 + -3.562532243500e-02 -3.540229840658e-02 -3.517959234853e-02 -3.495727770905e-02 + -3.473543172998e-02 -3.451413492302e-02 -3.429347052373e-02 -3.407352392670e-02 + -3.385438210523e-02 -3.363613301929e-02 -3.341886501524e-02 -3.320266622131e-02 + -3.298762394241e-02 -3.277382405822e-02 -3.256135042847e-02 -3.235028430897e-02 + -3.214070378242e-02 -3.193268320750e-02 -3.172629268990e-02 -3.152159757872e-02 + -3.131865799163e-02 -3.111752837185e-02 -3.091825708000e-02 -3.072088602362e-02 + -3.052545032675e-02 -3.033197804211e-02 -3.014048990770e-02 -2.995099914979e-02 + -2.976351133363e-02 -2.957802426325e-02 -2.939452793110e-02 -2.921300451825e-02 + -2.903342844527e-02 -2.885576647395e-02 -2.867997785924e-02 -2.850601455098e-02 + -2.833382144417e-02 -2.816333667671e-02 -2.799449197269e-02 -2.782721302956e-02 + -2.766141994684e-02 -2.749702769383e-02 -2.733394661371e-02 -2.717208296080e-02 + -2.701133946797e-02 -2.685161594061e-02 -2.669280987347e-02 -2.653481708672e-02 + -2.637753237709e-02 -2.622085018006e-02 -2.606466523893e-02 -2.590887327648e-02 + -2.575337166480e-02 -2.559806008909e-02 -2.544284120097e-02 -2.528762125705e-02 + -2.513231073838e-02 -2.497682494674e-02 -2.482108457356e-02 -2.466501623762e-02 + -2.450855298765e-02 -2.435163476629e-02 -2.419420883202e-02 -2.403623013573e-02 + -2.387766164928e-02 -2.371847464307e-02 -2.355864891050e-02 -2.339817293711e-02 + -2.323704401269e-02 -2.307526828495e-02 -2.291286075357e-02 -2.274984520407e-02 + -2.258625408096e-02 -2.242212830027e-02 -2.225751700172e-02 -2.209247724135e-02 + -2.192707362565e-02 -2.176137788862e-02 -2.159546841364e-02 -2.142942970219e-02 + -2.126335179210e-02 -2.109732962799e-02 -2.093146238710e-02 -2.076585276399e-02 + -2.060060621782e-02 -2.043583018613e-02 -2.027163326949e-02 -2.010812439128e-02 + -1.994541193741e-02 -1.978360288077e-02 -1.962280189525e-02 -1.946311046452e-02 + -1.930462599078e-02 -1.914744090855e-02 -1.899164180891e-02 -1.883730857935e-02 + -1.868451356458e-02 -1.853332075332e-02 -1.838378499630e-02 -1.823595126041e-02 + -1.808985392377e-02 -1.794551611644e-02 -1.780294911118e-02 -1.766215176856e-02 + -1.752311004029e-02 -1.738579653452e-02 -1.725017014658e-02 -1.711617575804e-02 + -1.698374400709e-02 -1.685279113236e-02 -1.672321889232e-02 -1.659491456194e-02 + -1.646775100755e-02 -1.634158684107e-02 -1.621626665358e-02 -1.609162132846e-02 + -1.596746843346e-02 -1.584361269051e-02 -1.571984652213e-02 -1.559595067190e-02 + -1.547169489659e-02 -1.534683872624e-02 -1.522113228779e-02 -1.509431718645e-02 + -1.496612743749e-02 -1.483629043856e-02 -1.470452796987e-02 -1.457055720485e-02 + -1.443409170812e-02 -1.429484238992e-02 -1.415251837503e-02 -1.400682773128e-02 + -1.385747798508e-02 -1.370417633100e-02 -1.354662941759e-02 -1.338454256474e-02 + -1.321761823931e-02 -1.304555358959e-02 -1.286803681889e-02 -1.268474217206e-02 + -1.249532332271e-02 -1.229940499551e-02 -1.209657274723e-02 -1.188636097593e-02 + -1.166823943872e-02 -1.144159884417e-02 -1.120573644391e-02 -1.095984297292e-02 + -1.070299275375e-02 -1.043413925187e-02 -1.015211878805e-02 -9.855665409747e-03 + -9.543440008834e-03 -9.214076556271e-03 -8.866247718325e-03 -8.498751054188e-03 + -8.110615439050e-03 -7.701225329127e-03 -7.270458073131e-03 -6.818826842202e-03 + -6.347619139072e-03 -5.859018565355e-03 -5.356195924376e-03 -4.843355172226e-03 + -4.325720516624e-03 -3.809453321228e-03 -3.301491475836e-03 -2.809309425588e-03 + -2.340603789462e-03 -1.902916906830e-03 -1.503218023709e-03 -1.147468351328e-03 + -8.402010638750e-04 -5.841497027245e-04 -3.799578710602e-04 -2.259992769873e-04 + -1.183302128984e-04 -5.078691996859e-05 -1.522880477927e-05 -1.916246212603e-06 + 0.000000000000e+00 + Type L N + 0 1 0 + 0.000000000000e+00 4.626669306440e-02 9.247677643884e-02 1.385737661495e-01 + 1.845014292772e-01 2.302039085422e-01 2.756258457606e-01 3.207125038039e-01 + 3.654098866971e-01 4.096648574975e-01 4.534252536048e-01 4.966399991622e-01 + 5.392592142182e-01 5.812343203311e-01 6.225181423090e-01 6.630650057955e-01 + 7.028308304215e-01 7.417732182629e-01 7.798515373591e-01 8.170270000629e-01 + 8.532627360156e-01 8.885238595536e-01 9.227775313771e-01 9.559930143289e-01 + 9.881417231541e-01 1.019197268128e+00 1.049135492469e+00 1.077934503457e+00 + 1.105574697231e+00 1.132038777224e+00 1.157311766233e+00 1.181381012159e+00 + 1.204236187438e+00 1.225869282229e+00 1.246274591448e+00 1.265448695731e+00 + 1.283390436474e+00 1.300100885050e+00 1.315583306407e+00 1.329843117176e+00 + 1.342887838522e+00 1.354727043913e+00 1.365372302051e+00 1.374837115191e+00 + 1.383136853106e+00 1.390288682952e+00 1.396311495311e+00 1.401225826696e+00 + 1.405053778803e+00 1.407818934819e+00 1.409546273083e+00 1.410262078416e+00 + 1.409993851433e+00 1.408770216150e+00 1.406620826218e+00 1.403576270089e+00 + 1.399667975436e+00 1.394928113157e+00 1.389389501250e+00 1.383085508897e+00 + 1.376049961044e+00 1.368317043767e+00 1.359921210742e+00 1.350897091066e+00 + 1.341279398726e+00 1.331102843968e+00 1.320402046811e+00 1.309211452959e+00 + 1.297565252319e+00 1.285497300354e+00 1.273041042453e+00 1.260229441521e+00 + 1.247094908937e+00 1.233669239051e+00 1.219983547349e+00 1.206068212405e+00 + 1.191952821741e+00 1.177666121662e+00 1.163235971158e+00 1.148689299921e+00 + 1.134052070515e+00 1.119349244734e+00 1.104604754140e+00 1.089841474788e+00 + 1.075081206110e+00 1.060344653911e+00 1.045651417444e+00 1.031019980477e+00 + 1.016467706281e+00 1.002010836454e+00 9.876644934525e-01 9.734426867397e-01 + 9.593583224036e-01 9.454232161144e-01 9.316481092715e-01 9.180426881845e-01 + 9.046156061222e-01 8.913745080609e-01 8.783260579512e-01 8.654759683243e-01 + 8.528290320477e-01 8.403891560415e-01 8.281593967612e-01 8.161419972524e-01 + 8.043384255816e-01 7.927494144461e-01 7.813750017691e-01 7.702145720852e-01 + 7.592668985250e-01 7.485301852117e-01 7.380021098828e-01 7.276798665597e-01 + 7.175602080880e-01 7.076394883814e-01 6.979137042049e-01 6.883785363434e-01 + 6.790293900054e-01 6.698614343236e-01 6.608696408190e-01 6.520488207049e-01 + 6.433936609179e-01 6.348987587694e-01 6.265586551227e-01 6.183678660090e-01 + 6.103209126074e-01 6.024123495215e-01 5.946367912964e-01 5.869889371295e-01 + 5.794635937392e-01 5.720556963634e-01 5.647603278708e-01 5.575727359769e-01 + 5.504883485661e-01 5.435027871291e-01 5.366118783351e-01 5.298116637647e-01 + 5.230984078384e-01 5.164686039829e-01 5.099189790850e-01 5.034464962871e-01 + 4.970483561883e-01 4.907219965172e-01 4.844650903499e-01 4.782755429504e-01 + 4.721514873143e-01 4.660912785021e-01 4.600934868494e-01 4.541568901450e-01 + 4.482804648686e-01 4.424633765848e-01 4.367049695852e-01 4.310047558766e-01 + 4.253624036096e-01 4.197777250424e-01 4.142506641348e-01 4.087812838625e-01 + 4.033697533448e-01 3.980163348711e-01 3.927213709139e-01 3.874852712079e-01 + 3.823084999769e-01 3.771915633804e-01 3.721349972533e-01 3.671393552038e-01 + 3.622051971318e-01 3.573330782258e-01 3.525235384903e-01 3.477770928499e-01 + 3.430942218749e-01 3.384753631632e-01 3.339209034105e-01 3.294311711968e-01 + 3.250064305082e-01 3.206468750123e-01 3.163526230955e-01 3.121237136700e-01 + 3.079601027506e-01 3.038616607970e-01 2.998281708131e-01 2.958593271912e-01 + 2.919547352822e-01 2.881139116717e-01 2.843362851372e-01 2.806211982569e-01 + 2.769679096388e-01 2.733755967358e-01 2.698433592092e-01 2.663702228010e-01 + 2.629551436727e-01 2.595970131682e-01 2.562946629558e-01 2.530468705019e-01 + 2.498523648317e-01 2.467098325280e-01 2.436179239222e-01 2.405752594280e-01 + 2.375804359731e-01 2.346320334812e-01 2.317286213597e-01 2.288687649482e-01 + 2.260510318856e-01 2.232739983553e-01 2.205362551671e-01 2.178364136421e-01 + 2.151731112625e-01 2.125450170553e-01 2.099508366804e-01 2.073893171946e-01 + 2.048592514678e-01 2.023594822299e-01 1.998889057289e-01 1.974464749851e-01 + 1.950312026290e-01 1.926421633118e-01 1.902784956831e-01 1.879394039318e-01 + 1.856241588886e-01 1.833320986932e-01 1.810626290297e-01 1.788152229396e-01 + 1.765894202199e-01 1.743848264217e-01 1.722011114618e-01 1.700380078656e-01 + 1.678953086602e-01 1.657728649384e-01 1.636705831165e-01 1.615884219095e-01 + 1.595263890502e-01 1.574845377777e-01 1.554629631231e-01 1.534617980220e-01 + 1.514812092796e-01 1.495213934218e-01 1.475825724573e-01 1.456649895836e-01 + 1.437689048635e-01 1.418945909028e-01 1.400423285557e-01 1.382124026860e-01 + 1.364050980113e-01 1.346206950549e-01 1.328594662287e-01 1.311216720732e-01 + 1.294075576724e-01 1.277173492659e-01 1.260512510763e-01 1.244094423676e-01 + 1.227920747499e-01 1.211992697433e-01 1.196311166126e-01 1.180876704799e-01 + 1.165689507245e-01 1.150749396739e-01 1.136055815889e-01 1.121607819445e-01 + 1.107404070054e-01 1.093442836937e-01 1.079721997437e-01 1.066239041386e-01 + 1.052991078190e-01 1.039974846564e-01 1.027186726775e-01 1.014622755288e-01 + 1.002278641668e-01 9.901497875795e-02 9.782313077323e-02 9.665180525899e-02 + 9.550046326660e-02 9.436854442164e-02 9.325546961334e-02 9.216064378426e-02 + 9.108345880003e-02 9.002329637868e-02 8.897953105904e-02 8.795153318799e-02 + 8.693867190608e-02 8.594031811199e-02 8.495584738619e-02 8.398464285514e-02 + 8.302609797786e-02 8.207961923751e-02 8.114462872159e-02 8.022056657532e-02 + 7.930689331374e-02 7.840309197944e-02 7.750867013367e-02 7.662316167031e-02 + 7.574612844318e-02 7.487716169847e-02 7.401588330588e-02 7.316194678300e-02 + 7.231503810912e-02 7.147487632614e-02 7.064121392554e-02 6.981383702175e-02 + 6.899256531393e-02 6.817725183911e-02 6.736778252125e-02 6.656407552203e-02 + 6.576608040015e-02 6.497377708742e-02 6.418717469067e-02 6.340631012970e-02 + 6.263124662243e-02 6.186207202910e-02 6.109889706828e-02 6.034185341798e-02 + 5.959109171580e-02 5.884677947253e-02 5.810909891384e-02 5.737824476519e-02 + 5.665442199500e-02 5.593784353143e-02 5.522872796790e-02 5.452729727241e-02 + 5.383377451555e-02 5.314838163169e-02 5.247133722744e-02 5.180285445101e-02 + 5.114313893551e-02 5.049238682857e-02 4.985078291990e-02 4.921849887774e-02 + 4.859569160412e-02 4.798250171810e-02 4.737905217510e-02 4.678544702965e-02 + 4.620177034738e-02 4.562808527175e-02 4.506443324922e-02 4.451083341594e-02 + 4.396728214785e-02 4.343375277482e-02 4.291019545869e-02 4.239653723369e-02 + 4.189268220694e-02 4.139851191555e-02 4.091388583593e-02 4.043864204001e-02 + 3.997259799209e-02 3.951555147938e-02 3.906728166825e-02 3.862755027772e-02 + 3.819610286095e-02 3.777267018490e-02 3.735696969794e-02 3.694870707447e-02 + 3.654757782553e-02 3.615326896400e-02 3.576546071256e-02 3.538382824290e-02 + 3.500804343402e-02 3.463777663802e-02 3.427269844162e-02 3.391248141169e-02 + 3.355680181363e-02 3.320534129149e-02 3.285778849928e-02 3.251384067318e-02 + 3.217320513500e-02 3.183560071786e-02 3.150075910546e-02 3.116842607708e-02 + 3.083836265137e-02 3.051034612224e-02 3.018417098153e-02 2.985964972338e-02 + 2.953661352651e-02 2.921491281118e-02 2.889441766852e-02 2.857501816086e-02 + 2.825662449243e-02 2.793916705072e-02 2.762259631970e-02 2.730688266665e-02 + 2.699201600563e-02 2.667800534077e-02 2.636487819401e-02 2.605267992196e-02 + 2.574147292769e-02 2.543133577365e-02 2.512236220262e-02 2.481466007401e-02 + 2.450835022332e-02 2.420356525313e-02 2.390044826409e-02 2.359915153494e-02 + 2.329983516064e-02 2.300266565796e-02 2.270781454790e-02 2.241545692458e-02 + 2.212577001985e-02 2.183893177319e-02 2.155511941611e-02 2.127450808001e-02 + 2.099726943654e-02 2.072357037869e-02 2.045357175104e-02 2.018742713666e-02 + 1.992528170814e-02 1.966727114943e-02 1.941352065482e-02 1.916414401067e-02 + 1.891924276507e-02 1.867890548977e-02 1.844320713834e-02 1.821220850348e-02 + 1.798595577619e-02 1.776448020835e-02 1.754779787984e-02 1.733590957064e-02 + 1.712880073748e-02 1.692644159407e-02 1.672878729330e-02 1.653577820895e-02 + 1.634734031411e-02 1.616338565257e-02 1.598381289929e-02 1.580850800495e-02 + 1.563734491978e-02 1.547018639065e-02 1.530688482563e-02 1.514728321942e-02 + 1.499121613292e-02 1.483851071980e-02 1.468898779289e-02 1.454246292273e-02 + 1.439874756077e-02 1.425765017942e-02 1.411897742129e-02 1.398253524971e-02 + 1.384813009314e-02 1.371556997561e-02 1.358466562605e-02 1.345523155923e-02 + 1.332708712145e-02 1.320005749427e-02 1.307397465026e-02 1.294867825452e-02 + 1.282401650690e-02 1.269984691961e-02 1.257603702582e-02 1.245246501512e-02 + 1.232902029249e-02 1.220560395758e-02 1.208212920209e-02 1.195852162325e-02 + 1.183471945225e-02 1.171067369687e-02 1.158634819813e-02 1.146171960159e-02 + 1.133677724410e-02 1.121152295783e-02 1.108597079338e-02 1.096014666495e-02 + 1.083408792038e-02 1.070784283988e-02 1.058147006741e-02 1.045503797910e-02 + 1.032862399368e-02 1.020231383001e-02 1.007620071720e-02 9.950384563086e-03 + 9.824971087055e-03 9.700070923359e-03 9.575798701242e-03 9.452272108278e-03 + 9.329610943381e-03 9.207936165980e-03 9.087368947783e-03 8.968029733511e-03 + 8.850037316863e-03 8.733507937802e-03 8.618554407078e-03 8.505285263657e-03 + 8.393803970449e-03 8.284208153457e-03 8.176588889091e-03 8.071030044062e-03 + 7.967607671864e-03 7.866389469441e-03 7.767434297208e-03 7.670791765129e-03 + 7.576501887099e-03 7.484594805397e-03 7.395090586489e-03 7.307999088963e-03 + 7.223319903894e-03 7.141042367445e-03 7.061145645014e-03 6.983598885766e-03 + 6.908361445924e-03 6.835383178746e-03 6.764604788651e-03 6.695958246585e-03 + 6.629367263288e-03 6.564747816781e-03 6.502008730030e-03 6.441052294461e-03 + 6.381774934689e-03 6.324067909605e-03 6.267818044733e-03 6.212908490608e-03 + 6.159219501783e-03 6.106629230949e-03 6.055014532629e-03 6.004251770844e-03 + 5.954217625165e-03 5.904789889639e-03 5.855848259131e-03 5.807275097749e-03 + 5.758956184216e-03 5.710781429171e-03 5.662645559677e-03 5.614448766417e-03 + 5.566097309364e-03 5.517504078010e-03 5.468589102591e-03 5.419280013061e-03 + 5.369512443000e-03 5.319230375965e-03 5.268386432279e-03 5.216942094584e-03 + 5.164867870992e-03 5.112143395040e-03 5.058757462124e-03 5.004708002508e-03 + 4.950001991440e-03 4.894655297341e-03 4.838692469426e-03 4.782146466559e-03 + 4.725058329501e-03 4.667476799104e-03 4.609457883366e-03 4.551064376569e-03 + 4.492365334071e-03 4.433435506574e-03 4.374354737978e-03 4.315207331132e-03 + 4.256081386021e-03 4.197068115070e-03 4.138261140407e-03 4.079755777996e-03 + 4.021648313667e-03 3.964035276043e-03 3.907012711426e-03 3.850675465625e-03 + 3.795116477667e-03 3.740426090216e-03 3.686691381401e-03 3.633995522588e-03 + 3.582417166444e-03 3.532029869390e-03 3.482901552337e-03 3.435094003277e-03 + 3.388662425042e-03 3.343655031184e-03 3.300112692642e-03 3.258068637445e-03 + 3.217548205397e-03 3.178568659244e-03 3.141139053489e-03 3.105260161581e-03 + 3.070924461834e-03 3.038116182008e-03 3.006811402101e-03 2.976978214492e-03 + 2.948576940192e-03 2.921560399576e-03 2.895874235616e-03 2.871457287251e-03 + 2.848242010226e-03 2.826154942389e-03 2.805117210156e-03 2.785045072566e-03 + 2.765850499104e-03 2.747441777247e-03 2.729724145494e-03 2.712600447460e-03 + 2.695971802504e-03 2.679738288218e-03 2.663799630071e-03 2.648055893421e-03 + 2.632408173111e-03 2.616759275908e-03 2.601014391046e-03 2.585081744281e-03 + 2.568873230918e-03 2.552305023468e-03 2.535298149731e-03 2.517779037327e-03 + 2.499680020904e-03 2.480939808524e-03 2.461503903985e-03 2.441324982167e-03 + 2.420363214753e-03 2.398586544076e-03 2.375970903129e-03 2.352500380192e-03 + 2.328167326847e-03 2.302972408589e-03 2.276924597575e-03 2.250041107472e-03 + 2.222347270745e-03 2.193876359100e-03 2.164669348201e-03 2.134774628125e-03 + 2.104247661406e-03 2.073150590858e-03 2.041551799704e-03 2.009525426863e-03 + 1.977150840543e-03 1.944512073575e-03 1.911697224169e-03 1.878797826026e-03 + 1.845908191926e-03 1.813124735106e-03 1.780545272907e-03 1.748268317253e-03 + 1.716392356669e-03 1.685015134571e-03 1.654232928608e-03 1.624139835837e-03 + 1.594827068485e-03 1.566382264978e-03 1.538888820844e-03 1.512425243959e-03 + 1.487064538469e-03 1.462873621539e-03 1.439912776851e-03 1.418235148603e-03 + 1.397886279419e-03 1.378903695388e-03 1.361316541089e-03 1.345145267177e-03 + 1.330401372742e-03 1.317087204330e-03 1.305195813119e-03 1.294710871381e-03 + 1.285606648941e-03 1.277848049954e-03 1.271390709857e-03 1.266181151892e-03 + 1.262157002094e-03 1.259247261038e-03 1.257372629988e-03 1.256445888300e-03 + 1.256372317939e-03 1.257050169762e-03 1.258371164675e-03 1.260221020806e-03 + 1.262479995372e-03 1.265023426865e-03 1.267722259454e-03 1.270443527154e-03 + 1.273050770446e-03 1.275404352865e-03 1.277361640234e-03 1.278777001383e-03 + 1.279501587554e-03 1.279382849847e-03 1.278263761804e-03 1.275981729809e-03 + 1.272367199681e-03 1.267242005586e-03 1.260417558647e-03 1.251693037373e-03 + 1.240853818454e-03 1.227670470115e-03 1.211898713617e-03 1.193280830673e-03 + 1.171549041425e-03 1.146431382802e-03 1.117660563243e-03 1.084986141051e-03 + 1.048190158810e-03 1.007106061638e-03 9.616403401761e-04 9.117958912844e-04 + 8.576956167753e-04 7.996043336342e-04 7.379467099683e-04 6.733187363399e-04 + 6.064902563311e-04 5.383963642217e-04 4.701160591847e-04 4.028374193811e-04 + 3.378096816747e-04 2.762838987458e-04 2.194451740707e-04 1.683406996263e-04 + 1.238087845849e-04 8.641461945317e-05 5.639855469582e-05 3.364212299270e-05 + 1.765590279501e-05 7.591682743524e-06 2.279385157959e-06 2.870401658966e-07 + 0.000000000000e+00 + Type L N + 0 1 1 + 0.000000000000e+00 3.375340101333e-02 6.746796349822e-02 1.011049138555e-01 + 1.346256082234e-01 1.679915970424e-01 2.011646892560e-01 2.341070160275e-01 + 2.667810938520e-01 2.991498869451e-01 3.311768687900e-01 3.628260827265e-01 + 3.940622014666e-01 4.248505854211e-01 4.551573397281e-01 4.849493698694e-01 + 5.141944357697e-01 5.428612042712e-01 5.709192998796e-01 5.983393536821e-01 + 6.250930503389e-01 6.511531730530e-01 6.764936464275e-01 7.010895771214e-01 + 7.249172922209e-01 7.479543752446e-01 7.701796997065e-01 7.915734601660e-01 + 8.121172006957e-01 8.317938407052e-01 8.505876980641e-01 8.684845094698e-01 + 8.854714480139e-01 9.015371379059e-01 9.166716663176e-01 9.308665923177e-01 + 9.441149528744e-01 9.564112659059e-01 9.677515303693e-01 9.781332233824e-01 + 9.875552943794e-01 9.960181563106e-01 1.003523673900e+00 1.010075148982e+00 + 1.015677302955e+00 1.020336256368e+00 1.024059505710e+00 1.026855897434e+00 + 1.028735599272e+00 1.029710068925e+00 1.029792020169e+00 1.028995386487e+00 + 1.027335282286e+00 1.024827961803e+00 1.021490775799e+00 1.017342126138e+00 + 1.012401418364e+00 1.006689012392e+00 1.000226171440e+00 9.930350093166e-01 + 9.851384362041e-01 9.765601030744e-01 9.673243448728e-01 9.574561226182e-01 + 9.469809645661e-01 9.359249065863e-01 9.243144319084e-01 9.121764103924e-01 + 8.995380374803e-01 8.864267729912e-01 8.728702799165e-01 8.588963633783e-01 + 8.445329099101e-01 8.298078272199e-01 8.147489845939e-01 7.993841540983e-01 + 7.837409527334e-01 7.678467856909e-01 7.517287908658e-01 7.354137847644e-01 + 7.189282099516e-01 7.022980841725e-01 6.855489512787e-01 6.687058340848e-01 + 6.517931892735e-01 6.348348644627e-01 6.178540575378e-01 6.008732783497e-01 + 5.839143128664e-01 5.669981898627e-01 5.501451502191e-01 5.333746188975e-01 + 5.167051796490e-01 5.001545525002e-01 4.837395740569e-01 4.674761806538e-01 + 4.513793943678e-01 4.354633119048e-01 4.197410963605e-01 4.042249718435e-01 + 3.889262209421e-01 3.738551850050e-01 3.590212671974e-01 3.444329382852e-01 + 3.300977450887e-01 3.160223215414e-01 3.022124022789e-01 2.886728386745e-01 + 2.754076172314e-01 2.624198802337e-01 2.497119485487e-01 2.372853464705e-01 + 2.251408284840e-01 2.132784078267e-01 2.016973867172e-01 1.903963881162e-01 + 1.793733888809e-01 1.686257541706e-01 1.581502729567e-01 1.479431944907e-01 + 1.380002655774e-01 1.283167685047e-01 1.188875594752e-01 1.097071073890e-01 + 1.007695328252e-01 9.206864707152e-02 8.359799105358e-02 7.535087401652e-02 + 6.732041181622e-02 5.949956467938e-02 5.188117429660e-02 4.445800011708e-02 + 3.722275471825e-02 3.016813812988e-02 2.328687099752e-02 1.657172647727e-02 + 1.001556076019e-02 3.611342132348e-03 -2.647821516258e-03 -8.768656812552e-03 + -1.475770072170e-02 -2.062127813107e-02 -2.636548125059e-02 -3.199615087445e-02 + -3.751885954038e-02 -4.293889661385e-02 -4.826125531553e-02 -5.349062170172e-02 + -5.863136559834e-02 -6.368753348054e-02 -6.866284328140e-02 -7.356068110460e-02 + -7.838409980795e-02 -8.313581941656e-02 -8.781822931687e-02 -9.243339217524e-02 + -9.698304951803e-02 -1.014686289032e-01 -1.058912526074e-01 -1.102517477471e-01 + -1.145506577458e-01 -1.187882550557e-01 -1.229645550382e-01 -1.270793309018e-01 + -1.311321295940e-01 -1.351222885425e-01 -1.390489531347e-01 -1.429110948275e-01 + -1.467075297752e-01 -1.504369378627e-01 -1.540978820347e-01 -1.576888278065e-01 + -1.612081628491e-01 -1.646542165373e-01 -1.680252793568e-01 -1.713196220647e-01 + -1.745355145039e-01 -1.776712439735e-01 -1.807251330624e-01 -1.836955568580e-01 + -1.865809594450e-01 -1.893798696175e-01 -1.920909157293e-01 -1.947128396172e-01 + -1.972445095340e-01 -1.996849320388e-01 -2.020332627945e-01 -2.042888162310e-01 + -2.064510740412e-01 -2.085196924792e-01 -2.104945084419e-01 -2.123755443193e-01 + -2.141630116067e-01 -2.158573132777e-01 -2.174590449274e-01 -2.189689946957e-01 + -2.203881419935e-01 -2.217176550569e-01 -2.229588873615e-01 -2.241133729361e-01 + -2.251828206181e-01 -2.261691073020e-01 -2.270742702318e-01 -2.279004983992e-01 + -2.286501231081e-01 -2.293256077729e-01 -2.299295370205e-01 -2.304646051689e-01 + -2.309336041573e-01 -2.313394110069e-01 -2.316849748892e-01 -2.319733038842e-01 + -2.322074515083e-01 -2.323905030937e-01 -2.325255621004e-01 -2.326157364412e-01 + -2.326641248984e-01 -2.326738037117e-01 -2.326478134108e-01 -2.325891459689e-01 + -2.325007323449e-01 -2.323854304855e-01 -2.322460138479e-01 -2.320851605065e-01 + -2.319054428983e-01 -2.317093182599e-01 -2.314991198032e-01 -2.312770486727e-01 + -2.310451667226e-01 -2.308053901448e-01 -2.305594839771e-01 -2.303090575121e-01 + -2.300555606232e-01 -2.298002810200e-01 -2.295443424368e-01 -2.292887037559e-01 + -2.290341590589e-01 -2.287813385964e-01 -2.285307106594e-01 -2.282825843322e-01 + -2.280371130998e-01 -2.277942992806e-01 -2.275539992486e-01 -2.273159294059e-01 + -2.270796728624e-01 -2.268446867758e-01 -2.266103103025e-01 -2.263757731044e-01 + -2.261402043576e-01 -2.259026422030e-01 -2.256620435804e-01 -2.254172943820e-01 + -2.251672198643e-01 -2.249105952529e-01 -2.246461564765e-01 -2.243726109647e-01 + -2.240886484469e-01 -2.237929516866e-01 -2.234842070895e-01 -2.231611151244e-01 + -2.228224004966e-01 -2.224668220165e-01 -2.220931821080e-01 -2.217003359051e-01 + -2.212871998854e-01 -2.208527599957e-01 -2.203960792263e-01 -2.199163045941e-01 + -2.194126735000e-01 -2.188845194288e-01 -2.183312769643e-01 -2.177524860977e-01 + -2.171477958094e-01 -2.165169669117e-01 -2.158598741418e-01 -2.151765075019e-01 + -2.144669728436e-01 -2.137314917035e-01 -2.129704003968e-01 -2.121841483821e-01 + -2.113732959162e-01 -2.105385110171e-01 -2.096805657643e-01 -2.088003319618e-01 + -2.078987761994e-01 -2.069769543454e-01 -2.060360055126e-01 -2.050771455367e-01 + -2.041016600137e-01 -2.031108969411e-01 -2.021062590137e-01 -2.010891956219e-01 + -2.000611946063e-01 -1.990237738205e-01 -1.979784725550e-01 -1.969268428776e-01 + -1.958704409425e-01 -1.948108183233e-01 -1.937495134222e-01 -1.926880430083e-01 + -1.916278939346e-01 -1.905705150858e-01 -1.895173096023e-01 -1.884696274276e-01 + -1.874287582222e-01 -1.863959246844e-01 -1.853722763173e-01 -1.843588836761e-01 + -1.833567331280e-01 -1.823667221539e-01 -1.813896552157e-01 -1.804262402126e-01 + -1.794770855423e-01 -1.785426977825e-01 -1.776234800020e-01 -1.767197307079e-01 + -1.758316434314e-01 -1.749593069500e-01 -1.741027061414e-01 -1.732617234589e-01 + -1.724361410166e-01 -1.716256432660e-01 -1.708298202458e-01 -1.700481713799e-01 + -1.692801097974e-01 -1.685249671453e-01 -1.677819988611e-01 -1.670503898697e-01 + -1.663292606680e-01 -1.656176737570e-01 -1.649146403799e-01 -1.642191275233e-01 + -1.635300651373e-01 -1.628463535283e-01 -1.621668708785e-01 -1.614904808458e-01 + -1.608160401959e-01 -1.601424064214e-01 -1.594684452990e-01 -1.587930383416e-01 + -1.581150900972e-01 -1.574335352539e-01 -1.567473455058e-01 -1.560555361414e-01 + -1.553571723131e-01 -1.546513749544e-01 -1.539373263077e-01 -1.532142750324e-01 + -1.524815408637e-01 -1.517385187968e-01 -1.509846827728e-01 -1.502195888465e-01 + -1.494428778197e-01 -1.486542773268e-01 -1.478536033625e-01 -1.470407612462e-01 + -1.462157460186e-01 -1.453786422729e-01 -1.445296234235e-01 -1.436689504200e-01 + -1.427969699176e-01 -1.419141119176e-01 -1.410208868957e-01 -1.401178824382e-01 + -1.392057594094e-01 -1.382852476765e-01 -1.373571414199e-01 -1.364222940610e-01 + -1.354816128392e-01 -1.345360530754e-01 -1.335866121565e-01 -1.326343232816e-01 + -1.316802490079e-01 -1.307254746382e-01 -1.297711014920e-01 -1.288182401004e-01 + -1.278680033690e-01 -1.269214997512e-01 -1.259798264725e-01 -1.250440628491e-01 + -1.241152637407e-01 -1.231944531781e-01 -1.222826182036e-01 -1.213807029615e-01 + -1.204896030750e-01 -1.196101603416e-01 -1.187431577798e-01 -1.178893150558e-01 + -1.170492843167e-01 -1.162236464545e-01 -1.154129078230e-01 -1.146174974243e-01 + -1.138377645830e-01 -1.130739771182e-01 -1.123263200242e-01 -1.115948946659e-01 + -1.108797184913e-01 -1.101807252617e-01 -1.094977657963e-01 -1.088306092237e-01 + -1.081789447325e-01 -1.075423838067e-01 -1.069204629317e-01 -1.063126467520e-01 + -1.057183316588e-01 -1.051368497861e-01 -1.045674733867e-01 -1.040094195616e-01 + -1.034618553116e-01 -1.029239028794e-01 -1.023946453480e-01 -1.018731324599e-01 + -1.013583866214e-01 -1.008494090529e-01 -1.003451860488e-01 -9.984469530635e-02 + -9.934691228511e-02 -9.885081655779e-02 -9.835539811317e-02 -9.785966357267e-02 + -9.736264228232e-02 -9.686339224335e-02 -9.636100584524e-02 -9.585461536651e-02 + -9.534339821039e-02 -9.482658184372e-02 -9.430344840978e-02 -9.377333898760e-02 + -9.323565747272e-02 -9.268987405661e-02 -9.213552828457e-02 -9.157223167475e-02 + -9.099966988322e-02 -9.041760440345e-02 -8.982587379098e-02 -8.922439440716e-02 + -8.861316067895e-02 -8.799224487455e-02 -8.736179639766e-02 -8.672204060623e-02 + -8.607327716429e-02 -8.541587793847e-02 -8.475028445345e-02 -8.407700492325e-02 + -8.339661087801e-02 -8.270973340809e-02 -8.201705904985e-02 -8.131932533933e-02 + -8.061731606233e-02 -7.991185623101e-02 -7.920380681863e-02 -7.849405928578e-02 + -7.778352993221e-02 -7.707315410983e-02 -7.636388033277e-02 -7.565666432118e-02 + -7.495246301588e-02 -7.425222860060e-02 -7.355690256896e-02 -7.286740987259e-02 + -7.218465318639e-02 -7.150950732601e-02 -7.084281385174e-02 -7.018537589158e-02 + -6.953795321511e-02 -6.890125758787e-02 -6.827594843441e-02 -6.766262883596e-02 + -6.706184188687e-02 -6.647406743135e-02 -6.589971920003e-02 -6.533914236294e-02 + -6.479261151330e-02 -6.426032909359e-02 -6.374242427268e-02 -6.323895228008e-02 + -6.274989420036e-02 -6.227515722821e-02 -6.181457538156e-02 -6.136791066736e-02 + -6.093485469211e-02 -6.051503070615e-02 -6.010799606826e-02 -5.971324511462e-02 + -5.933021241354e-02 -5.895827638510e-02 -5.859676326279e-02 -5.824495137181e-02 + -5.790207569719e-02 -5.756733271290e-02 -5.723988544151e-02 -5.691886871294e-02 + -5.660339458914e-02 -5.629255792112e-02 -5.598544200347e-02 -5.568112429147e-02 + -5.537868214503e-02 -5.507719856411e-02 -5.477576787990e-02 -5.447350136674e-02 + -5.416953274002e-02 -5.386302350631e-02 -5.355316813253e-02 -5.323919900273e-02 + -5.292039113168e-02 -5.259606660662e-02 -5.226559872992e-02 -5.192841583729e-02 + -5.158400476822e-02 -5.123191396769e-02 -5.087175620014e-02 -5.050321085940e-02 + -5.012602586062e-02 -4.974001910291e-02 -4.934507949390e-02 -4.894116753052e-02 + -4.852831543246e-02 -4.810662682810e-02 -4.767627599506e-02 -4.723750666042e-02 + -4.679063036846e-02 -4.633602442617e-02 -4.587412943961e-02 -4.540544645667e-02 + -4.493053373399e-02 -4.445000314847e-02 -4.396451627563e-02 -4.347478015932e-02 + -4.298154279907e-02 -4.248558838326e-02 -4.198773229754e-02 -4.148881593965e-02 + -4.098970137276e-02 -4.049126585042e-02 -3.999439624720e-02 -3.949998342938e-02 + -3.900891660067e-02 -3.852207765799e-02 -3.804033559219e-02 -3.756454096847e-02 + -3.709552052070e-02 -3.663407189310e-02 -3.618095856188e-02 -3.573690496837e-02 + -3.530259189383e-02 -3.487865210461e-02 -3.446566629484e-02 -3.406415935180e-02 + -3.367459696729e-02 -3.329738261618e-02 -3.293285492101e-02 -3.258128541928e-02 + -3.224287674747e-02 -3.191776125334e-02 -3.160600004545e-02 -3.130758248621e-02 + -3.102242613197e-02 -3.075037712086e-02 -3.049121100666e-02 -3.024463403384e-02 + -3.001028484654e-02 -2.978773662133e-02 -2.957649961123e-02 -2.937602408583e-02 + -2.918570364980e-02 -2.900487891999e-02 -2.883284153897e-02 -2.866883850065e-02 + -2.851207676207e-02 -2.836172811322e-02 -2.821693427547e-02 -2.807681219758e-02 + -2.794045951709e-02 -2.780696015387e-02 -2.767539000166e-02 -2.754482268274e-02 + -2.741433533076e-02 -2.728301436604e-02 -2.714996122805e-02 -2.701429802975e-02 + -2.687517309904e-02 -2.673176637293e-02 -2.658329461132e-02 -2.642901639774e-02 + -2.626823689621e-02 -2.610031233427e-02 -2.592465418425e-02 -2.574073301636e-02 + -2.554808199911e-02 -2.534630002494e-02 -2.513505444066e-02 -2.491408336509e-02 + -2.468319757853e-02 -2.444228197111e-02 -2.419129654013e-02 -2.393027692850e-02 + -2.365933449986e-02 -2.337865594821e-02 -2.308850244281e-02 -2.278920831204e-02 + -2.248117927242e-02 -2.216489021197e-02 -2.184088253950e-02 -2.150976111438e-02 + -2.117219077357e-02 -2.082889247518e-02 -2.048063908047e-02 -2.012825079787e-02 + -1.977259031513e-02 -1.941455764743e-02 -1.905508473103e-02 -1.869512979362e-02 + -1.833567153412e-02 -1.797770314545e-02 -1.762222621544e-02 -1.727024454121e-02 + -1.692275789348e-02 -1.658075576729e-02 -1.624521115604e-02 -1.591707438558e-02 + -1.559726704482e-02 -1.528667604908e-02 -1.498614787135e-02 -1.469648297606e-02 + -1.441843048879e-02 -1.415268313393e-02 -1.389987247105e-02 -1.366056445881e-02 + -1.343525537381e-02 -1.322436810926e-02 -1.302824887671e-02 -1.284716433160e-02 + -1.268129914080e-02 -1.253075400823e-02 -1.239554417166e-02 -1.227559838124e-02 + -1.217075836756e-02 -1.208077880421e-02 -1.200532776672e-02 -1.194398768716e-02 + -1.189625680016e-02 -1.186155107347e-02 -1.183920661233e-02 -1.182848252393e-02 + -1.182856422366e-02 -1.183856716099e-02 -1.185754093687e-02 -1.188447377830e-02 + -1.191829732706e-02 -1.195789168909e-02 -1.200209067673e-02 -1.204968715833e-02 + -1.209943840630e-02 -1.215007130625e-02 -1.220028725426e-02 -1.224876652818e-02 + -1.229417187213e-02 -1.233515098480e-02 -1.237033755583e-02 -1.239835045939e-02 + -1.241779070038e-02 -1.242723573197e-02 -1.242523084214e-02 -1.241027746188e-02 + -1.238081850111e-02 -1.233522118866e-02 -1.227175839268e-02 -1.218859002675e-02 + -1.208374688581e-02 -1.195512006101e-02 -1.180045987933e-02 -1.161738899598e-02 + -1.140343469983e-02 -1.115608551522e-02 -1.087287663337e-02 -1.055150743420e-02 + -1.018999225887e-02 -9.786842636481e-03 -9.341275432695e-03 -8.853437083322e-03 + -8.324629554625e-03 -7.757519422508e-03 -7.156308076494e-03 -6.526839170932e-03 + -5.876619671647e-03 -5.214733660413e-03 -4.551633714403e-03 -3.898803112012e-03 + -3.268292897218e-03 -2.672150143947e-03 -2.121766438798e-03 -1.627187242489e-03 + -1.196431908000e-03 -8.348793414504e-04 -5.447745126481e-04 -3.249056704027e-04 + -1.704912337315e-04 -7.329963822255e-05 -2.200628869199e-05 -2.771091616120e-06 + 0.000000000000e+00 + Type L N + 0 2 0 + 0.000000000000e+00 -3.343626342662e-04 -1.336837154607e-03 -3.005584903671e-03 + -5.337546547975e-03 -8.328449682246e-03 -1.197281945274e-02 -1.626399216017e-02 + -2.119413180214e-02 -2.675424950468e-02 -3.293422578324e-02 -3.972283556741e-02 + -4.710777591292e-02 -5.507569631817e-02 -6.361223155362e-02 -7.270203690572e-02 + -8.232882572951e-02 -9.247540919759e-02 -1.031237381265e-01 -1.142549467555e-01 + -1.258493983485e-01 -1.378867324813e-01 -1.503459138772e-01 -1.632052826437e-01 + -1.764426057637e-01 -1.900351296900e-01 -2.039596338880e-01 -2.181924851715e-01 + -2.327096926724e-01 -2.474869632865e-01 -2.624997574346e-01 -2.777233449784e-01 + -2.931328611333e-01 -3.087033622181e-01 -3.244098810844e-01 -3.402274820706e-01 + -3.561313153280e-01 -3.720966703679e-01 -3.880990286845e-01 -4.041141153094e-01 + -4.201179491604e-01 -4.360868920511e-01 -4.519976962312e-01 -4.678275503368e-01 + -4.835541236322e-01 -4.991556084334e-01 -5.146107606085e-01 -5.298989380595e-01 + -5.450001370934e-01 -5.598950266029e-01 -5.745649799796e-01 -5.889921046952e-01 + -6.031592694904e-01 -6.170501291222e-01 -6.306491466272e-01 -6.439416130674e-01 + -6.569136647327e-01 -6.695522977849e-01 -6.818453803336e-01 -6.937816619452e-01 + -7.053507805935e-01 -7.165432670680e-01 -7.273505468671e-01 -7.377649396064e-01 + -7.477796559861e-01 -7.573887923636e-01 -7.665873229882e-01 -7.753710899610e-01 + -7.837367909893e-01 -7.916819650125e-01 -7.992049757811e-01 -8.063049934769e-01 + -8.129819744702e-01 -8.192366393094e-01 -8.250704490495e-01 -8.304855800252e-01 + -8.354848971804e-01 -8.400719260699e-01 -8.442508236491e-01 -8.480263479737e-01 + -8.514038269297e-01 -8.543891261192e-01 -8.569886160244e-01 -8.592091385765e-01 + -8.610579732544e-01 -8.625428028381e-01 -8.636716789393e-01 -8.644529874351e-01 + -8.648954139221e-01 -8.650079093126e-01 -8.647996556872e-01 -8.642800325178e-01 + -8.634585833709e-01 -8.623449831963e-01 -8.609490063045e-01 -8.592804951284e-01 + -8.573493298636e-01 -8.551653990737e-01 -8.527385713425e-01 -8.500786680519e-01 + -8.471954373523e-01 -8.440985293945e-01 -8.407974728780e-01 -8.373016529705e-01 + -8.336202906425e-01 -8.297624234571e-01 -8.257368878476e-01 -8.215523029081e-01 + -8.172170557172e-01 -8.127392882070e-01 -8.081268855835e-01 -8.033874662982e-01 + -7.985283735640e-01 -7.935566684020e-01 -7.884791242011e-01 -7.833022227637e-01 + -7.780321518080e-01 -7.726748038897e-01 -7.672357767027e-01 -7.617203747098e-01 + -7.561336120554e-01 -7.504802167010e-01 -7.447646357266e-01 -7.389910417321e-01 + -7.331633402733e-01 -7.272851782609e-01 -7.213599532512e-01 -7.153908235516e-01 + -7.093807190655e-01 -7.033323527959e-01 -6.972482329292e-01 -6.911306754180e-01 + -6.849818169812e-01 -6.788036284404e-01 -6.725979283113e-01 -6.663663965707e-01 + -6.601105885181e-01 -6.538319486556e-01 -6.475318245087e-01 -6.412114803151e-01 + -6.348721105083e-01 -6.285148529281e-01 -6.221408016911e-01 -6.157510196589e-01 + -6.093465504440e-01 -6.029284298983e-01 -5.964976970317e-01 -5.900554043133e-01 + -5.836026273123e-01 -5.771404736385e-01 -5.706700911490e-01 -5.641926753898e-01 + -5.577094762487e-01 -5.512218037973e-01 -5.447310333076e-01 -5.382386094324e-01 + -5.317460495410e-01 -5.252549462125e-01 -5.187669688857e-01 -5.122838646765e-01 + -5.058074583733e-01 -4.993396516261e-01 -4.928824213526e-01 -4.864378173819e-01 + -4.800079593679e-01 -4.735950330014e-01 -4.672012855581e-01 -4.608290208195e-01 + -4.544805934091e-01 -4.481584025867e-01 -4.418648855484e-01 -4.356025102794e-01 + -4.293737680101e-01 -4.231811653276e-01 -4.170272159956e-01 -4.109144325344e-01 + -4.048453176194e-01 -3.988223553477e-01 -3.928480024327e-01 -3.869246793767e-01 + -3.810547616785e-01 -3.752405711272e-01 -3.694843672348e-01 -3.637883388583e-01 + -3.581545960596e-01 -3.525851622505e-01 -3.470819666678e-01 -3.416468372203e-01 + -3.362814937487e-01 -3.309875417352e-01 -3.257664664965e-01 -3.206196278925e-01 + -3.155482555784e-01 -3.105534448246e-01 -3.056361529269e-01 -3.007971962230e-01 + -2.960372477322e-01 -2.913568354266e-01 -2.867563411432e-01 -2.822360001380e-01 + -2.777959012850e-01 -2.734359879143e-01 -2.691560592826e-01 -2.649557726669e-01 + -2.608346460667e-01 -2.567920614966e-01 -2.528272688523e-01 -2.489393903234e-01 + -2.451274253294e-01 -2.413902559506e-01 -2.377266528210e-01 -2.341352814527e-01 + -2.306147089543e-01 -2.271634111079e-01 -2.237797797652e-01 -2.204621305236e-01 + -2.172087106397e-01 -2.140177071397e-01 -2.108872550835e-01 -2.078154459384e-01 + -2.048003360207e-01 -2.018399549607e-01 -1.989323141484e-01 -1.960754151182e-01 + -1.932672578291e-01 -1.905058488019e-01 -1.877892090725e-01 -1.851153819227e-01 + -1.824824403534e-01 -1.798884942646e-01 -1.773316973091e-01 -1.748102533895e-01 + -1.723224227703e-01 -1.698665277787e-01 -1.674409580705e-01 -1.650441754402e-01 + -1.626747181578e-01 -1.603312048155e-01 -1.580123376728e-01 -1.557169054900e-01 + -1.534437858432e-01 -1.511919469166e-01 -1.489604487725e-01 -1.467484440982e-01 + -1.445551784381e-01 -1.423799899146e-01 -1.402223084519e-01 -1.380816545125e-01 + -1.359576373628e-01 -1.338499528870e-01 -1.317583809666e-01 -1.296827824501e-01 + -1.276230957362e-01 -1.255793329962e-01 -1.235515760637e-01 -1.215399720218e-01 + -1.195447285159e-01 -1.175661088266e-01 -1.156044267334e-01 -1.136600412031e-01 + -1.117333509371e-01 -1.098247888115e-01 -1.079348162442e-01 -1.060639175244e-01 + -1.042125941364e-01 -1.023813591143e-01 -1.005707314578e-01 -9.878123064275e-02 + -9.701337125784e-02 -9.526765779625e-02 -9.354457963214e-02 -9.184460620859e-02 + -9.016818246269e-02 -8.851572451171e-02 -8.688761562231e-02 -8.528420248277e-02 + -8.370579179616e-02 -8.215264721034e-02 -8.062498659825e-02 -7.912297969974e-02 + -7.764674613412e-02 -7.619635378974e-02 -7.477181759514e-02 -7.337309867347e-02 + -7.200010387990e-02 -7.065268571912e-02 -6.933064263796e-02 -6.803371968591e-02 + -6.676160953406e-02 -6.551395384105e-02 -6.429034495247e-02 -6.309032791849e-02 + -6.191340281251e-02 -6.075902733211e-02 -5.962661966204e-02 -5.851556157749e-02 + -5.742520176494e-02 -5.635485933641e-02 -5.530382751238e-02 -5.427137744758e-02 + -5.325676217347e-02 -5.225922063068e-02 -5.127798176446e-02 -5.031226865597e-02 + -4.936130266255e-02 -4.842430754004e-02 -4.750051352083e-02 -4.658916132185e-02 + -4.568950605718e-02 -4.480082103116e-02 -4.392240138864e-02 -4.305356760016e-02 + -4.219366876109e-02 -4.134208568535e-02 -4.049823377542e-02 -3.966156565219e-02 + -3.883157352997e-02 -3.800779132324e-02 -3.718979647415e-02 -3.637721149118e-02 + -3.556970519142e-02 -3.476699364092e-02 -3.396884078953e-02 -3.317505879834e-02 + -3.238550806028e-02 -3.160009691578e-02 -3.081878106792e-02 -3.004156270276e-02 + -2.926848932289e-02 -2.849965230358e-02 -2.773518518292e-02 -2.697526169857e-02 + -2.622009358570e-02 -2.546992815167e-02 -2.472504564458e-02 -2.398575643389e-02 + -2.325239802234e-02 -2.252533190942e-02 -2.180494032745e-02 -2.109162287172e-02 + -2.038579304718e-02 -1.968787475392e-02 -1.899829873448e-02 -1.831749900579e-02 + -1.764590929849e-02 -1.698395952636e-02 -1.633207230820e-02 -1.569065956384e-02 + -1.506011920558e-02 -1.444083194557e-02 -1.383315823866e-02 -1.323743537947e-02 + -1.265397477111e-02 -1.208305938198e-02 -1.152494140576e-02 -1.097984013816e-02 + -1.044794008281e-02 -9.929389296949e-03 -9.424297986017e-03 -8.932737354798e-03 + -8.454738720835e-03 -7.990292894352e-03 -7.539349827129e-03 -7.101818531054e-03 + -6.677567265404e-03 -6.266423990178e-03 -5.868177081158e-03 -5.482576300744e-03 + -5.109334017007e-03 -4.748126661889e-03 -4.398596418013e-03 -4.060353122176e-03 + -3.732976372278e-03 -3.416017823244e-03 -3.109003656357e-03 -2.811437205408e-03 + -2.522801722167e-03 -2.242563262875e-03 -1.970173676792e-03 -1.705073677284e-03 + -1.446695975487e-03 -1.194468456330e-03 -9.478173764667e-04 -7.061705636916e-04 + -4.689605974468e-04 -2.356279502815e-04 -5.624070443108e-06 2.215856137444e-04 + 4.465187864809e-04 6.696734521357e-04 8.915252751909e-04 1.112525068831e-03 + 1.333096447502e-03 1.553633657665e-03 1.774499599783e-03 1.996024053307e-03 + 2.218502115094e-03 2.442192860297e-03 2.667318233328e-03 2.894062174991e-03 + 3.122569990378e-03 3.352947960583e-03 3.585263199706e-03 3.819543757117e-03 + 4.055778963323e-03 4.293920016333e-03 4.533880803833e-03 4.775538955066e-03 + 5.018737114848e-03 5.263284430803e-03 5.508958243561e-03 5.755505968455e-03 + 6.002647156047e-03 6.250075717768e-03 6.497462301937e-03 6.744456804555e-03 + 6.990690998455e-03 7.235781263722e-03 7.479331401700e-03 7.720935514475e-03 + 7.960180931322e-03 8.196651163443e-03 8.429928868145e-03 8.659598803677e-03 + 8.885250756012e-03 9.106482419171e-03 9.322902210975e-03 9.534132006645e-03 + 9.739809773209e-03 9.939592088387e-03 1.013315652839e-02 1.032020390999e-02 + 1.050046037311e-02 1.067367929138e-02 1.083964299904e-02 1.099816432397e-02 + 1.114908791773e-02 1.129229137491e-02 1.142768613538e-02 1.155521816451e-02 + 1.167486840766e-02 1.178665301699e-02 1.189062334975e-02 1.198686573886e-02 + 1.207550103810e-02 1.215668394523e-02 1.223060210846e-02 1.229747502216e-02 + 1.235755271998e-02 1.241111427384e-02 1.245846610930e-02 1.249994014833e-02 + 1.253589179188e-02 1.256669775556e-02 1.259275377257e-02 1.261447217886e-02 + 1.263227939621e-02 1.264661332954e-02 1.265792069506e-02 1.266665429669e-02 + 1.267327026786e-02 1.267822529655e-02 1.268197385112e-02 1.268496542450e-02 + 1.268764181424e-02 1.269043445550e-02 1.269376182389e-02 1.269802692425e-02 + 1.270361488126e-02 1.271089064677e-02 1.272019683810e-02 1.273185172070e-02 + 1.274614734761e-02 1.276334786702e-02 1.278368800834e-02 1.280737175581e-02 + 1.283457121768e-02 1.286542569759e-02 1.290004097353e-02 1.293848878846e-02 + 1.298080655521e-02 1.302699727721e-02 1.307702968475e-02 1.313083858562e-02 + 1.318832542729e-02 1.324935906660e-02 1.331377674153e-02 1.338138523858e-02 + 1.345196224768e-02 1.352525789593e-02 1.360099644967e-02 1.367887817415e-02 + 1.375858133831e-02 1.383976435191e-02 1.392206802105e-02 1.400511790768e-02 + 1.408852677781e-02 1.417189712294e-02 1.425482373845e-02 1.433689634259e-02 + 1.441770221955e-02 1.449682886970e-02 1.457386665042e-02 1.464841139079e-02 + 1.472006696371e-02 1.478844779938e-02 1.485318132444e-02 1.491391031148e-02 + 1.497029512441e-02 1.502201584577e-02 1.506877427283e-02 1.511029577033e-02 + 1.514633096835e-02 1.517665729523e-02 1.520108033617e-02 1.521943500936e-02 + 1.523158655287e-02 1.523743131645e-02 1.523689735383e-02 1.522994481228e-02 + 1.521656611768e-02 1.519678595426e-02 1.517066104006e-02 1.513827969981e-02 + 1.509976123868e-02 1.505525512150e-02 1.500493996308e-02 1.494902233675e-02 + 1.488773540916e-02 1.482133741048e-02 1.475010995040e-02 1.467435619093e-02 + 1.459439888821e-02 1.451057831614e-02 1.442325008548e-02 1.433278287269e-02 + 1.423955607319e-02 1.414395739449e-02 1.404638040462e-02 1.394722205179e-02 + 1.384688017131e-02 1.374575099580e-02 1.364422668469e-02 1.354269288897e-02 + 1.344152636660e-02 1.334109266410e-02 1.324174387886e-02 1.314381651665e-02 + 1.304762945779e-02 1.295348204502e-02 1.286165230509e-02 1.277239531539e-02 + 1.268594172582e-02 1.260249644524e-02 1.252223750064e-02 1.244531507624e-02 + 1.237185073831e-02 1.230193685046e-02 1.223563618299e-02 1.217298171836e-02 + 1.211397665396e-02 1.205859460168e-02 1.200677998284e-02 1.195844861567e-02 + 1.191348849118e-02 1.187176073223e-02 1.183310072929e-02 1.179731944541e-02 + 1.176420488159e-02 1.173352369290e-02 1.170502294478e-02 1.167843199771e-02 + 1.165346450811e-02 1.162982053213e-02 1.160718871857e-02 1.158524857654e-02 + 1.156367280306e-02 1.154212965511e-02 1.152028535082e-02 1.149780648386e-02 + 1.147436243525e-02 1.144962776679e-02 1.142328458018e-02 1.139502482655e-02 + 1.136455255094e-02 1.133158605705e-02 1.129585997790e-02 1.125712723852e-02 + 1.121516089784e-02 1.116975585722e-02 1.112073042436e-02 1.106792772183e-02 + 1.101121693077e-02 1.095049436119e-02 1.088568434131e-02 1.081673991978e-02 + 1.074364337555e-02 1.066640653153e-02 1.058507086931e-02 1.049970744365e-02 + 1.041041659643e-02 1.031732747148e-02 1.022059733232e-02 1.012041068691e-02 + 1.001697822396e-02 9.910535567088e-03 9.801341854133e-03 9.689678149904e-03 + 9.575845701974e-03 9.460164049946e-03 9.342968999703e-03 9.224610474943e-03 + 9.105450259188e-03 8.985859642125e-03 8.866216984828e-03 8.746905218928e-03 + 8.628309295287e-03 8.510813598082e-03 8.394799340493e-03 8.280641958326e-03 + 8.168708518025e-03 8.059355155419e-03 7.952924561508e-03 7.849743531260e-03 + 7.750120591151e-03 7.654343720673e-03 7.562678182560e-03 7.475364475847e-03 + 7.392616425167e-03 7.314619418914e-03 7.241528808031e-03 7.173468476237e-03 + 7.110529591491e-03 7.052769547440e-03 7.000211102441e-03 6.952841722580e-03 + 6.910613133880e-03 6.873441087605e-03 6.841205341262e-03 6.813749856528e-03 + 6.790883213907e-03 6.772379242453e-03 6.757977861265e-03 6.747386127750e-03 + 6.740279485677e-03 6.736303203743e-03 6.735073992636e-03 6.736181785112e-03 + 6.739191659263e-03 6.743645879500e-03 6.749066022504e-03 6.754955146012e-03 + 6.760799946435e-03 6.766072836490e-03 6.770233856141e-03 6.772732309341e-03 + 6.773007995942e-03 6.770491884438e-03 6.764606049322e-03 6.754762681147e-03 + 6.740361973409e-03 6.720788705873e-03 6.695407387943e-03 6.663555908574e-03 + 6.624537771248e-03 6.577613182754e-03 6.521989517875e-03 6.456811997516e-03 + 6.381155784392e-03 6.294021095072e-03 6.194333312052e-03 6.080950401236e-03 + 5.952680131222e-03 5.808309573621e-03 5.646649058578e-03 5.466592095872e-03 + 5.267191701375e-03 5.047752081595e-03 4.807932768711e-03 4.547860173024e-03 + 4.268239306083e-03 3.970456368326e-03 3.656661280562e-03 3.329818380641e-03 + 2.993713697702e-03 2.652908684317e-03 2.312633146252e-03 1.978614320966e-03 + 1.656844398248e-03 1.353294841584e-03 1.073592084013e-03 8.226748497738e-04 + 6.044577664810e-04 4.215284098635e-04 2.749049451014e-04 1.638788182719e-04 + 8.596153714402e-05 3.694682421181e-05 1.109000226043e-05 1.396308876444e-06 + 0.000000000000e+00 \ No newline at end of file diff --git a/ABACUS.develop/examples/H2O-deepks/STRU b/ABACUS.develop/examples/H2O-deepks-pw/STRU similarity index 100% rename from ABACUS.develop/examples/H2O-deepks/STRU rename to ABACUS.develop/examples/H2O-deepks-pw/STRU diff --git a/ABACUS.develop/examples/H2O-deepks/descriptor.dat b/ABACUS.develop/examples/H2O-deepks-pw/descriptor.dat similarity index 100% rename from ABACUS.develop/examples/H2O-deepks/descriptor.dat rename to ABACUS.develop/examples/H2O-deepks-pw/descriptor.dat diff --git a/ABACUS.develop/examples/H2O-deepks/descriptor.dat.bak b/ABACUS.develop/examples/H2O-deepks-pw/descriptor.dat.bak similarity index 100% rename from ABACUS.develop/examples/H2O-deepks/descriptor.dat.bak rename to ABACUS.develop/examples/H2O-deepks-pw/descriptor.dat.bak diff --git a/ABACUS.develop/examples/H2O-deepks/logout.bak b/ABACUS.develop/examples/H2O-deepks-pw/logout.bak similarity index 100% rename from ABACUS.develop/examples/H2O-deepks/logout.bak rename to ABACUS.develop/examples/H2O-deepks-pw/logout.bak From 2ec0336d3fa74939cb25eedc1994958e872a2d0a Mon Sep 17 00:00:00 2001 From: mohanchen Date: Sun, 31 Jan 2021 09:12:07 +0800 Subject: [PATCH 045/233] update Makefile, move all of the .o files to obj/ --- ABACUS.develop/source/Makefile | 23 +++++++++++++---------- ABACUS.develop/source/Makefile.Objects | 2 +- ABACUS.develop/source/Makefile.vars | 8 +++++--- ABACUS.develop/source/obj/README | 1 + 4 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 ABACUS.develop/source/obj/README diff --git a/ABACUS.develop/source/Makefile b/ABACUS.develop/source/Makefile index 8bf15a37c7..6911072ef8 100644 --- a/ABACUS.develop/source/Makefile +++ b/ABACUS.develop/source/Makefile @@ -1,4 +1,5 @@ -# Makefile for plane wave basis code. +# This is the Makefile of ABACUS + include Makefile.system include Makefile.Objects @@ -45,7 +46,7 @@ OPTS_GDB = -g -W -I/home/mohan/software/boost_1_39_0/ #========================== # OBJECTS NEEDED #========================== -FP_OBJS=$(OBJS_OTHER)\ +FP_OBJS_0=$(OBJS_OTHER)\ $(OBJS_FIRST_PRINCIPLE)\ $(OBJS_PARALLEL)\ $(OBJS_TOOLS) \ @@ -56,15 +57,17 @@ $(OBJS_WANNIER)\ $(OBJS_COMMON)\ $(OBJS_MLWF)\ $(OBJS_EXX)\ -main.o \ +main.o\ -PDIAG_OBJS=$(OBJS_PDIAG)\ +FP_OBJS=$(patsubst %.o, ${OBJ_DIR}/%.o, ${FP_OBJS_0}) +PDIAG_OBJS=$(patsubst %.o, ${OBJ_DIR}/%.o, ${OBJS_PDIAG}) +PDIAG_MR=$(patsubst %.o, ${OBJ_DIR}/%.o, ${PDIAG_MR_0}) #========================== # MAKING OPTIONS #========================== -fp_mpi : ${FP_OBJS} ${PDIAG_MR} ${PDIAG_OBJS}$ ${HEADERS} - ${CPLUSPLUS_MPI} ${OPTS} ${OPTS_MPI} $(FP_OBJS) ${PDIAG_OBJS} ${PDIAG_MR} ${LIBS} -o ../bin/${VERSION}.mpi.1.0.0 +fp_mpi : ${FP_OBJS} ${PDIAG_OBJS} ${PDIAG_MR} ${HEADERS} + ${CPLUSPLUS_MPI} ${OPTS} ${OPTS_MPI} $(FP_OBJS) ${PDIAG_OBJS} ${PDIAG_MR} ${LIBS} -o ../bin/${VERSION}.mpi fp : ${FP_OBJS} ${HEADERS} ${CPLUSPLUS} ${OPTS} $(FP_OBJS) ${LIBS} -o ${VERSION}.fp.x @@ -81,11 +84,11 @@ fp_mem : ${FP_OBJS} ../src_parallel/mcd.o ${HEADERS} #========================== # rules #========================== -.cpp.o: +${OBJ_DIR}/%.o:%.cpp ${CPLUSPLUS_MPI} ${OPTS} ${OPTS_MPI} -c ${HONG} $< -o $@ -.f.o: - ${FORTRAN} ${OPTS} -c ${HONG} $< -o $@ +${OBJ_DIR}/%.o:%.f + ${FORTRAN} -c ${HONG} $< -o $@ .PHONY:clean clean: - $(RM) *.o ../bin/ABACUS* + $(RM) ${OBJ_DIR}/*.o ../bin/ABACUS* diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 7866a9e5ab..408699c5c3 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -295,7 +295,7 @@ pzt2s.o\ pdtrsm.o\ pzhtrsm.o\ -PDIAG_MR=dcopy.o\ +PDIAG_MR_0=dcopy.o\ dlae2.o\ dlaebz.o\ dlaev2.o\ diff --git a/ABACUS.develop/source/Makefile.vars b/ABACUS.develop/source/Makefile.vars index 31d2341967..ab69def452 100644 --- a/ABACUS.develop/source/Makefile.vars +++ b/ABACUS.develop/source/Makefile.vars @@ -11,15 +11,17 @@ LAPACK_DIR = $(MKLROOT) #LAPACK_DIR = $(MKLROOT) #LAPACK_DIR = /public/intel2017/mkl -FFTW_DIR = /home/qianrui/intelcompile/impi_fftw +FFTW_DIR = /home/mohan/1_Software/impi_fftw-3.3.8 #FFTW_DIR = /public/udata/xiaohui/software/fftw2 #FFTW_DIR =/opt/fftw/3.3.6-p12/intel/2017.update4 #FFTW_DIR = /public/fftw-3.3.8 -BOOST_DIR = /home/qianrui/intelcompile/impi_boost +BOOST_DIR = /home/mohan/1_Software/impi_boost-1.70.0 #BOOST_DIR = /public/udata/xiaohui/software/boost_1_39_0 #BOOST_DIR = /opt/boost/1.64.0 -ELPA_DIR=/home/qianrui/intelcompile/test/soft_epla +ELPA_DIR = /home/mohan/1_Software/impi_elpa-16.05.005 #ELPA_DIR = /public/udata/xiaohui/ELPA-2016.05.004 #ELPA_DIR = /opt/elpa/intel_2017_update4 + +OBJ_DIR = obj diff --git a/ABACUS.develop/source/obj/README b/ABACUS.develop/source/obj/README new file mode 100644 index 0000000000..3f49259cf9 --- /dev/null +++ b/ABACUS.develop/source/obj/README @@ -0,0 +1 @@ +This directory contains all of the .o files From 8851bf8f1226e06e25446016f8cce0e216b8763b Mon Sep 17 00:00:00 2001 From: mohanchen Date: Sun, 31 Jan 2021 09:31:11 +0800 Subject: [PATCH 046/233] delete useless exx funciton in pw --- ABACUS.develop/source/Makefile | 1 - ABACUS.develop/source/Makefile.Objects | 3 - ABACUS.develop/source/src_pw/electrons.cpp | 17 -- ABACUS.develop/source/src_pw/energy.cpp | 7 +- ABACUS.develop/source/src_pw/energy.h | 1 - ABACUS.develop/source/src_pw/exx.f90 | 229 -------------------- ABACUS.develop/source/src_pw/exx_div.cpp | 56 ----- ABACUS.develop/source/src_pw/exx_div.h | 25 --- ABACUS.develop/source/src_pw/exx_pw.cpp | 236 --------------------- ABACUS.develop/source/src_pw/exx_pw.h | 69 ------ ABACUS.develop/source/src_pw/global.cpp | 22 +- ABACUS.develop/source/src_pw/global.h | 77 +------ ABACUS.develop/source/src_pw/hamilt_pw.cpp | 6 - 13 files changed, 7 insertions(+), 742 deletions(-) delete mode 100644 ABACUS.develop/source/src_pw/exx.f90 delete mode 100644 ABACUS.develop/source/src_pw/exx_div.cpp delete mode 100644 ABACUS.develop/source/src_pw/exx_div.h delete mode 100644 ABACUS.develop/source/src_pw/exx_pw.cpp delete mode 100644 ABACUS.develop/source/src_pw/exx_pw.h diff --git a/ABACUS.develop/source/Makefile b/ABACUS.develop/source/Makefile index 6911072ef8..84cb01a8a7 100644 --- a/ABACUS.develop/source/Makefile +++ b/ABACUS.develop/source/Makefile @@ -56,7 +56,6 @@ $(OBJS_CG)\ $(OBJS_WANNIER)\ $(OBJS_COMMON)\ $(OBJS_MLWF)\ -$(OBJS_EXX)\ main.o\ FP_OBJS=$(patsubst %.o, ${OBJ_DIR}/%.o, ${FP_OBJS_0}) diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 408699c5c3..1bd8fa9c57 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -268,9 +268,6 @@ symm_other.o \ eximport.o \ Mulliken_Charge.o\ -OBJS_EXX=exx_pw.o\ -exx_div.o\ - #OBJS_MLWF=mlwf_kmesh.o\ mlwf_overlap.o\ mlwf_optimize.o\ diff --git a/ABACUS.develop/source/src_pw/electrons.cpp b/ABACUS.develop/source/src_pw/electrons.cpp index 200c38794e..3c4affc2a9 100644 --- a/ABACUS.develop/source/src_pw/electrons.cpp +++ b/ABACUS.develop/source/src_pw/electrons.cpp @@ -153,12 +153,6 @@ void electrons::self_consistent(const int &istep) // } // ### - // start the Exx calculation - if(DFT_FUNCTIONAL == "PBE0") - { - exxpw.init(true); - } - for (this->iter = 1;iter <= NITER;iter++) { ofs_running @@ -195,12 +189,6 @@ void electrons::self_consistent(const int &istep) // output the new eigenvalues and wave functions. this->c_bands(); - // mohan add 2010-07-22 - if(DFT_FUNCTIONAL == "PBE0") - { - exxpw.get_exx2(); - } - if (check_stop_now()) return; en.eband = 0.0; @@ -450,11 +438,6 @@ void electrons::c_bands(void) { hm.init_k(ik); - if(DFT_FUNCTIONAL == "PBE0") - { - exxpw.ik_now = ik; - } - //=========================================== // Conjugate-Gradient diagonalization // h_diag is the precondition matrix diff --git a/ABACUS.develop/source/src_pw/energy.cpp b/ABACUS.develop/source/src_pw/energy.cpp index a7f27621c7..808aa412f2 100644 --- a/ABACUS.develop/source/src_pw/energy.cpp +++ b/ABACUS.develop/source/src_pw/energy.cpp @@ -47,7 +47,6 @@ energy::energy() this->etxc = 0; // the exchange and correlation energy this->vtxc = 0; // another exchange-correlation energy this->etxcc = 0; // the nlcc exchange and correlation - this->exx = 0; // the exact exchange energy. this->ewld = 0; // the ewald energy this->demet = 0; // correction for metals @@ -72,7 +71,7 @@ void energy::calculate_harris(const int &flag) else if(flag==2) { this->etot_harris = eband + deband_harris + (etxc - etxcc) + ewld - + ehart + demet + exx + Efield::etotefield; + + ehart + demet + Efield::etotefield; if(INPUT.dft_plus_u) this->etot_harris += dftu.EU; //Energy correction from DFT+U; Quxin adds on 20201029 } @@ -86,7 +85,7 @@ void energy::calculate_etot(void) TITLE("energy","calculate_etot"); //cout << "\n demet in etot = " << demet << endl; this->etot = eband + deband + (etxc - etxcc) + ewld + - ehart + demet + descf + exx + Efield::etotefield; + ehart + demet + descf + Efield::etotefield; if(vdwd2.vdwD2) //Peize Lin add 2014-04-03, update 2019-04-26 { @@ -110,7 +109,6 @@ void energy::calculate_etot(void) cout << " ehart=" << ehart << endl; cout << " demet=" << demet << endl; cout << " descf=" << descf << endl; - cout << " exx=" << exx << endl; cout << " efiled=" << Efield::etotefield << endl; */ } @@ -153,7 +151,6 @@ bool print) { this->print_format("E_vdwD3",vdwd3.energy_result); } -// this->print_format("e_exx",exx); } else { diff --git a/ABACUS.develop/source/src_pw/energy.h b/ABACUS.develop/source/src_pw/energy.h index b7c65feb51..681d0b1827 100644 --- a/ABACUS.develop/source/src_pw/energy.h +++ b/ABACUS.develop/source/src_pw/energy.h @@ -51,7 +51,6 @@ class energy double etxc; // the exchange and correlation energy double vtxc; // another exchange-correlation energy double etxcc; // the nlcc exchange and correlation - double exx; // the exact exchange energy. double ewld; // the ewald energy double alpha; // the coefficient of ewald method diff --git a/ABACUS.develop/source/src_pw/exx.f90 b/ABACUS.develop/source/src_pw/exx.f90 deleted file mode 100644 index cdadbe973d..0000000000 --- a/ABACUS.develop/source/src_pw/exx.f90 +++ /dev/null @@ -1,229 +0,0 @@ - subroutine vexx(lda, n, m, psi, hpsi) - !band loop - temppsic(:) = ( 0.D0, 0.D0 ) - temppsic(nls(igk(1:npw))) = psi(1:npw,im) - CALL cft3s( temppsic, nr1s, nr2s, nr3s, nrx1s, nrx2s, nrx3s, 2 ) - - ! k point loop - do iqi=1,nqi - ! G loop - do ibnd=1,nbnd !for each band of psi - - !calculate rho in real space - rhoc(:)=CONJG(tempphic(:))*temppsic(:) / omega - !brings it to G-space - CALL cft3s( rhoc,nr1s, nr2s, nr3s, nrx1s, nrx2s, nrx3s, -1 ) - - vc(:) = ( 0.D0, 0.D0 ) - vc(nls(1:ngm)) = fac(1:ngm) * rhoc(nls(1:ngm)) - vc = vc * x_occupation(ibnd,ik) / nqs - - !brings back v in real space - CALL cft3s( vc, nr1s, nr2s, nr3s, nrx1s, nrx2s, nrx3s, 1 ) - - !accumulates over bands and k points - result(1:nrxxs)=result(1:nrxxs)+vc(1:nrxxs)*tempphic(1:nrxxs) - end do - end do - !write(*,*) result(1:10) - CALL mp_sum( result(1:nrxxs), inter_image_comm ) - !write(*,*) 'result is: ',result(1), result(nrxxs), nrxxs, my_image_id - !brings back result in G-space - CALL cft3s( result, nr1s, nr2s, nr3s, nrx1s, nrx2s, nrx3s, -2 ) - !adds it to hpsi - hpsi(1:npw,im)=hpsi(1:npw,im) - exxalfa*result(nls(igk(1:npw))) - - deallocate (tempphic,temppsic, result, rhoc, vc, fac ) - - call stop_clock ('vexx') - - end subroutine vexx - - function exxenergy () - ! This function is called to correct the deband value and have - ! the correct energy -! energy=0.d0 -! do ik=1,nks -! current_k = ik -! IF ( lsda ) current_spin = isk(ik) - ! npw = ngk (ik) - ! IF ( nks > 1 ) THEN - ! READ( iunigk ) igk - ! call get_buffer (psi, nwordwfc, iunwfc, ik) - ! ELSE - ! psi(1:npwx,1:nbnd) = evc(1:npwx,1:nbnd) - ! END IF - ! vxpsi(:,:) = (0.d0, 0.d0) - ! call vexx(npwx,npw,nbnd,psi,vxpsi) - do ibnd=1,nbnd - energy = energy + & - wg(ibnd,ik) * ZDOTC(npw,psi(1,ibnd),1,vxpsi(1,ibnd),1) - end do - if (gamma_only .and. gstart == 2) then - do ibnd=1,nbnd - energy = energy - & - 0.5d0 * wg(ibnd,ik) * CONJG(psi(1,ibnd)) * vxpsi(1,ibnd) - end do - end if - end do - - if (gamma_only) energy = 2.d0 * energy - - - call mp_sum( energy, intra_pool_comm ) - call mp_sum( energy, inter_pool_comm ) - - exxenergy = energy - - call stop_clock ('exxenergy') - end function exxenergy - - !----------------------------------------------------------------------- - function exxenergy2() - !----------------------------------------------------------------------- - energy=0.d0 - - tpiba2 = (fpi / 2.d0 / alat) **2 - - allocate (tempphic(nrxxs), temppsic(nrxxs), rhoc(nrxxs), fac(ngm) ) - - nqi=nqs/nimage - - IF ( nks > 1 ) REWIND( iunigk ) - do ikk=1,nks - current_k = ikk - IF ( lsda ) current_spin = isk(ikk) - npw = ngk (ikk) - IF ( nks > 1 ) THEN - READ( iunigk ) igk - call get_buffer (evc, nwordwfc, iunwfc, ikk) - END IF - - do jbnd=1, nbnd !for each band of psi (the k cycle is outside band) - temppsic(:) = ( 0.D0, 0.D0 ) - temppsic(nls(igk(1:npw))) = evc(1:npw,jbnd) - - CALL cft3s( temppsic, nr1s, nr2s, nr3s, nrx1s, nrx2s, nrx3s, 2 ) - - do iqi=1,nqi - iq=iqi+nqi*my_image_id - ikq = index_xkq(current_k,iq) - ik = index_xk(ikq) - isym = abs(index_sym(ikq)) - - xk_cryst(:)=at(1,:)*xk(1,ik)+at(2,:)*xk(2,ik)+at(3,:)*xk(3,ik) - if (index_sym(ikq) < 0 ) xk_cryst = - xk_cryst - sxk(:) = s(:,1,isym)*xk_cryst(1) + & - s(:,2,isym)*xk_cryst(2) + & - s(:,3,isym)*xk_cryst(3) - xkq(:) = bg(:,1)*sxk(1) + bg(:,2)*sxk(2) + bg(:,3)*sxk(3) - - do ig=1,ngm - q(1)= xk(1,current_k) - xkq(1) + g(1,ig) - q(2)= xk(2,current_k) - xkq(2) + g(2,ig) - q(3)= xk(3,current_k) - xkq(3) + g(3,ig) - qq = ( q(1)*q(1) + q(2)*q(2) + q(3)*q(3) ) - if (qq.gt.1.d-8) then - fac(ig)=e2*fpi/(tpiba2*qq + yukawa ) * grid_factor - if (gamma_only) fac(ig) = 2.d0 * fac(ig) - if (on_double_grid) fac(ig) = 0.d0 - else - fac(ig)= - exxdiv ! & ! or rather something else (see F.Gygi) - ! - e2*fpi ! THIS ONLY APPLYS TO HYDROGEN - if (yukawa.gt.1.d-8 .and. .not. x_gamma_extrapolation) then - fac(ig) = fac(ig) + e2*fpi/(tpiba2*qq + yukawa ) - end if - end if - end do - - do ibnd=1,nbnd !for each band of psi - if ( abs(x_occupation(ibnd,ik)) < 1.d-6) cycle - do ji=1, nrxxs - tempphic(ji)=exxbuff(ji,ikq,ibnd) - enddo - !calculate rho in real space - rhoc(:)=CONJG(tempphic(:))*temppsic(:) / omega - !brings it to G-space - CALL cft3s( rhoc,nr1s, nr2s, nr3s, nrx1s, nrx2s, nrx3s, -1 ) - vc = 0.D0 - do ig=1,ngm - vc = vc + fac(ig) * rhoc(nls(ig)) * CONJG(rhoc(nls(ig))) - end do - vc = vc * omega * x_occupation(ibnd,ik) / nqs - energy = energy - exxalfa * vc * wg(jbnd,ikk) - end do - end do - end do - end do - - deallocate (tempphic, temppsic, rhoc, fac ) - - call mp_sum( energy, inter_image_comm ) - call mp_sum( energy, intra_pool_comm ) - call mp_sum( energy, inter_pool_comm ) - - exxenergy2 = energy - - call stop_clock ('exxen2') - - end function exxenergy2 - - function exx_divergence () - - alpha = 10.d0 * tpiba2 / ecutwfc - - dq1= 1.d0/DBLE(nq1) - dq2= 1.d0/DBLE(nq2) - dq3= 1.d0/DBLE(nq3) - - div = 0.d0 - do iq1=1,nq1 - do iq2=1,nq2 - do iq3=1,nq3 - xq(:) = bg(:,1) * (iq1-1) * dq1 + & - bg(:,2) * (iq2-1) * dq2 + & - bg(:,3) * (iq3-1) * dq3 - do ig=1,ngm - q(1)= xq(1) + g(1,ig) - q(2)= xq(2) + g(2,ig) - q(3)= xq(3) + g(3,ig) - qq = ( q(1)*q(1) + q(2)*q(2) + q(3)*q(3) ) - if (.not.on_double_grid) then - if ( qq.gt.1.d-8 .or. yukawa .gt. 1.d-8) then - div = div + exp( -alpha * qq) / (qq + yukawa/tpiba2) & - * grid_factor - else - div = div - alpha ! or maybe something else - end if - end if - end do - end do - end do - end do - call mp_sum( div, intra_pool_comm ) - - div = div * e2 * fpi / tpiba2 / nqs - alpha = alpha / tpiba2 - nqq = 100000 - dq = 5.0d0 / sqrt(alpha) /nqq - aa = 0.d0 - do iq=0, nqq - q_ = dq * (iq+0.5d0) - qq = q_ * q_ - aa = aa - exp( -alpha * qq) * yukawa / (qq + yukawa) * dq - end do - aa = aa * 8.d0 /fpi - aa = aa + 1.d0/sqrt(alpha*0.25d0*fpi) - write (stdout,*) aa, 1.d0/sqrt(alpha*0.25d0*fpi) - - div = div - e2*omega * aa -! div = div - e2*omega/sqrt(alpha*0.25d0*fpi) - exx_divergence = div * nqs - write (stdout,'(a,i4,a,3f12.4)') 'EXX divergence (',nq1,')= ', & - div, alpha - - return - end function exx_divergence - - -end module exx diff --git a/ABACUS.develop/source/src_pw/exx_div.cpp b/ABACUS.develop/source/src_pw/exx_div.cpp deleted file mode 100644 index b8d823757f..0000000000 --- a/ABACUS.develop/source/src_pw/exx_div.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "exx_div.h" -#include "global.h" - -Exx_Divergence::Exx_Divergence() -{ - this->factor = new double[1]; -} - -Exx_Divergence::~Exx_Divergence() -{ - delete[] factor; -} - -void Exx_Divergence::init(void) -{ - // default : use gamma_extrapolation - - this->gamma_extra = true; - - if(this->gamma_extra) - { - this->grid_fac = 8.0 / 7.0; - } - else - { - this->grid_fac = 1.0; - } - return; -} - -// set the factor = 1/|G + k - q|^2 -// and then deal with the divergence term. -void Exx_Divergence::get_factor(const int &ik, const int &iq) -{ - delete[] factor; - this->factor = new double[wf.npw]; - - static double e2 = 2.0; // in Rydberg unit. - const double multi = e2 * FOUR_PI / ucell.tpiba2; - - if(pw.gstart==1) - { - factor[0] = 141.966625802957; // tmp - //factor[0] = 0.0; - } - - for(int ig=pw.gstart; igfactor[ig] = multi / ( pw.gcar[ig] + kv.kvec_c[ik] - kv.kvec_c[iq] ).norm2() * grid_fac; - // cout << " ig=" << ig << " factor=" << factor[ig] << endl; - } - //QUIT(); - - - return; -} diff --git a/ABACUS.develop/source/src_pw/exx_div.h b/ABACUS.develop/source/src_pw/exx_div.h deleted file mode 100644 index f8311e7730..0000000000 --- a/ABACUS.develop/source/src_pw/exx_div.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef EXX_DIV_H -#define EXX_DIV_H - -class Exx_Divergence -{ - public: - - Exx_Divergence(); - ~Exx_Divergence(); - - void init(void); - void get_factor(const int &ik, const int &iq); - - - double* factor; - - private: - - bool gamma_extra; - double grid_fac; - - -}; - -#endif diff --git a/ABACUS.develop/source/src_pw/exx_pw.cpp b/ABACUS.develop/source/src_pw/exx_pw.cpp deleted file mode 100644 index 0b8a3f6f4c..0000000000 --- a/ABACUS.develop/source/src_pw/exx_pw.cpp +++ /dev/null @@ -1,236 +0,0 @@ -#include "exx_pw.h" -#include "global.h" - -Exx_pw::Exx_pw() -{ - ik_now = 0; - alpha = 0.0; - start = false; -} - -Exx_pw::~Exx_pw() -{} - -void Exx_pw::init(bool start_in) -{ - TITLE("Exx_pw","init"); - this->start = start_in; - this->exxdiv.init(); - if(DFT_FUNCTIONAL == "PBE0") - { - this->alpha = 0.25; - } - return; -} - -void Exx_pw::get_exx(void) -{ - TITLE("Exx_pw","get_exx"); - timer::tick("Exx_pw","get_exx"); - - en.exx = 0.0; - - for(int ik=0; ikik_now = ik; - wf.npw = kv.ngk[ik]; - if(NSPIN==2) CURRENT_SPIN = kv.isk[ik]; - - complex *vpsi = new complex[wf.npw]; - complex *psi = new complex[wf.npw]; - - for(int ib=0; ibvxx_psi(psi, vpsi); - - for(int ig=0; ig *psi = new complex[pw.nrxx]; - complex *phi = new complex[pw.nrxx]; - complex *prho = new complex[pw.nrxx]; - en.exx = 0.0; - - for(int ik=0; ikik_now = ik; - wf.npw = kv.ngk[ik]; - for(int ib=0; ibexxdiv.get_factor(ik, iq); - for(int m=0; m - for(int ir=0; ir rho = prho[ pw.ig2fftw[ wf.igk(ik,ig) ] ]; - vc += exxdiv.factor[ig] * ( rho * conj(rho) ).real(); - } - cout << " ib=" << ib << " m=" << m << " vc=" << vc << endl;; - - en.exx = en.exx - this->alpha * vc * ucell.omega * wf.wg(ik,ib) / (double) kv.nkstot; - } // end m - } // end iq - }// end ib - } // end ik - delete[] psi; - delete[] phi; - delete[] prho; - - cout << " Exx = " << en.exx << " (Rydberg)" << endl; - en.exx *= -0.5; - timer::tick("Exx_pw","get_exx2"); - return; -} - -void Exx_pw::vxx_psi(complex* psi_in, complex *hpsi) -{ - return; - if(!start) return; - timer::tick("Exx_pw","vxx_psi"); - - // SUMMARAY : - // Vxx|psi(kn)> = \int dr sum_{mq} psi_mq(r') * psi_mq(r) * phi_kn(r) / |r-r'| - // where the last term, is pair density(pdensity). - - //(2) FFT(psi) - complex *psi = new complex[pw.nrxx]; - ZEROS(psi, pw.nrxx); - for(int ig=0; ig *phi = new complex[pw.nrxx]; - complex *prho = new complex[pw.nrxx]; - complex *denG = new complex[wf.npw]; - const double e2 = 2.0; - - for (int iq=0; iqexxdiv.get_factor(this->ik_now, iq); - for(int n=0; n - for(int ir=0; irexxdiv.factor[ig] * denG[ig] * wf.wg(iq,n) / (double)kv.nkstot; - } - - // (3.5) FFT prho/|r-r'| back to real space - ZEROS(prho, pw.nrxx); - for(int ig=0; igalpha * prho[ pw.ig2fftw[ wf.igk(ik_now, ig) ] ]; - } - - // Vxx_psi(r') = Vpari(r') * psi_{mq}(r') - // note: Vpair is diagnolized in real space, but not in G space, - // this is the same as Vlocal. - // get Vxx_psi(G) according to FFT( Vxx_psi(r') ). - } - } - - delete[] denG; - delete[] prho; - delete[] psi; - delete[] phi; - timer::tick("Exx_pw","vxx_psi"); - return; -} - - diff --git a/ABACUS.develop/source/src_pw/exx_pw.h b/ABACUS.develop/source/src_pw/exx_pw.h deleted file mode 100644 index c98fdc477a..0000000000 --- a/ABACUS.develop/source/src_pw/exx_pw.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef EXX_PW_H -#define EXX_PW_H - -#include "tools.h" -#include "exx_div.h" - -class Exx_pw -{ - public: - - Exx_pw(); - ~Exx_pw(); - - void init(bool start_in); - void get_exx(void); - void get_exx2(void); - void vxx_psi(complex* psi_in, complex *hpsi); - int ik_now; - - private: - - Exx_Divergence exxdiv; - double alpha; // 0.25 for PBE0. - bool start; - -}; - -// If we ignore the divergence term, the error intruduced in total energy -// is proportional to 1/(NQS*Omega) - -// other tricks: -// dexx = fock1 - 0.5 * ( fock + fock2 ) must be converged. -// fock0 = sum -// fock1 = sum -// fock2 = sum - -// -------------- Level 1 ----------------------- -// Target : Implement the H|psi> including exact -// exchange Vx | psi > - -// * need to overview of CG method, see how to do -// h|psi> - -// * need to calculate Vx, which is non-local. -// for eack k point. - -// * calculate the pair density for a k point -// n_{nk,mq}(r) = phi_{mq}(r) * chi_{nk}(r) - -// * solve the singularity problem. - -// -------------- Level 2 ----------------------- -// Target : Can calculate the total energy -// include Ex. - -// -------------- Level 3 ----------------------- -// Target : Implement 0.25 Ex, and PBE0. -// in potential, alphs Ex + (1-alpha) Ex(PBE) -// Ec. And the potential. - -// -------------- Level 4 ----------------------- -// Target : Parallel PBE0. - -// -------------- Level 5 ----------------------- -// Target : Force including PBE0. - -// -------------- Level 6 ----------------------- -// Target : consider HSE03 or B3LYP. -#endif diff --git a/ABACUS.develop/source/src_pw/global.cpp b/ABACUS.develop/source/src_pw/global.cpp index d3d3030c36..993ea308be 100644 --- a/ABACUS.develop/source/src_pw/global.cpp +++ b/ABACUS.develop/source/src_pw/global.cpp @@ -1,6 +1,7 @@ //========================================================== // Author: Lixin He,mohan // DATE : 2008-11-6 +// LAST MODIFIED : 2021-01-31 by Mohan //========================================================== #include "global.h" @@ -17,23 +18,6 @@ PW_Basis pw; energy en; wavefunc wf; Hamilt hm; -Exx_pw exxpw; - -#ifdef __EPM - -UnitCell_epm ucell; -Potential_EPM epm; -FFT fftsb; -so_pw sopw; -so_smallbox sobox ; -zeeman zm; - -#else - - -#ifdef __FP -//wannier wan; -#endif UnitCell_pseudo ucell; pseudopot_cell_vnl ppcell; @@ -50,9 +34,7 @@ Parallel_Kpoints Pkpoints; // mohan add 2010-06-07 Vdwd2 vdwd2(ucell); // Peize Lin add 2019-04-26 Vdwd3 vdwd3(ucell); // jiyy add 2019-05-18 -Soc soc;//added by zhengdy-soc +Soc soc; //added by zhengdy-soc Restart restart; // Peize Lin add 2020.04.04 -#endif - diff --git a/ABACUS.develop/source/src_pw/global.h b/ABACUS.develop/source/src_pw/global.h index 7861da1479..34aa1bac0f 100644 --- a/ABACUS.develop/source/src_pw/global.h +++ b/ABACUS.develop/source/src_pw/global.h @@ -1,7 +1,7 @@ //========================================================== - // Author: Lixin He,mohan // DATE : 2008-11-6 +// LAST MODIFIED : 2021-01-31 by Mohan //========================================================== #ifndef GLOBAL_H #define GLOBAL_H @@ -11,18 +11,12 @@ #include "pw_basis.h" #include "energy.h" #include "occupy.h" - -#ifndef __EPM - #include "pseudopot_cell_vnl.h" #include "../run_frag.h" #include "charge_broyden.h" #include "potential.h" #include "electrons.h" #include "functional.h" - -#endif - #include "hamilt.h" #include "ions.h" #include "wavefunc.h" @@ -31,7 +25,6 @@ //#include "../src_develop/src_wannier/wan_global.h" #include "../src_pw/output.h" #include "magnetism.h" -#include "exx_pw.h" #include "vdwd2.h" #include "vdwd3.h" #include "src_global/restart.h" @@ -50,26 +43,6 @@ extern PW_Basis pw; extern energy en; extern wavefunc wf; extern Hamilt hm; -extern Exx_pw exxpw; - -// if define epm. -#ifdef __EPM - -#include "../src_epm/potential_epm.h" -#include "../src_epm/unitcell_epm.h" -#include "../src_epm/so_pw.h" -#include "../src_epm/so_smallbox.h" -#include "../src_epm/zeeman.h" - -extern UnitCell_epm ucell; -extern Potential_EPM epm; -extern FFT fftsb; -extern so_pw sopw; -extern so_smallbox sobox; -extern zeeman zm; - -// else, plane wave or first principles -#else #include "symmetry.h" #include "unitcell_pseudo.h" @@ -90,57 +63,13 @@ extern Parallel_Kpoints Pkpoints; extern Vdwd2 vdwd2; // Peize Lin add 2019-04-26 extern Vdwd3 vdwd3; // jiyy add 2019-05-18 -extern Restart restart; // Peize Lin add 2020.04.04 +extern Restart restart; // Peize Lin add 2020.04.04 //zhengdy-soc #include "soc.h" extern Soc soc; -#ifdef __FP -#include "../src_lcao/global_fp.h" -#endif -#endif -//========================================================== -// EXPLAIN : from control_flags.f90 -// EXPLAIN : define "GLOBAL VARIABLES" -// EXPLAIN : bool variables ,"l" stands for label. -//========================================================== +#include "../src_lcao/global_fp.h" -//extern bool two_fermi_energies; // TURE : in LSDA calculation case , there are -//extern int isolve; // "2": Davidson or "1": CG diagonalization -//extern double alpha0; // the mixing parameters for the extrapolation -//extern double beta0; // ??? of the starting potential -//extern int ngm0; // used in mix_rho -//extern int nmix; // the number of iteration kept in the history -//extern int iverbosity; // type of printing ( 0 few, 1 all ) -//extern bool lfixatom; // if .TRUE. some atoms is kept fixed -//extern bool lmd; // if .TRUE. the calculation is a dynamics -//extern bool lpath; // if .TRUE. the calculation is a path optimizations -//extern bool lneb; // if .TRUE. the calculation is NEB dynamics -//extern bool lsmd; // if .TRUE. the calculation is string dynamics -//extern bool lwf; // if .TRUE. the calculation is with wannier functions -//extern bool lphonon; // if .TRUE. the calculation is phonon -//extern bool lraman; // if .TRUE. the calculation is raman -//extern bool lconstrain; // if .TRUE. the calculation is constraint -//extern bool ldamped; // if .TRUE. the calculation is a damped dynamics -//extern bool conv_ions; // if .TRUE. ionic convergence has been reached -//extern bool noinv; // if .TRUE. eliminates inversion symmetry -//extern bool reduce_io; // if .TRUE. reduce the I/O to the strict minimum -//extern realArray ns; //(:,:,:,:), the occupation matrix used in h_psi -//extern realArray nsnew; //(:,:,:,:) the occupation matrix computed by at -//extern double eth; // the (corrected) Hubbard contribution -//extern double *Hubbard_U; //(ntypx),the Hubbard U -//extern int Hubbard_lmax; // maximum agular momentum of Hubbard states -//extern ComplexMatrix swfcatom; // = (), -//extern string U_projection; // 'atomic', 'ortho-atomic', 'file' -//extern double magtot; -//extern double absmag; -//extern int current_spin; -//extern matrix f_inp; -//extern matrix tetra; // index of k-points in a given tetrahedron -//extern int ntetra; // specifies how input coordinates are given -//extern bool lberry; -//extern ComplexMatrix becp; // is used in wf,chr,elec. -//extern bool noncolin; #endif diff --git a/ABACUS.develop/source/src_pw/hamilt_pw.cpp b/ABACUS.develop/source/src_pw/hamilt_pw.cpp index 8f0873f3bf..318e9ba120 100644 --- a/ABACUS.develop/source/src_pw/hamilt_pw.cpp +++ b/ABACUS.develop/source/src_pw/hamilt_pw.cpp @@ -537,12 +537,6 @@ void Hamilt_PW::h_psi(const complex *psi_in, complex *hpsi) } } - // mohan add 2010-07-22 - if( DFT_FUNCTIONAL == "PBE0" ) - { - //exxpw.vxx_psi(psi_in, hpsi); - } - timer::tick("Hamilt_PW","h_psi",'H'); return; } From bec0a47e9ab9fc7c8a9ce3dc492e81a8bc076f06 Mon Sep 17 00:00:00 2001 From: mohanchen Date: Sun, 31 Jan 2021 10:43:08 +0800 Subject: [PATCH 047/233] delete B-field related codes in src_lcao, delete useless EPM precompiling flag in ABACUS, I can image these useless codes will be very distrubing for new developers, so I must clean them up. --- ABACUS.develop/source/Makefile.Objects | 21 - ABACUS.develop/source/dc_driv.cpp | 19 - ABACUS.develop/source/input.cpp | 67 +-- ABACUS.develop/source/input.h | 7 - ABACUS.develop/source/input_conv.cpp | 40 +- ABACUS.develop/source/input_conv.h | 4 - ABACUS.develop/source/src_lcao/bfield.cpp | 392 ------------ ABACUS.develop/source/src_lcao/bfield.h | 71 --- ABACUS.develop/source/src_lcao/gint_gamma.h | 46 +- .../source/src_lcao/gint_gamma_bfield.cpp | 388 ------------ .../source/src_lcao/gint_gamma_rho.cpp | 415 +------------ .../source/src_lcao/gint_gamma_stap.cpp | 565 ------------------ .../source/src_lcao/gint_gamma_vl.cpp | 475 +-------------- .../source/src_lcao/gint_gamma_vna.cpp | 9 +- .../source/src_lcao/gint_gamma_vna_d.cpp | 15 +- ABACUS.develop/source/src_lcao/gint_speed.cpp | 9 +- .../source/src_lcao/grid_technique.cpp | 4 - .../source/src_lcao/lcao_matrix.cpp | 106 ++-- .../source/src_lcao/local_orbital_charge.cpp | 428 ++++++------- .../source/src_lcao/local_orbital_charge.h | 1 - .../source/src_lcao/local_orbital_elec.cpp | 37 +- .../source/src_lcao/local_orbital_wfc.cpp | 169 ++---- .../source/src_lcao/local_orbital_wfc.h | 1 - .../source/src_lcao/update_input.cpp | 1 - .../source/src_lcao/use_hamilt_matrix.cpp | 89 +-- .../source/src_lcao/use_overlap_matrix.cpp | 40 +- .../source/src_parallel/subgrid_oper.cpp | 318 +--------- ABACUS.develop/source/src_pw/atom_spec.cpp | 8 - ABACUS.develop/source/src_pw/atom_spec.h | 6 - ABACUS.develop/source/src_pw/electrons.h | 12 +- ABACUS.develop/source/src_pw/energy.cpp | 7 - ABACUS.develop/source/src_pw/eximport.cpp | 17 - ABACUS.develop/source/src_pw/guider.cpp | 13 - ABACUS.develop/source/src_pw/guider.h | 14 - ABACUS.develop/source/src_pw/hamilt.cpp | 23 +- ABACUS.develop/source/src_pw/hamilt.h | 10 - ABACUS.develop/source/src_pw/hamilt_pw.cpp | 20 - ABACUS.develop/source/src_pw/hamilt_pw.h | 8 +- ABACUS.develop/source/src_pw/potential.cpp | 21 - 39 files changed, 334 insertions(+), 3562 deletions(-) delete mode 100644 ABACUS.develop/source/src_lcao/bfield.cpp delete mode 100644 ABACUS.develop/source/src_lcao/bfield.h delete mode 100644 ABACUS.develop/source/src_lcao/gint_gamma_bfield.cpp delete mode 100644 ABACUS.develop/source/src_lcao/gint_gamma_stap.cpp delete mode 100644 ABACUS.develop/source/src_pw/guider.cpp delete mode 100644 ABACUS.develop/source/src_pw/guider.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 1bd8fa9c57..9481b1cd1b 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -120,11 +120,9 @@ gint_gamma_vl.o\ gint_gamma_rho.o\ gint_gamma_mull.o\ gint_gamma_env.o \ -gint_gamma_bfield.o\ gint_gamma_fvna.o\ gint_gamma_vna.o\ gint_gamma_vna_d.o\ -gint_gamma_stap.o\ gint_k.o\ gint_k_init.o\ gint_k_vl.o\ @@ -154,7 +152,6 @@ istate_charge.o \ istate_envelope.o \ diago_lcao_matrix.o\ evolve_lcao_matrix.o\ -bfield.o\ ylm.o\ force_lcao.o\ force_lcao_gamma.o\ @@ -184,24 +181,6 @@ numerical_basis.o\ numerical_descriptor.o\ wavefunc_in_pw.o\ -OBJS_EPM=run_epm.o\ -potential_epm.o\ -atom_epm.o\ -unitcell_epm.o\ -so_common.o\ -so_pw.o\ -so_smallbox.o\ -fft_smallbox.o\ -eigen_common.o\ -zeeman.o\ -epm_cg.o\ -epm_fs.o\ -fs_cg.o\ -fs_dav.o\ -nscf_epm.o\ -input.o \ -main.o \ - OBJS_PARALLEL=parallel_global.o\ parallel_kpoints.o\ parallel_common.o\ diff --git a/ABACUS.develop/source/dc_driv.cpp b/ABACUS.develop/source/dc_driv.cpp index ed344dee74..543ecdc1ac 100644 --- a/ABACUS.develop/source/dc_driv.cpp +++ b/ABACUS.develop/source/dc_driv.cpp @@ -1,11 +1,5 @@ #include "dc_driv.h" - -#ifdef __EPM -#include "../src_epm/run_epm.h" -#else #include "run_frag.h" -#endif - #include "input.h" #include "input_conv.h" #include "src_lcao/global_fp.h" @@ -67,13 +61,8 @@ void DC_Driv::reading(void) timer::tick("DC_Driv","reading",'A'); INPUT.Init( global_in_card ); Input_Conv::Convert(); -#ifdef __EPM - Input_Conv::Convert_EPM(); -#else Input_Conv::Convert_FP(); -#endif -#ifdef __FP Parallel_Global::split_diag_world(DIAGO_PROC); Parallel_Global::split_grid_world(DIAGO_PROC); @@ -378,7 +367,6 @@ void DC_Driv::reading(void) cout< chec = this->cal_phase(A,r,1); -// cout<<"======"< trial = complex(0,1)*1.0;//complex(1,1); -// cout<<"==========trial==="<Rydberg_x=tesla_x*this->fac; - this->Rydberg_y=tesla_y*this->fac; - this->Rydberg_z=tesla_z*this->fac; -} - - -void Bfield::cal_A(double A[3],double r[3]) //sun zhiyuan updated at 2011-12-26// -{ - double B[3],rtmp[3],DoublA[3]={0,0,0}; - B[0]=Rydberg_x; - B[1]=Rydberg_y; - B[2]=Rydberg_z; - rtmp[0]=r[0]-Gauge_Origin_x; - rtmp[1]=r[1]-Gauge_Origin_y; - rtmp[2]=r[2]-Gauge_Origin_z; - a_x_b(B,rtmp,DoublA); - A[0]=DoublA[0]*0.500; - A[1]=DoublA[1]*0.500; - A[2]=DoublA[2]*0.500; - return; -} -void Bfield::cal_A_of_Atom(void) //Zhiyuan add at 2011-12-24. Former version:cal_RxB// -{ - TITLE("Bfield","cal_A_of_Atom"); - - cout << " begin to prepare for bfield calculations using local orbitals." << endl; - - this->A_of_Atom = new double*[ucell.nat]; - for(int iat=0; iatA_of_Atom[iat] = new double[3]; - ZEROS(A_of_Atom[iat], 3); - } - - double R[3]; - int iat=0; - for(int it=0; ittau[ia].x*ucell.lat0; - R[1] = atom->tau[ia].y*ucell.lat0; - R[2] = atom->tau[ia].z*ucell.lat0; - this->cal_A(A_of_Atom[iat],R); - ++iat; - } - } - this->Ready_A_of_Atom=1; - return; -} - -// exp[(+ or -) i (sqrt(2)/c)*(A dot r)],Zhiyuan add 2011-12-31// -complex Bfield::cal_phase(double A[3],double r[3], int sign) -{ - assert(sign == 1 || sign == -1); - double A_dot_r = A[0]*r[0]+A[1]*r[1]+A[2]*r[2]; //this->a_dot_b(A,r); - double whole = A_dot_r*this->fac_of_phase; - if(sign == -1) - { - whole = - whole; - } - double e1 = std::cos(whole); - double e2 = std::sin(whole); - return complex(e1, e2); -} - -void Bfield::a_x_b(const double* a, const double* b, double *c) -{ - // write a program to calculate a * b, return c - c[0] = a[1] * b[2] - a[2] * b[1]; - c[1] = a[2] * b[0] - a[0] * b[2]; - c[2] = a[0] * b[1] - a[1] * b[0]; -} - -double Bfield::a_dot_b(const double* a, const double* b) -{ - return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]; -} - -double Bfield::a_dot_b(const Vector3 &a, const double* b) -{ - return a.x*b[0]+a.y*b[1]+a.z*b[2]; -} - -void Bfield::get_nlocal(void) -{ - this->trace=new int [NLOCAL]; - for(int i=0;i=0|| ParaO.trace_loc_col[iw_all]>=0) - { - trace[iw_all]=nlocal; - nlocal++; - } - } - } - cout<<"============basis in this processor"<get_nlocal(); - int nkb = ORB.nkb; - - cout << " the dimension of table is (atom, l1, n1, m1) * (atom, l, m) = " - << NLOCAL << " * " << nkb << endl; - assert( nkb >= 0); //in case of all Hydrogen atom, nkb=0// - - this->Tab = new complex*[nlocal]; - if(nkb>0) - { - for(int i=0; i[nkb]; - ZEROS(Tab[i], nkb); - } - Memory::record("Bfield","table",nlocal*nkb,"double"); - - UHM.GG.cal_vnl_B(Tab); - } - - this->allocate_tab = true; - - -/* - cout << " Grid integration: table of " << endl; - for(int i=0; i 0.001 ) - { - cout << setw(15) << Tab[i][j].real(); - ofs_running< nlm=ZERO; - this->snap_psibeta(nlm,indexi,indexj); - LM.set_HSk(i,j,nlm,'N'); - } - } - } - */ - - - -void Bfield::calculate_NL_B(void) -{ - TITLE("Bfield","calculate_NL_B"); - - assert(allocate_tab); - - for (int T1 = 0; T1 < ucell.ntype; T1++) - { - const Atom* atom1 = &ucell.atoms[T1]; - for (int I1 =0; I1< atom1->na; I1++) - { - //GridD.Find_atom( atom1->tau[I1] ); - GridD.Find_atom( atom1->tau[I1] ,T1, I1); - const int iat1 = ucell.itia2iat(T1, I1); - const int start1 = ucell.itiaiw2iwt(T1, I1, 0); - const Vector3 tau1 = atom1->tau[I1]; - - for (int ad2=0; ad2 tau2 = ucell.atoms[T2].tau[I2]; - - // < psi1 | all projectors | psi2 > - for (int j=0; jnw; j++) - { - const int iw1_all = start1 + j; - const int mu = ParaO.trace_loc_row[iw1_all]; - if(mu < 0)continue; - - // fix a serious bug: atom2[T2] -> atom2 - // mohan 2010-12-20 - for (int k=0; knw; k++) - { - const int iw2_all = start2 + k; - const int nu = ParaO.trace_loc_col[iw2_all]; - if(nu < 0)continue; - //(3) run over all projectors in nonlocal pseudopotential. - for (int ad0=0; ad0 < ucell.nat; ad0++) - { - const int T0 = ucell.iat2it[ad0]; - const int I0 = ucell.iat2ia[ad0]; - - // mohan add 2010-12-19 - // if( ORB.nproj[T0] == 0) continue; - - const int start0 = ucell.itiaiw2iwt(T0, I0, 0); - const Vector3 tau0 = ucell.atoms[T0].tau[I0]; - - complex nlm=ZERO; - this->snap_psibeta( - nlm, 0, - tau1, T1, iw1_all, - tau2, T2, iw2_all, - tau0, T0, I0); - LM.set_HSk(iw1_all,iw2_all,nlm,'N'); - } // ad0 - }// k - } // j - //---------------------------------------------------------------------------------- - } // ad2 - } // I1 - } // T1 - - delete [] trace; - - return; -} - -void Bfield::snap_psibeta( - complex &nlm, - const int& job, - const Vector3 &R1, - const int &T1, - const int &iw1_all, - const Vector3 &R2, - const int &T2, - const int &iw2_all, - const Vector3 &R0,// The projector. - const int &T0, - const int &I0) const -{ - const int nproj = ORB.nproj[T0]; - Numerical_Orbital::set_position(R1, R2); - - // (1) get distance between R1 and R2 (a.u.) - // judge if there exist overlap - double distance = Numerical_Orbital::get_distance()*ucell.lat0; - - const double Rcut1 = ORB.Phi[T1].getRcut(); - const double Rcut2 = ORB.Phi[T2].getRcut(); - - nlm = ZERO; - - if( distance > (Rcut1 + Rcut2) ) return; - - int indexi=trace[iw1_all]; - int indexj=trace[iw2_all]; //sun zhiyuan add// - - int ib_start = ORB.itiaib2ib_all(T0,I0,0); - for(int nb=0; nb -#include "../src_global/vector3.h" -using namespace std; - -class Bfield -{ - public: - Bfield(); - ~Bfield(); - - double tesla_x; - double tesla_y; - double tesla_z; - double Rydberg_x; - double Rydberg_y; - double Rydberg_z; //sun zhiyuan added at 2011-12-26// - double Gauge_Origin_x; - double Gauge_Origin_y; - double Gauge_Origin_z; //sun zhiyuan added at 2011-12-26// - double fac_of_phase; //sun zhiyuan added at 2011-12-31// - double bohr_mag; //sun zhiyuan added at 2012-02-17// - bool Ready_A_of_Atom; //judge whether A_of_Atom has been done, 2012-01-05// - - double fac; //transform from IU to Rydberg// - double c; //speed of light in Rydberg unit// - - int nlocal; //nlocal is the number of local basis this processor includes// - int *trace; //trace[NLOCAL] this array gives the index of a basis among the bases in this processor according to its index among the whole bases// - - double** A_of_Atom; //nAtom*3, Zhiyuan add at 2011-12-24, former version:RxB// - complex** Tab; - - void check(); //Zhiyuan add 2011-12-27 in order to check the input// - void convert(); //Convert bfield to Rydberg unit, sun zhiyuan added at 2011-12-26// - void cal_A_of_Atom(void); - void make_table(void); - bool allocate_tab; - - complex cal_phase(double A[3], double r[3], int sign); //Zhiyuan add 2011-12-31// - void cal_A(double A[3],double r[3]); //sun zhiyuan add at 2011-08-07// - static void a_x_b(const double* a, const double* b, double*c); - static double a_dot_b(const double* a, const double* b); - static double a_dot_b(const Vector3 &a, const double *b); - - void calculate_NL_B(void); - - void snap_psibeta(complex &nlm, const int& job, - const Vector3 &R1, - const int &T1, - const int &iw1_all, - const Vector3 &R2, - const int &T2, - const int &iw2_all, - const Vector3 &R0,// The projector. - const int &T0, - const int &I0 - ) const; - void get_nlocal(void); //sun zhiyuan add at 2011-08-22, for the dimension of table// - - void add_zeeman(); - - - -}; - -extern Bfield bfid; - -#endif diff --git a/ABACUS.develop/source/src_lcao/gint_gamma.h b/ABACUS.develop/source/src_lcao/gint_gamma.h index 5036307a06..bb23cddb13 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma.h +++ b/ABACUS.develop/source/src_lcao/gint_gamma.h @@ -40,7 +40,9 @@ class Gint_Gamma : public Grid_Base_Beta double* x12; double* x03; int *iq; -omp_lock_t lock; + + // peize add, I guess, mohan add 2021-01-31 + omp_lock_t lock; void save_atoms_on_grid(const Grid_Technique >); @@ -58,17 +60,9 @@ omp_lock_t lock; void gamma_vlocal(void); - // for calculation of pVp under B field. - void gamma_vlocal_B(void); - - // for calculation of charege double gamma_charge(void); - - // for calculatin of charge under B field - double gamma_charge_B(void); //mohan add 2012-04-19 - // for calculation of Mulliken charge. void gamma_mulliken(double** mulliken); @@ -78,10 +72,6 @@ omp_lock_t lock; void gamma_envelope(const double* wfc, double* rho);// mohan add 2011-07-01 - // for calculation of < beta_i | phi_j> under magnetic B field. - void grid_integration_vnl(complex **Tab); - - // for calculatin of < dphi_i | Vlocal | phi_j > for foce calculation // on regular FFT real space grid. void gamma_force(void); @@ -92,33 +82,17 @@ omp_lock_t lock; void gamma_force_vna(const Grid_Technique >, LCAO_Matrix &lm); - // for claculation of terms under B field, - void gamma_S_T_AP(char type, const Grid_Technique >);// sun zhiyuan add 2012-01-03// - - - //To be used in cal_S_T_AP(), zhiyuan add 2011-01-06// - complex Add_S(complex phase, double psi1, double psi2); - - complex Add_T(complex phase, double A1[3], double A2[3], - double dphi1x,double dphi1y,double dphi1z, - double dphi2x,double dphi2y,double dphi2z, - double psi1, double psi2); - - complex Add_AP(complex phase, double Aldr3[3],double A2[3], - double dphi2x,double dphi2y,double dphi2z, - double psi1, double psi2); - - complex Add_AA(complex phase, double AAdr, - double psi1, double psi2); - -void cal_meshball_vlocal(int size, int LD_pool, int* block_iw, int* bsize, int* colidx, + void cal_meshball_vlocal(int size, int LD_pool, int* block_iw, int* bsize, int* colidx, int** cal_flag, double* vldr3, double** psir_ylm, double** psir_vlbr3, int* vindex, int lgd_now, double** GridVlocal); -void cal_band_rho(int size, int LD_pool, int* block_iw, int* bsize, int* colidx, + + void cal_band_rho(int size, int LD_pool, int* block_iw, int* bsize, int* colidx, int** cal_flag, double ** psir_ylm, double **psir_DM, double* psir_DM_pool, int* vindex); -void setVindex(const int ncyz, const int ibx, const int jby, const int kbz, int* vindex) const; -void cal_psir_ylm_rho(int size, int grid_index, double delta_r, + + void setVindex(const int ncyz, const int ibx, const int jby, const int kbz, int* vindex) const; + + void cal_psir_ylm_rho(int size, int grid_index, double delta_r, double** distance, double* ylma, int* at, int* block_index, int* block_iw, int* block_size, int** cal_flag, double** psir_ylm); diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_bfield.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_bfield.cpp deleted file mode 100644 index 6c3e7d6b9b..0000000000 --- a/ABACUS.develop/source/src_lcao/gint_gamma_bfield.cpp +++ /dev/null @@ -1,388 +0,0 @@ -#include "gint_gamma.h" -#include "grid_technique.h" -#include "lcao_orbitals.h" -#include "../src_pw/global.h" -#include "bfield.h" - -void Gint_Gamma::cal_vnl_B(complex **Tab) -{ - TITLE("Gint_Gamma","cal_vnl_B"); - timer::tick("Gint_Gamma","cal_vnl_B"); - - this->job = cal_vnlb; - this->save_atoms_on_grid(GridT); - this->grid_integration_vnl(Tab); - - timer::tick("Gint_Gamma","cal_vnl_B"); - return; -} - -void Gint_Gamma::grid_integration_vnl(complex **Tab) -{ - TITLE("Grid_Integral","grid_integration_vnl"); - cout << " grid integration for vnl() " << endl; - cout << " vfactor=" << vfactor << endl; - // it's a uniform grid to save orbital values, so the delta_r is a constant. - - const int lgd_now= GridT.lgd; - const int lgd_beta=GridT.lgbeta; - - complex **table; - if(lgd_now > 0 && lgd_beta > 0) - { - table = new complex*[lgd_now]; - for (int i=0; i [lgd_beta]; - ZEROS(table[i], lgd_beta); - } - } - - const double delta_r = ORB.dr_uniform; - const Numerical_Orbital_Lm* pa; - const Numerical_Nonlocal_Lm* pb; - - int nnnmax=0; - int nhmax=0;//mohan add 2012-04-13 - for(int T=0; T= pb->nr_uniform"); - } - - tmp = c1*pb->beta_uniform[ip]+c2*pb->dbeta_uniform[ip] - + c3*pb->beta_uniform[ip+1] + c4*pb->dbeta_uniform[ip+1]; - } - - const int L = pb->getL(); - for(int m=0; m<2*L+1; m++) - { - assert( nnn[it] > ORB.ib2_ylm(it,ibm) ); - betar_ylm[ib][id][ibm] = tmp * ylma[ ORB.ib2_ylm(it,ibm) ]; - ++ibm; - } - }// end iproj - }// end ib - }// end id - - - // PHASE - int index=0; - double rA[3]={0,0,0}; - for(int ii=0; ii phase=ZERO;// PHASE - phase=bfid.cal_phase(A2_ms_A1,Rbxyz[ib],-1);// PHASE - for (int iw=0; iw< atom1->nw; iw++) - { - complex v1 = phase*psi1[iw]*vfactor;//PHASE - - //double phase = Bfield::a_dot_b( this->dr[ia2], bfid.RxB[iat2] ); - //double e1 = std::cos(phase); - //double e2 = std::sin(phase); - //complex v1e = v1 * complex(e1, e2); - int iproj_all = start2; - const int iw1_lo = GridT.trace_lo[iw_all]; - for (int iproj=0; iproj< atom2->nh; iproj++) - { - assert(iw_all=0); - table[iw1_lo][iw2_lo] += v1 * beta2[iproj]; - - //cout << " Tab=" << Tab[iw_all][ib_all] << " betar_ylm=" << betar_ylm[ia2][ib] << endl; - // int ok; cin >> ok; - ++iproj_all; - }//iw2 - ++iw_all; - }//iw - }//end cal_flag - }// end ib - }// ia2 - }// ia1 - }// k - }// j - }// i - - delete[] vindex; - delete[] ylma; - delete[] vldr3; - - if(max_size!=0) - { - for(int i=0; i *tmp=new complex [nkb]; - for(int i=0;i=0) - { - for(int j=0;j=0) - { - tmp[j]=table[mu][nu]; - } - } - } - Parallel_Reduce::reduce_complex_double_pool( tmp, nkb); //need to be updated// - if(ParaO.trace_loc_row[i]>=0|| ParaO.trace_loc_col[i]>=0) - { - for(int j=0;jsave_atoms_on_grid(GridT); double ne = 0.0; -omp_init_lock(&lock); - if(BFIELD) - { - this->gamma_charge_B(); - } - else - { - ne = this->gamma_charge(); - } -omp_destroy_lock(&lock); - timer::tick("Gint_Gamma","cal_rho",'F'); - return ne; -} - -#include "bfield.h" -double Gint_Gamma::gamma_charge_B(void) -{ - TITLE("Grid_Integral","gamma_charge_B"); - timer::tick("Gint_Gamma","gamma_charge_B",'I'); - - //get cartesian lattice vectors, in bohr, zhiyuan add 2012-01-13// - double latvec1[3],latvec2[3],latvec3[3]; - latvec1[0]=ucell.latvec.e11*ucell.lat0; - latvec1[1]=ucell.latvec.e12*ucell.lat0; - latvec1[2]=ucell.latvec.e13*ucell.lat0; - latvec2[0]=ucell.latvec.e21*ucell.lat0; - latvec2[1]=ucell.latvec.e22*ucell.lat0; - latvec2[2]=ucell.latvec.e23*ucell.lat0; - latvec3[0]=ucell.latvec.e31*ucell.lat0; - latvec3[1]=ucell.latvec.e32*ucell.lat0; - latvec3[2]=ucell.latvec.e33*ucell.lat0; - - //This is to store the position of grids, zhiyuan add 2012-01-13// - double **Rbxyz = new double *[pw.bxyz]; // bxyz*3// - for(int i=0;igrid_index = (k-nbz_start) + j * nbz + i * nby * nbz; - - // get the value: how many atoms has orbital value on this grid. - const int size = GridT.how_many_atoms[ this->grid_index ]; - if(size==0) continue; - - // (1) initialized the phi * Ylm. - for (int id=0; id GridT.orbital_rmax) continue; - // Ylm::get_ylm_real(this->nnn[it], this->dr[id], ylma); - if (distance[ib][id] < 1.0E-9) distance[ib][id] += 1.0E-9; - - Ylm::sph_harm ( ucell.atoms[it].nwl, - dr[ib][id][0] / distance[ib][id], - dr[ib][id][1] / distance[ib][id], - dr[ib][id][2] / distance[ib][id], - ylma); - // these parameters are about interpolation - // because once we know the distance from atom to grid point, - // we can get the parameters we need to do interpolation and - // store them first!! these can save a lot of effort. - const double position = distance[ib][id] / delta_r; - /* - this->iq[id] = static_cast(position); - this->x0[id] = position - static_cast(iq[id]); - this->x1[id] = 1.0 - x0[id]; - this->x2[id] = 2.0 - x0[id]; - this->x3[id] = 3.0 - x0[id]; - this->x12[id] = x1[id]*x2[id] / 6.0; - this->x03[id] = x0[id]*x3[id] / 2.0; - */ - int ip; - double dx, dx2, dx3; - double c1, c2, c3, c4; - - - ip = static_cast(position); - dx = position - ip; - dx2 = dx * dx; - dx3 = dx2 * dx; - - c3 = 3.0*dx2-2.0*dx3; - c1 = 1.0-c3; - c2 = (dx-2.0*dx2+dx3)*delta_r; - c4 = (dx3-dx2)*delta_r; - - // int ip = this->iq[id]; - // double A = ip+1.0-position/delta_r; - // double B = 1.0-A; - // double coef1 = (A*A*A-A)/6.0*delta_r*delta_r; - // double coef2 = (B*B*B-B)/6.0*delta_r*delta_r; - - Atom* atom1 = &ucell.atoms[it]; - for (int iw=0; iw< atom1->nw; iw++) - { - if ( atom1->iw2_new[iw] ) - { - pointer = &ORB.Phi[it].PhiLN( - atom1->iw2l[iw], - atom1->iw2n[iw]); - phi = c1*pointer->psi_uniform[ip]+c2*pointer->dpsi_uniform[ip] - + c3*pointer->psi_uniform[ip+1] + c4*pointer->dpsi_uniform[ip+1]; - } - psir_ylm[ib][id][iw] = phi * ylma[atom1->iw2_ylm[iw]]; - //psir_ylm[ib][id][iw] = 1;//for test - } - }// end ib - }// end id - - this->setVindex(ncyz, ibx, jby, kbz, vindex); - /* - int bindex = 0; - // z is the fastest, - for(int ii=0; ii ORB.Phi[T1].getRcut())continue; - - //for(int ia2=ia1; ia2 T1, we done all elements, for T2 == T1, - // we done about half. - if (T2 >= T1) - { - for(int is=0; is phase=0; - phase=bfid.cal_phase(A2_ms_A1,Rbxyz[ib],-1); - int iw1_lo = GridT.trace_lo[start1]; - double* psi1 = psir_ylm[ib][ia1]; - double* psi2 = psir_ylm[ib][ia2]; - double tmp = 0.0; - - // how many orbitals in this type: SZ or DZP or TZP... - for (int iw=0; iw< atom1->nw; iw++, ++iw1_lo) - { - v1=psi1[iw]+psi1[iw]; - int iw2_lo = GridT.trace_lo[start2]; - - //zhiyuan add 2012-01-03// - complex *DMp_B; - DMp_B= &LOC.DM_B[is][iw1_lo][iw2_lo]; - - double *psi2p = psi2; - double *psi2p_end = psi2 + atom2->nw; - - for (; psi2p < psi2p_end; - ++iw2_lo, ++psi2p, ++DMp_B) - { - if ( iw1_lo > iw2_lo) - { - // ++iw2_lo; - continue; - } - // for diago part, the charge density be accumulated once. - // for off-diago part, the charge density be accumulated twice. - // (easy to understand, right? because we only calculate half - // of the matrix). - - // double tmp = v1*psir_ylm[ib][ia2][iw2]*DMp[0]; - double tmp1=(phase*DMp_B[0]).real(); - double tmp2=tmp1*v1*psi2p[0]; - - if (iw1_logamma_charge(); + omp_destroy_lock(&lock); + timer::tick("Gint_Gamma","cal_rho",'F'); return ne; } - // this subroutine lies in the heart of LCAO algorithms. // so it should be done very efficiently, very carefully. // I might repeat again to emphasize this: need to optimize diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_stap.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_stap.cpp deleted file mode 100644 index ce5832e4a5..0000000000 --- a/ABACUS.develop/source/src_lcao/gint_gamma_stap.cpp +++ /dev/null @@ -1,565 +0,0 @@ -//sun zhiyuan add at 2011-08-10, for calculating A*P for bfield// -#include "gint_gamma.h" -#include "grid_technique.h" -#include "lcao_orbitals.h" -#include "../src_pw/global.h" -#include "bfield.h" -void Gint_Gamma::cal_S_T_AP(char type, const Grid_Technique >) -{ - this->save_atoms_on_grid(gt); - assert(bfid.Ready_A_of_Atom==1); - this->gamma_S_T_AP(type, gt); -} - -// this subroutine lies in the heart of LCAO algorithms. -// so it should be done very efficiently, very carefully. -// I might repeat again to emphasize this: need to optimize -// this code very efficiently, very carefully. -void Gint_Gamma::gamma_S_T_AP(char type, const Grid_Technique >) -{ - TITLE("Grid_Integral","gamma_S_T_AP"); - timer::tick("Gint_Gamma","gamma_S_T_AP"); - - cout << " calculate " << type << endl; - - //get cartesian lattice vectors, in bohr// - double latvec1[3],latvec2[3],latvec3[3]; - latvec1[0]=ucell.latvec.e11*ucell.lat0; - latvec1[1]=ucell.latvec.e12*ucell.lat0; - latvec1[2]=ucell.latvec.e13*ucell.lat0; - latvec2[0]=ucell.latvec.e21*ucell.lat0; - latvec2[1]=ucell.latvec.e22*ucell.lat0; - latvec2[2]=ucell.latvec.e23*ucell.lat0; - latvec3[0]=ucell.latvec.e31*ucell.lat0; - latvec3[1]=ucell.latvec.e32*ucell.lat0; - latvec3[2]=ucell.latvec.e33*ucell.lat0; - - // it's a uniform grid to save orbital values, so the delta_r is a constant. - const double delta_r = ORB.dr_uniform; - const Numerical_Orbital_Lm* pointer; - double mt[3]={0,0,0}; - double A_atom1[3]={0,0,0}; - double A_atom2[3]={0,0,0}; - double A2_ms_A1[3]={0,0,0}; //used to store A2-A1// - //----------------------------------------------------------- - //temporary matrixes of S, T, A*P and A*A. lgd is the number of related orbitals// - complex ** GridS; //for S matrix// - complex ** Grid_T; //for T matrix// - complex ** GridAP; //for A*P matrix// - complex ** GridAA; //for A*A matrix// - bool perform_gint = true; - const int lgd_now = gt.lgd; - if(lgd_now > 0) - { - GridS = new complex* [lgd_now]; - Grid_T = new complex* [lgd_now]; - GridAP = new complex* [lgd_now]; - GridAA = new complex* [lgd_now]; - for (int i=0; i [lgd_now]; - Grid_T[i] = new complex [lgd_now]; - GridAP[i] = new complex [lgd_now]; - GridAA[i] = new complex [lgd_now]; - ZEROS(GridS[i], lgd_now); - ZEROS(Grid_T[i], lgd_now); - ZEROS(GridAP[i], lgd_now); - ZEROS(GridAA[i], lgd_now); - } - Memory::record("Gint_Gamma","Grid_STAP",4*2*lgd_now*lgd_now,"double"); - } - else if(lgd_now <= 0) - { - perform_gint = false; - } - //----------------------------------------------------------- - - //some arrays// - double*** dr; // vectors between atom and grid: [bxyz, maxsize, 3] - double** distance; // distance between atom and grid: [bxyz, maxsize] - double*** psir_ylm; //value of wave functions// - double*** dphix; //derivatives of wave functions// - double*** dphiy; - double*** dphiz; - bool** cal_flag; //use this to decide whether the distance is larger than cutoff// - - if(max_size!=0) - { - dr = new double**[pw.bxyz]; - distance = new double*[pw.bxyz]; - psir_ylm = new double**[pw.bxyz]; - dphix = new double**[pw.bxyz]; - dphiy = new double**[pw.bxyz]; - dphiz = new double**[pw.bxyz]; - cal_flag = new bool*[pw.bxyz]; - for(int i=0; i rly; - vector> grly; - - //arrays to store the vector potential A and position r, updated at 2012-01-05// - double **Aldr3 = new double *[pw.bxyz]; // bxyz*3// - double **Rbxyz = new double *[pw.bxyz]; // bxyz*3// - double *AAdr = new double [pw.bxyz]; // bxyz// - ZEROS(AAdr, pw.bxyz); - for(int i=0;igrid_index = (k-nbz_start) + j * nbz + i * nby * nbz; - const int size = gt.how_many_atoms[ this->grid_index ]; - if(size==0)continue; - - //get pre-information about adjacent atoms// - for (int id=0; idiq[id] = static_cast(position); - this->x0[id] = position - static_cast(iq[id]); - this->x1[id] = 1.0 - x0[id]; - this->x2[id] = 2.0 - x0[id]; - this->x3[id] = 3.0 - x0[id]; - this->x12[id] = x1[id]*x2[id] / 6.0; - this->x03[id] = x0[id]*x3[id] / 2.0; - - double tmp, dtmp; - for (int iw=0; iw< atom->nw; iw++) - { - if ( atom->iw2_new[iw] ) - { - pointer = &ORB.Phi[it].PhiLN( - atom->iw2l[iw], - atom->iw2n[iw]); - - if ( iq[id] >= pointer->nr_uniform-4) - { - tmp = dtmp = 0.0; - } - else - { - tmp = x12[id]*(pointer->psi_uniform[iq[id]]*x3[id] - +pointer->psi_uniform[iq[id]+3]*x0[id]) - + x03[id]*(pointer->psi_uniform[iq[id]+1]*x2[id] - -pointer->psi_uniform[iq[id]+2]*x1[id]); - - dtmp = x12[id]*(pointer->dpsi_uniform[iq[id]]*x3[id] - +pointer->dpsi_uniform[iq[id]+3]*x0[id]) - + x03[id]*(pointer->dpsi_uniform[iq[id]+1]*x2[id] - -pointer->dpsi_uniform[iq[id]+2]*x1[id]); - - } - }//new l is used. - - int ll = atom->iw2l[iw]; - int idx_lm = atom->iw2_ylm[iw]; - - //special case for distance[id] -> 0 - //Problems Remained - //You have to add this two lines - double rr = distance[ib][id]; - if (rr < 1e-9) - { - if (ll == 0) - { - psir_ylm[ib][id][iw] = tmp * rly[idx_lm]; - dphix[ib][id][iw] = dphiy[ib][id][iw] = dphiz[ib][id][iw] = 0.0; - } - else - { - pointer = &ORB.Phi[it]. - PhiLN(atom->iw2l[iw], atom->iw2n[iw]); - - double Zty = pointer->zty; - psir_ylm[ib][id][iw] = Zty * rly[idx_lm]; - dphix[ib][id][iw] = Zty * grly[idx_lm][0]; - dphiy[ib][id][iw] = Zty * grly[idx_lm][1]; - dphiz[ib][id][iw] = Zty * grly[idx_lm][2]; - } - } - else - { - double rl; - if(ll==0) - { - rl = 1.0; - } - else if(ll==1) - { - rl = rr; - } - else - { - rl = pow(rr, ll); - } - - psir_ylm[ib][id][iw] = tmp * rly[idx_lm] / rl; - - double tmpdphi_rly = (dtmp - tmp * ll / rr) / rl * rly[idx_lm] / rr; - double tmprl = tmp/rl; - - dphix[ib][id][iw] = tmpdphi_rly * dr[ib][id][0] + tmprl * grly[idx_lm][0]; - dphiy[ib][id][iw] = tmpdphi_rly * dr[ib][id][1] + tmprl * grly[idx_lm][1]; - dphiz[ib][id][iw] = tmpdphi_rly * dr[ib][id][2] + tmprl * grly[idx_lm][2]; - } - } - }// ib - }//!id //finish loop of calc pre-info for each adjacent atom - - //get information about the vector potential A, and position r// - int index=0; - double rA[3]={0,0,0}; - for(int ii=0; ii phase=0; //the phase for overlap// - phase=bfid.cal_phase(A2_ms_A1,Rbxyz[ib],-1); - - int iw1_lo = gt.trace_lo[start1]; - - //cycle for the orbitals of atom1// - for (int iw=0; iw< atom1->nw; ++iw, ++psi1, - ++dphi1x,++dphi1y,++dphi1z) - { - complex* pS = &GridS[iw1_lo][iw2_lo]; - complex* pT = &Grid_T[iw1_lo][iw2_lo]; - complex* pAP = &GridAP[iw1_lo][iw2_lo]; - complex* pAA = &GridAA[iw1_lo][iw2_lo]; - - double* psi2= &psir_ylm[ib][ia2][0]; - double* dphi2x = dphix[ib][ia2]; - double* dphi2y = dphiy[ib][ia2]; - double* dphi2z = dphiz[ib][ia2]; - - double* phi2_end = psi2 + atom2->nw; - - //cycle for the orbitals of atom2// - for (; psi2 *tmpS = new complex[NLOCAL]; - complex *tmpT = new complex[NLOCAL]; - complex *tmpAP = new complex[NLOCAL]; - complex *tmpAA = new complex[NLOCAL]; - - const int mu = gt.trace_lo[i]; - if(mu >=0) - { - for (int j=0; j=0) - { - tmpS[j] = GridS[mu][nu]; - tmpT[j] = Grid_T[mu][nu]; - tmpAP[j] = GridAP[mu][nu]; - tmpAA[j] = GridAA[mu][nu]; - } - } - } - - Parallel_Reduce::reduce_complex_double_pool( tmpS, NLOCAL); - Parallel_Reduce::reduce_complex_double_pool( tmpT, NLOCAL); - Parallel_Reduce::reduce_complex_double_pool( tmpAP, NLOCAL); - Parallel_Reduce::reduce_complex_double_pool( tmpAA, NLOCAL); - - for (int j=0; j SS=tmpS[j]; - complex TT=tmpT[j]; - complex AP=tmpAP[j]; - complex AA=tmpAA[j]; - - if(type=='S') - { - LM.set_HSk(i,j,SS,'S'); - } - else if(type=='T') - { - LM.set_HSk(i,j,TT,'T'); - } - else if(type=='A') - { - LM.set_HSk(i,j,AP,'T'); - LM.set_HSk(i,j,AA,'T'); - } - } - - delete[] tmpS; - delete[] tmpT; - delete[] tmpAP; - delete[] tmpAA; - } - - //delete GridS, Grid_T, GridAP, GridAA// - if(gt.lgd>0) - { - for(int i=0; i Gint_Gamma::Add_S(complex phase, double psi1, double psi2) -{ - return (phase*psi1*psi2*this->vfactor); -} - -//sub-function for calculating T// -complex Gint_Gamma::Add_T(complex phase, double A1[3], double A2[3], - double dphi1x,double dphi1y,double dphi1z, - double dphi2x,double dphi2y,double dphi2z, - double psi1, double psi2) -{ - double part1 = 2.0/bfid.c/bfid.c*(A1[0]*A2[0]+A1[1]*A2[1]+A1[2]*A2[2])*psi1*psi2; - double part2 = dphi1x*dphi2x+dphi1y*dphi2y+dphi1z*dphi2z; - double part3 = -1.414213562/bfid.c*(A2[0]*dphi1x+A2[1]*dphi1y+A2[2]*dphi1z)*psi2; - double part4 = 1.414213562/bfid.c*(A1[0]*dphi2x+A1[1]*dphi2y+A1[2]*dphi2z)*psi1; - complex sum1= complex ((part1+part2),(part3+part4)); - complex sum = phase*sum1*this->vfactor; - return(sum); -} - -//sub-function for calculating A*P// -complex Gint_Gamma::Add_AP(complex phase, double Aldr3[3], double A2[3], - double dphi2x,double dphi2y,double dphi2z, - double psi1, double psi2) -{ - double part1 = (Aldr3[0]*dphi2x+Aldr3[1]*dphi2y+Aldr3[2]*dphi2z); - double part2 = -1.414213562/bfid.c*(Aldr3[0]*A2[0]+Aldr3[1]*A2[1]+Aldr3[2]*A2[2])*psi2; - complex sum1 = complex (part1,part2); - complex sum2 = -2.0*1.414213562/bfid.c*phase*sum1*psi1*this->vfactor; - complex sum = (complex (0,1.0))*sum2; - return(sum); -} - -//sub-function for calculating A*A// -complex Gint_Gamma::Add_AA(complex phase, double AAdr, - double psi1, double psi2) -{ - return (phase*AAdr*2.0/bfid.c/bfid.c*psi1*psi2*this->vfactor); -} diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp index 2819827719..a1cffcb022 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp @@ -368,14 +368,8 @@ void Gint_Gamma::cal_vlocal( this->job=cal_local; this->vlocal=vlocal_in; this->save_atoms_on_grid(GridT); - if(BFIELD) - { - this->gamma_vlocal_B(); - } - else - { - this->gamma_vlocal(); - } + + this->gamma_vlocal(); omp_destroy_lock(&lock); @@ -383,471 +377,6 @@ void Gint_Gamma::cal_vlocal( return; } -#include "bfield.h" -void Gint_Gamma::gamma_vlocal_B(void) -{ - TITLE("Grid_Integral","gamma_vlocal_B"); - - //get cartesian lattice vectors, in bohr// - double latvec1[3],latvec2[3],latvec3[3]; - latvec1[0]=ucell.latvec.e11*ucell.lat0; - latvec1[1]=ucell.latvec.e12*ucell.lat0; - latvec1[2]=ucell.latvec.e13*ucell.lat0; - latvec2[0]=ucell.latvec.e21*ucell.lat0; - latvec2[1]=ucell.latvec.e22*ucell.lat0; - latvec2[2]=ucell.latvec.e23*ucell.lat0; - latvec3[0]=ucell.latvec.e31*ucell.lat0; - latvec3[1]=ucell.latvec.e32*ucell.lat0; - latvec3[2]=ucell.latvec.e33*ucell.lat0; - - - complex** GridVlocal = nullptr; - bool perform_gint=true; - - const int lgd_now=GridT.lgd; - if(lgd_now > 0) - { - GridVlocal=new complex*[lgd_now]; - for (int i=0; i[lgd_now]; - ZEROS(GridVlocal[i], lgd_now); - } - Memory::record("Gint_Gamma","GridVlocal",2*lgd_now*lgd_now,"double"); - } - else if(lgd_now <= 0) - { - perform_gint=false; - } - // it's a uniform grid to save orbital values, so the delta_r is a constant. - const double delta_r=ORB.dr_uniform; - const Numerical_Orbital_Lm* pointer = nullptr; - - // allocate 1 - int nnnmax=0; - for(int T=0; Tgrid_index=(k-nbz_start) + j * nbz + i * nby * nbz; - - // get the value: how many atoms has orbital value on this grid. - const int size=GridT.how_many_atoms[ this->grid_index ]; - if(size==0) continue; - - // (1) initialized the phi * Ylm. - for (int id=0; id GridT.orbital_rmax) continue; - // Ylm::get_ylm_real(this->nnn[it], this->dr[id], ylma); - if (distance[ib][id] < 1.0E-9) distance[ib][id] += 1.0E-9; - - Ylm::sph_harm ( ucell.atoms[it].nwl, - dr[ib][id][0] / distance[ib][id], - dr[ib][id][1] / distance[ib][id], - dr[ib][id][2] / distance[ib][id], - ylma); - // these parameters are about interpolation - // because once we know the distance from atom to grid point, - // we can get the parameters we need to do interpolation and - // store them first!! these can save a lot of effort. - const double position=distance[ib][id] / delta_r; - /* - this->iq[id]=static_cast(position); - this->x0[id]=position - static_cast(iq[id]); - this->x1[id]=1.0 - x0[id]; - this->x2[id]=2.0 - x0[id]; - this->x3[id]=3.0 - x0[id]; - this->x12[id]=x1[id]*x2[id] / 6.0; - this->x03[id]=x0[id]*x3[id] / 2.0; - */ - int ip; - double dx, dx2, dx3; - double c1, c2, c3, c4; - - ip=static_cast(position); - dx=position - ip; - dx2=dx * dx; - dx3=dx2 * dx; - - c3=3.0*dx2-2.0*dx3; - c1=1.0-c3; - c2=(dx-2.0*dx2+dx3)*delta_r; - c4=(dx3-dx2)*delta_r; - - // int ip=this->iq[id]; - // double A=ip+1.0-position/delta_r; - // double B=1.0-A; - // double coef1=(A*A*A-A)/6.0*delta_r*delta_r; - // double coef2=(B*B*B-B)/6.0*delta_r*delta_r; - Atom* atom1=&ucell.atoms[it]; - for (int iw=0; iw< atom1->nw; iw++) - { - if ( atom1->iw2_new[iw] ) - { - pointer=&ORB.Phi[it].PhiLN( - atom1->iw2l[iw], - atom1->iw2n[iw]); - phi=c1*pointer->psi_uniform[ip]+c2*pointer->dpsi_uniform[ip] - + c3*pointer->psi_uniform[ip+1] + c4*pointer->dpsi_uniform[ip+1]; - } - psir_ylm[ib][id][iw]=phi * ylma[atom1->iw2_ylm[iw]]; - //psir_ylm[ib][id][iw]=1;//for test - } - }// end ib - }// end id - - - int bindex=0; - // z is the fastest, - for(int ii=0; iivlocal[vindex[ib]] * this->vfactor; - // vldr3[ib]=1.0e-5; // for test - // vldr3[bindex]=this->vfactor; // for checking overlap S - } - - //get the information about position r of grid// - int index=0; - double rA[3]={0,0,0}; - for(int ii=0; iinnn[T1], this->dr[ia1], this->ylm1); - - // attention! assume all rcut are same for this atom type now. - //if (distance[ia1] > ORB.Phi[T1].getRcut())continue; - - //for(int ia2=ia1; ia2 T1, we done all elements, for T2 == T1, - // we done about half. - if (T2 >= T1) - { - Atom *atom2=&ucell.atoms[T2]; - const int I2=ucell.iat2ia[ GridT.which_atom[mcell_index2]]; - const int start2=ucell.itiaiw2iwt(T2, I2, 0); - - for (int ib=0; ib phase=0; //the phase for overlap// - phase=bfid.cal_phase(A2_ms_A1,Rbxyz[ib],-1); - - // how many orbitals in this type: SZ or DZP or TZP... - for (int iw=0; iw< atom1->nw; iw++, ++iw1_lo) - { - v1=psi1[iw] * vldr3[ib]; - int iw2_lo=GridT.trace_lo[start2]; - complex* result=&GridVlocal[iw1_lo][iw2_lo]; - double* psi2p=psi2; - double* psi2p_end=psi2p + atom2->nw; - for (;psi2p iw2_lo) - { - continue; - } - result[0] += phase*v1*psi2p[0]; - - // note 1 - // why I increase both iw2_lo and iw2_all: - // Because iw2_lo is used to save element. - // And iw2_all is used to judge if we need - // to calculate the element according to - // "iw1_all > iw2_all" condition. - // note 2 - // in fact we don't need to do this. - // because GridVlocal is a symmetry matrix. - // whatever the division is , the order - // is same between iw2_lo,iw1_lo and - // iw2_all, iw1_all - }//iw2 - }//iw - }// cal_flag - }//ib - }//T - }// ia2 - }// ia1 - - }// k - }// j - }// i - - delete[] vindex; - delete[] ylma; - delete[] vldr3; - - if(max_size!=0) - { - for(int i=0; i* tmp=new complex[NLOCAL]; - for (int i=0; i= 0) - { - for (int j=0; j=0) - { - if (mu <= nu) - { - tmp[j]=GridVlocal[mu][nu]; - } - else - { - //------------------------------- - // origin: - // tmp[i]=GridVlocal[nu][mu]; - // mohan fix bug - // 2011-01-13 - //------------------------------- - tmp[j] =conj(GridVlocal[nu][mu]); - //zhiyuan changed 2012-01-13, the v local matrix is Hermite// - } - } - } - } - Parallel_Reduce::reduce_complex_double_pool( tmp, NLOCAL); - for (int j=0; j0) - { - for(int i=0; i(tmp[j],0.0),'L'); - } - else - { - LM.set_HSgamma(i,j,tmp[j],'L'); - } + LM.set_HSgamma(i,j,tmp[j],'L'); } delete[] tmp; } diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_vna_d.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_vna_d.cpp index 37a0b6e93e..4429563a7b 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_vna_d.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_vna_d.cpp @@ -436,17 +436,10 @@ void Gint_Gamma::gamma_vna_d(const Grid_Technique >, const char &matrix_type) } // mohan update 2011-04-15 - if(BFIELD) - { - LM.set_HSk(i,j,complex(tmp[j],0.0),matrix_type); - } - else - { - //change L to T, which is two different matrix. - // L : local - // T : T, Vnl, Vna - LM.set_HSgamma(i,j,tmp[j],matrix_type); - } + //change L to T, which is two different matrix. + // L : local + // T : T, Vnl, Vna + LM.set_HSgamma(i,j,tmp[j],matrix_type); } delete[] tmp; } diff --git a/ABACUS.develop/source/src_lcao/gint_speed.cpp b/ABACUS.develop/source/src_lcao/gint_speed.cpp index a35bd7d518..eb4dce3182 100644 --- a/ABACUS.develop/source/src_lcao/gint_speed.cpp +++ b/ABACUS.develop/source/src_lcao/gint_speed.cpp @@ -291,14 +291,7 @@ void Gint_Speed::gamma_vlocal(void) } // mohan update 2011-04-15 - if(BFIELD) - { - LM.set_HSk(i,j,complex(tmp[j],0.0),'L'); - } - else - { - LM.set_HSgamma(i,j,tmp[j],'L'); - } + LM.set_HSgamma(i,j,tmp[j],'L'); } delete[] tmp; } diff --git a/ABACUS.develop/source/src_lcao/grid_technique.cpp b/ABACUS.develop/source/src_lcao/grid_technique.cpp index 06bb3c88f8..837e508775 100644 --- a/ABACUS.develop/source/src_lcao/grid_technique.cpp +++ b/ABACUS.develop/source/src_lcao/grid_technique.cpp @@ -76,10 +76,6 @@ void Grid_Technique::set_pbc_grid( this->init_atoms_on_grid(); this->cal_trace_lo(); - if(BFIELD) - { - this->cal_trace_beta();//add by sunzhiyuan - } timer::tick("Grid_Technique","init",'D'); return; } diff --git a/ABACUS.develop/source/src_lcao/lcao_matrix.cpp b/ABACUS.develop/source/src_lcao/lcao_matrix.cpp index 8526a1fc22..04cfd22521 100644 --- a/ABACUS.develop/source/src_lcao/lcao_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/lcao_matrix.cpp @@ -76,16 +76,7 @@ void LCAO_Matrix::divide_HS_in_frag(void) // (3) allocate matrix. if(GAMMA_ONLY_LOCAL) { - if(BFIELD) - { - // if b field is chosen, - // the hamiltonian is complex. - allocate_HS_k(ParaO.nloc); - } - else - { - allocate_HS_gamma(ParaO.nloc); - } + allocate_HS_gamma(ParaO.nloc); } else { @@ -477,27 +468,24 @@ void LCAO_Matrix::print_HSgamma(const char &mtype) ofs_running << " element number = " << ParaO.ncol << endl; if (mtype=='S') { - if(!BFIELD) + cout << setprecision(8); + cout << " print Sloc" << endl; + for(int i=0; i 1.0e-8) { - double v = Sloc[i*ParaO.ncol+j]; - if( abs(v) > 1.0e-8) - { - cout << setw(15) << v; - } - else - { - cout << setw(15) << "0"; - } - }//end j - cout << endl; - }//end i - } + cout << setw(15) << v; + } + else + { + cout << setw(15) << "0"; + } + }//end j + cout << endl; + }//end i /* ofs_running << " " << setw(10) << "LocalRow" << setw(10) << "LocalCol" @@ -591,50 +579,44 @@ void LCAO_Matrix::print_HSgamma(const char &mtype) } */ - if(!BFIELD) + cout << " print Hloc_fixed" << endl; + for(int i=0; i 1.0e-8) { - double v = Hloc_fixed[i*ParaO.ncol+j]; - if( abs(v) > 1.0e-8) - { - cout << setw(15) << v; - } - else - { - cout << setw(15) << "0"; - } - }//end j - cout << endl; - }//end i - } + cout << setw(15) << v; + } + else + { + cout << setw(15) << "0"; + } + }//end j + cout << endl; + }//end i } if (mtype=='H') { - if(!BFIELD) + cout << " print Hloc" << endl; + for(int i=0; i 1.0e-8) { - double v = Hloc[i*ParaO.ncol+j]; - if( abs(v) > 1.0e-8) - { - cout << setw(15) << v; - } - else - { - cout << setw(15) << "0"; - } - }//end j - cout << endl; - }//end i - } + cout << setw(15) << v; + } + else + { + cout << setw(15) << "0"; + } + }//end j + cout << endl; + }//end i /* ofs_running << " " << setw(10) << "LocalRow" << setw(10) << "LocalCol" diff --git a/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp b/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp index ae57021149..4c654d86c6 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp @@ -42,35 +42,22 @@ Local_Orbital_Charge::~Local_Orbital_Charge() { // with gamma point only if (this->init_DM) - { - if(BFIELD) - { - for (int is=0; isinit_DM_R) @@ -375,71 +362,37 @@ void Local_Orbital_Charge::allocate_gamma(const Grid_Technique >) // mohan add 2010-07-01 if(this->init_DM) { - if(BFIELD) - { - assert(lgd_last > 0); - for (int is=0; is 0); - for (int is=0; is 0); + for (int is=0; is 0) { - if(BFIELD) - { - this->DM_B = new complex **[NSPIN]; - this->DM_B_pool = new complex *[NSPIN]; - for(int is=0; isDM_B_pool[is]=new complex [lgd_now*lgd_now]; - ZEROS(DM_B_pool[is], lgd_now*lgd_now); - this->DM_B[is] = new complex*[lgd_now]; - - for (int i=0; i"); - } - } - else - { - this->DM = new double**[NSPIN]; - this->DM_pool = new double *[NSPIN]; - for(int is=0; isDM_pool[is]=new double [lgd_now*lgd_now]; - ZEROS(DM_pool[is], lgd_now*lgd_now); - this->DM[is] = new double*[lgd_now]; - - for (int i=0; iinit_DM = true; + this->DM = new double**[NSPIN]; + this->DM_pool = new double *[NSPIN]; + for(int is=0; isDM_pool[is]=new double [lgd_now*lgd_now]; + ZEROS(DM_pool[is], lgd_now*lgd_now); + this->DM[is] = new double*[lgd_now]; + + for (int i=0; iinit_DM = true; this->lgd_last = lgd_now; //xiaohui add 'OUT_LEVEL', 2015-09-16 if(OUT_LEVEL != "m") ofs_running << " allocate DM , the dimension is " << lgd_now << endl; @@ -453,8 +406,10 @@ void Local_Orbital_Charge::allocate_gamma(const Grid_Technique >) WARNING_QUIT("Local_Orbital_Charge::allocate","lgd<0!Something Wrong!"); } - if(!BFIELD) setAlltoallvParameter(ParaO.comm_2D, ParaO.blacs_ctxt, ParaO.nb); + setAlltoallvParameter(ParaO.comm_2D, ParaO.blacs_ctxt, ParaO.nb); + wfc_dm_2d.init(); // Peize Lin test 2019-01-16 + return; } @@ -1019,176 +974,135 @@ void Local_Orbital_Charge::cal_dk_gamma(void) assert(NSPIN==kv.nks); - if(BFIELD) - { - for(int is=0; isDM_B[is][i], lgd_now); - } - } - for(int is=0; is= 0) - { - // set a pointer. - complex *alpha = this->DM_B[is][mu_local]; - for (int j=i; j= 0) - { - for (int ib=0; ib0) - { - // dm = \sum ( wg * c[ib][mu] * c[ib][nu] ) - // dm saved accordint to sub-FFT box. - alpha[nu_local] += wg_local * (conj(LOWF.WFC_GAMMA_B[is][ib][mu_local]) * LOWF.WFC_GAMMA_B[is][ib][nu_local]).real(); - } - } - } - } - } - } - } - } #ifdef __MPI //2015-09-06, xiaohui - else // Peize Lin update 2018-07-02 - { - for( int is=0; isDM[is][i], lgd_now); - - int nprocs,myid; - //MPI_Status status; - MPI_Comm_size(DIAG_HPSEPS_WORLD,&nprocs); - MPI_Comm_rank(DIAG_HPSEPS_WORLD,&myid); - - vector bands_local(DSIZE); - for (int id=0; id= NBANDS) - { - lastband_in_proc = id; - break; - } - } - - matrix wg_local(NSPIN,band_local); - for(int id=0, Total_Bands=0; id <= lastband_in_proc; ++id) - { - if(myid == id) - for(int is=0; isDM[is][i], lgd_now); + + int nprocs,myid; + //MPI_Status status; + MPI_Comm_size(DIAG_HPSEPS_WORLD,&nprocs); + MPI_Comm_rank(DIAG_HPSEPS_WORLD,&myid); + + vector bands_local(DSIZE); + for (int id=0; id= NBANDS) + { + lastband_in_proc = id; + break; + } + } + + matrix wg_local(NSPIN,band_local); + for(int id=0, Total_Bands=0; id <= lastband_in_proc; ++id) + { + if(myid == id) + for(int is=0; isDM[is][row_mu][col_nu] = rho_row_col(i_row,i_col); - } - } - } - } // end for col_count - } // end for row_count - ofs_running<<"DM[0][0:1][0:1] in cal_dk_gamma:"<=0) - { - ofs_running<<"DM(0,0)"<=0 && idx1>=0) - { - ofs_running<<"DM(0,1)"<=0) - { - ofs_running<<"DM(1,1)"<DM[is][row_mu][col_nu] = rho_row_col(i_row,i_col); + } + } + } + } // end for col_count + } // end for row_count + ofs_running<<"DM[0][0:1][0:1] in cal_dk_gamma:"<=0) + { + ofs_running<<"DM(0,0)"<=0 && idx1>=0) + { + ofs_running<<"DM(0,1)"<=0) + { + ofs_running<<"DM(1,1)"<*** DM_B; //density matrix in B field, Zhiyuan add 2012-01-13// double** DM_R; void write_dm(const int &is, const int &iter, const string &fn, const int &precision); diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp index 39e38597c1..e6ce73daeb 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp @@ -779,17 +779,9 @@ void Local_Orbital_Elec::cal_bands(const int &istep) // // mohan add 2011-04-15 - // if(BFIELD) - // { - // //cout << " solve comlex matrix()" << endl; - // DLM.solve_complex_matrix(ik, SGO.totwfc_B[0], istep); - // } - // else - // { - // //DLM.solve_double_matrix(ik, LOWF.WFC_GAMMA[CURRENT_SPIN]); - // // the temperary array totwfc only have one spin direction. - // DLM.solve_double_matrix(ik, SGO.totwfc[0]); - // } + // //DLM.solve_double_matrix(ik, LOWF.WFC_GAMMA[CURRENT_SPIN]); + // // the temperary array totwfc only have one spin direction. + // DLM.solve_double_matrix(ik, SGO.totwfc[0]); //} //else if(LINEAR_SCALING==2) //{ @@ -812,17 +804,9 @@ void Local_Orbital_Elec::cal_bands(const int &istep) //xiaohui add 2013-09-02 Diago_LCAO_Matrix DLM; - if(BFIELD) - { - //cout << " solve comlex matrix()" << endl; - DLM.solve_complex_matrix(ik, SGO.totwfc_B[0], LOC.wfc_dm_2d.wfc_k[ik]); - } - else - { - //DLM.solve_double_matrix(ik, LOWF.WFC_GAMMA[CURRENT_SPIN]); - // the temperary array totwfc only have one spin direction. - DLM.solve_double_matrix(ik, SGO.totwfc[0], LOC.wfc_dm_2d.wfc_gamma[ik]); - } //xiaohui add 2013-09-02. Attention... + //DLM.solve_double_matrix(ik, LOWF.WFC_GAMMA[CURRENT_SPIN]); + // the temperary array totwfc only have one spin direction. + DLM.solve_double_matrix(ik, SGO.totwfc[0], LOC.wfc_dm_2d.wfc_gamma[ik]); } else { @@ -838,14 +822,7 @@ void Local_Orbital_Elec::cal_bands(const int &istep) MPI_Barrier(MPI_COMM_WORLD); #endif // distribute the wave functions again. - if(!BFIELD) - { - SGO.dis_subwfc(); - } - else - { - SGO.dis_subwfc_complex(); - } + SGO.dis_subwfc(); }//end gamma // with k points else diff --git a/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp b/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp index 6fcaf02d5a..90f5e93e4c 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp @@ -17,30 +17,15 @@ Local_Orbital_wfc::~Local_Orbital_wfc() // used for gamma if(allocate_flag) { - if(BFIELD) + for(int is=0; isWFC_GAMMA_B[is][i]; - } - delete[] this->WFC_GAMMA_B[is]; + delete[] this->WFC_GAMMA[is][i]; } - delete[] this->WFC_GAMMA_B; - } - else - { - for(int is=0; isWFC_GAMMA[is][i]; - } - delete[] this->WFC_GAMMA[is]; - } - delete[] this->WFC_GAMMA; + delete[] this->WFC_GAMMA[is]; } + delete[] this->WFC_GAMMA; } // used for force @@ -206,24 +191,11 @@ void Local_Orbital_wfc::aloc_gamma_wfc(const Grid_Technique >) // mohan add 2010-07-01 if(allocate_flag) { - if(BFIELD) - { - for(int is=0; isWFC_GAMMA_B[is][ib]; - } - } - } - else + for(int is=0; isWFC_GAMMA[is][ib]; - } + delete[] this->WFC_GAMMA[is][ib]; } } allocate_flag = false; @@ -233,21 +205,10 @@ void Local_Orbital_wfc::aloc_gamma_wfc(const Grid_Technique >) static bool first = true; if(first) { - if(BFIELD) + this->WFC_GAMMA = new double**[NSPIN]; + for(int is=0; isWFC_GAMMA_B = new complex**[NSPIN]; - for(int is=0; isWFC_GAMMA_B[is] = new complex*[NBANDS]; - } - } - else - { - this->WFC_GAMMA = new double**[NSPIN]; - for(int is=0; isWFC_GAMMA[is] = new double*[NBANDS]; - } + this->WFC_GAMMA[is] = new double*[NBANDS]; } first=false; } @@ -257,107 +218,55 @@ void Local_Orbital_wfc::aloc_gamma_wfc(const Grid_Technique >) { // Create wave functions(Coefficients) in local basis. // Same as evc in plane wave basis. - if(BFIELD) + for(int is=0; isWFC_GAMMA_B[is][ib] = new complex[gt.lgd]; - ZEROS(this->WFC_GAMMA_B[is][ib],gt.lgd); - } - Memory::record("LocalOrbital_Coef","WFC_GAMMA_B",NSPIN*NBANDS*NLOCAL,"cdouble"); - allocate_flag = true; - } - } - else - { - for(int is=0; isWFC_GAMMA[is][ib] = new double[gt.lgd]; - ZEROS(this->WFC_GAMMA[is][ib],gt.lgd); - } - Memory::record("LocalOrbital_Coef","WFC_GAMMA",NSPIN*NBANDS*NLOCAL,"double"); - allocate_flag = true; + this->WFC_GAMMA[is][ib] = new double[gt.lgd]; + ZEROS(this->WFC_GAMMA[is][ib],gt.lgd); } + Memory::record("LocalOrbital_Coef","WFC_GAMMA",NSPIN*NBANDS*NLOCAL,"double"); + allocate_flag = true; } } OUT(ofs_running,"start_wfc",wf.start_wfc); if(wf.start_wfc == "atomic" ) { - // Bfield - if(BFIELD) + for(int is=0; is=0) - { - // be careful! std::rand must be translated to double! - // c[i][j] = static_cast( std::rand() ) / RAND_MAX ; - - // mohan modify 2010-07-02 - this->WFC_GAMMA_B[is][i][mu] = complex(1.0, 0.0); - } - } - }// j - }// i - }// is - } - // no Bfield - else - { - for(int is=0; is=0) { - const int mu = gt.trace_lo[j]; - if(mu>=0) - { - // be careful! std::rand must be translated to double! -// this->WFC_GAMMA[is][i][mu] = static_cast( std::rand() ) / RAND_MAX ; - - // mohan modify 2010-07-02 - this->WFC_GAMMA[is][i][mu] = 1.0; - } + // be careful! std::rand must be translated to double! + // this->WFC_GAMMA[is][i][mu] = static_cast( std::rand() ) / RAND_MAX ; + + // mohan modify 2010-07-02 + this->WFC_GAMMA[is][i][mu] = 1.0; } - }// j - }// i - }// is - } + } + }// j + }// i + }// is + // cout << " set LCAO wave fuctions to unit." << endl; } else if(wf.start_wfc == "file") { int error; - if(BFIELD) - { - cout << " not implemented read_lowf for B field yet." << endl; - WARNING_QUIT("Local_Orbital_wfc::aloc_gamma_wfc","not implement yet"); - } - else + for(int is=0; isWFC_GAMMA[is] ); - } + CURRENT_SPIN = is; + + // read in the wave functions from file and then + // distribute it. + error = WF_Local::read_lowf( this->WFC_GAMMA[is] ); } #ifdef __MPI Parallel_Common::bcast_int(error); diff --git a/ABACUS.develop/source/src_lcao/local_orbital_wfc.h b/ABACUS.develop/source/src_lcao/local_orbital_wfc.h index 30afd5d875..341ae46b27 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_wfc.h +++ b/ABACUS.develop/source/src_lcao/local_orbital_wfc.h @@ -11,7 +11,6 @@ class Local_Orbital_wfc ~Local_Orbital_wfc(); double*** WFC_GAMMA; // [NSPIN, NBANDS, NLOCAL] - complex*** WFC_GAMMA_B; // WFC_GAMMA for B field calculation. // used to generate density matrix: LOC.DM_R, // which is used to calculate the charge density. diff --git a/ABACUS.develop/source/src_lcao/update_input.cpp b/ABACUS.develop/source/src_lcao/update_input.cpp index a3a927cf29..3af3791b22 100644 --- a/ABACUS.develop/source/src_lcao/update_input.cpp +++ b/ABACUS.develop/source/src_lcao/update_input.cpp @@ -8,7 +8,6 @@ #include "update_input.h" #include "../src_ions/ions_move_basic.h" #include "../src_pw/optical.h" -#include "../src_lcao/bfield.h" #include "../src_lcao/force_lcao.h" #include "../src_lcao/local_orbital_charge.h" diff --git a/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp b/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp index 79383d0030..f034f2e542 100644 --- a/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp @@ -2,7 +2,6 @@ #include "use_hamilt_matrix.h" #include "build_st_pw.h" #include "sltk_atom_arrange.h" -#include "bfield.h" #include "lcao_vna.h" Use_Hamilt_Matrix::Use_Hamilt_Matrix() @@ -41,14 +40,7 @@ void Use_Hamilt_Matrix::set_ion(void) } // calulate the 'S', 'T' and 'Vnl' matrix for gamma algorithms. - if(!BFIELD) - { - this->calculate_STNR_gamma(); - } - else - { - this->calculate_STNR_gamma_B(); - } + this->calculate_STNR_gamma(); // vna only need to do once, you can check this in lcao_vna.cpp if(VNA>=1) @@ -95,14 +87,7 @@ void Use_Hamilt_Matrix::calculate_Hgamma(void) timer::tick("Use_Hamilt_Matrix","cal_Hgamma",'F'); // Set the matrix 'H' to zero. - if(BFIELD) - { - LM.zeros_HSk('H'); // 3 stands for Hloc. - } - else - { - LM.zeros_HSgamma('H'); // 3 stands for Hloc. - } + LM.zeros_HSgamma('H'); // 3 stands for Hloc. bool local_pw = false; @@ -155,33 +140,16 @@ void Use_Hamilt_Matrix::calculate_Hgamma(void) } //add T+VNL+Vl matrix. - if(BFIELD) - { - LM.update_Hloc2(); - } - else - { - LM.update_Hloc(); - } + LM.update_Hloc(); //@@@@@@@ //test //@@@@@@@ if(NURSE) { - if(BFIELD) - { - LM.print_HSk('S'); - LM.print_HSk('T'); - LM.print_HSk('H','R'); // - LM.print_HSk('H','I'); // - } - else - { - LM.print_HSgamma('S'); // S - LM.print_HSgamma('T'); - LM.print_HSgamma('H'); - } + LM.print_HSgamma('S'); // S + LM.print_HSgamma('T'); + LM.print_HSgamma('H'); // WARNING_QUIT("Use_Hamilt_Matrix::calculate_Hgamma","print the H,S matrix"); // QUIT(); } @@ -192,51 +160,6 @@ void Use_Hamilt_Matrix::calculate_Hgamma(void) } -void Use_Hamilt_Matrix::calculate_STNR_gamma_B(void) -{ - TITLE("Use_Hamilt_Matrix","calculate_STNR_gamma_B"); - - // s matrix - bfid.cal_A_of_Atom(); - bfid.make_table(); - LM.zeros_HSk('S'); - - // calculate overlap - this->GG.cal_S_T_AP('S', GridT); - //this->UOM.calculate_S_no(); -// LM.print_HSk('S','R'); - - LM.zeros_HSk('T'); - - //time_t time_vnl_start = time(NULL); - if(VNL_IN_H) - { - bfid.cal_A_of_Atom(); - // calculate A - this->GG.cal_S_T_AP('A', GridT); - // calculate nonlocal - bfid.calculate_NL_B(); - } - //time_t time_vnl_end = time(NULL); - - //time_t time_t_start = time(NULL); - if(T_IN_H) - { - // calculate T - if(T_IN_H==1) - { - UOM.calculate_T_no(); - } - else if(T_IN_H==2) - { - this->GG.cal_S_T_AP('T', GridT); - } -// LM.print_HSk('T','R'); - } - //time_t time_t_end = time(NULL); - return; -} - void Use_Hamilt_Matrix::calculate_STNR_gamma(void) { diff --git a/ABACUS.develop/source/src_lcao/use_overlap_matrix.cpp b/ABACUS.develop/source/src_lcao/use_overlap_matrix.cpp index 76e332d507..0e57c9659c 100644 --- a/ABACUS.develop/source/src_lcao/use_overlap_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/use_overlap_matrix.cpp @@ -125,20 +125,12 @@ void Use_Overlap_Matrix::build_ST_new(const char& dtype, const bool& calc_deri) if(GAMMA_ONLY_LOCAL) { - if(BFIELD) - { - LM.set_HSk(iw1_all, iw2_all, complex(olm[0],0.0), dtype); - } - else - { - // mohan add 2010-06-29 - // set the value in Hloc and Sloc - // according to trace_loc_row and trace_loc_col - // the last paramete: 1 for Sloc, 2 for Hloc - // and 3 for Hloc_fixed. - LM.set_HSgamma(iw1_all, iw2_all, olm[0], dtype); - } - + // mohan add 2010-06-29 + // set the value in Hloc and Sloc + // according to trace_loc_row and trace_loc_col + // the last paramete: 1 for Sloc, 2 for Hloc + // and 3 for Hloc_fixed. + LM.set_HSgamma(iw1_all, iw2_all, olm[0], dtype); } else // k point algorithm { @@ -556,15 +548,8 @@ void Use_Overlap_Matrix::build_Nonlocal_mu(const bool &calc_deri) // mohan add 2010-12-20 if( nlm[0]!=0.0 ) { - if(BFIELD) - { - LM.set_HSk(iw1_all,iw2_all,complex(nlm[0],0.0),'N'); - } - else - { - //ofs_running << setw(10) << iw1_all << setw(10) << iw2_all << setw(20) << nlm[0] << endl; - LM.set_HSgamma(iw1_all,iw2_all,nlm[0],'N');//N stands for nonlocal. - } + //ofs_running << setw(10) << iw1_all << setw(10) << iw2_all << setw(20) << nlm[0] << endl; + LM.set_HSgamma(iw1_all,iw2_all,nlm[0],'N');//N stands for nonlocal. } } else @@ -734,14 +719,7 @@ void Use_Overlap_Matrix::build_Nonlocal_beta(const bool& calc_deri) if(GAMMA_ONLY_LOCAL) { - if(BFIELD) - { - LM.set_HSk(iw1_all,iw2_all,complex(nlm[0],0.0),'N'); - } - else - { - LM.set_HSgamma(iw1_all,iw2_all,nlm[0],'N');//N stands for nonlocal. - } + LM.set_HSgamma(iw1_all,iw2_all,nlm[0],'N');//N stands for nonlocal. } else { diff --git a/ABACUS.develop/source/src_parallel/subgrid_oper.cpp b/ABACUS.develop/source/src_parallel/subgrid_oper.cpp index ad81e2498d..aaea95fdd6 100644 --- a/ABACUS.develop/source/src_parallel/subgrid_oper.cpp +++ b/ABACUS.develop/source/src_parallel/subgrid_oper.cpp @@ -211,76 +211,39 @@ void SubGrid_oper::cal_totwfc() } - if(!BFIELD) - { - this->totwfc = new double**[1]; - for(int is=0; is<1; ++is) - { - this->totwfc[is] = new double*[NBANDS]; - for(int ib=0; ibtotwfc[is][ib] = new double[lgd]; - ZEROS(totwfc[is][ib], lgd); - - // mohan update 2012-02-10 - //if(DIAGO_TYPE!="cg") xiaohui modify 2013-09-02 - if(KS_SOLVER!="cg") //xiaohui add 2013-09-02 - { - for(int i=0; itotwfc[is][ib][i] = LOWF.WFC_GAMMA[CURRENT_SPIN][ib][i]; //mohan update 2012-02-07 - } - } - } - } - } - else + this->totwfc = new double**[1]; + for(int is=0; is<1; ++is) { - this->totwfc_B = new complex**[1]; - for(int is=0; is<1; ++is) + this->totwfc[is] = new double*[NBANDS]; + for(int ib=0; ibtotwfc_B[is] = new complex*[NBANDS]; - for(int ib=0; ibtotwfc_B[is][ib] = new complex[lgd]; - ZEROS(totwfc_B[is][ib], lgd); - //if(DIAGO_TYPE!="cg") xiaohui modify 2013-09-02 - if(KS_SOLVER!="cg") //xiaohui add 2013-09-02 + this->totwfc[is][ib] = new double[lgd]; + ZEROS(totwfc[is][ib], lgd); + + // mohan update 2012-02-10 + //if(DIAGO_TYPE!="cg") xiaohui modify 2013-09-02 + if(KS_SOLVER!="cg") //xiaohui add 2013-09-02 + { + for(int i=0; itotwfc_B[is][ib][trace_lo_tot[i]] = ONE; - } + totwfc[is][ib][trace_lo_tot[i]] = 1.0; } } } - else + } + else //use cg method + { + // bug: dimension of WFC_GAMMA is smaller than totwfc + for(int i=0; itotwfc_B[is][ib][i] = LOWF.WFC_GAMMA_B[CURRENT_SPIN][ib][i]; - } + this->totwfc[is][ib][i] = LOWF.WFC_GAMMA[CURRENT_SPIN][ib][i]; //mohan update 2012-02-07 } } - } + } } allocate_totwfc = true; @@ -494,240 +457,3 @@ void SubGrid_oper::dis_subwfc() return; } - - - -void SubGrid_oper::dis_subwfc_complex() -{ - TITLE("SubGrid_oper","dis_subwfc_complex"); - -#ifdef __MPI - -// cout << " distribute the wave functions " << endl; - - //------------------------------------------ - // bcast the eigenvalues - //------------------------------------------ - for(int ik=0; ik= 0) - { - const int mu2 = this->trace_lo_tot[iw]; - - for(int ib=0; ibtotwfc_B[0][ib][mu2]; - }//ib - }//mu1>=0 - }//iw - }//i - else - { - int tag; - // receive trace_lo2 - tag = i * 10; - int* trace_lo2 = new int[NLOCAL]; - MPI_Recv(trace_lo2, NLOCAL, MPI_INT, i, tag, GRID_WORLD, &status); - -/* - ofs_running << " Proc " << i << endl; - for(int i=0; i* crecv = new complex[NBANDS*GridT.lgd]; - ZEROS(crecv, NBANDS*GridT.lgd); - - tag = GRANK * 10 + 2; -// ofs_running << " receive=" << tag << endl; - MPI_Recv(crecv, NBANDS*GridT.lgd, mpicomplex, 0, tag, GRID_WORLD, &status); -// ofs_running << " receive done." << endl; - - - for(int ib=0; ibdescf *= ucell.omega / pw.ncxyz; return; } -#endif void energy::perform_dos(void) { diff --git a/ABACUS.develop/source/src_pw/eximport.cpp b/ABACUS.develop/source/src_pw/eximport.cpp index 444167a69f..d5b8744e4a 100644 --- a/ABACUS.develop/source/src_pw/eximport.cpp +++ b/ABACUS.develop/source/src_pw/eximport.cpp @@ -540,12 +540,8 @@ void eximport::out_input(ofstream &out_data) << setw(20) << pw.ny << setw(20) << pw.nz << setw(20) << pw.nxyz << endl;//1.6 -#ifndef __EPM out_data << setw(20) << pot.startingpot << endl;//1.7 out_data << setw(20) << chr.mixing_beta << endl;//1.8 -#else - out_data << setw(20) << "EPM" << endl; -#endif */ out_data << "\n
"<> iter;//6.1 -#endif in >> etot;//6.2 in >> eband;//6.4 in >> one_electron;//6.5 in >> hartree;//6.6 -#ifndef __EPM in >> xc;//6.7 -#endif in >> ewald;//6.8 } #ifdef __MPI -#ifdef __EPM -#else void eximport::in_charge_mpi(const string &dir) { cout << "\n ==> eximport::in_charge()" << endl; @@ -846,7 +834,6 @@ void eximport::out_charge_mpi(const string &dir,double* rho_in) return; } #endif -#endif //******************************** // charge @@ -854,7 +841,6 @@ void eximport::out_charge_mpi(const string &dir,double* rho_in) void eximport::out_charge(ofstream &out_data) { /* -#ifndef __EPM ofs_running << "\n Output charge file." << endl; out_data << setw(20) << "CHARGE" << endl; //7.0 out_data << setw(20) << pw.omega << endl; //7.1 @@ -875,7 +861,6 @@ void eximport::out_charge(ofstream &out_data) out_data << endl; } return; -#endif */ } @@ -906,7 +891,6 @@ void eximport::in_charge(ifstream &in) void eximport::nscf_chgfile(const string &chg_file) { -#ifndef __EPM /* cout<<"\n ==> eximport::nscf_chgfile()"; cout<<" file_name : "<hpw.init(); -} -#else void Hamilt::init(const bool use_pw) { if (test_hm)TITLE("Hamilt","init"); @@ -27,7 +21,6 @@ void Hamilt::init(const bool use_pw) } return; } -#endif void Hamilt::init_k(const int ik) { @@ -274,8 +267,6 @@ void Hamilt::h_1psi(const int dim,const complex *psi,complex *hp //if (LINEAR_SCALING) xiaohui modify 2013-09-02 if(BASIS_TYPE=="lcao") //xiaohui add 2013-09-02. Attention! Maybe this change is not reasonable. { -#ifndef __EPM -#ifdef __FP timer::tick("Hamilt","Sparse_SH"); double *psi_real = new double[dim]; double *hpsi_real = new double[dim]; @@ -286,8 +277,8 @@ void Hamilt::h_1psi(const int dim,const complex *psi,complex *hp for (int i=0; ihon.UHM.Sparse_H.multiply_vector(psi_real, hpsi_real); -// this->hon.UOM.Sparse_S.multiply_vector(psi_real, spsi_real); +// this->hon.UHM.Sparse_H.multiply_vector(psi_real, hpsi_real); +// this->hon.UOM.Sparse_S.multiply_vector(psi_real, spsi_real); for (int i=0; i( spsi_real[i], 0.0 ); for (int i=0; i( hpsi_real[i], 0.0 ); @@ -296,8 +287,6 @@ void Hamilt::h_1psi(const int dim,const complex *psi,complex *hp delete[] hpsi_real; delete[] spsi_real; timer::tick("Hamilt","Sparse_SH"); -#endif -#endif } else { @@ -311,8 +300,6 @@ void Hamilt::s_1psi(const int dim, const complex *psi, complex * //if (LINEAR_SCALING) xiaohui modify 2013-09-02 if(BASIS_TYPE=="lcao") //xiaohui add 2013-09-02. Attention! Maybe this change is not reasonable. { -#ifndef __EPM -#ifdef __FP timer::tick("Hamilt","Sparse_S"); double *psi_real = new double[dim]; double *spsi_real = new double[dim]; @@ -331,8 +318,6 @@ void Hamilt::s_1psi(const int dim, const complex *psi, complex * delete[] psi_real; delete[] spsi_real; timer::tick("Hamilt","Sparse_S"); -#endif -#endif } else { @@ -341,13 +326,11 @@ void Hamilt::s_1psi(const int dim, const complex *psi, complex * return; } -#ifndef __EPM void Hamilt::h_psi( const int dim, const complex *psi, complex *hpsi) { //if (LINEAR_SCALING) xiaohui modify 2013-09-02 if(BASIS_TYPE=="lcao") //xiaohui add 2013-09-02. Attention! Maybe this change is not reasonable. { -#ifdef __FP timer::tick("Hamilt","Sparse_H"); double *psi_real = new double[dim]; double *hpsi_real = new double[dim]; @@ -363,7 +346,6 @@ void Hamilt::h_psi( const int dim, const complex *psi, complex * delete[] psi_real; delete[] hpsi_real; timer::tick("Hamilt","Sparse_H"); -#endif } else { @@ -371,7 +353,6 @@ void Hamilt::h_psi( const int dim, const complex *psi, complex * } return; } -#endif void Hamilt::cdiaghg( const int nstart, diff --git a/ABACUS.develop/source/src_pw/hamilt.h b/ABACUS.develop/source/src_pw/hamilt.h index 207ca834d0..03c3a74aff 100644 --- a/ABACUS.develop/source/src_pw/hamilt.h +++ b/ABACUS.develop/source/src_pw/hamilt.h @@ -15,19 +15,13 @@ class Hamilt Hamilt(); ~Hamilt(); -#ifdef __EPM - void init(void); -#else void init(const bool use_pw = true); -#endif void init_k(const int ik); -#ifdef __FP void init_before_ions(void); void init_before_electrons(void); void clear_after_ions(void); -#endif void cinitcgg(const int ik, const int nstart,const int nbnd, const ComplexMatrix &psi,ComplexMatrix &evc,double *en); @@ -47,11 +41,7 @@ class Hamilt void h_psi( const int dim, const complex *psi,complex *hpsi); Hamilt_PW hpw; -#ifndef __EPM -#ifdef __FP Hamilt_Linear hon; -#endif -#endif private: bool test_exit_cond( const int &ntry, const int ¬conv); diff --git a/ABACUS.develop/source/src_pw/hamilt_pw.cpp b/ABACUS.develop/source/src_pw/hamilt_pw.cpp index 318e9ba120..8773bad142 100644 --- a/ABACUS.develop/source/src_pw/hamilt_pw.cpp +++ b/ABACUS.develop/source/src_pw/hamilt_pw.cpp @@ -17,13 +17,8 @@ Hamilt_PW::Hamilt_PW() hpsi = new complex[1]; spsi = new complex[1]; GR_index = new int[1]; - -#ifndef __EPM Bec = new complex[1]; Ps = new complex[1]; -#else - GR_index2 = new int[1]; -#endif } Hamilt_PW::~Hamilt_PW() @@ -35,12 +30,8 @@ Hamilt_PW::~Hamilt_PW() delete[] hpsi; delete[] spsi; delete[] GR_index; -#ifndef __EPM delete[] Bec; delete[] Ps; -#else - delete[] GR_index2; -#endif } #ifdef __EPM @@ -52,22 +43,18 @@ void Hamilt_PW::init() delete[] hpsi; delete[] spsi; delete[] GR_index; - delete[] GR_index2; this->hpsi = new complex[wf.npwx]; this->spsi = new complex[wf.npwx]; this->GR_index = new int[nrxxs]; - this->GR_index2= new int[nrxxs]; OUT(ofs_running,"hpsi allocation = ","Done"); OUT(ofs_running,"spsi allocation = ","Done"); OUT(ofs_running,"GR_index allocation = ","Done"); - OUT(ofs_running,"GR_index2 allocation = ","Done"); ZEROS(hpsi,wf.npwx); ZEROS(spsi,wf.npwx); ZEROS(GR_index,wf.npwx); - ZEROS(GR_index2,wf.npwx); return; } @@ -123,13 +110,6 @@ void Hamilt_PW::init_k(const int ik) { this->GR_index[ig] = pw.ig2fftw[ wf.igk(ik, ig) ]; } - -#ifdef __EPM - for ( int ig=0; ig< wf.npw;ig++) - { - this->GR_index2[ig] = pw.ig2ngg[ wf.igk(ik, ig) ]; - } -#endif return; } diff --git a/ABACUS.develop/source/src_pw/hamilt_pw.h b/ABACUS.develop/source/src_pw/hamilt_pw.h index d0d088a9f4..4ef2d857fb 100644 --- a/ABACUS.develop/source/src_pw/hamilt_pw.h +++ b/ABACUS.develop/source/src_pw/hamilt_pw.h @@ -52,9 +52,7 @@ class Hamilt_PW complex *hpsi, complex *spsi); -#ifndef __EPM void h_psi( const complex *psi, complex *hpsi); -#endif void s_1psi( const int npw, @@ -65,7 +63,6 @@ class Hamilt_PW double ddot_real( const int& npw, const complex* psi_L, const complex* psi_R)const; int *GR_index; - int *GR_index2; complex *psi_one; @@ -76,10 +73,7 @@ class Hamilt_PW complex *Bec; complex *Ps; -#ifndef __EPM void add_vuspsi(complex *hpsi, const complex *becp); -#endif - complex ddot( const int& npw, @@ -96,4 +90,4 @@ class Hamilt_PW const complex *psik )const ; }; -#endif // HERMIT_H +#endif diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index a391c3b652..1d77633034 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -859,9 +859,6 @@ const matrix &v, const int &precision, const int &hartree)const // contributions. //========================================================== // from set_vrs.f90 -#ifdef __FP -#include "../src_lcao/bfield.h" -#endif void potential::set_vrs(const bool doublegrid) { TITLE("potential","set_vrs"); @@ -943,15 +940,6 @@ void potential::set_vrs(const bool doublegrid) */ } -#ifdef __FP - if(BFIELD) - { - if(NSPIN==2) - { - bfid.add_zeeman(); - } - } -#endif timer::tick("potential","set_vrs"); return; @@ -1378,15 +1366,6 @@ void potential::set_vrs_tddft(const bool doublegrid, const int istep) */ } -#ifdef __FP - if(BFIELD) - { - if(NSPIN==2) - { - bfid.add_zeeman(); - } - } -#endif timer::tick("potential","set_vrs_tddft"); return; From 56481114b6e755672e3d00513b19437a9a8cdbae Mon Sep 17 00:00:00 2001 From: mohanchen Date: Sun, 31 Jan 2021 11:10:01 +0800 Subject: [PATCH 048/233] update dc_driv, delete useless divide-and-conquer related codes --- ABACUS.develop/source/dc_driv.cpp | 80 ++++++++++--------- ABACUS.develop/source/dc_driv.h | 46 ++--------- .../source/src_lcao/lcao_matrix.cpp | 28 +++++-- 3 files changed, 69 insertions(+), 85 deletions(-) diff --git a/ABACUS.develop/source/dc_driv.cpp b/ABACUS.develop/source/dc_driv.cpp index 543ecdc1ac..d8c4721e66 100644 --- a/ABACUS.develop/source/dc_driv.cpp +++ b/ABACUS.develop/source/dc_driv.cpp @@ -5,36 +5,36 @@ #include "src_lcao/global_fp.h" #include "src_pw/global.h" -DC_Driv::DC_Driv() -{} +DC_Driv::DC_Driv(){} + + +DC_Driv::~DC_Driv(){} -DC_Driv::~DC_Driv() -{} void DC_Driv::init() { TITLE("DC_Driv","init"); - time_t time_start = std::time(NULL); + time_t time_start = std::time(NULL); timer::start(); - // read the parameters. + + // (1) read the parameters. this->reading(); -#ifdef __FP - // divide the system into fragments. - this->divide_frag(); - // setup the information for each fragment. - this->setup_frag(); -#endif + // (2) prepare plane wave basis sets + this->prepare(); + + + // (3) welcome to the atomic world + this->welcome_to_atomic_world(); - // solve each fragment. - this->solve_eachf(); time_t time_finish= std::time(NULL); + // print out information before ABACUS ends cout << "\n START Time : " << ctime(&time_start); cout << " FINISH Time : " << ctime(&time_finish); cout << " TOTAL Time : " << difftime(time_finish, time_start) << endl; @@ -56,14 +56,22 @@ void DC_Driv::init() return; } + void DC_Driv::reading(void) { timer::tick("DC_Driv","reading",'A'); + + // reading input files from the 'INPUT' object + // the 'INPUT' is global and can be used anywhere, + // although I suggest you keep the parameters to be as + // local as possible -- mohan 2021-01-31 INPUT.Init( global_in_card ); Input_Conv::Convert(); Input_Conv::Convert_FP(); - + // there is a 'DIAGONALIZATION' world I define when I was young + // the 'DIAGO' world only uses computational resources that + // are needed for diagonalization of the Hamiltionian -- mohan 2021-01-31 Parallel_Global::split_diag_world(DIAGO_PROC); Parallel_Global::split_grid_world(DIAGO_PROC); OUT(ofs_running,"DRANK",DRANK+1); @@ -72,26 +80,32 @@ void DC_Driv::reading(void) OUT(ofs_running,"GRANK",GRANK+1); OUT(ofs_running,"GSIZE",GSIZE); + // call frag_init Run_Frag::frag_init(); - //if(LOCAL_BASIS==4 && LINEAR_SCALING) xiaohui modify 2013-09-01 + + // for LCAO basis, reading the orbitals and construct + // the interpolation tables. if(BASIS_TYPE=="lcao") //xiaohui add 2013-09-01 { - // read orbital information. - // init overlap matrix table. - // init kinetical matrix element table. - // init non-local pseudopotential matrix element table. + // init overlap matrix table, which is 'S Table' + // init kinetical matrix element table, which is 'T Table' + // init non-local pseudopotential matrix element table, which is 'NL Table' hm.hon.set_orb_tables(); - LM.divide_HS_in_frag(); //add 2015-09-06, xiaohui - } //add 2015-09-06, xiaohui + // xiaohui add 2015-09-06 + // (1) divide the H and S matrix into each CPU, count the dimensions + // (2) set the 'trace' between local H/S and global H/S + // (2) allocate the needed H and S memory + LM.divide_HS_in_frag(); + } if(CALCULATION=="scf" || CALCULATION=="relax" || CALCULATION=="cell-relax" || CALCULATION=="nscf" || CALCULATION=="istate" || CALCULATION=="ienvelope" - || CALCULATION=="md") //pengfei 2014-10-13 + || CALCULATION=="md") //pengfei add 2014-10-13 { //LM.divide_HS_in_frag(); //move it above 2015-09-06, xiaohui cout << " ---------------------------------------------------------" << endl; @@ -374,25 +388,20 @@ void DC_Driv::reading(void) return; } + #include "src_pw/cal_test.h" #include "src_pw/cal_test0.h" -//#include "../src_develop/src_dc/dc_info.h" void DC_Driv::divide_frag(void) { TITLE("DC_Driv","divide_frag"); timer::tick("DC_Driv","divide_frag",'A'); - // (1) Init the plane wave. + // (1) Initalize the plane wave basis set pw.gen_pw(ofs_running, ucell, kv); DONE(ofs_running,"INIT PLANEWAVE"); cout << " UNIFORM GRID DIM : " << pw.nx <<" * " << pw.ny <<" * "<< pw.nz << endl; cout << " UNIFORM GRID DIM(BIG): " << pw.nbx <<" * " << pw.nby <<" * "<< pw.nbz << endl; - //bool test_dc = false; - //if(test_dc) - //{ - // DC_Info::divide_fragments(ucell); - //} // mohan add 2010-10-10, just to test the symmetry of a variety // of systems. @@ -415,16 +424,11 @@ void DC_Driv::divide_frag(void) return; } -void DC_Driv::setup_frag(void) -{ - TITLE("DC_Driv","setup_frag"); -} - -void DC_Driv::solve_eachf(void) +void DC_Driv::solve(void) { - TITLE("DC_Driv","solve_eachf"); - timer::tick("DC_Driv","solve_eachf",'A'); + TITLE("DC_Driv","solve"); + timer::tick("DC_Driv","solve",'A'); Run_Frag RF; diff --git a/ABACUS.develop/source/dc_driv.h b/ABACUS.develop/source/dc_driv.h index cd6616004a..468e5e9052 100644 --- a/ABACUS.develop/source/dc_driv.h +++ b/ABACUS.develop/source/dc_driv.h @@ -5,39 +5,6 @@ #ifndef DC_DRIV_H #define DC_DRIV_H - -// DC stands for 'Divide and Conqure' and related methods. -// A DC class should contain the following important informations: -// -// (1) A 'reading' routine which read all the needed information, -// especially the dividsion method - -// (2) A 'divide_frag' routine which is in charge of divided pieces, -// setup the information for each pieces, and let the information -// can be easily accessed. - -// (3) A 'setup_frag' routine to setup the information for each -// fragment or others. - -// (4) A 'solve_each' routine which can be used to solve the -// Kohn-Sham equation in each 'piece', to get either charge density, -// potential, or even wave functions as new basis, or part of -// the Hamiltonian or Overlap matrix. - -// (4) A 'solve_interaction' to solve the interaction betweeen -// 'pieces', the results may turn out to be part of the Hamiltonian -// matrix. - -// (5) A 'solve_whole' routine which can be used solve the terms -// which must be calculated in the whole systen, such as the -// Hartree tern, the global plane wave can be genreated here. - -// (6) A 'conqure' routine to deal with the final information, -// either making the final H and S matrix, or patching each -// part of charge density together to calculate the error, -// Global Kohn-Sham equation may be solved here or not, -// depends which method we are using. - class DC_Driv { public: @@ -49,13 +16,14 @@ class DC_Driv private: + // reading the parameters void reading(); - void divide_frag(); - void setup_frag(); - void solve_eachf(); - void solve_interaction(); - void solve_whole(); - void conqure(); + + // prepare + void prepare(); + + // do stuff, have fun! + void welcome_to_atomic_world(); }; diff --git a/ABACUS.develop/source/src_lcao/lcao_matrix.cpp b/ABACUS.develop/source/src_lcao/lcao_matrix.cpp index 04cfd22521..ccd7adc857 100644 --- a/ABACUS.develop/source/src_lcao/lcao_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/lcao_matrix.cpp @@ -31,6 +31,7 @@ LCAO_Matrix::~LCAO_Matrix() delete[] Sdiag2; } + void LCAO_Matrix::divide_HS_in_frag(void) { TITLE("LCAO_Matrix","divide_HS_in_frag"); @@ -38,7 +39,6 @@ void LCAO_Matrix::divide_HS_in_frag(void) ofs_running << "\n SETUP THE DIVISION OF H/S MATRIX" << endl; // (1) calculate nrow, ncol, nloc. - //if (DIAGO_TYPE=="hpseps" || DIAGO_TYPE=="scalpack" || DIAGO_TYPE=="selinv") xiaohui modify 2013-09-02 if (KS_SOLVER=="genelpa" || KS_SOLVER=="hpseps" || KS_SOLVER=="scalpack" || KS_SOLVER=="selinv" || KS_SOLVER=="scalapack_gvx") //xiaohui add 2013-09-02 { ofs_running << " divide the H&S matrix using 2D block algorithms." << endl; @@ -48,25 +48,29 @@ void LCAO_Matrix::divide_HS_in_frag(void) WARNING_QUIT("LCAO_Matrix::init","diago_type = 'HPSEPS' is not available for series version.\n You can use 'LAPACK' instead."); #endif } - //else if (DIAGO_TYPE == "canonical" - // || DIAGO_TYPE == "trace_resetting" - // || DIAGO_TYPE == "trace_correcting") xiaohui modify 2013-09-02 else if(KS_SOLVER == "canonical" || KS_SOLVER == "trace_resetting" - || KS_SOLVER == "trace_correcting") //xiaohui add 2013-09-02 - { + || KS_SOLVER == "trace_correcting") + { + //------------------------------------------------------------------------------------- + // This part is intended for linear-scaling solver for KS matrix utilizing + // the sparse matrices. The developments of these parts need to have efficient + // algorithms to design, distribute (parallel), and operate sprase Hamiltionian + // matrix (H), sparse density matrix (DM), and sparse overlap matrix (S),etc. + // in localized basis sets -- mohan 2021-01-31 + //------------------------------------------------------------------------------------- ofs_running << " divide the H&S matrix according to atoms." << endl; // done nothing. // the nloc is calculated in "ParaA.set_trace" } else { + // the full matrix ParaO.nloc = NLOCAL * NLOCAL; } - // (2) set the trace, then we - // can calculate the nnr. + // (2) set the trace, then we can calculate the nnr. // for 2d: calculate ParaO.nloc first, then trace_loc_row and trace_loc_col // for O(N): calculate the three together. ParaO.set_trace(); @@ -87,6 +91,7 @@ void LCAO_Matrix::divide_HS_in_frag(void) return; } + void LCAO_Matrix::allocate_HS_gamma(const long &nloc) { TITLE("LCAO_Matrix","allocate_HS_gamma"); @@ -94,6 +99,9 @@ void LCAO_Matrix::allocate_HS_gamma(const long &nloc) OUT(ofs_running,"nloc",nloc); if(nloc==0) return; //mohan fix bug 2012-05-25 + // because we initilize in the constructor function + // with dimension '1', so here we reconstruct these + // matrices delete[] Sloc; delete[] Hloc_fixed; delete[] Hloc; @@ -107,6 +115,7 @@ void LCAO_Matrix::allocate_HS_gamma(const long &nloc) ZEROS(Sloc,nloc); ZEROS(Hloc_fixed,nloc); ZEROS(Hloc,nloc); + ZEROS(Sdiag,nloc); // mohan add 2021-01-30 return; } @@ -119,6 +128,9 @@ void LCAO_Matrix::allocate_HS_k(const long &nloc) OUT(ofs_running,"nloc",nloc); if(nloc==0) return; //mohan fix bug 2012-05-25 + // because we initilize in the constructor function + // with dimension '1', so here we reconstruct these + // matrices delete[] Sloc2; delete[] Hloc_fixed2; delete[] Hloc2; From 8311bef9b02527121183dc0f7fd64f024ceb8999 Mon Sep 17 00:00:00 2001 From: mohanchen Date: Sun, 31 Jan 2021 11:45:03 +0800 Subject: [PATCH 049/233] update the main directory --- ABACUS.develop/source/dc_driv.cpp | 102 ++---- ABACUS.develop/source/dc_driv.h | 2 +- ABACUS.develop/source/run_frag.cpp | 341 +++++------------- ABACUS.develop/source/run_frag.h | 26 +- .../source/src_lcao/hamilt_linear.cpp | 7 - .../source/src_lcao/local_orbital_ions.cpp | 4 +- ABACUS.develop/source/src_pw/ions.cpp | 4 +- 7 files changed, 134 insertions(+), 352 deletions(-) diff --git a/ABACUS.develop/source/dc_driv.cpp b/ABACUS.develop/source/dc_driv.cpp index d8c4721e66..2211d18f83 100644 --- a/ABACUS.develop/source/dc_driv.cpp +++ b/ABACUS.develop/source/dc_driv.cpp @@ -28,8 +28,8 @@ void DC_Driv::init() this->prepare(); - // (3) welcome to the atomic world - this->welcome_to_atomic_world(); + // (3) welcome to the atomic world! + this->atomic_world(); time_t time_finish= std::time(NULL); @@ -80,12 +80,19 @@ void DC_Driv::reading(void) OUT(ofs_running,"GRANK",GRANK+1); OUT(ofs_running,"GSIZE",GSIZE); + //---------------------------------- // call frag_init - Run_Frag::frag_init(); + // * divide the k-points into NPOOL + // * setup the unit cell + // * do symmetry analysis + // * setup the k-points + //---------------------------------- + Run_Frag::init(); // for LCAO basis, reading the orbitals and construct // the interpolation tables. + // this part should be moved somewher else -- mohan 2021-01-30 if(BASIS_TYPE=="lcao") //xiaohui add 2013-09-01 { // read orbital information. @@ -101,8 +108,8 @@ void DC_Driv::reading(void) LM.divide_HS_in_frag(); } - - + + // the following printing information should be moved to somewhere else -- mohan 2021-01-30 if(CALCULATION=="scf" || CALCULATION=="relax" || CALCULATION=="cell-relax" || CALCULATION=="nscf" || CALCULATION=="istate" || CALCULATION=="ienvelope" || CALCULATION=="md") //pengfei add 2014-10-13 @@ -340,49 +347,14 @@ void DC_Driv::reading(void) cout << endl; } - - - - - - cout << " ---------------------------------------------------------" << endl; cout << " Initial plane wave basis and FFT box" << endl; cout << " ---------------------------------------------------------" << endl; - // cout << " GRID_SPEED : " << GRID_SPEED << endl; } - //} //delete 2015-09-06, xiaohui - /* - else if(BASIS_TYPE=="pw") //2015-09-06, xiaohui - { - cout << " " << setw(8) << "ELEMENT"; - cout << setw(12) << "NATOM"; - cout << setw(12) << "XC"; - cout << endl; - for(int it=0; it 1, After reading in NPOOL, + // (1) If k point number > 1, After reading in NPOOL, // divide the NPROC processprs into NPOOL. Pkpoints.init(); #endif - // (3) Read in parameters about wannier functions. + // (2) Read in parameters about wannier functions. winput::Init( global_wannier_card ); //xiaohui move 3 lines, 2015-09-30 @@ -171,34 +37,32 @@ void Run_Frag::frag_init(void) //ss2 << global_out_dir << "INPUTw"; //winput::Print( ss2.str() ); - // (4) Print the parameters into INPUT file. + // (3) Print the parameters into INPUT file. stringstream ss1; ss1 << global_out_dir << global_in_card; INPUT.Print( ss1.str() ); //DONE(ofs_running,"READING CARDS"); - // (5) Setup the unitcell. + // (4) Setup the unitcell. ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running); DONE(ofs_running, "SETUP UNITCELL"); - // (6) symmetry analysize. + // (5) symmetry analysize. if (SYMMETRY) { symm.analy_sys(); DONE(ofs_running, "SYMMETRY"); } - // (7) Setup the k points according to symmetry. + // (6) Setup the k points according to symmetry. kv.set( symm, global_kpoint_card, NSPIN, ucell.G, ucell.latvec ); DONE(ofs_running,"INIT K-POINTS"); - // (8) About Wannier functions, not used now. - //wannier::init_dir( ofs_running ); - // (9) check the number of basis + // (7) check the number of basis, the warning should be moved to + // other places -- mohan 2021-01-30 // mohan add 2011-01-5 - //if( LOCAL_BASIS ) xiaohui modify 2013-09-01 - if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-01. Attention! Maybe there is some problem. + if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") { if( NLOCAL < NBANDS ) { @@ -212,20 +76,21 @@ void Run_Frag::frag_init(void) } } - timer::tick("Run_Frag","frag_init",'B'); + timer::tick("Run_Frag","init",'B'); return; } -void Run_Frag::frag_LCAO_line(void) + +void Run_Frag::LCAO_line(void) { - TITLE("Run_Frag","frag_lcao_line"); - timer::tick("Run_Frag","frag_LCAO_line",'B'); + TITLE("Run_Frag","lcao_line"); + timer::tick("Run_Frag","LCAO_line",'B'); - // (2) Init the charge density. + // (1) Init the charge density. chr.init(); DONE(ofs_running,"INIT CHARGE"); - // (3) Init the potential. + // (2) Init the potential. pot.init(pw.nrxx); DONE(ofs_running,"INIT POTENTIAL"); @@ -233,75 +98,74 @@ void Run_Frag::frag_LCAO_line(void) enum use_wf_coef {SOME_PW, ALL_LO}; use_wf_coef uoc = ALL_LO; - switch (uoc) - { - case ALL_LO: - // (4) Init the local wave functions. - wf.init_local(); - // (5) Init the FFT. - UFFT.allocate(); - // (6) Init the hamiltonian. - // first0 stands for nkb, but no used. - // second0 stands for no use hpw.init() - hm.init(0); - // (7) Init the local part of NC pseudopotential. - ppcell.init_vloc(); - // (8) Init the potential. - pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs - break; - case SOME_PW: - wf.init(kv.nks); - UFFT.allocate(); - ppcell.init(ucell.ntype); - hm.init(); - ppcell.init_vloc(); - ppcell.init_vnl(); - pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs - pot.newd();//once - DONE(ofs_running,"INIT POTENTIAL"); - wf.wfcinit(); - DONE(ofs_running,"INIT SOME_PW"); - break; - } + switch (uoc) + { + case ALL_LO: + // (4) Init the local wave functions. + wf.init_local(); + // (5) Init the FFT. + UFFT.allocate(); + // (6) Init the hamiltonian. + // first0 stands for nkb, but no used. + // second0 stands for no use hpw.init() + hm.init(0); + // (7) Init the local part of NC pseudopotential. + ppcell.init_vloc(); + // (8) Init the potential. + pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs + break; + case SOME_PW: + wf.init(kv.nks); + UFFT.allocate(); + ppcell.init(ucell.ntype); + hm.init(); + ppcell.init_vloc(); + ppcell.init_vnl(); + pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs + pot.newd();//once + DONE(ofs_running,"INIT POTENTIAL"); + wf.wfcinit(); + DONE(ofs_running,"INIT SOME_PW"); + break; + } - //Quxin added for DFT+U - if(INPUT.dft_plus_u) dftu.init(); + // Quxin added for DFT+U + if(INPUT.dft_plus_u) + { + dftu.init(); + } Local_Orbital_Ions ions; ions.opt_ions(); en.perform_dos(); - timer::tick("Run_Frag","frag_LCAO_line",'B'); + timer::tick("Run_Frag","LCAO_line",'B'); return; } -void Run_Frag::frag_pw_line(void) + + +void Run_Frag::plane_wave_line(void) { - TITLE("Run_Frag","frag_pw_line"); - timer::tick("Run_Frag","frag_pw_line",'B'); + TITLE("Run_Frag","plane_wave_line"); + timer::tick("Run_Frag","plane_wave_line",'B'); //---------------------------------------------------------- -// preprocess part, consist of : -// 1 print out copyright informations: version,authors, ... -// 2 read in initial data: +// 1 read in initial data: // a lattice structure:atom_species,atom_positions,lattice vector // b k_points // c pseudopotential -// 3 setup planeware basis, FFT,structure factor, ... -// 4 initialize local and nonlocal pseudopotential in G_space -// 5 initialize charge desity and warefunctios in G_space +// 2 setup planeware basis, FFT,structure factor, ... +// 3 initialize local and nonlocal pseudopotential in G_space +// 4 initialize charge desity and warefunctios in G_space //---------------------------------------------------------- - //if (winput::begin_stop_flag) - //{ - // wannier::begin_stop(); - //} - //===================== // init potential //===================== chr.init(); pot.init(pw.nrxx); + //===================== // init wave functions //===================== @@ -312,21 +176,25 @@ void Run_Frag::frag_pw_line(void) // init pseudopotential //======================= ppcell.init(ucell.ntype); + //===================== // init hamiltonian //===================== hm.init(); // DONE(ofs_running,"CHARGE, POTENTIAL, WAVE FUNCTINOS ALLOCATION"); + //================================= // initalize local pseudopotential //================================= ppcell.init_vloc(); DONE(ofs_running,"LOCAL POTENTIAL"); + //====================================== // Initalize non local pseudopotential //====================================== ppcell.init_vnl(); DONE(ofs_running,"NON-LOCAL POTENTIAL"); + //========================================================= // calculate the total local pseudopotential in real space //========================================================= @@ -339,36 +207,22 @@ void Run_Frag::frag_pw_line(void) // create ppcell.tab_at , for trial wave functions. //================================================== wf.init_at_1(); - //================================== - // Initial localized wave functions - //================================== - //if (LOCAL_BASIS == 1) wannier::running( ofs_running ); //================================ // Initial start wave functions //================================ wf.wfcinit(); - //if (winput::before_iter) - //{ - // wannier::running( ofs_running ) ; - // return; - //} DONE(ofs_running,"INIT BASIS"); - //========================================================= - // - // Third Part: Electronic structure calculation begin! - // - //========================================================= - // -// if(SCF || (!SCF && LOCAL_BASIS==0) ) -// { + + // ion optimization begins + // electron density optimization is included in ion optimization Ions ions; ions.opt_ions_pw(); - // caoyu added 2020-11-24, mohan updated 2021-01-03 + // caoyu add 2020-11-24, mohan updat 2021-01-03 if(BASIS_TYPE=="pw" && INPUT.out_descriptor==1) { Numerical_Descriptor nc; @@ -376,8 +230,7 @@ void Run_Frag::frag_pw_line(void) DONE(ofs_running,"GENERATE DESCRIPTOR FOR DEEPKS"); } -// } - //if (LOCAL_BASIS==0 && winput::out_spillage) xiaohui modify 2013-09-01 + if(BASIS_TYPE=="pw" && winput::out_spillage) //xiaohui add 2013-09-01 { //cout << "\n Output Spillage Information : " << endl; @@ -394,7 +247,7 @@ void Run_Frag::frag_pw_line(void) { wf.wanf2[ik].create(NLOCAL, wf.npwx); //if ( LOCAL_BASIS == 3 || LOCAL_BASIS == 0 ) xiaohui modify 2013-09-01 - if(BASIS_TYPE=="pw") //xiaohui add 2013-09-01. Attention! "LOCAL_BASIS==3"??? + if(BASIS_TYPE=="pw") //xiaohui add 2013-09-01. Attention! "LOCAL_BASIS==3"??? { cout << " ik=" << ik + 1 << endl; @@ -420,6 +273,7 @@ void Run_Frag::frag_pw_line(void) //Spillage sp; //sp.get_both(NBANDS, NLOCAL, wf.wanf2, wf.evc); } + // output overlap if ( winput::out_spillage <= 2 ) { @@ -429,36 +283,25 @@ void Run_Frag::frag_pw_line(void) } } - //if (winput::end_flag) - //{ - // wannier::end(); - //} - //if (winput::after_iter) - //{ - // wannier::running( ofs_running ); - //}//mohan - //if (Optical::opt_epsilon2 && LINEAR_SCALING==0 ) xiaohui modify 2013-09-01 - if(Optical::opt_epsilon2 && (BASIS_TYPE=="pw" || BASIS_TYPE=="lcao_in_pw")) //xiaohui add 2013-09-01. Attention! Maybe there is some problem. + + //xiaohui add 2013-09-01. Attention! Maybe there is some problem. + if(Optical::opt_epsilon2 && (BASIS_TYPE=="pw" || BASIS_TYPE=="lcao_in_pw")) { Optical opt; opt.cal_epsilon2(NBANDS); } - //if (MLWF_FLAG) - //{ - //mlwf_optimize op; - //op.wannierise(); - //DONE(ofs_running,"MAXIMALLY LOCALIZED WANNIER FUNCTIONS"); - //} + // compute density of states en.perform_dos(); - timer::tick("Run_Frag","frag_pw_line",'B'); + timer::tick("Run_Frag","plane_wave_line",'B'); return; } -void Run_Frag::frag_linear_scaling_line(void) + +void Run_Frag::linear_scaling_line(void) { - TITLE("Run_Frag","frag_linear_scaling_line"); + TITLE("Run_Frag","linear_scaling_line"); // (2) Init the charge density. chr.init(); @@ -516,16 +359,14 @@ void Run_Frag::frag_linear_scaling_line(void) return; } -void Run_Frag::frag_test(void) -{ - -} //LiuXh add a new function here, //which is used to do initialization after variable cell //20180515 -void Run_Frag::frag_init_after_vc(void) +void Run_Frag::init_after_vc(void) { + TITLE("Run_Frag","init_after_vc"); + ucell.setup_cell_after_vc(global_pseudo_dir, global_atom_card, ofs_running); DONE(ofs_running, "SETUP UNITCELL"); @@ -574,6 +415,7 @@ void Run_Frag::frag_init_after_vc(void) return; } + //LiuXh add a new function here, //which is used to do initialization after variable cell //20180619 @@ -683,4 +525,3 @@ void Run_Frag::final_calculation_after_vc(void) DONE(ofs_running,"INIT BASIS"); } } -#endif diff --git a/ABACUS.develop/source/run_frag.h b/ABACUS.develop/source/run_frag.h index a99db5b50a..3bd1c8bd23 100644 --- a/ABACUS.develop/source/run_frag.h +++ b/ABACUS.develop/source/run_frag.h @@ -10,23 +10,29 @@ class Run_Frag { + public: Run_Frag(); ~Run_Frag(); -#ifdef __FP - static void frag_init(void); - void frag_test(void); - void frag_pw_line(void); - void frag_LCAO_line(void); - void frag_linear_scaling_line(void); - static void frag_init_after_vc(void); //LiuXh add 20180515 - static void final_calculation_after_vc(void); //LiuXh add 20180619 -#endif + static void init(void); + + // perform Linear Combination of Atomic Orbitals (LCAO) calculations + void LCAO_line(void); +\ + // perform plane wave basis calculations + void plane_wave_line(void); + + // perform linear-scaling calculations for sparse matrix H and S + // useless now + void linear_scaling_line(void); - void pw_line(void); + static void init_after_vc(void); //LiuXh add 20180515 + + + static void final_calculation_after_vc(void); //LiuXh add 20180619 }; diff --git a/ABACUS.develop/source/src_lcao/hamilt_linear.cpp b/ABACUS.develop/source/src_lcao/hamilt_linear.cpp index 408ef12f4e..a443634ec2 100644 --- a/ABACUS.develop/source/src_lcao/hamilt_linear.cpp +++ b/ABACUS.develop/source/src_lcao/hamilt_linear.cpp @@ -22,13 +22,6 @@ void Hamilt_Linear::set_orb_tables(void) TITLE("Hamilt_Linear","set_orb_tables"); timer::tick("Hamilt_Linear","set_orb_tables",'B'); - //xiaohui modify 2013-09-02 - //if(!LINEAR_SCALING) - //{ - // timer::tick("Hamilt_Linear","set_orb_tables",'B'); - // return; //mohan add 2009-12-22 - //} xiaohui modify 2013-09-02. Attention... - //============================================================================= // (1) FUNCTION : use 'info' to generate 'Numerical Orbital' // (1) RESULT : We have 'Numerical Orbital' for calculate S-table and T-table. diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index e6d7f8d662..ffde2a8cee 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -676,7 +676,7 @@ xiaohui modify 2014-08-09*/ } else { - Run_Frag::frag_init_after_vc(); + Run_Frag::init_after_vc(); pot.init_pot(stress_step); ++stress_step; @@ -722,7 +722,7 @@ xiaohui modify 2014-08-09*/ } else { - Run_Frag::frag_init_after_vc(); + Run_Frag::init_after_vc(); pot.init_pot(stress_step); ++stress_step; diff --git a/ABACUS.develop/source/src_pw/ions.cpp b/ABACUS.develop/source/src_pw/ions.cpp index 74590095fc..7dc9b5ae8d 100644 --- a/ABACUS.develop/source/src_pw/ions.cpp +++ b/ABACUS.develop/source/src_pw/ions.cpp @@ -331,7 +331,7 @@ bool Ions::force_stress(const int &istep, int &force_step, int &stress_step) // } else { - Run_Frag::frag_init_after_vc(); + Run_Frag::init_after_vc(); //pot.init_pot(0); pot.init_pot(stress_step); //LiuXh add 20180619 ofs_running << " Setup the new wave functions?" << endl; //LiuXh add 20180619 @@ -393,7 +393,7 @@ bool Ions::force_stress(const int &istep, int &force_step, int &stress_step) // } else { - Run_Frag::frag_init_after_vc(); + Run_Frag::init_after_vc(); //pot.init_pot(0); pot.init_pot(stress_step); //LiuXh add 20180619 From e4d7e86efa129694a219002ff0e6dcd0ee2120e6 Mon Sep 17 00:00:00 2001 From: mohanchen Date: Sun, 31 Jan 2021 14:50:39 +0800 Subject: [PATCH 050/233] add print_info, update dc_driv --- ABACUS.develop/source/Makefile.Objects | 1 + ABACUS.develop/source/dc_driv.cpp | 281 +----------------- ABACUS.develop/source/dc_driv.h | 3 - ABACUS.develop/source/input_conv.cpp | 111 ++++--- ABACUS.develop/source/run_frag.cpp | 6 +- ABACUS.develop/source/run_frag.h | 2 +- .../source/src_global/global_variable.h | 22 +- .../source/src_global/print_info.cpp | 262 ++++++++++++++++ ABACUS.develop/source/src_global/print_info.h | 20 ++ ABACUS.develop/source/src_lcao/global_fp.h | 4 +- .../source/src_lcao/local_orbital_elec.cpp | 34 +-- 11 files changed, 380 insertions(+), 366 deletions(-) create mode 100644 ABACUS.develop/source/src_global/print_info.cpp create mode 100644 ABACUS.develop/source/src_global/print_info.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 9481b1cd1b..229cfe5e7d 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -77,6 +77,7 @@ sparsematrix.o\ export.o\ timer.o\ memory.o\ +print_info.o\ mathzone.o\ mathzone_add1.o\ integral.o \ diff --git a/ABACUS.develop/source/dc_driv.cpp b/ABACUS.develop/source/dc_driv.cpp index 2211d18f83..06480ed17a 100644 --- a/ABACUS.develop/source/dc_driv.cpp +++ b/ABACUS.develop/source/dc_driv.cpp @@ -4,6 +4,10 @@ #include "input_conv.h" #include "src_lcao/global_fp.h" #include "src_pw/global.h" +#include "src_global/print_info.h" + +#include "src_pw/cal_test.h" +#include "src_pw/cal_test0.h" DC_Driv::DC_Driv(){} @@ -20,15 +24,11 @@ void DC_Driv::init() timer::start(); - // (1) read the parameters. + // (1) read the input parameters. this->reading(); - // (2) prepare plane wave basis sets - this->prepare(); - - - // (3) welcome to the atomic world! + // (2) welcome to the atomic world! this->atomic_world(); @@ -66,6 +66,8 @@ void DC_Driv::reading(void) // although I suggest you keep the parameters to be as // local as possible -- mohan 2021-01-31 INPUT.Init( global_in_card ); + + // copy the variables from INPUT to each class Input_Conv::Convert(); Input_Conv::Convert_FP(); @@ -108,267 +110,14 @@ void DC_Driv::reading(void) LM.divide_HS_in_frag(); } - - // the following printing information should be moved to somewhere else -- mohan 2021-01-30 - if(CALCULATION=="scf" || CALCULATION=="relax" || CALCULATION=="cell-relax" || CALCULATION=="nscf" - || CALCULATION=="istate" || CALCULATION=="ienvelope" - || CALCULATION=="md") //pengfei add 2014-10-13 - { - //LM.divide_HS_in_frag(); //move it above 2015-09-06, xiaohui - cout << " ---------------------------------------------------------" << endl; - if(CALCULATION=="scf") - { - cout << " This calculation is self-consistent" << endl; - } - else if(CALCULATION=="test") - { - cout << " This calculation is for test" << endl; - } - if(CALCULATION=="relax") //add 4 lines 2015-09-06, xiaohui - { - //cout << " This calculation is structure relaxation" << endl; - cout << " This calculation is ion relaxation" << endl; - } - if(CALCULATION=="cell-relax") - { - cout << " This calculation is cell relaxation" << endl; - } - if(CALCULATION=="md") //add 4 lines 2015-09-06, xiaohui - { - cout << " This calculation is molecular dynamics" << endl; - - //xiaohui add 2015-09-15 - cout << " ---------------------------------------------------------" << endl; - - if(INPUT.md_mdtype ==1 || INPUT.md_mdtype==2) - { - cout << " ENSEMBLE : " << "NVT" << endl; - } - else if(INPUT.md_mdtype==0) - { - cout << " ENSEMBLE : " << "NVE" << endl; - } - cout << " Qmass for NVT(a.u.) : " << INPUT.md_qmass/6.02/9.109*1e5 << endl; - cout << " Time interval(fs) : " << INPUT.md_dt << endl; - } - cout << " ---------------------------------------------------------" << endl; - - - // TITLE - cout << " " << setw(8) << "SPIN" - << setw(16) << "KPOINTS" - << setw(12) << "PROCESSORS"; - - //if(LOCAL_BASIS==4) xiaohui modify 2013-09-01 - if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-01 - { - cout << setw(12) << "NBASE"; - cout << setw(12) << "VNA"; - } - - cout << endl; - - - - // data - cout << " " << setw(8) << NSPIN; - - if(GAMMA_ONLY_LOCAL) - { - if(COLOUR && MY_RANK==0) - { - // red - //printf( "\e[31m%-16s\e[0m", "Gamma"); - printf( "[31m%-16s[0m", "Gamma"); - } - else - { - cout << setw(16) << "Gamma"; - } - } - else - { - if(COLOUR && MY_RANK==0) - { - // zi - //printf( "\e[35m%-16d\e[0m", kv.nkstot); - printf( "[35m%-16d[0m", kv.nkstot); - } - else - { - cout << setw(16) << kv.nkstot; - } - } - - cout << setw(12) << NPROC; - - //if(LOCAL_BASIS==4) xiaohui modify 2013-09-01 - if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-01 - { - cout << setw(12) << NLOCAL; - - if(VNA==0) - cout << setw(12) << "No"; - else if(VNA>0) - cout << setw(12) << "Yes"; - } - - cout << endl; - - - - - cout << " ---------------------------------------------------------" << endl; - //if(LOCAL_BASIS==4 && LINEAR_SCALING==1) xiaohui modify 2013-09-01 - if(BASIS_TYPE=="lcao") //xiaohui add 2013-09-01 - { - if(COLOUR && MY_RANK==0) - { - string a = "Use Systematically Improvable Atomic bases"; - //printf( " \e[36m%-45s\e[0m\n", a.c_str()); - printf( " [36m%-45s[0m\n", a.c_str()); - } - else - { - cout << " Use Systematically Improvable Atomic bases" << endl; - } - } - //else if(LOCAL_BASIS==4 && LINEAR_SCALING==0) xiaohui modify 2013-09-01 - else if(BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-01 - { - //cout << " Expand Systematically Improvable Atomic bases into plane waves" << endl; - cout << " Expand Atomic bases into plane waves" << endl; - } - //else if(LOCAL_BASIS==0 && LINEAR_SCALING==0) xiaohui modify 2013-09-01 - else if(BASIS_TYPE=="pw") //xiaohui add 2013-09-01 - { - cout << " Use plane wave basis" << endl; - } - cout << " ---------------------------------------------------------" << endl; - - - - //---------------------------------- - // second part - //---------------------------------- - - cout << " " << setw(8) << "ELEMENT"; - - //if(LOCAL_BASIS==4) xiaohui modify 2013-09-01 - if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-01 - { - cout << setw(16) << "ORBITALS"; - cout << setw(12) << "NBASE"; - //cout << setw(12) << "NATOM"; //move it below 2015-09-06, xiaohui - } - cout << setw(12) << "NATOM"; //add 2015-09-06, xiaohui - - cout << setw(12) << "XC"; - cout << endl; - - - - for(int it=0; it0) + cout << setw(12) << "Yes"; + } + + cout << endl; + + + + + cout << " ---------------------------------------------------------" << endl; + //if(LOCAL_BASIS==4 && LINEAR_SCALING==1) xiaohui modify 2013-09-01 + if(BASIS_TYPE=="lcao") //xiaohui add 2013-09-01 + { + if(COLOUR && MY_RANK==0) + { + string a = "Use Systematically Improvable Atomic bases"; + //printf( " \e[36m%-45s\e[0m\n", a.c_str()); + printf( " [36m%-45s[0m\n", a.c_str()); + } + else + { + cout << " Use Systematically Improvable Atomic bases" << endl; + } + } + //else if(LOCAL_BASIS==4 && LINEAR_SCALING==0) xiaohui modify 2013-09-01 + else if(BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-01 + { + //cout << " Expand Systematically Improvable Atomic bases into plane waves" << endl; + cout << " Expand Atomic bases into plane waves" << endl; + } + //else if(LOCAL_BASIS==0 && LINEAR_SCALING==0) xiaohui modify 2013-09-01 + else if(BASIS_TYPE=="pw") //xiaohui add 2013-09-01 + { + cout << " Use plane wave basis" << endl; + } + cout << " ---------------------------------------------------------" << endl; + + + + //---------------------------------- + // second part + //---------------------------------- + + cout << " " << setw(8) << "ELEMENT"; + + //if(LOCAL_BASIS==4) xiaohui modify 2013-09-01 + if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-01 + { + cout << setw(16) << "ORBITALS"; + cout << setw(12) << "NBASE"; + //cout << setw(12) << "NATOM"; //move it below 2015-09-06, xiaohui + } + cout << setw(12) << "NATOM"; //add 2015-09-06, xiaohui + + cout << setw(12) << "XC"; + cout << endl; + + + + for(int it=0; it Date: Sun, 31 Jan 2021 17:36:30 +0800 Subject: [PATCH 051/233] add electrons_stochastic class in src_pw; add rwstream class in src_global; ion is no longer inherited from electrons; change chr. to CHR. in global --- ABACUS.develop/source/Makefile.Objects | 2 + ABACUS.develop/source/input_conv.cpp | 6 +- ABACUS.develop/source/run_frag.cpp | 8 +- .../src_external/src_pdiag/pdiag_double.cpp | 2 +- ABACUS.develop/source/src_global/restart.cpp | 6 +- ABACUS.develop/source/src_global/rwstream.cpp | 44 + ABACUS.develop/source/src_global/rwstream.h | 103 ++ ABACUS.develop/source/src_lcao/dftu.cpp | 2 +- ABACUS.develop/source/src_lcao/force_lcao.cpp | 6 +- .../source/src_lcao/gint_gamma_mull.cpp | 2 +- .../source/src_lcao/gint_gamma_rho.cpp | 4 +- .../source/src_lcao/gint_gamma_vl.cpp | 2 +- ABACUS.develop/source/src_lcao/gint_k_rho.cpp | 4 +- .../source/src_lcao/gint_speed_rho.cpp | 4 +- .../source/src_lcao/grid_integral.cpp | 2 +- .../source/src_lcao/istate_charge.cpp | 6 +- .../source/src_lcao/istate_envelope.cpp | 8 +- .../source/src_lcao/local_orbital_charge.cpp | 4 +- .../source/src_lcao/local_orbital_elec.cpp | 40 +- .../source/src_lcao/local_orbital_ions.cpp | 4 +- .../source/src_lcao/stress_lcao.cpp | 24 +- .../source/src_lcao/update_input.cpp | 16 +- .../source/src_parallel/parallel_global.cpp | 3 +- .../source/src_parallel/parallel_kpoints.h | 8 +- ABACUS.develop/source/src_pw/cal_test.cpp | 12 +- ABACUS.develop/source/src_pw/charge.h | 7 +- .../source/src_pw/charge_broyden.cpp | 1 + ABACUS.develop/source/src_pw/charge_broyden.h | 6 +- ABACUS.develop/source/src_pw/charge_extra.cpp | 40 +- ABACUS.develop/source/src_pw/charge_pulay.h | 6 +- ABACUS.develop/source/src_pw/electrons.cpp | 106 +- ABACUS.develop/source/src_pw/electrons.h | 27 +- .../source/src_pw/electrons_stochastic.cpp | 388 ++++++ .../source/src_pw/electrons_stochastic.h | 30 + ABACUS.develop/source/src_pw/energy.cpp | 1126 +++++++++-------- ABACUS.develop/source/src_pw/energy.h | 3 +- ABACUS.develop/source/src_pw/eximport.cpp | 22 +- ABACUS.develop/source/src_pw/forces.cpp | 6 +- ABACUS.develop/source/src_pw/gga_pw.cpp | 48 +- ABACUS.develop/source/src_pw/global.cpp | 3 +- ABACUS.develop/source/src_pw/global.h | 5 +- ABACUS.develop/source/src_pw/hamilt_pw.h | 8 +- ABACUS.develop/source/src_pw/ions.cpp | 154 +-- ABACUS.develop/source/src_pw/ions.h | 18 +- ABACUS.develop/source/src_pw/lattlib.F | 930 -------------- ABACUS.develop/source/src_pw/magnetism.cpp | 10 +- ABACUS.develop/source/src_pw/potential.cpp | 40 +- ABACUS.develop/source/src_pw/stress.cpp | 40 +- ABACUS.develop/source/src_pw/symmetry_rho.cpp | 4 +- ABACUS.develop/source/src_pw/threshold_elec.h | 1 + ABACUS.develop/source/src_pw/wavefunc.h | 2 +- ABACUS.develop/source/src_pw/wf_io.cpp | 230 ++-- ABACUS.develop/source/src_pw/wf_io.h | 3 +- 53 files changed, 1649 insertions(+), 1937 deletions(-) create mode 100644 ABACUS.develop/source/src_global/rwstream.cpp create mode 100644 ABACUS.develop/source/src_global/rwstream.h create mode 100644 ABACUS.develop/source/src_pw/electrons_stochastic.cpp create mode 100644 ABACUS.develop/source/src_pw/electrons_stochastic.h delete mode 100644 ABACUS.develop/source/src_pw/lattlib.F diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 229cfe5e7d..bdce423f44 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -46,6 +46,7 @@ atom_pseudo.o\ unitcell_pseudo.o\ threshold_elec.o\ electrons.o \ +electrons_stochastic.o\ forces.o\ stress.o\ myfunc1.o\ @@ -235,6 +236,7 @@ inverse_matrix.o \ energy.o \ wavefunc.o\ wf_io.o \ +rwstream.o\ wf_atomic.o \ wf_igk.o \ use_fft.o\ diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index fb67c373d6..21c668184c 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -579,8 +579,8 @@ void Input_Conv::Convert_FP(void) //---------------------------------------------------------- // charge mixing(3/3) //---------------------------------------------------------- - //chr.set_mixing(INPUT.mixing_mode, INPUT.mixing_beta, INPUT.mixing_ndim); - chr.set_mixing(INPUT.mixing_mode, INPUT.mixing_beta, INPUT.mixing_ndim, INPUT.mixing_gg0); //mohan modify 2014-09-27, add mixing_gg0 + //CHR.set_mixing(INPUT.mixing_mode, INPUT.mixing_beta, INPUT.mixing_ndim); + CHR.set_mixing(INPUT.mixing_mode, INPUT.mixing_beta, INPUT.mixing_ndim, INPUT.mixing_gg0); //mohan modify 2014-09-27, add mixing_gg0 //---------------------------------------------------------- // iteration (2/3) @@ -593,7 +593,7 @@ void Input_Conv::Convert_FP(void) //---------------------------------------------------------- pot.start_pot = INPUT.start_pot; pot.extra_pot = INPUT.charge_extrap;//xiaohui modify 2015-02-01 - chr.out_charge = INPUT.out_charge; + CHR.out_charge = INPUT.out_charge; pot.out_potential = INPUT.out_potential; wf.out_wf = INPUT.out_wf; en.out_dos = INPUT.out_dos; diff --git a/ABACUS.develop/source/run_frag.cpp b/ABACUS.develop/source/run_frag.cpp index e689ce80ef..c66323254c 100644 --- a/ABACUS.develop/source/run_frag.cpp +++ b/ABACUS.develop/source/run_frag.cpp @@ -91,7 +91,7 @@ void Run_Frag::LCAO_line(void) timer::tick("Run_Frag","LCAO_line",'B'); // (1) Init the charge density. - chr.init(); + CHR.init(); DONE(ofs_running,"INIT CHARGE"); // (2) Init the potential. @@ -167,7 +167,7 @@ void Run_Frag::plane_wave_line(void) //===================== // init potential //===================== - chr.init(); + CHR.init(); pot.init(pw.nrxx); //===================== @@ -308,7 +308,7 @@ void Run_Frag::linear_scaling_line(void) TITLE("Run_Frag","linear_scaling_line"); // (2) Init the charge density. - chr.init(); + CHR.init(); DONE(ofs_running,"INIT CHARGE"); // (3) Init the potential. @@ -471,7 +471,7 @@ void Run_Frag::final_calculation_after_vc(void) //===================== // init potential //===================== - chr.init_final_scf(); + CHR.init_final_scf(); pot.init(pw.nrxx); //===================== // init wave functions diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp b/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp index caa3417198..e434ea16d1 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp +++ b/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp @@ -522,7 +522,7 @@ void Pdiag_Double::diago_double_begin(const int &ik, double **wfc, matrix &wfc_2 int THIS_REAL_ELPA_KERNEL_API=12; int useQR=0; // may be changed to input parameter sometime - if(chr.get_new_e_iteration()) + if(CHR.get_new_e_iteration()) { timer::tick("Diago_LCAO_Matrix","genelpa1",'G'); method=0; diff --git a/ABACUS.develop/source/src_global/restart.cpp b/ABACUS.develop/source/src_global/restart.cpp index fdecf4b4a0..f70c8d0679 100644 --- a/ABACUS.develop/source/src_global/restart.cpp +++ b/ABACUS.develop/source/src_global/restart.cpp @@ -38,7 +38,7 @@ void Restart::read_file2(const std::string &file_name, void*const ptr, const siz void Restart::save_disk(const std::string mode, const int i) const { if("charge"==mode) - write_file2(folder+"charge_"+TO_STRING(MY_RANK)+"_"+TO_STRING(i), chr.rho[i], pw.nrxx*sizeof(double)); + write_file2(folder+"charge_"+TO_STRING(MY_RANK)+"_"+TO_STRING(i), CHR.rho[i], pw.nrxx*sizeof(double)); if("H"==mode) { if(GAMMA_ONLY_LOCAL) @@ -51,7 +51,7 @@ void Restart::save_disk(const std::string mode, const int i) const void Restart::load_disk(const std::string mode, const int i) const { if("charge"==mode) - read_file2(folder+"charge_"+TO_STRING(MY_RANK)+"_"+TO_STRING(i), chr.rho[i], pw.nrxx*sizeof(double)); + read_file2(folder+"charge_"+TO_STRING(MY_RANK)+"_"+TO_STRING(i), CHR.rho[i], pw.nrxx*sizeof(double)); if("H"==mode) { if(GAMMA_ONLY_LOCAL) @@ -59,4 +59,4 @@ void Restart::load_disk(const std::string mode, const int i) const else read_file2(folder+"Hk_"+TO_STRING(MY_RANK)+"_"+TO_STRING(i), LM.Hloc2, ParaO.nloc*sizeof(complex)); } -} \ No newline at end of file +} diff --git a/ABACUS.develop/source/src_global/rwstream.cpp b/ABACUS.develop/source/src_global/rwstream.cpp new file mode 100644 index 0000000000..8853d6bbe8 --- /dev/null +++ b/ABACUS.develop/source/src_global/rwstream.cpp @@ -0,0 +1,44 @@ +#include +#include "rwstream.h" + +Rwstream::Rwstream(FILE* &ptr) +{ + fileptr=ptr; +} + +Rwstream::Rwstream(const string filename,const char *op) +{ + fileptr=fopen(filename.c_str(),op); +} + +void Rwstream:: setptr(FILE* &ptr) +{ + fileptr=ptr; + return; +} + +void Rwstream::open(const string filename,const char *op) +{ + fileptr=fopen(filename.c_str(),op); +} + +void Rwstream:: close() +{ + fclose(fileptr); + return; +} + +bool Rwstream::operator!() const +{ + if (fileptr==NULL) + return true; + else + return false; +} +Rwstream::operator bool() const +{ + if (fileptr==NULL) + return false; + else + return true; +} diff --git a/ABACUS.develop/source/src_global/rwstream.h b/ABACUS.develop/source/src_global/rwstream.h new file mode 100644 index 0000000000..5afeacf7e0 --- /dev/null +++ b/ABACUS.develop/source/src_global/rwstream.h @@ -0,0 +1,103 @@ +#ifndef RWSTREAM_H +#define RWSTREAM_H + +#include "malloc.h" +#include +#include +#include +#include +using namespace std; + + +//A class to read or write binary data. +//By qianrui 2020-1-6 +class Rwstream +{ + public: + Rwstream(){ + fileptr=NULL; + }; + Rwstream(const string,const char*); + Rwstream(FILE* &ptr); + ~Rwstream(){}; + void setptr(FILE* &ptr); + FILE* fileptr; + void close(); + void open(const string,const char*); + bool operator!() const; + operator bool() const; +}; + + +//For template operator, you had better write defination in .h file!! +//for variation or array +template +Rwstream& operator<<(Rwstream& wstream,const T data) +{ + int size=sizeof(T); + int n=sizeof(data)/sizeof(T); + fwrite(&data,size,n,wstream.fileptr); + return wstream; +} +/*//for dynamic memory +//malloc_usable_size has problem! +template +Rwstream& operator<<(Rwstream& wstream,T* &data) +{ + int size=sizeof(T); + int n=malloc_usable_size(data)/sizeof(T); + fwrite(data,size,n,wstream.fileptr); + return wstream; +}*/ +template +Rwstream& operator>>(Rwstream& rstream,T& data) +{ + int size=sizeof(T); + int n=sizeof(data)/sizeof(T); + size_t ch; + ch=fread(&data,size,n,rstream.fileptr); +#ifdef __JUG + if(ch +Rwstream& operator>>(Rwstream& rstream,T* &data) +{ + int size=sizeof(T); + int n=malloc_usable_size(data)/sizeof(T); + cout< +void rwread(Rwstream& rstream,T* &data,int n) +{ + int size=sizeof(T); + size_t ch; + ch=fread(data,size,n,rstream.fileptr); +#ifdef __JUG + if(ch( chr.rho[is][ir], 0.0 ); + aux[ir] += complex( CHR.rho[is][ir], 0.0 ); } } @@ -708,7 +708,7 @@ void Force_LCAO::cal_force_cc(void) timer::tick("Force_LCAO","cal_force_cc",'E'); // recalculate the exchange-correlation potential. matrix vxc(NSPIN, pw.nrxx); - pot.v_xc(chr.rho, en.etxc, en.vtxc, vxc); + pot.v_xc(CHR.rho, en.etxc, en.vtxc, vxc); complex * psiv = new complex [pw.nrxx]; ZEROS(psiv, pw.nrxx); @@ -739,7 +739,7 @@ void Force_LCAO::cal_force_cc(void) if (ucell.atoms[T1].nlcc) { //call drhoc - chr.non_linear_core_correction( + CHR.non_linear_core_correction( ppcell.numeric, ucell.atoms[T1].msh, ucell.atoms[T1].r, diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_mull.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_mull.cpp index 15e90575bf..1c6b1c8ec7 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_mull.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_mull.cpp @@ -230,7 +230,7 @@ void Gint_Gamma::gamma_mulliken(double** mulliken) for(int is=0; isnorm1[count] < this->Rcut1 && this->norm2[count] < this->Rcut2) { - chr.rho[0][ ijk_index[count] ] += factor * + CHR.rho[0][ ijk_index[count] ] += factor * Mathzone::Polynomial_Interpolation( pointer1->getPsiuniform(), // Peize Lin update 2016-05-14 pointer1->getNruniform(), diff --git a/ABACUS.develop/source/src_lcao/istate_charge.cpp b/ABACUS.develop/source/src_lcao/istate_charge.cpp index ddeef7dfc5..57cbd25c4c 100644 --- a/ABACUS.develop/source/src_lcao/istate_charge.cpp +++ b/ABACUS.develop/source/src_lcao/istate_charge.cpp @@ -126,20 +126,20 @@ void IState_Charge::begin(void) // (3) zero out of charge density array. for(int is=0; isLOWF.init_Cij( 0 ); // check the orthogonality of local orbital. - //chr.sum_band(); use local orbital in plane wave basis to calculate bands. + //CHR.sum_band(); use local orbital in plane wave basis to calculate bands. // but must has evc first! //------------------------------------------------------------------------- @@ -372,7 +372,7 @@ void Local_Orbital_Elec::scf(const int &istep) en.deband = en.delta_e(); // (8) Mix charge density - chr.mix_rho(dr2,0,DRHO2,iter,conv_elec); + CHR.mix_rho(dr2,0,DRHO2,iter,conv_elec); // Peize Lin add 2020.04.04 if(restart.info_save.save_charge) @@ -392,7 +392,7 @@ void Local_Orbital_Elec::scf(const int &istep) if(!conv_elec) { // option 1 - pot.v_of_rho(chr.rho, en.ehart, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho, en.ehart, en.etxc, en.vtxc, pot.vr); en.delta_escf(); // option 2 @@ -401,16 +401,16 @@ void Local_Orbital_Elec::scf(const int &istep) // use real E_tot functional. //------------------------------ /* - pot.v_of_rho(chr.rho_save, en.ehart, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho_save, en.ehart, en.etxc, en.vtxc, pot.vr); en.calculate_etot(); en.print_etot(conv_elec, istep, iter, dr2, 0.0, ETHR, avg_iter,0); - pot.v_of_rho(chr.rho, en.ehart, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho, en.ehart, en.etxc, en.vtxc, pot.vr); en.delta_escf(); */ } else { - pot.v_of_rho(chr.rho, en.ehart, en.etxc, en.vtxc, pot.vnew); + pot.v_of_rho(CHR.rho, en.ehart, en.etxc, en.vtxc, pot.vnew); //(used later for scf correction to the forces ) pot.vnew -= pot.vr; en.descf = 0.0; @@ -425,7 +425,7 @@ void Local_Orbital_Elec::scf(const int &istep) stringstream ssc; ssc << global_out_dir << "tmp" << "_SPIN" << is + 1 << "_CHG"; - chr.write_rho( is, iter, ssc.str(), precision );//mohan add 2007-10-17 + CHR.write_rho( is, iter, ssc.str(), precision );//mohan add 2007-10-17 stringstream ssd; @@ -482,7 +482,7 @@ void Local_Orbital_Elec::scf(const int &istep) //quxin add for DFT+U for nscf calculation if(INPUT.dft_plus_u) { - if(chr.out_charge) + if(CHR.out_charge) { stringstream sst; sst << global_out_dir << "onsite.dm"; @@ -496,7 +496,7 @@ void Local_Orbital_Elec::scf(const int &istep) stringstream ssc; ssc << global_out_dir << "SPIN" << is + 1 << "_CHG"; - chr.write_rho( is, 0, ssc.str() );//mohan add 2007-10-17 + CHR.write_rho( is, 0, ssc.str() );//mohan add 2007-10-17 stringstream ssd; if(GAMMA_ONLY_LOCAL) @@ -521,7 +521,7 @@ void Local_Orbital_Elec::scf(const int &istep) //fuxiang add 2017-03-15 stringstream sse; sse << global_out_dir << "SPIN" << is + 1 << "_DIPOLE_ELEC"; - chr.write_rho_dipole( is, 0, sse.str()); + CHR.write_rho_dipole( is, 0, sse.str()); */ } @@ -914,9 +914,9 @@ void Local_Orbital_Elec::init_mixstep_final_scf(void) { TITLE("Local_Orbital_Elec","init_mixstep_final_scf"); - chr.irstep=0; - chr.idstep=0; - chr.totstep=0; + CHR.irstep=0; + CHR.idstep=0; + CHR.totstep=0; return; } diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index ffde2a8cee..2a0575f7e4 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -222,7 +222,7 @@ void Local_Orbital_Ions::opt_ions(void) { for(int is=0; is(chr.rho[is][ir], 0.0 ); + Porter[ir] += complex(CHR.rho[is][ir], 0.0 ); } } pw.FFT_chg.FFT3D(Porter, -1); @@ -660,7 +660,7 @@ void Stress_LCAO::cal_stress_cc(void) //recalculate the exchange-correlation potential matrix vxc(NSPIN, pw.nrxx); - pot.v_xc(chr.rho, en.etxc, en.vtxc, vxc); + pot.v_xc(CHR.rho, en.etxc, en.vtxc, vxc); complex * psic = new complex [pw.nrxx]; @@ -688,7 +688,7 @@ void Stress_LCAO::cal_stress_cc(void) for(nt=0;nt( chr.rho[is][ir], 0.0 ); + Porter[ir] += complex( CHR.rho[is][ir], 0.0 ); } } //============================= @@ -771,7 +771,7 @@ void Stress_LCAO::cal_stress_har(){ ZEROS( psic0, pw.nrxx); for(int is=0; is(psic0[ir], 0.0); @@ -881,12 +881,12 @@ void Stress_LCAO::cal_stress_gradcorr() const double fac = 1.0/ NSPIN; // doing FFT to get rho in G space: rhog1 - chr.set_rhog(chr.rho[0], chr.rhog[0]); + CHR.set_rhog(CHR.rho[0], CHR.rhog[0]); if(NSPIN==2)//mohan fix bug 2012-05-28 { - chr.set_rhog(chr.rho[1], chr.rhog[1]); + CHR.set_rhog(CHR.rho[1], CHR.rhog[1]); } - chr.set_rhog(chr.rho_core, chr.rhog_core); + CHR.set_rhog(CHR.rho_core, CHR.rhog_core); double* rhotmp1; double* rhotmp2; @@ -899,8 +899,8 @@ void Stress_LCAO::cal_stress_gradcorr() rhogsum1 = new complex[pw.ngmc]; ZEROS(rhotmp1, pw.nrxx); ZEROS(rhogsum1, pw.ngmc); - for(int ir=0; ir[pw.nrxx]; ZEROS(gdr1, pw.nrxx); @@ -912,8 +912,8 @@ void Stress_LCAO::cal_stress_gradcorr() rhogsum2 = new complex[pw.ngmc]; ZEROS(rhotmp2, pw.nrxx); ZEROS(rhogsum2, pw.ngmc); - for(int ir=0; ir[pw.nrxx]; ZEROS(gdr2, pw.nrxx); diff --git a/ABACUS.develop/source/src_lcao/update_input.cpp b/ABACUS.develop/source/src_lcao/update_input.cpp index 3af3791b22..96ac994cf4 100644 --- a/ABACUS.develop/source/src_lcao/update_input.cpp +++ b/ABACUS.develop/source/src_lcao/update_input.cpp @@ -147,10 +147,10 @@ bool Update_input::Read(const string &fn) else if (strcmp("mixing_beta", word) == 0) { read_value(ifs, mixing_beta); - if(mixing_beta!=chr.mixing_beta) + if(mixing_beta!=CHR.mixing_beta) { - this->change(ofs_warning,"mixing_beta",chr.mixing_beta,mixing_beta); - chr.mixing_beta = mixing_beta; + this->change(ofs_warning,"mixing_beta",CHR.mixing_beta,mixing_beta); + CHR.mixing_beta = mixing_beta; } } // 8 @@ -187,10 +187,10 @@ bool Update_input::Read(const string &fn) else if (strcmp("out_charge", word) == 0) { read_value(ifs, out_charge); - if(out_charge!=chr.out_charge) + if(out_charge!=CHR.out_charge) { - this->change(ofs_warning,"out_charge",chr.out_charge,out_charge); - chr.out_charge = this->out_charge; + this->change(ofs_warning,"out_charge",CHR.out_charge,out_charge); + CHR.out_charge = this->out_charge; } } // 11 @@ -270,10 +270,10 @@ void Update_input::Bcast() Parallel_Common::bcast_double( DRHO2 ); Parallel_Common::bcast_int( NITER ); Parallel_Common::bcast_int( NSTEP ); - Parallel_Common::bcast_double( chr.mixing_beta ); + Parallel_Common::bcast_double( CHR.mixing_beta ); Parallel_Common::bcast_int( en.printe ); Parallel_Common::bcast_string( pot.extra_pot );//xiaohui modify 2015-02-01 - Parallel_Common::bcast_int( chr.out_charge ); + Parallel_Common::bcast_int( CHR.out_charge ); Parallel_Common::bcast_int( LOC.out_dm ); Parallel_Common::bcast_int( en.out_dos ); Parallel_Common::bcast_int( ParaO.out_lowf ); diff --git a/ABACUS.develop/source/src_parallel/parallel_global.cpp b/ABACUS.develop/source/src_parallel/parallel_global.cpp index d5a1d881bd..5e5f993f76 100644 --- a/ABACUS.develop/source/src_parallel/parallel_global.cpp +++ b/ABACUS.develop/source/src_parallel/parallel_global.cpp @@ -217,7 +217,8 @@ void Parallel_Global::read_mpi_parameters(int argc,char **argv) // mohan 2011-03-15 if (MY_RANK != 0 ) { - cout.rdbuf(NULL); + //cout.rdbuf(NULL); + cout.setstate(ios::failbit);//qianrui modify 2020-10-14 } // end test diff --git a/ABACUS.develop/source/src_parallel/parallel_kpoints.h b/ABACUS.develop/source/src_parallel/parallel_kpoints.h index 0a03e516dc..9dbdfe3d44 100644 --- a/ABACUS.develop/source/src_parallel/parallel_kpoints.h +++ b/ABACUS.develop/source/src_parallel/parallel_kpoints.h @@ -23,10 +23,10 @@ class Parallel_Kpoints int *nproc_pool; int *startpro_pool; - // inforamation about kpoints - int* nks_pool; - int* startk_pool; - int* whichpool; + // inforamation about kpoints //qianrui add comment + int* nks_pool; //number of k-points in each pool + int* startk_pool; //the first k-point in each pool + int* whichpool; //whichpool[k] : the pool which k belongs to private: diff --git a/ABACUS.develop/source/src_pw/cal_test.cpp b/ABACUS.develop/source/src_pw/cal_test.cpp index fa314ad380..885689cb11 100644 --- a/ABACUS.develop/source/src_pw/cal_test.cpp +++ b/ABACUS.develop/source/src_pw/cal_test.cpp @@ -62,13 +62,13 @@ void Cal_Test::test_memory(void) mrho_core = mrho; // (2) memory for charge mixing - cout << " Mixing mode = " << chr.mixing_mode << endl; - if(chr.mixing_mode == "pulay") + cout << " Mixing mode = " << CHR.mixing_mode << endl; + if(CHR.mixing_mode == "pulay") { - cout << " Mixing dimension = " << chr.mixing_ndim << endl; - mRrho = chr.mixing_ndim * mrho; - mdRrho = (chr.mixing_ndim-1) * mrho; - mdrho = (chr.mixing_ndim-1) * mrho; + cout << " Mixing dimension = " << CHR.mixing_ndim << endl; + mRrho = CHR.mixing_ndim * mrho; + mdRrho = (CHR.mixing_ndim-1) * mrho; + mdrho = (CHR.mixing_ndim-1) * mrho; mrho_save2 = mrho; // cout << " Memory for pulay mixing: " << mrho << " MB" << endl; } diff --git a/ABACUS.develop/source/src_pw/charge.h b/ABACUS.develop/source/src_pw/charge.h index a7619df9a8..da215cd662 100644 --- a/ABACUS.develop/source/src_pw/charge.h +++ b/ABACUS.develop/source/src_pw/charge.h @@ -7,10 +7,11 @@ #include "tools.h" #include "../src_parallel/parallel_global.h" + //========================================================== -// Charge is the key value of all physics properties ! -// So write this class carefully. +// Electron Charge Density //========================================================== + class Charge { public: @@ -72,7 +73,7 @@ class Charge double sum_rho(void) const; bool allocate_rho; -bool allocate_rho_final_scf; //LiuXh add 20180606 + bool allocate_rho_final_scf; //LiuXh add 20180606 }; diff --git a/ABACUS.develop/source/src_pw/charge_broyden.cpp b/ABACUS.develop/source/src_pw/charge_broyden.cpp index 7d95fa1999..0146adc8cc 100644 --- a/ABACUS.develop/source/src_pw/charge_broyden.cpp +++ b/ABACUS.develop/source/src_pw/charge_broyden.cpp @@ -6,6 +6,7 @@ Charge_Broyden::Charge_Broyden() { initb = false; } + Charge_Broyden::~Charge_Broyden() { if (initb) diff --git a/ABACUS.develop/source/src_pw/charge_broyden.h b/ABACUS.develop/source/src_pw/charge_broyden.h index 3fd52f134e..318e475889 100644 --- a/ABACUS.develop/source/src_pw/charge_broyden.h +++ b/ABACUS.develop/source/src_pw/charge_broyden.h @@ -12,6 +12,7 @@ //=================================== #include "tools.h" #include "charge_pulay.h" + class Charge_Broyden: public Charge_Pulay { public: @@ -22,7 +23,6 @@ class Charge_Broyden: public Charge_Pulay const double &tr2,const int &iter, bool &converged);// mix rho - private: // Sophisticated mixing method. @@ -33,8 +33,6 @@ class Charge_Broyden: public Charge_Pulay void generate_Zmk(const int &totstep, const int &irstep, const int &idstep, const int &is); void generate_new_broyden_rho(const int &is, const int &irstep); - - bool initb; // b stands for Broyden algorithms. double w0; double* w; @@ -42,8 +40,6 @@ class Charge_Broyden: public Charge_Pulay matrix betabar; // (dstep, dstep) matrix* Zmk; matrix* Zmk_old; - - }; #endif diff --git a/ABACUS.develop/source/src_pw/charge_extra.cpp b/ABACUS.develop/source/src_pw/charge_extra.cpp index 1a39a5b8bd..3a77be23c9 100644 --- a/ABACUS.develop/source/src_pw/charge_extra.cpp +++ b/ABACUS.develop/source/src_pw/charge_extra.cpp @@ -140,7 +140,7 @@ void Charge_Extra::allocate(void) // first value from charge density. for(int ir=0; irrho_ion[0][is][ir]; + CHR.rho[is][ir] = 2.0*rho_tmp[ir] - this->rho_ion[0][is][ir]; } // (3) save the current charge density for next step. @@ -220,7 +220,7 @@ void Charge_Extra::extrapolate_charge() { // start from atomic charge density. // worst method ever! - chr.atomic_rho(NSPIN, chr.rho); + CHR.atomic_rho(NSPIN, CHR.rho); } xiaohui modify 2015-02-01*/ //else if(pot.extra_pot == 4) @@ -237,7 +237,7 @@ xiaohui modify 2015-02-01*/ // should not do this after grid_technique is done!. // for(int is=0; isc_bands(); + this->c_bands(istep); if (check_stop_now()) return; @@ -202,13 +190,13 @@ void electrons::self_consistent(const int &istep) //(4) save change density as previous charge, // prepared fox mixing. - chr.save_rho_before_sum_band(); + CHR.save_rho_before_sum_band(); //(5) calculate new charge density according to // new wave functions. // calculate the new eband here. - chr.sum_band(); + CHR.sum_band(); //(6) calculate the delta_harris energy // according to new charge density. @@ -230,9 +218,9 @@ void electrons::self_consistent(const int &istep) en.deband = en.delta_e(); //if (LOCAL_BASIS) xiaohui modify 2013-09-02 - if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-02 + if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-02 { - chr.mix_rho(dr2,0,DRHO2,iter,conv_elec); + CHR.mix_rho(dr2,0,DRHO2,iter,conv_elec); } else { @@ -253,7 +241,7 @@ void electrons::self_consistent(const int &istep) // rho contain the output charge density. // in other cases rhoin contains the mixed charge density // (the new input density) while rho is unchanged. - chr.mix_rho(dr2,diago_error,DRHO2,iter,conv_elec); + CHR.mix_rho(dr2,diago_error,DRHO2,iter,conv_elec); //if(MY_RANK==0) //{ @@ -281,7 +269,7 @@ void electrons::self_consistent(const int &istep) if (!conv_elec) { // not converged yet, calculate new potential from mixed charge density - pot.v_of_rho(chr.rho, en.ehart, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho, en.ehart, en.etxc, en.vtxc, pot.vr); // because = are calculated after sum // band, using output charge density. @@ -303,7 +291,7 @@ void electrons::self_consistent(const int &istep) // mohan fix bug 2012-06-05, // the new potential V(PL)+V(H)+V(xc) - pot.v_of_rho(chr.rho, en.ehart, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho, en.ehart, en.etxc, en.vtxc, pot.vr); //cout<<"Exc = "<= 0 ) chr.rho = chr.rho_save; + //if ( imix >= 0 ) CHR.rho = CHR.rho_save; //ofs_running << "\n start next iterate for idum "; } //END DO - timer::tick("electrons","self_consistent",'D'); + timer::tick("Electrons","self_consistent",'D'); return; -} // end electrons +} // end Electrons -bool electrons::check_stop_now(void) + +bool Electrons::check_stop_now(void) { bool check_stop_now = false; @@ -420,10 +414,11 @@ bool electrons::check_stop_now(void) return check_stop_now; } // END FUNCTION check_stop_now -void electrons::c_bands(void) + +void Electrons::c_bands(const int &istep) { - if (test_elec) TITLE("electrons","c_bands"); - timer::tick("electrons","c_bands",'E'); + if (test_elec) TITLE("Electrons","c_bands"); + timer::tick("Electrons","c_bands",'E'); int precondition_type = 2; @@ -460,7 +455,7 @@ void electrons::c_bands(void) } } //h_diag can't be zero! //zhengdy-soc - if(NPOL==2) + if(NPOL==2) { for(int ig = wf.npw;ig < wf.npwx; ig++) { @@ -484,7 +479,7 @@ void electrons::c_bands(void) // eigenstates. //============================================================= double avg_iter_k = 0.0; - hm.diago(this->istep, this->iter, ik, h_diag, avg_iter_k); + hm.diago(istep, this->iter, ik, h_diag, avg_iter_k); avg_iter += avg_iter_k; @@ -511,13 +506,14 @@ void electrons::c_bands(void) return; } // END SUBROUTINE c_bands_k -void electrons::init_mixstep_final_scf(void) + +void Electrons::init_mixstep_final_scf(void) { TITLE("electrons","init_mixstep_final_scf"); - chr.irstep=0; - chr.idstep=0; - chr.totstep=0; + CHR.irstep=0; + CHR.idstep=0; + CHR.totstep=0; return; } diff --git a/ABACUS.develop/source/src_pw/electrons.h b/ABACUS.develop/source/src_pw/electrons.h index 99322c5a08..74fab33c44 100644 --- a/ABACUS.develop/source/src_pw/electrons.h +++ b/ABACUS.develop/source/src_pw/electrons.h @@ -4,46 +4,41 @@ #include "tools.h" #include "threshold_elec.h" -class electrons: private Threshold_Elec +class Electrons: private Threshold_Elec { public: // constructor and deconstructor - electrons(); - ~electrons(); + Electrons(); + ~Electrons(); public: //========================================================== - // lberry : If TRUE Berry phase polarization is calculated. - // iter : Current step of electrons iteration. - // ntry : - // notconv : - // ethr : the convergence threshold for eigenvalues // avg_iter : Average iteration number in ccgdiagg //========================================================== int iter; + static double avg_iter; + int test; + int unit; + double delta_total_energy; -protected: void self_consistent(const int &istep); - void non_self_consistent(void); - int istep; -private: - - void c_bands(void); - void compute_magnetization(void); + void non_self_consistent(const int &istep); private: - // used in electrons() + void c_bands(const int &istep); + bool check_stop_now(void); + void init_mixstep_final_scf(void); }; diff --git a/ABACUS.develop/source/src_pw/electrons_stochastic.cpp b/ABACUS.develop/source/src_pw/electrons_stochastic.cpp new file mode 100644 index 0000000000..1286f28c7b --- /dev/null +++ b/ABACUS.develop/source/src_pw/electrons_stochastic.cpp @@ -0,0 +1,388 @@ +#include "tools.h" +#include "global.h" +#include "electrons_stochastic.h" +#include "algorithms.h" +#include "symmetry_rho.h" +#include "../src_pw/wf_io.h" + +double Electrons_Stochastic::avg_iter = 0; + +Electrons_Stochastic::Electrons_Stochastic() +{ +} + +Electrons_Stochastic::~Electrons_Stochastic() +{ +} + + +void Electrons_Stochastic::scf_stochastic(const int &istep) +{ + timer::tick("Elec_Stochastic","scf_stochastic",'D'); + en.ewld = en.ewald(); + + set_ethr(); + + this->unit = 0; + + if(OUT_LEVEL=="ie") + { + cout << setprecision(12); + cout<< " " << setw(7)<< "ITER"; + + if(NSPIN==2) + { + cout<conv_elec = false; + + clock_t start,finish; + double duration = 0.0; + + for (this->iter = 1;iter <= NITER;iter++) + { + ofs_running + << "\n PW ALGORITHM --------------- ION=" << setw(4) << istep + 1 + << " ELEC=" << setw(4) << iter + << "--------------------------------\n"; + + if(iter==1) CHR.new_e_iteration = true; + else CHR.new_e_iteration = false; + + // record the start time. + start=std::clock(); + + //(1) set converged threshold, + // automatically updated during self consistency. + //this->update_ethr(iter); + if(FINAL_SCF && iter==1) ETHR = 1.0e-2; + else this->update_ethr(iter); + if(FINAL_SCF && iter==1) + { + CHR.irstep=0; + CHR.idstep=0; + CHR.totstep=0; + } + + // mohan move harris functional to here, 2012-06-05 + // use 'rho(in)' and 'v_h and v_xc'(in) + en.calculate_harris(1); + + // first_iter_again: // Peize Lin delete 2019-05-01 + + //(2) calculate band energy using cg or davidson method. + // output the new eigenvalues and wave functions. + this->c_bands(istep); + + if (check_stop_now()) return; + + en.eband = 0.0; + en.demet = 0.0; + en.ef = 0.0; + en.ef_up = 0.0; + en.ef_dw = 0.0; + + //(3) calculate weights of each band. + Occupy::calculate_weights(); + + //(4) save change density as previous charge, + // prepared fox mixing. + CHR.save_rho_before_sum_band(); + + //(5) calculate new charge density according to + // new wave functions. + + // calculate the new eband here. + CHR.sum_band(); + + //(6) calculate the delta_harris energy + // according to new charge density. + // mohan add 2009-01-23 + en.calculate_harris(2); + + + Symmetry_rho srho; + for(int is=0; is= 0 ) CHR.rho = CHR.rho_save; + //ofs_running << "\n start next iterate for idum "; + } + + timer::tick("Elec_Stochastic","scf_stochastic",'D'); + return; +} // end electrons + + +bool Electrons_Stochastic::check_stop_now(void) +{ + bool check_stop_now = false; + + if (check_stop_now) + { + conv_elec = false; + } + + return check_stop_now; +} + + +void Electrons_Stochastic::c_bands(const int &istep) +{ + if (test_elec) TITLE("electrons","c_bands"); + timer::tick("Elec_Stochastic","c_bands",'E'); + + int precondition_type = 2; + + double *h_diag = new double[wf.npwx * NPOL];//added by zhengdy-soc + ZEROS(h_diag, wf.npwx * NPOL); + + avg_iter = 0.0; + + ofs_running << " " <iter, ik, h_diag, avg_iter_k); + + + avg_iter += avg_iter_k; + + en.print_band(ik); + + clock_t finish=clock(); + const double duration = static_cast(finish - start) / CLOCKS_PER_SEC; + + + ofs_running << " " << setw(8) + << ik+1 << setw(15) + << avg_iter_k << setw(15) << duration << endl; + }//End K Loop + + + if(BASIS_TYPE=="pw") + { + // ofs_running << " avg_iteri " << avg_iter << endl; + Parallel_Reduce::reduce_double_allpool(avg_iter); //mohan fix bug 2012-06-05 + // ofs_running << " avg_iter_after " << avg_iter << endl; + avg_iter /= static_cast(kv.nkstot); + } + delete [] h_diag; + timer::tick("Elec_Stochastic","c_bands",'E'); + return; +} + diff --git a/ABACUS.develop/source/src_pw/electrons_stochastic.h b/ABACUS.develop/source/src_pw/electrons_stochastic.h new file mode 100644 index 0000000000..d62ecba599 --- /dev/null +++ b/ABACUS.develop/source/src_pw/electrons_stochastic.h @@ -0,0 +1,30 @@ +#ifndef INCLUDE_ELECTRONS_STOCHASTIC_H +#define INCLUDE_ELECTRONS_STOCHASTIC_H + +#include "tools.h" +#include "threshold_elec.h" + +class Electrons_Stochastic: private Threshold_Elec +{ + +public: + + // constructor and deconstructor + Electrons_Stochastic(); + ~Electrons_Stochastic(); + + int iter; + static double avg_iter; + int test; + int unit; + + void scf_stochastic(const int &istep); + +private: + + void c_bands(const int &istep); + + bool check_stop_now(void); +}; + +#endif// Eelectrons_Stochastic diff --git a/ABACUS.develop/source/src_pw/energy.cpp b/ABACUS.develop/source/src_pw/energy.cpp index d7770e31cd..0fe9837a26 100644 --- a/ABACUS.develop/source/src_pw/energy.cpp +++ b/ABACUS.develop/source/src_pw/energy.cpp @@ -774,13 +774,13 @@ double energy::delta_e(void) double deband_aux = 0.0; - for (int ir=0; irdescf -= ( chr.rho[0][ir]- chr.rho_save[0][ir] ) * pot.vr(0,ir); + this->descf -= ( CHR.rho[0][ir]- CHR.rho_save[0][ir] ) * pot.vr(0,ir); } if (NSPIN==2) { for (int ir=0; irdescf -= ( chr.rho[1][ir] - chr.rho_save[1][ir] ) * pot.vr(1, ir); + this->descf -= ( CHR.rho[1][ir] - CHR.rho_save[1][ir] ) * pot.vr(1, ir); } } if (NSPIN==4) { for(int ir=0; irdescf -= ( chr.rho[1][ir] - chr.rho_save[1][ir] ) * pot.vr(1, ir); - this->descf -= ( chr.rho[2][ir] - chr.rho_save[2][ir] ) * pot.vr(2, ir); - this->descf -= ( chr.rho[3][ir] - chr.rho_save[3][ir] ) * pot.vr(3, ir); + this->descf -= ( CHR.rho[1][ir] - CHR.rho_save[1][ir] ) * pot.vr(1, ir); + this->descf -= ( CHR.rho[2][ir] - CHR.rho_save[2][ir] ) * pot.vr(2, ir); + this->descf -= ( CHR.rho[3][ir] - CHR.rho_save[3][ir] ) * pot.vr(3, ir); } } @@ -866,8 +866,7 @@ void energy::perform_dos(void) if(MY_RANK==0) { - if(CALCULATION=="scf" || CALCULATION=="md" || CALCULATION=="relax") - //if(CALCULATION=="scf" || CALCULATION=="md") + if(CALCULATION=="scf" || CALCULATION=="md" || CALCULATION=="relax") { stringstream ss; ss << global_out_dir << "istate.info" ; @@ -878,47 +877,128 @@ void energy::perform_dos(void) for(int is=0; isdos_edelta_ev; - - - - const int npoints = static_cast(std::floor ( ( emax - emin ) / de_ev )); - int NUM=NLOCAL*npoints; - Wfc_Dm_2d D; - D.init(); - if(GAMMA_ONLY_LOCAL) - { - for(int in=0;in *waveg = new complex [NLOCAL]; - - double* Gauss = new double [np]; - - for(int is=0; is Mulk; - Mulk.resize(1); - Mulk[0].create(ParaO.ncol,ParaO.nrow); - - - matrix Dwf = D.wfc_gamma[is]; - for (int i=0; i Mulk; - Mulk.resize(1); - Mulk[0].create(ParaO.ncol,ParaO.nrow); - - - for(int ik=0;ikdos_edelta_ev; + + + const int npoints = static_cast(std::floor ( ( emax - emin ) / de_ev )); + + int NUM=NLOCAL*npoints; + + Wfc_Dm_2d D; + D.init(); + if(GAMMA_ONLY_LOCAL) + { + for(int in=0;in" <" << NSPIN<< "<"<<"/"<<"nspin"<<">"<< endl; - out << "<"<<"norbitals"<<">" <"<< endl; - out << "<"<<"energy"<<"_"<<"values units"<<"="<<"\""<<"eV"<<"\""<<">"<" <nw; ++j) - { - const int L1 = atom1->iw2l[j]; - const int N1 = atom1->iw2n[j]; - const int m1 = atom1->iw2m[j]; - const int w = ucell.itiaiw2iwt(t, a, j); - - //out << "<"<<"/"<<"energy"<<"_"<<"values"<<">" <" <" <" <" <" <nw; ++j) - { - const int L1 = atom1->iw2l[j]; - const int N1 = atom1->iw2n[j]; - const int m1 = atom1->iw2m[j]; - out < *waveg = new complex [NLOCAL]; + + double* Gauss = new double [np]; + for(int is=0; isdos_edelta_ev, - emax, - emin, - kv.nks, kv.nkstot, kv.wk, wf.wg, NBANDS, wf.ekb ); - ifstream in(ss.str().c_str()); - if(!in) - { - // cout<<"\n Can't find file : "<< name << endl; - // return 0; - } + if(GAMMA_ONLY_LOCAL) + { + std::vector Mulk; + Mulk.resize(1); + Mulk[0].create(ParaO.ncol,ParaO.nrow); - //---------------------------------------------------------- - // FOUND LOCAL VARIABLES : - // NAME : number(number of DOS points) - // NAME : nk(number of k point used) - // NAME : energy(energy range,from emin_ev to emax_ev) - // NAME : dos(old,count k points in the energy range) - // NAME : dos2(new,count k points in the energy range) - //---------------------------------------------------------- - int number=0; - int nk=0; - in >> number; - in >> nk; - double *energy = new double[number]; - double *dos = new double[number]; - double *dos2 = new double[number]; - for(int i=0 ;i> energy[i] >> dos[i]; - } - if(!in.eof()) - { - //cout<<"\n Read Over!"< Mulk; + Mulk.resize(1); + Mulk[0].create(ParaO.ncol,ParaO.nrow); + + + for(int ik=0;ik" <" << NSPIN<< "<"<<"/"<<"nspin"<<">"<< endl; + out << "<"<<"norbitals"<<">" <"<< endl; + out << "<"<<"energy"<<"_"<<"values units"<<"="<<"\""<<"eV"<<"\""<<">"<" <nw; ++j) + { + const int L1 = atom1->iw2l[j]; + const int N1 = atom1->iw2n[j]; + const int m1 = atom1->iw2m[j]; + const int w = ucell.itiaiw2iwt(t, a, j); + + //out << "<"<<"/"<<"energy"<<"_"<<"values"<<">" <" <" <" <" <" <nw; ++j) + { + const int L1 = atom1->iw2l[j]; + const int N1 = atom1->iw2n[j]; + const int m1 = atom1->iw2m[j]; + out <dos_edelta_ev, + emax, + emin, + kv.nks, kv.nkstot, kv.wk, wf.wg, NBANDS, wf.ekb ); + ifstream in(ss.str().c_str()); + if(!in) + { + // cout<<"\n Can't find file : "<< name << endl; + // return 0; + } + + //---------------------------------------------------------- + // FOUND LOCAL VARIABLES : + // NAME : number(number of DOS points) + // NAME : nk(number of k point used) + // NAME : energy(energy range,from emin_ev to emax_ev) + // NAME : dos(old,count k points in the energy range) + // NAME : dos2(new,count k points in the energy range) + //---------------------------------------------------------- + int number=0; + int nk=0; + in >> number; + in >> nk; + double *energy = new double[number]; + double *dos = new double[number]; + double *dos2 = new double[number]; + for(int i=0 ;i> energy[i] >> dos[i]; + } + if(!in.eof()) + { + //cout<<"\n Read Over!"<"<self_consistent(istep-1); + elec.self_consistent(istep-1); + eiter = elec.iter; } else if(CALCULATION=="nscf") { - this->non_self_consistent(); + elec.non_self_consistent(istep-1); + eiter = elec.iter; } + // mohan added 2021-01-28, perform stochastic calculations + else if(CALCULATION=="scf-sto" || CALCULATION=="relax-sto" || CALCULATION=="md-sto") + { + elec_sto.scf_stochastic(istep-1); + eiter = elec_sto.iter; + } - int iat=0; //LiuXh add 20180619 - if(CALCULATION=="relax"|| CALCULATION=="md" || CALCULATION=="cell-relax") - { - for(int it = 0;it < ucell.ntype;it++) - { - Atom* atom = &ucell.atoms[it]; - for(int ia =0;ia< ucell.atoms[it].na;ia++) - { - CE.pos_old2[3*iat ] = CE.pos_old1[3*iat ]; - CE.pos_old2[3*iat+1] = CE.pos_old1[3*iat+1]; - CE.pos_old2[3*iat+2] = CE.pos_old1[3*iat+2]; - - CE.pos_old1[3*iat ] = CE.pos_now[3*iat ]; - CE.pos_old1[3*iat+1] = CE.pos_now[3*iat+1]; - CE.pos_old1[3*iat+2] = CE.pos_now[3*iat+2]; - - CE.pos_now[3*iat ] = atom->tau[ia].x*ucell.lat0; - CE.pos_now[3*iat+1] = atom->tau[ia].y*ucell.lat0; - CE.pos_now[3*iat+2] = atom->tau[ia].z*ucell.lat0; - - iat++; - } - } - } - - if(pot.out_potential == 2) - { - stringstream ssp; - stringstream ssp_ave; - ssp << global_out_dir << "ElecStaticPot"; - ssp_ave << global_out_dir << "ElecStaticPot_AVE"; - pot.write_elecstat_pot(ssp.str(), ssp_ave.str()); //output 'Hartree + local pseudopot' - } - + int iat=0; //LiuXh add 20180619 + if(CALCULATION=="relax"|| CALCULATION=="md" || CALCULATION=="cell-relax") + { + for(int it = 0;it < ucell.ntype;it++) + { + Atom* atom = &ucell.atoms[it]; + for(int ia =0;ia< ucell.atoms[it].na;ia++) + { + CE.pos_old2[3*iat ] = CE.pos_old1[3*iat ]; + CE.pos_old2[3*iat+1] = CE.pos_old1[3*iat+1]; + CE.pos_old2[3*iat+2] = CE.pos_old1[3*iat+2]; + + CE.pos_old1[3*iat ] = CE.pos_now[3*iat ]; + CE.pos_old1[3*iat+1] = CE.pos_now[3*iat+1]; + CE.pos_old1[3*iat+2] = CE.pos_now[3*iat+2]; + + CE.pos_now[3*iat ] = atom->tau[ia].x*ucell.lat0; + CE.pos_now[3*iat+1] = atom->tau[ia].y*ucell.lat0; + CE.pos_now[3*iat+2] = atom->tau[ia].z*ucell.lat0; + + iat++; + } + } + } + + if(pot.out_potential == 2) + { + stringstream ssp; + stringstream ssp_ave; + ssp << global_out_dir << "ElecStaticPot"; + ssp_ave << global_out_dir << "ElecStaticPot_AVE"; + pot.write_elecstat_pot(ssp.str(), ssp_ave.str()); //output 'Hartree + local pseudopot' + } + time_t eend = time(NULL); time_t fstart = time(NULL); - //stop = this->force_stress(istep); + + if (CALCULATION=="scf" || CALCULATION=="relax" || CALCULATION=="cell-relax") { stop = this->force_stress(istep, force_step, stress_step); // pengfei Li 2018-05-14 } time_t fend = time(NULL); + if(OUT_LEVEL=="i") { double etime_min = difftime(eend, estart)/60.0; @@ -166,7 +177,7 @@ void Ions::opt_ions_pw(void) ss << MOVE_IONS << istep; cout << " " << setw(7) << ss.str() - << setw(5) << this->iter + << setw(5) << eiter << setw(15) << setprecision(6) << en.etot * Ry_to_eV << setw(15) << IMM.get_ediff() * Ry_to_eV << setprecision(3) @@ -187,38 +198,8 @@ void Ions::opt_ions_pw(void) ofs_running << setprecision(16); ofs_running << " !FINAL_ETOT_IS " << en.etot * Ry_to_eV << " eV" << endl; ofs_running << " --------------------------------------------\n\n" << endl; - -/* - if(STRESS) - { - if(stress_step==1) - { - Stress ss; - ss.cal_stress(); - matrix stress; - stress.create(3,3); - - PRESSURE = (ss.sigmatot[0][0]+ss.sigmatot[1][1]+ss.sigmatot[2][2])/3; - } - double pressure = PRESSURE; - en.etot = en.etot + ucell.omega * pressure; - - ofs_running << "\n\n --------------------------------------------" << endl; - ofs_running << setprecision(16); - ofs_running << " !FINAL_ETOT_IS (+ P*V) " << en.etot * Ry_to_eV << " eV" << endl; - ofs_running << " --------------------------------------------\n\n" << endl; - } -*/ } -/* - if(stop && STRESS) //LiuXh add 20180619 - { - FINAL_SCF = true; - Run_Frag::final_calculation_after_vc(); - this->self_consistent(0); - } -*/ if(OUT_LEVEL=="i") { @@ -229,22 +210,16 @@ void Ions::opt_ions_pw(void) return; } -//bool Ions::force_stress(const int &istep) + bool Ions::force_stress(const int &istep, int &force_step, int &stress_step) // pengfei Li 2018-05-14 { TITLE("Ions","force_stress"); + if(!FORCE && !STRESS) { return 1; } - //if(STRESS) - //{ - //calculate the stress - //Stress ss; - //ss.cal_stress(); - //change the latvec - //} if(FORCE&&!STRESS) { @@ -463,18 +438,3 @@ bool Ions::force_stress(const int &istep, int &force_step, int &stress_step) // } -void Ions::extrapolate_wfcs() -{ - TITLE("Ions","extrapolate_wfcs"); - // wave function extrapolation: - // wfc_order = 0 nothing is done - // wfc_order = 2 first order extrapolation: - // |psi(t+dt)> = 2*|psi(t)> - |psi(t-dt)> - // wfc_order = 3 second order extrapolation: - // |psi(t+dt)> = |psi(t)> + - // + alpha0*( |psi(t)> - |psi(t-dt)> ) - // + beta0* ( |psi(t-dt)> - |psi(t-2*dt)> ) - - - return; -} diff --git a/ABACUS.develop/source/src_pw/ions.h b/ABACUS.develop/source/src_pw/ions.h index 64a4968ce0..3c2471cb76 100644 --- a/ABACUS.develop/source/src_pw/ions.h +++ b/ABACUS.develop/source/src_pw/ions.h @@ -2,13 +2,14 @@ #define IONS_H #include "electrons.h" +#include "electrons_stochastic.h" //mohan added 2021-01-28 #include "tools.h" #include "../src_ions/ions_move_methods.h" #include "../src_ions/lattice_change_methods.h" #include "charge_extra.h" //#include "../src_develop/src_md/md.h" -class Ions : public electrons +class Ions { public: @@ -19,16 +20,29 @@ class Ions : public electrons private: + // mohan add 2021-01-28 + Electrons elec; + + // mohan add for stochastic wave functions + Electrons_Stochastic elec_sto; + + // mohan add 2021-01-28 + // mohan moved this variable from electrons.h to ions.h + int istep; + Ions_Move_Methods IMM; + //MD md; //mohan add 2011-11-07 + Charge_Extra CE; Lattice_Change_Methods LCM; + bool force_stress(const int &istep, int &force_step, int &stress_step); // pengfei Li 2018-05-14 bool force_stress(const int &istep); + void update_pot(void); - void extrapolate_wfcs(void); }; diff --git a/ABACUS.develop/source/src_pw/lattlib.F b/ABACUS.develop/source/src_pw/lattlib.F deleted file mode 100644 index 0131904142..0000000000 --- a/ABACUS.develop/source/src_pw/lattlib.F +++ /dev/null @@ -1,930 +0,0 @@ - SUBROUTINE LATTYP(A1,A2,A3,ITYP,CELDIM,PRCHAN) -! Routine LATTYP identifies the type of bravais lattice spanned by * -! the primitive lattice vectors A1, A2 and A3. The lattice will be * -! transformed to a 'standard crystallographic setting' and the cell * -! dimensions will be estimated using the conventions of routine * -! LATGEN. The relation between 'original' and 'transformed' lattice * -! vectors will be given in matrix form. * -! * -! A1, A2 and A3 are the three crystallographic vectors of the * -! primitive unit cell (given in cartesian coordinates x,y,z) * -! of the real space lattice given in units of bohrs ('a'). * -! PRCHAN defines the unit number for printing output information. * -! * -! Output parameters: * -! ------------------ * -! A1, A2 and A3 contain on output the three crystallographic * -! vectors being transformed to some 'standard setting'. * -! ITYP gives the lattice type (1-14) as keyed in routine LATGEN. * -! CELDIM gives the cell dimensions as defined in routine LATGEN. * -!*********************************************************************** - INTEGER PRCHAN - DIMENSION A1(3),A2(3),A3(3),RB(3,3),XB(3,3),CELDIM(6),YB(3) - DIMENSION CELLDM(6),SA1(3),SA2(3),SA3(3),CDMINP(6) - -! First test the original vectors (what do we apparently find?): - ISTRGE=0 -! Lengths of the axes and cosines between the axes: - ABS1=XB(1,1)*XB(1,1)+XB(2,1)*XB(2,1)+XB(3,1)*XB(3,1) - ABS2=XB(1,2)*XB(1,2)+XB(2,2)*XB(2,2)+XB(3,2)*XB(3,2) - ABS3=XB(1,3)*XB(1,3)+XB(2,3)*XB(2,3)+XB(3,3)*XB(3,3) - A2XA1=XB(1,1)*XB(1,2)+XB(2,1)*XB(2,2)+XB(3,1)*XB(3,2) - A3XA1=XB(1,1)*XB(1,3)+XB(2,1)*XB(2,3)+XB(3,1)*XB(3,3) - A3XA2=XB(1,2)*XB(1,3)+XB(2,2)*XB(2,3)+XB(3,2)*XB(3,3) - ABS2M1=SQRT(ABS1+ABS2-2._q*A2XA1) - ABS3M1=SQRT(ABS1+ABS3-2._q*A3XA1) - ABS3M2=SQRT(ABS2+ABS3-2._q*A3XA2) - ABS2P1=SQRT(ABS1+ABS2+2._q*A2XA1) - ABS3P1=SQRT(ABS1+ABS3+2._q*A3XA1) - ABS3P2=SQRT(ABS2+ABS3+2._q*A3XA2) - A1P2M3=SQRT(ABS1+ABS2+ABS3+2._q*A2XA1-2._q*A3XA1-2._q*A3XA2) - A2P3M1=SQRT(ABS1+ABS2+ABS3+2._q*A3XA2-2._q*A2XA1-2._q*A3XA1) - A3P1M2=SQRT(ABS1+ABS2+ABS3+2._q*A3XA1-2._q*A3XA2-2._q*A2XA1) - ABS123=A2XA1+A3XA1+A3XA2 - ABS1=SQRT(ABS1) - ABS2=SQRT(ABS2) - ABS3=SQRT(ABS3) - A2XA1=A2XA1/ABS1/ABS2 - A3XA1=A3XA1/ABS1/ABS3 - A3XA2=A3XA2/ABS2/ABS3 - A1XA2=ABS(A2XA1) - A1XA3=ABS(A3XA1) - A2XA3=ABS(A3XA2) -! Warning extremly strange inputs (very large/small ratios 'c/a', 'b/a' -! or cosines very close to +/-1) could sometimes lead to some problems -! due to the finite precision of the machine ...). Here we test some -! parameters and if we find 'strange parameters', we (DO NOT) stop! - IF (A1XA2>0.995_q) ISTRGE=ISTRGE+1 - IF (A2XA3>0.995_q) ISTRGE=ISTRGE+1 - IF (A1XA3>0.995_q) ISTRGE=ISTRGE+1 - IF ((ABS3/ABS1)<0.001_q) ISTRGE=ISTRGE+1 - IF ((ABS2/ABS1)<0.001_q) ISTRGE=ISTRGE+1 - IF ((ABS3/ABS2)<0.001_q) ISTRGE=ISTRGE+1 - IF ((ABS1/ABS3)<0.001_q) ISTRGE=ISTRGE+1 - IF ((ABS1/ABS2)<0.001_q) ISTRGE=ISTRGE+1 - IF ((ABS2/ABS3)<0.001_q) ISTRGE=ISTRGE+1 - -! Following the identification of the crystal type, transformation of -! the basis to 'crystallographic standard settings' and estimate of the -! cell dimensions (using the conventions of routine LATGEN): - CELLDM(1)=0._q - CELLDM(2)=0._q - CELLDM(3)=0._q - CELLDM(4)=0._q - CELLDM(5)=0._q - CELLDM(6)=0._q - IBRAV=15 -! Crystal classes with A1*A2=A1*A3=A2*A3: - IF ((ABS(A2XA1-A3XA1)TINY).AND. & - & ((ABS2-ABS1)>TINY)) THEN - IBRAV=8 - CELLDM(1)=ABS1 - CELLDM(2)=ABS2/ABS1 - CELLDM(3)=ABS3/ABS1 - END IF - END IF -! Crystal classes with A1*A3=A2*A3=/A1*A2: - ELSE IF (ABS(A3XA1-A3XA2)TINY)) THEN - IBRAV=12 - IF ((PRCHAN>=0).AND.(PRCHAN<=99)) & - & WRITE(PRCHAN,*) ' Warning from LATTYP: '// & - & 'Monoclinic adjustement (A1->A3, A2->A1, A3->A2)!' - CELLDM(1)=ABS2 - CELLDM(2)=ABS3/ABS2 - CELLDM(3)=ABS1/ABS2 - CELLDM(5)=A2XA1 - SA3(1)=XB(1,1) - SA3(2)=XB(2,1) - SA3(3)=XB(3,1) - SA1(1)=XB(1,2) - SA1(2)=XB(2,2) - SA1(3)=XB(3,2) - SA2(1)=XB(1,3) - SA2(2)=XB(2,3) - SA2(3)=XB(3,3) - END IF -! Arbitrary angles between the axes: - ELSE -! |A1|=|A2|=|A3| means body-centered tetragonal (IBRAV=6): -! Further additional criterions are: (A1+A2), (A1+A3) and (A2+A3) are -! orthogonal to one another and (adjustment!): |A1+A3|=|A2+A3|<|A1+A2| - IF ((ABS(ABS1-ABS2)TINY).AND. & - & (ABS(ABS3*ABS3+ABS123)|A1+A3|>|A2+A3| - IF ((ABS(ABS1-ABS2)TINY).AND. & - & ((ABS2P1-ABS3P1)>TINY).AND. & - & (ABS(ABS3*ABS3+ABS123)|A1+A3-A2|>|A2+A3-A1| - ELSE IF ((ABS(ABS2M1-ABS3)TINY).AND. & - & ((A3P1M2-A2P3M1)>TINY)) THEN - IBRAV=10 - CELLDM(1)=A2P3M1 - CELLDM(2)=A3P1M2/A2P3M1 - CELLDM(3)=A1P2M3/A2P3M1 -! Now there exists only one further possibility - triclinic (IBRAV=14): -! Adjustment: All three cosines shall be greater than zero and ordered: - ELSE IF ((A2XA1>A3XA1).AND.(A3XA1>A3XA2).AND. & - & (A3XA2>TINY)) THEN - IBRAV=14 - CELLDM(1)=ABS1 - CELLDM(2)=ABS2/ABS1 - CELLDM(3)=ABS3/ABS1 - CELLDM(4)=A3XA2 - CELLDM(5)=A3XA1 - CELLDM(6)=A2XA1 - END IF - END IF -! Remember the result ... : - IBRINP=IBRAV - CDMINP(1)=CELLDM(1) - CDMINP(2)=CELLDM(2) - CDMINP(3)=CELLDM(3) - CDMINP(4)=CELLDM(4) - CDMINP(5)=CELLDM(5) - CDMINP(6)=CELLDM(6) - -! Warning extremly strange inputs (very large/small ratios 'c/a', 'b/a' -! or cosines very close to +/-1) could sometimes lead to some problems -! due to the finite precision of the machine ...). Here we test some -! parameters and if we find 'strange parameters' we (DO NOT) stop! - ABS1=RB(1,1)*RB(1,1)+RB(2,1)*RB(2,1)+RB(3,1)*RB(3,1) - ABS2=RB(1,2)*RB(1,2)+RB(2,2)*RB(2,2)+RB(3,2)*RB(3,2) - ABS3=RB(1,3)*RB(1,3)+RB(2,3)*RB(2,3)+RB(3,3)*RB(3,3) - A2XA1=RB(1,1)*RB(1,2)+RB(2,1)*RB(2,2)+RB(3,1)*RB(3,2) - A3XA1=RB(1,1)*RB(1,3)+RB(2,1)*RB(2,3)+RB(3,1)*RB(3,3) - A3XA2=RB(1,2)*RB(1,3)+RB(2,2)*RB(2,3)+RB(3,2)*RB(3,3) - ABS1=SQRT(ABS1) - ABS2=SQRT(ABS2) - ABS3=SQRT(ABS3) - A1XA2=ABS(A2XA1/ABS1/ABS2) - A1XA3=ABS(A3XA1/ABS1/ABS3) - A2XA3=ABS(A3XA2/ABS2/ABS3) - IF (A1XA2>0.99999_q) ISTRGE=ISTRGE+1 - IF (A2XA3>0.99999_q) ISTRGE=ISTRGE+1 - IF (A1XA3>0.99999_q) ISTRGE=ISTRGE+1 - IF ((ABS3/ABS1)<0.00001_q) ISTRGE=ISTRGE+1 - IF ((ABS2/ABS1)<0.00001_q) ISTRGE=ISTRGE+1 - IF ((ABS3/ABS2)<0.00001_q) ISTRGE=ISTRGE+1 - IF ((ABS1/ABS3)<0.00001_q) ISTRGE=ISTRGE+1 - IF ((ABS1/ABS2)<0.00001_q) ISTRGE=ISTRGE+1 - IF ((ABS2/ABS3)<0.00001_q) ISTRGE=ISTRGE+1 - -! Search a primitive basis with shortest lattice vectors: - - ICOUNT=0 - GOTO 199 - -! The algorithm is the following: Take first one vector and subtract or -! add the two other vectors until you have found the shortest vector. -! Do the same with the other two vectors ... . The iterative method -! used here garantuees that the cell volume will be kept constant and -! all cell vectors occuring during the iterations span primitive cells. -! Two parameters control the flow: ILOOP checks every loop whether a -! vector could be found with smaller or with equal length compared to -! the starting vector by subtraction of an other vector. If ILOOP is not -! set you cannot lower the vector by subtraction of an other vector so -! you have to try it with addition of the vectors. Therefore every loop -! has the following structure: First try it with Ai-ICOUNT*Aj. If the -! shortest vector is found for ICOUNT=0 then try to take Ai+ICOUNT*Aj. -! The loops break if the vector length starts to increase and the vector -! Ai will be set equal to the shortest vector (Ai <-- Ai +/- ICOUNT*Aj). -! IFLAG will be set equal to one whenever a shorter vector was found -! during the total iteration step (6 loops!). If IFLAG is not set we -! found a basis with shortest lattice vectors. If not we should start -! a new iteration ... . - -! First try A1-ICOUNT*A2 (loop 1a): - 100 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,1)=RB(1,1)-RB(1,2) - RB(2,1)=RB(2,1)-RB(2,2) - RB(3,1)=RB(3,1)-RB(3,2) - ABSR=SQRT(RB(1,1)*RB(1,1)+RB(2,1)*RB(2,1)+RB(3,1)*RB(3,1)) -! Breakpoint of loop 1a: - IF (ABSR>(ABS1+TINY)) GOTO 102 -! Found some shorter vector ? Then set IFLAG (and store the length): - IF (ABSR<(ABS1-TINY)) THEN - IFLAG=1 - ABS1=ABSR - END IF -! Vector was not longer than the starting vector. Set ILOOP ... : - ILOOP=1 - GOTO 100 -! After leaving loop 1a we have subtracted A2 one times too often ... : - 102 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,1)=RB(1,1)+RB(1,2) - RB(2,1)=RB(2,1)+RB(2,2) - RB(3,1)=RB(3,1)+RB(3,2) -! Nothing found ? Try A1+ICOUNT*A2 (loop 1b): - IF (ILOOP==0) THEN - 103 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,1)=RB(1,1)+RB(1,2) - RB(2,1)=RB(2,1)+RB(2,2) - RB(3,1)=RB(3,1)+RB(3,2) - ABSR=SQRT(RB(1,1)*RB(1,1)+RB(2,1)*RB(2,1)+RB(3,1)*RB(3,1)) -! Breakpoint of loop 1b: - IF (ABSR>(ABS1+TINY)) GOTO 105 -! Found some shorter vector ? Then set IFLAG (and store the length): - IF (ABSR<(ABS1-TINY)) THEN - IFLAG=1 - ABS1=ABSR - END IF - GOTO 103 -! After leaving loop 1b we have added A2 one times too often ... : - 105 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,1)=RB(1,1)-RB(1,2) - RB(2,1)=RB(2,1)-RB(2,2) - RB(3,1)=RB(3,1)-RB(3,2) - END IF -! Reset ILOOP before starting the next loop ... : - ILOOP=0 -! Try A1-ICOUNT*A3 (loop 2a): - 110 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,1)=RB(1,1)-RB(1,3) - RB(2,1)=RB(2,1)-RB(2,3) - RB(3,1)=RB(3,1)-RB(3,3) - ABSR=SQRT(RB(1,1)*RB(1,1)+RB(2,1)*RB(2,1)+RB(3,1)*RB(3,1)) - IF (ABSR>(ABS1+TINY)) GOTO 112 - IF (ABSR<(ABS1-TINY)) THEN - IFLAG=1 - ABS1=ABSR - END IF - ILOOP=1 - GOTO 110 - 112 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,1)=RB(1,1)+RB(1,3) - RB(2,1)=RB(2,1)+RB(2,3) - RB(3,1)=RB(3,1)+RB(3,3) -! Nothing found ? Try A1+ICOUNT*A3 (loop 2b): - IF (ILOOP==0) THEN - 113 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,1)=RB(1,1)+RB(1,3) - RB(2,1)=RB(2,1)+RB(2,3) - RB(3,1)=RB(3,1)+RB(3,3) - ABSR=SQRT(RB(1,1)*RB(1,1)+RB(2,1)*RB(2,1)+RB(3,1)*RB(3,1)) - IF (ABSR>(ABS1+TINY)) GOTO 115 - IF (ABSR<(ABS1-TINY)) THEN - IFLAG=1 - ABS1=ABSR - END IF - GOTO 113 - 115 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,1)=RB(1,1)-RB(1,3) - RB(2,1)=RB(2,1)-RB(2,3) - RB(3,1)=RB(3,1)-RB(3,3) - END IF - ILOOP=0 -! Try A2-ICOUNT*A1 (loop 3a): - 120 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,2)=RB(1,2)-RB(1,1) - RB(2,2)=RB(2,2)-RB(2,1) - RB(3,2)=RB(3,2)-RB(3,1) - ABSR=SQRT(RB(1,2)*RB(1,2)+RB(2,2)*RB(2,2)+RB(3,2)*RB(3,2)) - IF (ABSR>(ABS2+TINY)) GOTO 122 - IF (ABSR<(ABS2-TINY)) THEN - IFLAG=1 - ABS2=ABSR - END IF - ILOOP=1 - GOTO 120 - 122 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,2)=RB(1,2)+RB(1,1) - RB(2,2)=RB(2,2)+RB(2,1) - RB(3,2)=RB(3,2)+RB(3,1) -! Nothing found ? Try A2+ICOUNT*A1 (loop 3b): - IF (ILOOP==0) THEN - 123 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,2)=RB(1,2)+RB(1,1) - RB(2,2)=RB(2,2)+RB(2,1) - RB(3,2)=RB(3,2)+RB(3,1) - ABSR=SQRT(RB(1,2)*RB(1,2)+RB(2,2)*RB(2,2)+RB(3,2)*RB(3,2)) - IF (ABSR>(ABS2+TINY)) GOTO 125 - IF (ABSR<(ABS2-TINY)) THEN - IFLAG=1 - ABS2=ABSR - END IF - GOTO 123 - 125 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,2)=RB(1,2)-RB(1,1) - RB(2,2)=RB(2,2)-RB(2,1) - RB(3,2)=RB(3,2)-RB(3,1) - END IF - ILOOP=0 -! Try A2-ICOUNT*A3 (loop 4a): - 130 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,2)=RB(1,2)-RB(1,3) - RB(2,2)=RB(2,2)-RB(2,3) - RB(3,2)=RB(3,2)-RB(3,3) - ABSR=SQRT(RB(1,2)*RB(1,2)+RB(2,2)*RB(2,2)+RB(3,2)*RB(3,2)) - IF (ABSR>(ABS2+TINY)) GOTO 132 - IF (ABSR<(ABS2-TINY)) THEN - IFLAG=1 - ABS2=ABSR - END IF - ILOOP=1 - GOTO 130 - 132 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,2)=RB(1,2)+RB(1,3) - RB(2,2)=RB(2,2)+RB(2,3) - RB(3,2)=RB(3,2)+RB(3,3) -! Nothing found ? Try A2+ICOUNT*A3 (loop 4b): - IF (ILOOP==0) THEN - 133 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,2)=RB(1,2)+RB(1,3) - RB(2,2)=RB(2,2)+RB(2,3) - RB(3,2)=RB(3,2)+RB(3,3) - ABSR=SQRT(RB(1,2)*RB(1,2)+RB(2,2)*RB(2,2)+RB(3,2)*RB(3,2)) - IF (ABSR>(ABS2+TINY)) GOTO 135 - IF (ABSR<(ABS2-TINY)) THEN - IFLAG=1 - ABS2=ABSR - END IF - GOTO 133 - 135 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,2)=RB(1,2)-RB(1,3) - RB(2,2)=RB(2,2)-RB(2,3) - RB(3,2)=RB(3,2)-RB(3,3) - END IF - ILOOP=0 -! Try A3-ICOUNT*A1 (loop 5a): - 140 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,3)=RB(1,3)-RB(1,1) - RB(2,3)=RB(2,3)-RB(2,1) - RB(3,3)=RB(3,3)-RB(3,1) - ABSR=SQRT(RB(1,3)*RB(1,3)+RB(2,3)*RB(2,3)+RB(3,3)*RB(3,3)) - IF (ABSR>(ABS3+TINY)) GOTO 142 - IF (ABSR<(ABS3-TINY)) THEN - IFLAG=1 - ABS3=ABSR - END IF - ILOOP=1 - GOTO 140 - 142 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,3)=RB(1,3)+RB(1,1) - RB(2,3)=RB(2,3)+RB(2,1) - RB(3,3)=RB(3,3)+RB(3,1) -! Nothing found ? Try A3+ICOUNT*A1 (loop 5b): - IF (ILOOP==0) THEN - 143 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,3)=RB(1,3)+RB(1,1) - RB(2,3)=RB(2,3)+RB(2,1) - RB(3,3)=RB(3,3)+RB(3,1) - ABSR=SQRT(RB(1,3)*RB(1,3)+RB(2,3)*RB(2,3)+RB(3,3)*RB(3,3)) - IF (ABSR>(ABS3+TINY)) GOTO 145 - IF (ABSR<(ABS3-TINY)) THEN - IFLAG=1 - ABS3=ABSR - END IF - GOTO 143 - 145 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,3)=RB(1,3)-RB(1,1) - RB(2,3)=RB(2,3)-RB(2,1) - RB(3,3)=RB(3,3)-RB(3,1) - END IF - ILOOP=0 -! Try A3-ICOUNT*A2 (loop 6a): - 150 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,3)=RB(1,3)-RB(1,2) - RB(2,3)=RB(2,3)-RB(2,2) - RB(3,3)=RB(3,3)-RB(3,2) - ABSR=SQRT(RB(1,3)*RB(1,3)+RB(2,3)*RB(2,3)+RB(3,3)*RB(3,3)) - IF (ABSR>(ABS3+TINY)) GOTO 152 - IF (ABSR<(ABS3-TINY)) THEN - IFLAG=1 - ABS3=ABSR - END IF - ILOOP=1 - GOTO 150 - 152 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,3)=RB(1,3)+RB(1,2) - RB(2,3)=RB(2,3)+RB(2,2) - RB(3,3)=RB(3,3)+RB(3,2) -! Nothing found ? Try A3+ICOUNT*A2 (loop 6b): - IF (ILOOP==0) THEN - 153 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,3)=RB(1,3)+RB(1,2) - RB(2,3)=RB(2,3)+RB(2,2) - RB(3,3)=RB(3,3)+RB(3,2) - ABSR=SQRT(RB(1,3)*RB(1,3)+RB(2,3)*RB(2,3)+RB(3,3)*RB(3,3)) - IF (ABSR>(ABS3+TINY)) GOTO 155 - IF (ABSR<(ABS3-TINY)) THEN - IFLAG=1 - ABS3=ABSR - END IF - GOTO 153 - 155 CONTINUE - ICOUNT=ICOUNT+1 - RB(1,3)=RB(1,3)-RB(1,2) - RB(2,3)=RB(2,3)-RB(2,2) - RB(3,3)=RB(3,3)-RB(3,2) - END IF -! Nothing found during loops 1a-6b ? Hurray, we have got it !! - IF (IFLAG==0) GOTO 200 -! Next iteration ... : - 199 ABS1=SQRT(RB(1,1)*RB(1,1)+RB(2,1)*RB(2,1)+RB(3,1)*RB(3,1)) - ABS2=SQRT(RB(1,2)*RB(1,2)+RB(2,2)*RB(2,2)+RB(3,2)*RB(3,2)) - ABS3=SQRT(RB(1,3)*RB(1,3)+RB(2,3)*RB(2,3)+RB(3,3)*RB(3,3)) - IFLAG=0 - ILOOP=0 - GOTO 100 - 200 CONTINUE - -! Adjustement of the basis to right-hand-sense (by inversion of all -! three lattice vectors if necessary ...): - CALL CELVOL(RB(1,1),RB(1,2),RB(1,3),OMEGA) - IF (OMEGA<0) THEN - RB(1,1)=-1._q*RB(1,1) - RB(2,1)=-1._q*RB(2,1) - RB(3,1)=-1._q*RB(3,1) - RB(1,2)=-1._q*RB(1,2) - RB(2,2)=-1._q*RB(2,2) - RB(3,2)=-1._q*RB(3,2) - RB(1,3)=-1._q*RB(1,3) - RB(2,3)=-1._q*RB(2,3) - RB(3,3)=-1._q*RB(3,3) - END IF - -! Warning extremly strange inputs (very large/small ratios 'c/a', 'b/a' -! or cosines very close to +/-1) could sometimes lead to some problems -! due to the finite precision of the machine ...). Here we test some -! parameters and if we find 'strange parameters' we (DO NOT) stop! - ABS1=RB(1,1)*RB(1,1)+RB(2,1)*RB(2,1)+RB(3,1)*RB(3,1) - ABS2=RB(1,2)*RB(1,2)+RB(2,2)*RB(2,2)+RB(3,2)*RB(3,2) - ABS3=RB(1,3)*RB(1,3)+RB(2,3)*RB(2,3)+RB(3,3)*RB(3,3) - A2XA1=RB(1,1)*RB(1,2)+RB(2,1)*RB(2,2)+RB(3,1)*RB(3,2) - A3XA1=RB(1,1)*RB(1,3)+RB(2,1)*RB(2,3)+RB(3,1)*RB(3,3) - A3XA2=RB(1,2)*RB(1,3)+RB(2,2)*RB(2,3)+RB(3,2)*RB(3,3) - ABS1=SQRT(ABS1) - ABS2=SQRT(ABS2) - ABS3=SQRT(ABS3) - A1XA2=ABS(A2XA1/ABS1/ABS2) - A1XA3=ABS(A3XA1/ABS1/ABS3) - A2XA3=ABS(A3XA2/ABS2/ABS3) - IF (A1XA2>0.995_q) ISTRGE=ISTRGE+1 - IF (A2XA3>0.995_q) ISTRGE=ISTRGE+1 - IF (A1XA3>0.995_q) ISTRGE=ISTRGE+1 - IF ((ABS3/ABS1)<0.001_q) ISTRGE=ISTRGE+1 - IF ((ABS2/ABS1)<0.001_q) ISTRGE=ISTRGE+1 - IF ((ABS3/ABS2)<0.001_q) ISTRGE=ISTRGE+1 - IF ((ABS1/ABS3)<0.001_q) ISTRGE=ISTRGE+1 - IF ((ABS1/ABS2)<0.001_q) ISTRGE=ISTRGE+1 - IF ((ABS2/ABS3)<0.001_q) ISTRGE=ISTRGE+1 - -! Now construct several possible combinations of lattice vectors -! and test them all for specific criterions ... : - - !write(*,*) "RB1=",RB(1,1),RB(2,1),RB(3,1) !mohan - !write(*,*) "RB2=",RB(1,2),RB(2,2),RB(3,2) !mohan - !write(*,*) "RB3=",RB(1,3),RB(2,3),RB(3,3) !mohan - ITYP=15 - COS1=1._q - COS2=1._q - COS3=1._q - DO N9=-2,2 - DO N8=-2,2 - DO N7=-2,2 - DO N6=-2,2 - DO N5=-2,2 - ID1=N5*N9-N6*N8 - DO N4=-2,2 - ID2=N6*N7-N4*N9 - ID3=N4*N8-N5*N7 - DO N3=-2,2 - ID4=N3*ID3 - DO N2=-2,2 - ID5=N2*ID2+ID4 - DO N1=-2,2 - IF ((N1*ID1+ID5)==1) THEN - XB(1,1)=N1*RB(1,1)+N2*RB(1,2)+N3*RB(1,3) - XB(2,1)=N1*RB(2,1)+N2*RB(2,2)+N3*RB(2,3) - XB(3,1)=N1*RB(3,1)+N2*RB(3,2)+N3*RB(3,3) - XB(1,2)=N4*RB(1,1)+N5*RB(1,2)+N6*RB(1,3) - XB(2,2)=N4*RB(2,1)+N5*RB(2,2)+N6*RB(2,3) - XB(3,2)=N4*RB(3,1)+N5*RB(3,2)+N6*RB(3,3) - XB(1,3)=N7*RB(1,1)+N8*RB(1,2)+N9*RB(1,3) - XB(2,3)=N7*RB(2,1)+N8*RB(2,2)+N9*RB(2,3) - XB(3,3)=N7*RB(3,1)+N8*RB(3,2)+N9*RB(3,3) - -! Lengths of the axes and cosines between the axes: - ABS1=XB(1,1)*XB(1,1)+XB(2,1)*XB(2,1)+XB(3,1)*XB(3,1) - ABS2=XB(1,2)*XB(1,2)+XB(2,2)*XB(2,2)+XB(3,2)*XB(3,2) - ABS3=XB(1,3)*XB(1,3)+XB(2,3)*XB(2,3)+XB(3,3)*XB(3,3) - A2XA1=XB(1,1)*XB(1,2)+XB(2,1)*XB(2,2)+XB(3,1)*XB(3,2) - A3XA1=XB(1,1)*XB(1,3)+XB(2,1)*XB(2,3)+XB(3,1)*XB(3,3) - A3XA2=XB(1,2)*XB(1,3)+XB(2,2)*XB(2,3)+XB(3,2)*XB(3,3) - ABS2M1=SQRT(ABS1+ABS2-2._q*A2XA1) - ABS3M1=SQRT(ABS1+ABS3-2._q*A3XA1) - ABS3M2=SQRT(ABS2+ABS3-2._q*A3XA2) - ABS2P1=SQRT(ABS1+ABS2+2._q*A2XA1) - ABS3P1=SQRT(ABS1+ABS3+2._q*A3XA1) - ABS3P2=SQRT(ABS2+ABS3+2._q*A3XA2) - A1P2M3=SQRT(ABS1+ABS2+ABS3+2._q*A2XA1-2._q*A3XA1-2._q*A3XA2) - A2P3M1=SQRT(ABS1+ABS2+ABS3+2._q*A3XA2-2._q*A2XA1-2._q*A3XA1) - A3P1M2=SQRT(ABS1+ABS2+ABS3+2._q*A3XA1-2._q*A3XA2-2._q*A2XA1) - ABS123=A2XA1+A3XA1+A3XA2 - ABS1=SQRT(ABS1) - ABS2=SQRT(ABS2) - ABS3=SQRT(ABS3) - A2XA1=A2XA1/ABS1/ABS2 - A3XA1=A3XA1/ABS1/ABS3 - A3XA2=A3XA2/ABS2/ABS3 - A1XA2=ABS(A2XA1) - A1XA3=ABS(A3XA1) - A2XA3=ABS(A3XA2) -! Warning extremly strange inputs (very large/small ratios 'c/a', 'b/a' -! or cosines very close to +/-1) could sometimes lead to some problems -! due to the finite precision of the machine ...). Here we test some -! parameters and if we find 'strange parameters', we (DO NOT) stop! - -! Following the identification of the crystal type, transformation of -! the basis to 'crystallographic standard settings' and estimate of the -! cell dimensions (using the conventions of routine LATGEN): - CELLDM(1)=0._q - CELLDM(2)=0._q - CELLDM(3)=0._q - CELLDM(4)=0._q - CELLDM(5)=0._q - CELLDM(6)=0._q - IBRAV=15 -! Crystal classes with A1*A2=A1*A3=A2*A3: - IF ((ABS(A2XA1-A3XA1)TINY).AND. & - & ((ABS2-ABS1)>TINY)) THEN - IBRAV=8 - CELLDM(1)=ABS1 - CELLDM(2)=ABS2/ABS1 - CELLDM(3)=ABS3/ABS1 - END IF - END IF -! Crystal classes with A1*A3=A2*A3=/A1*A2: - ELSE IF (ABS(A3XA1-A3XA2)TINY)) THEN - IBRAV=12 - CELLDM(1)=ABS2 - CELLDM(2)=ABS3/ABS2 - CELLDM(3)=ABS1/ABS2 - CELLDM(5)=A2XA1 - YB(1)=XB(1,3) - YB(2)=XB(2,3) - YB(3)=XB(3,3) - XB(1,3)=XB(1,1) - XB(2,3)=XB(2,1) - XB(3,3)=XB(3,1) - XB(1,1)=XB(1,2) - XB(2,1)=XB(2,2) - XB(3,1)=XB(3,2) - XB(1,2)=YB(1) - XB(2,2)=YB(2) - XB(3,2)=YB(3) - END IF -! Arbitrary angles between the axes: - ELSE -! |A1|=|A2|=|A3| means body-centered tetragonal (IBRAV=6): -! Further additional criterions are: (A1+A2), (A1+A3) and (A2+A3) are -! orthogonal to one another and (adjustment!): |A1+A3|=|A2+A3|/=|A1+A2| - IF ((ABS(ABS1-ABS2)TINY).AND. & - & (ABS(ABS3*ABS3+ABS123)|A1+A3|>|A2+A3| - IF ((ABS(ABS1-ABS2)TINY).AND. & - & ((ABS2P1-ABS3P1)>TINY).AND. & - & (ABS(ABS3*ABS3+ABS123)|A1+A3-A2|>|A2+A3-A1| - ELSE IF ((ABS(ABS2M1-ABS3)TINY).AND. & - & ((A3P1M2-A2P3M1)>TINY)) THEN - IBRAV=10 - CELLDM(1)=A2P3M1 - CELLDM(2)=A3P1M2/A2P3M1 - CELLDM(3)=A1P2M3/A2P3M1 -! Now there exists only one further possibility - triclinic (IBRAV=14): -! Adjustment: All three cosines shall be greater than zero and ordered: - ELSE IF ((A2XA1>A3XA1).AND.(A3XA1>A3XA2).AND. & - & (A3XA2>TINY)) THEN - IBRAV=14 - CELLDM(1)=ABS1 - CELLDM(2)=ABS2/ABS1 - CELLDM(3)=ABS3/ABS1 - CELLDM(4)=A3XA2 - CELLDM(5)=A3XA1 - CELLDM(6)=A2XA1 - END IF - END IF - -! Have we found some lattice with lower index IBRAV as all previous? - IF ((IBRAVvltot); + EFID.add_efield(CHR.rho[0], this->vltot); } } else @@ -107,7 +107,7 @@ void potential::init_pot(const int &istep, const bool delta_vh, const bool vna) } } // (2) core correction potential. - chr.set_rho_core( pw.strucFac ); + CHR.set_rho_core( pw.strucFac ); //if(vna==1)return; // tmp by mohan } @@ -120,7 +120,7 @@ void potential::init_pot(const int &istep, const bool delta_vh, const bool vna) if (this->start_pot == "atomic")//mohan add 2007-10-17 { start_from_atomic: - chr.atomic_rho(NSPIN, chr.rho); + CHR.atomic_rho(NSPIN, CHR.rho); } else if (this->start_pot == "file") { @@ -131,7 +131,7 @@ void potential::init_pot(const int &istep, const bool delta_vh, const bool vna) ssc << global_out_dir << "SPIN" << is + 1 << "_CHG"; ofs_running << ssc.str() << endl; // mohan update 2012-02-10 - if(chr.read_rho( is, ssc.str() )) + if(CHR.read_rho( is, ssc.str() )) { ofs_running << " Read in the charge density: " << ssc.str() << endl; } @@ -141,7 +141,7 @@ void potential::init_pot(const int &istep, const bool delta_vh, const bool vna) {//read only up+down , others set to zero. ofs_running << " Didn't read in the charge density but autoset it for spin " <v_of_rho( chr.rho, en.ehart, en.etxc, en.vtxc, vr, delta_vh, vna); + this->v_of_rho( CHR.rho, en.ehart, en.etxc, en.vtxc, vr, delta_vh, vna); //---------------------------------------------------------- // Define the total local potential (external+scf) @@ -242,7 +242,7 @@ void potential::set_local(double* vl_pseudo)const if(EFIELD && !DIPOLE) { Efield EFID; - // in fact, chr.rho is not used here. + // in fact, CHR.rho is not used here. // if charge correction due to Efield is considered, // the structure here need to be updated. @@ -252,7 +252,7 @@ void potential::set_local(double* vl_pseudo)const cout << " ADD THE EFIELD (V/A) : " << Efield::eamp*51.44 << endl; first = false; } - EFID.add_efield(chr.rho[0], vl_pseudo); + EFID.add_efield(CHR.rho[0], vl_pseudo); } //ofs_running <<" set local pseudopotential done." << endl; @@ -290,7 +290,7 @@ void potential::v_of_rho ZEROS(rho_atom[is], pw.nrxx); } - chr.atomic_rho(NSPIN,rho_atom); + CHR.atomic_rho(NSPIN,rho_atom); this->v_h(NSPIN, ehart, v_in, rho_atom); @@ -326,7 +326,7 @@ void potential::v_of_rho ZEROS(rho_atom[is], pw.nrxx); } - chr.atomic_rho(NSPIN,rho_atom); + CHR.atomic_rho(NSPIN,rho_atom); //-------------------------------------------- // get the delta atomic charge on real space @@ -406,7 +406,7 @@ void potential::v_xc // 2008-06-01 mohan for (int ir = 0;ir < pw.nrxx;ir++) { - rhox = rho_in[0][ir] + chr.rho_core[ir]; + rhox = rho_in[0][ir] + CHR.rho_core[ir]; arhox = abs(rhox); if (arhox > vanishing_charge) { @@ -433,7 +433,7 @@ void potential::v_xc if (test_potential>0) cout<<"\n Begin calculate Exc(r) and Vxc(r)"; for (ir = 0;ir < pw.nrxx;ir++) { - rhox = rho_in[0][ir] + rho_in[1][ir] + chr.rho_core[ir]; //HLX(05-29-06): bug fixed + rhox = rho_in[0][ir] + rho_in[1][ir] + CHR.rho_core[ir]; //HLX(05-29-06): bug fixed arhox = abs(rhox); if (arhox > vanishing_charge) @@ -483,7 +483,7 @@ void potential::v_xc { double amag = sqrt( pow(rho_in[1][ir],2) + pow(rho_in[2][ir],2) + pow(rho_in[3][ir],2) ); - rhox = rho_in[0][ir] + chr.rho_core[ir]; + rhox = rho_in[0][ir] + CHR.rho_core[ir]; if ( rho_in[0][ir] < 0.0 ) neg[0] -= rho_in[0][ir]; @@ -1389,7 +1389,7 @@ void potential::write_elecstat_pot(const string &fn, const string &fn_ave) { for(int ir=0; ir( chr.rho[is][ir], 0.0 ); + Porter[ir] += complex( CHR.rho[is][ir], 0.0 ); } } diff --git a/ABACUS.develop/source/src_pw/stress.cpp b/ABACUS.develop/source/src_pw/stress.cpp index f0259163f7..1cf4c80886 100644 --- a/ABACUS.develop/source/src_pw/stress.cpp +++ b/ABACUS.develop/source/src_pw/stress.cpp @@ -362,14 +362,14 @@ void Stress::stres_har(){ complex *Porter = UFFT.porter; // Hartree potential VH(r) from n(r) - ZEROS( Porter, pw.nrxx ); - for(int is=0; is( chr.rho[is][ir], 0.0 ); - } - } + ZEROS( Porter, pw.nrxx ); + for(int is=0; is( CHR.rho[is][ir], 0.0 ); + } + } //============================= // bring rho (aux) to G space //============================= @@ -380,7 +380,7 @@ void Stress::stres_har(){ ZEROS( psic0, pw.nrxx); for(int is=0; is(psic0[ir], 0.0); @@ -516,7 +516,7 @@ void Stress::stres_loc() { for (int ir=0; ir(chr.rho[is][ir], 0.0 ); + Porter[ir] += complex(CHR.rho[is][ir], 0.0 ); } } pw.FFT_chg.FFT3D(Porter, -1); @@ -526,7 +526,7 @@ void Stress::stres_loc() ZEROS( psic0, pw.nrxx); for(int is=0; is(psic0[ir], 0.0); @@ -1440,12 +1440,12 @@ void Stress::stres_gradcorr() const double fac = 1.0/ NSPIN; // doing FFT to get rho in G space: rhog1 - chr.set_rhog(chr.rho[0], chr.rhog[0]); + CHR.set_rhog(CHR.rho[0], CHR.rhog[0]); if(NSPIN==2)//mohan fix bug 2012-05-28 { - chr.set_rhog(chr.rho[1], chr.rhog[1]); + CHR.set_rhog(CHR.rho[1], CHR.rhog[1]); } - chr.set_rhog(chr.rho_core, chr.rhog_core); + CHR.set_rhog(CHR.rho_core, CHR.rhog_core); double* rhotmp1; double* rhotmp2; @@ -1458,8 +1458,8 @@ void Stress::stres_gradcorr() rhogsum1 = new complex[pw.ngmc]; ZEROS(rhotmp1, pw.nrxx); ZEROS(rhogsum1, pw.ngmc); - for(int ir=0; ir[pw.nrxx]; ZEROS(gdr1, pw.nrxx); @@ -1471,8 +1471,8 @@ void Stress::stres_gradcorr() rhogsum2 = new complex[pw.ngmc]; ZEROS(rhotmp2, pw.nrxx); ZEROS(rhogsum2, pw.ngmc); - for(int ir=0; ir[pw.nrxx]; ZEROS(gdr2, pw.nrxx); @@ -1642,7 +1642,7 @@ void Stress::stres_cc() //recalculate the exchange-correlation potential matrix vxc(NSPIN, pw.nrxx); - pot.v_xc(chr.rho, en.etxc, en.vtxc, vxc); + pot.v_xc(CHR.rho, en.etxc, en.vtxc, vxc); complex * psic = new complex [pw.nrxx]; ZEROS(psic, pw.nrxx); @@ -1675,7 +1675,7 @@ void Stress::stres_cc() for(nt=0;nt *gkk) { - if (test_wf) TITLE("WF_io","write_wfc2"); - - ofstream ofs( fn.c_str() ); - - if(MY_RANK==0) - { - ofs.precision(10); - ofs << ucell.lat0 << endl; + if (test_wf) TITLE("WF_io","write_wfc2"); - ofs << ucell.latvec.e11 << " " << ucell.latvec.e12 << " " << ucell.latvec.e13 << endl; - ofs << ucell.latvec.e21 << " " << ucell.latvec.e22 << " " << ucell.latvec.e23 << endl; - ofs << ucell.latvec.e31 << " " << ucell.latvec.e32 << " " << ucell.latvec.e33 << endl; - - ofs << ucell.ntype << " ntype" << endl; - for (int it=0; it"; - } - - // (2) - for (int ik=0; ik" << endl; - ofs.close(); - } - - // out put the wave functions in plane wave basis. + //if(MY_RANK!=0) cout.clear(); + //cout<<"Hello"<"<\n"<"<\n"<" <" < *gkk); void read_wfc(const string &fn, const ComplexMatrix *psi); } From 165a6d4fa1b599776d1b8483334fb1b0461d6130 Mon Sep 17 00:00:00 2001 From: mohanchen Date: Sun, 31 Jan 2021 20:32:36 +0800 Subject: [PATCH 052/233] update the inclusion of global_fp.h --- ABACUS.develop/source/input_conv.cpp | 4 ++++ ABACUS.develop/source/src_global/global_variable.cpp | 11 ----------- ABACUS.develop/source/src_lcao/build_st_pw.cpp | 2 ++ ABACUS.develop/source/src_lcao/gint_gamma_fvl.cpp | 2 ++ ABACUS.develop/source/src_lcao/gint_gamma_fvna.cpp | 2 ++ ABACUS.develop/source/src_lcao/gint_gamma_mull.cpp | 2 ++ ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp | 2 ++ ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp | 2 ++ ABACUS.develop/source/src_lcao/gint_gamma_vna.cpp | 2 ++ ABACUS.develop/source/src_lcao/gint_gamma_vna_d.cpp | 2 ++ ABACUS.develop/source/src_lcao/gint_k.cpp | 2 ++ ABACUS.develop/source/src_lcao/gint_k_fvl.cpp | 2 ++ ABACUS.develop/source/src_lcao/gint_k_rho.cpp | 2 ++ ABACUS.develop/source/src_lcao/gint_k_vna.cpp | 2 ++ ABACUS.develop/source/src_lcao/gint_k_vna_d.cpp | 2 ++ ABACUS.develop/source/src_lcao/gint_speed.cpp | 2 ++ ABACUS.develop/source/src_lcao/gint_speed_rho.cpp | 2 ++ ABACUS.develop/source/src_lcao/grid_base.cpp | 2 ++ ABACUS.develop/source/src_lcao/grid_base_beta.cpp | 2 ++ ABACUS.develop/source/src_lcao/grid_bigcell.cpp | 2 ++ ABACUS.develop/source/src_lcao/grid_integral.cpp | 2 ++ ABACUS.develop/source/src_lcao/grid_technique.cpp | 2 ++ ABACUS.develop/source/src_lcao/lcao_vna.cpp | 1 + ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp | 2 ++ ABACUS.develop/source/src_lcao/sltk_atom_arrange.cpp | 2 ++ ABACUS.develop/source/src_lcao/update_input.cpp | 1 + ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp | 2 ++ ABACUS.develop/source/src_lcao/use_overlap_matrix.cpp | 2 ++ ABACUS.develop/source/src_pw/chi0_hilbert.cpp | 1 + ABACUS.develop/source/src_pw/chi0_standard.cpp | 2 +- ABACUS.develop/source/src_pw/global.h | 9 ++------- ABACUS.develop/source/src_pw/toWannier90.cpp | 1 + ABACUS.develop/source/src_pw/unitcell_pseudo.cpp | 3 +-- 33 files changed, 60 insertions(+), 21 deletions(-) diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index 21c668184c..1fce194ce6 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -8,6 +8,10 @@ #include "src_lcao/local_orbital_charge.h" #include "src_lcao/lcao_orbitals.h" #include "src_pw/efield.h" +#include "src_lcao/global_fp.h" + +// those included filese below this comment should not appear here +// mohan 2021-01-30 #include "src_pw/vdwd2.h" #include "src_pw/vdwd3.h" #include "src_pw/chi0_hilbert.h" diff --git a/ABACUS.develop/source/src_global/global_variable.cpp b/ABACUS.develop/source/src_global/global_variable.cpp index a0492352e6..15c7f36b9c 100644 --- a/ABACUS.develop/source/src_global/global_variable.cpp +++ b/ABACUS.develop/source/src_global/global_variable.cpp @@ -137,17 +137,6 @@ string global_out_dir; ofstream ofs_running; ofstream ofs_warning; -#ifdef __EPM -int EPM_SPIN_ORBITAL = false; -// 0 stands for no spin-orbital coupling; -// 1 stands for plane wave method; -// 2 stands for small-box technique; -bool EPM_ZEEMAN = false; -double EPM_MAG_FIELD_X = 0.0; -double EPM_MAG_FIELD_Y = 0.0; -double EPM_MAG_FIELD_Z = 0.0; -#endif - //---------------------------------------------------------- // EXPLAIN : test level for each class //---------------------------------------------------------- diff --git a/ABACUS.develop/source/src_lcao/build_st_pw.cpp b/ABACUS.develop/source/src_lcao/build_st_pw.cpp index f3688ca5ee..be4bd22f59 100644 --- a/ABACUS.develop/source/src_lcao/build_st_pw.cpp +++ b/ABACUS.develop/source/src_lcao/build_st_pw.cpp @@ -1,6 +1,8 @@ #include "build_st_pw.h" #include "../src_pw/global.h" +#include "../src_lcao/global_fp.h" // mohan add 2021-01-30 + Build_ST_pw::Build_ST_pw() { diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_fvl.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_fvl.cpp index 0f9afd599c..26aa0880ed 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_fvl.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_fvl.cpp @@ -4,6 +4,8 @@ #include "../src_pw/global.h" #include "src_global/blas_connector.h" +#include "global_fp.h" // mohan add 2021-01-30 + void Gint_Gamma::cal_force(const double* vlocal_in) { timer::tick("Gint_Gamma","cal_force",'H'); diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_fvna.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_fvna.cpp index ef293e87c1..0491bbd29a 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_fvna.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_fvna.cpp @@ -3,6 +3,8 @@ #include "lcao_orbitals.h" #include "../src_pw/global.h" +#include "global_fp.h" // mohan add 2021-01-30 + void Gint_Gamma::cal_force_vna(const double* vlocal_in, const Grid_Technique >, LCAO_Matrix &lm) { timer::tick("Gint_Gamma","cal_force_vna",'I'); diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_mull.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_mull.cpp index 1c6b1c8ec7..1a8d4845f6 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_mull.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_mull.cpp @@ -3,6 +3,8 @@ #include "lcao_orbitals.h" #include "../src_pw/global.h" +#include "global_fp.h" // mohan add 2021-01-30 + void Gint_Gamma::cal_mulliken(double** mulliken) { TITLE("Gint_Gamma","cal_mulliken"); diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp index f86cdf25c2..4027fe99f9 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp @@ -5,6 +5,8 @@ #include "src_global/blas_connector.h" #include +#include "global_fp.h" // mohan add 2021-01-30 + //inline void setVindex(const int ncyz, const int ibx, const int jby, const int kbz, int* vindex) void Gint_Gamma::setVindex(const int ncyz, const int ibx, const int jby, const int kbz, int* vindex) const { diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp index bb482262f4..9f5c284e53 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp @@ -4,6 +4,8 @@ #include "../src_pw/global.h" #include "src_global/blas_connector.h" #include + +#include "global_fp.h" // mohan add 2021-01-30 //#include extern "C" diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_vna.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_vna.cpp index 4161da1d19..240390c961 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_vna.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_vna.cpp @@ -3,6 +3,8 @@ #include "lcao_orbitals.h" #include "../src_pw/global.h" +#include "global_fp.h" // mohan add 2021-01-30 + void Gint_Gamma::cal_vna( const double* vlocal_in) { diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_vna_d.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_vna_d.cpp index 4429563a7b..068bfec239 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_vna_d.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_vna_d.cpp @@ -3,6 +3,8 @@ #include "lcao_orbitals.h" #include "../src_pw/global.h" +#include "global_fp.h" // mohan add 2021-01-30 + void Gint_Gamma::cal_vna_d(const Grid_Technique >, const double* vrs1, const char &matrix_type) { diff --git a/ABACUS.develop/source/src_lcao/gint_k.cpp b/ABACUS.develop/source/src_lcao/gint_k.cpp index 1ff0b346c2..e5add55998 100644 --- a/ABACUS.develop/source/src_lcao/gint_k.cpp +++ b/ABACUS.develop/source/src_lcao/gint_k.cpp @@ -6,6 +6,8 @@ #include "ylm.h" #include "../src_pw/global.h" +#include "global_fp.h" // mohan add 2021-01-30 + Gint_k::Gint_k() { ik_now = 0; diff --git a/ABACUS.develop/source/src_lcao/gint_k_fvl.cpp b/ABACUS.develop/source/src_lcao/gint_k_fvl.cpp index b6478c4d40..ebb7ef94ab 100644 --- a/ABACUS.develop/source/src_lcao/gint_k_fvl.cpp +++ b/ABACUS.develop/source/src_lcao/gint_k_fvl.cpp @@ -2,6 +2,8 @@ #include "../src_pw/global.h" #include "lcao_nnr.h" +#include "global_fp.h" // mohan add 2021-01-30 + void Gint_k::fvl_k_RealSpace(double** fvl_dphi, const double *vl) { TITLE("Gint_k","cal_force"); diff --git a/ABACUS.develop/source/src_lcao/gint_k_rho.cpp b/ABACUS.develop/source/src_lcao/gint_k_rho.cpp index f3972f4a55..ded706f8ff 100644 --- a/ABACUS.develop/source/src_lcao/gint_k_rho.cpp +++ b/ABACUS.develop/source/src_lcao/gint_k_rho.cpp @@ -7,6 +7,8 @@ #include "../src_pw/global.h" #include "src_global/blas_connector.h" +#include "global_fp.h" // mohan add 2021-01-30 + inline void setVindex(const int ncyz, const int ibx, const int jby, const int kbz, int* vindex) { int bindex = 0; diff --git a/ABACUS.develop/source/src_lcao/gint_k_vna.cpp b/ABACUS.develop/source/src_lcao/gint_k_vna.cpp index 86de21341e..b54402b42b 100644 --- a/ABACUS.develop/source/src_lcao/gint_k_vna.cpp +++ b/ABACUS.develop/source/src_lcao/gint_k_vna.cpp @@ -4,6 +4,8 @@ #include "../src_pw/global.h" #include "lcao_nnr.h" +#include "global_fp.h" // mohan add 2021-01-30 + void Gint_k::cal_vna(const double* vrs1, const Grid_Technique >) { diff --git a/ABACUS.develop/source/src_lcao/gint_k_vna_d.cpp b/ABACUS.develop/source/src_lcao/gint_k_vna_d.cpp index 362b17c42d..0fb9de0279 100644 --- a/ABACUS.develop/source/src_lcao/gint_k_vna_d.cpp +++ b/ABACUS.develop/source/src_lcao/gint_k_vna_d.cpp @@ -4,6 +4,8 @@ #include "../src_pw/global.h" #include "lcao_nnr.h" +#include "global_fp.h" // mohan add 2021-01-30 + void Gint_k::cal_vna_d(const Grid_Technique >, const double* vrs1, const char &matrix_type) { diff --git a/ABACUS.develop/source/src_lcao/gint_speed.cpp b/ABACUS.develop/source/src_lcao/gint_speed.cpp index eb4dce3182..12050a8da0 100644 --- a/ABACUS.develop/source/src_lcao/gint_speed.cpp +++ b/ABACUS.develop/source/src_lcao/gint_speed.cpp @@ -4,6 +4,8 @@ #include "../src_pw/global.h" #include "local_orbital_elec.h" //mohan add 2012-03-29 +#include "global_fp.h" // mohan add 2021-01-30 + #include Gint_Speed::Gint_Speed() diff --git a/ABACUS.develop/source/src_lcao/gint_speed_rho.cpp b/ABACUS.develop/source/src_lcao/gint_speed_rho.cpp index 2ffe8bbed5..f966752b3b 100644 --- a/ABACUS.develop/source/src_lcao/gint_speed_rho.cpp +++ b/ABACUS.develop/source/src_lcao/gint_speed_rho.cpp @@ -4,6 +4,8 @@ #include "../src_pw/global.h" #include "local_orbital_elec.h" //mohan add 2012-03-29 +#include "global_fp.h" // mohan add 2021-01-30 + double Gint_Speed::cal_rho(void) { diff --git a/ABACUS.develop/source/src_lcao/grid_base.cpp b/ABACUS.develop/source/src_lcao/grid_base.cpp index 7a58edd5f5..e7bbbb0b2e 100644 --- a/ABACUS.develop/source/src_lcao/grid_base.cpp +++ b/ABACUS.develop/source/src_lcao/grid_base.cpp @@ -3,6 +3,8 @@ #include "ylm.h" #include "lcao_orbitals.h" +#include "global_fp.h" // mohan add 2021-01-30 + Grid_Base::Grid_Base() { this->Rcut_max = new double[1]; diff --git a/ABACUS.develop/source/src_lcao/grid_base_beta.cpp b/ABACUS.develop/source/src_lcao/grid_base_beta.cpp index f9b92d7dfe..a7acc0a3e0 100644 --- a/ABACUS.develop/source/src_lcao/grid_base_beta.cpp +++ b/ABACUS.develop/source/src_lcao/grid_base_beta.cpp @@ -2,6 +2,8 @@ #include "../src_pw/global.h" #include "ylm.h" +#include "global_fp.h" // mohan add 2021-01-30 + Grid_Base_Beta::Grid_Base_Beta() { this->nnn = new int[1]; diff --git a/ABACUS.develop/source/src_lcao/grid_bigcell.cpp b/ABACUS.develop/source/src_lcao/grid_bigcell.cpp index adde245d0d..cb0b4efb01 100644 --- a/ABACUS.develop/source/src_lcao/grid_bigcell.cpp +++ b/ABACUS.develop/source/src_lcao/grid_bigcell.cpp @@ -1,6 +1,8 @@ #include "grid_bigcell.h" #include "../src_pw/global.h" +#include "global_fp.h" // mohan add 2021-01-30 + Grid_BigCell::Grid_BigCell() { this->flag_tib = false; diff --git a/ABACUS.develop/source/src_lcao/grid_integral.cpp b/ABACUS.develop/source/src_lcao/grid_integral.cpp index 23b0e36c77..7f4c865077 100644 --- a/ABACUS.develop/source/src_lcao/grid_integral.cpp +++ b/ABACUS.develop/source/src_lcao/grid_integral.cpp @@ -3,6 +3,8 @@ #include "ylm.h" #include "lcao_orbitals.h" +#include "global_fp.h" // mohan add 2021-01-30 + // use density kernel(density matrix) to calcualte the density // on real space grid. diff --git a/ABACUS.develop/source/src_lcao/grid_technique.cpp b/ABACUS.develop/source/src_lcao/grid_technique.cpp index 837e508775..56c1e7fa5d 100644 --- a/ABACUS.develop/source/src_lcao/grid_technique.cpp +++ b/ABACUS.develop/source/src_lcao/grid_technique.cpp @@ -1,6 +1,8 @@ #include "grid_technique.h" #include "../src_pw/global.h" +#include "global_fp.h" // mohan add 2021-01-30 + Grid_Technique GridT; Grid_Technique::Grid_Technique() diff --git a/ABACUS.develop/source/src_lcao/lcao_vna.cpp b/ABACUS.develop/source/src_lcao/lcao_vna.cpp index b39fe2fdc9..81ef248809 100644 --- a/ABACUS.develop/source/src_lcao/lcao_vna.cpp +++ b/ABACUS.develop/source/src_lcao/lcao_vna.cpp @@ -1,5 +1,6 @@ #include "lcao_vna.h" #include "../src_pw/global.h" +#include "global_fp.h" // mohan add 2021-01-30 LCAO_Vna::LCAO_Vna() {} diff --git a/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp b/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp index 90f5e93e4c..40ae51cb1f 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp @@ -3,6 +3,8 @@ #include "../src_pw/algorithms.h" #include "../src_lcao/wf_local.h" +#include "global_fp.h" // mohan add 2021-01-30 + Local_Orbital_wfc::Local_Orbital_wfc() { allocate_flag = false; diff --git a/ABACUS.develop/source/src_lcao/sltk_atom_arrange.cpp b/ABACUS.develop/source/src_lcao/sltk_atom_arrange.cpp index 401aa24b90..0e497d9aca 100644 --- a/ABACUS.develop/source/src_lcao/sltk_atom_arrange.cpp +++ b/ABACUS.develop/source/src_lcao/sltk_atom_arrange.cpp @@ -4,6 +4,8 @@ #include "sltk_grid.h" #include "sltk_grid_driver.h" +#include "../src_lcao/global_fp.h" // mohan add 2021-01-30 + atom_arrange::atom_arrange() { diff --git a/ABACUS.develop/source/src_lcao/update_input.cpp b/ABACUS.develop/source/src_lcao/update_input.cpp index 96ac994cf4..3a6952c563 100644 --- a/ABACUS.develop/source/src_lcao/update_input.cpp +++ b/ABACUS.develop/source/src_lcao/update_input.cpp @@ -10,6 +10,7 @@ #include "../src_pw/optical.h" #include "../src_lcao/force_lcao.h" #include "../src_lcao/local_orbital_charge.h" +#include "global_fp.h" // mohan update 2021-01-30 Update_input::Update_input() {} Update_input::~Update_input() {} diff --git a/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp b/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp index f034f2e542..df31673272 100644 --- a/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp @@ -4,6 +4,8 @@ #include "sltk_atom_arrange.h" #include "lcao_vna.h" +#include "global_fp.h" // mohan add 2021-01-30 + Use_Hamilt_Matrix::Use_Hamilt_Matrix() { init_s = false; diff --git a/ABACUS.develop/source/src_lcao/use_overlap_matrix.cpp b/ABACUS.develop/source/src_lcao/use_overlap_matrix.cpp index 0e57c9659c..21b1dae741 100644 --- a/ABACUS.develop/source/src_lcao/use_overlap_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/use_overlap_matrix.cpp @@ -4,6 +4,8 @@ //#include "../src_develop/src_wannier/manipulation.h" #include "lcao_nnr.h" +#include "global_fp.h" // mohan add 2021-01-30 + Use_Overlap_Matrix::Use_Overlap_Matrix() {} diff --git a/ABACUS.develop/source/src_pw/chi0_hilbert.cpp b/ABACUS.develop/source/src_pw/chi0_hilbert.cpp index 9b5c645c36..a99583cc05 100644 --- a/ABACUS.develop/source/src_pw/chi0_hilbert.cpp +++ b/ABACUS.develop/source/src_pw/chi0_hilbert.cpp @@ -15,6 +15,7 @@ #include "optical.h" #include "klist.h" #include +#include "../src_lcao/global_fp.h" using namespace std; Chi0_hilbert chi0_hilbert; diff --git a/ABACUS.develop/source/src_pw/chi0_standard.cpp b/ABACUS.develop/source/src_pw/chi0_standard.cpp index 666148e914..d27b6a79c5 100644 --- a/ABACUS.develop/source/src_pw/chi0_standard.cpp +++ b/ABACUS.develop/source/src_pw/chi0_standard.cpp @@ -262,7 +262,7 @@ void Chi0_standard:: Chi() Cal_rpa(iq); Cal_chi(); cout<<"chi iq= "< // Peize Lin fix bug about strcmp 2016-08-02 @@ -318,7 +319,6 @@ void UnitCell_pseudo::read_atom_species(ifstream &ifa) } } -#ifdef __FP if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") { if( SCAN_BEGIN(ifa, "NUMERICAL_ORBITAL") ) @@ -356,7 +356,6 @@ void UnitCell_pseudo::read_atom_species(ifstream &ifa) } } } -#endif //========================== // read in lattice constant From d68ad9601245edc51f9f71bd454dbc02552d5393 Mon Sep 17 00:00:00 2001 From: qianrui Date: Mon, 1 Feb 2021 11:34:10 +0800 Subject: [PATCH 053/233] Modify Makefile --- ABACUS.develop/bin/README | 0 ABACUS.develop/source/Makefile | 38 ++++++++++++++++++++++++----- ABACUS.develop/source/Makefile.vars | 4 +++ ABACUS.develop/source/obj/README | 1 - 4 files changed, 36 insertions(+), 7 deletions(-) delete mode 100644 ABACUS.develop/bin/README delete mode 100644 ABACUS.develop/source/obj/README diff --git a/ABACUS.develop/bin/README b/ABACUS.develop/bin/README deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ABACUS.develop/source/Makefile b/ABACUS.develop/source/Makefile index 84cb01a8a7..bedb29ed6f 100644 --- a/ABACUS.develop/source/Makefile +++ b/ABACUS.develop/source/Makefile @@ -65,19 +65,44 @@ PDIAG_MR=$(patsubst %.o, ${OBJ_DIR}/%.o, ${PDIAG_MR_0}) #========================== # MAKING OPTIONS #========================== -fp_mpi : ${FP_OBJS} ${PDIAG_OBJS} ${PDIAG_MR} ${HEADERS} +fp_mpi : + @ make init + @ make -j $(NP) parallel + +fp : + @ make init + @ make -j $(NP) serial + +fp_gbd : + @ make init + @ make -j $(NP) serial_gbd + +fp_gprof : + @ make init + @ make -j $(NP) serial_gprof + +fp_mem : + @ make init + @ make -j $(NP) serial_mem + +init : + @ if [ ! -d $(OBJ_DIR) ]; then mkdir $(OBJ_DIR); fi + @ if [ ! -d $(OBJ_DIR)/README ]; then echo "This directory contains all of the .o files" > $(OBJ_DIR)/README; fi + @ if [ ! -d ../bin ]; then mkdir ../bin; fi + +parallel : ${FP_OBJS} ${PDIAG_OBJS} ${PDIAG_MR} ${HEADERS} ${CPLUSPLUS_MPI} ${OPTS} ${OPTS_MPI} $(FP_OBJS) ${PDIAG_OBJS} ${PDIAG_MR} ${LIBS} -o ../bin/${VERSION}.mpi -fp : ${FP_OBJS} ${HEADERS} +serial : ${FP_OBJS} ${HEADERS} ${CPLUSPLUS} ${OPTS} $(FP_OBJS) ${LIBS} -o ${VERSION}.fp.x -fp_gdb : ${FP_OBJS} ${HEADERS} +serial_gdb : ${FP_OBJS} ${HEADERS} ${CPLUSPLUS} ${OPTS_GDB} $(FP_OBJS) ${LIBS} -o ${VERSION}.fp_gdb.x -fp_gprof : ${FP_OBJS} ${HEADERS} +serial_gprof : ${FP_OBJS} ${HEADERS} ${CPLUSPLUS} ${OPTS} $(FP_OBJS) ${LIBS} -o ${VERSION}.fp_gprof.x -fp_mem : ${FP_OBJS} ../src_parallel/mcd.o ${HEADERS} +serial_mem : ${FP_OBJS} ../src_parallel/mcd.o ${HEADERS} ${CPLUSPLUS} $(FP_OBJS) ../src_parallel/mcd.o ${LIBS} -o ${VERSION}.fp_mem.x #========================== @@ -90,4 +115,5 @@ ${OBJ_DIR}/%.o:%.f .PHONY:clean clean: - $(RM) ${OBJ_DIR}/*.o ../bin/ABACUS* + @ if [ -d $(OBJ_DIR) ]; then rm -rf $(OBJ_DIR); fi + @ if [ -d ../bin ]; then rm -rf ../bin; fi diff --git a/ABACUS.develop/source/Makefile.vars b/ABACUS.develop/source/Makefile.vars index ab69def452..fcff7e531a 100644 --- a/ABACUS.develop/source/Makefile.vars +++ b/ABACUS.develop/source/Makefile.vars @@ -12,16 +12,20 @@ LAPACK_DIR = $(MKLROOT) #LAPACK_DIR = /public/intel2017/mkl FFTW_DIR = /home/mohan/1_Software/impi_fftw-3.3.8 +#FFTW_DIR = /home/qianrui/intelcompile/impi_fftw #FFTW_DIR = /public/udata/xiaohui/software/fftw2 #FFTW_DIR =/opt/fftw/3.3.6-p12/intel/2017.update4 #FFTW_DIR = /public/fftw-3.3.8 BOOST_DIR = /home/mohan/1_Software/impi_boost-1.70.0 +#BOOST_DIR = /home/qianrui/intelcompile/impi_boost #BOOST_DIR = /public/udata/xiaohui/software/boost_1_39_0 #BOOST_DIR = /opt/boost/1.64.0 ELPA_DIR = /home/mohan/1_Software/impi_elpa-16.05.005 +#ELPA_DIR = /home/qianrui/intelcompile/impi_elpa #ELPA_DIR = /public/udata/xiaohui/ELPA-2016.05.004 #ELPA_DIR = /opt/elpa/intel_2017_update4 OBJ_DIR = obj +NP = 10 diff --git a/ABACUS.develop/source/obj/README b/ABACUS.develop/source/obj/README deleted file mode 100644 index 3f49259cf9..0000000000 --- a/ABACUS.develop/source/obj/README +++ /dev/null @@ -1 +0,0 @@ -This directory contains all of the .o files From 96a770a82c69ecfb80363a0a6584858552ede36b Mon Sep 17 00:00:00 2001 From: mohanchen Date: Mon, 1 Feb 2021 17:15:59 +0800 Subject: [PATCH 054/233] add README in source directory and update some descriptions in files --- ABACUS.develop/source/README | 12 ++++ ABACUS.develop/source/run_frag.cpp | 4 +- ABACUS.develop/source/src_pw/potential.cpp | 14 ++++- ABACUS.develop/source/src_pw/potential.h | 7 ++- ABACUS.develop/source/src_pw/pw_basis.h | 66 +++++++++++++--------- 5 files changed, 69 insertions(+), 34 deletions(-) create mode 100644 ABACUS.develop/source/README diff --git a/ABACUS.develop/source/README b/ABACUS.develop/source/README new file mode 100644 index 0000000000..9055166340 --- /dev/null +++ b/ABACUS.develop/source/README @@ -0,0 +1,12 @@ + +Currently we are working on: +1) fix the parallel bug when using plane wave basis (pw is not enough) +2) SDFT +3) DeepKS + +----------------------------------------------------------------------- + +The code should be reconstructed with the following details: + +1) the TDDFT module should be relocated. +2) the inclusion of files in vdw3 should be changed. diff --git a/ABACUS.develop/source/run_frag.cpp b/ABACUS.develop/source/run_frag.cpp index c66323254c..d0bf68fc60 100644 --- a/ABACUS.develop/source/run_frag.cpp +++ b/ABACUS.develop/source/run_frag.cpp @@ -90,11 +90,11 @@ void Run_Frag::LCAO_line(void) TITLE("Run_Frag","lcao_line"); timer::tick("Run_Frag","LCAO_line",'B'); - // (1) Init the charge density. + // (1) Inititlize the charge density. CHR.init(); DONE(ofs_running,"INIT CHARGE"); - // (2) Init the potential. + // (2) Initializee the potential. pot.init(pw.nrxx); DONE(ofs_running,"INIT POTENTIAL"); diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index ac8175cd57..8851bc58b6 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -208,15 +208,20 @@ void potential::init_pot(const int &istep, const bool delta_vh, const bool vna) //---------------------------------------------------------- // Define the total local potential (external+scf) //---------------------------------------------------------- - if(vext == 0) this->set_vrs(pw.doublegrid); - else this->set_vrs_tddft(pw.doublegrid, istep); + if(vext == 0) + { + this->set_vrs(pw.doublegrid); + } + else + this->set_vrs_tddft(pw.doublegrid, istep); + } //figure::picture(this->vrs1,pw.ncx,pw.ncy,pw.ncz); timer::tick("potential","init_pot"); return; } -// from setlocal.f90 + //========================================================== // This routine computes the local potential in real space // vltot(ir) @@ -227,7 +232,9 @@ void potential::set_local(double* vl_pseudo)const timer::tick("potential","set_local"); complex *vg = new complex[pw.ngmc]; + ZEROS( vg, pw.ngmc ); + for (int it=0; it the coordinates in FFT box - //============================================= - //Part3:Charge & Potential (G vectors,FFT box) - //============================================= + //=============================================== + // Part3: Charge & Potential (G vectors,FFT box) + //=============================================== // G vectors, FFT box related to charge density and potentials etc. - //fft grid for charge density, potentials etc. - //this grid equal to the wave function grid - //when only NCPPs are used - //(doublegrid=.false.) + // fft grid for charge density, potentials etc. + // this grid equal to the wave function grid int nrxx; //for parallel,local FFT grid dimension int nrxx_start; //for parallel,local FFT grid dimension int ngmc; // new, num. of G vectors within ggchg, int ngmc_g; // mohan add 2008-4-2 - // ngmc global (for parrel) int *ig2fftc; //(=*ind_FFT) //1D G vector -> charge/potential FFT //ig2fftc= new int [ngmc] for wave functions //ig2fftc[ng] -> the coordinates in FFT box @@ -109,7 +118,7 @@ class PW_Basis //gg[ng]=ig[ng]*GGT*ig[ng]/(lat0*lat0)=g[ng]*g[ng] (/lat0*lat0) //================== - // void set_nggm() + // void set_nggm() //================== int nggm; // =ngl(another dft code); // number of |G| shells (i.e., how many different |G|s) @@ -123,9 +132,11 @@ class PW_Basis ComplexMatrix eigts1; // ComplexMatrix eigts2; //the phases e^{-iG*tau_s} ComplexMatrix eigts3; // + int *ig1; // int *ig2; // the indices of G components int *ig3; // + double *gg_global0; //LiuXh add 20180515 int *cutgg_num_table; //LiuXh add 20180515 int ggchg_time_global; //LiuXh add 20180515 @@ -133,25 +144,28 @@ class PW_Basis bool doublegrid; // .TRUE. if we use a double grid; (for USPP) // .FALSE., if NCPP. - PW_Basis(); - ~PW_Basis(); - void gen_pw(ofstream &log, const UnitCell &Ucell_in, const kvect &Klist_in); + void setup_structure_factor(); // Calculate structur factors + void update_gvectors(ofstream &log, const UnitCell &Ucell_in); //LiuXh add 20180515 -private: + + private: + void setup_gg(); void setup_FFT_dimension(); // set up FFT dimensions -private: - #ifdef __MPI void divide_fft_grid(); + void get_MPI_GVectors(); + void columns_and_pw_distribution_2(); #else + void get_GVectors(); + #endif void get_nggm(const int ngmc_local); From b2702123d8648dae82e15a53a0e4a9a0679dd3d0 Mon Sep 17 00:00:00 2001 From: mohanchen Date: Tue, 2 Feb 2021 10:21:31 +0800 Subject: [PATCH 055/233] delete some remaining EPM flags --- .../source/src_parallel/parallel_grid.cpp | 11 +++++- .../source/src_parallel/parallel_grid.h | 6 ++- .../source/src_parallel/parallel_pw.cpp | 6 +-- ABACUS.develop/source/src_pw/energy.h | 5 ++- ABACUS.develop/source/src_pw/hamilt_pw.cpp | 38 +------------------ ABACUS.develop/source/src_pw/klist.cpp | 3 +- ABACUS.develop/source/src_pw/pw_basis.cpp | 20 +++++----- ABACUS.develop/source/src_pw/symmetry_rho.cpp | 2 - ABACUS.develop/source/src_pw/unitcell.cpp | 5 +-- 9 files changed, 33 insertions(+), 63 deletions(-) diff --git a/ABACUS.develop/source/src_parallel/parallel_grid.cpp b/ABACUS.develop/source/src_parallel/parallel_grid.cpp index c1513e6873..cc03d6025a 100644 --- a/ABACUS.develop/source/src_parallel/parallel_grid.cpp +++ b/ABACUS.develop/source/src_parallel/parallel_grid.cpp @@ -24,8 +24,15 @@ Parallel_Grid::~Parallel_Grid() } } -void Parallel_Grid::init(const int &ncx_in, const int &ncy_in, const int &ncz_in, const int &nczp_in, -const int &nrxx_in, const int &nbz_in, const int &bz_in) + +void Parallel_Grid::init( + const int &ncx_in, + const int &ncy_in, + const int &ncz_in, + const int &nczp_in, + const int &nrxx_in, + const int &nbz_in, + const int &bz_in) { #ifndef __MPI diff --git a/ABACUS.develop/source/src_parallel/parallel_grid.h b/ABACUS.develop/source/src_parallel/parallel_grid.h index d88e524b47..26b23e580c 100644 --- a/ABACUS.develop/source/src_parallel/parallel_grid.h +++ b/ABACUS.develop/source/src_parallel/parallel_grid.h @@ -13,7 +13,9 @@ class Parallel_Grid ~Parallel_Grid(); void init(const int &ncx, const int &ncy, const int &ncz, const int &nczp, const int &nrxx, const int &nbz, const int &bz); -void init_final_scf(const int &ncx, const int &ncy, const int &ncz, const int &nczp, const int &nrxx, const int &nbz, const int &bz); //LiuXh add 20180606 + + void init_final_scf(const int &ncx, const int &ncy, const int &ncz, + const int &nczp, const int &nrxx, const int &nbz, const int &bz); //LiuXh add 20180606 #ifdef __MPI void zpiece_to_all(double *zpiece, const int &iz, double *rho); @@ -37,7 +39,7 @@ void init_final_scf(const int &ncx, const int &ncy, const int &ncz, const int &n int ncz; int ncxy; int ncxyz; - int nczp; // different processor has different value. + int nczp; // different processors have different values. int nrxx; int nbz; int bz; diff --git a/ABACUS.develop/source/src_parallel/parallel_pw.cpp b/ABACUS.develop/source/src_parallel/parallel_pw.cpp index 45409e71cf..c77c903bfd 100644 --- a/ABACUS.develop/source/src_parallel/parallel_pw.cpp +++ b/ABACUS.develop/source/src_parallel/parallel_pw.cpp @@ -95,9 +95,9 @@ void Parallel_PW::init(const double &gcut_in, const int &n1_in, const int &n2_in } } -delete[] this->ngm_i_number; -this->ngm_i_number = new int[10]; -ZEROS(ngm_i_number, 10); + delete[] this->ngm_i_number; + this->ngm_i_number = new int[10]; + ZEROS(ngm_i_number, 10); return; } diff --git a/ABACUS.develop/source/src_pw/energy.h b/ABACUS.develop/source/src_pw/energy.h index 73d768583b..7a086538c4 100644 --- a/ABACUS.develop/source/src_pw/energy.h +++ b/ABACUS.develop/source/src_pw/energy.h @@ -80,11 +80,12 @@ class energy void print_format(const string &name, const double &value); -#ifndef __EPM void calculate_harris(const int &flag); //mohan add 2012-06-05 + double delta_e(void); + void delta_escf(void); -#endif + void rgen( const Vector3 &dtau, const double &rmax, diff --git a/ABACUS.develop/source/src_pw/hamilt_pw.cpp b/ABACUS.develop/source/src_pw/hamilt_pw.cpp index 8773bad142..66a8439bd6 100644 --- a/ABACUS.develop/source/src_pw/hamilt_pw.cpp +++ b/ABACUS.develop/source/src_pw/hamilt_pw.cpp @@ -6,10 +6,6 @@ #include "src_global/blas_connector.h" #include "optical.h" // only get judgement to calculate optical matrix or not. -#ifdef __EPM -#include "../src_epm/nscf_epm.h" -#endif - int Hamilt_PW::moved = 0; Hamilt_PW::Hamilt_PW() @@ -34,31 +30,7 @@ Hamilt_PW::~Hamilt_PW() delete[] Ps; } -#ifdef __EPM -void Hamilt_PW::init() -{ - TITLE("Hamilt_PW","init"); - const int nrxxs = pw.nrxxs; - - delete[] hpsi; - delete[] spsi; - delete[] GR_index; - - this->hpsi = new complex[wf.npwx]; - this->spsi = new complex[wf.npwx]; - this->GR_index = new int[nrxxs]; - - OUT(ofs_running,"hpsi allocation = ","Done"); - OUT(ofs_running,"spsi allocation = ","Done"); - OUT(ofs_running,"GR_index allocation = ","Done"); - - ZEROS(hpsi,wf.npwx); - ZEROS(spsi,wf.npwx); - ZEROS(GR_index,wf.npwx); - return; -} -#else void Hamilt_PW::init(void) { if (test_hm) TITLE("Hamilt_PW","init"); @@ -81,7 +53,7 @@ void Hamilt_PW::init(void) // ofs_running << "\n Hamiltonian allocate done."< *psi, complex *hpsi, complex < double> *spsi) { -#ifdef __EPM - nscf_epm::hpsi(psi, hpsi); -#else this->h_psi(psi, hpsi); -#endif for (int i=0;i *psi_in, complex *hpsi) { timer::tick("Hamilt_PW","h_psi",'H'); @@ -520,9 +487,7 @@ void Hamilt_PW::h_psi(const complex *psi_in, complex *hpsi) timer::tick("Hamilt_PW","h_psi",'H'); return; } -#endif -#ifndef __EPM void Hamilt_PW::add_vuspsi(complex *hpsi_in,const complex *becp) { timer::tick("Hamilt_PW","add_vuspsi",'I'); @@ -606,7 +571,6 @@ void Hamilt_PW::add_vuspsi(complex *hpsi_in,const complex *becp) timer::tick("Hamilt_PW","add_vuspsi",'I'); return; } -#endif void Hamilt_PW::diag_zheev(const int &npw_in, ComplexMatrix &psi, const int &nband, double *em, double *err) { diff --git a/ABACUS.develop/source/src_pw/klist.cpp b/ABACUS.develop/source/src_pw/klist.cpp index b73986de25..308a060c35 100644 --- a/ABACUS.develop/source/src_pw/klist.cpp +++ b/ABACUS.develop/source/src_pw/klist.cpp @@ -122,9 +122,8 @@ void kvect::set( // It's very important in parallel case, // firstly do the mpi_k() and then // do set_kup_and_kdw() -#ifndef __EPM Pkpoints.kinfo(nkstot); -#endif + this->mpi_k();//2008-4-29 this->set_kup_and_kdw(); diff --git a/ABACUS.develop/source/src_pw/pw_basis.cpp b/ABACUS.develop/source/src_pw/pw_basis.cpp index f282b7aef7..259a0c0555 100644 --- a/ABACUS.develop/source/src_pw/pw_basis.cpp +++ b/ABACUS.develop/source/src_pw/pw_basis.cpp @@ -181,8 +181,6 @@ void PW_Basis::gen_pw(ofstream &runlog, const UnitCell &Ucell_in, const kvect &K //{ // ofs_running << " Turn on the cutgg function." << endl; //} - - #else // mohan update 2011-09-21 this->nbzp=nbz; //nbz shoud equal nz for single proc. @@ -358,11 +356,7 @@ void PW_Basis::gen_pw(ofstream &runlog, const UnitCell &Ucell_in, const kvect &K this->get_nggm(this->ngmc); -#ifdef __EPM // needs in EPM because spin-orbital must use it. - if (EPM_SPIN_ORBITAL) this->setup_structure_factor(); -#else this->setup_structure_factor(); -#endif // this->printPW("src_check/check_pw.txt"); timer::tick("PW_Basis","gen_pw",'B'); @@ -480,19 +474,26 @@ void PW_Basis::setup_FFT_dimension(void) return; } -#ifdef __MPI +#ifdef __MPI +// FUNCTION: +// set nbzp: how many planes in this processor +// set nczp +// set nbxx +// set nrxx +// set nrxxs void PW_Basis::divide_fft_grid(void) { TITLE("PW_Basis","divide_fft_grid"); + //---------------------------------------------- // set charge/potential grid : nrxx // and smooth grid : nrxxs - // nczp: how many planes in this process. //---------------------------------------------- const int remain_planes = this->nbz%NPROC_IN_POOL; this->nbzp = this->nbz/NPROC_IN_POOL; - if (RANK_IN_POOL < remain_planes) + + if (RANK_IN_POOL < remain_planes) { nbzp++; } @@ -502,6 +503,7 @@ void PW_Basis::divide_fft_grid(void) this->nbxx = nbzp*this->nbx*this->nby; this->nrxx = nczp*this->ncx*this->ncy; this->nrxxs = this->nrxx; + //===================================== // set nrxx_start //===================================== diff --git a/ABACUS.develop/source/src_pw/symmetry_rho.cpp b/ABACUS.develop/source/src_pw/symmetry_rho.cpp index d83498df75..cd86e17a94 100644 --- a/ABACUS.develop/source/src_pw/symmetry_rho.cpp +++ b/ABACUS.develop/source/src_pw/symmetry_rho.cpp @@ -20,10 +20,8 @@ void Symmetry_rho::begin(const int &spin_now) const // parallel version psymm(CHR.rho[spin_now]); #else -#ifndef __EPM // series version. symm.rho_symmetry(CHR.rho[spin_now], pw.ncx, pw.ncy, pw.ncz); -#endif #endif return; } diff --git a/ABACUS.develop/source/src_pw/unitcell.cpp b/ABACUS.develop/source/src_pw/unitcell.cpp index 76f6473422..4db8a001c5 100644 --- a/ABACUS.develop/source/src_pw/unitcell.cpp +++ b/ABACUS.develop/source/src_pw/unitcell.cpp @@ -47,11 +47,9 @@ UnitCell::UnitCell() UnitCell::~UnitCell() { -#ifndef __EPM delete[] atom_label; delete[] atom_mass; delete[] pseudo_fn; -#endif delete[] iat2it; delete[] iat2ia; delete[] iwt2iat; @@ -113,9 +111,8 @@ void UnitCell::bcast_unitcell(void) Parallel_Common::bcast_double( latvec_supercell.e32 ); Parallel_Common::bcast_double( latvec_supercell.e33 ); -#ifndef __EPM Parallel_Common::bcast_double( mag.start_magnetization, ntype ); -#endif + if(NSPIN != 1) for(int it = 0;it Date: Tue, 2 Feb 2021 11:22:49 +0800 Subject: [PATCH 056/233] delete nrxxs parameter in pw_basis.h, this variable is uselss in my opinion, it is associated with USPP but we don't have plan to implement it in near future --- ABACUS.develop/source/src_lcao/build_st_pw.cpp | 6 +++--- ABACUS.develop/source/src_pw/hamilt_pw.cpp | 12 ++++++------ ABACUS.develop/source/src_pw/potential.cpp | 1 + ABACUS.develop/source/src_pw/pseudo_nc.h | 4 +++- ABACUS.develop/source/src_pw/pw_basis.cpp | 11 +++-------- ABACUS.develop/source/src_pw/pw_basis.h | 1 - 6 files changed, 16 insertions(+), 19 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/build_st_pw.cpp b/ABACUS.develop/source/src_lcao/build_st_pw.cpp index be4bd22f59..3a0dbbbb1d 100644 --- a/ABACUS.develop/source/src_lcao/build_st_pw.cpp +++ b/ABACUS.develop/source/src_lcao/build_st_pw.cpp @@ -138,7 +138,7 @@ void Build_ST_pw::set_local(const int &ik) psi_one[ig] = wf.wanf2[ik](i, ig); } - ZEROS( psic, pw.nrxxs); + ZEROS( psic, pw.nrxx); // (1) set value for (int ig=0; ig< npw; ig++) { @@ -189,8 +189,8 @@ void Build_ST_pw::set_local(const int &ik) psi_down[ig] = wf.wanf2[ik](i, ig+ wf.npwx); } - ZEROS( psic, pw.nrxxs); - ZEROS( psic1, pw.nrxxs); + ZEROS( psic, pw.nrxx); + ZEROS( psic1, pw.nrxx); // (1) set value for (int ig=0; ig< npw; ig++) { diff --git a/ABACUS.develop/source/src_pw/hamilt_pw.cpp b/ABACUS.develop/source/src_pw/hamilt_pw.cpp index 66a8439bd6..b938e6be70 100644 --- a/ABACUS.develop/source/src_pw/hamilt_pw.cpp +++ b/ABACUS.develop/source/src_pw/hamilt_pw.cpp @@ -43,13 +43,13 @@ void Hamilt_PW::init(void) this->hpsi = new complex [wf.npwx * NPOL]; this->spsi = new complex [wf.npwx * NPOL]; - this->GR_index = new int[pw.nrxxs]; + this->GR_index = new int[pw.nrxx]; this->Bec = new complex [ppcell.nkb]; this->Ps = new complex [ppcell.nkb * NPOL]; ZEROS(this->hpsi,wf.npwx * NPOL); ZEROS(this->spsi,wf.npwx * NPOL); - ZEROS(this->GR_index, pw.nrxxs); + ZEROS(this->GR_index, pw.nrxx); // ofs_running << "\n Hamiltonian allocate done."< *psi_in, complex *hpsi) if(VL_IN_H) { if(NSPIN!=4){ - ZEROS( UFFT.porter, pw.nrxxs); + ZEROS( UFFT.porter, pw.nrxx); UFFT.RoundTrip( psi_in, pot.vrs1, GR_index, UFFT.porter ); for (j = 0;j < wf.npw;j++) @@ -418,9 +418,9 @@ void Hamilt_PW::h_psi(const complex *psi_in, complex *hpsi) } else { - complex* porter1 = new complex[pw.nrxxs]; - ZEROS( UFFT.porter, pw.nrxxs); - ZEROS( porter1, pw.nrxxs); + complex* porter1 = new complex[pw.nrxx]; + ZEROS( UFFT.porter, pw.nrxx); + ZEROS( porter1, pw.nrxx); for (int ig=0; ig< wf.npw; ig++) { UFFT.porter[ GR_index[ig] ] = psi_in[ig]; diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index 8851bc58b6..6e7b714b79 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -213,6 +213,7 @@ void potential::init_pot(const int &istep, const bool delta_vh, const bool vna) this->set_vrs(pw.doublegrid); } else + { this->set_vrs_tddft(pw.doublegrid, istep); } diff --git a/ABACUS.develop/source/src_pw/pseudo_nc.h b/ABACUS.develop/source/src_pw/pseudo_nc.h index 851175a902..99ee5b104b 100644 --- a/ABACUS.develop/source/src_pw/pseudo_nc.h +++ b/ABACUS.develop/source/src_pw/pseudo_nc.h @@ -18,7 +18,9 @@ class pseudo_nc: public pseudo_vl { -public: + + public: + // int *lll; // lll(nbeta), angular momentum of the beta function int kkbeta; // kkbeta(nbeta), point where the beta are zero diff --git a/ABACUS.develop/source/src_pw/pw_basis.cpp b/ABACUS.develop/source/src_pw/pw_basis.cpp index 259a0c0555..3f4a4b15de 100644 --- a/ABACUS.develop/source/src_pw/pw_basis.cpp +++ b/ABACUS.develop/source/src_pw/pw_basis.cpp @@ -308,10 +308,10 @@ void PW_Basis::gen_pw(ofstream &runlog, const UnitCell &Ucell_in, const kvect &K #ifdef __MPI this->get_MPI_GVectors(); - //cout<<" UNIFORM GRID DIM : "<nx <<" * "<ny <<" * "<nz << "," << this->nrxxs << endl; + //cout<<" UNIFORM GRID DIM : "<nx <<" * "<ny <<" * "<nz << "," << this->nrxx << endl; //cout<<" UNIFORM GRID DIM : "<ncx<<" * "<ncy<<" * "<ncz << "," << this->nrxx << endl; - FFT_wfc.setup_MPI_FFT3D(this->nx, this->ny, this->nz,this->nrxxs,1); + FFT_wfc.setup_MPI_FFT3D(this->nx, this->ny, this->nz,this->nrxx,1); FFT_chg.setup_MPI_FFT3D(this->ncx, this->ncy, this->ncz,this->nrxx,1); #endif } @@ -343,7 +343,7 @@ void PW_Basis::gen_pw(ofstream &runlog, const UnitCell &Ucell_in, const kvect &K this->get_MPI_GVectors(); - FFT_wfc.setup_MPI_FFT3D(this->nx, this->ny, this->nz,this->nrxxs,1); + FFT_wfc.setup_MPI_FFT3D(this->nx, this->ny, this->nz,this->nrxx,1); FFT_chg.setup_MPI_FFT3D(this->ncx, this->ncy, this->ncz,this->nrxx,1); #else this->get_GVectors(); @@ -481,14 +481,12 @@ void PW_Basis::setup_FFT_dimension(void) // set nczp // set nbxx // set nrxx -// set nrxxs void PW_Basis::divide_fft_grid(void) { TITLE("PW_Basis","divide_fft_grid"); //---------------------------------------------- // set charge/potential grid : nrxx - // and smooth grid : nrxxs //---------------------------------------------- const int remain_planes = this->nbz%NPROC_IN_POOL; this->nbzp = this->nbz/NPROC_IN_POOL; @@ -502,7 +500,6 @@ void PW_Basis::divide_fft_grid(void) this->nbxx = nbzp*this->nbx*this->nby; this->nrxx = nczp*this->ncx*this->ncy; - this->nrxxs = this->nrxx; //===================================== // set nrxx_start @@ -527,7 +524,6 @@ void PW_Basis::divide_fft_grid(void) if(test_pw)OUT(ofs_running,"nbzp_start",nbzp); OUT(ofs_running,"nbxx",nbxx); OUT(ofs_running,"nrxx",nrxx); - if(test_pw)OUT(ofs_running,"nrxxs",nrxxs); if(test_pw)OUT(ofs_running,"nrxx_start",nrxx_start); if(test_pw)OUT(ofs_running,"nbxx_start",nbxx_start); @@ -629,7 +625,6 @@ void PW_Basis::get_GVectors(void) timer::tick("PW_Basis","get_GVectors"); this->nrxx = this->ncxyz; - this->nrxxs = this->nxyz; this->ngmc=this->ngmc_g; //************************************************************ diff --git a/ABACUS.develop/source/src_pw/pw_basis.h b/ABACUS.develop/source/src_pw/pw_basis.h index ac5c8d3df5..4fa4c788cf 100644 --- a/ABACUS.develop/source/src_pw/pw_basis.h +++ b/ABACUS.develop/source/src_pw/pw_basis.h @@ -80,7 +80,6 @@ class PW_Basis //========================================= // Part2: Wave function(G vectors,FFT box) //========================================= - int nrxxs; int ngmw; //(= ngmax) / num. of G vectors within ggfft /*** mohan add 2008-3-25 ***/ int *ig2fftw; //(=*ind_FFT) /1D G vector -> for wave function FFT From fb483bfc2f6e44603b2c642b27463c885ae64902 Mon Sep 17 00:00:00 2001 From: mohanchen Date: Tue, 2 Feb 2021 13:27:04 +0800 Subject: [PATCH 057/233] move initialization after variable cell to src_ion/variable_cell.h and src_ion/variable_cell.cpp --- ABACUS.develop/source/Makefile.Objects | 1 + ABACUS.develop/source/run_frag.cpp | 167 ---------------- ABACUS.develop/source/run_frag.h | 6 - .../source/src_ions/variable_cell.cpp | 184 ++++++++++++++++++ .../source/src_ions/variable_cell.h | 27 +++ .../source/src_lcao/local_orbital_ions.cpp | 9 +- ABACUS.develop/source/src_pw/ions.cpp | 5 +- 7 files changed, 220 insertions(+), 179 deletions(-) create mode 100644 ABACUS.develop/source/src_ions/variable_cell.cpp create mode 100644 ABACUS.develop/source/src_ions/variable_cell.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index bdce423f44..4047c005fc 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -218,6 +218,7 @@ update_input.o \ lattice_change_methods.o \ lattice_change_cg.o \ lattice_change_basic.o \ +variable_cell.o\ dftu.o\ lscc.o\ diff --git a/ABACUS.develop/source/run_frag.cpp b/ABACUS.develop/source/run_frag.cpp index d0bf68fc60..adcfcc0b97 100644 --- a/ABACUS.develop/source/run_frag.cpp +++ b/ABACUS.develop/source/run_frag.cpp @@ -362,170 +362,3 @@ void Run_Frag::linear_scaling_line(void) return; } - - -//LiuXh add a new function here, -//which is used to do initialization after variable cell -//20180515 -void Run_Frag::init_after_vc(void) -{ - TITLE("Run_Frag","init_after_vc"); - - ucell.setup_cell_after_vc(global_pseudo_dir, global_atom_card, ofs_running); - DONE(ofs_running, "SETUP UNITCELL"); - - if(SYMMETRY) - { - symm.analy_sys(); - DONE(ofs_running, "SYMMETRY"); - } - - kv.set_after_vc(symm, global_kpoint_card, NSPIN, ucell.G, ucell.latvec); - DONE(ofs_running, "INIT K-POINTS"); - - pw.update_gvectors(ofs_running, ucell); - - pw.setup_structure_factor(); - - if(BASIS_TYPE=="pw") - { - wf.init_after_vc(kv.nks); - wf.init_at_1(); - } - - ofs_running << " Setup the Vl+Vh+Vxc according to new structure factor and new charge." << endl; - //================================= - // initalize local pseudopotential - //================================= - ppcell.init_vloc(); - DONE(ofs_running,"LOCAL POTENTIAL"); - - //====================================== - // Initalize non local pseudopotential - //====================================== - if(BASIS_TYPE=="pw") - { - ppcell.init_vnl(); - DONE(ofs_running,"NON-LOCAL POTENTIAL"); - } - -/* - pot.init_pot(0); - - ofs_running << " Setup the new wave functions?" << endl; - wf.wfcinit(); -*/ - - return; -} - - -//LiuXh add a new function here, -//which is used to do initialization after variable cell -//20180619 -void Run_Frag::final_calculation_after_vc(void) -{ - //cout<<" -------------------------------------------"< Date: Tue, 2 Feb 2021 13:34:35 +0800 Subject: [PATCH 058/233] delete EPM related parameters in input.h and input.cpp --- ABACUS.develop/source/input.cpp | 28 ---------------------------- ABACUS.develop/source/input.h | 31 +++++++++++++------------------ 2 files changed, 13 insertions(+), 46 deletions(-) diff --git a/ABACUS.develop/source/input.cpp b/ABACUS.develop/source/input.cpp index 22685a7b43..463a9fa257 100644 --- a/ABACUS.develop/source/input.cpp +++ b/ABACUS.develop/source/input.cpp @@ -145,7 +145,6 @@ void Input::Default(void) pseudo_dir = ""; pseudo_type = "auto"; // mohan add 2013-05-20 (xiaohui add 2013-06-23) wannier_card = ""; - epm_pseudo_card = ""; latname = "test"; //xiaohui modify 2015-09-15, relax -> scf //calculation = "relax"; @@ -154,7 +153,6 @@ void Input::Default(void) nbands = 0; nbands_istate = 5; npool = 1; - epm_spin_orbital = 0; berry_phase = false; gdir = 3; towannier90 = false; @@ -564,10 +562,6 @@ bool Input::Read(const string &fn) { read_value(ifs, wannier_card); } - else if (strcmp("epm_pseudo_card",word) == 0 ) - { - read_value(ifs, epm_pseudo_card); - } else if (strcmp("latname", word) == 0)// which material { read_value(ifs, latname); @@ -592,26 +586,6 @@ bool Input::Read(const string &fn) { read_value(ifs, npool); } - else if (strcmp("epm_spin_orbital", word) == 0) - { - read_value(ifs, epm_spin_orbital); - } - else if (strcmp("epm_zeeman", word) == 0) - { - read_value(ifs, epm_zeeman); - } - else if (strcmp("epm_mag_field_x", word) == 0) - { - read_value(ifs, epm_mag_field_x); - } - else if (strcmp("epm_mag_field_y", word) == 0) - { - read_value(ifs, epm_mag_field_y); - } - else if (strcmp("epm_mag_field_z", word) == 0) - { - read_value(ifs, epm_mag_field_z); - } else if (strcmp("berry_phase", word) == 0)// berry phase calculation { read_value(ifs, berry_phase); @@ -1927,14 +1901,12 @@ void Input::Bcast() Parallel_Common::bcast_string( pseudo_type ); // mohan add 2013-05-20 (xiaohui add 2013-06-23) Parallel_Common::bcast_string( kpoint_file );//xiaohui modify 2015-02-01 Parallel_Common::bcast_string( wannier_card ); - Parallel_Common::bcast_string( epm_pseudo_card ); Parallel_Common::bcast_string( latname ); Parallel_Common::bcast_string( calculation ); Parallel_Common::bcast_int( ntype ); Parallel_Common::bcast_int( nbands ); Parallel_Common::bcast_int( nbands_istate ); Parallel_Common::bcast_int( npool ); - Parallel_Common::bcast_int( epm_spin_orbital ); Parallel_Common::bcast_bool( berry_phase ); Parallel_Common::bcast_int( gdir ); Parallel_Common::bcast_bool(towannier90); diff --git a/ABACUS.develop/source/input.h b/ABACUS.develop/source/input.h index 34c9365c84..0f0633061d 100644 --- a/ABACUS.develop/source/input.h +++ b/ABACUS.develop/source/input.h @@ -8,46 +8,41 @@ #include using namespace std; -//========================================================== -// CLASS : -// NAME : Input(readin "input_parameters" from "in_data" dir) -//========================================================== class Input { -public: + public: Input(); ~Input(); + void Init(const string &fn); + void Print(const string &fn)const; + void close_log(void)const; - int npool; + int npool; // ecch pool is for one k point -//========================================================== -// MEMBER VARIABLES : -// main parameters -//========================================================== string suffix; // suffix of out put dir string atom_file; //xiaohui modify 2015-02-01 string pseudo_dir; // dir of pseudopotential string pseudo_type; // the type of pseudopotential, mohan add 2013-05-20, we can accept - // UPF format (default) and vwr format. (xiaohui add 2013-06-23) + // UPF format (default) and vwr format. (xiaohui add 2013-06-23) + string kpoint_file; //xiaohui modify 2015-02-01 string wannier_card; // input card for wannier functions. - string epm_pseudo_card; // string latname; // lattice name + string calculation; // "scf" : self consistent calculation. - // "nscf" : non-self consistent calculation. + // "nscf" : non-self consistent calculation. + int ntype; // number of atom types + int nbands; // number of bands + int nbands_istate; // number of bands around fermi level for istate calculation. - int epm_spin_orbital; // 0: no so effect; 1: plane wave; 2: small box - bool epm_zeeman; - double epm_mag_field_x; - double epm_mag_field_y; - double epm_mag_field_z; + bool berry_phase; // berry phase calculation int gdir; // berry phase calculation From 8f42aa2a775627c42f27c8f3262ed3e3b2df237a Mon Sep 17 00:00:00 2001 From: mohanchen Date: Tue, 2 Feb 2021 13:44:33 +0800 Subject: [PATCH 059/233] update input.h --- ABACUS.develop/source/README | 6 + ABACUS.develop/source/input.h | 389 ++++++++++++++++++++++++---------- 2 files changed, 288 insertions(+), 107 deletions(-) diff --git a/ABACUS.develop/source/README b/ABACUS.develop/source/README index 9055166340..1277ab2143 100644 --- a/ABACUS.develop/source/README +++ b/ABACUS.develop/source/README @@ -10,3 +10,9 @@ The code should be reconstructed with the following details: 1) the TDDFT module should be relocated. 2) the inclusion of files in vdw3 should be changed. + + +----------------------------------------------------------------------- +Unitesets should include +1) initialization after cell variation +2) diff --git a/ABACUS.develop/source/input.h b/ABACUS.develop/source/input.h index 0f0633061d..588f2f2e6e 100644 --- a/ABACUS.develop/source/input.h +++ b/ABACUS.develop/source/input.h @@ -45,298 +45,461 @@ class Input bool berry_phase; // berry phase calculation + int gdir; // berry phase calculation + bool towannier90; // add by jingan for wannier90 + string NNKP; // add by jingan for wannier90 + string wannier_spin; // add by jingan for wannier90 + int efield; // add electrical field + int edir; + double emaxpos; + double eopreg; + double eamp; + bool opt_epsilon2; // true : calculate the dielectric functions + int opt_nbands; // number of bands for optical transition matrix + bool lda_plus_u; // true : lda plus u calculation + //========================================================== // electrons / spin //========================================================== + string dft_functional; // input DFT functional. + int nspin; // LDA ; LSDA ; non-linear spin + double nelec; // total number of electrons + int lmaxmax; + double tot_magnetization; + //========================================================== // new function //========================================================== - //int local_basis; xiaohui modify 2013-09-01, for structural adjustment // 0:pw 1:lo 2:atomic - //int linear_scaling; xiaohui modify 2013-09-01 // + string basis_type; //xiaohui add 2013-09-01, for structural adjustment + string ks_solver; //xiaohui add 2013-09-01 + bool sparse_matrix; + int atom_distribution; + bool symmetry; // + bool mlwf_flag; + int vna; //control the vna term. + int grid_speed; //1:normal 2:fast, mohan add 2012-03-29 + int force; + bool force_set; + double force_thr; // threshold of force in unit (Ry/Bohr) + double force_thr_ev2; // invalid force threshold, mohan add 2011-04-17 + double stress_thr; // Pengfei Li 2017-11-01 //LiuXh update 20180515 + double press1; + double press2; + double press3; + bool stress; // calculate the stress + string fixed_axes; //which axes are fixed + string ion_dynamics; // methods to move_ion: sd, bfgs, cg... + double cg_threshold; // threshold when cg to bfgs, pengfei add 2011-08-15 + double bfgs_w1; // wolfe condition 1 + double bfgs_w2; // wolfe condition 2 + double trust_radius_max; // trust radius max + double trust_radius_min; // trust radius min + double trust_radius_ini; // initial move -// bool gauss_pao_flag + //========================================================== // planewave //========================================================== - //bool gamma_only; + bool gamma_only; // for plane wave. + bool gamma_only_local; // for local orbitals. + double ecutwfc; // energy cutoff for wavefunctions + double ecutrho; // energy cutoff for charge/potential + int ncx,ncy,ncz; // three dimension of FFT charge/grid + int nx,ny,nz; // three dimension of FFT wavefunc + int bx,by,bz; // big mesh ball. mohan add 2011-04-21 + //========================================================== // technique //========================================================== + //string diago_type; xiaohui modify 2013-09-01 // "cg","davidson","fs" int diago_proc; // the number of procs used to diag. mohan add 2012-01-13 + int diago_cg_maxiter; + int diago_cg_prec; // mohan add 2012-03-31 + int diago_david_ndim; + double ethr; // used in cg method + double fs_ref_energy; // folded-spectrum reference energy + int nb2d; // matrix 2d division. + int nurse; // used for debug. + bool colour; // used for fun. - int t_in_h; // calculate the T or not. + + int t_in_h; // calculate the T or not. + int vl_in_h; // calculate the T or not. + int vnl_in_h; // calculate the T or not. + int zeeman_in_h; // calculate the zeeman energy or not. + int test_force; // test the force. + int test_stress; // test the stress. + //========================================================== // iteration //========================================================== + double dr2; // \sum |rhog_out - rhog_in |^2 + int niter; // number of max elec iter + int nstep; // number of max ionic iter + int out_stru; // outut stru file each ion step + string out_level; // control the output information. + bool out_md_control; // internal parameter , added by zhengdy 2019-04-07 + //========================================================== // occupation //========================================================== + string occupations; // "fixed","smearing","tetrahedra","from_input" + string smearing; // "gaussian", - // "mp","methfessel-paxton" - // "mv","marzari-vanderbilt","cold" - // "fd","fermi-dirac" + // "mp","methfessel-paxton" + // "mv","marzari-vanderbilt","cold" + // "fd","fermi-dirac" double degauss; // + //========================================================== // charge mixing //========================================================== + string mixing_mode; // "plain","broden",... + double mixing_beta; // 0 : no_mixing + int mixing_ndim; // used in Broden method + double mixing_gg0; // used in kerker method. mohan add 2014-09-27 + //========================================================== // potential / charge / wavefunction / energy //========================================================== + string restart_mode; // + string start_wfc; // "file","atomic","random" + string start_pot; // "file","atomic" + string charge_extrap; // xiaohui modify 2015-02-01 + int mem_saver; // 1: save psi when nscf calculation. + int printe; // mohan add 2011-03-16 + int out_charge; // output charge density. + int out_dm; // output density matrix. + int out_potential; // yes or no + bool out_wf; // yes or no + int out_dos; // dos calculation. mohan add 20090909 - int out_band; // band calculation pengfei 2014-10-13 + + int out_band; // band calculation pengfei 2014-10-13 + int out_hs; // output H matrix and S matrix in local basis. + int out_hs2; //LiuXh add 2019-07-16, output H(R) matrix and S(R) matrix in local basis. + int out_r_matrix; // jingan add 2019-8-14, output r(R) matrix. + bool out_lowf; // output the wave functions in local basis. + bool out_alllog; // output all logs. + double dos_emin_ev; + double dos_emax_ev; + double dos_edelta_ev; - double b_coef; // pengfei 2014-10-13 + + double b_coef; // pengfei 2014-10-13 + //========================================================== // parameters about LCAO calculation. // mohan add 2009-11-11 //========================================================== + double lcao_ecut; // ecut of two center integral + double lcao_dk; // delta k used in two center integral + double lcao_dr; // dr used in two center integral + double lcao_rmax; // rmax(a.u.) to make table. + double search_radius; //11.1 + bool search_pbc; // 11.2 // Divide&Conqure int dc_nx; + int dc_ny; + int dc_nz; // selinv method parameter (cooperate with LinLin) int selinv_npole; + double selinv_temp; + double selinv_gap; + double selinv_deltae; + double selinv_mu; + double selinv_threshold; + int selinv_niter; -/* - // md and related parameters. - double md_dt; //dt: time step for MD. - int md_restart; // mohan add: restart from file. - double md_tolv; // tolv: tolerence for velocity scaling. - string md_thermostat; //ionic temperature: various md_thermostat - double md_temp0; // tempw: start temperature. - int md_tstep; // nraise: the temperature will reduce every md_tstep. - double md_delt; // delta_t: the reduce amount of temperature. -*/ - -//md and related parameters(added by zheng da ye) - int md_mdtype; //choose ensemble - double md_tauthermo; - double md_taubaro; - double md_dt; //time step - int md_nresn; //parameter during integrater - int md_nyosh; //parameter during integrater - double md_qmass; //mass of thermostat - double md_tfirst; //temperature begin - double md_tlast; //temperature end - int md_dumpmdfred; //The period to dump MD information for monitoring and restarting MD - string md_mdoutpath; //output path for md + //md and related parameters(added by zheng da ye) + int md_mdtype; //choose ensemble + + double md_tauthermo; + + double md_taubaro; + + double md_dt; //time step + + int md_nresn; //parameter during integrater + + int md_nyosh; //parameter during integrater + + double md_qmass; //mass of thermostat + + double md_tfirst; //temperature begin + + double md_tlast; //temperature end + + int md_dumpmdfred; //The period to dump MD information for monitoring and restarting MD + + string md_mdoutpath; //output path for md + bool md_domsd; //whether compute - bool md_domsdatom; //whether compute msd for each atom - int md_rstmd; //whether restart; - int md_outputstressperiod; //period to output stress - int md_fixtemperature; //period to change temperature - double md_ediff; //parameter for constraining total energy change + + bool md_domsdatom; //whether compute msd for each atom + + int md_rstmd; //whether restart; + + int md_outputstressperiod; //period to output stress + + int md_fixtemperature; //period to change temperature + + double md_ediff; //parameter for constraining total energy change + double md_ediffg; //parameter for constraining max force change - int md_msdstartTime; //choose which step that msd be calculated -//end of zhengdaye's add -/* //========================================================== -// vdwD2 -// Peize Lin add 2014-03-31 -//========================================================== - bool vdwD2; //calculate vdwD2 or not - double vdwD2_scaling; - double vdwD2_d; //damping parameter - string vdwD2_C6_file; - string vdwD2_C6_unit; //"Bohr" or "Angstrom" - string vdwD2_R0_file; - string vdwD2_R0_unit; //"Bohr" or "Angstrom" - string vdwD2_model; //"period" or "radius" - Vector3 vdwD2_period; - double vdwD2_radius; - string vdwD2_radius_unit; //"Bohr" or "Angstrom" */ + + int md_msdstartTime; //choose which step that msd be calculated //========================================================== // vdw //Peize Lin add 2014-03-31, jiyy update 2019-08-01 //========================================================== string vdw_method; //the method of vdw calculation + string vdw_s6; //scale parameter + string vdw_s8; //scale parameter + string vdw_a1; //damping function parameter + string vdw_a2; //damping function parameter + double vdw_d; //damping function parameter d + bool vdw_abc; //third-order term? + string vdw_radius; //cutoff radius for pair interactions + string vdw_radius_unit; //"Bohr" or "Angstrom" + double vdw_cn_thr; //cutoff radius for calculating the coordination number + string vdw_cn_thr_unit; //"Bohr" or "Angstrom" + string vdw_C6_file; + string vdw_C6_unit; //"Bohr" or "Angstrom" + string vdw_R0_file; + string vdw_R0_unit; //"Bohr" or "Angstrom" + string vdw_model; //"period" or "radius" - Vector3 vdw_period; + Vector3 vdw_period; //========================================================== // spectrum // pengfei Li add 2016-11-23 //========================================================== - //bool epsilon; // calculate epsilon or not - string spectral_type; // the type of the calculated spectrum - int spectral_method; // 0: tddft(linear response) - int eels_method; // 0: hilbert_transform method; 1: standard method - int absorption_method; // 0: vasp's method 1: pwscf's method - //int epsilon_choice; // 0: hilbert_transform method; 1: standard method - - string kernel_type; // the kernel type: rpa, tdlda ... - - string system; // bulk or surface - double eta; // unit(Ry) - double domega; // unit(Ry) - int nomega; - int ecut_chi; // the dimension of G - //int oband; // the number of "occupied" bands - double q_start[3]; // the position of the first q point in direct coordinate - double q_direct[3]; // the q direction - //int start_q; // the serial number of the start qpoint - //int interval_q; // the interval of the qpoints - int nq; // the total number of qpoints for calculation - bool out_epsilon; // output epsilon or not - bool out_chi; // output chi or not - bool out_chi0; // output chi0 or not - double fermi_level; // the change the fermi level(Ry) - bool coulomb_cutoff; // turn on or off the Coulomb_cutoff 0/1 - - //bool epsilon0; // calculate the macroscopic dielectric constant or not - //double intersmear; // eta - double intrasmear; // Eta - double shift; - bool metalcalc; // metal or not - double eps_degauss; // degauss - - //int epsilon0_choice; // 0: vasp's method 1: pwscf's method - - bool kmesh_interpolation; // calculting - double qcar[100][3]; // the Cartesian position of q points(unit: 2*PI/lat0) - int ocp; - //int ocp_n; - string ocp_set; - //double ocp_kb[10000]; - int lcao_box[3]; // the scale for searching the existence of the overlap +//bool epsilon; // calculate epsilon or not + + string spectral_type; // the type of the calculated spectrum + + int spectral_method; // 0: tddft(linear response) + + int eels_method; // 0: hilbert_transform method; 1: standard method + + int absorption_method; // 0: vasp's method 1: pwscf's method + + //int epsilon_choice; // 0: hilbert_transform method; 1: standard method + + string kernel_type; // the kernel type: rpa, tdlda ... + + string system; // bulk or surface + + double eta; // unit(Ry) + + double domega; // unit(Ry) + + int nomega; + + int ecut_chi; // the dimension of G + + //int oband; // the number of "occupied" bands + + double q_start[3]; // the position of the first q point in direct coordinate + + double q_direct[3]; // the q direction + + //int start_q; // the serial number of the start qpoint + + //int interval_q; // the interval of the qpoints + + int nq; // the total number of qpoints for calculation + + bool out_epsilon; // output epsilon or not + + bool out_chi; // output chi or not + + bool out_chi0; // output chi0 or not + + double fermi_level; // the change the fermi level(Ry) + + bool coulomb_cutoff; // turn on or off the Coulomb_cutoff 0/1 + + //bool epsilon0; // calculate the macroscopic dielectric constant or not + //double intersmear; // eta + + double intrasmear; // Eta + + double shift; + + bool metalcalc; // metal or not + + double eps_degauss; // degauss + + //int epsilon0_choice; // 0: vasp's method 1: pwscf's method + + bool kmesh_interpolation; // calculting + + double qcar[100][3]; // the Cartesian position of q points(unit: 2*PI/lat0) + + int ocp; + + //int ocp_n; + string ocp_set; + + //double ocp_kb[10000]; + int lcao_box[3]; // the scale for searching the existence of the overlap + int mulliken;//qifeng add 2019-9-10 //added by zhengdy-soc + bool noncolin; + bool lspinorb; -// bool starting_spin_angle; + + // bool starting_spin_angle; double *angle1; + double *angle2; - + //========================================================== // tddft // Fuxiang He add 2016-10-26 //========================================================== int tddft; //calculate tddft or not + double td_dr2; //threshold for electronic iteration of tddft + double td_dt; //"fs" + double td_force_dt; //"fs" + int val_elec_01; //valence electron 01 + int val_elec_02; //valence electron 02 + int val_elec_03; //valence electron 03 + int vext; //add extern potential or not + int vext_dire; //vext direction //========================================================== @@ -344,8 +507,8 @@ class Input // Peize Lin add 2020-04-04 //========================================================== bool restart_save; - bool restart_load; + bool restart_load; //xiaohui add 2015-09-16 bool input_error; @@ -366,24 +529,34 @@ class Input //========================================================== // DFT+U Xin Qu added on 2020-10-29 //========================================================== + bool dft_plus_u; //true:DFT+U correction; false:standard DFT calcullation(default) + int *orbital_corr; // which correlated orbitals need corrected ; d:2 ,f:3, do not need correction:-1 + double *hubbard_u; //Hubbard Coulomb interaction parameter U(ev) + double *hund_j; //Hund exchange parameter J(ev) + bool omc; //whether turn on occupation matrix control method or not + bool yukawa_potential; //default:false + double yukawa_lambda; //default:0.0 + //The two parameters below are not usable currently + int dftu_type; //1:rotationally invarient formalism; 2:simplified form(default) - int double_counting; // 1:FLL(fully localized limit)(default); 2:AMF(around mean field) + int double_counting; // 1:FLL(fully localized limit)(default); 2:AMF(around mean field) // for deepks int out_descriptor; // output descritpor for deepks. caoyu added 2020-11-24, mohan modified 2021-01-03 - int lmax_descriptor; // lmax used in descriptor, mohan added 2021-01-03 + int lmax_descriptor; // lmax used in descriptor, mohan added 2021-01-03 private: + //========================================================== // MEMBER FUNCTIONS : // NAME : Read() @@ -393,19 +566,21 @@ class Input // from first cpu, and distribute the data to the // other processors) //========================================================== + bool Read(const string &fn); + void Default(void); + void Default_2(void); //jiyy add 2019-08-04 + void Check(void); + #ifdef __MPI void Bcast(void); #endif public: -//========================================================== -// MEMBER FUNCTION : -// NAME : read_value(a module used to read in datas) -//========================================================== + template static void read_value(ifstream &ifs, T &var) { From 4524c61b57dbaea3d6350f12adc56b2e79d539f3 Mon Sep 17 00:00:00 2001 From: mohanchen Date: Tue, 2 Feb 2021 14:07:10 +0800 Subject: [PATCH 060/233] divide run_frag into run_pw, run_lcao, and run_linearscaling --- ABACUS.develop/source/Makefile.Objects | 4 +- ABACUS.develop/source/dc_driv.cpp | 81 +++- ABACUS.develop/source/dc_driv.h | 2 + ABACUS.develop/source/run_frag.cpp | 364 ------------------ ABACUS.develop/source/run_lcao.cpp | 81 ++++ ABACUS.develop/source/run_lcao.h | 24 ++ ABACUS.develop/source/run_linearscaling.cpp | 71 ++++ .../{run_frag.h => run_linearscaling.h} | 20 +- ABACUS.develop/source/run_pw.cpp | 164 ++++++++ ABACUS.develop/source/run_pw.h | 24 ++ ABACUS.develop/source/src_pw/global.h | 2 +- 11 files changed, 451 insertions(+), 386 deletions(-) delete mode 100644 ABACUS.develop/source/run_frag.cpp create mode 100644 ABACUS.develop/source/run_lcao.cpp create mode 100644 ABACUS.develop/source/run_lcao.h create mode 100644 ABACUS.develop/source/run_linearscaling.cpp rename ABACUS.develop/source/{run_frag.h => run_linearscaling.h} (51%) create mode 100644 ABACUS.develop/source/run_pw.cpp create mode 100644 ABACUS.develop/source/run_pw.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 4047c005fc..75de4c67b3 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -29,7 +29,9 @@ cg_precon.o\ OBJS_DC=dc_driv.o\ input.o \ input_conv.o\ -run_frag.o\ +run_pw.o\ +run_lcao.o\ +run_linearscaling.o\ OBJS_PW_BASIC=functional.o \ xc_functional.o\ diff --git a/ABACUS.develop/source/dc_driv.cpp b/ABACUS.develop/source/dc_driv.cpp index 06480ed17a..b342dcc7ae 100644 --- a/ABACUS.develop/source/dc_driv.cpp +++ b/ABACUS.develop/source/dc_driv.cpp @@ -1,5 +1,6 @@ #include "dc_driv.h" -#include "run_frag.h" +#include "run_pw.h" +#include "run_lcao.h" #include "input.h" #include "input_conv.h" #include "src_lcao/global_fp.h" @@ -8,6 +9,7 @@ #include "src_pw/cal_test.h" #include "src_pw/cal_test0.h" +#include "src_pw/winput.h" DC_Driv::DC_Driv(){} @@ -89,7 +91,7 @@ void DC_Driv::reading(void) // * do symmetry analysis // * setup the k-points //---------------------------------- - Run_Frag::init(); + this->prepare(); // for LCAO basis, reading the orbitals and construct @@ -153,16 +155,16 @@ void DC_Driv::atomic_world(void) TITLE("DC_Driv","atomic_world"); timer::tick("DC_Driv","atomic_world",'A'); - Run_Frag RF; - //xiaohui add 2013-09-01 if(BASIS_TYPE=="pw" || BASIS_TYPE=="lcao_in_pw") { - RF.plane_wave_line(); + Run_pw rp; + rp.plane_wave_line(); } else if(BASIS_TYPE=="lcao") { - RF.LCAO_line(); + Run_lcao rl; + rl.lcao_line(); } timer::tick("DC_Driv","atomic_world",'A'); @@ -173,3 +175,70 @@ void DC_Driv::atomic_world(void) return; } + +// * initialize the NPOOL for k-points +// * initialize the input parameters for wannier functions +// * setup the unit cell +// * symmetry analysis +// * setup the k-points according to symmetry annalysis +void DC_Driv::prepare(void) +{ + TITLE("Run_Frag","init"); + timer::tick("Run_Frag","init",'B'); + +#ifdef __MPI + // (1) If k point number > 1, After reading in NPOOL, + // divide the NPROC processprs into NPOOL. + Pkpoints.init(); +#endif + + // (2) Read in parameters about wannier functions. + winput::Init( global_wannier_card ); + + //xiaohui move 3 lines, 2015-09-30 + //stringstream ss2; + //ss2 << global_out_dir << "INPUTw"; + //winput::Print( ss2.str() ); + + // (3) Print the parameters into INPUT file. + stringstream ss1; + ss1 << global_out_dir << global_in_card; + INPUT.Print( ss1.str() ); + //DONE(ofs_running,"READING CARDS"); + + // (4) Setup the unitcell. + ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running); + DONE(ofs_running, "SETUP UNITCELL"); + + // (5) symmetry analysize. + if (SYMMETRY) + { + symm.analy_sys(); + DONE(ofs_running, "SYMMETRY"); + } + + // (6) Setup the k points according to symmetry. + kv.set( symm, global_kpoint_card, NSPIN, ucell.G, ucell.latvec ); + DONE(ofs_running,"INIT K-POINTS"); + + + // (7) check the number of basis, the warning should be moved to + // other places -- mohan 2021-01-30 + // mohan add 2011-01-5 + if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") + { + if( NLOCAL < NBANDS ) + { + WARNING_QUIT("UnitCell_pseudo::cal_nwfc","NLOCAL < NBANDS"); + } + else + { + //OUT(ofs_running,"NLOCAL",NLOCAL); + OUT(ofs_running,"NBASE",NLOCAL); + OUT(ofs_running,"NBANDS",NBANDS); + } + } + + timer::tick("Run_Frag","init",'B'); + return; +} diff --git a/ABACUS.develop/source/dc_driv.h b/ABACUS.develop/source/dc_driv.h index 90d32adf20..2044ffdd69 100644 --- a/ABACUS.develop/source/dc_driv.h +++ b/ABACUS.develop/source/dc_driv.h @@ -19,6 +19,8 @@ class DC_Driv // reading the parameters void reading(); + void prepare(); + // do stuff, have fun! void atomic_world(); diff --git a/ABACUS.develop/source/run_frag.cpp b/ABACUS.develop/source/run_frag.cpp deleted file mode 100644 index adcfcc0b97..0000000000 --- a/ABACUS.develop/source/run_frag.cpp +++ /dev/null @@ -1,364 +0,0 @@ -//========================================================== -// AUTHOR : mohan -// DATE : 2008-11-06 -//========================================================== -#include "run_frag.h" -#include "src_pw/global.h" -#include "input.h" -#include "src_pw/algorithms.h" -#include "src_pw/pseudopot_cell_us.h" -#include "src_pw/optical.h" -#include "src_pw/cal_test.h" -#include "src_lcao/dftu.h" //Quxin add for DFT+U on 20201029 -#include "src_pw/winput.h" -#include "src_lcao/sltk_atom_arrange.h" -#include "src_lcao/local_orbital_ions.h" - -Run_Frag::Run_Frag(){} -Run_Frag::~Run_Frag(){} - -// * initialize the NPOOL for k-points -// * initialize the input parameters for wannier functions -// * setup the unit cell -// * symmetry analysis -// * setup the k-points according to symmetry annalysis -void Run_Frag::init(void) -{ - TITLE("Run_Frag","init"); - timer::tick("Run_Frag","init",'B'); - -#ifdef __MPI - // (1) If k point number > 1, After reading in NPOOL, - // divide the NPROC processprs into NPOOL. - Pkpoints.init(); -#endif - - // (2) Read in parameters about wannier functions. - winput::Init( global_wannier_card ); - - //xiaohui move 3 lines, 2015-09-30 - //stringstream ss2; - //ss2 << global_out_dir << "INPUTw"; - //winput::Print( ss2.str() ); - - // (3) Print the parameters into INPUT file. - stringstream ss1; - ss1 << global_out_dir << global_in_card; - INPUT.Print( ss1.str() ); - //DONE(ofs_running,"READING CARDS"); - - // (4) Setup the unitcell. - ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running); - DONE(ofs_running, "SETUP UNITCELL"); - - // (5) symmetry analysize. - if (SYMMETRY) - { - symm.analy_sys(); - DONE(ofs_running, "SYMMETRY"); - } - - // (6) Setup the k points according to symmetry. - kv.set( symm, global_kpoint_card, NSPIN, ucell.G, ucell.latvec ); - DONE(ofs_running,"INIT K-POINTS"); - - - // (7) check the number of basis, the warning should be moved to - // other places -- mohan 2021-01-30 - // mohan add 2011-01-5 - if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") - { - if( NLOCAL < NBANDS ) - { - WARNING_QUIT("UnitCell_pseudo::cal_nwfc","NLOCAL < NBANDS"); - } - else - { - //OUT(ofs_running,"NLOCAL",NLOCAL); - OUT(ofs_running,"NBASE",NLOCAL); - OUT(ofs_running,"NBANDS",NBANDS); - } - } - - timer::tick("Run_Frag","init",'B'); - return; -} - - -void Run_Frag::LCAO_line(void) -{ - TITLE("Run_Frag","lcao_line"); - timer::tick("Run_Frag","LCAO_line",'B'); - - // (1) Inititlize the charge density. - CHR.init(); - DONE(ofs_running,"INIT CHARGE"); - - // (2) Initializee the potential. - pot.init(pw.nrxx); - DONE(ofs_running,"INIT POTENTIAL"); - - // declration - enum use_wf_coef {SOME_PW, ALL_LO}; - use_wf_coef uoc = ALL_LO; - - switch (uoc) - { - case ALL_LO: - // (4) Init the local wave functions. - wf.init_local(); - // (5) Init the FFT. - UFFT.allocate(); - // (6) Init the hamiltonian. - // first0 stands for nkb, but no used. - // second0 stands for no use hpw.init() - hm.init(0); - // (7) Init the local part of NC pseudopotential. - ppcell.init_vloc(); - // (8) Init the potential. - pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs - break; - case SOME_PW: - wf.init(kv.nks); - UFFT.allocate(); - ppcell.init(ucell.ntype); - hm.init(); - ppcell.init_vloc(); - ppcell.init_vnl(); - pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs - pot.newd();//once - DONE(ofs_running,"INIT POTENTIAL"); - wf.wfcinit(); - DONE(ofs_running,"INIT SOME_PW"); - break; - } - - // Quxin added for DFT+U - if(INPUT.dft_plus_u) - { - dftu.init(); - } - - Local_Orbital_Ions ions; - ions.opt_ions(); - en.perform_dos(); - - timer::tick("Run_Frag","LCAO_line",'B'); - return; -} - - - -void Run_Frag::plane_wave_line(void) -{ - TITLE("Run_Frag","plane_wave_line"); - timer::tick("Run_Frag","plane_wave_line",'B'); - -//---------------------------------------------------------- -// 1 read in initial data: -// a lattice structure:atom_species,atom_positions,lattice vector -// b k_points -// c pseudopotential -// 2 setup planeware basis, FFT,structure factor, ... -// 3 initialize local and nonlocal pseudopotential in G_space -// 4 initialize charge desity and warefunctios in G_space -//---------------------------------------------------------- - - //===================== - // init potential - //===================== - CHR.init(); - pot.init(pw.nrxx); - - //===================== - // init wave functions - //===================== - wf.init(kv.nks); - UFFT.allocate(); - - //======================= - // init pseudopotential - //======================= - ppcell.init(ucell.ntype); - - //===================== - // init hamiltonian - //===================== - hm.init(); -// DONE(ofs_running,"CHARGE, POTENTIAL, WAVE FUNCTINOS ALLOCATION"); - - //================================= - // initalize local pseudopotential - //================================= - ppcell.init_vloc(); - DONE(ofs_running,"LOCAL POTENTIAL"); - - //====================================== - // Initalize non local pseudopotential - //====================================== - ppcell.init_vnl(); - DONE(ofs_running,"NON-LOCAL POTENTIAL"); - - //========================================================= - // calculate the total local pseudopotential in real space - //========================================================= - pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs - - pot.newd();//once - DONE(ofs_running,"INIT POTENTIAL"); - - //================================================== - // create ppcell.tab_at , for trial wave functions. - //================================================== - wf.init_at_1(); - - //================================ - // Initial start wave functions - //================================ - wf.wfcinit(); - - - DONE(ofs_running,"INIT BASIS"); - - // ion optimization begins - // electron density optimization is included in ion optimization - Ions ions; - ions.opt_ions_pw(); - - - // caoyu add 2020-11-24, mohan updat 2021-01-03 - if(BASIS_TYPE=="pw" && INPUT.out_descriptor==1) - { - Numerical_Descriptor nc; - nc.output_descriptor(wf.evc, INPUT.lmax_descriptor); - DONE(ofs_running,"GENERATE DESCRIPTOR FOR DEEPKS"); - } - - - if(BASIS_TYPE=="pw" && winput::out_spillage) //xiaohui add 2013-09-01 - { - //cout << "\n Output Spillage Information : " << endl; - // calculate spillage value. - if ( winput::out_spillage == 3) - { - // control here!! - //LOCAL_BASIS = 0; xiaohui modify 2013-09-01 - BASIS_TYPE="pw"; //xiaohui add 2013-09-01 - //LOCAL_BASIS = 0; - cout << " NLOCAL = " << NLOCAL << endl; - - for (int ik=0; ik Date: Wed, 3 Feb 2021 10:04:47 +0800 Subject: [PATCH 061/233] delete the useless doublegrid variable --- .../source/src_lcao/evolve_lcao_matrix.cpp | 2 +- .../source/src_lcao/local_orbital_elec.cpp | 21 +- ABACUS.develop/source/src_pw/electrons.cpp | 11 +- .../source/src_pw/electrons_stochastic.cpp | 188 ++++++++++-------- .../source/src_pw/electrons_stochastic.h | 9 +- ABACUS.develop/source/src_pw/potential.cpp | 39 +--- ABACUS.develop/source/src_pw/potential.h | 4 +- ABACUS.develop/source/src_pw/pw_basis.cpp | 6 - 8 files changed, 138 insertions(+), 142 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/evolve_lcao_matrix.cpp b/ABACUS.develop/source/src_lcao/evolve_lcao_matrix.cpp index d685060df9..f0bc3c8067 100644 --- a/ABACUS.develop/source/src_lcao/evolve_lcao_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/evolve_lcao_matrix.cpp @@ -25,7 +25,7 @@ void Evolve_LCAO_Matrix::evolve_complex_matrix(const int &ik, complex** this->using_LAPACK_complex(ik, cc, cc_init); #endif */ - this-> using_LAPACK_complex(ik, cc, cc_init); + this->using_LAPACK_complex(ik, cc, cc_init); } else { diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp index 9411b207e4..f5140f074a 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp @@ -210,13 +210,18 @@ void Local_Orbital_Elec::scf(const int &istep) // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pot.v_of_rho(CHR.rho, en.ehart, en.etxc, en.vtxc, pot.vr); en.delta_escf(); - if (vext == 0) pot.set_vrs(pw.doublegrid); - else pot.set_vrs_tddft(pw.doublegrid, istep); + if (vext == 0) + { + pot.set_vrs(); + } + else + { + pot.set_vrs_tddft(istep); + } } } //fuxiang add 2016-11-1 - if(tddft==1 && iter == 1) { this->WFC_init = new complex**[kv.nks]; @@ -448,8 +453,14 @@ void Local_Orbital_Elec::scf(const int &istep) } // (10) add Vloc to Vhxc. - if(vext == 0) pot.set_vrs(pw.doublegrid); - else pot.set_vrs_tddft(pw.doublegrid, istep); + if(vext == 0) + { + pot.set_vrs(); + } + else + { + pot.set_vrs_tddft(istep); + } //time_finish=std::time(NULL); double duration = (double)(clock() - clock_start) / CLOCKS_PER_SEC; diff --git a/ABACUS.develop/source/src_pw/electrons.cpp b/ABACUS.develop/source/src_pw/electrons.cpp index 8d94d96e2e..9ad2c6abe8 100644 --- a/ABACUS.develop/source/src_pw/electrons.cpp +++ b/ABACUS.develop/source/src_pw/electrons.cpp @@ -322,8 +322,15 @@ void Electrons::self_consistent(const int &istep) //DONE(ofs_running,"write wave functions into file WAVEFUNC.dat"); } - if(vext == 0) pot.set_vrs(pw.doublegrid); - else pot.set_vrs_tddft(pw.doublegrid, istep); + if(vext == 0) + { + pot.set_vrs(); + } + else + { + pot.set_vrs_tddft(istep); + } + //pot.set_vrs(pw.doublegrid); //print_eigenvalue(ofs_running); en.calculate_etot(); diff --git a/ABACUS.develop/source/src_pw/electrons_stochastic.cpp b/ABACUS.develop/source/src_pw/electrons_stochastic.cpp index 1286f28c7b..3135f08860 100644 --- a/ABACUS.develop/source/src_pw/electrons_stochastic.cpp +++ b/ABACUS.develop/source/src_pw/electrons_stochastic.cpp @@ -23,8 +23,6 @@ void Electrons_Stochastic::scf_stochastic(const int &istep) set_ethr(); - this->unit = 0; - if(OUT_LEVEL=="ie") { cout << setprecision(12); @@ -62,12 +60,18 @@ void Electrons_Stochastic::scf_stochastic(const int &istep) for (this->iter = 1;iter <= NITER;iter++) { ofs_running - << "\n PW ALGORITHM --------------- ION=" << setw(4) << istep + 1 + << "\n PW-STOCHASTIC ALGO --------- ION=" << setw(4) << istep + 1 << " ELEC=" << setw(4) << iter << "--------------------------------\n"; - if(iter==1) CHR.new_e_iteration = true; - else CHR.new_e_iteration = false; + if(iter==1) + { + CHR.new_e_iteration = true; + } + else + { + CHR.new_e_iteration = false; + } // record the start time. start=std::clock(); @@ -75,8 +79,15 @@ void Electrons_Stochastic::scf_stochastic(const int &istep) //(1) set converged threshold, // automatically updated during self consistency. //this->update_ethr(iter); - if(FINAL_SCF && iter==1) ETHR = 1.0e-2; - else this->update_ethr(iter); + if(FINAL_SCF && iter==1) + { + ETHR = 1.0e-2; + } + else + { + this->update_ethr(iter); + } + if(FINAL_SCF && iter==1) { CHR.irstep=0; @@ -133,53 +144,46 @@ void Electrons_Stochastic::scf_stochastic(const int &istep) en.deband = en.delta_e(); - if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-02 - { - CHR.mix_rho(dr2,0,DRHO2,iter,conv_elec); - } - else - { - // tr2_min used only in first scf iteraton - double diago_error = 0.0; - if(iter==1) + // tr2_min used only in first scf iteraton + double diago_error = 0.0; + if(iter==1) + { + // if 'dr2 < ETHR * nelec' happen, + // in other word, 'dr2 < diago_error' + // we update ETHR. + diago_error = ETHR*std::max(1.0, ucell.nelec); + } + + // if converged is achieved, or the self-consistent error(dr2) + // is samller than the estimated error due to diagonalization(diago_error) + // rhoin and rho are unchanged: + // rhoin contain the input charge density and + // rho contain the output charge density. + // in other cases rhoin contains the mixed charge density + // (the new input density) while rho is unchanged. + CHR.mix_rho(dr2,diago_error,DRHO2,iter,conv_elec); + + // if(MY_RANK==0) + // { + // ofs_mix << setw(5) << iter << setw(20) << dr2 << endl; + // } + + if (iter==1) + { + if (dr2 < diago_error) { - // if 'dr2 < ETHR * nelec' happen, - // in other word, 'dr2 < diago_error' - // we update ETHR. - diago_error = ETHR*std::max(1.0, ucell.nelec); + ofs_running << " Notice: Threshold on eigenvalues was too large.\n"; + + WARNING("scf","Threshold on eigenvalues was too large."); + ofs_running << " dr2=" << dr2 << " < diago_error=" << diago_error << endl; + + // update ETHR. + ofs_running << " Origin ETHR = " << ETHR << endl; + ETHR = dr2 / ucell.nelec; + ofs_running << " New ETHR = " << ETHR << endl; + // goto first_iter_again; } - - // if converged is achieved, or the self-consistent error(dr2) - // is samller than the estimated error due to diagonalization(diago_error) - // rhoin and rho are unchanged: - // rhoin contain the input charge density and - // rho contain the output charge density. - // in other cases rhoin contains the mixed charge density - // (the new input density) while rho is unchanged. - CHR.mix_rho(dr2,diago_error,DRHO2,iter,conv_elec); - -// if(MY_RANK==0) -// { -// ofs_mix << setw(5) << iter << setw(20) << dr2 << endl; -// } - - if (iter==1) - { - if (dr2 < diago_error) - { - ofs_running << " Notice: Threshold on eigenvalues was too large.\n"; - - WARNING("scf","Threshold on eigenvalues was too large."); - ofs_running << " dr2=" << dr2 << " < diago_error=" << diago_error << endl; - - // update ETHR. - ofs_running << " Origin ETHR = " << ETHR << endl; - ETHR = dr2 / ucell.nelec; - ofs_running << " New ETHR = " << ETHR << endl; -// goto first_iter_again; - } - } - } + } if (!conv_elec) { @@ -205,7 +209,7 @@ void Electrons_Stochastic::scf_stochastic(const int &istep) // the new potential V(PL)+V(H)+V(xc) pot.v_of_rho(CHR.rho, en.ehart, en.etxc, en.vtxc, pot.vr); - //cout<<"Exc = "<iter, ik, h_diag, avg_iter_k); + //============================================================ + // diago the hamiltonian!! + // In plane wave method, firstly using cinitcgg to diagnolize, + // then using cg method. + // + // In localized orbital presented in plane wave case, + // only using cinitcgg. + // + // In linear scaling method, using sparse matrix and + // adjacent searching code and cg method to calculate the + // eigenstates. + //============================================================= + double avg_iter_k = 0.0; + hm.diago(istep, this->iter, ik, h_diag, avg_iter_k); - avg_iter += avg_iter_k; + avg_iter += avg_iter_k; - en.print_band(ik); + en.print_band(ik); - clock_t finish=clock(); - const double duration = static_cast(finish - start) / CLOCKS_PER_SEC; + clock_t finish=clock(); + const double duration = static_cast(finish - start) / CLOCKS_PER_SEC; - ofs_running << " " << setw(8) - << ik+1 << setw(15) - << avg_iter_k << setw(15) << duration << endl; + ofs_running << " " << setw(8) + << ik+1 << setw(15) + << avg_iter_k << setw(15) << duration << endl; }//End K Loop if(BASIS_TYPE=="pw") { - // ofs_running << " avg_iteri " << avg_iter << endl; - Parallel_Reduce::reduce_double_allpool(avg_iter); //mohan fix bug 2012-06-05 - // ofs_running << " avg_iter_after " << avg_iter << endl; - avg_iter /= static_cast(kv.nkstot); + // ofs_running << " avg_iteri " << avg_iter << endl; + Parallel_Reduce::reduce_double_allpool(avg_iter); //mohan fix bug 2012-06-05 + // ofs_running << " avg_iter_after " << avg_iter << endl; + avg_iter /= static_cast(kv.nkstot); } + delete [] h_diag; + timer::tick("Elec_Stochastic","c_bands",'E'); + return; } diff --git a/ABACUS.develop/source/src_pw/electrons_stochastic.h b/ABACUS.develop/source/src_pw/electrons_stochastic.h index d62ecba599..df9ede2bcd 100644 --- a/ABACUS.develop/source/src_pw/electrons_stochastic.h +++ b/ABACUS.develop/source/src_pw/electrons_stochastic.h @@ -4,10 +4,14 @@ #include "tools.h" #include "threshold_elec.h" +//---------------------------------------------- +// methods based on stochastic wave functions +//---------------------------------------------- + class Electrons_Stochastic: private Threshold_Elec { -public: + public: // constructor and deconstructor Electrons_Stochastic(); @@ -16,11 +20,10 @@ class Electrons_Stochastic: private Threshold_Elec int iter; static double avg_iter; int test; - int unit; void scf_stochastic(const int &istep); -private: + private: void c_bands(const int &istep); diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index 6e7b714b79..caeabb6f06 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -210,11 +210,11 @@ void potential::init_pot(const int &istep, const bool delta_vh, const bool vna) //---------------------------------------------------------- if(vext == 0) { - this->set_vrs(pw.doublegrid); + this->set_vrs(); } else { - this->set_vrs_tddft(pw.doublegrid, istep); + this->set_vrs_tddft(istep); } //figure::picture(this->vrs1,pw.ncx,pw.ncy,pw.ncz); @@ -868,7 +868,7 @@ const matrix &v, const int &precision, const int &hartree)const // contributions. //========================================================== // from set_vrs.f90 -void potential::set_vrs(const bool doublegrid) +void potential::set_vrs(void) { TITLE("potential","set_vrs"); timer::tick("potential","set_vrs"); @@ -932,21 +932,6 @@ void potential::set_vrs(const bool doublegrid) } */ - //==================================================== - // And interpolate it on the smooth mesh if necessary - //==================================================== - /* - if (doublegrid) - { - double *vrs_1d = new double[pw.nrxx](); - assert(vrs_1d != 0); - dcopy(vrs, is, vrs_1d); - //interpolate (vrs (1, is), vrs (1, is), - 1); - interpolate(vrs_1d, vrs_1d, -1); - //(vrs ( is, 0), vrs ( is, 0), - 1); - delete [] vrs_1d; - } - */ } @@ -1260,7 +1245,7 @@ double potential::vr_ave(const int n,const int size,const double *p) // fuxiang add in 2017-05 //========================================================== -void potential::set_vrs_tddft(const bool doublegrid, const int istep) +void potential::set_vrs_tddft(const int istep) { TITLE("potential","set_vrs_tddft"); timer::tick("potential","set_vrs_tddft"); @@ -1357,22 +1342,6 @@ void potential::set_vrs_tddft(const bool doublegrid, const int istep) delete[] this->vextold; delete[] this->vext; } - - //==================================================== - // And interpolate it on the smooth mesh if necessary - //==================================================== - /* - if (doublegrid) - { - double *vrs_1d = new double[pw.nrxx](); - assert(vrs_1d != 0); - dcopy(vrs, is, vrs_1d); - //interpolate (vrs (1, is), vrs (1, is), - 1); - interpolate(vrs_1d, vrs_1d, -1); - //(vrs ( is, 0), vrs ( is, 0), - 1); - delete [] vrs_1d; - } - */ } diff --git a/ABACUS.develop/source/src_pw/potential.h b/ABACUS.develop/source/src_pw/potential.h index 70eb616340..1ec7f9737a 100644 --- a/ABACUS.develop/source/src_pw/potential.h +++ b/ABACUS.develop/source/src_pw/potential.h @@ -49,10 +49,10 @@ class potential // vrs = vr + vltotK // vr : Hartree potential + V_xc potential . // vltot : From pseudopotential . - void set_vrs(const bool doublegrid); + void set_vrs(void); // I guess this is done by Fuxiang He, -- mohan 2021-02-01 - void set_vrs_tddft(const bool doublegrid, const int istep); + void set_vrs_tddft(const int istep); void print_pot(ofstream &ofs)const; double vr_ave(const int, const int, const double *) ; diff --git a/ABACUS.develop/source/src_pw/pw_basis.cpp b/ABACUS.develop/source/src_pw/pw_basis.cpp index 3f4a4b15de..41b482472d 100644 --- a/ABACUS.develop/source/src_pw/pw_basis.cpp +++ b/ABACUS.develop/source/src_pw/pw_basis.cpp @@ -409,12 +409,6 @@ void PW_Basis::setup_gg(void) OUT(ofs_running,"energy cutoff for wavefunc (unit:Ry)",ecutwfc); - this->doublegrid = false; - if (ggwfc != ggchg) - { - doublegrid = true; - ofs_running << "Double grid is used."< Date: Wed, 3 Feb 2021 10:35:55 +0800 Subject: [PATCH 062/233] delete useless parameters in input --- ABACUS.develop/source/input.cpp | 12 ------ ABACUS.develop/source/input.h | 62 ++++++---------------------- ABACUS.develop/source/input_conv.cpp | 1 - 3 files changed, 13 insertions(+), 62 deletions(-) diff --git a/ABACUS.develop/source/input.cpp b/ABACUS.develop/source/input.cpp index 463a9fa257..bf9e6c8a1a 100644 --- a/ABACUS.develop/source/input.cpp +++ b/ABACUS.develop/source/input.cpp @@ -245,7 +245,6 @@ void Input::Default(void) zeeman_in_h = 1; test_force = 0; test_stress = 0; - fs_ref_energy = 0.0; //---------------------------------------------------------- // iteration //---------------------------------------------------------- @@ -899,15 +898,6 @@ bool Input::Read(const string &fn) { read_value(ifs, test_stress); } - else if (strcmp("fs_ref_energy_ev", word) == 0) - { - read_value(ifs, fs_ref_energy); - fs_ref_energy = fs_ref_energy / Ry_to_eV; - } - else if (strcmp("fs_ref_energy_ry", word) == 0) - { - read_value(ifs, fs_ref_energy); - } //---------------------------------------------------------- // iteration //---------------------------------------------------------- @@ -1995,8 +1985,6 @@ void Input::Bcast() Parallel_Common::bcast_int( test_force ); Parallel_Common::bcast_int( test_stress ); - Parallel_Common::bcast_double( fs_ref_energy ); - Parallel_Common::bcast_double( dr2 ); Parallel_Common::bcast_int( niter ); Parallel_Common::bcast_int( nstep ); diff --git a/ABACUS.develop/source/input.h b/ABACUS.develop/source/input.h index 588f2f2e6e..d12ae1ec48 100644 --- a/ABACUS.develop/source/input.h +++ b/ABACUS.develop/source/input.h @@ -21,53 +21,45 @@ class Input void close_log(void)const; - int npool; // ecch pool is for one k point +//========================================================== +// directories of files +//========================================================== string suffix; // suffix of out put dir - string atom_file; //xiaohui modify 2015-02-01 - string pseudo_dir; // dir of pseudopotential - - string pseudo_type; // the type of pseudopotential, mohan add 2013-05-20, we can accept + string atom_file; // file contains atomic positions -- xiaohui modify 2015-02-01 + string pseudo_dir; // directory of pseudopotential + string pseudo_type; // the type of pseudopotential, mohan add 2013-05-20, ABACUS supports // UPF format (default) and vwr format. (xiaohui add 2013-06-23) - - string kpoint_file; //xiaohui modify 2015-02-01 + string kpoint_file; // file contains k-points -- xiaohui modify 2015-02-01 string wannier_card; // input card for wannier functions. string latname; // lattice name + string calculation; // "scf" : self consistent calculation. // "nscf" : non-self consistent calculation. - + // "relax" : cell relaxations int ntype; // number of atom types - int nbands; // number of bands - int nbands_istate; // number of bands around fermi level for istate calculation. + bool symmetry; // turn on symmetry or not + int npool; // ecch pool is for one k point bool berry_phase; // berry phase calculation - int gdir; // berry phase calculation bool towannier90; // add by jingan for wannier90 - string NNKP; // add by jingan for wannier90 - string wannier_spin; // add by jingan for wannier90 int efield; // add electrical field - int edir; - double emaxpos; - double eopreg; - double eamp; bool opt_epsilon2; // true : calculate the dielectric functions - int opt_nbands; // number of bands for optical transition matrix - bool lda_plus_u; // true : lda plus u calculation //========================================================== @@ -75,29 +67,20 @@ class Input //========================================================== string dft_functional; // input DFT functional. - - int nspin; // LDA ; LSDA ; non-linear spin - + int nspin; // LDA ; LSDA ; non-linear spin double nelec; // total number of electrons - int lmaxmax; - double tot_magnetization; //========================================================== -// new function +// LCAO parameters //========================================================== string basis_type; //xiaohui add 2013-09-01, for structural adjustment - string ks_solver; //xiaohui add 2013-09-01 - bool sparse_matrix; - int atom_distribution; - bool symmetry; // - bool mlwf_flag; int vna; //control the vna term. @@ -113,29 +96,21 @@ class Input double force_thr_ev2; // invalid force threshold, mohan add 2011-04-17 double stress_thr; // Pengfei Li 2017-11-01 //LiuXh update 20180515 - double press1; - double press2; - double press3; - bool stress; // calculate the stress string fixed_axes; //which axes are fixed - string ion_dynamics; // methods to move_ion: sd, bfgs, cg... double cg_threshold; // threshold when cg to bfgs, pengfei add 2011-08-15 double bfgs_w1; // wolfe condition 1 - double bfgs_w2; // wolfe condition 2 double trust_radius_max; // trust radius max - double trust_radius_min; // trust radius min - double trust_radius_ini; // initial move //========================================================== @@ -143,36 +118,25 @@ class Input //========================================================== bool gamma_only; // for plane wave. - bool gamma_only_local; // for local orbitals. double ecutwfc; // energy cutoff for wavefunctions - double ecutrho; // energy cutoff for charge/potential int ncx,ncy,ncz; // three dimension of FFT charge/grid - int nx,ny,nz; // three dimension of FFT wavefunc - int bx,by,bz; // big mesh ball. mohan add 2011-04-21 //========================================================== // technique //========================================================== - //string diago_type; xiaohui modify 2013-09-01 // "cg","davidson","fs" int diago_proc; // the number of procs used to diag. mohan add 2012-01-13 - int diago_cg_maxiter; - int diago_cg_prec; // mohan add 2012-03-31 - int diago_david_ndim; - double ethr; // used in cg method - double fs_ref_energy; // folded-spectrum reference energy - int nb2d; // matrix 2d division. int nurse; // used for debug. diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index 1fce194ce6..359cc11293 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -181,7 +181,6 @@ void Input_Conv::Convert(void) VNL_IN_H = INPUT.vnl_in_h; // 25 TEST_FORCE = INPUT.test_force; // 26 TEST_STRESS = INPUT.test_stress; - FS_REF_ENERGY = INPUT.fs_ref_energy; // 16 //---------------------------------------------------------- // iteration (1/3) From d7133915c7b8d1ca835423bb3d0486c27018a7b7 Mon Sep 17 00:00:00 2001 From: mohanchen Date: Wed, 3 Feb 2021 17:25:03 +0800 Subject: [PATCH 063/233] updatee input, add stochastic files --- ABACUS.develop/source/Makefile.Objects | 3 +- ABACUS.develop/source/input.cpp | 31 --- ABACUS.develop/source/input.h | 201 ++++-------------- ...trons_stochastic.cpp => electrons_sto.cpp} | 2 +- ...electrons_stochastic.h => electrons_sto.h} | 7 +- ABACUS.develop/source/src_pw/ions.h | 2 +- ABACUS.develop/source/src_pw/wf_atomic.h | 12 +- ABACUS.develop/source/src_pw/wf_igk.h | 1 + ABACUS.develop/source/src_pw/wf_sto.cpp | 43 ++++ ABACUS.develop/source/src_pw/wf_sto.h | 29 +++ 10 files changed, 127 insertions(+), 204 deletions(-) rename ABACUS.develop/source/src_pw/{electrons_stochastic.cpp => electrons_sto.cpp} (99%) rename ABACUS.develop/source/src_pw/{electrons_stochastic.h => electrons_sto.h} (85%) create mode 100644 ABACUS.develop/source/src_pw/wf_sto.cpp create mode 100644 ABACUS.develop/source/src_pw/wf_sto.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 75de4c67b3..e688fd8ed2 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -48,7 +48,7 @@ atom_pseudo.o\ unitcell_pseudo.o\ threshold_elec.o\ electrons.o \ -electrons_stochastic.o\ +electrons_sto.o\ forces.o\ stress.o\ myfunc1.o\ @@ -241,6 +241,7 @@ wavefunc.o\ wf_io.o \ rwstream.o\ wf_atomic.o \ +wf_sto.o \ wf_igk.o \ use_fft.o\ klist.o \ diff --git a/ABACUS.develop/source/input.cpp b/ABACUS.develop/source/input.cpp index bf9e6c8a1a..80913922cd 100644 --- a/ABACUS.develop/source/input.cpp +++ b/ABACUS.develop/source/input.cpp @@ -242,7 +242,6 @@ void Input::Default(void) t_in_h = 1; vl_in_h = 1; vnl_in_h = 1; - zeeman_in_h = 1; test_force = 0; test_stress = 0; //---------------------------------------------------------- @@ -301,12 +300,6 @@ void Input::Default(void) lcao_dr = 0.01; lcao_rmax = 30; // (a.u.) //---------------------------------------------------------- -// Divide and Conqure -//---------------------------------------------------------- - dc_nx = 1; - dc_ny = 1; - dc_nz = 1; -//---------------------------------------------------------- // Selinv //---------------------------------------------------------- selinv_npole = 40; @@ -886,10 +879,6 @@ bool Input::Read(const string &fn) { read_value(ifs, vnl_in_h); } - else if (strcmp("zeeman_in_h", word) == 0) - { - read_value(ifs, zeeman_in_h); - } else if (strcmp("test_force", word) == 0) { read_value(ifs, test_force); @@ -1081,19 +1070,6 @@ bool Input::Read(const string &fn) { read_value(ifs, lcao_rmax); } -// Divide&Conqure - else if (strcmp("dc_nx", word) == 0) - { - read_value(ifs, dc_nx); - } - else if (strcmp("dc_ny", word) == 0) - { - read_value(ifs, dc_ny); - } - else if (strcmp("dc_nz", word) == 0) - { - read_value(ifs, dc_nz); - } else if (strcmp("selinv_npole", word) == 0) { read_value(ifs, selinv_npole); @@ -1980,7 +1956,6 @@ void Input::Bcast() Parallel_Common::bcast_int( t_in_h ); Parallel_Common::bcast_int( vl_in_h ); Parallel_Common::bcast_int( vnl_in_h ); - Parallel_Common::bcast_int( zeeman_in_h ); Parallel_Common::bcast_int( test_force ); Parallel_Common::bcast_int( test_stress ); @@ -2031,11 +2006,6 @@ void Input::Bcast() Parallel_Common::bcast_double( lcao_dr ); Parallel_Common::bcast_double( lcao_rmax ); - // mohan add 2011-06-12 - Parallel_Common::bcast_int( dc_nx ); - Parallel_Common::bcast_int( dc_ny ); - Parallel_Common::bcast_int( dc_nz ); - // mohan add 2011-09-28 Parallel_Common::bcast_int( selinv_npole); Parallel_Common::bcast_double( selinv_temp); @@ -3130,7 +3100,6 @@ void Input::Print(const string &fn)const OUTP(ofs,"t_in_h", t_in_h,"calculate the kinetic energy or not"); OUTP(ofs,"vl_in_h", vl_in_h,"calculate the local potential or not"); OUTP(ofs,"vnl_in_h", vnl_in_h,"calculate the nonlocal potential or not"); - OUTP(ofs,"zeeman_in_h", zeeman_in_h,"calculate the zeeman term or not"); OUTP(ofs,"test_force", test_force, "test the force"); OUTP(ofs,"test_stress", test_stress, "test the force"); diff --git a/ABACUS.develop/source/input.h b/ABACUS.develop/source/input.h index d12ae1ec48..e76062d02e 100644 --- a/ABACUS.develop/source/input.h +++ b/ABACUS.develop/source/input.h @@ -48,16 +48,27 @@ class Input bool berry_phase; // berry phase calculation int gdir; // berry phase calculation +//========================================================== +// Wannier functions +//========================================================== bool towannier90; // add by jingan for wannier90 string NNKP; // add by jingan for wannier90 string wannier_spin; // add by jingan for wannier90 + bool mlwf_flag; // add by mohan + +//========================================================== +// E field +//========================================================== int efield; // add electrical field int edir; double emaxpos; double eopreg; double eamp; +//========================================================== +// Optical properties +//========================================================== bool opt_epsilon2; // true : calculate the dielectric functions int opt_nbands; // number of bands for optical transition matrix bool lda_plus_u; // true : lda plus u calculation @@ -65,7 +76,6 @@ class Input //========================================================== // electrons / spin //========================================================== - string dft_functional; // input DFT functional. int nspin; // LDA ; LSDA ; non-linear spin double nelec; // total number of electrons @@ -75,34 +85,33 @@ class Input //========================================================== // LCAO parameters //========================================================== - - string basis_type; //xiaohui add 2013-09-01, for structural adjustment - string ks_solver; //xiaohui add 2013-09-01 + string basis_type; //xiaohui add 2013-09-01, for structural adjustment + string ks_solver; //xiaohui add 2013-09-01 bool sparse_matrix; int atom_distribution; - bool mlwf_flag; - int vna; //control the vna term. - int grid_speed; //1:normal 2:fast, mohan add 2012-03-29 +//========================================================== +// Forces +//========================================================== int force; - bool force_set; - double force_thr; // threshold of force in unit (Ry/Bohr) - double force_thr_ev2; // invalid force threshold, mohan add 2011-04-17 +//========================================================== +// Stress +//========================================================== double stress_thr; // Pengfei Li 2017-11-01 //LiuXh update 20180515 double press1; double press2; double press3; bool stress; // calculate the stress - string fixed_axes; //which axes are fixed - string ion_dynamics; // methods to move_ion: sd, bfgs, cg... + string fixed_axes; //which axes are fixed + string ion_dynamics; // methods to move_ion: sd, bfgs, cg... double cg_threshold; // threshold when cg to bfgs, pengfei add 2011-08-15 @@ -114,9 +123,8 @@ class Input double trust_radius_ini; // initial move //========================================================== -// planewave +// Planewave //========================================================== - bool gamma_only; // for plane wave. bool gamma_only_local; // for local orbitals. @@ -130,7 +138,6 @@ class Input //========================================================== // technique //========================================================== - int diago_proc; // the number of procs used to diag. mohan add 2012-01-13 int diago_cg_maxiter; int diago_cg_prec; // mohan add 2012-03-31 @@ -144,37 +151,25 @@ class Input bool colour; // used for fun. int t_in_h; // calculate the T or not. - int vl_in_h; // calculate the T or not. - int vnl_in_h; // calculate the T or not. - int zeeman_in_h; // calculate the zeeman energy or not. - int test_force; // test the force. - int test_stress; // test the stress. //========================================================== // iteration //========================================================== - double dr2; // \sum |rhog_out - rhog_in |^2 - int niter; // number of max elec iter - int nstep; // number of max ionic iter - int out_stru; // outut stru file each ion step - string out_level; // control the output information. - - bool out_md_control; // internal parameter , added by zhengdy 2019-04-07 + bool out_md_control; // internal parameter , added by zhengdy 2019-04-07 //========================================================== // occupation //========================================================== - string occupations; // "fixed","smearing","tetrahedra","from_input" string smearing; // "gaussian", @@ -186,262 +181,160 @@ class Input //========================================================== // charge mixing //========================================================== - string mixing_mode; // "plain","broden",... - double mixing_beta; // 0 : no_mixing - int mixing_ndim; // used in Broden method - double mixing_gg0; // used in kerker method. mohan add 2014-09-27 //========================================================== // potential / charge / wavefunction / energy //========================================================== - string restart_mode; // string start_wfc; // "file","atomic","random" - string start_pot; // "file","atomic" - string charge_extrap; // xiaohui modify 2015-02-01 + string charge_extrap; // xiaohui modify 2015-02-01 int mem_saver; // 1: save psi when nscf calculation. int printe; // mohan add 2011-03-16 - int out_charge; // output charge density. - int out_dm; // output density matrix. - int out_potential; // yes or no - bool out_wf; // yes or no - int out_dos; // dos calculation. mohan add 20090909 - int out_band; // band calculation pengfei 2014-10-13 - int out_hs; // output H matrix and S matrix in local basis. - int out_hs2; //LiuXh add 2019-07-16, output H(R) matrix and S(R) matrix in local basis. - int out_r_matrix; // jingan add 2019-8-14, output r(R) matrix. - bool out_lowf; // output the wave functions in local basis. - bool out_alllog; // output all logs. double dos_emin_ev; - double dos_emax_ev; - double dos_edelta_ev; double b_coef; // pengfei 2014-10-13 //========================================================== -// parameters about LCAO calculation. +// two center integrals in LCAO // mohan add 2009-11-11 //========================================================== - double lcao_ecut; // ecut of two center integral - double lcao_dk; // delta k used in two center integral - double lcao_dr; // dr used in two center integral - double lcao_rmax; // rmax(a.u.) to make table. - double search_radius; //11.1 - bool search_pbc; // 11.2 - // Divide&Conqure - int dc_nx; - - int dc_ny; - - int dc_nz; +//========================================================== +// selected inversion method +//========================================================== // selinv method parameter (cooperate with LinLin) int selinv_npole; - double selinv_temp; - double selinv_gap; - double selinv_deltae; - double selinv_mu; - double selinv_threshold; - int selinv_niter; - //md and related parameters(added by zheng da ye) +//========================================================== +// molecular dynamics +// added by Daye Zheng +//========================================================== int md_mdtype; //choose ensemble - double md_tauthermo; - double md_taubaro; - double md_dt; //time step - int md_nresn; //parameter during integrater - int md_nyosh; //parameter during integrater - double md_qmass; //mass of thermostat - double md_tfirst; //temperature begin - double md_tlast; //temperature end - int md_dumpmdfred; //The period to dump MD information for monitoring and restarting MD - string md_mdoutpath; //output path for md - bool md_domsd; //whether compute - bool md_domsdatom; //whether compute msd for each atom - int md_rstmd; //whether restart; - int md_outputstressperiod; //period to output stress - int md_fixtemperature; //period to change temperature - double md_ediff; //parameter for constraining total energy change - double md_ediffg; //parameter for constraining max force change - int md_msdstartTime; //choose which step that msd be calculated //========================================================== // vdw -//Peize Lin add 2014-03-31, jiyy update 2019-08-01 +// Peize Lin add 2014-03-31, jiyy update 2019-08-01 //========================================================== string vdw_method; //the method of vdw calculation - string vdw_s6; //scale parameter - string vdw_s8; //scale parameter - string vdw_a1; //damping function parameter - string vdw_a2; //damping function parameter - double vdw_d; //damping function parameter d - bool vdw_abc; //third-order term? - string vdw_radius; //cutoff radius for pair interactions - string vdw_radius_unit; //"Bohr" or "Angstrom" - double vdw_cn_thr; //cutoff radius for calculating the coordination number - string vdw_cn_thr_unit; //"Bohr" or "Angstrom" - string vdw_C6_file; - string vdw_C6_unit; //"Bohr" or "Angstrom" - string vdw_R0_file; - string vdw_R0_unit; //"Bohr" or "Angstrom" - string vdw_model; //"period" or "radius" - Vector3 vdw_period; //========================================================== -// spectrum +// Spectrum // pengfei Li add 2016-11-23 //========================================================== -//bool epsilon; // calculate epsilon or not - + //bool epsilon; // calculate epsilon or not string spectral_type; // the type of the calculated spectrum - int spectral_method; // 0: tddft(linear response) - int eels_method; // 0: hilbert_transform method; 1: standard method - int absorption_method; // 0: vasp's method 1: pwscf's method - //int epsilon_choice; // 0: hilbert_transform method; 1: standard method - string kernel_type; // the kernel type: rpa, tdlda ... - string system; // bulk or surface - double eta; // unit(Ry) - double domega; // unit(Ry) - int nomega; - int ecut_chi; // the dimension of G - //int oband; // the number of "occupied" bands - double q_start[3]; // the position of the first q point in direct coordinate - double q_direct[3]; // the q direction - //int start_q; // the serial number of the start qpoint - //int interval_q; // the interval of the qpoints - int nq; // the total number of qpoints for calculation - bool out_epsilon; // output epsilon or not - bool out_chi; // output chi or not - bool out_chi0; // output chi0 or not - double fermi_level; // the change the fermi level(Ry) - bool coulomb_cutoff; // turn on or off the Coulomb_cutoff 0/1 - //bool epsilon0; // calculate the macroscopic dielectric constant or not //double intersmear; // eta - double intrasmear; // Eta - double shift; - bool metalcalc; // metal or not - double eps_degauss; // degauss - //int epsilon0_choice; // 0: vasp's method 1: pwscf's method - bool kmesh_interpolation; // calculting - double qcar[100][3]; // the Cartesian position of q points(unit: 2*PI/lat0) - int ocp; - //int ocp_n; string ocp_set; - //double ocp_kb[10000]; int lcao_box[3]; // the scale for searching the existence of the overlap - int mulliken;//qifeng add 2019-9-10 //added by zhengdy-soc - bool noncolin; - bool lspinorb; // bool starting_spin_angle; double *angle1; - double *angle2; //========================================================== @@ -449,21 +342,13 @@ class Input // Fuxiang He add 2016-10-26 //========================================================== int tddft; //calculate tddft or not - double td_dr2; //threshold for electronic iteration of tddft - double td_dt; //"fs" - double td_force_dt; //"fs" - int val_elec_01; //valence electron 01 - int val_elec_02; //valence electron 02 - int val_elec_03; //valence electron 03 - int vext; //add extern potential or not - int vext_dire; //vext direction //========================================================== @@ -471,12 +356,9 @@ class Input // Peize Lin add 2020-04-04 //========================================================== bool restart_save; - bool restart_load; - //xiaohui add 2015-09-16 bool input_error; - double cell_factor; //LiuXh add 20180619 //========================================================== @@ -493,30 +375,23 @@ class Input //========================================================== // DFT+U Xin Qu added on 2020-10-29 //========================================================== - bool dft_plus_u; //true:DFT+U correction; false:standard DFT calcullation(default) - int *orbital_corr; // which correlated orbitals need corrected ; d:2 ,f:3, do not need correction:-1 - double *hubbard_u; //Hubbard Coulomb interaction parameter U(ev) - double *hund_j; //Hund exchange parameter J(ev) - bool omc; //whether turn on occupation matrix control method or not - bool yukawa_potential; //default:false - double yukawa_lambda; //default:0.0 //The two parameters below are not usable currently int dftu_type; //1:rotationally invarient formalism; 2:simplified form(default) - int double_counting; // 1:FLL(fully localized limit)(default); 2:AMF(around mean field) - // for deepks +//========================================================== +// DeepKS -- added by caoyu and mohan +//========================================================== int out_descriptor; // output descritpor for deepks. caoyu added 2020-11-24, mohan modified 2021-01-03 - int lmax_descriptor; // lmax used in descriptor, mohan added 2021-01-03 private: diff --git a/ABACUS.develop/source/src_pw/electrons_stochastic.cpp b/ABACUS.develop/source/src_pw/electrons_sto.cpp similarity index 99% rename from ABACUS.develop/source/src_pw/electrons_stochastic.cpp rename to ABACUS.develop/source/src_pw/electrons_sto.cpp index 3135f08860..80219506a9 100644 --- a/ABACUS.develop/source/src_pw/electrons_stochastic.cpp +++ b/ABACUS.develop/source/src_pw/electrons_sto.cpp @@ -1,6 +1,6 @@ #include "tools.h" #include "global.h" -#include "electrons_stochastic.h" +#include "electrons_sto.h" #include "algorithms.h" #include "symmetry_rho.h" #include "../src_pw/wf_io.h" diff --git a/ABACUS.develop/source/src_pw/electrons_stochastic.h b/ABACUS.develop/source/src_pw/electrons_sto.h similarity index 85% rename from ABACUS.develop/source/src_pw/electrons_stochastic.h rename to ABACUS.develop/source/src_pw/electrons_sto.h index df9ede2bcd..a4976d93b0 100644 --- a/ABACUS.develop/source/src_pw/electrons_stochastic.h +++ b/ABACUS.develop/source/src_pw/electrons_sto.h @@ -1,5 +1,5 @@ -#ifndef INCLUDE_ELECTRONS_STOCHASTIC_H -#define INCLUDE_ELECTRONS_STOCHASTIC_H +#ifndef INCLUDE_ELECTRONS_STO_H +#define INCLUDE_ELECTRONS_STO_H #include "tools.h" #include "threshold_elec.h" @@ -15,11 +15,12 @@ class Electrons_Stochastic: private Threshold_Elec // constructor and deconstructor Electrons_Stochastic(); + ~Electrons_Stochastic(); int iter; + static double avg_iter; - int test; void scf_stochastic(const int &istep); diff --git a/ABACUS.develop/source/src_pw/ions.h b/ABACUS.develop/source/src_pw/ions.h index 3c2471cb76..01e82c96f4 100644 --- a/ABACUS.develop/source/src_pw/ions.h +++ b/ABACUS.develop/source/src_pw/ions.h @@ -2,7 +2,7 @@ #define IONS_H #include "electrons.h" -#include "electrons_stochastic.h" //mohan added 2021-01-28 +#include "electrons_sto.h" //mohan added 2021-01-28 #include "tools.h" #include "../src_ions/ions_move_methods.h" #include "../src_ions/lattice_change_methods.h" diff --git a/ABACUS.develop/source/src_pw/wf_atomic.h b/ABACUS.develop/source/src_pw/wf_atomic.h index b5365d94bb..943518c268 100644 --- a/ABACUS.develop/source/src_pw/wf_atomic.h +++ b/ABACUS.develop/source/src_pw/wf_atomic.h @@ -7,16 +7,18 @@ class WF_atomic : public WF_igk { public: + WF_atomic(); ~WF_atomic(); realArray table_local;//mohan add 2009-09-10 - // evc : (nbnd,npwx),wavefunctions in the PW basis - // wanf2 : wannier functions in the PW basis - ComplexMatrix *evc; - ComplexMatrix *wanf2; + + ComplexMatrix *evc; // wavefunctions in the PW basis + + ComplexMatrix *wanf2; // wannier functions in the PW basis void init_at_1(void);// from init_at_1.f90 + void print_PAOs(void)const; protected: @@ -37,6 +39,8 @@ class WF_atomic : public WF_igk // as trial wave functions //================================== void random(ComplexMatrix &psi,const int iw_start,const int iw_end,const int ik)const; + void check_psi(const ComplexMatrix *psi)const; + }; #endif diff --git a/ABACUS.develop/source/src_pw/wf_igk.h b/ABACUS.develop/source/src_pw/wf_igk.h index e2cd38c638..33989c354c 100644 --- a/ABACUS.develop/source/src_pw/wf_igk.h +++ b/ABACUS.develop/source/src_pw/wf_igk.h @@ -7,6 +7,7 @@ class WF_igk { public: + WF_igk(); ~WF_igk(); diff --git a/ABACUS.develop/source/src_pw/wf_sto.cpp b/ABACUS.develop/source/src_pw/wf_sto.cpp new file mode 100644 index 0000000000..fc98834e95 --- /dev/null +++ b/ABACUS.develop/source/src_pw/wf_sto.cpp @@ -0,0 +1,43 @@ +#include "wf_sto.h" +#include "global.h" + +WF_Stochastic::WF_Stochastic() +{ + evc = new ComplexMatrix[1]; +} + +WF_Stochastic::~WF_Stochastic() +{ + delete[] evc; +} + + +// update the function to generate random wave functions as stochastic wave functions. + +void WF_Stochastic::random(ComplexMatrix &psi,const int iw_start,const int iw_end,const int ik)const +{ +/* + assert(iw_start >= 0); + assert(psi.nr >= iw_end); + const int ng = kv.ngk[ik]; + for (int iw = iw_start ;iw < iw_end;iw++) + { + for (int ig = 0;ig < ng;ig++) + { + const double rr = std::rand(); + const double arg= TWO_PI * std::rand(); + Vector3 v3 = kv.kvec_c[ik] + pw.gcar[this->igk(ik, ig)]; + psi(iw,ig) = complex(rr * cos(arg), rr * sin(arg)) / (v3 * v3 + 1.0); + } + if(NPOL==2)for (int ig = wf.npwx;ig < wf.npwx + ng;ig++) + { + const double rr = std::rand(); + const double arg= TWO_PI * std::rand(); + Vector3 v3 = kv.kvec_c[ik] + pw.gcar[this->igk(ik, ig-wf.npwx)]; + psi(iw,ig) = complex(rr * cos(arg), rr * sin(arg)) / (v3 * v3 + 1.0); + } + } +*/ + return; +} + diff --git a/ABACUS.develop/source/src_pw/wf_sto.h b/ABACUS.develop/source/src_pw/wf_sto.h new file mode 100644 index 0000000000..6f517020b3 --- /dev/null +++ b/ABACUS.develop/source/src_pw/wf_sto.h @@ -0,0 +1,29 @@ +#ifndef WF_STO_H +#define WF_STO_H + +#include "tools.h" + +class WF_Stochastic +{ + public: + + WF_Stochastic(); + ~WF_Stochastic(); + + + ComplexMatrix *evc; // wavefunctions in the PW basis + + void init_at_1(void);// from init_at_1.f90 + + protected: + + //================================== + // Calculate random wave functions + // as stochastic wave functions + //================================== + void random(ComplexMatrix &psi,const int iw_start,const int iw_end,const int ik)const; + + void check_psi(const ComplexMatrix *psi)const; + +}; +#endif From d89185ee4b45f101c117bd2ff302ad2ce517efc8 Mon Sep 17 00:00:00 2001 From: mohanchen Date: Wed, 3 Feb 2021 20:14:43 +0800 Subject: [PATCH 064/233] add modules for developments of stochastic density functional theory --- ABACUS.develop/source/Makefile.Objects | 7 ++- ABACUS.develop/source/src_pw/ions.h | 4 +- ABACUS.develop/source/src_pw/sto_che.cpp | 12 ++++++ ABACUS.develop/source/src_pw/sto_che.h | 25 +++++++++++ .../{electrons_sto.cpp => sto_elec.cpp} | 14 +++--- .../src_pw/{electrons_sto.h => sto_elec.h} | 14 +++--- ABACUS.develop/source/src_pw/sto_hchi.cpp | 20 +++++++++ ABACUS.develop/source/src_pw/sto_hchi.h | 34 +++++++++++++++ ABACUS.develop/source/src_pw/sto_iter.cpp | 11 +++++ ABACUS.develop/source/src_pw/sto_iter.h | 31 +++++++++++++ ABACUS.develop/source/src_pw/sto_wf.cpp | 40 +++++++++++++++++ ABACUS.develop/source/src_pw/sto_wf.h | 41 ++++++++++++++++++ ABACUS.develop/source/src_pw/wf_sto.cpp | 43 ------------------- ABACUS.develop/source/src_pw/wf_sto.h | 29 ------------- 14 files changed, 236 insertions(+), 89 deletions(-) create mode 100644 ABACUS.develop/source/src_pw/sto_che.cpp create mode 100644 ABACUS.develop/source/src_pw/sto_che.h rename ABACUS.develop/source/src_pw/{electrons_sto.cpp => sto_elec.cpp} (96%) rename ABACUS.develop/source/src_pw/{electrons_sto.h => sto_elec.h} (70%) create mode 100644 ABACUS.develop/source/src_pw/sto_hchi.cpp create mode 100644 ABACUS.develop/source/src_pw/sto_hchi.h create mode 100644 ABACUS.develop/source/src_pw/sto_iter.cpp create mode 100644 ABACUS.develop/source/src_pw/sto_iter.h create mode 100644 ABACUS.develop/source/src_pw/sto_wf.cpp create mode 100644 ABACUS.develop/source/src_pw/sto_wf.h delete mode 100644 ABACUS.develop/source/src_pw/wf_sto.cpp delete mode 100644 ABACUS.develop/source/src_pw/wf_sto.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index e688fd8ed2..66fe2ec743 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -48,7 +48,6 @@ atom_pseudo.o\ unitcell_pseudo.o\ threshold_elec.o\ electrons.o \ -electrons_sto.o\ forces.o\ stress.o\ myfunc1.o\ @@ -69,6 +68,11 @@ soc.o\ toWannier90.o \ unkOverlap_pw.o \ berryphase.o \ +sto_elec.o\ +sto_wf.o\ +sto_iter.o\ +sto_hchi.o\ +sto_che.o\ OBJS_TOOLS=complexarray.o\ complexmatrix.o \ @@ -241,7 +245,6 @@ wavefunc.o\ wf_io.o \ rwstream.o\ wf_atomic.o \ -wf_sto.o \ wf_igk.o \ use_fft.o\ klist.o \ diff --git a/ABACUS.develop/source/src_pw/ions.h b/ABACUS.develop/source/src_pw/ions.h index 01e82c96f4..412831b0ee 100644 --- a/ABACUS.develop/source/src_pw/ions.h +++ b/ABACUS.develop/source/src_pw/ions.h @@ -2,12 +2,12 @@ #define IONS_H #include "electrons.h" -#include "electrons_sto.h" //mohan added 2021-01-28 #include "tools.h" #include "../src_ions/ions_move_methods.h" #include "../src_ions/lattice_change_methods.h" #include "charge_extra.h" //#include "../src_develop/src_md/md.h" +#include "sto_elec.h" //mohan added 2021-01-28 class Ions { @@ -24,7 +24,7 @@ class Ions Electrons elec; // mohan add for stochastic wave functions - Electrons_Stochastic elec_sto; + Stochastic_Elec elec_sto; // mohan add 2021-01-28 // mohan moved this variable from electrons.h to ions.h diff --git a/ABACUS.develop/source/src_pw/sto_che.cpp b/ABACUS.develop/source/src_pw/sto_che.cpp new file mode 100644 index 0000000000..a935432ce7 --- /dev/null +++ b/ABACUS.develop/source/src_pw/sto_che.cpp @@ -0,0 +1,12 @@ +#include "tools.h" +#include "global.h" +#include "sto_che.h" + + +Stochastic_Chebychev::Stochastic_Chebychev() +{ +} + +Stochastic_Chebychev::~Stochastic_Chebychev() +{ +} diff --git a/ABACUS.develop/source/src_pw/sto_che.h b/ABACUS.develop/source/src_pw/sto_che.h new file mode 100644 index 0000000000..9e39f392ca --- /dev/null +++ b/ABACUS.develop/source/src_pw/sto_che.h @@ -0,0 +1,25 @@ +#ifndef INCLUDE_STO_CHEBYCHEV_H +#define INCLUDE_STO_CHEBYCHEV_H + +#include "tools.h" + +//---------------------------------------------- +// Chebychev Filtering +//---------------------------------------------- + +class Stochastic_Chebychev +{ + + public: + + // constructor and deconstructor + Stochastic_Chebychev(); + ~Stochastic_Chebychev(); + + private: + + + +}; + +#endif// Eelectrons_Chebychev diff --git a/ABACUS.develop/source/src_pw/electrons_sto.cpp b/ABACUS.develop/source/src_pw/sto_elec.cpp similarity index 96% rename from ABACUS.develop/source/src_pw/electrons_sto.cpp rename to ABACUS.develop/source/src_pw/sto_elec.cpp index 80219506a9..a1b7a55f54 100644 --- a/ABACUS.develop/source/src_pw/electrons_sto.cpp +++ b/ABACUS.develop/source/src_pw/sto_elec.cpp @@ -1,22 +1,22 @@ #include "tools.h" #include "global.h" -#include "electrons_sto.h" +#include "sto_elec.h" #include "algorithms.h" #include "symmetry_rho.h" #include "../src_pw/wf_io.h" -double Electrons_Stochastic::avg_iter = 0; +double Stochastic_Elec::avg_iter = 0; -Electrons_Stochastic::Electrons_Stochastic() +Stochastic_Elec::Stochastic_Elec() { } -Electrons_Stochastic::~Electrons_Stochastic() +Stochastic_Elec::~Stochastic_Elec() { } -void Electrons_Stochastic::scf_stochastic(const int &istep) +void Stochastic_Elec::scf_stochastic(const int &istep) { timer::tick("Elec_Stochastic","scf_stochastic",'D'); en.ewld = en.ewald(); @@ -288,7 +288,7 @@ void Electrons_Stochastic::scf_stochastic(const int &istep) } // end electrons -bool Electrons_Stochastic::check_stop_now(void) +bool Stochastic_Elec::check_stop_now(void) { bool check_stop_now = false; @@ -301,7 +301,7 @@ bool Electrons_Stochastic::check_stop_now(void) } -void Electrons_Stochastic::c_bands(const int &istep) +void Stochastic_Elec::c_bands(const int &istep) { if (test_elec) TITLE("electrons","c_bands"); timer::tick("Elec_Stochastic","c_bands",'E'); diff --git a/ABACUS.develop/source/src_pw/electrons_sto.h b/ABACUS.develop/source/src_pw/sto_elec.h similarity index 70% rename from ABACUS.develop/source/src_pw/electrons_sto.h rename to ABACUS.develop/source/src_pw/sto_elec.h index a4976d93b0..7ed66853bf 100644 --- a/ABACUS.develop/source/src_pw/electrons_sto.h +++ b/ABACUS.develop/source/src_pw/sto_elec.h @@ -1,22 +1,22 @@ -#ifndef INCLUDE_ELECTRONS_STO_H -#define INCLUDE_ELECTRONS_STO_H +#ifndef INCLUDE_STO_ELEC_H +#define INCLUDE_STO_ELEC_H #include "tools.h" #include "threshold_elec.h" +#include "sto_wf.h" //---------------------------------------------- // methods based on stochastic wave functions //---------------------------------------------- -class Electrons_Stochastic: private Threshold_Elec +class Stochastic_Elec: private Threshold_Elec { public: // constructor and deconstructor - Electrons_Stochastic(); - - ~Electrons_Stochastic(); + Stochastic_Elec(); + ~Stochastic_Elec(); int iter; @@ -26,6 +26,8 @@ class Electrons_Stochastic: private Threshold_Elec private: + Stochastic_WF swf; + void c_bands(const int &istep); bool check_stop_now(void); diff --git a/ABACUS.develop/source/src_pw/sto_hchi.cpp b/ABACUS.develop/source/src_pw/sto_hchi.cpp new file mode 100644 index 0000000000..8ece995851 --- /dev/null +++ b/ABACUS.develop/source/src_pw/sto_hchi.cpp @@ -0,0 +1,20 @@ +#include "tools.h" +#include "global.h" +#include "sto_hchi.h" + +Stochastic_Hchi::Stochastic_Hchi() +{ +} + +Stochastic_Hchi::~Stochastic_Hchi() +{ +} + + +void Stochastic_Hchi::orthogonal_to_psi() +{ + TITLE("Stochastic_Hchi","orthogonal_to_psi0"); + + + return; +} diff --git a/ABACUS.develop/source/src_pw/sto_hchi.h b/ABACUS.develop/source/src_pw/sto_hchi.h new file mode 100644 index 0000000000..e862c48f36 --- /dev/null +++ b/ABACUS.develop/source/src_pw/sto_hchi.h @@ -0,0 +1,34 @@ +#ifndef INCLUDE_STO_HCHI_H +#define INCLUDE_STO_HCHI_H + +#include "tools.h" + +//----------------------------------------------------- +// H * chi +// chi: stochastic wave functions +// +// H: the Hamiltonian matrix, which is decomposed +// into the electron kinetic, effective potential V(r), +// and the non-local pseudopotentials. +// The effective potential = Local pseudopotential + +// Hartree potential + Exchange-correlation potential +//------------------------------------------------------ + +class Stochastic_Hchi +{ + + public: + + // constructor and deconstructor + Stochastic_Hchi(); + ~Stochastic_Hchi(); + + private: + + // chi should be orthogonal to psi (generated by diaganolization methods, + // such as CG) + void orthogonal_to_psi(); + +}; + +#endif// Eelectrons_Hchi diff --git a/ABACUS.develop/source/src_pw/sto_iter.cpp b/ABACUS.develop/source/src_pw/sto_iter.cpp new file mode 100644 index 0000000000..6cb3f891bf --- /dev/null +++ b/ABACUS.develop/source/src_pw/sto_iter.cpp @@ -0,0 +1,11 @@ +#include "global.h" +#include "sto_iter.h" + + +Stochastic_Iter::Stochastic_Iter() +{ +} + +Stochastic_Iter::~Stochastic_Iter() +{ +} diff --git a/ABACUS.develop/source/src_pw/sto_iter.h b/ABACUS.develop/source/src_pw/sto_iter.h new file mode 100644 index 0000000000..6b3be8d327 --- /dev/null +++ b/ABACUS.develop/source/src_pw/sto_iter.h @@ -0,0 +1,31 @@ +#ifndef INCLUDE_STO_ITER_H +#define INCLUDE_STO_ITER_H + +#include "tools.h" + +//---------------------------------------------- +// Solve for the new electron density and iterate +// until SCF loop converges (mu, epsilon, rho) +// mu: chemical potential +// epsilon: eigenvalues +// rho: charge density +//---------------------------------------------- + +class Stochastic_Iter +{ + + public: + + // constructor and deconstructor + Stochastic_Iter(); + + ~Stochastic_Iter(); + + double mu; // chemical potential + + private: + + +}; + +#endif// Eelectrons_Iter diff --git a/ABACUS.develop/source/src_pw/sto_wf.cpp b/ABACUS.develop/source/src_pw/sto_wf.cpp new file mode 100644 index 0000000000..9970d47949 --- /dev/null +++ b/ABACUS.develop/source/src_pw/sto_wf.cpp @@ -0,0 +1,40 @@ +#include "sto_wf.h" +#include "global.h" + +Stochastic_WF::Stochastic_WF() +{ + chi = new ComplexMatrix[1]; +} + +Stochastic_WF::~Stochastic_WF() +{ + delete[] chi; +} + +void Stochastic_WF::allocate_chi() +{ + + +} + + +// update the function to generate random wave functions as stochastic wave functions. +void Stochastic_WF::random(ComplexMatrix &chi) +{ + int ik=0; // only supports gamma-only case now + + const int ng = kv.ngk[ik]; + + for (int iw = 0 ;iw < this->nchi;iw++) + { + for (int ig = 0;ig < ng;ig++) + { + // const double rr = std::rand(); + // const double arg= TWO_PI * std::rand(); + // Vector3 v3 = kv.kvec_c[ik] + pw.gcar[this->igk(ik, ig)]; + // psi(iw,ig) = complex(rr * cos(arg), rr * sin(arg)) / (v3 * v3 + 1.0); + } + } + return; +} + diff --git a/ABACUS.develop/source/src_pw/sto_wf.h b/ABACUS.develop/source/src_pw/sto_wf.h new file mode 100644 index 0000000000..1ecbab68a5 --- /dev/null +++ b/ABACUS.develop/source/src_pw/sto_wf.h @@ -0,0 +1,41 @@ +#ifndef STOCHASTIC_WF_H +#define STOCHASTIC_WF_H + +#include "tools.h" + +//---------------------------------------------- +// Generate stochastic wave functions +//---------------------------------------------- + +class Stochastic_WF +{ + public: + + Stochastic_WF(); + + ~Stochastic_WF(); + + + void allocate_chi(); + + + // ComplexMatrix may not be a best filetype to store the electronic wave functions + ComplexMatrix *chi; // stochastic wavefunctions in the PW basis + + int nchi; + + int nbands_diag; // number of bands obtained from diagonalization + + int nbands_total; // number of bands in total, nbands_total=nchi+nbands_diag; + + protected: + + + // Calculate random wave functions as stochastic wave functions + void random(ComplexMatrix &chi); + + // check the properties of chi + void check_chi(const ComplexMatrix *chi)const; + +}; +#endif diff --git a/ABACUS.develop/source/src_pw/wf_sto.cpp b/ABACUS.develop/source/src_pw/wf_sto.cpp deleted file mode 100644 index fc98834e95..0000000000 --- a/ABACUS.develop/source/src_pw/wf_sto.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "wf_sto.h" -#include "global.h" - -WF_Stochastic::WF_Stochastic() -{ - evc = new ComplexMatrix[1]; -} - -WF_Stochastic::~WF_Stochastic() -{ - delete[] evc; -} - - -// update the function to generate random wave functions as stochastic wave functions. - -void WF_Stochastic::random(ComplexMatrix &psi,const int iw_start,const int iw_end,const int ik)const -{ -/* - assert(iw_start >= 0); - assert(psi.nr >= iw_end); - const int ng = kv.ngk[ik]; - for (int iw = iw_start ;iw < iw_end;iw++) - { - for (int ig = 0;ig < ng;ig++) - { - const double rr = std::rand(); - const double arg= TWO_PI * std::rand(); - Vector3 v3 = kv.kvec_c[ik] + pw.gcar[this->igk(ik, ig)]; - psi(iw,ig) = complex(rr * cos(arg), rr * sin(arg)) / (v3 * v3 + 1.0); - } - if(NPOL==2)for (int ig = wf.npwx;ig < wf.npwx + ng;ig++) - { - const double rr = std::rand(); - const double arg= TWO_PI * std::rand(); - Vector3 v3 = kv.kvec_c[ik] + pw.gcar[this->igk(ik, ig-wf.npwx)]; - psi(iw,ig) = complex(rr * cos(arg), rr * sin(arg)) / (v3 * v3 + 1.0); - } - } -*/ - return; -} - diff --git a/ABACUS.develop/source/src_pw/wf_sto.h b/ABACUS.develop/source/src_pw/wf_sto.h deleted file mode 100644 index 6f517020b3..0000000000 --- a/ABACUS.develop/source/src_pw/wf_sto.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef WF_STO_H -#define WF_STO_H - -#include "tools.h" - -class WF_Stochastic -{ - public: - - WF_Stochastic(); - ~WF_Stochastic(); - - - ComplexMatrix *evc; // wavefunctions in the PW basis - - void init_at_1(void);// from init_at_1.f90 - - protected: - - //================================== - // Calculate random wave functions - // as stochastic wave functions - //================================== - void random(ComplexMatrix &psi,const int iw_start,const int iw_end,const int ik)const; - - void check_psi(const ComplexMatrix *psi)const; - -}; -#endif From ad2bd091703d32964fc2a6309ec266e3d3573326 Mon Sep 17 00:00:00 2001 From: qianrui Date: Thu, 4 Feb 2021 13:41:16 +0800 Subject: [PATCH 065/233] Modify some part to make the program compatible with gnu --- ABACUS.develop/source/Makefile.vars | 12 +++--- .../source/src_external/src_pdiag/MRRR/mrrr.h | 1 + ABACUS.develop/source/src_global/rwstream.h | 4 -- ABACUS.develop/source/src_pw/sto_wf.cpp | 42 +++++++++---------- ABACUS.develop/source/src_pw/sto_wf.h | 11 +++-- ABACUS.develop/source/src_pw/wavefunc.cpp | 2 +- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/ABACUS.develop/source/Makefile.vars b/ABACUS.develop/source/Makefile.vars index fcff7e531a..13b6bedbfd 100644 --- a/ABACUS.develop/source/Makefile.vars +++ b/ABACUS.develop/source/Makefile.vars @@ -11,19 +11,19 @@ LAPACK_DIR = $(MKLROOT) #LAPACK_DIR = $(MKLROOT) #LAPACK_DIR = /public/intel2017/mkl -FFTW_DIR = /home/mohan/1_Software/impi_fftw-3.3.8 -#FFTW_DIR = /home/qianrui/intelcompile/impi_fftw +#FFTW_DIR = /home/mohan/1_Software/impi_fftw-3.3.8 +FFTW_DIR = /home/qianrui/intelcompile/impi_fftw #FFTW_DIR = /public/udata/xiaohui/software/fftw2 #FFTW_DIR =/opt/fftw/3.3.6-p12/intel/2017.update4 #FFTW_DIR = /public/fftw-3.3.8 -BOOST_DIR = /home/mohan/1_Software/impi_boost-1.70.0 -#BOOST_DIR = /home/qianrui/intelcompile/impi_boost +#BOOST_DIR = /home/mohan/1_Software/impi_boost-1.70.0 +BOOST_DIR = /home/qianrui/intelcompile/impi_boost #BOOST_DIR = /public/udata/xiaohui/software/boost_1_39_0 #BOOST_DIR = /opt/boost/1.64.0 -ELPA_DIR = /home/mohan/1_Software/impi_elpa-16.05.005 -#ELPA_DIR = /home/qianrui/intelcompile/impi_elpa +#ELPA_DIR = /home/mohan/1_Software/impi_elpa-16.05.005 +ELPA_DIR = /home/qianrui/intelcompile/impi_elpa #ELPA_DIR = /public/udata/xiaohui/ELPA-2016.05.004 #ELPA_DIR = /opt/elpa/intel_2017_update4 diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/mrrr.h b/ABACUS.develop/source/src_external/src_pdiag/MRRR/mrrr.h index 5ed9293fe6..0c04fb184b 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/MRRR/mrrr.h +++ b/ABACUS.develop/source/src_external/src_pdiag/MRRR/mrrr.h @@ -13,6 +13,7 @@ #define max(a,b) ((a) >= (b) ? (a) : (b)) #define dmin(a,b) (double)min(a,b) #define dmax(a,b) (double)max(a,b) +#define dlamch dlamch_ extern "C" double dlamch(char *); /* diff --git a/ABACUS.develop/source/src_global/rwstream.h b/ABACUS.develop/source/src_global/rwstream.h index 5afeacf7e0..84e871a367 100644 --- a/ABACUS.develop/source/src_global/rwstream.h +++ b/ABACUS.develop/source/src_global/rwstream.h @@ -56,13 +56,11 @@ Rwstream& operator>>(Rwstream& rstream,T& data) int n=sizeof(data)/sizeof(T); size_t ch; ch=fread(&data,size,n,rstream.fileptr); -#ifdef __JUG if(chnchi;iw++) + int nrxx = 1; + complex ui(0,1); + + delete[] chi0; + //We temporarily init one group of orbitals for all k points. + //This save memories. + chi0 = new ComplexMatrix[1]; + chi0[0].create(nchi,nrxx,0); + //init with random number + for(int i=0; i v3 = kv.kvec_c[ik] + pw.gcar[this->igk(ik, ig)]; - // psi(iw,ig) = complex(rr * cos(arg), rr * sin(arg)) / (v3 * v3 + 1.0); - } + chi0[0].c[i]=exp(2*PI*rand()*ui); } + + delete[] chi; + int nkk = 1; // We temporarily use gamma k point. + chi = new ComplexMatrix[nkk]; return; } + + diff --git a/ABACUS.develop/source/src_pw/sto_wf.h b/ABACUS.develop/source/src_pw/sto_wf.h index 1ecbab68a5..6cff719fc3 100644 --- a/ABACUS.develop/source/src_pw/sto_wf.h +++ b/ABACUS.develop/source/src_pw/sto_wf.h @@ -3,6 +3,8 @@ #include "tools.h" +//qianrui 2021-2-4 + //---------------------------------------------- // Generate stochastic wave functions //---------------------------------------------- @@ -16,11 +18,13 @@ class Stochastic_WF ~Stochastic_WF(); - void allocate_chi(); + void init(); + void calculate_chi(); // ComplexMatrix may not be a best filetype to store the electronic wave functions - ComplexMatrix *chi; // stochastic wavefunctions in the PW basis + ComplexMatrix* chi0; // origin stochastic wavefunctions in real space + ComplexMatrix* chi; // stochastic wavefunctions after orthogonalized with KS wavefunctions int nchi; @@ -31,8 +35,7 @@ class Stochastic_WF protected: - // Calculate random wave functions as stochastic wave functions - void random(ComplexMatrix &chi); + // check the properties of chi void check_chi(const ComplexMatrix *chi)const; diff --git a/ABACUS.develop/source/src_pw/wavefunc.cpp b/ABACUS.develop/source/src_pw/wavefunc.cpp index 7279f0f0f1..0551f8d9bb 100644 --- a/ABACUS.develop/source/src_pw/wavefunc.cpp +++ b/ABACUS.develop/source/src_pw/wavefunc.cpp @@ -573,7 +573,7 @@ void wavefunc::wfcinit_k(void) { arg = gkqg * Rcar[iw1][iw2][ir] * TWO_PI; phase = complex( cos(arg), -sin(arg) ); - overlap_aux[iw1][iw2][g][ir] += conj(wf.wanf2[ik](iw1,ig)) * wanf2_q[ik][iw2][ig] * phase/kv.nks; + overlap_aux[iw1][iw2][g][ir] += conj(wf.wanf2[ik](iw1,ig)) * wanf2_q[ik][iw2][ig] * phase/double(kv.nks); } } From c3f272a8c2ef7abf51f51405e656d08242fd090d Mon Sep 17 00:00:00 2001 From: Qianruipku Date: Thu, 4 Feb 2021 13:52:14 +0800 Subject: [PATCH 066/233] Add some problems to README --- ABACUS.develop/source/Makefile.vars | 12 ++++++------ ABACUS.develop/source/README | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ABACUS.develop/source/Makefile.vars b/ABACUS.develop/source/Makefile.vars index 13b6bedbfd..fcff7e531a 100644 --- a/ABACUS.develop/source/Makefile.vars +++ b/ABACUS.develop/source/Makefile.vars @@ -11,19 +11,19 @@ LAPACK_DIR = $(MKLROOT) #LAPACK_DIR = $(MKLROOT) #LAPACK_DIR = /public/intel2017/mkl -#FFTW_DIR = /home/mohan/1_Software/impi_fftw-3.3.8 -FFTW_DIR = /home/qianrui/intelcompile/impi_fftw +FFTW_DIR = /home/mohan/1_Software/impi_fftw-3.3.8 +#FFTW_DIR = /home/qianrui/intelcompile/impi_fftw #FFTW_DIR = /public/udata/xiaohui/software/fftw2 #FFTW_DIR =/opt/fftw/3.3.6-p12/intel/2017.update4 #FFTW_DIR = /public/fftw-3.3.8 -#BOOST_DIR = /home/mohan/1_Software/impi_boost-1.70.0 -BOOST_DIR = /home/qianrui/intelcompile/impi_boost +BOOST_DIR = /home/mohan/1_Software/impi_boost-1.70.0 +#BOOST_DIR = /home/qianrui/intelcompile/impi_boost #BOOST_DIR = /public/udata/xiaohui/software/boost_1_39_0 #BOOST_DIR = /opt/boost/1.64.0 -#ELPA_DIR = /home/mohan/1_Software/impi_elpa-16.05.005 -ELPA_DIR = /home/qianrui/intelcompile/impi_elpa +ELPA_DIR = /home/mohan/1_Software/impi_elpa-16.05.005 +#ELPA_DIR = /home/qianrui/intelcompile/impi_elpa #ELPA_DIR = /public/udata/xiaohui/ELPA-2016.05.004 #ELPA_DIR = /opt/elpa/intel_2017_update4 diff --git a/ABACUS.develop/source/README b/ABACUS.develop/source/README index 1277ab2143..3e5730fb12 100644 --- a/ABACUS.develop/source/README +++ b/ABACUS.develop/source/README @@ -10,7 +10,8 @@ The code should be reconstructed with the following details: 1) the TDDFT module should be relocated. 2) the inclusion of files in vdw3 should be changed. - +3) Is is necessary to include +4) There is a segmental fault when use ABACUS compiled with gnu-mpich ----------------------------------------------------------------------- Unitesets should include From dd3d6e2d2d35c6cb6cc507ade08b380481d71c58 Mon Sep 17 00:00:00 2001 From: mohanchen Date: Thu, 4 Feb 2021 14:05:59 +0800 Subject: [PATCH 067/233] change dc_driv.h to driver.h, the same for .cpp files --- ABACUS.develop/source/Makefile.Objects | 2 +- .../source/{dc_driv.cpp => driver.cpp} | 171 +++++++++--------- ABACUS.develop/source/{dc_driv.h => driver.h} | 12 +- ABACUS.develop/source/input.cpp | 150 +++++++-------- ABACUS.develop/source/main.cpp | 4 +- .../source/src_parallel/parallel_grid.h | 3 +- 6 files changed, 154 insertions(+), 188 deletions(-) rename ABACUS.develop/source/{dc_driv.cpp => driver.cpp} (85%) rename ABACUS.develop/source/{dc_driv.h => driver.h} (76%) diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 66fe2ec743..4267553613 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -26,7 +26,7 @@ chem_pot.o\ cg_lcao.o\ cg_precon.o\ -OBJS_DC=dc_driv.o\ +OBJS_DC=driver.o\ input.o \ input_conv.o\ run_pw.o\ diff --git a/ABACUS.develop/source/dc_driv.cpp b/ABACUS.develop/source/driver.cpp similarity index 85% rename from ABACUS.develop/source/dc_driv.cpp rename to ABACUS.develop/source/driver.cpp index b342dcc7ae..5ffacb6ce1 100644 --- a/ABACUS.develop/source/dc_driv.cpp +++ b/ABACUS.develop/source/driver.cpp @@ -1,4 +1,4 @@ -#include "dc_driv.h" +#include "driver.h" #include "run_pw.h" #include "run_lcao.h" #include "input.h" @@ -11,15 +11,15 @@ #include "src_pw/cal_test0.h" #include "src_pw/winput.h" -DC_Driv::DC_Driv(){} +Driver::Driver(){} -DC_Driv::~DC_Driv(){} +Driver::~Driver(){} -void DC_Driv::init() +void Driver::init() { - TITLE("DC_Driv","init"); + TITLE("Driver","init"); time_t time_start = std::time(NULL); @@ -59,9 +59,11 @@ void DC_Driv::init() } -void DC_Driv::reading(void) +void Driver::reading(void) { - timer::tick("DC_Driv","reading",'A'); + timer::tick("Driver","reading",'A'); + +//--------------------------------------------------------------------------------- // reading input files from the 'INPUT' object // the 'INPUT' is global and can be used anywhere, @@ -84,14 +86,70 @@ void DC_Driv::reading(void) OUT(ofs_running,"GRANK",GRANK+1); OUT(ofs_running,"GSIZE",GSIZE); - //---------------------------------- - // call frag_init - // * divide the k-points into NPOOL - // * setup the unit cell - // * do symmetry analysis - // * setup the k-points - //---------------------------------- - this->prepare(); + + +//--------------------------------------------------------------------------------- +// * initialize the NPOOL for k-points +// * initialize the input parameters for wannier functions +// * setup the unit cell +// * symmetry analysis +// * setup the k-points according to symmetry annalysis + +#ifdef __MPI + // (1) If k point number > 1, After reading in NPOOL, + // divide the NPROC processprs into NPOOL. + Pkpoints.init(); +#endif + + // (2) Read in parameters about wannier functions. + winput::Init( global_wannier_card ); + + //xiaohui move 3 lines, 2015-09-30 + //stringstream ss2; + //ss2 << global_out_dir << "INPUTw"; + //winput::Print( ss2.str() ); + + // (3) Print the parameters into INPUT file. + stringstream ss1; + ss1 << global_out_dir << global_in_card; + INPUT.Print( ss1.str() ); + //DONE(ofs_running,"READING CARDS"); + + + // (4) Setup the unitcell. + ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running); + DONE(ofs_running, "SETUP UNITCELL"); + + // (5) symmetry analysize. + if (SYMMETRY) + { + symm.analy_sys(); + DONE(ofs_running, "SYMMETRY"); + } + + // (6) Setup the k points according to symmetry. + kv.set( symm, global_kpoint_card, NSPIN, ucell.G, ucell.latvec ); + DONE(ofs_running,"INIT K-POINTS"); + + + // (7) check the number of basis, the warning should be moved to + // other places -- mohan 2021-01-30 + // mohan add 2011-01-5 + if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") + { + if( NLOCAL < NBANDS ) + { + WARNING_QUIT("UnitCell_pseudo::cal_nwfc","NLOCAL < NBANDS"); + } + else + { + //OUT(ofs_running,"NLOCAL",NLOCAL); + OUT(ofs_running,"NBASE",NLOCAL); + OUT(ofs_running,"NBANDS",NBANDS); + } + } + +//--------------------------------------------------------------------------------- // for LCAO basis, reading the orbitals and construct @@ -117,6 +175,7 @@ void DC_Driv::reading(void) Print_Info PI; PI.screen_output(); +//--------------------------------------------------------------------------------- // Initalize the plane wave basis set @@ -138,22 +197,23 @@ void DC_Driv::reading(void) } // mohan add 2010-09-13 - // init the grid, then the charge - // on grid can be distributed. - Pgrid.init(pw.ncx, pw.ncy, pw.ncz, pw.nczp, pw.nrxx, pw.nbz, pw.bz); // mohan add 2010-07-22, update 2011-05-04 + // initialize the real-space uniform grid for FFT and parallel + // distribution of plane waves + Pgrid.init(pw.ncx, pw.ncy, pw.ncz, pw.nczp, + pw.nrxx, pw.nbz, pw.bz); // mohan add 2010-07-22, update 2011-05-04 - timer::tick("DC_Driv","reading",'A'); + timer::tick("Driver","reading",'A'); return; } -void DC_Driv::atomic_world(void) +void Driver::atomic_world(void) { - TITLE("DC_Driv","atomic_world"); - timer::tick("DC_Driv","atomic_world",'A'); + TITLE("Driver","atomic_world"); + timer::tick("Driver","atomic_world",'A'); //xiaohui add 2013-09-01 if(BASIS_TYPE=="pw" || BASIS_TYPE=="lcao_in_pw") @@ -167,7 +227,7 @@ void DC_Driv::atomic_world(void) rl.lcao_line(); } - timer::tick("DC_Driv","atomic_world",'A'); + timer::tick("Driver","atomic_world",'A'); timer::finish( ofs_running ); Memory::print_all( ofs_running ) ; @@ -176,69 +236,4 @@ void DC_Driv::atomic_world(void) } -// * initialize the NPOOL for k-points -// * initialize the input parameters for wannier functions -// * setup the unit cell -// * symmetry analysis -// * setup the k-points according to symmetry annalysis -void DC_Driv::prepare(void) -{ - TITLE("Run_Frag","init"); - timer::tick("Run_Frag","init",'B'); - -#ifdef __MPI - // (1) If k point number > 1, After reading in NPOOL, - // divide the NPROC processprs into NPOOL. - Pkpoints.init(); -#endif - - // (2) Read in parameters about wannier functions. - winput::Init( global_wannier_card ); - - //xiaohui move 3 lines, 2015-09-30 - //stringstream ss2; - //ss2 << global_out_dir << "INPUTw"; - //winput::Print( ss2.str() ); - - // (3) Print the parameters into INPUT file. - stringstream ss1; - ss1 << global_out_dir << global_in_card; - INPUT.Print( ss1.str() ); - //DONE(ofs_running,"READING CARDS"); - - // (4) Setup the unitcell. - ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running); - DONE(ofs_running, "SETUP UNITCELL"); - // (5) symmetry analysize. - if (SYMMETRY) - { - symm.analy_sys(); - DONE(ofs_running, "SYMMETRY"); - } - - // (6) Setup the k points according to symmetry. - kv.set( symm, global_kpoint_card, NSPIN, ucell.G, ucell.latvec ); - DONE(ofs_running,"INIT K-POINTS"); - - - // (7) check the number of basis, the warning should be moved to - // other places -- mohan 2021-01-30 - // mohan add 2011-01-5 - if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") - { - if( NLOCAL < NBANDS ) - { - WARNING_QUIT("UnitCell_pseudo::cal_nwfc","NLOCAL < NBANDS"); - } - else - { - //OUT(ofs_running,"NLOCAL",NLOCAL); - OUT(ofs_running,"NBASE",NLOCAL); - OUT(ofs_running,"NBANDS",NBANDS); - } - } - - timer::tick("Run_Frag","init",'B'); - return; -} diff --git a/ABACUS.develop/source/dc_driv.h b/ABACUS.develop/source/driver.h similarity index 76% rename from ABACUS.develop/source/dc_driv.h rename to ABACUS.develop/source/driver.h index 2044ffdd69..a1367abb87 100644 --- a/ABACUS.develop/source/dc_driv.h +++ b/ABACUS.develop/source/driver.h @@ -2,15 +2,15 @@ // AUTHOR : mohan // DATE : 2011-06-12 //========================================================== -#ifndef DC_DRIV_H -#define DC_DRIV_H +#ifndef DRIVER_H +#define DRIVER_H -class DC_Driv +class Driver { public: - DC_Driv(); - ~DC_Driv(); + Driver(); + ~Driver(); void init(); @@ -19,8 +19,6 @@ class DC_Driv // reading the parameters void reading(); - void prepare(); - // do stuff, have fun! void atomic_world(); diff --git a/ABACUS.develop/source/input.cpp b/ABACUS.develop/source/input.cpp index 80913922cd..4f215bd56c 100644 --- a/ABACUS.develop/source/input.cpp +++ b/ABACUS.develop/source/input.cpp @@ -20,7 +20,9 @@ Input::Input() angle2 = new double[1]; // all values set in Default } -Input::~Input() { + +Input::~Input() +{ delete[] angle1; delete[] angle2; } @@ -58,39 +60,10 @@ void Input::Init(const string &fn) // OTHRE CLASS MEMBER FUNCTION : // NAME : Run::make_dir( dir name : OUT.suffix) //---------------------------------------------------------- - //Global_File::make_dir_out( this->suffix , this->calculation, MY_RANK, this->linear_scaling, this->out_alllog); xiaohui modify 2013-09-01, delete "this->linear_scaling" Global_File::make_dir_out( this->suffix , this->calculation, MY_RANK, this->out_alllog); //xiaohui add 2013-09-01 Check(); time_t time_now = time(NULL); - //xiaohui modify 2015-03-25 - /* - ofs_running << " ------------------------------------------------------------------------------------" << endl; - ofs_running << " " << endl; - ofs_running << " ############ " << endl; - ofs_running << " ################## " << endl; - ofs_running << " ##### #### ##### " << endl; - ofs_running << " ### ########## " << endl; - ofs_running << " ##### ##### ############## ###### ### ############ " << endl; - ofs_running << " ######## ######### ################# #### #### ################ " << endl; - ofs_running << " ########### ###### #### #### ####### #### #### ###### " << endl; - ofs_running << " #### ########## #### #### ###### #### #### ######### #### " << endl; - ofs_running << " #### #### #### #### ########### #### #### ########### #### " << endl; - ofs_running << " #### #### ##### ##### #### #### #### #### " << endl; - ofs_running << " #### #### ################ #### #### ################# " << endl; - ofs_running << " #### #### ############## #### #### ############### " << endl; - ofs_running << " ##### " << endl; - ofs_running << " ###### " << endl; - ofs_running << " #### " << endl; - ofs_running << " " << endl; - ofs_running << " ------------------------------------------------------------------------------------" << endl; - - ofs_running << " " << endl; - ofs_running << " WELCOME TO MESIA " << endl; - ofs_running << " " << endl; - ofs_running << " 'Massive Electronic simulation based on Systematically Improvable Atomic bases' " << endl; - ofs_running << " " << endl; - */ ofs_running << " " << endl; ofs_running << " WELCOME TO ABACUS " << endl; ofs_running << " " << endl; @@ -102,7 +75,6 @@ void Input::Init(const string &fn) ofs_running << setiosflags(ios::right); - #ifdef __MPI //ofs_running << " Version: Parallel, under ALPHA test" << endl; ofs_running << " Version: Parallel, in development" << endl; @@ -321,27 +293,27 @@ void Input::Default(void) md_tstep=1; //reduec md_delt every md_tstep step. md_delt=1.0; */ -//md and related parameters(added by zheng da ye) - md_mdtype=1; - md_tauthermo=0; - md_taubaro=0; - md_dt=-1; - md_nresn=3; - md_nyosh=3; - md_qmass=1; - md_tfirst=-1; //kelvin - md_tlast=md_tfirst; - md_dumpmdfred=1; - md_mdoutpath="mdoutput"; + //md and related parameters(added by zheng da ye) + md_mdtype=1; + md_tauthermo=0; + md_taubaro=0; + md_dt=-1; + md_nresn=3; + md_nyosh=3; + md_qmass=1; + md_tfirst=-1; //kelvin + md_tlast=md_tfirst; + md_dumpmdfred=1; + md_mdoutpath="mdoutput"; md_domsd=0; - md_domsdatom=0; - md_rstmd=0; - md_outputstressperiod=1; - md_fixtemperature=1; - md_ediff=1e-4; + md_domsdatom=0; + md_rstmd=0; + md_outputstressperiod=1; + md_fixtemperature=1; + md_ediff=1e-4; md_ediffg=1e-3; - md_msdstartTime=1; -//end of zhengdaye's add. + md_msdstartTime=1; + //end of zhengdaye's add. /* //---------------------------------------------------------- // vdwD2 //Peize Lin add 2014-03-31, update 2015-09-30 @@ -382,46 +354,46 @@ void Input::Default(void) //----------------------------------------------------------- // spectrum // pengfei Li add 2016-11-23 //----------------------------------------------------------- - //epsilon=false; - //epsilon_choice=0; - spectral_type="None"; - spectral_method=0; - kernel_type="rpa"; - eels_method=0; - absorption_method=0; - system="bulk"; - eta=0.05; - domega=0.01; - nomega=300; - ecut_chi=1; - //oband=1; - q_start[0]=0.1; q_start[1]=0.1; q_start[2]=0.1; - q_direct[0]=1; q_direct[1]=0; q_direct[2]=0; - //start_q=1; - //interval_q=1; - nq=1; - out_epsilon=true; - out_chi=false; - out_chi0=false; - fermi_level=0.0; - coulomb_cutoff=false; - - kmesh_interpolation=false; - for(int i=0; i<100; i++) - { - qcar[i][0] = 0.0; qcar[i][1] = 0.0; qcar[i][2] = 0.0; - } +//epsilon=false; +//epsilon_choice=0; + spectral_type="None"; + spectral_method=0; + kernel_type="rpa"; + eels_method=0; + absorption_method=0; + system="bulk"; + eta=0.05; + domega=0.01; + nomega=300; + ecut_chi=1; + //oband=1; + q_start[0]=0.1; q_start[1]=0.1; q_start[2]=0.1; + q_direct[0]=1; q_direct[1]=0; q_direct[2]=0; + //start_q=1; + //interval_q=1; + nq=1; + out_epsilon=true; + out_chi=false; + out_chi0=false; + fermi_level=0.0; + coulomb_cutoff=false; + + kmesh_interpolation=false; + for(int i=0; i<100; i++) + { + qcar[i][0] = 0.0; qcar[i][1] = 0.0; qcar[i][2] = 0.0; + } - lcao_box[0] = 10; lcao_box[1] = 10; lcao_box[2] = 10; - - //epsilon0 = false; - //intersmear = 0.01; - intrasmear = 0.0; - shift = 0.0; - metalcalc = false; - eps_degauss = 0.01; - - //epsilon0_choice = 0; + lcao_box[0] = 10; lcao_box[1] = 10; lcao_box[2] = 10; + + //epsilon0 = false; + //intersmear = 0.01; + intrasmear = 0.0; + shift = 0.0; + metalcalc = false; + eps_degauss = 0.01; + + //epsilon0_choice = 0; //added by zhengdy-soc noncolin = false; lspinorb = false; diff --git a/ABACUS.develop/source/main.cpp b/ABACUS.develop/source/main.cpp index 0745e9ccbb..1b75a81d54 100644 --- a/ABACUS.develop/source/main.cpp +++ b/ABACUS.develop/source/main.cpp @@ -2,7 +2,7 @@ // AUTHOR : mohan // DATE : 2008-11-10 //========================================================== -#include "dc_driv.h" +#include "driver.h" #include "src_parallel/parallel_global.h" #include "src_global/global_variable.h" #include @@ -18,7 +18,7 @@ int main(int argc, char **argv) void calculate() { // divide and conqure (DC) starts here, - DC_Driv DD; + Driver DD; DD.init(); #ifdef __MPI diff --git a/ABACUS.develop/source/src_parallel/parallel_grid.h b/ABACUS.develop/source/src_parallel/parallel_grid.h index 26b23e580c..388cd95960 100644 --- a/ABACUS.develop/source/src_parallel/parallel_grid.h +++ b/ABACUS.develop/source/src_parallel/parallel_grid.h @@ -12,7 +12,8 @@ class Parallel_Grid Parallel_Grid(); ~Parallel_Grid(); - void init(const int &ncx, const int &ncy, const int &ncz, const int &nczp, const int &nrxx, const int &nbz, const int &bz); + void init(const int &ncx, const int &ncy, const int &ncz, + const int &nczp, const int &nrxx, const int &nbz, const int &bz); void init_final_scf(const int &ncx, const int &ncy, const int &ncz, const int &nczp, const int &nrxx, const int &nbz, const int &bz); //LiuXh add 20180606 From 4fd944a6af428cef794c08bf9ef1208e88b25f85 Mon Sep 17 00:00:00 2001 From: mohanchen Date: Thu, 4 Feb 2021 15:03:53 +0800 Subject: [PATCH 068/233] merge input_conv and input_conv_fp functions --- ABACUS.develop/source/driver.cpp | 50 ++++------------------------ ABACUS.develop/source/input_conv.cpp | 9 +---- ABACUS.develop/source/input_conv.h | 2 +- ABACUS.develop/source/main.cpp | 35 ++++++++++++++++++- 4 files changed, 42 insertions(+), 54 deletions(-) diff --git a/ABACUS.develop/source/driver.cpp b/ABACUS.develop/source/driver.cpp index 5ffacb6ce1..788d746fe5 100644 --- a/ABACUS.develop/source/driver.cpp +++ b/ABACUS.develop/source/driver.cpp @@ -6,7 +6,6 @@ #include "src_lcao/global_fp.h" #include "src_pw/global.h" #include "src_global/print_info.h" - #include "src_pw/cal_test.h" #include "src_pw/cal_test0.h" #include "src_pw/winput.h" @@ -21,11 +20,6 @@ void Driver::init() { TITLE("Driver","init"); - time_t time_start = std::time(NULL); - - timer::start(); - - // (1) read the input parameters. this->reading(); @@ -34,25 +28,7 @@ void Driver::init() this->atomic_world(); - time_t time_finish= std::time(NULL); - - // print out information before ABACUS ends - cout << "\n START Time : " << ctime(&time_start); - cout << " FINISH Time : " << ctime(&time_finish); - cout << " TOTAL Time : " << difftime(time_finish, time_start) << endl; - cout << " SEE INFORMATION IN : "< 1, After reading in NPOOL, - // divide the NPROC processprs into NPOOL. + // (4) divide the NPROC processors into NPOOL for k-points parallelization. Pkpoints.init(); #endif - // (2) Read in parameters about wannier functions. + // (5) Read in parameters about wannier functions. winput::Init( global_wannier_card ); //xiaohui move 3 lines, 2015-09-30 diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index 359cc11293..433877ae9d 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -561,14 +561,7 @@ void Input_Conv::Convert(void) ppcell.cell_factor = INPUT.cell_factor; //LiuXh add 20180619 NEW_DM=INPUT.newDM; // Shen Yu add 2019/5/9 - timer::tick("Input_Conv","Convert",'B'); - return; -} -void Input_Conv::Convert_FP(void) -{ - TITLE("Input","Convert_FP"); - timer::tick("Input_Conv","Convert_FP",'B'); //---------------------------------------------------------- // main parameters / electrons / spin ( 2/16 ) //---------------------------------------------------------- @@ -618,7 +611,7 @@ void Input_Conv::Convert_FP(void) ORB.dR = INPUT.lcao_dr; ORB.Rmax = INPUT.lcao_rmax; - timer::tick("Input_Conv","Convert_FP",'B'); + timer::tick("Input_Conv","Convert",'B'); return; } diff --git a/ABACUS.develop/source/input_conv.h b/ABACUS.develop/source/input_conv.h index 92223bf7e7..a41cfe39d2 100644 --- a/ABACUS.develop/source/input_conv.h +++ b/ABACUS.develop/source/input_conv.h @@ -16,10 +16,10 @@ using namespace std; + namespace Input_Conv { void Convert(void); - void Convert_FP(void); } diff --git a/ABACUS.develop/source/main.cpp b/ABACUS.develop/source/main.cpp index 1b75a81d54..2811b7bc1c 100644 --- a/ABACUS.develop/source/main.cpp +++ b/ABACUS.develop/source/main.cpp @@ -5,24 +5,57 @@ #include "driver.h" #include "src_parallel/parallel_global.h" #include "src_global/global_variable.h" +#include "src_global/timer.h" + #include + void calculate(); int main(int argc, char **argv) { Parallel_Global::read_mpi_parameters(argc,argv); + calculate(); + return 0; } + void calculate() { - // divide and conqure (DC) starts here, + + time_t time_start = std::time(NULL); + + timer::start(); + + //---------------------------------------------------------- + // main program for doing electronic structure calculations + //---------------------------------------------------------- Driver DD; DD.init(); + time_t time_finish= std::time(NULL); + + // print out information before ABACUS ends + cout << "\n START Time : " << ctime(&time_start); + cout << " FINISH Time : " << ctime(&time_finish); + cout << " TOTAL Time : " << difftime(time_finish, time_start) << endl; + cout << " SEE INFORMATION IN : "< Date: Thu, 4 Feb 2021 15:12:00 +0800 Subject: [PATCH 069/233] delete the linearscaling line --- ABACUS.develop/source/Makefile.Objects | 1 - ABACUS.develop/source/driver.cpp | 14 ++-- ABACUS.develop/source/run_lcao.h | 4 +- ABACUS.develop/source/run_linearscaling.cpp | 71 --------------------- ABACUS.develop/source/run_linearscaling.h | 25 -------- ABACUS.develop/source/run_pw.h | 2 +- 6 files changed, 12 insertions(+), 105 deletions(-) delete mode 100644 ABACUS.develop/source/run_linearscaling.cpp delete mode 100644 ABACUS.develop/source/run_linearscaling.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 4267553613..21fcce5111 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -31,7 +31,6 @@ input.o \ input_conv.o\ run_pw.o\ run_lcao.o\ -run_linearscaling.o\ OBJS_PW_BASIC=functional.o \ xc_functional.o\ diff --git a/ABACUS.develop/source/driver.cpp b/ABACUS.develop/source/driver.cpp index 788d746fe5..1cd77c115b 100644 --- a/ABACUS.develop/source/driver.cpp +++ b/ABACUS.develop/source/driver.cpp @@ -177,16 +177,20 @@ void Driver::atomic_world(void) TITLE("Driver","atomic_world"); timer::tick("Driver","atomic_world",'A'); - //xiaohui add 2013-09-01 + + //-------------------------------------------------- + // choose basis sets: + // pw: plane wave basis set + // lcao_in_pw: LCAO expaned by plane wave basis set + // lcao: linear combination of atomic orbitals + //-------------------------------------------------- if(BASIS_TYPE=="pw" || BASIS_TYPE=="lcao_in_pw") { - Run_pw rp; - rp.plane_wave_line(); + Run_pw::plane_wave_line(); } else if(BASIS_TYPE=="lcao") { - Run_lcao rl; - rl.lcao_line(); + Run_lcao::lcao_line(); } timer::tick("Driver","atomic_world",'A'); diff --git a/ABACUS.develop/source/run_lcao.h b/ABACUS.develop/source/run_lcao.h index 2ebdbb3690..ac21da60c6 100644 --- a/ABACUS.develop/source/run_lcao.h +++ b/ABACUS.develop/source/run_lcao.h @@ -11,13 +11,13 @@ class Run_lcao { -public: + public: Run_lcao(); ~Run_lcao(); // perform Linear Combination of Atomic Orbitals (LCAO) calculations - void lcao_line(void); + static void lcao_line(void); }; diff --git a/ABACUS.develop/source/run_linearscaling.cpp b/ABACUS.develop/source/run_linearscaling.cpp deleted file mode 100644 index 0a50c2cde3..0000000000 --- a/ABACUS.develop/source/run_linearscaling.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "run_linearscaling.h" -#include "src_pw/global.h" -#include "input.h" -#include "src_pw/algorithms.h" -#include "src_pw/pseudopot_cell_us.h" -#include "src_lcao/sltk_atom_arrange.h" -#include "src_lcao/local_orbital_ions.h" - -Run_linearscaling::Run_linearscaling(){} -Run_linearscaling::~Run_linearscaling(){} - - -void Run_linearscaling::linear_scaling_line(void) -{ - TITLE("Run_Frag","linear_scaling_line"); - - // (2) Init the charge density. - CHR.init(); - DONE(ofs_running,"INIT CHARGE"); - - // (3) Init the potential. - pot.init(pw.nrxx); - DONE(ofs_running,"INIT POTENTIAL"); - - // declration - enum use_wf_coef {SOME_PW, ALL_LO}; - // generate object - use_wf_coef uoc = ALL_LO; - - switch (uoc) - { - case ALL_LO: - - // (4) Init the local wave functions. - wf.init_local(); - - // (5) Init the FFT. - UFFT.allocate(); - - // (6) Init the hamiltonian. - hm.init(); - - // (7) Init the local part of NC pseudopotential. - ppcell.init_vloc(); - - // (8) Init the potential. - pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs - DONE(ofs_running,"INIT ALL_LO"); - break; - - case SOME_PW: - wf.init(kv.nks); - UFFT.allocate(); - ppcell.init(ucell.ntype); - hm.init(); - ppcell.init_vloc(); - ppcell.init_vnl(); - pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs - pot.newd();//once - DONE(ofs_running,"INIT POTENTIAL"); - wf.wfcinit(); - DONE(ofs_running,"INIT SOME_PW"); - break; - } - - // (9) Begin the ion iteration. - Local_Orbital_Ions ions; - ions.opt_ions(); - - return; -} diff --git a/ABACUS.develop/source/run_linearscaling.h b/ABACUS.develop/source/run_linearscaling.h deleted file mode 100644 index 1df5fe587f..0000000000 --- a/ABACUS.develop/source/run_linearscaling.h +++ /dev/null @@ -1,25 +0,0 @@ -//========================================================== -// AUTHOR : mohan -// DATE : 2021-02-01 -//========================================================== -#ifndef RUN_LINEARSCALING_H -#define RUN_LINEARSCALING_H - -#include "src_pw/tools.h" -#include "input.h" - -class Run_linearscaling -{ - -public: - - Run_linearscaling(); - ~Run_linearscaling(); - - // perform linear-scaling calculations for sparse matrix H and S - // useless now - void linear_scaling_line(void); - -}; - -#endif diff --git a/ABACUS.develop/source/run_pw.h b/ABACUS.develop/source/run_pw.h index 77e2fa8549..7a9a3325aa 100644 --- a/ABACUS.develop/source/run_pw.h +++ b/ABACUS.develop/source/run_pw.h @@ -17,7 +17,7 @@ class Run_pw ~Run_pw(); // perform plane wave basis calculations - void plane_wave_line(void); + static void plane_wave_line(void); }; From 6c0538680b2c8ac5276f7d660ddaa5d65dc228ab Mon Sep 17 00:00:00 2001 From: Qianruipku Date: Fri, 5 Feb 2021 15:32:55 +0800 Subject: [PATCH 070/233] updage sto*.cpp --- ABACUS.develop/source/Makefile.vars | 12 ++++++------ ABACUS.develop/source/src_pw/sto_hchi.cpp | 18 ++++++++++++++++++ ABACUS.develop/source/src_pw/sto_hchi.h | 1 + ABACUS.develop/source/src_pw/sto_wf.cpp | 9 ++++++--- ABACUS.develop/source/src_pw/sto_wf.h | 8 +++++--- 5 files changed, 36 insertions(+), 12 deletions(-) diff --git a/ABACUS.develop/source/Makefile.vars b/ABACUS.develop/source/Makefile.vars index fcff7e531a..13b6bedbfd 100644 --- a/ABACUS.develop/source/Makefile.vars +++ b/ABACUS.develop/source/Makefile.vars @@ -11,19 +11,19 @@ LAPACK_DIR = $(MKLROOT) #LAPACK_DIR = $(MKLROOT) #LAPACK_DIR = /public/intel2017/mkl -FFTW_DIR = /home/mohan/1_Software/impi_fftw-3.3.8 -#FFTW_DIR = /home/qianrui/intelcompile/impi_fftw +#FFTW_DIR = /home/mohan/1_Software/impi_fftw-3.3.8 +FFTW_DIR = /home/qianrui/intelcompile/impi_fftw #FFTW_DIR = /public/udata/xiaohui/software/fftw2 #FFTW_DIR =/opt/fftw/3.3.6-p12/intel/2017.update4 #FFTW_DIR = /public/fftw-3.3.8 -BOOST_DIR = /home/mohan/1_Software/impi_boost-1.70.0 -#BOOST_DIR = /home/qianrui/intelcompile/impi_boost +#BOOST_DIR = /home/mohan/1_Software/impi_boost-1.70.0 +BOOST_DIR = /home/qianrui/intelcompile/impi_boost #BOOST_DIR = /public/udata/xiaohui/software/boost_1_39_0 #BOOST_DIR = /opt/boost/1.64.0 -ELPA_DIR = /home/mohan/1_Software/impi_elpa-16.05.005 -#ELPA_DIR = /home/qianrui/intelcompile/impi_elpa +#ELPA_DIR = /home/mohan/1_Software/impi_elpa-16.05.005 +ELPA_DIR = /home/qianrui/intelcompile/impi_elpa #ELPA_DIR = /public/udata/xiaohui/ELPA-2016.05.004 #ELPA_DIR = /opt/elpa/intel_2017_update4 diff --git a/ABACUS.develop/source/src_pw/sto_hchi.cpp b/ABACUS.develop/source/src_pw/sto_hchi.cpp index 8ece995851..7b0777f8b8 100644 --- a/ABACUS.develop/source/src_pw/sto_hchi.cpp +++ b/ABACUS.develop/source/src_pw/sto_hchi.cpp @@ -10,6 +10,24 @@ Stochastic_Hchi::~Stochastic_Hchi() { } +void Stochastic_Hchi:: Hchi() +{ + //------------------------------------ + //(1) the kinetical energy. + //------------------------------------ + if(T_IN_H) + { + + } + + //------------------------------------ + //(2) the local potential. + //------------------------------------ + if(VL_IN_H) + { + + } +} void Stochastic_Hchi::orthogonal_to_psi() { diff --git a/ABACUS.develop/source/src_pw/sto_hchi.h b/ABACUS.develop/source/src_pw/sto_hchi.h index e862c48f36..b9c0c6292b 100644 --- a/ABACUS.develop/source/src_pw/sto_hchi.h +++ b/ABACUS.develop/source/src_pw/sto_hchi.h @@ -22,6 +22,7 @@ class Stochastic_Hchi // constructor and deconstructor Stochastic_Hchi(); ~Stochastic_Hchi(); + void Hchi(); private: diff --git a/ABACUS.develop/source/src_pw/sto_wf.cpp b/ABACUS.develop/source/src_pw/sto_wf.cpp index e1f7d79129..daf6903d34 100644 --- a/ABACUS.develop/source/src_pw/sto_wf.cpp +++ b/ABACUS.develop/source/src_pw/sto_wf.cpp @@ -16,16 +16,19 @@ Stochastic_WF::~Stochastic_WF() void Stochastic_WF::init() { - int nrxx = 1; + //wait for init + int nrxx; + int nx,ny,nz; + complex ui(0,1); delete[] chi0; //We temporarily init one group of orbitals for all k points. //This save memories. chi0 = new ComplexMatrix[1]; - chi0[0].create(nchi,nrxx,0); + chi0[0].create(nchip,nrxx,0); //init with random number - for(int i=0; i Date: Fri, 5 Feb 2021 16:13:18 +0800 Subject: [PATCH 071/233] Add some global variables for stochastic method --- ABACUS.develop/source/Makefile.vars | 12 ++++++------ ABACUS.develop/source/input.cpp | 14 ++++++++++++++ ABACUS.develop/source/input.h | 2 ++ ABACUS.develop/source/input_conv.cpp | 2 ++ ABACUS.develop/source/src_pw/global.cpp | 1 + ABACUS.develop/source/src_pw/global.h | 1 + ABACUS.develop/source/src_pw/sto_che.h | 1 + ABACUS.develop/source/src_pw/sto_hchi.h | 3 ++- ABACUS.develop/source/src_pw/sto_wf.h | 6 +++--- 9 files changed, 32 insertions(+), 10 deletions(-) diff --git a/ABACUS.develop/source/Makefile.vars b/ABACUS.develop/source/Makefile.vars index 13b6bedbfd..fcff7e531a 100644 --- a/ABACUS.develop/source/Makefile.vars +++ b/ABACUS.develop/source/Makefile.vars @@ -11,19 +11,19 @@ LAPACK_DIR = $(MKLROOT) #LAPACK_DIR = $(MKLROOT) #LAPACK_DIR = /public/intel2017/mkl -#FFTW_DIR = /home/mohan/1_Software/impi_fftw-3.3.8 -FFTW_DIR = /home/qianrui/intelcompile/impi_fftw +FFTW_DIR = /home/mohan/1_Software/impi_fftw-3.3.8 +#FFTW_DIR = /home/qianrui/intelcompile/impi_fftw #FFTW_DIR = /public/udata/xiaohui/software/fftw2 #FFTW_DIR =/opt/fftw/3.3.6-p12/intel/2017.update4 #FFTW_DIR = /public/fftw-3.3.8 -#BOOST_DIR = /home/mohan/1_Software/impi_boost-1.70.0 -BOOST_DIR = /home/qianrui/intelcompile/impi_boost +BOOST_DIR = /home/mohan/1_Software/impi_boost-1.70.0 +#BOOST_DIR = /home/qianrui/intelcompile/impi_boost #BOOST_DIR = /public/udata/xiaohui/software/boost_1_39_0 #BOOST_DIR = /opt/boost/1.64.0 -#ELPA_DIR = /home/mohan/1_Software/impi_elpa-16.05.005 -ELPA_DIR = /home/qianrui/intelcompile/impi_elpa +ELPA_DIR = /home/mohan/1_Software/impi_elpa-16.05.005 +#ELPA_DIR = /home/qianrui/intelcompile/impi_elpa #ELPA_DIR = /public/udata/xiaohui/ELPA-2016.05.004 #ELPA_DIR = /opt/elpa/intel_2017_update4 diff --git a/ABACUS.develop/source/input.cpp b/ABACUS.develop/source/input.cpp index 4f215bd56c..e5f96b7e9a 100644 --- a/ABACUS.develop/source/input.cpp +++ b/ABACUS.develop/source/input.cpp @@ -123,7 +123,9 @@ void Input::Default(void) calculation = "scf"; ntype = 0; nbands = 0; + nbands_sto = 0; nbands_istate = 5; + nche_sto = 0; npool = 1; berry_phase = false; gdir = 3; @@ -541,10 +543,18 @@ bool Input::Read(const string &fn) else if (strcmp("nbands", word) == 0)// number of atom bands { read_value(ifs, nbands); + } + else if (strcmp("nbands_sto", word) == 0)//number of stochastic bands + { + read_value(ifs, nbands_sto); } else if (strcmp("nbands_istate", word) == 0)// number of atom bands { read_value(ifs, nbands_istate); + } + else if (strcmp("nche_sto", word) == 0)// Chebyshev expansion order + { + read_value(ifs, nche_sto); } else if (strcmp("npool", word) == 0)// number of pools { @@ -1843,7 +1853,9 @@ void Input::Bcast() Parallel_Common::bcast_string( calculation ); Parallel_Common::bcast_int( ntype ); Parallel_Common::bcast_int( nbands ); + Parallel_Common::bcast_int( nbands_sto ); Parallel_Common::bcast_int( nbands_istate ); + Parallel_Common::bcast_int( nche_sto ); Parallel_Common::bcast_int( npool ); Parallel_Common::bcast_bool( berry_phase ); Parallel_Common::bcast_int( gdir ); @@ -2894,7 +2906,9 @@ void Input::Print(const string &fn)const OUTP(ofs,"ntype",ntype,"atom species number"); OUTP(ofs,"nspin",nspin,"1: single spin; 2: up and down spin; 4: noncollinear spin"); OUTP(ofs,"nbands",nbands,"number of bands"); + OUTP(ofs,"nbands_sto",nbands_sto,"number of stochastic bands"); OUTP(ofs,"nbands_istate",nbands_istate,"number of bands around Fermi level for istate calulation"); + OUTP(ofs,"nche_sto",nche_sto,"number of orders for Chebyshev expansion in stochastic DFT"); OUTP(ofs,"symmetry",symmetry,"turn symmetry on or off"); OUTP(ofs,"nelec",nelec,"input number of electrons"); //OUTP(ofs,"lmax1",lmax1,"lmax"); diff --git a/ABACUS.develop/source/input.h b/ABACUS.develop/source/input.h index e76062d02e..a83f36d00b 100644 --- a/ABACUS.develop/source/input.h +++ b/ABACUS.develop/source/input.h @@ -40,7 +40,9 @@ class Input // "relax" : cell relaxations int ntype; // number of atom types int nbands; // number of bands + int nbands_sto; // number of stochastic bands //qianrui 2021-2-5 int nbands_istate; // number of bands around fermi level for istate calculation. + int nche_sto; // number of orders for Chebyshev expansion in stochastic DFT //qinarui 2021-2-5 bool symmetry; // turn on symmetry or not int npool; // ecch pool is for one k point diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index 433877ae9d..13685d4354 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -50,6 +50,8 @@ void Input_Conv::Convert(void) NPOOL = INPUT.npool; // mohan add 2010-06-09 CALCULATION = INPUT.calculation; // 2 BERRY_PHASE = INPUT.berry_phase; // 3 + STO_WF.nchi = INPUT.nbands_sto; // qianrui add 2021-2-5 + STO_WF.nche_sto = INPUT.nche_sto; EFIELD = INPUT.efield; diff --git a/ABACUS.develop/source/src_pw/global.cpp b/ABACUS.develop/source/src_pw/global.cpp index 4fddedf7e7..bda683443d 100644 --- a/ABACUS.develop/source/src_pw/global.cpp +++ b/ABACUS.develop/source/src_pw/global.cpp @@ -15,6 +15,7 @@ FFT fftwan; output out; PW_Basis pw; +Stochastic_WF STO_WF; energy en; wavefunc wf; Hamilt hm; diff --git a/ABACUS.develop/source/src_pw/global.h b/ABACUS.develop/source/src_pw/global.h index 616bdc663a..4269ba6660 100644 --- a/ABACUS.develop/source/src_pw/global.h +++ b/ABACUS.develop/source/src_pw/global.h @@ -39,6 +39,7 @@ extern kvect kv; extern output out; extern PW_Basis pw; +extern Stochastic_WF STO_WF; //qianrui add 2021-2-5 extern energy en; extern wavefunc wf; extern Hamilt hm; diff --git a/ABACUS.develop/source/src_pw/sto_che.h b/ABACUS.develop/source/src_pw/sto_che.h index 9e39f392ca..811634189e 100644 --- a/ABACUS.develop/source/src_pw/sto_che.h +++ b/ABACUS.develop/source/src_pw/sto_che.h @@ -15,6 +15,7 @@ class Stochastic_Chebychev // constructor and deconstructor Stochastic_Chebychev(); ~Stochastic_Chebychev(); + int norder; private: diff --git a/ABACUS.develop/source/src_pw/sto_hchi.h b/ABACUS.develop/source/src_pw/sto_hchi.h index b9c0c6292b..2b0572d834 100644 --- a/ABACUS.develop/source/src_pw/sto_hchi.h +++ b/ABACUS.develop/source/src_pw/sto_hchi.h @@ -1,6 +1,5 @@ #ifndef INCLUDE_STO_HCHI_H #define INCLUDE_STO_HCHI_H - #include "tools.h" //----------------------------------------------------- @@ -23,6 +22,7 @@ class Stochastic_Hchi Stochastic_Hchi(); ~Stochastic_Hchi(); void Hchi(); + private: @@ -30,6 +30,7 @@ class Stochastic_Hchi // such as CG) void orthogonal_to_psi(); + }; #endif// Eelectrons_Hchi diff --git a/ABACUS.develop/source/src_pw/sto_wf.h b/ABACUS.develop/source/src_pw/sto_wf.h index 3a433444d9..8f73faeeb3 100644 --- a/ABACUS.develop/source/src_pw/sto_wf.h +++ b/ABACUS.develop/source/src_pw/sto_wf.h @@ -2,7 +2,7 @@ #define STOCHASTIC_WF_H #include "tools.h" - +#include "sto_che.h" //qianrui 2021-2-4 //---------------------------------------------- @@ -25,10 +25,10 @@ class Stochastic_WF // ComplexMatrix may not be a best filetype to store the electronic wave functions ComplexMatrix* chi0; // origin stochastic wavefunctions in real space ComplexMatrix* chi; // stochastic wavefunctions after orthogonalized with KS wavefunctions - + Stochastic_Chebychev sto_che; int nchi; // Total number of stochatic obitals int nchip; // The number of stochatic obitals in current process - + int nche_sto; // number of orders for Chebyshev expansion int nbands_diag; // number of bands obtained from diagonalization From 6f7cbfc0ad8432657aadf5500d74ef618b066c21 Mon Sep 17 00:00:00 2001 From: Qianruipku Date: Fri, 5 Feb 2021 16:17:29 +0800 Subject: [PATCH 072/233] Create a new branch --- ABACUS.develop/source/Makefile.vars | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ABACUS.develop/source/Makefile.vars b/ABACUS.develop/source/Makefile.vars index fcff7e531a..13b6bedbfd 100644 --- a/ABACUS.develop/source/Makefile.vars +++ b/ABACUS.develop/source/Makefile.vars @@ -11,19 +11,19 @@ LAPACK_DIR = $(MKLROOT) #LAPACK_DIR = $(MKLROOT) #LAPACK_DIR = /public/intel2017/mkl -FFTW_DIR = /home/mohan/1_Software/impi_fftw-3.3.8 -#FFTW_DIR = /home/qianrui/intelcompile/impi_fftw +#FFTW_DIR = /home/mohan/1_Software/impi_fftw-3.3.8 +FFTW_DIR = /home/qianrui/intelcompile/impi_fftw #FFTW_DIR = /public/udata/xiaohui/software/fftw2 #FFTW_DIR =/opt/fftw/3.3.6-p12/intel/2017.update4 #FFTW_DIR = /public/fftw-3.3.8 -BOOST_DIR = /home/mohan/1_Software/impi_boost-1.70.0 -#BOOST_DIR = /home/qianrui/intelcompile/impi_boost +#BOOST_DIR = /home/mohan/1_Software/impi_boost-1.70.0 +BOOST_DIR = /home/qianrui/intelcompile/impi_boost #BOOST_DIR = /public/udata/xiaohui/software/boost_1_39_0 #BOOST_DIR = /opt/boost/1.64.0 -ELPA_DIR = /home/mohan/1_Software/impi_elpa-16.05.005 -#ELPA_DIR = /home/qianrui/intelcompile/impi_elpa +#ELPA_DIR = /home/mohan/1_Software/impi_elpa-16.05.005 +ELPA_DIR = /home/qianrui/intelcompile/impi_elpa #ELPA_DIR = /public/udata/xiaohui/ELPA-2016.05.004 #ELPA_DIR = /opt/elpa/intel_2017_update4 From 2baa7ca7933236c03e71520e79de6f4b3fba39ef Mon Sep 17 00:00:00 2001 From: Qianruipku Date: Sat, 6 Feb 2021 09:31:15 +0800 Subject: [PATCH 073/233] update sto*.cpp --- ABACUS.develop/source/src_pw/sto_che.cpp | 49 +++++++++++++++++++++++- ABACUS.develop/source/src_pw/sto_che.h | 10 ++++- ABACUS.develop/source/src_pw/sto_elec.h | 3 +- ABACUS.develop/source/src_pw/sto_wf.cpp | 4 ++ 4 files changed, 61 insertions(+), 5 deletions(-) diff --git a/ABACUS.develop/source/src_pw/sto_che.cpp b/ABACUS.develop/source/src_pw/sto_che.cpp index a935432ce7..27abd0e63f 100644 --- a/ABACUS.develop/source/src_pw/sto_che.cpp +++ b/ABACUS.develop/source/src_pw/sto_che.cpp @@ -1,12 +1,57 @@ -#include "tools.h" -#include "global.h" #include "sto_che.h" +#include "global.h" Stochastic_Chebychev::Stochastic_Chebychev() { + initplan = false; + norder = 0; } Stochastic_Chebychev::~Stochastic_Chebychev() { + fftw_destroy_plan(plancoef); + delete [] coef; + delete [] ccoef; +} +void Stochastic_Chebychev:: init() +{ + if(norder != 0) + { + norder2 = 2 * norder; + coef = new double [norder2]; + ccoef = new complex [norder2]; + initcoef = true; + } + else + { + WARNING_QUIT("Stochastic_Chebychev", "The Chebychev expansion order should be at least one!"); + } + } + +void Stochastic_Chebychev:: calcoef(double* fun(double)) +{ + if(!initcoef) WARNING_QUIT("Stochastic_Chebychev", "Please init coef first!"); + for(int i = 0; i < norder2; ++i) + { + coef = fun(cos((i+0.5)*PI/norder)); + } + if(!initplan) + { + initplan = true; + plancoef = fftw_plan_dft_1d(norder2, (fftw_complex *) coef, (fftw_complex *) ccoef, FFTW_FORWARD, FFTW_MEASURE); + } + fftw_execute(plancoef); + for(int i = 0; i *ccoef; //temperary complex coefficient + double *coef; //expansion coefficient of each order, only first norder coefficient will be used. + fftw_plan plancoef; + bool initplan, initcoef; private: diff --git a/ABACUS.develop/source/src_pw/sto_elec.h b/ABACUS.develop/source/src_pw/sto_elec.h index 7ed66853bf..4f09f53876 100644 --- a/ABACUS.develop/source/src_pw/sto_elec.h +++ b/ABACUS.develop/source/src_pw/sto_elec.h @@ -25,8 +25,7 @@ class Stochastic_Elec: private Threshold_Elec void scf_stochastic(const int &istep); private: - - Stochastic_WF swf; + Stochastic_WF swf; void c_bands(const int &istep); diff --git a/ABACUS.develop/source/src_pw/sto_wf.cpp b/ABACUS.develop/source/src_pw/sto_wf.cpp index daf6903d34..7e494f7ea4 100644 --- a/ABACUS.develop/source/src_pw/sto_wf.cpp +++ b/ABACUS.develop/source/src_pw/sto_wf.cpp @@ -20,6 +20,10 @@ void Stochastic_WF::init() int nrxx; int nx,ny,nz; + //distribute nchi for each process + nchip = int(nchi/NPROC_IN_POOL); + if(RANK_IN_POOL < nchi%NPROC_IN_POOL) ++nchip; + complex ui(0,1); delete[] chi0; From 5a305a1efe3ea86cf48c2c5ce0f3bfbd568108db Mon Sep 17 00:00:00 2001 From: mohan Date: Sat, 6 Feb 2021 10:38:05 +0800 Subject: [PATCH 074/233] update LCAO line --- .../source/src_ions/lattice_change_methods.h | 5 ++ .../source/src_lcao/local_orbital_ions.cpp | 3 +- .../source/src_lcao/local_orbital_ions.h | 14 +++- ABACUS.develop/source/src_pw/charge_extra.cpp | 80 +++++++++---------- ABACUS.develop/source/src_pw/charge_extra.h | 8 +- 5 files changed, 63 insertions(+), 47 deletions(-) diff --git a/ABACUS.develop/source/src_ions/lattice_change_methods.h b/ABACUS.develop/source/src_ions/lattice_change_methods.h index e6f372c744..968e189c06 100644 --- a/ABACUS.develop/source/src_ions/lattice_change_methods.h +++ b/ABACUS.develop/source/src_ions/lattice_change_methods.h @@ -8,14 +8,19 @@ using namespace std; class Lattice_Change_Methods { public: + Lattice_Change_Methods(); + ~Lattice_Change_Methods(); void allocate(void); + void cal_lattice_change(const int &istep, matrix &stress, const double &etot); bool get_converged(void)const {return Lattice_Change_Basic::converged;} + double get_ediff(void)const {return Lattice_Change_Basic::ediff;} + double get_largest_grad(void)const {return Lattice_Change_Basic::largest_grad;} private: diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index af2f236db2..9503d05cfe 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -45,7 +45,8 @@ void Local_Orbital_Ions::opt_ions(void) CE.allocate(); } - if(STRESS) // pengfei Li 2018-05-14 + // pengfei Li 2018-05-14 + if(STRESS) { LCM.allocate(); } diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.h b/ABACUS.develop/source/src_lcao/local_orbital_ions.h index 4c9ff9214d..7387dd71b2 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.h +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.h @@ -14,6 +14,7 @@ class Local_Orbital_Ions { + public: Local_Orbital_Ions(); ~Local_Orbital_Ions(); @@ -22,22 +23,27 @@ class Local_Orbital_Ions void opt_ions(void); void output_HS_R(void); //LiuXh add 2019-07-15 + //2014-06-06, xiaohui - mdnvt MDNVT ; - mdNVE MDNVE ; + mdnvt MDNVT ; + mdNVE MDNVE ; -private: + private: Ions_Move_Methods IMM; - //MD md; //bool force_stress(void); Lattice_Change_Methods LCM; + bool force_stress(const int &istep, int &force_step, int &stress_step); + int istep; + // electron charge density extropolation method Charge_Extra CE; + //choose md ensemble, zheng daye int mdtype; + void final_scf(void); }; diff --git a/ABACUS.develop/source/src_pw/charge_extra.cpp b/ABACUS.develop/source/src_pw/charge_extra.cpp index 3a77be23c9..162fd98d1c 100644 --- a/ABACUS.develop/source/src_pw/charge_extra.cpp +++ b/ABACUS.develop/source/src_pw/charge_extra.cpp @@ -56,12 +56,12 @@ Charge_Extra::~Charge_Extra() delete[] delta_rho[is]; //xiaohui add 2014-05-10, for second-order extrapolation delete[] delta_rho3[is]; - } - delete[] delta_rho1; - delete[] delta_rho2; - delete[] delta_rho; - //xiaohui add 2014-05-10, for second-order extrapolation - delete[] delta_rho3; + } + delete[] delta_rho1; + delete[] delta_rho2; + delete[] delta_rho; + //xiaohui add 2014-05-10, for second-order extrapolation + delete[] delta_rho3; //xiaohui add 2014-05-10, for second-order extrapolation delete[] pos_old1; @@ -278,23 +278,23 @@ xiaohui modify 2015-02-01*/ //xiaohui add 2014-05-03 CHR.atomic_rho(NSPIN,rho_atom_new); for(int is=0; is Date: Sat, 6 Feb 2021 11:52:24 +0800 Subject: [PATCH 075/233] Update dftu.cpp DFT+U:fix an error of Gamma_only --- ABACUS.develop/source/src_lcao/dftu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/dftu.cpp b/ABACUS.develop/source/src_lcao/dftu.cpp index 9885d412cf..057ac5ae70 100644 --- a/ABACUS.develop/source/src_lcao/dftu.cpp +++ b/ABACUS.develop/source/src_lcao/dftu.cpp @@ -767,7 +767,7 @@ void DFTU::cal_occup_m_gamma(const int iter) { for(int is=0; is Date: Sat, 6 Feb 2021 17:25:11 +0800 Subject: [PATCH 076/233] Update dftu.cpp SOC+U:some modifications --- ABACUS.develop/source/src_lcao/dftu.cpp | 394 ++++++++++++++++-------- 1 file changed, 267 insertions(+), 127 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/dftu.cpp b/ABACUS.develop/source/src_lcao/dftu.cpp index 057ac5ae70..a7ad490cc6 100644 --- a/ABACUS.develop/source/src_lcao/dftu.cpp +++ b/ABACUS.develop/source/src_lcao/dftu.cpp @@ -132,14 +132,25 @@ void DFTU::init() for(int n=0; n loc_occup_m; vector loc_occup_m_tmp; - if(NSPIN==1) + if(NSPIN==1 || NSPIN==4) { loc_occup_m.resize(1); loc_occup_m_tmp.resize(1); @@ -372,7 +397,7 @@ void DFTU::cal_occup_m_k(const int iter) loc_occup_m.at(0).create((2*l+1)*NPOL, (2*l+1)*NPOL); loc_occup_m_tmp.at(0).create((2*l+1)*NPOL, (2*l+1)*NPOL); } - else if(NSPIN==2 || NSPIN==4) + else if(NSPIN==2) { loc_occup_m.resize(2); loc_occup_m_tmp.resize(2); @@ -404,54 +429,26 @@ void DFTU::cal_occup_m_k(const int iter) const int irc = nu*ParaO.nrow + mu; const int irc_prime = mu_prime*ParaO.nrow + nu_prime; - // const int m0_all = m0 + ipol0*(2*l+1); - // const int m1_all = m1 + ipol1*(2*l+1); + const int m0_all = m0 + ipol0*(2*l+1); + const int m1_all = m1 + ipol1*(2*l+1); if( (nu>=0) && (mu>=0) ) { - if(NSPIN==1 || NSPIN==2) + for(int ik=0; ik=0) && (mu_prime>=0) ) { - if(NSPIN==1 || NSPIN==2) - { - for(int ik=0; ik> zeta; ifdftu.ignore(150, '\n'); - for(int is=0; is<2; is++) + if(NSPIN==1 || NSPIN==2) { - ifdftu >> word; - if(strcmp("spin", word) == 0) - { - ifdftu >> spin; - ifdftu.ignore(150, '\n'); - - double value = 0.0; - for(int m0=0; m0<2*L+1; m0++) + for(int is=0; is<2; is++) + { + ifdftu >> word; + if(strcmp("spin", word) == 0) + { + ifdftu >> spin; + ifdftu.ignore(150, '\n'); + + double value = 0.0; + for(int m0=0; m0<2*L+1; m0++) + { + for(int m1=0; m1<2*L+1; m1++) + { + ifdftu >> value; + locale.at(iat).at(L).at(zeta).at(spin)(m0, m1) = value; + } + ifdftu.ignore(150, '\n'); + } + } + else + { + cout << "WRONG IN READING LOCAL OCCUPATION NUMBER MATRIX FROM DFTU FILE" << endl; + exit(0); + } + } + } + else if(NSPIN==4) //SOC + { + double value = 0.0; + for(int m0=0; m0<2*L+1; m0++) + { + for(int ipol0=0; ipol0> value; - locale.at(iat).at(L).at(zeta).at(spin)(m0, m1) = value; + { + for(int ipol1=0; ipol1> value; + locale.at(iat).at(L).at(zeta).at(0)(m0_all, m1_all) = value; + } } - ifdftu.ignore(150, '\n'); - } + ifdftu.ignore(150, '\n'); + } } - else - { - cout << "WRONG IN READING LOCAL OCCUPATION NUMBER MATRIX FROM DFTU FILE" << endl; - exit(0); - } } } else @@ -1054,15 +1108,38 @@ void DFTU::local_occup_bcast() // if(!Yukawa && n!=0) continue; if(n!=0) continue; - for(int spin=0; spin<2; spin++) + if(NSPIN==1 || NSPIN==2) { - for(int m0=0; m0<2*l+1; m0++) - { - for(int m1=0; m1<2*l+1; m1++) + for(int spin=0; spin<2; spin++) + { + for(int m0=0; m0<2*l+1; m0++) { - MPI_Bcast(&locale.at(iat).at(l).at(n).at(spin)(m0, m1), 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); + for(int m1=0; m1<2*l+1; m1++) + { + MPI_Bcast(&locale.at(iat).at(l).at(n).at(spin)(m0, m1), 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); + } } - } + } + } + else if(NSPIN==4) //SOC + { + for(int m0=0; m0<2*L+1; m0++) + { + for(int ipol0=0; ipol0locale.at(iat).at(l).at(n).at(spin)(m0, m0); + for(int m1=0; m1<2*l+1; m1++) + { + nm2_trace += this->locale.at(iat).at(l).at(n).at(spin)(m0,m1)*this->locale.at(iat).at(l).at(n).at(spin)(m1,m0); + } + } + if(Yukawa) this->EU += 0.5*(this->U_Yukawa.at(T).at(l).at(n) - this->J_Yukawa.at(T).at(l).at(n))*(nm_trace - nm2_trace); + else this->EU += 0.5*(this->U[T] - this->J[T])*(nm_trace - nm2_trace); + } + } + else if(NSPIN==4) //SOC { double nm_trace = 0.0; double nm2_trace = 0.0; for(int m0=0; m0<2*l+1; m0++) { - nm_trace += this->locale.at(iat).at(l).at(n).at(spin)(m0, m0); - for(int m1=0; m1<2*l+1; m1++) + for(int ipol0=0; ipol0locale.at(iat).at(l).at(n).at(spin)(m0,m1)*this->locale.at(iat).at(l).at(n).at(spin)(m1,m0); + const int m0_all = m0 + (2*l+1)*ipol0; + nm_trace += this->locale.at(iat).at(l).at(n).at(0)(m0_all, m0_all); + + for(int m1=0; m1<2*l+1; m1++) + { + for(int ipol1=0; ipol1locale.at(iat).at(l).at(n).at(0)(m0_all,m1_all)*this->locale.at(iat).at(l).at(n).at(0)(m1_all, m0_all); + } + } } } if(Yukawa) this->EU += 0.5*(this->U_Yukawa.at(T).at(l).at(n) - this->J_Yukawa.at(T).at(l).at(n))*(nm_trace - nm2_trace); - else this->EU += 0.5*(this->U[T] - this->J[T])*(nm_trace - nm2_trace); + else this->EU += 0.5*(this->U[T] - this->J[T])*(nm_trace - nm2_trace); } } @@ -1146,16 +1252,34 @@ void DFTU::cal_energy_correction(const int istep) //calculate the double counting term included in eband for(int m1=0; m1<2*l+1; m1++) - { - for(int m2=0; m2<2*l+1; m2++) - { - for(int is=0; is<2; is++) - { - double VU = 0.0; - VU = get_onebody_eff_pot(T, iat, l, n, is, m1, m2, cal_type, 0); - EU_dc += VU*this->locale.at(iat).at(l).at(n).at(is)(m1,m2); - } - } + { + for(int ipol1=0; ipol1locale.at(iat).at(l).at(n).at(is)(m1_all,m2_all); + } + } + else if(NSPIN==4) //SOC + { + double VU = 0.0; + VU = get_onebody_eff_pot(T, iat, l, n, 0, m1_all, m2_all, cal_type, 0); + EU_dc += VU*this->locale.at(iat).at(l).at(n).at(0)(m1_all,m2_all); + } + } + } + } } }//end n }//end L @@ -1194,6 +1318,8 @@ void DFTU::cal_eff_pot_mat(const int ik, const int istep) if((CALCULATION=="scf" || CALCULATION=="relax" || CALCULATION=="cell-relax") && (!INPUT.omc) && istep==0 && this->iter_dftu==1) return; + int spin = kv.isk[ik]; + if(GAMMA_ONLY_LOCAL) ZEROS(VECTOR_TO_PTR(this->pot_eff_gamma.at(kv.isk[ik])), ParaO.nloc); else ZEROS(VECTOR_TO_PTR(this->pot_eff_k.at(ik)), ParaO.nloc); @@ -1322,21 +1448,12 @@ void DFTU::cal_eff_pot_mat(const int ik, const int istep) // if(m1==m2 && iwt1==iwt2) delta.at(irc) = 1.0; - if(NSPIN==1 || NSPIN==2) - { - int spin = kv.isk[ik]; - double val = get_onebody_eff_pot(T1, iat1, L1, n1, spin, m1, m2, cal_type, 1); - VU.at(irc) = complex(val, 0.0); - } - else if(NSPIN==4) //SOC - { - if(ipol1==ipol2) - { - int spin = ipol1; - double val = get_onebody_eff_pot(T1, iat1, L1, n1, spin, m1, m2, cal_type, 1); - VU.at(irc) = complex(val, 0.0); - } - } + int m1_all = m1 + (2*L1+1)*ipol1; + int m2_all = m2 + (2*L2+1)*ipol2; + + double val = get_onebody_eff_pot(T1, iat1, L1, n1, spin, m1_all, m2_all, cal_type, 1); + + VU.at(irc) = complex(val, 0.0); } } vector> potm_tmp(ParaO.nloc, complex(0.0, 0.0)); @@ -2853,16 +2970,39 @@ void DFTU::output() ofs_running << " zeta" << " " << n << endl; - for(int is=0; is<2; is++) + if(NSPIN==1 || NSPIN==2) { - ofs_running << "spin" << " " << is << endl; - for(int m0=0; m0<2*l+1; m0++) + for(int is=0; is<2; is++) { - for(int m1=0; m1<2*l+1; m1++) + ofs_running << "spin" << " " << is << endl; + for(int m0=0; m0<2*l+1; m0++) { - ofs_running << fixed << setw(12) << setprecision(8) << locale.at(iat).at(l).at(n).at(is)(m0, m1); + for(int m1=0; m1<2*l+1; m1++) + { + ofs_running << fixed << setw(12) << setprecision(8) << locale.at(iat).at(l).at(n).at(is)(m0, m1); + } + ofs_running << endl; } - ofs_running << endl; + } + } + else if(NSPIN==4) //SOC + { + for(int m0=0; m0<2*l+1; m0++) + { + for(int ipol0=0; ipol0 Date: Sat, 6 Feb 2021 21:01:10 +0800 Subject: [PATCH 077/233] delete the inclusion of boost filese in exx codes --- ABACUS.develop/source/src_lcao/abfs-vector3_order.h | 7 ++++--- .../source/src_lcao/exx_abfs-parallel-communicate-hexx.h | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/abfs-vector3_order.h b/ABACUS.develop/source/src_lcao/abfs-vector3_order.h index c2c5648dca..c15cca3e3e 100644 --- a/ABACUS.develop/source/src_lcao/abfs-vector3_order.h +++ b/ABACUS.develop/source/src_lcao/abfs-vector3_order.h @@ -8,8 +8,9 @@ #include "src_lcao/abfs.h" -#include -#include +// mohan comment out 2021-02-06 +//#include +//#include template class Abfs::Vector3_Order: public Vector3 { @@ -69,4 +70,4 @@ Abfs::Vector3_Order operator% ( const Abfs::Vector3_Order &v1, const Abfs: return Abfs::Vector3_Order{ mod(v1.x,v2.x), mod(v1.y,v2.y), mod(v1.z,v2.z) }; } -#endif // ABFS_VECTOR3_ORDER_H \ No newline at end of file +#endif // ABFS_VECTOR3_ORDER_H diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.h b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.h index ab3166a2a0..a37a543f6a 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.h @@ -12,8 +12,10 @@ #include #include #include -#include -#include + +// mohan comment out 2021-02-06 +//#include +//##include class Exx_Abfs::Parallel::Communicate::Hexx { @@ -154,4 +156,4 @@ class Exx_Abfs::Parallel::Communicate::Hexx Allreduce2 allreduce2; }; -#endif \ No newline at end of file +#endif From 678aec286a1241ca963bd4de700c4afecd8d7ea1 Mon Sep 17 00:00:00 2001 From: mohan Date: Sun, 7 Feb 2021 15:18:19 +0800 Subject: [PATCH 078/233] check the stress code, write notes of reconstructions in src_pw/stress.h --- .../source/src_ions/lattice_change_cg.cpp | 11 +- .../source/src_ions/lattice_change_cg.h | 13 +- .../source/src_lcao/local_orbital_ions.cpp | 89 +++--- .../source/src_lcao/stress_lcao.cpp | 266 ++++++++-------- ABACUS.develop/source/src_lcao/stress_lcao.h | 33 +- ABACUS.develop/source/src_pw/stress.cpp | 301 ++++++++++-------- ABACUS.develop/source/src_pw/stress.h | 164 ++++++---- 7 files changed, 481 insertions(+), 396 deletions(-) diff --git a/ABACUS.develop/source/src_ions/lattice_change_cg.cpp b/ABACUS.develop/source/src_ions/lattice_change_cg.cpp index 7488d6b131..8c85892009 100644 --- a/ABACUS.develop/source/src_ions/lattice_change_cg.cpp +++ b/ABACUS.develop/source/src_ions/lattice_change_cg.cpp @@ -1,11 +1,11 @@ #include "lattice_change_cg.h" #include "../src_pw/global.h" #include "lattice_change_basic.h" + +// the 'dim' variable is defined in Lattice_Change_Basic using namespace Lattice_Change_Basic; //=================== NOTES ======================== -// in vasp, it's like -// contolled by POTIM. // the approximate minimum of the total energy // is calculated from a cubic (or quadratic) // interpolation taking into account the change @@ -13,7 +13,7 @@ using namespace Lattice_Change_Basic; // ( 3 pieces of information ) // 1. trial step // 2. corrector step using cubic or quadratic interpolation -// 3. Check the force and see if we need brent method interpolation. +// 3. check the force and see if we need brent method interpolation. // 4. a new trial step.... // Brent's method is a complicated but popular // root-finding algorithm combining the bisection method, @@ -39,14 +39,19 @@ Lattice_Change_CG::~Lattice_Change_CG() void Lattice_Change_CG::allocate(void) { TITLE("Lattice_Change_CG","allocate"); + // mohan add 2021-02-07 + assert(dim>0); + delete[] lat0; delete[] grad0; delete[] cg_grad0; delete[] move0; + this->lat0 = new double[dim]; this->grad0 = new double[dim]; this->cg_grad0 = new double[dim]; this->move0 = new double[dim]; + ZEROS(lat0, dim); ZEROS(grad0, dim); ZEROS(cg_grad0, dim); diff --git a/ABACUS.develop/source/src_ions/lattice_change_cg.h b/ABACUS.develop/source/src_ions/lattice_change_cg.h index 50a5998743..0296249224 100644 --- a/ABACUS.develop/source/src_ions/lattice_change_cg.h +++ b/ABACUS.develop/source/src_ions/lattice_change_cg.h @@ -4,7 +4,9 @@ #include "../src_pw/tools.h" class Lattice_Change_CG { + public: + Lattice_Change_CG(); ~Lattice_Change_CG(); @@ -12,16 +14,23 @@ class Lattice_Change_CG void start(matrix &stress, const double &etot); private: + double* lat0; double* grad0; double* cg_grad0; double* move0; double e0; - // setup gradients. - void setup_cg_grad(double *grad, const double *grad0, double *cg_grad, const double *cg_grad0, const int &ncggrad, int &flag); + + // setup gradients. + void setup_cg_grad(double *grad, const double *grad0, double *cg_grad, + const double *cg_grad0, const int &ncggrad, int &flag); + void setup_move( double *move, double *cg_gradn, const double &trust_radius ); + void Brent(double &fa,double &fb,double &fc,double &xa,double &xb,double &xc,double &best_x,double &xpt); + void f_cal(const double *g0,const double *g1,const int &dim,double &f_value); + void third_order(const double &e0,const double &e1,const double &fa, const double &fb, const double x, double &best_x); }; diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index bd027e7e41..5c7773b2ac 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -52,6 +52,7 @@ void Local_Orbital_Ions::opt_ions(void) // pengfei Li 2018-05-14 if(STRESS) { + // allocate arrays related to changes of lattice vectors LCM.allocate(); } @@ -60,11 +61,15 @@ void Local_Orbital_Ions::opt_ions(void) { mdtype= INPUT.md_mdtype;//control md - if(mdtype==1||mdtype==2) { + // NVT ensemble + if(mdtype==1||mdtype==2) + { MDNVT.md_allocate(); MDNVT.initMD(); } - else if(mdtype==0){ + // NVE ensemble + else if(mdtype==0) + { MDNVE.md_allocate(); MDNVE.initMD(); } @@ -80,23 +85,19 @@ void Local_Orbital_Ions::opt_ions(void) if(OUT_LEVEL=="ie" || OUT_LEVEL=="m") //xiaohui add "m" option, 2015-09-16 { //add 2015-09-06, xiaohui - //cout << " -------------------------------------------" << endl; cout << " ---------------------------------------------------------" << endl; if(CALCULATION=="relax") { cout << " RELAX IONS : " << istep << endl; - //cout << " ---------------------------------------------------------" << endl; } else if(CALCULATION=="cell-relax") { cout << " RELAX CELL : " << stress_step << endl; cout << " RELAX IONS : " << force_step << " (in total: " << istep << ")" << endl; - //cout << " ---------------------------------------------------------" << endl; } else if(CALCULATION=="scf") { cout << " SELF-CONSISTENT : " << endl; - //cout << " ---------------------------------------------------------" << endl; } else if(CALCULATION=="md") //xiaohui add 2015-09-15 { @@ -104,12 +105,9 @@ void Local_Orbital_Ions::opt_ions(void) { cout<<" Molecular Dynamics (NVT) STEP "<< MDNVT.step_rst + istep<0) @@ -251,11 +230,13 @@ void Local_Orbital_Ions::opt_ions(void) // (9) S, T, Vnl, Vna matrix. UHM.set_ion(); - if(vdwd2.vdwD2) //Peize Lin add 2014-04-04, update 2019-04-26 + // Peize Lin add 2014-04-04, update 2019-04-26 + if(vdwd2.vdwD2) { vdwd2.energy(); } - if(vdwd3.vdwD3) //jiyy add 2019-05-18 + // jiyy add 2019-05-18 + else if(vdwd3.vdwD3) { vdwd3.energy(); } @@ -360,10 +341,22 @@ void Local_Orbital_Ions::opt_ions(void) //cout<<"CALCULATION:"<output_HS_R(); //LiuXh add 2019-07-15 + if(ParaO.out_hsR) + { + this->output_HS_R(); //LiuXh add 2019-07-15 + } time_t fstart = time(NULL); if (CALCULATION=="scf" || CALCULATION=="relax" || CALCULATION=="cell-relax") @@ -406,7 +402,8 @@ void Local_Orbital_Ions::opt_ions(void) } } } -///*LiuXh modify, 20180626 + + ///*LiuXh modify, 20180626 //if(FORCE || CALCULATION=="md" ) if(CALCULATION=="md" ) { @@ -426,8 +423,6 @@ void Local_Orbital_Ions::opt_ions(void) pot.init_pot( istep ); } } -//*/ - // need to destroy the matrix. @@ -843,10 +838,8 @@ void Local_Orbital_Ions::final_scf(void) // and allocate the space for H(R) and S(R). LNNR.cal_nnr(); LM.allocate_HS_R(LNNR.nnr); - } - if(!GAMMA_ONLY_LOCAL) - { - // need to first calculae lgd. + + // need to first calculae lgd. // using GridT.init. LNNR.cal_nnrg(GridT); //mohan add 2012-06-12 diff --git a/ABACUS.develop/source/src_lcao/stress_lcao.cpp b/ABACUS.develop/source/src_lcao/stress_lcao.cpp index a51b8b03b8..6238ec91d8 100644 --- a/ABACUS.develop/source/src_lcao/stress_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/stress_lcao.cpp @@ -46,9 +46,10 @@ void Stress_LCAO::start_stress(double overlap[][3],double tvnl_dphi[][3],double TITLE("Stress_LCAO","start_stress"); timer::tick("Stress_LCAO","start_stress",'E'); - - for(int i=0;i<3;i++){ - for(int j=0;j<3;j++){ + for(int i=0;i<3;i++) + { + for(int j=0;j<3;j++) + { scs[i][j] = 0.0; soverlap[i][j] = overlap[i][j]; stvnl_dphi[i][j] = tvnl_dphi[i][j]; @@ -67,10 +68,10 @@ void Stress_LCAO::start_stress(double overlap[][3],double tvnl_dphi[][3],double //-------------------------------------------------------- this->cal_stress_loc (); - //-------------------------------------------------------- - //hartree term - //-------------------------------------------------------- - this->cal_stress_har (); + //-------------------------------------------------------- + //hartree term + //-------------------------------------------------------- + this->cal_stress_har (); //-------------------------------------------------------- // ewald stress: use plane wave only. @@ -86,13 +87,14 @@ void Stress_LCAO::start_stress(double overlap[][3],double tvnl_dphi[][3],double //-------------------------------------------------------- // stress due to self-consistent charge. //-------------------------------------------------------- - for(int i=0;i<3;i++){ - //sigmaxc[i][i] = - (en.etxc-en.vtxc) / ucell.omega; - sigmaxc[i][i] = -(en.etxc) / ucell.omega; - -// sigmahar[i][i] = en.ehart /ucell.omega; + for(int i=0;i<3;i++) + { + // sigmaxc[i][i] = - (en.etxc-en.vtxc) / ucell.omega; + sigmaxc[i][i] = -(en.etxc) / ucell.omega; - } + // sigmahar[i][i] = en.ehart /ucell.omega; + + } //Exchange-correlation for PBE cal_stress_gradcorr(); @@ -126,19 +128,19 @@ void Stress_LCAO::start_stress(double overlap[][3],double tvnl_dphi[][3],double }*/ for(int i=0; i<3; i++) - { - for (int j=0;j<3;j++) - { - scs[i][j] += soverlap[i][j] - + stvnl_dphi[i][j] - + svnl_dbeta[i][j] - + svl_dphi[i][j] - + sigmadvl[i][j] // derivative of local potential stress (pw) - + sigmaewa[i][j] // ewald stress (pw) - + sigmacc[i][j] //nonlinear core correction stress (pw) - + sigmaxc[i][j]//exchange corretion stress - + sigmahar[i][j];// hartree stress - + { + for (int j=0;j<3;j++) + { + scs[i][j] += soverlap[i][j] + + stvnl_dphi[i][j] + + svnl_dbeta[i][j] + + svl_dphi[i][j] + + sigmadvl[i][j] // derivative of local potential stress (pw) + + sigmaewa[i][j] // ewald stress (pw) + + sigmacc[i][j] //nonlinear core correction stress (pw) + + sigmaxc[i][j]//exchange corretion stress + + sigmahar[i][j];// hartree stress + if(vdwd2.vdwD2) // Peize Lin update 2019-04-26 { scs[i][j] += stress_vdw(i , j); @@ -147,18 +149,17 @@ void Stress_LCAO::start_stress(double overlap[][3],double tvnl_dphi[][3],double { scs[i][j] += stress_vdw(i , j); } - /* if(EFIELD) - { - scs(iat, i) = scs(iat, i) + sefield(iat, i); - } -*/ - - } + /* if(EFIELD) + { + scs(iat, i) = scs(iat, i) + sefield(iat, i); + } + */ - + } -// if(OUT_LEVEL != "m") ofs_running << " correction stress for each atom along direction " << i+1 << " is " << sum/ucell.nat << endl; - } + // if(OUT_LEVEL != "m") ofs_running << " correction stress for each atom along direction " + // << i+1 << " is " << sum/ucell.nat << endl; + } /*if(SYMMETRY) { @@ -216,52 +217,52 @@ void Stress_LCAO::start_stress(double overlap[][3],double tvnl_dphi[][3],double { for(int j=0; j<3; j++) { - svlocal[i][j] = 0.0; - svlocal[i][j] = svl_dphi[i][j] + sigmadvl[i][j]; + svlocal[i][j] = 0.0; + svlocal[i][j] = svl_dphi[i][j] + sigmadvl[i][j]; } - } + } // test - double stvnl[3][3]; - for (int i = 0; i < 3; i++) - { + double stvnl[3][3]; + for (int i = 0; i < 3; i++) + { for(int j=0; j<3; j++) { - stvnl[i][j] = 0.0; - stvnl[i][j] = stvnl_dphi[i][j] + svnl_dbeta[i][j]; + stvnl[i][j] = 0.0; + stvnl[i][j] = stvnl_dphi[i][j] + svnl_dbeta[i][j]; } - } + } if(SYMMETRY) { - symm.stress_symmetry(scs); + symm.stress_symmetry(scs); }//end symmetry // print Rydberg stress or not bool ry = false; -// int TEST_STRESS = 1; +// int TEST_STRESS = 1; if(TEST_STRESS) { ofs_running << "\n PARTS OF STRESS: " << endl; ofs_running << setiosflags(ios::showpos); ofs_running << setiosflags(ios::fixed) << setprecision(8) << endl; this->print_stress("OVERLAP STRESS",soverlap,TEST_STRESS,ry); - //test - this->print_stress("T STRESS",stvnl_dphi,TEST_STRESS,ry); - this->print_stress("VNL STRESS",svnl_dbeta,TEST_STRESS,ry); + //test + this->print_stress("T STRESS",stvnl_dphi,TEST_STRESS,ry); + this->print_stress("VNL STRESS",svnl_dbeta,TEST_STRESS,ry); this->print_stress("T_VNL STRESS",stvnl,TEST_STRESS,ry); this->print_stress("VL_dPHI STRESS",svl_dphi,TEST_STRESS,ry); this->print_stress("VL_dVL STRESS",sigmadvl,TEST_STRESS,ry); - this->print_stress("HAR STRESS",sigmahar,TEST_STRESS,ry); + this->print_stress("HAR STRESS",sigmahar,TEST_STRESS,ry); this->print_stress("EWALD STRESS",sigmaewa,TEST_STRESS,ry); - this->print_stress("cc STRESS",sigmacc,TEST_STRESS,ry); -// this->print_stress("NLCC STRESS",sigmacc,TEST_STRESS,ry); + this->print_stress("cc STRESS",sigmacc,TEST_STRESS,ry); + // this->print_stress("NLCC STRESS",sigmacc,TEST_STRESS,ry); this->print_stress("XC STRESS",sigmaxc,TEST_STRESS,ry); - this->print_stress("TOTAL STRESS",scs,TEST_STRESS,ry); + this->print_stress("TOTAL STRESS",scs,TEST_STRESS,ry); } @@ -322,29 +323,28 @@ void Stress_LCAO::print_stress(const string &name, double f[][3], const bool scr } - for (int i=0;i<3;i++){ - ofs_running << setw(15)<< " "; - if( abs(f[i][0]) >output_acc) ofs_running << setw(15) << f[i][0]*fac; - else ofs_running << setw(15) << "0"; - if( abs(f[i][1]) >output_acc) ofs_running << setw(15) << f[i][1]*fac; - else ofs_running << setw(15) << "0"; - if( abs(f[i][2]) >output_acc) ofs_running << setw(15) << f[i][2]*fac; - else ofs_running << setw(15) << "0"; - ofs_running << endl; - - if(screen) - { - if( abs(f[i][0]) >output_acc) cout << setw(15) << f[i][0]*fac; - else cout << setw(15) << "0"; - if( abs(f[i][1]) >output_acc) cout << setw(15) << f[i][1]*fac; - else cout << setw(15) << "0"; - if( abs(f[i][2]) >output_acc) cout << setw(15) << f[i][2]*fac; - else cout << setw(15) << "0"; - cout << endl; - } - - - } + for (int i=0;i<3;i++) + { + ofs_running << setw(15)<< " "; + if( abs(f[i][0]) >output_acc) ofs_running << setw(15) << f[i][0]*fac; + else ofs_running << setw(15) << "0"; + if( abs(f[i][1]) >output_acc) ofs_running << setw(15) << f[i][1]*fac; + else ofs_running << setw(15) << "0"; + if( abs(f[i][2]) >output_acc) ofs_running << setw(15) << f[i][2]*fac; + else ofs_running << setw(15) << "0"; + ofs_running << endl; + + if(screen) + { + if( abs(f[i][0]) >output_acc) cout << setw(15) << f[i][0]*fac; + else cout << setw(15) << "0"; + if( abs(f[i][1]) >output_acc) cout << setw(15) << f[i][1]*fac; + else cout << setw(15) << "0"; + if( abs(f[i][2]) >output_acc) cout << setw(15) << f[i][2]*fac; + else cout << setw(15) << "0"; + cout << endl; + } + } cout << resetiosflags(ios::showpos); @@ -352,7 +352,7 @@ void Stress_LCAO::print_stress(const string &name, double f[][3], const bool scr return; } -void Stress_LCAO::printstress_total (bool ry) +void Stress_LCAO::printstress_total(bool ry) { // zhengdy update 2016-10-08 double unit_transform = 1; @@ -412,23 +412,25 @@ void Stress_LCAO::cal_stress_loc(void) dvloc = new double[pw.ngmc]; - for(l=0;l<3;l++){ - for(m=0;m<3;m++){ - sigmadvl[l][m]=0; - } - } + for(l=0;l<3;l++) + { + for(m=0;m<3;m++) + { + sigmadvl[l][m]=0; + } + } complex *Porter = UFFT.porter; - ZEROS( Porter, pw.nrxx ); - for(int is=0; is(CHR.rho[is][ir], 0.0 ); - } - } - pw.FFT_chg.FFT3D(Porter, -1); + ZEROS( Porter, pw.nrxx ); + for(int is=0; is(CHR.rho[is][ir], 0.0 ); + } + } + pw.FFT_chg.FFT3D(Porter, -1); // if(INPUT.gamma_only==1) fact=2.0; // else fact=1.0; @@ -448,7 +450,8 @@ void Stress_LCAO::cal_stress_loc(void) evloc += ppcell.vloc(it, pw.ig2ngg[ig]) * (pw.strucFac(it,ig) * conj(Porter[j]) * fact).real(); } } - for( nt = 0;nt< ucell.ntype; nt++){ + for( nt = 0;nt< ucell.ntype; nt++) + { const Atom* atom = &ucell.atoms[nt]; //mark by zhengdy for check // if ( ppcell.vloc == NULL ){ @@ -468,7 +471,8 @@ void Stress_LCAO::cal_stress_loc(void) // } - for( ng = 0;ng< pw.ngmc;ng++){ + for( ng = 0;ng< pw.ngmc;ng++) + { const int j = pw.ig2fftc[ng]; g[0]=pw.gcar[ng].x; g[1]=pw.gcar[ng].y; @@ -483,16 +487,19 @@ void Stress_LCAO::cal_stress_loc(void) } } - for( l = 0;l< 3;l++){ -// sigmadvl [l][l] = sigmadvl [l][l] + evloc;//modified 2017/3/21 + for( l = 0;l< 3;l++) + { +// sigmadvl [l][l] = sigmadvl [l][l] + evloc;//modified 2017/3/21 for (m = 0; m *Porter = UFFT.porter; - // Hartree potential VH(r) from n(r) - ZEROS( Porter, pw.nrxx ); - for(int is=0; is( CHR.rho[is][ir], 0.0 ); - } - } - //============================= - // bring rho (aux) to G space + // Hartree potential VH(r) from n(r) + ZEROS( Porter, pw.nrxx ); + for(int is=0; is( CHR.rho[is][ir], 0.0 ); + } + } + //============================= + // bring rho (aux) to G space //============================= - pw.FFT_chg.FFT3D(Porter, -1); + pw.FFT_chg.FFT3D(Porter, -1); complex *psic = new complex [pw.nrxx]; double *psic0 = new double[pw.nrxx]; @@ -1063,5 +1073,3 @@ void Stress_LCAO::cal_stress_gradcorr() } return; } - - diff --git a/ABACUS.develop/source/src_lcao/stress_lcao.h b/ABACUS.develop/source/src_lcao/stress_lcao.h index 79001c4c08..9e556d70b3 100644 --- a/ABACUS.develop/source/src_lcao/stress_lcao.h +++ b/ABACUS.develop/source/src_lcao/stress_lcao.h @@ -2,7 +2,6 @@ #define STRESS_LCAO_H #include "../src_pw/tools.h" - #include "../src_pw/stress.h" //test class Stress_LCAO @@ -19,18 +18,20 @@ class Stress_LCAO void cal_stress_ew (void); void cal_stress_scc (void); void cal_stress_cc (void); - void cal_stress_har(void); + void cal_stress_har(void); void cal_stress_gradcorr(void); - + void print_stress(const string &name, double f[][3], const bool screen, bool ry)const; void printstress_total (bool ry); - void start_stress(double overlap[][3],double tvnl_dphi[][3],double vnl_dbeta[][3],double vl_dphi[][3], const matrix& stress_vdw); + void start_stress(double overlap[][3], double tvnl_dphi[][3], + double vnl_dbeta[][3],double vl_dphi[][3], const matrix& stress_vdw); // total stress double scs[3][3]; - static double stress_invalid_threshold_ev; + static double stress_invalid_threshold_ev; + private: //each part of stress @@ -38,17 +39,17 @@ class Stress_LCAO double sigmaewa[3][3]; double sigmacc[3][3]; double sigmaxc[3][3]; - double sigmahar[3][3]; - //each part of stress - //only calculated in force_lcao part - double soverlap[3][3]; - double stvnl_dphi[3][3]; - double svnl_dbeta[3][3]; - double svl_dphi[3][3]; - - bool allocate_flag; + double sigmahar[3][3]; + //each part of stress + //only calculated in force_lcao part + double soverlap[3][3]; + double stvnl_dphi[3][3]; + double svnl_dbeta[3][3]; + double svl_dphi[3][3]; + + bool allocate_flag; double output_acc; // control the accuracy - - Stress str; //test + + Stress str; //test }; #endif diff --git a/ABACUS.develop/source/src_pw/stress.cpp b/ABACUS.develop/source/src_pw/stress.cpp index 1cf4c80886..132496ec17 100644 --- a/ABACUS.develop/source/src_pw/stress.cpp +++ b/ABACUS.develop/source/src_pw/stress.cpp @@ -7,29 +7,31 @@ void Stress::cal_stress() { - TITLE("Stress","cal_stress"); - timer::tick("Stress","cal_stress",'E'); - - for(int i=0;i<3;i++){ - for(int j=0;j<3;j++){ - sigmatot[i][j] = 0.0; - sigmaxc[i][j] = 0.0; - sigmahar[i][j] = 0.0; - sigmakin[i][j] = 0.0; - sigmaloc[i][j] = 0.0; - sigmanlc[i][j] = 0.0; - sigmaewa[i][j] = 0.0; - sigmaxcc[i][j] = 0.0; - } - } - //kinetic contribution - stres_knl(); -if(SYMMETRY) -{ - symm.stress_symmetry(sigmakin); -}//end symmetry - //hartree contribution - stres_har(); + TITLE("Stress","cal_stress"); + timer::tick("Stress","cal_stress",'E'); + + for(int i=0;i<3;i++) + { + for(int j=0;j<3;j++) + { + sigmatot[i][j] = 0.0; + sigmaxc[i][j] = 0.0; + sigmahar[i][j] = 0.0; + sigmakin[i][j] = 0.0; + sigmaloc[i][j] = 0.0; + sigmanlc[i][j] = 0.0; + sigmaewa[i][j] = 0.0; + sigmaxcc[i][j] = 0.0; + } + } + //kinetic contribution + stres_knl(); + if(SYMMETRY) + { + symm.stress_symmetry(sigmakin); + }//end symmetry + //hartree contribution + stres_har(); //ewald contribution stres_ewa(); @@ -47,24 +49,28 @@ if(SYMMETRY) stres_cc(); //nonlocal - stres_nl(); -if(SYMMETRY) -{ - symm.stress_symmetry(sigmanlc); -}//end symmetry + stres_nl(); - for(int ipol=0;ipol<3;ipol++){ - for(int jpol=0;jpol<3;jpol++){ + if(SYMMETRY) + { + symm.stress_symmetry(sigmanlc); + }//end symmetry + + for(int ipol=0;ipol<3;ipol++) + { + for(int jpol=0;jpol<3;jpol++) + { sigmatot[ipol][jpol] = sigmakin[ipol][jpol] + sigmahar[ipol][jpol] + sigmanlc[ipol][jpol] + sigmaxc[ipol][jpol] + sigmaxcc[ipol][jpol] + sigmaewa[ipol][jpol] + sigmaloc[ipol][jpol]; } } -if(SYMMETRY) -{ - symm.stress_symmetry(sigmatot); -} + if(SYMMETRY) + { + symm.stress_symmetry(sigmatot); + } + /* cout<<"total stress:"<printstress_total(ry); - - if(TEST_STRESS) - { - ofs_running << "\n PARTS OF STRESS: " << endl; - ofs_running << setiosflags(ios::showpos); - ofs_running << setiosflags(ios::fixed) << setprecision(10) << endl; - this->print_stress("KINETIC STRESS",sigmakin,TEST_STRESS,ry); - this->print_stress("LOCAL STRESS",sigmaloc,TEST_STRESS,ry); - this->print_stress("HARTREE STRESS",sigmahar,TEST_STRESS,ry); - this->print_stress("NON-LOCAL STRESS",sigmanlc,TEST_STRESS,ry); - this->print_stress("XC STRESS",sigmaxc,TEST_STRESS,ry); - this->print_stress("EWALD STRESS",sigmaewa,TEST_STRESS,ry); - this->print_stress("NLCC STRESS",sigmaxcc,TEST_STRESS,ry); - this->print_stress("TOTAL STRESS",sigmatot,TEST_STRESS,ry); - } - return; + bool ry = false; + this->printstress_total(ry); + + if(TEST_STRESS) + { + ofs_running << "\n PARTS OF STRESS: " << endl; + ofs_running << setiosflags(ios::showpos); + ofs_running << setiosflags(ios::fixed) << setprecision(10) << endl; + this->print_stress("KINETIC STRESS",sigmakin,TEST_STRESS,ry); + this->print_stress("LOCAL STRESS",sigmaloc,TEST_STRESS,ry); + this->print_stress("HARTREE STRESS",sigmahar,TEST_STRESS,ry); + this->print_stress("NON-LOCAL STRESS",sigmanlc,TEST_STRESS,ry); + this->print_stress("XC STRESS",sigmaxc,TEST_STRESS,ry); + this->print_stress("EWALD STRESS",sigmaewa,TEST_STRESS,ry); + this->print_stress("NLCC STRESS",sigmaxcc,TEST_STRESS,ry); + this->print_stress("TOTAL STRESS",sigmatot,TEST_STRESS,ry); + } + return; } void Stress::print_stress(const string &name, double f[][3], const bool screen, bool ry)const { - ofs_running << " --------------------------- " << name << " ----------------------------" << endl; + ofs_running << " --------------------------- " << name << " ----------------------------" << endl; - double fac = 1.0; - - if(!ry) - { - // fac = Ry_to_eV / 0.529177; - } + double fac = 1.0; - cout << setprecision(8); - cout << setiosflags(ios::showpos); + if(!ry) + { + // fac = Ry_to_eV / 0.529177; + } - if(screen) - { - cout << " ------------------- " << name << " --------------------" << endl; + cout << setprecision(8); + cout << setiosflags(ios::showpos); - } + if(screen) + { + cout << " ------------------- " << name << " --------------------" << endl; - const double output_acc = 1.0e-8; - for (int i=0;i<3;i++){ - ofs_running << setw(15)<< " "; - if( abs(f[i][0]) >output_acc) ofs_running << setw(15) << f[i][0]*fac; - else ofs_running << setw(15) << "0"; - if( abs(f[i][1]) >output_acc) ofs_running << setw(15) << f[i][1]*fac; - else ofs_running << setw(15) << "0"; - if( abs(f[i][2]) >output_acc) ofs_running << setw(15) << f[i][2]*fac; - else ofs_running << setw(15) << "0"; - ofs_running << endl; - - if(screen) - { - if( abs(f[i][0]) >output_acc) cout << setw(15) << f[i][0]*fac; - else cout << setw(15) << "0"; - if( abs(f[i][1]) >output_acc) cout << setw(15) << f[i][1]*fac; - else cout << setw(15) << "0"; - if( abs(f[i][2]) >output_acc) cout << setw(15) << f[i][2]*fac; - else cout << setw(15) << "0"; - cout << endl; - } + } + const double output_acc = 1.0e-8; + for (int i=0;i<3;i++) + { + ofs_running << setw(15)<< " "; + if( abs(f[i][0]) >output_acc) ofs_running << setw(15) << f[i][0]*fac; + else ofs_running << setw(15) << "0"; + if( abs(f[i][1]) >output_acc) ofs_running << setw(15) << f[i][1]*fac; + else ofs_running << setw(15) << "0"; + if( abs(f[i][2]) >output_acc) ofs_running << setw(15) << f[i][2]*fac; + else ofs_running << setw(15) << "0"; + ofs_running << endl; + + if(screen) + { + if( abs(f[i][0]) >output_acc) cout << setw(15) << f[i][0]*fac; + else cout << setw(15) << "0"; + if( abs(f[i][1]) >output_acc) cout << setw(15) << f[i][1]*fac; + else cout << setw(15) << "0"; + if( abs(f[i][2]) >output_acc) cout << setw(15) << f[i][2]*fac; + else cout << setw(15) << "0"; + cout << endl; + } - } + } - cout << resetiosflags(ios::showpos); + cout << resetiosflags(ios::showpos); - return; + return; } void Stress::printstress_total (bool ry) @@ -223,14 +229,14 @@ void Stress::stres_knl() int npwx=0; int qtot = 0; - for(int ik=0; ik *gk, - matrix &dylm, - const int ipol); - double Polynomial_Interpolation_nl( - const realArray &table, - const int &dim1, - const int &dim2, - const double &table_interval, - const double &x); - void get_dvnl2( - ComplexMatrix &vkb, - const int ik); - void get_dvnl1( - ComplexMatrix &vkb, - const int ik, - const int ipol); - - - - double sigmaxc[3][3]; - double sigmakin[3][3]; - double sigmahar[3][3]; - double sigmaloc[3][3]; - double sigmanlc[3][3]; - double sigmaewa[3][3]; - double sigmaxcc[3][3]; + private: + + void stres_knl(); + + void stres_har(); + + void stres_ewa(); + + void stres_loc(); + + void stres_cc(); + + void stres_gradcorr(); + + void stres_nl(); + + void dylmr2 ( + const int nylm, + const int ngy, + Vector3 *gk, + matrix &dylm, + const int ipol); + + double Polynomial_Interpolation_nl( + const realArray &table, + const int &dim1, + const int &dim2, + const double &table_interval, + const double &x); + + void get_dvnl2( + ComplexMatrix &vkb, + const int ik); + + void get_dvnl1( + ComplexMatrix &vkb, + const int ik, + const int ipol); + + // stress for exchange-correlation functional term + double sigmaxc[3][3]; + // stress for electron kinetic energy term + double sigmakin[3][3]; + // stress for hartree term + double sigmahar[3][3]; + // stress for local pseudopotential term + double sigmaloc[3][3]; + // stress for nonlocal pseudopotential term + double sigmanlc[3][3]; + // stress for Ewald term (ion-ion interaction) + double sigmaewa[3][3]; + // stress for non-linear core correction term + double sigmaxcc[3][3]; }; From 7e9ad4d09e738f5612fba79b358654d61e7d8888 Mon Sep 17 00:00:00 2001 From: mohan Date: Sun, 7 Feb 2021 15:37:49 +0800 Subject: [PATCH 079/233] reviewe md code, the md code needs reconstruction, notes are written in src_pw/md.h --- ABACUS.develop/source/src_pw/md.cpp | 631 ++++++++++++++------------ ABACUS.develop/source/src_pw/md.h | 109 +++-- ABACUS.develop/source/src_pw/stress.h | 18 +- 3 files changed, 417 insertions(+), 341 deletions(-) diff --git a/ABACUS.develop/source/src_pw/md.cpp b/ABACUS.develop/source/src_pw/md.cpp index 45b74693bc..7df0f26e1b 100644 --- a/ABACUS.develop/source/src_pw/md.cpp +++ b/ABACUS.develop/source/src_pw/md.cpp @@ -9,101 +9,114 @@ #include"../input.h" #include"../src_lcao/local_orbital_ions.h" #include "../src_lcao/sltk_atom_arrange.h" //2015-10-01, xiaohui -md::md(int n){ + +md::md(int n) +{ xLogS=0; // thermostat's position - vLogS=0 ;// thermostat's speed - tauthermo = 0; // The thermostat fluctuation period, for Al fcc at 300K ~ 1000fs - taubaro = 0 ; // The barostat fluctuation period, for Al fcc at 300K ~ 500 fs - Qmass = -1; // Inertia of extended system variable - dt = -1; // Time increment (hbar/E_hartree) - temperature= -1; //Temperature (in Hartree, 1 Hartree ~ 3E5 K) - doMSD = 1; // compute the mean square displacement. - doMSDAtom = 1; // compute the mean square displacement for each atom. - msdstartTime = 1; //beyond this time, msd is going to be computed - diffuCoeff = 0; - nResn=3; // Coarseness of Trotter factorization of Nose-Hoover thermostat - nYosh=3; // Order of thermostat scheme corresponding with "intCoeff" - outputstressperiod = 1 ;// The period to output stress - dumpmdfreq = 1 ; // The period to dump MD information for monitoring and restarting MD - fixTemperature = 1; // The period to read in new temperature during MD run. - rstMD = 0 ;// 1 : restart MD, vel.restart and ion.restart files will be read - // 0 : not restart from ion and vel files - // -n: restart from vel.n and ion.n in directory - // "md_output_path" - - startStep=0 ;// the first step number of MD - velRescale = 0 ;// whether to rescale velocities at the first step - mdoutputpath="mdDataOut"; - step_rst=0; - numIon=ucell.nat; - ntype=ucell.ntype; + vLogS=0 ;// thermostat's speed + tauthermo = 0; // The thermostat fluctuation period, for Al fcc at 300K ~ 1000fs + taubaro = 0 ; // The barostat fluctuation period, for Al fcc at 300K ~ 500 fs + Qmass = -1; // Inertia of extended system variable + dt = -1; // Time increment (hbar/E_hartree) + temperature= -1; //Temperature (in Hartree, 1 Hartree ~ 3E5 K) + doMSD = 1; // compute the mean square displacement. + doMSDAtom = 1; // compute the mean square displacement for each atom. + msdstartTime = 1; //beyond this time, msd is going to be computed + diffuCoeff = 0; + nResn=3; // Coarseness of Trotter factorization of Nose-Hoover thermostat + nYosh=3; // Order of thermostat scheme corresponding with "intCoeff" + outputstressperiod = 1 ;// The period to output stress + dumpmdfreq = 1 ; // The period to dump MD information for monitoring and restarting MD + fixTemperature = 1; // The period to read in new temperature during MD run. + rstMD = 0 ;// 1 : restart MD, vel.restart and ion.restart files will be read + // 0 : not restart from ion and vel files + // -n: restart from vel.n and ion.n in directory + // "md_output_path" + + startStep=0 ;// the first step number of MD + velRescale = 0 ;// whether to rescale velocities at the first step + mdoutputpath="mdDataOut"; + step_rst=0; + numIon=ucell.nat; + ntype=ucell.ntype; }; -void md::md_allocate(){ - na=new int[ntype]; - if (!MY_RANK){ - stringstream ssc; - ssc << global_out_dir << "MD_OUT"; - out.open(ssc.str().c_str()); - } - for(int i=0;i[numIon]; - cartNoWrap=new Vector3[numIon]; - taudirac=new Vector3[numIon]; - allmass=new double[numIon]; - ionmbl=new Vector3[numIon]; - force=new Vector3[numIon]; - return; + +void md::md_allocate() +{ + na=new int[ntype]; + if (!MY_RANK) + { + stringstream ssc; + ssc << global_out_dir << "MD_OUT"; + out.open(ssc.str().c_str()); } + for(int i=0;i[numIon]; + cartNoWrap=new Vector3[numIon]; + taudirac=new Vector3[numIon]; + allmass=new double[numIon]; + ionmbl=new Vector3[numIon]; + force=new Vector3[numIon]; + return; +} + const double md::fundamentalTime = 2.418884326505e-17; -void md::initMD(){ - mdtype=INPUT.md_mdtype; +void md::initMD(void) +{ + + mdtype=INPUT.md_mdtype; - mdenergy=en.etot/2; - - Qmass=INPUT.md_qmass/6.02/9.109*1e5; - dt=INPUT.md_dt/fundamentalTime/1e15; - temperature=INPUT.md_tfirst/3.1577464e5; - rstMD=INPUT.md_rstmd; - - nResn=INPUT.md_nresn; - nYosh=INPUT.md_nyosh; - dumpmdfreq=INPUT.md_dumpmdfred; - fixTemperature=INPUT.md_fixtemperature; - ediff=INPUT.md_ediff; - ediffg=INPUT.md_ediffg; - doMSD=INPUT.md_domsd; - doMSDAtom=INPUT.md_domsdatom; - mdoutputpath=INPUT.md_mdoutpath; - msdstartTime=INPUT.md_msdstartTime; - - if(rstMD==0){ - connection0(); - connection1(); + mdenergy=en.etot/2; + + Qmass=INPUT.md_qmass/6.02/9.109*1e5; + dt=INPUT.md_dt/fundamentalTime/1e15; + temperature=INPUT.md_tfirst/3.1577464e5; + rstMD=INPUT.md_rstmd; + + nResn=INPUT.md_nresn; + nYosh=INPUT.md_nyosh; + dumpmdfreq=INPUT.md_dumpmdfred; + fixTemperature=INPUT.md_fixtemperature; + ediff=INPUT.md_ediff; + ediffg=INPUT.md_ediffg; + doMSD=INPUT.md_domsd; + doMSDAtom=INPUT.md_domsdatom; + mdoutputpath=INPUT.md_mdoutpath; + msdstartTime=INPUT.md_msdstartTime; + + if(rstMD==0) + { + connection0(); + connection1(); //A fresh new MD: Do not restart MD - InitVelocity() ; - // Initialize thermostat, and barostat - xLogS = 0.0 ; // position of thermostat - vLogS = 0.0; // velocity of thermostat - - } - else if ( rstMD>0 ){ - connection0(); - connection1(); - InitVelocity() ; - if(!RestartMD()){ - cout<<"error in restart MD!"<0 ) + { + connection0(); + connection1(); + InitVelocity() ; + if(!RestartMD()){ + cout<<"error in restart MD!"<>xLogS; - file.get(); file.ignore(7, '\n'); - file>>vLogS; - file.get(); file.ignore(23, '\n'); - for(i = 0;i>vell[i]; - } - /*file.get(); file.ignore(17, '\n'); - for(i=0;i>cart[i]; - } - file.get(); file.ignore(13, '\n'); - for(i=0;i>dira[i]; - }*/ - file.get(); file.ignore(6, '\n'); - file>>step_rst; - file.close(); - } + file.ignore(7, '\n'); + file>>xLogS; + file.get(); file.ignore(7, '\n'); + file>>vLogS; + file.get(); file.ignore(23, '\n'); + for(i = 0;i>vell[i]; + } + /*file.get(); file.ignore(17, '\n'); + for(i=0;i>cart[i]; + } + file.get(); file.ignore(13, '\n'); + for(i=0;i>dira[i]; + }*/ + file.get(); + file.ignore(6, '\n'); + file>>step_rst; + file.close(); + } + //2015-09-05, xiaohui #ifdef __MPI - MPI_Bcast(&xLogS,1,MPI_DOUBLE,0,MPI_COMM_WORLD); - MPI_Bcast(&vLogS,1,MPI_DOUBLE,0,MPI_COMM_WORLD); - MPI_Bcast(&step_rst,1,MPI_INT,0,MPI_COMM_WORLD); - MPI_Bcast(vell,numIon*3,MPI_DOUBLE,0,MPI_COMM_WORLD); - // MPI_Bcast(cart,numIon*3,MPI_DOUBLE,0,MPI_COMM_WORLD); - // MPI_Bcast(dira,numIon*3,MPI_DOUBLE,0,MPI_COMM_WORLD); + MPI_Bcast(&xLogS,1,MPI_DOUBLE,0,MPI_COMM_WORLD); + MPI_Bcast(&vLogS,1,MPI_DOUBLE,0,MPI_COMM_WORLD); + MPI_Bcast(&step_rst,1,MPI_INT,0,MPI_COMM_WORLD); + MPI_Bcast(vell,numIon*3,MPI_DOUBLE,0,MPI_COMM_WORLD); + // MPI_Bcast(cart,numIon*3,MPI_DOUBLE,0,MPI_COMM_WORLD); + // MPI_Bcast(dira,numIon*3,MPI_DOUBLE,0,MPI_COMM_WORLD); #endif - for(i=0;i echo_md_restart.dat, for debug purpose. "< echo_md_restart.dat, for debug purpose. "< 1&& step%dumpmdfreq==0 ) ) - pass =1; - if (!pass) return; +void md::mstout(int step) +{ + //this function used for outputting the information of restart file + bool pass; + pass = 0; - int i; - if(!MY_RANK){ - stringstream ssc; - ssc << global_out_dir << "Restart_md.dat"; - ofstream file(ssc.str().c_str()); - file<<"MD_RESTART"< 1&& step%dumpmdfreq==0 ) ) + pass =1; + if (!pass) return; + + int i; + if(!MY_RANK) + { + stringstream ssc; + ssc << global_out_dir << "Restart_md.dat"; + ofstream file(ssc.str().c_str()); + file<<"MD_RESTART"<> EXTERNAL VARIABLES <> EXTERNAL VARIABLES <> INTERIOR VARIABLES <> INITIALIZATION <> FUNCTION BODY <> INTERIOR VARIABLES <> INITIALIZATION <> FUNCTION BODY <=0) i1=i0; else i1=i0+m; - i0=a*(j%q)-r*((j-j%q)/q); - if(j0>=0) j1=j0; else j1=j0+m; - for(M=0;M<3*numIon;){ - i0=a*(i1%q)-r*((i1-i1%q)/q); - if(i0>=0) i2=i0; - else i2=i0+m; - u=((double)i1)/((double)m); //first ramdon number - i1=i2; - j0=a*(j1%q)-r*((j1-j1%q)/q); - if(j0>=0) j2=j0; - else j2=j0+m; - v=((double)j1)/((double)m); //second ramdon number - j1=j2; - x=tan(PI*(u-0.5)); - y=1.6*v/(PI*(x*x+1.0)); - if(y<=(1.0/sqrt(2.0*PI)*exp(-0.5*x*x))){ - if(M=0) i1=i0; else i1=i0+m; + i0=a*(j%q)-r*((j-j%q)/q); + if(j0>=0) j1=j0; else j1=j0+m; + for(M=0;M<3*numIon;) + { + i0=a*(i1%q)-r*((i1-i1%q)/q); + if(i0>=0) i2=i0; + else i2=i0+m; + u=((double)i1)/((double)m); //first ramdon number + i1=i2; + j0=a*(j1%q)-r*((j1-j1%q)/q); + if(j0>=0) j2=j0; + else j2=j0+m; + v=((double)j1)/((double)m); //second ramdon number + j1=j2; + x=tan(PI*(u-0.5)); + y=1.6*v/(PI*(x*x+1.0)); + if(y<=(1.0/sqrt(2.0*PI)*exp(-0.5*x*x))) + { + if(M *vel;// velocity of each atom, unit is a.u. - Matrix3 vBoxG; // barostat's velocity + double xLogS; // thermostat's position + double vLogS;// thermostat's speed + Vector3 *vel;// velocity of each atom, unit is a.u. + Matrix3 vBoxG; // barostat's velocity Matrix3 ionlatvec; double tauthermo; // The thermostat fluctuation period, for Al fcc at 300K ~ 1000fs - double taubaro; // The barostat fluctuation period, for Al fcc at 300K ~ 500 fs - double Qmass; // Inertia of extended system variable - double dt ; // Time increment (hbar/E_hartree) - double temperature; //Temperature (in Hartree, 1 Hartree ~ 3E5 K) - bool doMSD; // compute the mean square displacement. - bool doMSDAtom; // compute the mean square displacement for each atom. - double msdstartTime; //beyond this time, msd is going to be computed - double *msd ; - double diffuCoeff ; + double taubaro; // The barostat fluctuation period, for Al fcc at 300K ~ 500 fs + double Qmass; // Inertia of extended system variable + double dt ; // Time increment (hbar/E_hartree) + double temperature; //Temperature (in Hartree, 1 Hartree ~ 3E5 K) + bool doMSD; // compute the mean square displacement. + bool doMSDAtom; // compute the mean square displacement for each atom. + double msdstartTime; //beyond this time, msd is going to be computed + double *msd ; + double diffuCoeff ; int numIon; int ntype; int* na; - int nfrozen; + int nfrozen; double *allmass; Vector3 *force; Vector3 *ionmbl; Vector3 *taudirac; //dirac coord of atoms - Vector3 *cartNoWrap; //cartensian coord of atoms, *not* wrapped - Vector3 *msdcoords0; - Vector3 *msdcoordst; - int nResn; // Coarseness of Trotter factorization of Nose-Hoover thermostat - int nYosh; // Order of thermostat scheme corresponding with "intCoeff" - double *intCoeff; - int outputstressperiod;// The period to output stress - int dumpmdfreq; // The period to dump MD information for monitoring and restarting MD - int fixTemperature; // The period to read in new temperature during MD run. - string mdoutputpath; // output directory of md files: .ion .vel - int rstMD;// 1 : restart MD, vel.restart and ion.restart files will be read - // 0 : not restart from ion and vel files + Vector3 *cartNoWrap; //cartensian coord of atoms, *not* wrapped + Vector3 *msdcoords0; + Vector3 *msdcoordst; + int nResn; // Coarseness of Trotter factorization of Nose-Hoover thermostat + int nYosh; // Order of thermostat scheme corresponding with "intCoeff" + double *intCoeff; + int outputstressperiod;// The period to output stress + int dumpmdfreq; // The period to dump MD information for monitoring and restarting MD + int fixTemperature; // The period to read in new temperature during MD run. + string mdoutputpath; // output directory of md files: .ion .vel + int rstMD;// 1 : restart MD, vel.restart and ion.restart files will be read + // 0 : not restart from ion and vel files double ediff; //parameter for constrain double ediffg; //parameter for constrain - int startStep;// the first step number of MD - bool velRescale;// whether to rescale velocities at the first step + int startStep;// the first step number of MD + bool velRescale;// whether to rescale velocities at the first step ofstream out; double mdenergy; - const static double fundamentalTime; - double rdf[100]; - int step_rst; + const static double fundamentalTime; + double rdf[100]; + int step_rst; matrix stress_lcao; }; -/*class mdmd:public md{ - mdmd(){}; - void initMD(); - void runMD(); - mdnvt MDNVT(0); - mdNVE MDNVE(0); -}*/ #endif diff --git a/ABACUS.develop/source/src_pw/stress.h b/ABACUS.develop/source/src_pw/stress.h index d79bbc6111..470ad3ac08 100644 --- a/ABACUS.develop/source/src_pw/stress.h +++ b/ABACUS.develop/source/src_pw/stress.h @@ -4,7 +4,7 @@ #include "tools.h" //------------------------------------------------------------------- -// mohan note: 2021-02-07 +// mohan reconstruction note: 2021-02-07 // the stress code needs reconstructions (by Daye Zheng) // 1) add explanations for each function, each variable, for // main procedures, make the code readable @@ -20,9 +20,25 @@ // term, +U? exx? may have other stress terms. // 5) delete useless comments and tests, if you have a useless code, // please explicitly explain why you want to keep the test +// 6) format should be beautiful! code should be readable like a +// note (let readers be comfortable) //------------------------------------------------------------------- +//---------------------------------------------------------------- +// compute the stress terms in terms of the plane wave basis set +// the stress terms include: +// 1) the stress from the electron kinetic energy +// 2) the stress from the local pseudopotentials +// 3) the stress from the non-local pseudopotentials +// 4) the stress from the Hartree term +// 5) the stress from the non-linear core correction (if any) +// 6) the strees from the exchange-correlation functional term +// 7) the stress from the ewald term (ion-ion intraction under +// periodic boundary conditions). +// 8) the stress from ionic contributions (for molecular dynamics) +//---------------------------------------------------------------- using namespace std; + class Stress { public: From 5d88b71c5636db341ac1f544cd17332b65ef6ec9 Mon Sep 17 00:00:00 2001 From: qianrui <1962242031@qq.com> Date: Sun, 7 Feb 2021 17:59:31 +0800 Subject: [PATCH 080/233] A wrong version with Segment fault --- ABACUS.develop/source/Makefile.vars | 2 +- ABACUS.develop/source/src_pw/sto_che.cpp | 25 +++++--- ABACUS.develop/source/src_pw/sto_che.h | 20 ++++-- ABACUS.develop/source/src_pw/sto_hchi.cpp | 75 ++++++++++++++++++++++- ABACUS.develop/source/src_pw/sto_hchi.h | 9 ++- 5 files changed, 116 insertions(+), 15 deletions(-) diff --git a/ABACUS.develop/source/Makefile.vars b/ABACUS.develop/source/Makefile.vars index 13b6bedbfd..c9aba76a39 100644 --- a/ABACUS.develop/source/Makefile.vars +++ b/ABACUS.develop/source/Makefile.vars @@ -28,4 +28,4 @@ ELPA_DIR = /home/qianrui/intelcompile/impi_elpa #ELPA_DIR = /opt/elpa/intel_2017_update4 OBJ_DIR = obj -NP = 10 +NP = 1 diff --git a/ABACUS.develop/source/src_pw/sto_che.cpp b/ABACUS.develop/source/src_pw/sto_che.cpp index 27abd0e63f..4485641791 100644 --- a/ABACUS.develop/source/src_pw/sto_che.cpp +++ b/ABACUS.develop/source/src_pw/sto_che.cpp @@ -5,7 +5,10 @@ Stochastic_Chebychev::Stochastic_Chebychev() { initplan = false; + initcoef = false; norder = 0; + ccoef = new complex [1]; + coef = new double [1]; } Stochastic_Chebychev::~Stochastic_Chebychev() @@ -19,8 +22,10 @@ void Stochastic_Chebychev:: init() if(norder != 0) { norder2 = 2 * norder; - coef = new double [norder2]; + delete[] coef; + delete[] ccoef; ccoef = new complex [norder2]; + coef = new double [norder]; initcoef = true; } else @@ -30,20 +35,20 @@ void Stochastic_Chebychev:: init() } -void Stochastic_Chebychev:: calcoef(double* fun(double)) +void Stochastic_Chebychev:: calcoef(double fun(double)) { if(!initcoef) WARNING_QUIT("Stochastic_Chebychev", "Please init coef first!"); for(int i = 0; i < norder2; ++i) { - coef = fun(cos((i+0.5)*PI/norder)); + ccoef[i]=complex(fun(cos((i+0.5)*PI/norder))); } if(!initplan) { initplan = true; - plancoef = fftw_plan_dft_1d(norder2, (fftw_complex *) coef, (fftw_complex *) ccoef, FFTW_FORWARD, FFTW_MEASURE); + plancoef = fftw_plan_dft_1d(norder2, (fftw_complex *) ccoef, (fftw_complex *) ccoef, FFTW_FORWARD, FFTW_MEASURE); } fftw_execute(plancoef); - for(int i = 0; i + void recurs(T *arraynp1, T* arrayn, T *arrayn_1, void fun(T *in,T *out), int& ndim); int norder; int norder2; // 2 * norder - complex *ccoef; //temperary complex coefficient - double *coef; //expansion coefficient of each order, only first norder coefficient will be used. + double* coef; //[norder] expansion coefficient of each order, + complex *ccoef; //[norder2] temporary complex expansion coefficient of each order, only first norder coefficient is usefull. fftw_plan plancoef; bool initplan, initcoef; @@ -31,4 +33,14 @@ class Stochastic_Chebychev }; +template +void Stochastic_Chebychev:: recurs(T *arraynp1, T* arrayn, T *arrayn_1, void fun(T *in,T *out), int& ndim) +{ + fun(arrayn,arraynp1,ndim); + for(int i = 0; i < ndim; ++i) + { + arraynp1[i]=2*arraynp1[i]-arrayn_1[i]; + } +} + #endif// Eelectrons_Chebychev diff --git a/ABACUS.develop/source/src_pw/sto_hchi.cpp b/ABACUS.develop/source/src_pw/sto_hchi.cpp index 7b0777f8b8..1f3f8bdc91 100644 --- a/ABACUS.develop/source/src_pw/sto_hchi.cpp +++ b/ABACUS.develop/source/src_pw/sto_hchi.cpp @@ -2,22 +2,86 @@ #include "global.h" #include "sto_hchi.h" + Stochastic_Hchi::Stochastic_Hchi() { + initplan = false; + initchi = false; + nrxx = 0; + tmpchi1 = new complex [1]; + tmpchi2 = new complex [1]; } Stochastic_Hchi::~Stochastic_Hchi() { + fftw_destroy_plan(pf); + delete[] tmpchi1; + delete[] tmpchi2; +} + +void Stochastic_Hchi:: init() +{ + if(nrxx != 0) + { + delete[] tmpchi1; + delete[] tmpchi2; + tmpchi1 = new complex [nrxx]; + tmpchi2 = new complex [nrxx]; + initchi = true; + } + else + { + WARNING_QUIT("Stochastic_Hchi", "Number of grids should be at least one!"); + } + } -void Stochastic_Hchi:: Hchi() +void Stochastic_Hchi:: Hchi(complex*wfin, complex *wfout) { + //wait for init-------------------------------------- + double dk1=1,dk2=1,dk3=1; double*vr; + + //--------------------------------------------------- + if(!initchi) WARNING_QUIT("Stochastic_Hchi", "Please init Hchi first!"); + if(!initplan) + { + initplan=true; + pf=fftw_plan_dft_3d(nx,ny,nz,(fftw_complex *)tmpchi1,(fftw_complex *)tmpchi2, FFTW_FORWARD, FFTW_MEASURE); + } + complex ui(0,1); + for(int ix = 0, i = 0; ix < nx; ++ix) + { + for(int iy = 0; iy < ny; ++iy) + { + for(int iz = 0; iz < nz; ++iz) + { + tmpchi1[i] = wfin[i]*exp(PI*(double(nx)/(nx-1)*ix+double(ny)/(ny-1)*iy+double(nz)/(nz-1)*iz)*ui); + ++i; + } + } + + } + //------------------------------------ //(1) the kinetical energy. //------------------------------------ if(T_IN_H) { + fftw_execute(pf); + Vector3 gg; + for(int ig1 = 0, i = 0; ig1 < nx; ++ig1) + { + for(int ig2 = 0; ig2 < ny; ++ig2) + { + for(int ig3 = 0; ig3 < nz; ++ig3) + { + gg.set((ig1-double(nx-1)/2)*dk1, (ig2-double(ny-1)/2)*dk2, (ig3-double(nz-1)/2)*dk3); + tmpchi2[i] *= -gg.norm2(); + ++i; + } + } + } } //------------------------------------ @@ -25,8 +89,15 @@ void Stochastic_Hchi:: Hchi() //------------------------------------ if(VL_IN_H) { - + for(int ir = 0; ir < nrxx; ++ir) + { + tmpchi1[ir]*=vr[ir]; + } } + + //------------------------------------ + // (3) the nonlocal pseudopotential. + //------------------------------------ } void Stochastic_Hchi::orthogonal_to_psi() diff --git a/ABACUS.develop/source/src_pw/sto_hchi.h b/ABACUS.develop/source/src_pw/sto_hchi.h index 2b0572d834..3c2ad01b7f 100644 --- a/ABACUS.develop/source/src_pw/sto_hchi.h +++ b/ABACUS.develop/source/src_pw/sto_hchi.h @@ -21,7 +21,14 @@ class Stochastic_Hchi // constructor and deconstructor Stochastic_Hchi(); ~Stochastic_Hchi(); - void Hchi(); + void init(); + int nrxx; + int nx,ny,nz; + fftw_plan pf,pb; + bool initplan,initchi; + complex *tmpchi1,*tmpchi2; + void Hchi(complex* chiin, complex *chiout); + private: From 43fa411cd0a5b2ff44ddc70e5e99526d0bc0fc51 Mon Sep 17 00:00:00 2001 From: qianrui <1962242031@qq.com> Date: Sun, 7 Feb 2021 18:54:21 +0800 Subject: [PATCH 081/233] Slove segment fault --- ABACUS.develop/source/src_pw/sto_che.cpp | 5 ++++- ABACUS.develop/source/src_pw/sto_hchi.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ABACUS.develop/source/src_pw/sto_che.cpp b/ABACUS.develop/source/src_pw/sto_che.cpp index 4485641791..748111bf25 100644 --- a/ABACUS.develop/source/src_pw/sto_che.cpp +++ b/ABACUS.develop/source/src_pw/sto_che.cpp @@ -13,7 +13,10 @@ Stochastic_Chebychev::Stochastic_Chebychev() Stochastic_Chebychev::~Stochastic_Chebychev() { - fftw_destroy_plan(plancoef); + if(initplan) + { + fftw_destroy_plan(plancoef); + } delete [] coef; delete [] ccoef; } diff --git a/ABACUS.develop/source/src_pw/sto_hchi.cpp b/ABACUS.develop/source/src_pw/sto_hchi.cpp index 1f3f8bdc91..6c178b5e98 100644 --- a/ABACUS.develop/source/src_pw/sto_hchi.cpp +++ b/ABACUS.develop/source/src_pw/sto_hchi.cpp @@ -14,7 +14,10 @@ Stochastic_Hchi::Stochastic_Hchi() Stochastic_Hchi::~Stochastic_Hchi() { - fftw_destroy_plan(pf); + if(initplan) + { + fftw_destroy_plan(pf); + } delete[] tmpchi1; delete[] tmpchi2; } From b3231e6185fccfe9f32a017839cb989d164953df Mon Sep 17 00:00:00 2001 From: 80610702-git Date: Mon, 8 Feb 2021 11:20:28 +0800 Subject: [PATCH 082/233] DFT+U A big modification of codes structure of DFT+U --- ABACUS.develop/source/Makefile.Objects | 2 + ABACUS.develop/source/src_lcao/dftu.cpp | 1676 +---------------- ABACUS.develop/source/src_lcao/dftu.h | 82 +- ABACUS.develop/source/src_lcao/dftu_relax.cpp | 1170 ++++++++++++ ABACUS.develop/source/src_lcao/dftu_relax.h | 72 + .../source/src_lcao/dftu_yukawa.cpp | 393 ++++ ABACUS.develop/source/src_lcao/dftu_yukawa.h | 46 + 7 files changed, 1770 insertions(+), 1671 deletions(-) create mode 100644 ABACUS.develop/source/src_lcao/dftu_relax.cpp create mode 100644 ABACUS.develop/source/src_lcao/dftu_relax.h create mode 100644 ABACUS.develop/source/src_lcao/dftu_yukawa.cpp create mode 100644 ABACUS.develop/source/src_lcao/dftu_yukawa.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 21fcce5111..a8c5084e35 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -225,6 +225,8 @@ lattice_change_cg.o \ lattice_change_basic.o \ variable_cell.o\ dftu.o\ +dftu_yukawa.o\ +dftu_relax.o\ lscc.o\ OBJS_COMMON=atom_spec.o \ diff --git a/ABACUS.develop/source/src_lcao/dftu.cpp b/ABACUS.develop/source/src_lcao/dftu.cpp index a7ad490cc6..565d20ac18 100644 --- a/ABACUS.develop/source/src_lcao/dftu.cpp +++ b/ABACUS.develop/source/src_lcao/dftu.cpp @@ -13,7 +13,6 @@ #include #include "dftu.h" -#include "../input.h" #include "../src_global/constants.h" #include "../src_pw/global.h" #include "global_fp.h" @@ -28,11 +27,6 @@ #include "../src_pw/charge.h" -extern "C" -{ - void sphbsl_(int *n, double *r, double *A, double *val); - void sphhnk_(int *n, double *r, double *A, double *val); -} DFTU dftu; @@ -1536,1627 +1530,119 @@ void DFTU::cal_eff_pot_mat(const int ik, const int istep) } -double DFTU::get_onebody_eff_pot -( - const int T, const int iat, - const int L, const int N, const int spin, - const int m0, const int m1, - const int type, const bool newlocale -) +void DFTU::output() { - TITLE("DFTU","get_onebody_eff_pot"); - - double VU = 0.0; - - //if(!Yukawa && N!=0) return 0.0; - - switch(type) - { - case 1: //rotationally invarient formalism and FLL double counting; Not available at present - - - break; + TITLE("DFTU", "output"); + + ofs_running << "//=========================L(S)DA+U===========================//" << endl; - case 2: //rotationally invarient formalism and AMF double counting; Not available at present - - break; + for(int T=0; TU_Yukawa.at(T).at(L).at(N)-this->J_Yukawa.at(T).at(L).at(N))*( 0.5 - this->locale.at(iat).at(L).at(N).at(spin)(m0,m1) ); - else VU = -(this->U_Yukawa.at(T).at(L).at(N)-this->J_Yukawa.at(T).at(L).at(N))*this->locale.at(iat).at(L).at(N).at(spin)(m0,m1); - } - else - { - if(m0==m1) VU = (this->U[T]-this->J[T])*( 0.5 - this->locale.at(iat).at(L).at(N).at(spin)(m0,m1) ); - else VU = -(this->U[T]-this->J[T])*this->locale.at(iat).at(L).at(N).at(spin)(m0,m1); - } - } - else - { - if(Yukawa) - { - if(m0==m1) VU = (this->U_Yukawa.at(T).at(L).at(N)-this->J_Yukawa.at(T).at(L).at(N))*( 0.5 - this->locale_save.at(iat).at(L).at(N).at(spin)(m0,m1) ); - else VU = -(this->U_Yukawa.at(T).at(L).at(N)-this->J_Yukawa.at(T).at(L).at(N))*this->locale_save.at(iat).at(L).at(N).at(spin)(m0,m1); - } - else - { - if(m0==m1) VU = (this->U[T]-this->J[T])*( 0.5 - this->locale_save.at(iat).at(L).at(N).at(spin)(m0,m1) ); - else VU = -(this->U[T]-this->J[T])*this->locale_save.at(iat).at(L).at(N).at(spin)(m0,m1); - } - } - - break; - - case 4: //simplified formalism and AMF double counting; ot available at present - - break; - } - - return VU; -} - - -void DFTU::force_stress() -{ - TITLE("DFTU", "force_stress"); + const int N = ucell.atoms[T].l_nchi[L]; - if(FORCE) - { - for(int iat=0; iat=INPUT.orbital_corr[T] && INPUT.orbital_corr[T]!=-1) { - this->force_dftu.at(iat).at(dim) = 0.0; + if(L!=INPUT.orbital_corr[T]) continue; + + if(!Yukawa) + { + ofs_running << "atom_type=" << T << " L=" << L << " chi=" << 0 << " U=" << this->U[T]*Ry_to_eV + << "ev J=" << this->J[T]*Ry_to_eV << "ev" << endl; + } + else + { + for(int n=0; nU_Yukawa.at(T).at(L).at(n) - this->J_Yukawa.at(T).at(L).at(n))*Ry_to_eV; + ofs_running << "atom_type=" << T << " L=" << L << " chi=" << n << " U=" << this->U_Yukawa.at(T).at(L).at(n)*Ry_to_eV << "ev " << "J=" << this->J_Yukawa.at(T).at(L).at(n)*Ry_to_eV + << "ev" << endl; + } + } } } } - if(STRESS) - { - for(int dim=0; dim<3; dim++) - { - this->stress_dftu.at(dim).at(0) = 0.0; - this->stress_dftu.at(dim).at(1) = 0.0; - this->stress_dftu.at(dim).at(2) = 0.0; - } - } - - this->allocate_force_stress(); - - //======================================================= - // intialize single particel effective potential matrix - //======================================================= - vector>> VU_k; - vector> VU_gamma; - if(FORCE || STRESS) + ofs_running << "Local occupation matrices" << endl; + for(int T=0; Tfolding_dSm_soverlap(); - - if(GAMMA_ONLY_LOCAL) - { - VU_gamma.resize(NSPIN); - for(int is=0; is(0.0,0.0)); - } - else if(NSPIN==2 || NSPIN==4) - { - VU_k.resize(2); - for(int is=0; is<2; is++) - { - VU_k.at(is).resize(ParaO.nloc, complex(0.0,0.0)); - } - } - } + if(INPUT.orbital_corr[T]==-1) continue; + const int NL = ucell.atoms[T].nwl+1; + const int LC = INPUT.orbital_corr[T]; - for(int ir=0; iriwt2it.at(iwt1); - const int iat1 = this->iwt2iat.at(iwt1); - const int L1 = this->iwt2l.at(iwt1); - const int n1 = this->iwt2n.at(iwt1); - const int m1 = this->iwt2m.at(iwt1); - const int ipol1 = this->iwt2ipol.at(iwt1); + const int iat = ucell.itia2iat(T, I); + ofs_running << "atoms" << " " << iat ; - for(int ic=0; iciwt2it.at(iwt2); - const int iat2 = this->iwt2iat.at(iwt2); - const int L2 = this->iwt2l.at(iwt2); - const int n2 = this->iwt2n.at(iwt2); - const int m2 = this->iwt2m.at(iwt2); - const int ipol2 = this->iwt2ipol.at(iwt2); - - int irc = ic*ParaO.nrow + ir; - - if(INPUT.orbital_corr[T1]==-1 || INPUT.orbital_corr[T2]==-1) continue; - - if(iat1!=iat2) continue; - // if(Yukawa) // { - // if(L1(val, 0.0); - } - else if(NSPIN==2) + if(NSPIN==1 || NSPIN==2) { - for(int is=0; is(val, 0.0); - } + ofs_running << "spin" << " " << is << endl; + for(int m0=0; m0<2*l+1; m0++) + { + for(int m1=0; m1<2*l+1; m1++) + { + ofs_running << fixed << setw(12) << setprecision(8) << locale.at(iat).at(l).at(n).at(is)(m0, m1); + } + ofs_running << endl; + } + } } - else if(NSPIN==4)//SOC + else if(NSPIN==4) //SOC { - if(ipol1==ipol2) + for(int m0=0; m0<2*l+1; m0++) { - int is = ipol1; - double val = get_onebody_eff_pot(T1, iat1, L1, n1, is, m1, m2, cal_type, false); - VU_k.at(is).at(irc) = complex(val, 0.0); - } - } - } - - }//end ic - }//end ir - } - - //======================================================= - // calculate force - //======================================================= - if(FORCE) - { - if(GAMMA_ONLY_LOCAL) cal_force_gamma(VU_gamma); - else cal_force_k(VU_k); - } - - if(STRESS) - { - if(GAMMA_ONLY_LOCAL) cal_stress_gamma(VU_gamma); - else cal_stress_k(VU_k); - } - - return; -} - - -void DFTU::cal_force_k(vector>> &VU) -{ - TITLE("DFTU", "cal_force_k"); - - const char transN = 'N', transT = 'T'; - const int one_int = 1; - const double alpha = 1.0, beta = 0.0; - - vector>> ftmp(ucell.nat); - for(int ia=0; ia(0.0,0.0)); //three dimension - } + for(int ipol0=0; ipol0>> dm_VU_dSm(3); - for(int dim=0; dim<3; dim++) - { - dm_VU_dSm.at(dim).resize(ParaO.nloc, complex(0.0, 0.0)); - } + for(int m1=0; m1<2*l+1; m1++) + { + for(int ipol1=0; ipol1> mat_tmp(ParaO.nloc, complex(0.0, 0.0)); - vector> force_tmp(ParaO.nloc, complex(0.0, 0.0)); - - if(dim==0) //dim=1,2 are same as dim=0 - { - ZEROS(VECTOR_TO_PTR(mat_tmp), ParaO.nloc); - - pzgemm_(&transT, &transN, - &NLOCAL, &NLOCAL, &NLOCAL, - &alpha, - LOC.wfc_dm_2d.dm_k.at(ik).c, &one_int, &one_int, ParaO.desc, - VECTOR_TO_PTR(VU.at(spin)), &one_int, &one_int, ParaO.desc, - &beta, - VECTOR_TO_PTR(mat_tmp), &one_int, &one_int, ParaO.desc); - } - - pzgemm_(&transN, &transN, - &NLOCAL, &NLOCAL, &NLOCAL, - &alpha, - VECTOR_TO_PTR(mat_tmp), &one_int, &one_int, ParaO.desc, - this->dSm_k[ik][dim], &one_int, &one_int, ParaO.desc, - &beta, - VECTOR_TO_PTR(force_tmp), &one_int, &one_int, ParaO.desc); - - for(int irc=0; ircdSm_k[ik][dim], &one_int, &one_int, ParaO.desc, - VECTOR_TO_PTR(mat_tmp), &one_int, &one_int, ParaO.desc, - &beta, - VECTOR_TO_PTR(force_tmp), &one_int, &one_int, ParaO.desc); - - for(int irc=0; irciwt2iat.at(iwt1); - - for(int ic=0; iciwt2iat.at(iwt2); - - const int irc = ic*ParaO.nrow + ir; - - if(iat1==iat2 && iwt1==iwt2) - { - ftmp.at(iat1).at(dim) += dm_VU_dSm.at(dim).at(irc); - } - }//end ic - }//end ir - - for(int iat=0; iat val = ftmp.at(iat).at(dim); - MPI_Allreduce(&val, &ftmp.at(iat).at(dim), 1, MPI_DOUBLE_COMPLEX, MPI_SUM, MPI_COMM_WORLD); - - this->force_dftu.at(iat).at(dim) = ftmp.at(iat).at(dim).real(); - } - } - - /* - if(MY_RANK==0) - { - ofstream of_fdftu("force_dftu.dat", ios_base::app); - for(int iat=0; iat>> &VU) -{ - TITLE("DFTU", "cal_stress_k"); - - const char transN = 'N', transT = 'T'; - const int one_int = 1; - const double alpha = 1.0, beta = 0.0; - - int count = 0; - for(int dim1=0; dim1<3; dim1++) - { - for(int dim2=dim1; dim2<3; dim2++) - { - vector> dm_VU_sover(ParaO.nloc, complex(0.0, 0.0)); - - for(int ik=0; ik> stress_tmp(ParaO.nloc, complex(0.0, 0.0)); - - //Calculate mat_tmp=dm*VU - vector> mat_tmp(ParaO.nloc, complex(0.0, 0.0)); - - pzgemm_(&transT, &transN, - &NLOCAL, &NLOCAL, &NLOCAL, - &alpha, - LOC.wfc_dm_2d.dm_k.at(ik).c, &one_int, &one_int, ParaO.desc, - VECTOR_TO_PTR(VU.at(spin)), &one_int, &one_int, ParaO.desc, - &beta, - VECTOR_TO_PTR(mat_tmp), &one_int, &one_int, ParaO.desc); - - pzgemm_(&transN, &transN, - &NLOCAL, &NLOCAL, &NLOCAL, - &alpha, - VECTOR_TO_PTR(mat_tmp), &one_int, &one_int, ParaO.desc, - this->soverlap_k[ik][count], &one_int, &one_int, ParaO.desc, - &beta, - VECTOR_TO_PTR(stress_tmp), &one_int, &one_int, ParaO.desc); - - for(int irc=0; ircsoverlap_k[ik][count], &one_int, &one_int, ParaO.desc, - VECTOR_TO_PTR(mat_tmp), &one_int, &one_int, ParaO.desc, - &beta, - VECTOR_TO_PTR(stress_tmp), &one_int, &one_int, ParaO.desc); - - for(int irc=0; irc stmp(0.0, 0.0); - for(int ir=0; ir tmp; - MPI_Allreduce(&stmp, &tmp, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - - /* - if(MY_RANK==0) - { - ofstream of_s("stress_test.dat", ios_base::app); - - of_s << "(" << fixed << setprecision(9) << setw(12) << tmp.real() << " i" << fixed << setprecision(9) << setw(12) << tmp.imag() << ") "; - - of_s << endl; - } - */ - - - count++; - }//end dim2 - - }//end dim1 - - for(int i=0; i<3; i++) - { - for(int j=0; j<3; j++) - { - if(i>j) this->stress_dftu.at(i).at(j) = stress_dftu.at(j).at(i); - } - } - - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - this->stress_dftu.at(i).at(j) *= ucell.lat0 / ucell.omega; - } - } - - /* - if(MY_RANK==0) - { - ofstream of_sdftu("stress_dftu.dat", ios_base::app); - for(int dim1=0; dim1<3; dim1++) - { - for(int dim2=0; dim2<3; dim2++) - { - of_sdftu << fixed << setprecision(9) << setw(12) << this->stress_dftu.at(dim1).at(dim2) << " "; - } - of_sdftu << endl; - } - of_sdftu << endl; - } - */ - - return; -} - - -void DFTU::cal_force_gamma(vector> &VU) -{ - TITLE("DFTU", "cal_force_gamma"); - - const char transN = 'N', transT = 'T'; - const int one_int = 1; - const double alpha = 1.0, beta = 0.0; - - vector> dm_VU_dSm; - dm_VU_dSm.resize(3); - for(int dim=0; dim<3; dim++) - { - dm_VU_dSm.at(dim).resize(ParaO.nloc, 0.0); - } - - vector force_tmp(ParaO.nloc, 0.0); - //Calculate mat_tmp=dm*VU - vector mat_tmp(ParaO.nloc, 0.0); - - for(int ik=0; ik> ftmp; - ftmp.resize(ucell.nat); - for(int iat=0; iatiwt2iat.at(iwt1); - - for(int ic=0; iciwt2iat.at(iwt2); - - const int irc = ic*ParaO.nrow + ir; - - if(iat1==iat2 && iwt1==iwt2) - { - ftmp.at(iat1).at(dim) += dm_VU_dSm.at(dim).at(irc); - } - }//end ic - }//end ir - }//end dim - - - for(int iat=0; iatforce_dftu.at(iat).at(dim) = tmp; - } - - /* - if(MY_RANK==0) - { - ofstream of_fdftu("force_dftu.dat"); - for(int iat=0; iat dm_VU_sover(ParaO.nloc, 0.0); - - for(int ik=0; ik stress_tmp(ParaO.nloc, 0.0); - - //Calculate mat_tmp=dm*VU - vector mat_tmp(ParaO.nloc, 0.0); - - pdgemm_(&transT, &transN, - &NLOCAL, &NLOCAL, &NLOCAL, - &alpha, - LOC.wfc_dm_2d.dm_gamma.at(spin).c, &one_int, &one_int, ParaO.desc, - VECTOR_TO_PTR(VU.at(spin)), &one_int, &one_int, ParaO.desc, - &beta, - VECTOR_TO_PTR(mat_tmp), &one_int, &one_int, ParaO.desc); - - pdgemm_(&transN, &transN, - &NLOCAL, &NLOCAL, &NLOCAL, - &alpha, - VECTOR_TO_PTR(mat_tmp), &one_int, &one_int, ParaO.desc, - this->soverlap_gamma[count], &one_int, &one_int, ParaO.desc, - &beta, - VECTOR_TO_PTR(stress_tmp), &one_int, &one_int, ParaO.desc); - - for(int irc=0; ircsoverlap_gamma[count], &one_int, &one_int, ParaO.desc, - VECTOR_TO_PTR(mat_tmp), &one_int, &one_int, ParaO.desc, - &beta, - VECTOR_TO_PTR(stress_tmp), &one_int, &one_int, ParaO.desc); - - for(int irc=0; ircj) this->stress_dftu.at(i).at(j) = stress_dftu.at(j).at(i); - } - } - - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - this->stress_dftu.at(i).at(j) *= ucell.lat0 / ucell.omega; - } - } - - /* - if(MY_RANK==0) - { - ofstream of_fdftu("force_dftu.dat"); - for(int iat=0; iatforce_dftu.at(iat).at(0) - << " force_y=" << fixed << setprecision(9) << setw(12) << this->force_dftu.at(iat).at(1) - << " force_z=" << fixed << setprecision(9) << setw(12) << this->force_dftu.at(iat).at(2) << endl; - } - - if(STRESS) - { - ofstream of_sdftu("stress_dftu.dat"); - for(int dim0=0; dim0<3; dim0++) - { - for(int dim1=0; dim1<3; dim1++) - { - of_sdftu << fixed << setprecision(9) << setw(12) << this->stress_dftu.at(dim0).at(dim1) << " "; - } - of_sdftu << endl; - } - } - } - */ - - return; -} - - -void DFTU::folding_dSm_soverlap() -{ - TITLE("DFTU", "folding_dSm_soverlap"); - - int nnr = 0; - - if(GAMMA_ONLY_LOCAL) - { - if(STRESS) - { - for(int i=0; i<6; i++) - { - ZEROS(soverlap_gamma[i], ParaO.nloc); - } - } - } - else - { - for(int ik=0; ik tau1, tau2, dtau; - Vector3 dtau1, dtau2, tau0; - for(int T1=0; T1na; ++I1) - { - tau1 = atom1->tau[I1]; - - GridD.Find_atom(tau1, T1, I1); - for(int ad=0; adnw*NPOL; ++jj) - { - const int jj0 = jj/NPOL; - const int L1 = atom1->iw2l[jj0]; - const int N1 = atom1->iw2n[jj0]; - const int m1 = atom1->iw2m[jj0]; - int iw2_all = ucell.itiaiw2iwt( T2, I2, 0); - - for(int kk=0; kknw*NPOL; ++kk) - { - const int kk0 = kk/NPOL; - const int L2 = atom2->iw2l[kk0]; - const int N2 = atom2->iw2n[kk0]; - const int m2 = atom2->iw2m[kk0]; - - if ( !ParaO.in_this_processor(iw1_all,iw2_all) ) - { - ++iw2_all; - continue; - } - - int mu = ParaO.trace_loc_row[iw1_all]; - int nu = ParaO.trace_loc_col[iw2_all]; - int irc = nu*ParaO.nrow + mu; - - if(GAMMA_ONLY_LOCAL) - { - if(STRESS) - { - this->soverlap_gamma[0][irc] += LM.DSloc_Rx[nnr]*LM.DH_r[nnr*3+0]; - this->soverlap_gamma[1][irc] += LM.DSloc_Rx[nnr]*LM.DH_r[nnr*3+1]; - this->soverlap_gamma[2][irc] += LM.DSloc_Rx[nnr]*LM.DH_r[nnr*3+2]; - this->soverlap_gamma[3][irc] += LM.DSloc_Ry[nnr]*LM.DH_r[nnr*3+1]; - this->soverlap_gamma[4][irc] += LM.DSloc_Ry[nnr]*LM.DH_r[nnr*3+2]; - this->soverlap_gamma[5][irc] += LM.DSloc_Rz[nnr]*LM.DH_r[nnr*3+2]; - } - } - else - { - Vector3 dR(GridD.getBox(ad).x, GridD.getBox(ad).y, GridD.getBox(ad).z); - - for(int ik=0; ik kphase = complex ( cos(arg), sin(arg) ); - - this->dSm_k[ik][0][irc] += LM.DSloc_Rx[nnr]*kphase; - this->dSm_k[ik][1][irc] += LM.DSloc_Ry[nnr]*kphase; - this->dSm_k[ik][2][irc] += LM.DSloc_Rz[nnr]*kphase; - - if(STRESS) - { - this->soverlap_k[ik][0][irc] += LM.DSloc_Rx[nnr]*LM.DH_r[nnr*3+0]*kphase; - this->soverlap_k[ik][1][irc] += LM.DSloc_Rx[nnr]*LM.DH_r[nnr*3+1]*kphase; - this->soverlap_k[ik][2][irc] += LM.DSloc_Rx[nnr]*LM.DH_r[nnr*3+2]*kphase; - this->soverlap_k[ik][3][irc] += LM.DSloc_Ry[nnr]*LM.DH_r[nnr*3+1]*kphase; - this->soverlap_k[ik][4][irc] += LM.DSloc_Ry[nnr]*LM.DH_r[nnr*3+2]*kphase; - this->soverlap_k[ik][5][irc] += LM.DSloc_Rz[nnr]*LM.DH_r[nnr*3+2]*kphase; - } - } - } - - ++nnr; - ++iw2_all; - }// nw2 - - ++iw1_all; - - }// nw1 - }// distance - else if(distance>=rcut) - { - int start1 = ucell.itiaiw2iwt( T1, I1, 0); - int start2 = ucell.itiaiw2iwt( T2, I2, 0); - bool is_adj = false; - for (int ad0=0; ad0nw * NPOL; ++jj) - { - const int mu = ParaO.trace_loc_row[start1+jj]; - if(mu<0)continue; - - for(int kk=0; kknw * NPOL; ++kk) - { - const int nu = ParaO.trace_loc_col[start2+kk]; - if(nu<0)continue; - - ++nnr; - }//kk - }//jj - } - }//distance - }// ad - }// I1 - }// T1 - - return; -} - - -void DFTU::allocate_force_stress() -{ - TITLE("DFTU","allocate_force_stress"); - - if(GAMMA_ONLY_LOCAL) - { - if(STRESS) - { - // this->soverlap_gamma.resize(6); //xx, xy, xz, yy, yz, zz - // for(int i=0; i<6; i++) - // { - // this->soverlap_gamma.at(i).resize(ParaO.nloc, 0.0); - // } - soverlap_gamma = new double* [6]; - for(int i=0; i<6; i++) - { - soverlap_gamma[i] = new double [ParaO.nloc]; - } - } - } - else - { - dSm_k = new complex** [kv.nks]; - //this->dSm_k.resize(kv.nks); - - for(int ik=0; ikdSm_k.at(ik).resize(3); - dSm_k[ik] = new complex* [3]; - for(int dim=0; dim<3; dim++) - { - //this->dSm_k.at(ik).at(dim).resize(ParaO.nloc, ZERO); - dSm_k[ik][dim] = new complex[ParaO.nloc]; - } - } - - if(STRESS) - { - //this->soverlap_k.resize(kv.nks); - soverlap_k = new complex** [kv.nks]; - - for(int ik=0; iksoverlap_k.at(ik).resize(6); //xx, xy, xz, yy, yz, zz - soverlap_k[ik] = new complex* [6]; - for(int i=0; i<6; i++) - { - //this->soverlap_k.at(ik).at(i).resize(ParaO.nloc, ZERO); - soverlap_k[ik][i] = new complex [ParaO.nloc]; - } - } - } - } - - return; -} - - -void DFTU::erase_force_stress() -{ - TITLE("DFTU","erase_force_stress"); - - if(GAMMA_ONLY_LOCAL) - { - if(STRESS) - { - //this->soverlap_gamma.resize(6); //xx, xy, xz, yy, yz, zz - for(int i=0; i<6; i++) - { - //this->soverlap_gamma.at(i).resize(1, 0.0); - delete [] soverlap_gamma[i]; - } - delete [] soverlap_gamma; - - } - } - else - { - //this->dSm_k.resize(kv.nks); - - for(int ik=0; ikdSm_k.at(ik).resize(3); - for(int dim=0; dim<3; dim++) - { - //this->dSm_k.at(ik).at(dim).resize(1, ZERO); - delete [] dSm_k[ik][dim]; - } - delete [] dSm_k[ik]; - } - delete [] dSm_k; - - if(STRESS) - { - //this->soverlap_k.resize(kv.nks); - - for(int ik=0; iksoverlap_k.at(ik).resize(6); //xx, xy, xz, yy, yz, zz - for(int i=0; i<6; i++) - { - //this->soverlap_k.at(ik).at(i).resize(1, ZERO); - delete [] soverlap_k[ik][i]; - } - delete [] soverlap_k[ik]; - } - delete [] soverlap_k; - } - } - - return; -} - - -void DFTU::cal_yukawa_lambda() -{ - TITLE("DFTU", "cal_yukawa_lambda"); - - double sum_rho = 0.0; - double sum_rho_lambda = 0.0; - for(int is=0; islambda = val2/val1; - - double lambda1 = this->lambda; - - - //rescaling - this->lambda /= 1.6; - - /* - double Nval = 0.0; - double ele_cor = 0.0; - for(int T=0; Tlocale.at(iat).at(L).at(n).at(is)(m,m); - } - } - } - } - } - */ - - double rho_remain = (Nval-Nc)/ucell.omega; - double lambda2 = 2*pow(3*rho_remain/PI, (double)1.0/6.0); - - /* - if(MY_RANK==0) - { - ofstream ofs_lambda("lambda.dat", ios_base::app); - - ofs_lambda << "All valence electrons. lambda=" << fixed << setw(8) << setprecision(4) << lambda1 << endl; - ofs_lambda << "Subtracting correltaed electrons from valence electrons. lambda=" << fixed << setw(8) << setprecision(4) << lambda2 << endl; - ofs_lambda << endl; - } - */ - - - return; -} - - -void DFTU::cal_slater_Fk(const int L, const int T) -{ - TITLE("DFTU","cal_slater_Fk"); - - if(Yukawa) - { - //this->lambda = INPUT.yukawa_lambda; - - for(int chi=0; chiFk.at(T).at(L).at(chi).at(k) -= (4*k+1)*lambda*pow(R_L0,2)*bslval*hnkval*pow(R_L1,2)*pow(r0,2)*pow(r1,2)*rab0*rab1; - } - } - // this->Fk.at(T).at(chi).at(k) /= pow(norm,2); - } - } - } - - return; -} - - -void DFTU::cal_slater_UJ(const int istep, const int iter) -{ - TITLE("DFTU", "cal_slater_UJ"); - if(!Yukawa) return; - - this->cal_yukawa_lambda(); - - for(int it=0; itFk.at(it).at(l).at(n)), l+1); - } - } - } - - for(int T=0; T=INPUT.orbital_corr[T] && INPUT.orbital_corr[T]!=-1) - { - if(L!=INPUT.orbital_corr[T]) continue; - - this->cal_slater_Fk(L, T); - - for(int n=0; nU_Yukawa.at(T).at(L).at(n) = this->Fk.at(T).at(L).at(n).at(0); - this->J_Yukawa.at(T).at(L).at(n) = this->Fk.at(T).at(L).at(n).at(1)/5.0; - } - else - { - // if(n!=0) continue; - - this->Fk.at(T).at(L).at(n).at(0) = this->U[T]; - this->Fk.at(T).at(L).at(n).at(1) = 5.0*this->J[T]; - } - break; - - case 2: //d electrons - if(Yukawa) - { - this->U_Yukawa.at(T).at(L).at(n) = this->Fk.at(T).at(L).at(n).at(0); - this->J_Yukawa.at(T).at(L).at(n) = (this->Fk.at(T).at(L).at(n).at(1)+this->Fk.at(T).at(L).at(n).at(2))/14.0; - } - else - { - // if(n!=0) continue; - - this->Fk.at(T).at(L).at(n).at(0) = this->U[T]; - this->Fk.at(T).at(L).at(n).at(1) = 14.0*this->J[T]/(1.0+0.625); - this->Fk.at(T).at(L).at(n).at(2) = 0.625*this->Fk.at(T).at(L).at(n).at(1); - } - break; - - case 3: //f electrons - if(Yukawa) - { - this->U_Yukawa.at(T).at(L).at(n) = this->Fk.at(T).at(L).at(n).at(0); - this->J_Yukawa.at(T).at(L).at(n) = (286.0*this->Fk.at(T).at(L).at(n).at(1) + - 195.0*this->Fk.at(T).at(L).at(n).at(2)+250.0*this->Fk.at(T).at(L).at(n).at(3))/6435.0; - } - else - { - // if(n!=0) continue; - - this->Fk.at(T).at(L).at(n).at(0) = this->U[T]; - this->Fk.at(T).at(L).at(n).at(1) = 6435.0*this->J[T]/(286.0+195.0*0.668+250.0*0.494); - this->Fk.at(T).at(L).at(n).at(2) = 0.668*this->Fk.at(T).at(L).at(n).at(1); - this->Fk.at(T).at(L).at(n).at(3) = 0.494*this->Fk.at(T).at(L).at(n).at(1); - } - break; - } - - //Hartree to Rydeberg - this->U_Yukawa.at(T).at(L).at(n) *= 2.0; - this->J_Yukawa.at(T).at(L).at(n) *= 2.0; - }//end n - - }//end if - - }//end L - }// end T - - /* - if(MY_RANK==0 && Yukawa) - { - ofstream of_UJ("Yukawa_UJ.dat", ios_base::app); - of_UJ << "ISTEP= " << istep << " ITER= " << iter << endl; - of_UJ << "Lambda= " << this->lambda << endl; - - for(int T=0; T=INPUT.orbital_corr[T] && INPUT.orbital_corr[T]!=-1) - { - if(L!=INPUT.orbital_corr[T]) continue; - for(int n=0; nU_Yukawa.at(T).at(L).at(n) - this->J_Yukawa.at(T).at(L).at(n))*Ry_to_eV; - of_UJ << "atom type=" << T << " L=" << L << " chi=" << n << endl; - of_UJ << "U[" << n << "]=" << this->U_Yukawa.at(T).at(L).at(n)*Ry_to_eV << " " << "J[" << n << "]=" << this->J_Yukawa.at(T).at(L).at(n)*Ry_to_eV - << " Ueff[" << n << "]=" << Ueff << endl; - of_UJ << endl; - } - } - } - } - } - */ - - return; -} - - -void DFTU::output() -{ - TITLE("DFTU", "output"); - - ofs_running << "//=========================L(S)DA+U===========================//" << endl; - - for(int T=0; T=INPUT.orbital_corr[T] && INPUT.orbital_corr[T]!=-1) - { - if(L!=INPUT.orbital_corr[T]) continue; - - if(!Yukawa) - { - ofs_running << "atom_type=" << T << " L=" << L << " chi=" << 0 << " U=" << this->U[T]*Ry_to_eV - << "ev J=" << this->J[T]*Ry_to_eV << "ev" << endl; - } - else - { - for(int n=0; nU_Yukawa.at(T).at(L).at(n) - this->J_Yukawa.at(T).at(L).at(n))*Ry_to_eV; - ofs_running << "atom_type=" << T << " L=" << L << " chi=" << n << " U=" << this->U_Yukawa.at(T).at(L).at(n)*Ry_to_eV << "ev " << "J=" << this->J_Yukawa.at(T).at(L).at(n)*Ry_to_eV - << "ev" << endl; - } - } - } - } - } - - ofs_running << "Local occupation matrices" << endl; - for(int T=0; TNc = tot_elec; - ofs_dftu << "Total number of electrons (" << L << "," << n << ") " << tot_elec << endl; - } - - ofs_dftu << endl; -// ofs_pot << endl; - - return; -} - - -void DFTU::cal_unscreened_slater_Fk(const int L, const int T) -{ - TITLE("DFTU","cal_slater_Fk"); - - for(int chi=0; chiFk.at(T).at(chi).at(k) += (numerator/denominator)*pow(R_L0,2)*pow(R_L1,2)*pow(r0,2)*pow(r1,2)*rab0*rab1; - } - } - } - - - } - - this->cal_slater_UJ(T, L); - - return; -} - -void DFTU::cal_slater_Vsc(const int T, const int L) -{ - TITLE("DFTU", "cal_slater_Vsc"); - - for(int N=0; NVsc.at(T).at(N)(M0, M1) += FOUR_PI*gaunt1*gaunt2*Fk.at(T).at(N).at(l)/(2.0*k+1.0); - } - } - } - } - } - } - } - - return; -} -*/ diff --git a/ABACUS.develop/source/src_lcao/dftu.h b/ABACUS.develop/source/src_lcao/dftu.h index 2e9323f051..5bf95fd68e 100644 --- a/ABACUS.develop/source/src_lcao/dftu.h +++ b/ABACUS.develop/source/src_lcao/dftu.h @@ -7,8 +7,9 @@ #include -#include "../src_global/complexmatrix.h" #include "../src_pw/charge_broyden.h" +#include "dftu_relax.h" + using namespace std; @@ -16,7 +17,7 @@ using namespace std; // CLASS : // NAME : DTFU (DFT+U) //========================================================== -class DFTU +class DFTU : public DFTU_RELAX { public: DFTU(); // constructor @@ -40,95 +41,24 @@ class DFTU //calculate the effective potential void cal_eff_pot_mat(const int ik, const int istep); - double get_onebody_eff_pot - ( - const int T, const int iat, - const int L, const int N, const int spin, - const int m0, - const int m1, - const int type, const bool newlocale - ); - - - //calculate force and stress - void cal_force_stress_gamma(); - void force_stress(); - void folding_dSm_soverlap(); - void allocate_force_stress(); - void erase_force_stress(); - void cal_force_k(vector>> &VU); - void cal_force_gamma(vector> &VU); - void cal_stress_k(vector>> &VU); - void cal_stress_gamma(vector> &VU); - - //LSCC - void cal_slater_Fk(const int L, const int T); //L:angular momnet, T:atom type - void cal_unscreened_slater_Fk(const int L, const int T); //L:angular momnet, T:atom type - void cal_yukawa_lambda(); - void cal_slater_UJ(const int istep, const int iter); - void cal_slater_Vsc(const int T, const int L); - // void print(const int T, const int iat, const int L, const int N, const int iter); + void print(const int T, const int iat, const int L, const int N, const int iter); void output(); + + void out_orbitals(); //Sm_k[ik][irc]: for k_points algorithm, calculated at LCAO_nnr::folding_fixedH(const int &ik) vector>> Sm_k; - // effective potential matrix for k algorithm: pot_eff_k[ik][irc] // effective potential matrix for gamma only algorithm: pot_eff_gamma[is][irc] vector>> pot_eff_k; vector> pot_eff_gamma; - - double EU; int iter_dftu; - - //force and stress - vector> force_dftu; //force_dftu[iat][dim] - vector> stress_dftu; - - -private: - - int cal_type; //1:dftu_tpye=1, dc=1; 2:dftu_type=1, dc=2; 3:dftu_tpye=2, dc=1; 4:dftu_tpye=2, dc=2; - int dc; //dc (type of double_counting) - bool Yukawa; //1:use Yukawa potential; 0: do not use Yukawa potential - double lambda; //the parameter in Yukawa potential - - double *U; //J (Hund parameter J) - double *J; //J (Hund parameter J) - double Nval; //Total nmuber of valence electrons of the system - double Nc; //Total nmuber of correlated electrons of the system - - vector> Vsc; //Vsc[T][N](i,j) - vector>>> Fk; //slater integral:Fk[T][L][N][k] - vector>> U_Yukawa; //U_Yukawa[T][L][N] - vector>> J_Yukawa; //J_Yukawa[T]{L][N] - - //transform between iwt index and it, ia, L, N and m index - vector>>>> iatlnmipol2iwt; //iatlnm2iwt[iat][l][n][m][ipol] - vector iwt2it; //iwt2it[iwt] - vector iwt2iat; //iwt2iat[iwt] - vector iwt2l; //iwt2l[iwt] - vector iwt2n; //iwt2n[iwt] - vector iwt2m; //iwt2m[iwt] - vector iwt2ipol; //iwt2ipol[iwt] - vector iat2it; - - //local occupancy matrix of the correlated subspace - //locale: the out put local occupation number matrix of correlated electrons in the current electronic step - //locale_save: the input local occupation number matrix of correlated electrons in the current electronic step - //locale_save2: the input local occupation number matrix of correlated electrons in the last electronic step - vector>>> locale; // locale[iat][l][n][spin](m1,m2) - vector>>> locale_save; // locale_save[iat][l][n][spin](m1,m2) - - complex ***dSm_k; //dSm_k[ik][dim][irc] - complex ***soverlap_k; //soverlap_k[ik][xy][irc] - double **soverlap_gamma; //soverlap_gamma[xy][irc] }; diff --git a/ABACUS.develop/source/src_lcao/dftu_relax.cpp b/ABACUS.develop/source/src_lcao/dftu_relax.cpp new file mode 100644 index 0000000000..6e77ba696f --- /dev/null +++ b/ABACUS.develop/source/src_lcao/dftu_relax.cpp @@ -0,0 +1,1170 @@ +//========================================================== +// Author:Xin Qu +// DATE : 2019-12-10 +//========================================================== +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dftu_relax.h" +#include "../src_global/constants.h" +#include "../src_pw/global.h" +#include "global_fp.h" +#include "../src_global/global_function.h" +#include "../src_global/scalapack_connector.h" +#include "../src_global/lapack_connector.h" +#include "../src_pw/inverse_matrix.h" +#include "local_orbital_ions.h" +#include "lcao_matrix.h" +#include "../src_pw/magnetism.h" +#include "use_overlap_table.h" +#include "../src_pw/charge.h" + + +DFTU_RELAX::DFTU_RELAX(){} + + +DFTU_RELAX::~DFTU_RELAX(){} + + +void DFTU_RELAX::force_stress() +{ + TITLE("DFTU_RELAX", "force_stress"); + + if(FORCE) + { + for(int iat=0; iatforce_dftu.at(iat).at(dim) = 0.0; + } + } + } + + if(STRESS) + { + for(int dim=0; dim<3; dim++) + { + this->stress_dftu.at(dim).at(0) = 0.0; + this->stress_dftu.at(dim).at(1) = 0.0; + this->stress_dftu.at(dim).at(2) = 0.0; + } + } + + this->allocate_force_stress(); + + //======================================================= + // intialize single particel effective potential matrix + //======================================================= + vector>> VU_k; + vector> VU_gamma; + if(FORCE || STRESS) + { + this->folding_dSm_soverlap(); + + if(GAMMA_ONLY_LOCAL) + { + VU_gamma.resize(NSPIN); + for(int is=0; is(0.0,0.0)); + } + else if(NSPIN==2 || NSPIN==4) + { + VU_k.resize(2); + for(int is=0; is<2; is++) + { + VU_k.at(is).resize(ParaO.nloc, complex(0.0,0.0)); + } + } + } + + for(int ir=0; iriwt2it.at(iwt1); + const int iat1 = this->iwt2iat.at(iwt1); + const int L1 = this->iwt2l.at(iwt1); + const int n1 = this->iwt2n.at(iwt1); + const int m1 = this->iwt2m.at(iwt1); + const int ipol1 = this->iwt2ipol.at(iwt1); + + for(int ic=0; iciwt2it.at(iwt2); + const int iat2 = this->iwt2iat.at(iwt2); + const int L2 = this->iwt2l.at(iwt2); + const int n2 = this->iwt2n.at(iwt2); + const int m2 = this->iwt2m.at(iwt2); + const int ipol2 = this->iwt2ipol.at(iwt2); + + int irc = ic*ParaO.nrow + ir; + + if(INPUT.orbital_corr[T1]==-1 || INPUT.orbital_corr[T2]==-1) continue; + + if(iat1!=iat2) continue; + + // if(Yukawa) + // { + // if(L1(val, 0.0); + } + else if(NSPIN==2) + { + for(int is=0; is(val, 0.0); + } + } + else if(NSPIN==4)//SOC + { + if(ipol1==ipol2) + { + int is = ipol1; + double val = get_onebody_eff_pot(T1, iat1, L1, n1, is, m1, m2, cal_type, false); + VU_k.at(is).at(irc) = complex(val, 0.0); + } + } + } + + }//end ic + }//end ir + } + + //======================================================= + // calculate force + //======================================================= + if(FORCE) + { + if(GAMMA_ONLY_LOCAL) cal_force_gamma(VU_gamma); + else cal_force_k(VU_k); + } + + if(STRESS) + { + if(GAMMA_ONLY_LOCAL) cal_stress_gamma(VU_gamma); + else cal_stress_k(VU_k); + } + + return; +} + + +void DFTU_RELAX::cal_force_k(vector>> &VU) +{ + TITLE("DFTU_RELAX", "cal_force_k"); + + const char transN = 'N', transT = 'T'; + const int one_int = 1; + const double alpha = 1.0, beta = 0.0; + + vector>> ftmp(ucell.nat); + for(int ia=0; ia(0.0,0.0)); //three dimension + } + + vector>> dm_VU_dSm(3); + for(int dim=0; dim<3; dim++) + { + dm_VU_dSm.at(dim).resize(ParaO.nloc, complex(0.0, 0.0)); + } + + for(int ik=0; ik> mat_tmp(ParaO.nloc, complex(0.0, 0.0)); + vector> force_tmp(ParaO.nloc, complex(0.0, 0.0)); + + if(dim==0) //dim=1,2 are same as dim=0 + { + ZEROS(VECTOR_TO_PTR(mat_tmp), ParaO.nloc); + + pzgemm_(&transT, &transN, + &NLOCAL, &NLOCAL, &NLOCAL, + &alpha, + LOC.wfc_dm_2d.dm_k.at(ik).c, &one_int, &one_int, ParaO.desc, + VECTOR_TO_PTR(VU.at(spin)), &one_int, &one_int, ParaO.desc, + &beta, + VECTOR_TO_PTR(mat_tmp), &one_int, &one_int, ParaO.desc); + } + + pzgemm_(&transN, &transN, + &NLOCAL, &NLOCAL, &NLOCAL, + &alpha, + VECTOR_TO_PTR(mat_tmp), &one_int, &one_int, ParaO.desc, + this->dSm_k[ik][dim], &one_int, &one_int, ParaO.desc, + &beta, + VECTOR_TO_PTR(force_tmp), &one_int, &one_int, ParaO.desc); + + for(int irc=0; ircdSm_k[ik][dim], &one_int, &one_int, ParaO.desc, + VECTOR_TO_PTR(mat_tmp), &one_int, &one_int, ParaO.desc, + &beta, + VECTOR_TO_PTR(force_tmp), &one_int, &one_int, ParaO.desc); + + for(int irc=0; irciwt2iat.at(iwt1); + + for(int ic=0; iciwt2iat.at(iwt2); + + const int irc = ic*ParaO.nrow + ir; + + if(iat1==iat2 && iwt1==iwt2) + { + ftmp.at(iat1).at(dim) += dm_VU_dSm.at(dim).at(irc); + } + }//end ic + }//end ir + + for(int iat=0; iat val = ftmp.at(iat).at(dim); + MPI_Allreduce(&val, &ftmp.at(iat).at(dim), 1, MPI_DOUBLE_COMPLEX, MPI_SUM, MPI_COMM_WORLD); + + this->force_dftu.at(iat).at(dim) = ftmp.at(iat).at(dim).real(); + } + } + + if(MY_RANK==0) + { + ofstream of_fdftu("force_dftu.dat", ios_base::app); + for(int iat=0; iat>> &VU) +{ + TITLE("DFTU_RELAX", "cal_stress_k"); + + const char transN = 'N', transT = 'T'; + const int one_int = 1; + const double alpha = 1.0, beta = 0.0; + + int count = 0; + for(int dim1=0; dim1<3; dim1++) + { + for(int dim2=dim1; dim2<3; dim2++) + { + vector> dm_VU_sover(ParaO.nloc, complex(0.0, 0.0)); + + for(int ik=0; ik> stress_tmp(ParaO.nloc, complex(0.0, 0.0)); + + //Calculate mat_tmp=dm*VU + vector> mat_tmp(ParaO.nloc, complex(0.0, 0.0)); + + pzgemm_(&transT, &transN, + &NLOCAL, &NLOCAL, &NLOCAL, + &alpha, + LOC.wfc_dm_2d.dm_k.at(ik).c, &one_int, &one_int, ParaO.desc, + VECTOR_TO_PTR(VU.at(spin)), &one_int, &one_int, ParaO.desc, + &beta, + VECTOR_TO_PTR(mat_tmp), &one_int, &one_int, ParaO.desc); + + pzgemm_(&transN, &transN, + &NLOCAL, &NLOCAL, &NLOCAL, + &alpha, + VECTOR_TO_PTR(mat_tmp), &one_int, &one_int, ParaO.desc, + this->soverlap_k[ik][count], &one_int, &one_int, ParaO.desc, + &beta, + VECTOR_TO_PTR(stress_tmp), &one_int, &one_int, ParaO.desc); + + for(int irc=0; ircsoverlap_k[ik][count], &one_int, &one_int, ParaO.desc, + VECTOR_TO_PTR(mat_tmp), &one_int, &one_int, ParaO.desc, + &beta, + VECTOR_TO_PTR(stress_tmp), &one_int, &one_int, ParaO.desc); + + for(int irc=0; irc stmp(0.0, 0.0); + for(int ir=0; ir tmp; + MPI_Allreduce(&stmp, &tmp, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + + + if(MY_RANK==0) + { + ofstream of_s("stress_test.dat", ios_base::app); + + of_s << "(" << fixed << setprecision(9) << setw(12) << tmp.real() << " i" << fixed << setprecision(9) << setw(12) << tmp.imag() << ") "; + + of_s << endl; + } + + + count++; + }//end dim2 + + }//end dim1 + + for(int i=0; i<3; i++) + { + for(int j=0; j<3; j++) + { + if(i>j) this->stress_dftu.at(i).at(j) = stress_dftu.at(j).at(i); + } + } + + for(int i=0;i<3;i++) + { + for(int j=0;j<3;j++) + { + this->stress_dftu.at(i).at(j) *= ucell.lat0 / ucell.omega; + } + } + + /* + if(MY_RANK==0) + { + ofstream of_sdftu("stress_dftu.dat", ios_base::app); + for(int dim1=0; dim1<3; dim1++) + { + for(int dim2=0; dim2<3; dim2++) + { + of_sdftu << fixed << setprecision(9) << setw(12) << this->stress_dftu.at(dim1).at(dim2) << " "; + } + of_sdftu << endl; + } + of_sdftu << endl; + } + */ + + return; +} + + +void DFTU_RELAX::cal_force_gamma(vector> &VU) +{ + TITLE("DFTU_RELAX", "cal_force_gamma"); + + const char transN = 'N', transT = 'T'; + const int one_int = 1; + const double alpha = 1.0, beta = 0.0; + + vector> dm_VU_dSm; + dm_VU_dSm.resize(3); + for(int dim=0; dim<3; dim++) + { + dm_VU_dSm.at(dim).resize(ParaO.nloc, 0.0); + } + + vector force_tmp(ParaO.nloc, 0.0); + //Calculate mat_tmp=dm*VU + vector mat_tmp(ParaO.nloc, 0.0); + + for(int ik=0; ik> ftmp; + ftmp.resize(ucell.nat); + for(int iat=0; iatiwt2iat.at(iwt1); + + for(int ic=0; iciwt2iat.at(iwt2); + + const int irc = ic*ParaO.nrow + ir; + + if(iat1==iat2 && iwt1==iwt2) + { + ftmp.at(iat1).at(dim) += dm_VU_dSm.at(dim).at(irc); + } + }//end ic + }//end ir + }//end dim + + + for(int iat=0; iatforce_dftu.at(iat).at(dim) = tmp; + } + + if(MY_RANK==0) + { + ofstream of_fdftu("force_dftu.dat"); + for(int iat=0; iat dm_VU_sover(ParaO.nloc, 0.0); + + for(int ik=0; ik stress_tmp(ParaO.nloc, 0.0); + + //Calculate mat_tmp=dm*VU + vector mat_tmp(ParaO.nloc, 0.0); + + pdgemm_(&transT, &transN, + &NLOCAL, &NLOCAL, &NLOCAL, + &alpha, + LOC.wfc_dm_2d.dm_gamma.at(spin).c, &one_int, &one_int, ParaO.desc, + VECTOR_TO_PTR(VU.at(spin)), &one_int, &one_int, ParaO.desc, + &beta, + VECTOR_TO_PTR(mat_tmp), &one_int, &one_int, ParaO.desc); + + pdgemm_(&transN, &transN, + &NLOCAL, &NLOCAL, &NLOCAL, + &alpha, + VECTOR_TO_PTR(mat_tmp), &one_int, &one_int, ParaO.desc, + this->soverlap_gamma[count], &one_int, &one_int, ParaO.desc, + &beta, + VECTOR_TO_PTR(stress_tmp), &one_int, &one_int, ParaO.desc); + + for(int irc=0; ircsoverlap_gamma[count], &one_int, &one_int, ParaO.desc, + VECTOR_TO_PTR(mat_tmp), &one_int, &one_int, ParaO.desc, + &beta, + VECTOR_TO_PTR(stress_tmp), &one_int, &one_int, ParaO.desc); + + for(int irc=0; ircj) this->stress_dftu.at(i).at(j) = stress_dftu.at(j).at(i); + } + } + + for(int i=0;i<3;i++) + { + for(int j=0;j<3;j++) + { + this->stress_dftu.at(i).at(j) *= ucell.lat0 / ucell.omega; + } + } + + /* + if(MY_RANK==0) + { + ofstream of_fdftu("force_dftu.dat"); + for(int iat=0; iatforce_dftu.at(iat).at(0) + << " force_y=" << fixed << setprecision(9) << setw(12) << this->force_dftu.at(iat).at(1) + << " force_z=" << fixed << setprecision(9) << setw(12) << this->force_dftu.at(iat).at(2) << endl; + } + + if(STRESS) + { + ofstream of_sdftu("stress_dftu.dat"); + for(int dim0=0; dim0<3; dim0++) + { + for(int dim1=0; dim1<3; dim1++) + { + of_sdftu << fixed << setprecision(9) << setw(12) << this->stress_dftu.at(dim0).at(dim1) << " "; + } + of_sdftu << endl; + } + } + } + */ + + return; +} + + +void DFTU_RELAX::folding_dSm_soverlap() +{ + TITLE("DFTU_RELAX", "folding_dSm_soverlap"); + + int nnr = 0; + + if(GAMMA_ONLY_LOCAL) + { + if(STRESS) + { + for(int i=0; i<6; i++) + { + ZEROS(soverlap_gamma[i], ParaO.nloc); + } + } + } + else + { + for(int ik=0; ik tau1, tau2, dtau; + Vector3 dtau1, dtau2, tau0; + for(int T1=0; T1na; ++I1) + { + tau1 = atom1->tau[I1]; + + GridD.Find_atom(tau1, T1, I1); + for(int ad=0; adnw*NPOL; ++jj) + { + const int jj0 = jj/NPOL; + const int L1 = atom1->iw2l[jj0]; + const int N1 = atom1->iw2n[jj0]; + const int m1 = atom1->iw2m[jj0]; + int iw2_all = ucell.itiaiw2iwt( T2, I2, 0); + + for(int kk=0; kknw*NPOL; ++kk) + { + const int kk0 = kk/NPOL; + const int L2 = atom2->iw2l[kk0]; + const int N2 = atom2->iw2n[kk0]; + const int m2 = atom2->iw2m[kk0]; + + if ( !ParaO.in_this_processor(iw1_all,iw2_all) ) + { + ++iw2_all; + continue; + } + + int mu = ParaO.trace_loc_row[iw1_all]; + int nu = ParaO.trace_loc_col[iw2_all]; + int irc = nu*ParaO.nrow + mu; + + if(GAMMA_ONLY_LOCAL) + { + if(STRESS) + { + this->soverlap_gamma[0][irc] += LM.DSloc_Rx[nnr]*LM.DH_r[nnr*3+0]; + this->soverlap_gamma[1][irc] += LM.DSloc_Rx[nnr]*LM.DH_r[nnr*3+1]; + this->soverlap_gamma[2][irc] += LM.DSloc_Rx[nnr]*LM.DH_r[nnr*3+2]; + this->soverlap_gamma[3][irc] += LM.DSloc_Ry[nnr]*LM.DH_r[nnr*3+1]; + this->soverlap_gamma[4][irc] += LM.DSloc_Ry[nnr]*LM.DH_r[nnr*3+2]; + this->soverlap_gamma[5][irc] += LM.DSloc_Rz[nnr]*LM.DH_r[nnr*3+2]; + } + } + else + { + Vector3 dR(GridD.getBox(ad).x, GridD.getBox(ad).y, GridD.getBox(ad).z); + + for(int ik=0; ik kphase = complex ( cos(arg), sin(arg) ); + + this->dSm_k[ik][0][irc] += LM.DSloc_Rx[nnr]*kphase; + this->dSm_k[ik][1][irc] += LM.DSloc_Ry[nnr]*kphase; + this->dSm_k[ik][2][irc] += LM.DSloc_Rz[nnr]*kphase; + + if(STRESS) + { + this->soverlap_k[ik][0][irc] += LM.DSloc_Rx[nnr]*LM.DH_r[nnr*3+0]*kphase; + this->soverlap_k[ik][1][irc] += LM.DSloc_Rx[nnr]*LM.DH_r[nnr*3+1]*kphase; + this->soverlap_k[ik][2][irc] += LM.DSloc_Rx[nnr]*LM.DH_r[nnr*3+2]*kphase; + this->soverlap_k[ik][3][irc] += LM.DSloc_Ry[nnr]*LM.DH_r[nnr*3+1]*kphase; + this->soverlap_k[ik][4][irc] += LM.DSloc_Ry[nnr]*LM.DH_r[nnr*3+2]*kphase; + this->soverlap_k[ik][5][irc] += LM.DSloc_Rz[nnr]*LM.DH_r[nnr*3+2]*kphase; + } + } + } + + ++nnr; + ++iw2_all; + }// nw2 + + ++iw1_all; + + }// nw1 + }// distance + else if(distance>=rcut) + { + int start1 = ucell.itiaiw2iwt( T1, I1, 0); + int start2 = ucell.itiaiw2iwt( T2, I2, 0); + bool is_adj = false; + for (int ad0=0; ad0nw * NPOL; ++jj) + { + const int mu = ParaO.trace_loc_row[start1+jj]; + if(mu<0)continue; + + for(int kk=0; kknw * NPOL; ++kk) + { + const int nu = ParaO.trace_loc_col[start2+kk]; + if(nu<0)continue; + + ++nnr; + }//kk + }//jj + } + }//distance + }// ad + }// I1 + }// T1 + + return; +} + + +void DFTU_RELAX::allocate_force_stress() +{ + TITLE("DFTU_RELAX","allocate_force_stress"); + + if(GAMMA_ONLY_LOCAL) + { + if(STRESS) + { + // this->soverlap_gamma.resize(6); //xx, xy, xz, yy, yz, zz + // for(int i=0; i<6; i++) + // { + // this->soverlap_gamma.at(i).resize(ParaO.nloc, 0.0); + // } + soverlap_gamma = new double* [6]; + for(int i=0; i<6; i++) + { + soverlap_gamma[i] = new double [ParaO.nloc]; + } + } + } + else + { + dSm_k = new complex** [kv.nks]; + //this->dSm_k.resize(kv.nks); + + for(int ik=0; ikdSm_k.at(ik).resize(3); + dSm_k[ik] = new complex* [3]; + for(int dim=0; dim<3; dim++) + { + //this->dSm_k.at(ik).at(dim).resize(ParaO.nloc, ZERO); + dSm_k[ik][dim] = new complex[ParaO.nloc]; + } + } + + if(STRESS) + { + //this->soverlap_k.resize(kv.nks); + soverlap_k = new complex** [kv.nks]; + + for(int ik=0; iksoverlap_k.at(ik).resize(6); //xx, xy, xz, yy, yz, zz + soverlap_k[ik] = new complex* [6]; + for(int i=0; i<6; i++) + { + //this->soverlap_k.at(ik).at(i).resize(ParaO.nloc, ZERO); + soverlap_k[ik][i] = new complex [ParaO.nloc]; + } + } + } + } + + return; +} + + +void DFTU_RELAX::erase_force_stress() +{ + TITLE("DFTU_RELAX","erase_force_stress"); + + if(GAMMA_ONLY_LOCAL) + { + if(STRESS) + { + //this->soverlap_gamma.resize(6); //xx, xy, xz, yy, yz, zz + for(int i=0; i<6; i++) + { + //this->soverlap_gamma.at(i).resize(1, 0.0); + delete [] soverlap_gamma[i]; + } + delete [] soverlap_gamma; + + } + } + else + { + //this->dSm_k.resize(kv.nks); + + for(int ik=0; ikdSm_k.at(ik).resize(3); + for(int dim=0; dim<3; dim++) + { + //this->dSm_k.at(ik).at(dim).resize(1, ZERO); + delete [] dSm_k[ik][dim]; + } + delete [] dSm_k[ik]; + } + delete [] dSm_k; + + if(STRESS) + { + //this->soverlap_k.resize(kv.nks); + + for(int ik=0; iksoverlap_k.at(ik).resize(6); //xx, xy, xz, yy, yz, zz + for(int i=0; i<6; i++) + { + //this->soverlap_k.at(ik).at(i).resize(1, ZERO); + delete [] soverlap_k[ik][i]; + } + delete [] soverlap_k[ik]; + } + delete [] soverlap_k; + } + } + + return; +} + + +double DFTU_RELAX::get_onebody_eff_pot +( + const int T, const int iat, + const int L, const int N, const int spin, + const int m0, const int m1, + const int type, const bool newlocale +) +{ + TITLE("DFTU_RELAX","get_onebody_eff_pot"); + + double VU = 0.0; + + //if(!Yukawa && N!=0) return 0.0; + + switch(type) + { + case 1: //rotationally invarient formalism and FLL double counting + /* + const int spin_oppsite = 1 - spin; + int nelec_tot = 0; + int nelec_spin = 0; + + for(int is=0; is<2; is++) + { + for(int i=0; i<2*L+1; i++) + { + if(newlocale) + { + nelec_tot += locale.at(iat).at(L).at(N).at(is)(i,i); + if(is==spin) nelec_spin += locale.at(iat).at(L).at(N).at(is)(i,i); + } + else + { + nelec_tot += locale_save.at(iat).at(L).at(N).at(is)(i,i); + if(is==spin) nelec_spin += locale_save.at(iat).at(L).at(N).at(is)(i,i); + } + + } + } + + for(int m2=0; m2<2*L+1; m2++) + { + for(int m3=0; m3<2*L+1; m3++) + { + int M0_prime = m2*(2*L+1) + m3; + + int M1 = m0*(2*L+1) + m3; + int M1_prime = m2*(2*L+1) + m1; + + if(newlocale) + { + VU += Vsc.at(T).at(N)(M0,M0_prime)*locale.at(iat).at(L).at(N).at(spin_oppsite)(m2,m3) + + (Vsc.at(T).at(N)(M0,M0_prime)- Vsc.at(T).at(N)(M1,M1_prime))*locale.at(iat).at(L).at(N).at(spin)(m2,m3); + } + else + { + VU += Vsc.at(T).at(N)(M0, M0_prime)*locale_save.at(iat).at(L).at(N).at(spin_oppsite)(m2,m3) + + (Vsc.at(T).at(N)(M0, M0_prime)- Vsc.at(T).at(N)(M1,M1_prime))*locale_save.at(iat).at(L).at(N).at(spin)(m2,m3); + } + } + } + + //if(Yukawa) VU += -U_Yukawa.at(T).at(N)*(nelec_tot-0.5) + J_Yukawa.at(T).at(N)*(nelec_spin-0.5); + //else VU += -U[T]*(nelec_tot-0.5) + J[T]*(nelec_spin-0.5); + VU += -U[T]*(nelec_tot-0.5) + J[T]*(nelec_spin-0.5); + */ + + break; + + case 2: //rotationally invarient formalism and AMF double counting + + break; + + case 3: //simplified formalism and FLL double counting + if(newlocale) + { + if(Yukawa) + { + if(m0==m1) VU = (this->U_Yukawa.at(T).at(L).at(N)-this->J_Yukawa.at(T).at(L).at(N))*( 0.5 - this->locale.at(iat).at(L).at(N).at(spin)(m0,m1) ); + else VU = -(this->U_Yukawa.at(T).at(L).at(N)-this->J_Yukawa.at(T).at(L).at(N))*this->locale.at(iat).at(L).at(N).at(spin)(m0,m1); + } + else + { + if(m0==m1) VU = (this->U[T]-this->J[T])*( 0.5 - this->locale.at(iat).at(L).at(N).at(spin)(m0,m1) ); + else VU = -(this->U[T]-this->J[T])*this->locale.at(iat).at(L).at(N).at(spin)(m0,m1); + } + } + else + { + if(Yukawa) + { + if(m0==m1) VU = (this->U_Yukawa.at(T).at(L).at(N)-this->J_Yukawa.at(T).at(L).at(N))*( 0.5 - this->locale_save.at(iat).at(L).at(N).at(spin)(m0,m1) ); + else VU = -(this->U_Yukawa.at(T).at(L).at(N)-this->J_Yukawa.at(T).at(L).at(N))*this->locale_save.at(iat).at(L).at(N).at(spin)(m0,m1); + } + else + { + if(m0==m1) VU = (this->U[T]-this->J[T])*( 0.5 - this->locale_save.at(iat).at(L).at(N).at(spin)(m0,m1) ); + else VU = -(this->U[T]-this->J[T])*this->locale_save.at(iat).at(L).at(N).at(spin)(m0,m1); + } + } + + break; + + case 4: //simplified formalism and AMF double counting + + break; + } + + return VU; +} diff --git a/ABACUS.develop/source/src_lcao/dftu_relax.h b/ABACUS.develop/source/src_lcao/dftu_relax.h new file mode 100644 index 0000000000..9722452ffe --- /dev/null +++ b/ABACUS.develop/source/src_lcao/dftu_relax.h @@ -0,0 +1,72 @@ +//========================================================== +// Author: Xin Qu +// DATE : 2019-12-10 +//========================================================== +#ifndef DFTU_RELAX_H +#define DFTU_RELAX_H + +#include +#include "dftu_yukawa.h" +#include "../src_global/complexmatrix.h" + +using namespace std; + +//========================================================== +// CLASS : +// NAME : DFTU_RELAX +//========================================================== +class DFTU_RELAX : public DFTU_Yukawa +{ +public: + DFTU_RELAX(); // constructor + ~DFTU_RELAX(); // deconstructor + + + void force_stress(); + void folding_dSm_soverlap(); + void allocate_force_stress(); + void erase_force_stress(); + void cal_force_k(vector>> &VU); + void cal_force_gamma(vector> &VU); + void cal_stress_k(vector>> &VU); + void cal_stress_gamma(vector> &VU); + + double get_onebody_eff_pot + ( + const int T, const int iat, + const int L, const int N, const int spin, + const int m0, + const int m1, + const int type, const bool newlocale + ); + + //force and stress + vector> force_dftu; //force_dftu[iat][dim] + vector> stress_dftu; + + //vector>>> dSm_k; //dSm_k[ik][dim][irc] + complex ***dSm_k; //dSm_k[ik][dim][irc] + //vector>>> soverlap_k; //soverlap_k[ik][xy][irc] + complex ***soverlap_k; //soverlap_k[ik][xy][irc] + //vector> soverlap_gamma; //soverlap_gamma[xy][irc] + double **soverlap_gamma; //soverlap_gamma[xy][irc] + + //transform between iwt index and it, ia, L, N and m index + vector>>>> iatlnmipol2iwt; //iatlnm2iwt[iat][l][n][m][ipol] + vector iwt2it; //iwt2it[iwt] + vector iwt2iat; //iwt2iat[iwt] + vector iwt2l; //iwt2l[iwt] + vector iwt2n; //iwt2n[iwt] + vector iwt2m; //iwt2m[iwt] + vector iwt2ipol; //iwt2ipol[iwt] + vector iat2it; + + //local occupancy matrix of the correlated subspace + //locale: the out put local occupation number matrix of correlated electrons in the current electronic step + //locale_save: the input local occupation number matrix of correlated electrons in the current electronic step + vector>>> locale; // locale[iat][l][n][spin](m1,m2) + vector>>> locale_save; // locale_save[iat][l][n][spin](m1,m2) + +}; + +#endif \ No newline at end of file diff --git a/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp b/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp new file mode 100644 index 0000000000..7886db3709 --- /dev/null +++ b/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp @@ -0,0 +1,393 @@ +//========================================================== +// Author:Xin Qu +// DATE : 2019-12-10 +//========================================================== +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dftu_yukawa.h" +#include "../src_global/constants.h" +#include "../src_pw/global.h" +#include "global_fp.h" +#include "../src_global/global_function.h" +#include "local_orbital_ions.h" +#include "lcao_matrix.h" + + +extern "C" +{ + void sphbsl_(int *n, double *r, double *A, double *val); + void sphhnk_(int *n, double *r, double *A, double *val); +} + +DFTU_Yukawa::DFTU_Yukawa(){} + +DFTU_Yukawa::~DFTU_Yukawa(){} + + +void DFTU_Yukawa::cal_yukawa_lambda() +{ + TITLE("DFTU_Yukawa", "cal_yukawa_lambda"); + + double sum_rho = 0.0; + double sum_rho_lambda = 0.0; + for(int is=0; islambda = val2/val1; + + double lambda1 = this->lambda; + + + //rescaling + this->lambda /= 1.6; + + /* + double Nval = 0.0; + double ele_cor = 0.0; + for(int T=0; Tlocale.at(iat).at(L).at(n).at(is)(m,m); + } + } + } + } + } + */ + + double rho_remain = (Nval-Nc)/ucell.omega; + double lambda2 = 2*pow(3*rho_remain/PI, (double)1.0/6.0); + + if(MY_RANK==0) + { + ofstream ofs_lambda("lambda.dat", ios_base::app); + + ofs_lambda << "All valence electrons. lambda=" << fixed << setw(8) << setprecision(4) << lambda1 << endl; + ofs_lambda << "Subtracting correltaed electrons from valence electrons. lambda=" << fixed << setw(8) << setprecision(4) << lambda2 << endl; + ofs_lambda << endl; + } + + + return; +} + + +void DFTU_Yukawa::cal_slater_Fk(const int L, const int T) +{ + TITLE("DFTU_Yukawa","cal_slater_Fk"); + + if(Yukawa) + { + //this->lambda = INPUT.yukawa_lambda; + + for(int chi=0; chiFk.at(T).at(L).at(chi).at(k) -= (4*k+1)*lambda*pow(R_L0,2)*bslval*hnkval*pow(R_L1,2)*pow(r0,2)*pow(r1,2)*rab0*rab1; + } + } + // this->Fk.at(T).at(chi).at(k) /= pow(norm,2); + } + } + } + + return; +} + + +void DFTU_Yukawa::cal_slater_UJ(const int istep, const int iter) +{ + TITLE("DFTU_Yukawa", "cal_slater_UJ"); + if(!Yukawa) return; + + this->cal_yukawa_lambda(); + + for(int it=0; itFk.at(it).at(l).at(n)), l+1); + } + } + } + + for(int T=0; T=INPUT.orbital_corr[T] && INPUT.orbital_corr[T]!=-1) + { + if(L!=INPUT.orbital_corr[T]) continue; + + this->cal_slater_Fk(L, T); + + for(int n=0; nU_Yukawa.at(T).at(L).at(n) = this->Fk.at(T).at(L).at(n).at(0); + this->J_Yukawa.at(T).at(L).at(n) = this->Fk.at(T).at(L).at(n).at(1)/5.0; + } + else + { + // if(n!=0) continue; + + this->Fk.at(T).at(L).at(n).at(0) = this->U[T]; + this->Fk.at(T).at(L).at(n).at(1) = 5.0*this->J[T]; + } + break; + + case 2: //d electrons + if(Yukawa) + { + this->U_Yukawa.at(T).at(L).at(n) = this->Fk.at(T).at(L).at(n).at(0); + this->J_Yukawa.at(T).at(L).at(n) = (this->Fk.at(T).at(L).at(n).at(1)+this->Fk.at(T).at(L).at(n).at(2))/14.0; + } + else + { + // if(n!=0) continue; + + this->Fk.at(T).at(L).at(n).at(0) = this->U[T]; + this->Fk.at(T).at(L).at(n).at(1) = 14.0*this->J[T]/(1.0+0.625); + this->Fk.at(T).at(L).at(n).at(2) = 0.625*this->Fk.at(T).at(L).at(n).at(1); + } + break; + + case 3: //f electrons + if(Yukawa) + { + this->U_Yukawa.at(T).at(L).at(n) = this->Fk.at(T).at(L).at(n).at(0); + this->J_Yukawa.at(T).at(L).at(n) = (286.0*this->Fk.at(T).at(L).at(n).at(1) + + 195.0*this->Fk.at(T).at(L).at(n).at(2)+250.0*this->Fk.at(T).at(L).at(n).at(3))/6435.0; + } + else + { + // if(n!=0) continue; + + this->Fk.at(T).at(L).at(n).at(0) = this->U[T]; + this->Fk.at(T).at(L).at(n).at(1) = 6435.0*this->J[T]/(286.0+195.0*0.668+250.0*0.494); + this->Fk.at(T).at(L).at(n).at(2) = 0.668*this->Fk.at(T).at(L).at(n).at(1); + this->Fk.at(T).at(L).at(n).at(3) = 0.494*this->Fk.at(T).at(L).at(n).at(1); + } + break; + } + + //Hartree to Rydeberg + this->U_Yukawa.at(T).at(L).at(n) *= 2.0; + this->J_Yukawa.at(T).at(L).at(n) *= 2.0; + }//end n + + }//end if + + }//end L + }// end T + + if(MY_RANK==0 && Yukawa) + { + ofstream of_UJ("Yukawa_UJ.dat", ios_base::app); + of_UJ << "ISTEP= " << istep << " ITER= " << iter << endl; + of_UJ << "Lambda= " << this->lambda << endl; + + for(int T=0; T=INPUT.orbital_corr[T] && INPUT.orbital_corr[T]!=-1) + { + if(L!=INPUT.orbital_corr[T]) continue; + for(int n=0; nU_Yukawa.at(T).at(L).at(n) - this->J_Yukawa.at(T).at(L).at(n))*Ry_to_eV; + of_UJ << "atom type=" << T << " L=" << L << " chi=" << n << endl; + of_UJ << "U[" << n << "]=" << this->U_Yukawa.at(T).at(L).at(n)*Ry_to_eV << " " << "J[" << n << "]=" << this->J_Yukawa.at(T).at(L).at(n)*Ry_to_eV + << " Ueff[" << n << "]=" << Ueff << endl; + of_UJ << endl; + } + } + } + } + } + + return; +} + +/* +void DFTU::cal_unscreened_slater_Fk(const int L, const int T) +{ + TITLE("DFTU","cal_slater_Fk"); + + for(int chi=0; chiFk.at(T).at(chi).at(k) += (numerator/denominator)*pow(R_L0,2)*pow(R_L1,2)*pow(r0,2)*pow(r1,2)*rab0*rab1; + } + } + } + + + } + + this->cal_slater_UJ(T, L); + + return; +} + +void DFTU::cal_slater_Vsc(const int T, const int L) +{ + TITLE("DFTU", "cal_slater_Vsc"); + + for(int N=0; NVsc.at(T).at(N)(M0, M1) += FOUR_PI*gaunt1*gaunt2*Fk.at(T).at(N).at(l)/(2.0*k+1.0); + } + } + } + } + } + } + } + + return; +} +*/ diff --git a/ABACUS.develop/source/src_lcao/dftu_yukawa.h b/ABACUS.develop/source/src_lcao/dftu_yukawa.h new file mode 100644 index 0000000000..8ed5791cd2 --- /dev/null +++ b/ABACUS.develop/source/src_lcao/dftu_yukawa.h @@ -0,0 +1,46 @@ +//========================================================== +// Author: Xin Qu +// DATE : 2019-12-10 +//========================================================== +#ifndef DFTU_Yukawa_H +#define DFTU_Yukawa_H + +#include + +using namespace std; + +//========================================================== +// CLASS : +// NAME : DFTU_Yukawa +//========================================================== +class DFTU_Yukawa +{ +public: + DFTU_Yukawa(); // constructor + ~DFTU_Yukawa(); // deconstructor + + void cal_slater_Fk(const int L, const int T); //L:angular momnet, T:atom type + void cal_yukawa_lambda(); + void cal_slater_UJ(const int istep, const int iter); + + //void cal_unscreened_slater_Fk(const int L, const int T); //L:angular momnet, T:atom type + //void cal_slater_Vsc(const int T, const int L); + + bool Yukawa; //1:use Yukawa potential; 0: do not use Yukawa potential + double lambda; //the parameter in Yukawa potential + int cal_type; //1:dftu_tpye=1, dc=1; 2:dftu_type=1, dc=2; 3:dftu_tpye=2, dc=1; 4:dftu_tpye=2, dc=2; + int dc; //dc (type of double_counting) + double *U; //J (Hund parameter J) + double *J; //J (Hund parameter J) + + //vector> Vsc; //Vsc[T][N](i,j) + vector>>> Fk; //slater integral:Fk[T][L][N][k] + vector>> U_Yukawa; //U_Yukawa[T][L][N] + vector>> J_Yukawa; //J_Yukawa[T]{L][N] + + double Nval; //Total nmuber of valence electrons of the system + double Nc; //Total nmuber of correlated electrons of the system + +}; + +#endif \ No newline at end of file From 7542b7b0db0007a2f5b79c78865f2ca4d5971e9b Mon Sep 17 00:00:00 2001 From: 80610702-git Date: Mon, 8 Feb 2021 11:22:44 +0800 Subject: [PATCH 083/233] Update dftu.cpp --- ABACUS.develop/source/src_lcao/dftu.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/dftu.cpp b/ABACUS.develop/source/src_lcao/dftu.cpp index 565d20ac18..0a3f8b4e09 100644 --- a/ABACUS.develop/source/src_lcao/dftu.cpp +++ b/ABACUS.develop/source/src_lcao/dftu.cpp @@ -26,9 +26,6 @@ #include "use_overlap_table.h" #include "../src_pw/charge.h" - - - DFTU dftu; DFTU::DFTU(){} From 51f6dbf40659e5e0f5b4e16f2ef2113bf3709965 Mon Sep 17 00:00:00 2001 From: 80610702-git Date: Mon, 8 Feb 2021 12:12:18 +0800 Subject: [PATCH 084/233] DFT+U Delete some unnecessary codes --- ABACUS.develop/source/src_lcao/dftu_relax.cpp | 73 ------------------ .../source/src_lcao/dftu_yukawa.cpp | 76 ------------------- 2 files changed, 149 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/dftu_relax.cpp b/ABACUS.develop/source/src_lcao/dftu_relax.cpp index 6e77ba696f..16e3a4d1fb 100644 --- a/ABACUS.develop/source/src_lcao/dftu_relax.cpp +++ b/ABACUS.develop/source/src_lcao/dftu_relax.cpp @@ -296,16 +296,6 @@ void DFTU_RELAX::cal_force_k(vector>> &VU) } } - if(MY_RANK==0) - { - ofstream of_fdftu("force_dftu.dat", ios_base::app); - for(int iat=0; iat>> &VU) complex tmp; MPI_Allreduce(&stmp, &tmp, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - - - if(MY_RANK==0) - { - ofstream of_s("stress_test.dat", ios_base::app); - - of_s << "(" << fixed << setprecision(9) << setw(12) << tmp.real() << " i" << fixed << setprecision(9) << setw(12) << tmp.imag() << ") "; - - of_s << endl; - } - count++; }//end dim2 @@ -430,22 +409,6 @@ void DFTU_RELAX::cal_stress_k(vector>> &VU) } } - /* - if(MY_RANK==0) - { - ofstream of_sdftu("stress_dftu.dat", ios_base::app); - for(int dim1=0; dim1<3; dim1++) - { - for(int dim2=0; dim2<3; dim2++) - { - of_sdftu << fixed << setprecision(9) << setw(12) << this->stress_dftu.at(dim1).at(dim2) << " "; - } - of_sdftu << endl; - } - of_sdftu << endl; - } - */ - return; } @@ -609,16 +572,6 @@ void DFTU_RELAX::cal_force_gamma(vector> &VU) this->force_dftu.at(iat).at(dim) = tmp; } - if(MY_RANK==0) - { - ofstream of_fdftu("force_dftu.dat"); - for(int iat=0; iatforce_dftu.at(iat).at(0) - << " force_y=" << fixed << setprecision(9) << setw(12) << this->force_dftu.at(iat).at(1) - << " force_z=" << fixed << setprecision(9) << setw(12) << this->force_dftu.at(iat).at(2) << endl; - } - - if(STRESS) - { - ofstream of_sdftu("stress_dftu.dat"); - for(int dim0=0; dim0<3; dim0++) - { - for(int dim1=0; dim1<3; dim1++) - { - of_sdftu << fixed << setprecision(9) << setw(12) << this->stress_dftu.at(dim0).at(dim1) << " "; - } - of_sdftu << endl; - } - } - } - */ - return; } diff --git a/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp b/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp index 7886db3709..c6707678fb 100644 --- a/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp +++ b/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp @@ -57,54 +57,9 @@ void DFTU_Yukawa::cal_yukawa_lambda() this->lambda = val2/val1; - double lambda1 = this->lambda; - - //rescaling this->lambda /= 1.6; - /* - double Nval = 0.0; - double ele_cor = 0.0; - for(int T=0; Tlocale.at(iat).at(L).at(n).at(is)(m,m); - } - } - } - } - } - */ - - double rho_remain = (Nval-Nc)/ucell.omega; - double lambda2 = 2*pow(3*rho_remain/PI, (double)1.0/6.0); - - if(MY_RANK==0) - { - ofstream ofs_lambda("lambda.dat", ios_base::app); - - ofs_lambda << "All valence electrons. lambda=" << fixed << setw(8) << setprecision(4) << lambda1 << endl; - ofs_lambda << "Subtracting correltaed electrons from valence electrons. lambda=" << fixed << setw(8) << setprecision(4) << lambda2 << endl; - ofs_lambda << endl; - } - - return; } @@ -260,37 +215,6 @@ void DFTU_Yukawa::cal_slater_UJ(const int istep, const int iter) }//end L }// end T - - if(MY_RANK==0 && Yukawa) - { - ofstream of_UJ("Yukawa_UJ.dat", ios_base::app); - of_UJ << "ISTEP= " << istep << " ITER= " << iter << endl; - of_UJ << "Lambda= " << this->lambda << endl; - - for(int T=0; T=INPUT.orbital_corr[T] && INPUT.orbital_corr[T]!=-1) - { - if(L!=INPUT.orbital_corr[T]) continue; - for(int n=0; nU_Yukawa.at(T).at(L).at(n) - this->J_Yukawa.at(T).at(L).at(n))*Ry_to_eV; - of_UJ << "atom type=" << T << " L=" << L << " chi=" << n << endl; - of_UJ << "U[" << n << "]=" << this->U_Yukawa.at(T).at(L).at(n)*Ry_to_eV << " " << "J[" << n << "]=" << this->J_Yukawa.at(T).at(L).at(n)*Ry_to_eV - << " Ueff[" << n << "]=" << Ueff << endl; - of_UJ << endl; - } - } - } - } - } return; } From ca84b4b9d640f36c1dfc7c3da3ecf4eece36bef4 Mon Sep 17 00:00:00 2001 From: mohan Date: Mon, 8 Feb 2021 17:07:33 +0800 Subject: [PATCH 085/233] move initialization of dm and wfc from local_orbital_ions to local_orbital_charge --- ABACUS.develop/source/README | 2 + .../source/src_lcao/dftu_yukawa.cpp | 2 +- .../source/src_lcao/local_orbital_charge.cpp | 22 ++++ .../source/src_lcao/local_orbital_charge.h | 3 + .../source/src_lcao/local_orbital_ions.cpp | 118 +----------------- .../source/src_lcao/local_orbital_ions.h | 4 +- .../source/src_lcao/use_hamilt_matrix.cpp | 39 ++++-- .../source/src_lcao/use_hamilt_matrix.h | 3 + ABACUS.develop/source/src_pw/stress.cpp | 10 +- ABACUS.develop/source/src_pw/stress.h | 5 +- 10 files changed, 81 insertions(+), 127 deletions(-) diff --git a/ABACUS.develop/source/README b/ABACUS.develop/source/README index 3e5730fb12..d8f5f76ca5 100644 --- a/ABACUS.develop/source/README +++ b/ABACUS.develop/source/README @@ -12,6 +12,8 @@ The code should be reconstructed with the following details: 2) the inclusion of files in vdw3 should be changed. 3) Is is necessary to include 4) There is a segmental fault when use ABACUS compiled with gnu-mpich +5) solve the memory problem regarding gamma wave functions in LCAO +6) delete VNA codes ----------------------------------------------------------------------- Unitesets should include diff --git a/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp b/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp index c6707678fb..8b9adf5f99 100644 --- a/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp +++ b/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp @@ -42,7 +42,7 @@ void DFTU_Yukawa::cal_yukawa_lambda() { for(int ir=0; irallocate_gamma(gt); + LOWF.aloc_gamma_wfc(gt); + } + else + { + LOWF.allocate_k(gt); + this->allocate_DM_k(); + } + + return; +} + + #include "lcao_nnr.h" void Local_Orbital_Charge::allocate_DM_k(void) { diff --git a/ABACUS.develop/source/src_lcao/local_orbital_charge.h b/ABACUS.develop/source/src_lcao/local_orbital_charge.h index 7e6df247e0..a112ff1d59 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_charge.h +++ b/ABACUS.develop/source/src_lcao/local_orbital_charge.h @@ -14,6 +14,9 @@ class Local_Orbital_Charge Local_Orbital_Charge(); ~Local_Orbital_Charge(); + // mohan added 2021-02-08 + void allocate_dm_wfc(const Grid_Technique >); + void allocate_gamma(const Grid_Technique >); void allocate_DM_k(void); void sum_bands(void); diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index 5c7773b2ac..2b4a0d51ed 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -154,13 +154,6 @@ void Local_Orbital_Ions::opt_ions(void) // need to first calculae lgd. // using GridT.init. LNNR.cal_nnrg(GridT); - - //mohan add 2012-06-12 - //the pvnapR need nnrg. - if(VNA>0) - { - UHM.GK.allocate_pvnapR(); - } } // (4) set the augmented orbitals index. @@ -171,17 +164,7 @@ void Local_Orbital_Ions::opt_ions(void) // (5) init density kernel // (6) init wave functions. - if(GAMMA_ONLY_LOCAL) - { - // here we reset the density matrix dimension. - LOC.allocate_gamma(GridT); - LOWF.aloc_gamma_wfc(GridT); - } - else - { - LOWF.allocate_k(GridT); - LOC.allocate_DM_k(); - } + LOC.allocate_dm_wfc(GridT); //====================================== // do the charge extrapolation before @@ -227,7 +210,7 @@ void Local_Orbital_Ions::opt_ions(void) pot.init_pot( istep-1 ); } - // (9) S, T, Vnl, Vna matrix. + // (9) compute S, T, Vnl, Vna matrix. UHM.set_ion(); // Peize Lin add 2014-04-04, update 2019-04-26 @@ -241,8 +224,9 @@ void Local_Orbital_Ions::opt_ions(void) vdwd3.energy(); } - // (10) self consistent - if (CALCULATION=="scf" || CALCULATION=="md" || CALCULATION=="relax" || CALCULATION=="cell-relax") //pengfei 2014-10-13 + // (10) self consistent calculations for electronic ground state + if (CALCULATION=="scf" || CALCULATION=="md" + || CALCULATION=="relax" || CALCULATION=="cell-relax") //pengfei 2014-10-13 { //Peize Lin add 2016-12-03 switch(exx_lcao.info.hybrid_type) @@ -259,6 +243,7 @@ void Local_Orbital_Ions::opt_ions(void) throw invalid_argument(TO_STRING(__FILE__)+TO_STRING(__LINE__)); } + // No exx if( Exx_Global::Hybrid_Type::No==exx_global.info.hybrid_type ) { LOE.scf(istep-1); @@ -425,15 +410,6 @@ void Local_Orbital_Ions::opt_ions(void) } - // need to destroy the matrix. - if(!GAMMA_ONLY_LOCAL) - { - //mohan add 2012-06-12 - if(VNA>0) - { - UHM.GK.destroy_pvnapR(); - } - } if(OUT_LEVEL=="i") { @@ -509,82 +485,6 @@ void Local_Orbital_Ions::opt_ions(void) */ } - if(stop && STRESS) - { -// final_scf(); -/* - FINAL_SCF = true; - Variable_Cell::final_calculation_after_vc(); - atom_arrange::set_sr_NL(); - atom_arrange::search( SEARCH_RADIUS ); - GridT.set_pbc_grid( - pw.ncx, pw.ncy, pw.ncz, - pw.bx, pw.by, pw.bz, - pw.nbx, pw.nby, pw.nbz, - pw.nbxx, pw.nbzp_start, pw.nbzp, VNA); - - // (2) If k point is used here, allocate HlocR after atom_arrange. - if(!GAMMA_ONLY_LOCAL) - { - // For each atom, calculate the adjacent atoms in different cells - // and allocate the space for H(R) and S(R). - LNNR.cal_nnr(); - LM.allocate_HS_R(LNNR.nnr); - } - if(!GAMMA_ONLY_LOCAL) - { - // need to first calculae lgd. - // using GridT.init. - LNNR.cal_nnrg(GridT); - //mohan add 2012-06-12 - //the pvnapR need nnrg. - if(VNA>0) - { - UHM.GK.allocate_pvnapR(); - } - } - - // (4) set the augmented orbitals index. - // after ParaO and GridT, - // this information is used to calculate - // the force. - LOWF.set_trace_aug(GridT); - - // (5) init density kernel - // (6) init wave functions. - if(GAMMA_ONLY_LOCAL) - { - // here we reset the density matrix dimension. - LOC.allocate_gamma(GridT); - LOWF.aloc_gamma_wfc(GridT); - } - else - { - LOWF.allocate_k(GridT); - LOC.allocate_DM_k(); - } - - UHM.set_ion(); - - if(vdwd2.vdwD2) //Peize Lin add 2014-04-04, update 2019-04-26 - { - vdwd2.energy(); - } - if(vdwd3.vdwD3) //jiyy add 2019-05-18 - { - vdwd3.energy(); - } - LOE.scf(0); - - if(CALCULATION=="scf" || CALCULATION=="relax") - { - ofs_running << "\n\n --------------------------------------------" << endl; - ofs_running << setprecision(16); - ofs_running << " !FINAL_ETOT_IS " << en.etot * Ry_to_eV << " eV" << endl; - ofs_running << " --------------------------------------------\n\n" << endl; - } -*/ - } hm.hon.clear_after_ions(); @@ -842,12 +742,6 @@ void Local_Orbital_Ions::final_scf(void) // need to first calculae lgd. // using GridT.init. LNNR.cal_nnrg(GridT); - //mohan add 2012-06-12 - //the pvnapR need nnrg. - if(VNA>0) - { - UHM.GK.allocate_pvnapR(); - } } // (4) set the augmented orbitals index. diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.h b/ABACUS.develop/source/src_lcao/local_orbital_ions.h index 7387dd71b2..978deaac7f 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.h +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.h @@ -15,7 +15,8 @@ class Local_Orbital_Ions { -public: + public: + Local_Orbital_Ions(); ~Local_Orbital_Ions(); @@ -29,6 +30,7 @@ class Local_Orbital_Ions mdNVE MDNVE ; private: + Ions_Move_Methods IMM; //bool force_stress(void); diff --git a/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp b/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp index e6a1b5176c..a0bfc4341c 100644 --- a/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp @@ -19,6 +19,10 @@ Use_Hamilt_Matrix::~Use_Hamilt_Matrix() } } +//-------------------------------------------- +// In set_ion, the 'calculate_STNR_gamma' or +// 'calculate_STNR_k' functions are called +//-------------------------------------------- void Use_Hamilt_Matrix::set_ion(void) { TITLE("Use_Hamilt_Matrix","set_ion"); @@ -52,7 +56,7 @@ void Use_Hamilt_Matrix::set_ion(void) lv.dense_vna(matrix_type); } } - else + else // multiple k-points { // calculate the 'S', 'T' and 'Vnl' matrix for k-points algorithms. this->calculate_STNR_k(); @@ -138,11 +142,17 @@ void Use_Hamilt_Matrix::calculate_Hgamma( const int &ik ) // Peize Lin add ik // Peize Lin add 2016-12-03 if( 5==xcf.iexch_now && 0==xcf.igcx_now ) // HF + { exx_lcao.add_Hexx(ik,1); + } else if( 6==xcf.iexch_now && 8==xcf.igcx_now ) // PBE0 + { exx_lcao.add_Hexx(ik,exx_global.info.hybrid_alpha); + } else if( 9==xcf.iexch_now && 12==xcf.igcx_now ) // HSE + { exx_lcao.add_Hexx(ik,exx_global.info.hybrid_alpha); + } } time_t time_vlocal_end = time(NULL); @@ -152,9 +162,8 @@ void Use_Hamilt_Matrix::calculate_Hgamma( const int &ik ) // Peize Lin add ik //add T+VNL+Vl matrix. LM.update_Hloc(); - //@@@@@@@ + //test - //@@@@@@@ if(NURSE) { LM.print_HSgamma('S'); // S @@ -177,15 +186,15 @@ void Use_Hamilt_Matrix::calculate_STNR_gamma(void) OUT(ofs_running,"gamma_only_local",GAMMA_ONLY_LOCAL); - // must be done after "setup_this_ion_iter" // because some basic parameters should be initialized // in UHM.GG.init(); LM.zeros_HSgamma('S'); + this->UOM.calculate_S_no(); - //LM.print_HSgamma('S'); + //LM.print_HSgamma('S'); //------------------------------------- // test using plane wave calculations. @@ -219,7 +228,7 @@ void Use_Hamilt_Matrix::calculate_STNR_gamma(void) } time_t time_t_end = time(NULL); -// ofs_running << " T+Vnl matrix" << endl; + // ofs_running << " T+Vnl matrix" << endl; //LM.print_HSgamma('T'); OUT_TIME("kinetical matrix",time_t_start, time_t_end); @@ -228,6 +237,7 @@ void Use_Hamilt_Matrix::calculate_STNR_gamma(void) return; } + #include "lcao_nnr.h" // be called in Local_Orbital_Elec::cal_bands(). void Use_Hamilt_Matrix::calculate_Hk(const int &ik) @@ -254,16 +264,29 @@ void Use_Hamilt_Matrix::calculate_Hk(const int &ik) // in LCAO basis. //-------------------------- LM.zeros_HSR('H', LNNR.nnr); - if(NSPIN!=4) this->GK.folding_vl_k(ik); - else this->GK.folding_vl_k_nc(ik); + + if(NSPIN!=4) + { + this->GK.folding_vl_k(ik); + } + else + { + this->GK.folding_vl_k_nc(ik); + } // Peize Lin add 2016-12-03 if( 5==xcf.iexch_now && 0==xcf.igcx_now ) // HF + { exx_lcao.add_Hexx(ik,1); + } else if( 6==xcf.iexch_now && 8==xcf.igcx_now ) // PBE0 + { exx_lcao.add_Hexx(ik,exx_global.info.hybrid_alpha); + } else if( 9==xcf.iexch_now && 12==xcf.igcx_now ) // HSE + { exx_lcao.add_Hexx(ik,exx_global.info.hybrid_alpha); + } } diff --git a/ABACUS.develop/source/src_lcao/use_hamilt_matrix.h b/ABACUS.develop/source/src_lcao/use_hamilt_matrix.h index cf5d38cf5e..a8c9a61512 100644 --- a/ABACUS.develop/source/src_lcao/use_hamilt_matrix.h +++ b/ABACUS.develop/source/src_lcao/use_hamilt_matrix.h @@ -21,6 +21,7 @@ class Use_Hamilt_Matrix // used for Gamma only Hamiltonian matrix. void calculate_Hgamma( const int &ik ); // Peize Lin add ik 2016-12-03 + void calculate_STN_R(void); //LiuXh add 2019-07-15 // used for gamma only algorithms. @@ -41,7 +42,9 @@ class Use_Hamilt_Matrix // used for gamma only algorithms. void calculate_STNR_gamma(void); + void calculate_STNR_gamma_B(void); //mohan add 2012-04-14 + void calculate_STNR_k(void); }; diff --git a/ABACUS.develop/source/src_pw/stress.cpp b/ABACUS.develop/source/src_pw/stress.cpp index 132496ec17..ccfcabfc42 100644 --- a/ABACUS.develop/source/src_pw/stress.cpp +++ b/ABACUS.develop/source/src_pw/stress.cpp @@ -182,7 +182,9 @@ void Stress::printstress_total (bool ry) for(int i=0; i<3; i++) { - ofs << " " << sigmatot[i][0]*unit_transform << " " << sigmatot[i][1]*unit_transform << " " << sigmatot[i][2]*unit_transform << endl; + ofs << " " << sigmatot[i][0]*unit_transform + << " " << sigmatot[i][1]*unit_transform + << " " << sigmatot[i][2]*unit_transform << endl; } ofs.close(); @@ -1320,7 +1322,8 @@ void Stress::stres_ewa(){ double alpha=2.9; double upperbound; - do{ + do + { alpha-=0.1; if(alpha==0.0) WARNING_QUIT("stres_ew", "optimal alpha not found"); @@ -1331,7 +1334,8 @@ void Stress::stres_ewa(){ //G-space sum here //Determine if this processor contains G=0 and set the constant term double sdewald; - if(pw.gstart == 1){ + if(pw.gstart == 1) + { sdewald = (TWO_PI) * e2 / 4.0 / alpha * pow(charge/ucell.omega,2); } else { diff --git a/ABACUS.develop/source/src_pw/stress.h b/ABACUS.develop/source/src_pw/stress.h index 470ad3ac08..c578da618b 100644 --- a/ABACUS.develop/source/src_pw/stress.h +++ b/ABACUS.develop/source/src_pw/stress.h @@ -20,8 +20,7 @@ // term, +U? exx? may have other stress terms. // 5) delete useless comments and tests, if you have a useless code, // please explicitly explain why you want to keep the test -// 6) format should be beautiful! code should be readable like a -// note (let readers be comfortable) +// 6) the codes should be written as clear as possibel, //------------------------------------------------------------------- //---------------------------------------------------------------- @@ -36,6 +35,8 @@ // 7) the stress from the ewald term (ion-ion intraction under // periodic boundary conditions). // 8) the stress from ionic contributions (for molecular dynamics) +// 9) the stress from DFT+U +// 10) the stress from vdW //---------------------------------------------------------------- using namespace std; From dbc82b3f769812bdf59fbdf3e81ba3ab956a6beb Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 9 Feb 2021 09:46:34 +0800 Subject: [PATCH 086/233] update force_lcao.h, move all public functions into private section and add friend classes, this is for the near-future reconstruction of ABACUS --- ABACUS.develop/source/src_lcao/force_lcao.cpp | 35 ++- ABACUS.develop/source/src_lcao/force_lcao.h | 11 +- .../source/src_lcao/local_orbital_charge.cpp | 230 ++++++++++-------- .../source/src_lcao/local_orbital_wfc.h | 1 + 4 files changed, 160 insertions(+), 117 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/force_lcao.cpp b/ABACUS.develop/source/src_lcao/force_lcao.cpp index 6158a33698..34d9c9e912 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/force_lcao.cpp @@ -168,17 +168,19 @@ void Force_LCAO::start_force(void) // clear the data. this->fcs.zero_out(); - stress_vdw.create(3,3);//zhengdy added in 2018-10-29 - if(vdwd2.vdwD2) //Peize Lin add 2014-04-04, update 2019-04-26 + // zhengdy added in 2018-10-29 + stress_vdw.create(3,3); + // Peize Lin add 2014-04-04, update 2019-04-26 + if(vdwd2.vdwD2) { vdwd2.force(stress_vdw, STRESS); } - if(vdwd3.vdwD3) //jiyy add 2019-05-18 + // jiyy add 2019-05-18 + else if(vdwd3.vdwD3) { vdwd3.force(stress_vdw, STRESS); } - - + matrix fefield; if(EFIELD) { @@ -201,9 +203,14 @@ void Force_LCAO::start_force(void) + fcc[iat][i] //nonlinear core correction force (pw) + fscc[iat][i];//self consistent corretion force (pw) - if(INPUT.dft_plus_u) fcs(iat, i) += dftu.force_dftu.at(iat).at(i); //Force contribution from DFT+U, Quxin add on 20201029 + // Force contribution from DFT+U, Quxin add on 20201029 + if(INPUT.dft_plus_u) + { + fcs(iat, i) += dftu.force_dftu.at(iat).at(i); + } - if(vdwd2.vdwD2) //Peize Lin add 2014-04-04, update 2019-04-26 + // Peize Lin add 2014-04-04, update 2019-04-261 + if(vdwd2.vdwD2) { switch(i) { @@ -213,7 +220,8 @@ void Force_LCAO::start_force(void) } } - if(vdwd3.vdwD3) //jiyy add 2019-05-18 + // jiyy add 2019-05-18 + if(vdwd3.vdwD3) { switch(i) { @@ -238,10 +246,16 @@ void Force_LCAO::start_force(void) } //xiaohui add "OUT_LEVEL", 2015-09-16 - if(OUT_LEVEL != "m") ofs_running << " correction force for each atom along direction " << i+1 << " is " << sum/ucell.nat << endl; + if(OUT_LEVEL != "m") + { + ofs_running << " correction force for each atom along direction " + << i+1 << " is " << sum/ucell.nat << endl; + } } - if(SYMMETRY) // pengfei 2016-12-20 + + // pengfei 2016-12-20 + if(SYMMETRY) { double *pos; double d1,d2,d3; @@ -250,7 +264,6 @@ void Force_LCAO::start_force(void) int iat = 0; for(int it = 0;it < ucell.ntype;it++) { - //Atom* atom = &ucell.atoms[it]; for(int ia =0;ia< ucell.atoms[it].na;ia++) { pos[3*iat ] = ucell.atoms[it].taud[ia].x ; diff --git a/ABACUS.develop/source/src_lcao/force_lcao.h b/ABACUS.develop/source/src_lcao/force_lcao.h index eeb6fcbfda..65aa6fd0d5 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao.h +++ b/ABACUS.develop/source/src_lcao/force_lcao.h @@ -4,14 +4,23 @@ #include "../src_pw/tools.h" #include "force_lcao_k.h" #include "stress_lcao.h" +#include "../input_conv.h" class Force_LCAO : private Force_LCAO_k { + // mohan add 2021-02-09 + friend class md; + friend void Input_Conv::Convert(); + friend class Update_input; + friend class Local_Orbital_Ions; + public : Force_LCAO (); ~Force_LCAO (); + private: + void allocate (void); void destroy (void); @@ -33,8 +42,6 @@ class Force_LCAO : private Force_LCAO_k matrix stress_vdw;//zhengdy added for vdw-stress-part - private: - //each part of force double** fvl_dvl; double** fewalds; diff --git a/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp b/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp index add12f4194..f4dda5898c 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp @@ -769,11 +769,18 @@ void Local_Orbital_Charge::cal_dk_k(const Grid_Technique >) DM_ATOM[is]=new complex[DM_ATOM_SIZE]; } for(int is=0; isDM_R[0][gstart+iv]=DM_ATOM[0][iv].real() + DM_ATOM[3][iv].real(); - if(NONCOLIN){//DOMAG - this->DM_R[1][gstart+iv]=DM_ATOM[1][iv].real() + DM_ATOM[2][iv].real(); - this->DM_R[2][gstart+iv]=DM_ATOM[1][iv].imag() - DM_ATOM[2][iv].imag(); - this->DM_R[3][gstart+iv]=DM_ATOM[0][iv].real() - DM_ATOM[3][iv].real(); - } - else if(!NONCOLIN)//DOMAG_Z - { - this->DM_R[1][gstart+iv]= 0.0; - this->DM_R[1][gstart+iv]= 0.0; - this->DM_R[3][gstart+iv]=DM_ATOM[0][iv].real() - DM_ATOM[3][iv].real(); - } - else//soc with no mag - { - this->DM_R[1][gstart+iv]= 0.0; - this->DM_R[2][gstart+iv]= 0.0; - this->DM_R[3][gstart+iv]= 0.0; - } - } - } + //note: storage nondiagonal term as Re[] and Im[] respectly; + this->DM_R[0][gstart+iv]=DM_ATOM[0][iv].real() + DM_ATOM[3][iv].real(); + if(NONCOLIN){//DOMAG + this->DM_R[1][gstart+iv]=DM_ATOM[1][iv].real() + DM_ATOM[2][iv].real(); + this->DM_R[2][gstart+iv]=DM_ATOM[1][iv].imag() - DM_ATOM[2][iv].imag(); + this->DM_R[3][gstart+iv]=DM_ATOM[0][iv].real() - DM_ATOM[3][iv].real(); + } + else if(!NONCOLIN)//DOMAG_Z + { + this->DM_R[1][gstart+iv]= 0.0; + this->DM_R[1][gstart+iv]= 0.0; + this->DM_R[3][gstart+iv]=DM_ATOM[0][iv].real() - DM_ATOM[3][iv].real(); + } + else//soc with no mag + { + this->DM_R[1][gstart+iv]= 0.0; + this->DM_R[2][gstart+iv]= 0.0; + this->DM_R[3][gstart+iv]= 0.0; + } + } + } } // if gt.in_this_processor }// I1 }// T1 @@ -839,10 +846,14 @@ void Local_Orbital_Charge::cal_dk_k(const Grid_Technique >) } */ for(int i=0; i=0) { ofs_running<<"DM(0,0)"<DM[is][i], lgd_now); + } + } for(int is=0; istaud[ia].x - << " " << atom->taud[ia].y - << " " << atom->taud[ia].z << endl; - } - } + if (out_dm==0) + { + return; + } + else if(iter % out_dm != 0) + { + return; + } + timer::tick("Local_Orbital_Charge","write_dm"); - ofs << "\n " << NSPIN; - if(NSPIN==1||NSPIN==4) - { - ofs << "\n " << en.ef << " (fermi energy)"; - } - else if(NSPIN==2) - { - if(is==0)ofs << "\n " << en.ef_up << " (fermi energy for spin=1)"; - else if(is==1)ofs << "\n " << en.ef_dw << " (fermi energy for spin=2)"; - } - else - { - WARNING_QUIT("write_rho","check nspin!"); - } + time_t start, end; + ofstream ofs; - - ofs << "\n " << NLOCAL << " " << NLOCAL << endl; + if(MY_RANK==0) + { + start = time(NULL); + + ofs.open(fn.c_str()); + if (!ofs) + { + WARNING("Charge::write_rho","Can't create Charge File!"); + } + + //ofs_running << "\n Output charge file." << endl; + + ofs << ucell.latName << endl;//1 + ofs << " " << ucell.lat0 * BOHR_TO_A << endl; + ofs << " " << ucell.latvec.e11 << " " << ucell.latvec.e12 << " " << ucell.latvec.e13 << endl; + ofs << " " << ucell.latvec.e21 << " " << ucell.latvec.e22 << " " << ucell.latvec.e23 << endl; + ofs << " " << ucell.latvec.e31 << " " << ucell.latvec.e32 << " " << ucell.latvec.e33 << endl; + for(int it=0; ittaud[ia].x + << " " << atom->taud[ia].y + << " " << atom->taud[ia].z << endl; + } + } - } + ofs << "\n " << NSPIN; + if(NSPIN==1||NSPIN==4) + { + ofs << "\n " << en.ef << " (fermi energy)"; + } + else if(NSPIN==2) + { + if(is==0)ofs << "\n " << en.ef_up << " (fermi energy for spin=1)"; + else if(is==1)ofs << "\n " << en.ef_dw << " (fermi energy for spin=2)"; + } + else + { + WARNING_QUIT("write_rho","check nspin!"); + } + + + ofs << "\n " << NLOCAL << " " << NLOCAL << endl; + + ofs << setprecision(precision); + ofs << scientific; + + } //ofs << "\n " << GAMMA_ONLY_LOCAL << " (GAMMA ONLY LOCAL)" << endl; #ifndef __MPI @@ -1397,13 +1419,13 @@ void Local_Orbital_Charge::write_dm(const int &is, const int &iter, const string WARNING_QUIT("local_orbital_charge","not ready to output DM_R"); } #endif - if(MY_RANK==0) - { - end = time(NULL); - OUT_TIME("write_rho",start,end); - ofs.close(); - } - timer::tick("Local_Orbital_Charge","write_dm"); + if(MY_RANK==0) + { + end = time(NULL); + OUT_TIME("write_rho",start,end); + ofs.close(); + } + timer::tick("Local_Orbital_Charge","write_dm"); return; } diff --git a/ABACUS.develop/source/src_lcao/local_orbital_wfc.h b/ABACUS.develop/source/src_lcao/local_orbital_wfc.h index 341ae46b27..c7665fed02 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_wfc.h +++ b/ABACUS.develop/source/src_lcao/local_orbital_wfc.h @@ -7,6 +7,7 @@ class Local_Orbital_wfc { public: + Local_Orbital_wfc(); ~Local_Orbital_wfc(); From d8be35f803467ab475d2a22f5f880d5388dddfae Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 9 Feb 2021 11:24:31 +0800 Subject: [PATCH 087/233] delte WFC_GAMMA and related functions in src_parallel/subgrid_oper.h and .cpp, it also affects two parts in exx code, it disable istate_charge and istate_envelope functions, so we might need to update this part in near future --- .../source/src_lcao/exx_abfs-dm.cpp | 20 +- ABACUS.develop/source/src_lcao/exx_lcao.cpp | 10 +- .../source/src_lcao/istate_charge.cpp | 8 +- .../source/src_lcao/istate_envelope.cpp | 13 +- .../source/src_lcao/local_orbital_charge.cpp | 1 - .../source/src_lcao/local_orbital_elec.cpp | 6 +- .../source/src_lcao/local_orbital_ions.cpp | 28 +- .../source/src_lcao/local_orbital_wfc.cpp | 304 ------------ .../source/src_lcao/local_orbital_wfc.h | 6 +- ABACUS.develop/source/src_lcao/wf_local.cpp | 6 +- ABACUS.develop/source/src_lcao/wfc_dm_2d.h | 6 +- .../source/src_parallel/subgrid_oper.cpp | 436 ------------------ .../source/src_parallel/subgrid_oper.h | 4 - ABACUS.develop/source/src_pw/chi0_hilbert.cpp | 12 +- ABACUS.develop/source/src_pw/chi0_hilbert.h | 64 +-- ABACUS.develop/source/src_pw/potential.cpp | 76 +-- 16 files changed, 150 insertions(+), 850 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-dm.cpp b/ABACUS.develop/source/src_lcao/exx_abfs-dm.cpp index 71e81c90cc..a7171426db 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-dm.cpp +++ b/ABACUS.develop/source/src_lcao/exx_abfs-dm.cpp @@ -109,9 +109,23 @@ map>> Exx_Abfs::DM::cal_DMk_raw( const s for( size_t ib=0; ib!=NBANDS; ++ib ) { if( GAMMA_ONLY_LOCAL ) - DMk_raw[iat1][iat2][ik](iw1,iw2) += wf.wg(ik,ib) * LOWF.WFC_GAMMA[ik][ib][ucell.itiaiw2iwt(it1,ia1,iw1)] * LOWF.WFC_GAMMA[ik][ib][ucell.itiaiw2iwt(it2,ia2,iw2)]; + { + //--------------------------------------------------------- + // LOWF.WFC_GAMMA has been replaced by wfc_dm_2d.cpp + // we need to fix this function in near future. + // -- mohan add 2021-02-09 + //--------------------------------------------------------- + WARNING_QUIT("Exx_Abfs::DM::cal_DMk_raw","need to update LOWF.WFC_GAMMA"); +// DMk_raw[iat1][iat2][ik](iw1,iw2) += wf.wg(ik,ib) +// * LOWF.WFC_GAMMA[ik][ib][ucell.itiaiw2iwt(it1,ia1,iw1)] +// * LOWF.WFC_GAMMA[ik][ib][ucell.itiaiw2iwt(it2,ia2,iw2)]; + } else - DMk_raw[iat1][iat2][ik](iw1,iw2) += wf.wg(ik,ib) * LOWF.WFC_K[ik][ib][ucell.itiaiw2iwt(it1,ia1,iw1)] * conj(LOWF.WFC_K[ik][ib][ucell.itiaiw2iwt(it2,ia2,iw2)]); + { + DMk_raw[iat1][iat2][ik](iw1,iw2) += wf.wg(ik,ib) + * LOWF.WFC_K[ik][ib][ucell.itiaiw2iwt(it1,ia1,iw1)] + * conj(LOWF.WFC_K[ik][ib][ucell.itiaiw2iwt(it2,ia2,iw2)]); + } } } } @@ -208,4 +222,4 @@ void Exx_Abfs::DM::pulay_mixing( #elif TEST_EXX_LCAO==-1 #error #endif -} \ No newline at end of file +} diff --git a/ABACUS.develop/source/src_lcao/exx_lcao.cpp b/ABACUS.develop/source/src_lcao/exx_lcao.cpp index e15040bd82..7b186a62dd 100644 --- a/ABACUS.develop/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/exx_lcao.cpp @@ -978,7 +978,15 @@ ofs_mpi.close(); for( size_t ib=0; ib!=NBANDS; ++ib ) { for( size_t iwt=0; iwt!=NLOCAL; ++iwt ) - ofs<= 0) { + //--------------------------------------------------------- + // LOWF.WFC_GAMMA has been replaced by wfc_dm_2d.cpp + // we need to fix this function in near future. + // -- mohan add 2021-02-09 + //--------------------------------------------------------- + WARNING_QUIT("IState_Charge::idmatrix","need to update LOWF.WFC_GAMMA"); // 2 stands for degeneracy. - alpha[nu_local] += 2.0 * LOWF.WFC_GAMMA[is][ib][mu_local] * LOWF.WFC_GAMMA[is][ib][nu_local]; + //alpha[nu_local] += 2.0 * LOWF.WFC_GAMMA[is][ib][mu_local] * LOWF.WFC_GAMMA[is][ib][nu_local]; } } } diff --git a/ABACUS.develop/source/src_lcao/istate_envelope.cpp b/ABACUS.develop/source/src_lcao/istate_envelope.cpp index 9693e47ec0..b36b85a1d7 100644 --- a/ABACUS.develop/source/src_lcao/istate_envelope.cpp +++ b/ABACUS.develop/source/src_lcao/istate_envelope.cpp @@ -77,7 +77,18 @@ void IState_Envelope::begin(void) { cout << " Perform envelope function for band " << ib+1 << endl; ZEROS(CHR.rho[is],pw.nrxx); - UHM.GG.cal_env( LOWF.WFC_GAMMA[is][ib], CHR.rho[is] ); + + + //--------------------------------------------------------- + // LOWF.WFC_GAMMA has been replaced by wfc_dm_2d.cpp + // we need to fix this function in near future. + // -- mohan add 2021-02-09 + //--------------------------------------------------------- + WARNING_QUIT("IState_Charge::idmatrix","need to update LOWF.WFC_GAMMA"); + + //UHM.GG.cal_env( LOWF.WFC_GAMMA[is][ib], CHR.rho[is] ); + + CHR.save_rho_before_sum_band(); //xiaohui add 2014-12-09 stringstream ss; ss << global_out_dir << "BAND" << ib + 1 << "_ENV" << is+1 << "_CHG"; diff --git a/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp b/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp index f4dda5898c..0f0999e9a5 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp @@ -97,7 +97,6 @@ void Local_Orbital_Charge::allocate_dm_wfc(const Grid_Technique >) { // here we reset the density matrix dimension. this->allocate_gamma(gt); - LOWF.aloc_gamma_wfc(gt); } else { diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp index 916a10827e..eb8624f3ed 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp @@ -804,7 +804,8 @@ void Local_Orbital_Elec::cal_bands(const int &istep) } // SGO: sub_grid_operation - SGO.cal_totwfc(); + // mohan comment out 2021-02-09 + // SGO.cal_totwfc(); //-------------------------------------- @@ -836,7 +837,8 @@ void Local_Orbital_Elec::cal_bands(const int &istep) MPI_Barrier(MPI_COMM_WORLD); #endif // distribute the wave functions again. - SGO.dis_subwfc(); + // delete the function -- mohan 2021-02-09 + // SGO.dis_subwfc(); }//end gamma // with k points else diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index 2b4a0d51ed..56061f1006 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -162,30 +162,21 @@ void Local_Orbital_Ions::opt_ions(void) // the force. LOWF.set_trace_aug(GridT); - // (5) init density kernel - // (6) init wave functions. + // (5) init density kernel and wave functions. LOC.allocate_dm_wfc(GridT); //====================================== // do the charge extrapolation before // the density matrix is regenerated. // mohan add 2011-04-08 - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // once the atom is move out of this processor, - // the density matrix will not map - // the 'moved' atom configuration, - //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // because once atoms are moving out of this processor, + // the density matrix will not map the new atomic configuration, //====================================== - // HOWEVER, I ACTUALLY FOUND THIS IS - // A BUG, BECAUSE THE INDEX GridT.trace_lo + // THIS IS A BUG, BECAUSE THE INDEX GridT.trace_lo // HAS BEEN REGENERATED, SO WE NEED TO - // REALLOCATE THE DENSITY MATRIX FIRST, - // THEN WE CAN READ IN DENSITY MATRIX, - // AND USE DENSITY MATRIX TO DO - // RHO CALCULATION. - // -- mohan 2013-03-31 + // REALLOCATE DENSITY MATRIX FIRST, THEN READ IN DENSITY MATRIX, + // AND USE DENSITY MATRIX TO DO RHO CALCULATION.-- mohan 2013-03-31 //====================================== - //if(pot.extra_pot==4 && istep>1) if(pot.extra_pot=="dm" && istep>1)//xiaohui modify 2015-02-01 { for(int is=0; isWFC_GAMMA[is][i]; - } - delete[] this->WFC_GAMMA[is]; - } - delete[] this->WFC_GAMMA; - } - // used for force if(allocate_aug_flag) { @@ -174,127 +160,6 @@ void Local_Orbital_wfc::allocate_k(const Grid_Technique >) return; } -//================================================================ -// FUNCTION: -// wave functions must be distributed. -// wave functions are used to construct the new charge density. -//================================================================ -void Local_Orbital_wfc::aloc_gamma_wfc(const Grid_Technique >) -{ - TITLE("Local_Orbital_wfc","aloc_gamma_wfc"); - -// if(DIAGO_TYPE=="selinv") return; //mohan add 2011-10-23 - - if(NLOCAL < NBANDS) - { - WARNING_QUIT("Local_Orbital_wfc::allocate","NLOCALWFC_GAMMA[is][ib]; - } - } - allocate_flag = false; - } - - // mohan fix bug 2011-03-15 - static bool first = true; - if(first) - { - this->WFC_GAMMA = new double**[NSPIN]; - for(int is=0; isWFC_GAMMA[is] = new double*[NBANDS]; - } - first=false; - } - - // mohan add 2010-09-06 - if( gt.lgd != 0) - { - // Create wave functions(Coefficients) in local basis. - // Same as evc in plane wave basis. - for(int is=0; isWFC_GAMMA[is][ib] = new double[gt.lgd]; - ZEROS(this->WFC_GAMMA[is][ib],gt.lgd); - } - Memory::record("LocalOrbital_Coef","WFC_GAMMA",NSPIN*NBANDS*NLOCAL,"double"); - allocate_flag = true; - } - } - - OUT(ofs_running,"start_wfc",wf.start_wfc); - if(wf.start_wfc == "atomic" ) - { - for(int is=0; is=0) - { - // be careful! std::rand must be translated to double! - // this->WFC_GAMMA[is][i][mu] = static_cast( std::rand() ) / RAND_MAX ; - - // mohan modify 2010-07-02 - this->WFC_GAMMA[is][i][mu] = 1.0; - } - } - }// j - }// i - }// is - -// cout << " set LCAO wave fuctions to unit." << endl; - } - else if(wf.start_wfc == "file") - { - int error; - for(int is=0; isWFC_GAMMA[is] ); - } -#ifdef __MPI - Parallel_Common::bcast_int(error); -#endif - ofs_running << " Error=" << error << endl; - if(error==1) - { - WARNING_QUIT("Local_Orbital_wfc","Can't find the wave function file: LOWF.dat"); - } - else if(error==2) - { - WARNING_QUIT("Local_Orbital_wfc","In wave function file, band number doesn't match"); - } - else if(error==3) - { - WARNING_QUIT("Local_Orbital_wfc","In wave function file, nlocal doesn't match"); - } - } - else - { - WARNING_QUIT("Local_Orbital_wfc","check the parameter: start_wfc"); - } - - - return; -} void Local_Orbital_wfc::set_trace_aug(const Grid_Technique >) { @@ -442,172 +307,3 @@ void Local_Orbital_wfc::set_trace_aug(const Grid_Technique >) timer::tick("Local_Orbital_wfc","set_trace_aug",'D'); return; } - -void Local_Orbital_wfc::init_Cij( const bool change_c ) -{ - TITLE("Local_Orbial_Coef", "init_Cij"); - timer::tick("Local_Orbital_wfc","init_Cij"); - - OUT(ofs_running,"init S matrix",UHM.init_s); - if(!UHM.init_s) - { - WARNING_QUIT("Local_Orbital_wfc","not yet init S matrix"); - } - - double *psi = new double[NLOCAL]; - double *sc = new double[NLOCAL]; - - // if the trial wave function is not orthogonal, - // try new set. - // try_new_wave_function_again: - - // output s matrix. - /* - for(int i=0; iWFC_GAMMA[is][m][j]; - // if(j%8==0) ofs_running << endl; - // ofs_running << setw(15) << psi[j]; - } - - //ofs_running << endl; - - // calculate S|psi> - //hm.s_1psi_real(NLOCAL, psi, sc); - - // calculate - double norm = 0.0; - for(int j=0; j 0.0 ); - norm = sqrt( norm ); - - ofs_running << " " << setw(8) << m+1 << setw(20) << norm; - // if we want to make sure the c orthogonal, - // we need =delta_{ij} - if(change_c) - { - // normalize using . - for(int j=0; jWFC_GAMMA[is][m][j] = psi[j]; - } - - // check the norm again. - //hm.s_1psi_real(NLOCAL, psi, sc); // sphi = S|psi(m)> - - norm = 0.0; - for(int j=0; j 0.0 ); - norm = sqrt( norm ); - ofs_running << setw(20) << norm << endl; - - } - } - } - - if(!change_c) return; - - for(int is=0; ischeck_orthogonal(psi, sc, is); - - if(which_band == -1) - { - OUT(ofs_running,"all bands orthogonal", "true"); - } - else - { - OUT(ofs_running,"not orthogonal band",which_band); - BLOCK_HERE("orthogonal"); - } - } - - delete[] psi; - delete[] sc; - timer::tick("Local_Orbital_wfc","init_Cij"); - return; -} - -/* xiaohui modified 2013-04-24 -int Local_Orbital_wfc::check_orthogonal(double *psi, double *sc, const int &is) -{ - Diago_CG_Real::reduce_type = 1; - - // make cij orthogonal - double *tmpc = new double[NLOCAL]; - for(int m=0; m=0) - { - occupy[i] += 1; - } - } - - // reduce occupy and get the full occupations. -#ifdef __MPI - Parallel_Reduce::reduce_int_grid(occupy, NLOCAL); -#endif - - delete[] trace_aug_tot; - trace_aug_tot = new int[NLOCAL]; - ZEROS(trace_aug_tot,NLOCAL); - for(int i=0; i= 0) - { - occupy[iw] = 1; - } - } - - // reduce occupy and get the full occupations. -#ifdef __MPI - // mohan 2012-02-23 - if(ATOM_DISTRIBUTION==1) - { - ofs_running << " Because of the atom distribution." << endl; - ofs_running << " Don't reduce the trace_lo_tot here." << endl; - } - else - { - Parallel_Reduce::reduce_int_grid(occupy, NLOCAL); - } -#endif - - /* - for(int i=0; itotwfc = new double**[1]; - for(int is=0; is<1; ++is) - { - this->totwfc[is] = new double*[NBANDS]; - } - } - // for B field. - else - { - this->totwfc_B = new complex**[1]; - for(int is=0; is<1; ++is) - { - this->totwfc_B[is] = new complex*[NBANDS]; - } - } - this->allocate_totwfc=false; - return; - } - - assert(this->allocate_totwfc==false); - - static bool first_time=true; - if(first_time) - { -// LOWF.init_Cij(1); - first_time=false; - } - - - this->totwfc = new double**[1]; - for(int is=0; is<1; ++is) - { - this->totwfc[is] = new double*[NBANDS]; - for(int ib=0; ibtotwfc[is][ib] = new double[lgd]; - ZEROS(totwfc[is][ib], lgd); - - // mohan update 2012-02-10 - //if(DIAGO_TYPE!="cg") xiaohui modify 2013-09-02 - if(KS_SOLVER!="cg") //xiaohui add 2013-09-02 - { - for(int i=0; itotwfc[is][ib][i] = LOWF.WFC_GAMMA[CURRENT_SPIN][ib][i]; //mohan update 2012-02-07 - } - } - } - } - - allocate_totwfc = true; - } - - delete[] occupy; //mohan fix bug 2012-03-25 - - return; -} - - -void SubGrid_oper::dis_subwfc() -{ - TITLE("SubGrid_oper","dis_subwfc"); - -#ifdef __MPI - -// cout << " distribute the wave functions " << endl; - - //------------------------------------------ - // bcast the eigenvalues - //------------------------------------------ - for(int ik=0; ik= 0) - { - const int mu2 = this->trace_lo_tot[iw]; - - for(int ib=0; ibtotwfc[0][ib][mu2]; - }//ib - }//mu1>=0 - }//iw - }//i - else - { - int tag; - // receive trace_lo2 - tag = i * 10; - int* trace_lo2 = new int[NLOCAL]; - MPI_Recv(trace_lo2, NLOCAL, MPI_INT, i, tag, GRID_WORLD, &status); - -/* - ofs_running << " Proc " << i << endl; - for(int i=0; i0 && NSPIN==4) - { - if(PRENSPIN == 1) - {//read only up+down , others set to zero. - ofs_running << " Didn't read in the charge density but autoset it for spin " <0 && NSPIN==4) { - ofs_running << " rearrange charge density " << endl; - for(int ir=0;irv_of_rho( CHR.rho, en.ehart, en.etxc, en.vtxc, vr, delta_vh, vna); //---------------------------------------------------------- - // Define the total local potential (external+scf) + // Define the total local potential (external+scf) in DFT + // Define TDDFT potential, by Fuxiang He //---------------------------------------------------------- if(vext == 0) { From ebc42b9dd477ee439e3bfe2b3d410d4634204120 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 9 Feb 2021 14:39:30 +0800 Subject: [PATCH 088/233] delete the VNA function and related codes, but the version has segmentation fault for gamma_only version using LCAO, will fix soon --- ABACUS.develop/source/input_conv.cpp | 2 - .../source/src_global/global_variable.cpp | 2 - .../source/src_global/global_variable.h | 2 - .../source/src_global/print_info.cpp | 7 +- .../source/src_lcao/force_lcao_gamma.cpp | 80 +-- .../source/src_lcao/force_lcao_gamma.h | 1 - .../source/src_lcao/force_lcao_k.cpp | 63 +-- ABACUS.develop/source/src_lcao/force_lcao_k.h | 4 - .../source/src_lcao/gint_gamma_vna.cpp | 485 ----------------- .../source/src_lcao/gint_gamma_vna_d.cpp | 463 ---------------- ABACUS.develop/source/src_lcao/gint_k.cpp | 476 +--------------- ABACUS.develop/source/src_lcao/gint_k.h | 65 --- .../source/src_lcao/gint_k_fvna.cpp | 512 ------------------ ABACUS.develop/source/src_lcao/gint_k_vna.cpp | 347 ------------ .../source/src_lcao/gint_k_vna_d.cpp | 218 -------- ABACUS.develop/source/src_lcao/gint_speed.cpp | 333 ------------ ABACUS.develop/source/src_lcao/gint_speed.h | 42 -- .../source/src_lcao/gint_speed2.cpp | 430 --------------- .../source/src_lcao/gint_speed_rho.cpp | 183 ------- .../source/src_lcao/grid_bigcell.cpp | 7 +- ABACUS.develop/source/src_lcao/grid_bigcell.h | 2 +- .../source/src_lcao/grid_technique.cpp | 6 +- .../source/src_lcao/grid_technique.h | 3 +- .../source/src_lcao/lcao_orbitals.cpp | 58 -- .../source/src_lcao/lcao_orbitals.h | 2 - ABACUS.develop/source/src_lcao/lcao_vna.cpp | 207 ------- ABACUS.develop/source/src_lcao/lcao_vna.h | 24 - .../source/src_lcao/local_orbital_charge.cpp | 9 +- .../source/src_lcao/local_orbital_elec.cpp | 31 +- .../source/src_lcao/local_orbital_ions.cpp | 12 +- .../source/src_lcao/make_vna_table.cpp | 355 ------------ .../source/src_lcao/make_vna_table.h | 86 --- .../source/src_lcao/neutral_pot.cpp | 356 ------------ ABACUS.develop/source/src_lcao/neutral_pot.h | 57 -- .../source/src_lcao/numerical_vna_lm.cpp | 238 -------- .../source/src_lcao/numerical_vna_lm.h | 90 --- .../source/src_lcao/use_hamilt_matrix.cpp | 67 +-- .../source/src_lcao/use_hamilt_matrix.h | 3 - .../source/src_lcao/use_overlap_table.cpp | 62 +-- .../source/src_lcao/use_overlap_table.h | 26 +- 40 files changed, 60 insertions(+), 5356 deletions(-) delete mode 100644 ABACUS.develop/source/src_lcao/gint_gamma_vna.cpp delete mode 100644 ABACUS.develop/source/src_lcao/gint_gamma_vna_d.cpp delete mode 100644 ABACUS.develop/source/src_lcao/gint_k_fvna.cpp delete mode 100644 ABACUS.develop/source/src_lcao/gint_k_vna.cpp delete mode 100644 ABACUS.develop/source/src_lcao/gint_k_vna_d.cpp delete mode 100644 ABACUS.develop/source/src_lcao/gint_speed.cpp delete mode 100644 ABACUS.develop/source/src_lcao/gint_speed.h delete mode 100644 ABACUS.develop/source/src_lcao/gint_speed2.cpp delete mode 100644 ABACUS.develop/source/src_lcao/gint_speed_rho.cpp delete mode 100644 ABACUS.develop/source/src_lcao/lcao_vna.cpp delete mode 100644 ABACUS.develop/source/src_lcao/lcao_vna.h delete mode 100644 ABACUS.develop/source/src_lcao/make_vna_table.cpp delete mode 100644 ABACUS.develop/source/src_lcao/make_vna_table.h delete mode 100644 ABACUS.develop/source/src_lcao/neutral_pot.cpp delete mode 100644 ABACUS.develop/source/src_lcao/neutral_pot.h delete mode 100644 ABACUS.develop/source/src_lcao/numerical_vna_lm.cpp delete mode 100644 ABACUS.develop/source/src_lcao/numerical_vna_lm.h diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index c5567437fb..3b1539e431 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -70,8 +70,6 @@ void Input_Conv::Convert(void) NSPIN = INPUT.nspin; // 7 CURRENT_SPIN = 0; // 8 - VNA = INPUT.vna; - GRID_SPEED = INPUT.grid_speed; // FORCE = INPUT.force; // 8.1 FORCE_THR = INPUT.force_thr; // 8.2 diff --git a/ABACUS.develop/source/src_global/global_variable.cpp b/ABACUS.develop/source/src_global/global_variable.cpp index 15c7f36b9c..fc8aa2a59a 100644 --- a/ABACUS.develop/source/src_global/global_variable.cpp +++ b/ABACUS.develop/source/src_global/global_variable.cpp @@ -32,8 +32,6 @@ string DFT_FUNCTIONAL = "none"; int NSPIN = 1; // LDA bool TWO_EFERMI = 0; // two fermi energy, exist only magnetization is fixed. int CURRENT_SPIN = 0; -int VNA = 0;//mohan add 2011-05-27 -int GRID_SPEED = 1; //mohan add 2012-03-29 int FORCE = 0;// if force >1, means do the grid integration 'force' times. double FORCE_THR = 1.0e-3; bool STRESS = false; diff --git a/ABACUS.develop/source/src_global/global_variable.h b/ABACUS.develop/source/src_global/global_variable.h index b242171665..8e77f84123 100644 --- a/ABACUS.develop/source/src_global/global_variable.h +++ b/ABACUS.develop/source/src_global/global_variable.h @@ -34,8 +34,6 @@ extern int NSPIN; // 7 extern bool TWO_EFERMI; // 7.5 mohan add 2011-04-03, two fermi energy, exist if magnetization is fixed. extern int CURRENT_SPIN; // 8 -extern int VNA; // 8.01 // mohan add 2011-05-27 -extern int GRID_SPEED; // 8.02 // mohan add 2012-03-29 extern int FORCE; // 8.1 extern double FORCE_THR; // 8.2 extern bool STRESS; // 8.25 calcualte the stress diff --git a/ABACUS.develop/source/src_global/print_info.cpp b/ABACUS.develop/source/src_global/print_info.cpp index 11e2adca32..24bf3fb47f 100644 --- a/ABACUS.develop/source/src_global/print_info.cpp +++ b/ABACUS.develop/source/src_global/print_info.cpp @@ -110,11 +110,8 @@ void Print_Info::screen_output(void) if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-01 { cout << setw(12) << NLOCAL; - - if(VNA==0) - cout << setw(12) << "No"; - else if(VNA>0) - cout << setw(12) << "Yes"; + // print VNA: no, should delete in future -- mohan 2021-02-09 + cout << setw(12) << "No"; } cout << endl; diff --git a/ABACUS.develop/source/src_lcao/force_lcao_gamma.cpp b/ABACUS.develop/source/src_lcao/force_lcao_gamma.cpp index 9ef589d1dd..9c63bcc83f 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao_gamma.cpp +++ b/ABACUS.develop/source/src_lcao/force_lcao_gamma.cpp @@ -1129,39 +1129,6 @@ void Force_LCAO_gamma::test_gamma(double* mm, const string &name) return; } -void Force_LCAO_gamma::cal_fvna(LCAO_Matrix &LM) -{ - TITLE("Force_LCAO_gamma","cal_fvna"); - timer::tick("Force_LCAO_gamma","cal_fvna",'H'); - int istep=1; - bool delta_vh = 0; - bool vna = 1; // tmp by mohan - - int dense = VNA; - OUT(ofs_running,"dense grid for VNA force",dense); - Grid_Technique gtf; - gtf.set_pbc_grid( - pw.ncx*dense,pw.ncy*dense,pw.ncz*dense, - pw.bx*dense,pw.by*dense,pw.bz*dense, - pw.nbx,pw.nby,pw.nbz, - pw.nbxx,pw.nbzp_start,pw.nbzp, - vna); - -//-------------------------------------------------------- -// The neutral potential can be only used when vna = 1, -// then to be used to check if the real space neutral -// potential is correct -//-------------------------------------------------------- -// pot.init_pot(istep, delta_vh, vna); -// for(int ir=0; ircal_fvna(LM); - } double* tmpDHx = new double[ParaO.nloc]; double* tmpDHy = new double[ParaO.nloc]; @@ -1216,19 +1173,7 @@ void Force_LCAO_gamma::cal_fvl_dphi(double** dm2d) //calculate int istep = 1; - if(VNA) - { - // calculate the (delta_Vh + Vxc) - bool delta_vh = 1; - bool vna = 0; - // istep must set to 1, other wise the charge - // density may be changed! - pot.init_pot(istep, delta_vh, vna); - } - else - { - pot.init_pot(istep); - } + pot.init_pot(istep); for(int is=0; is &dm2d) } } - if(OUT_LEVEL != "m") OUT(ofs_running,"VNA",VNA); - - //=================================== - // the neutral potential part. - //=================================== - if(VNA) - { - this->cal_fvna(LM); - } double* tmpDHx = new double[ParaO.nloc]; double* tmpDHy = new double[ParaO.nloc]; @@ -1607,19 +1543,7 @@ void Force_LCAO_gamma::cal_fvl_dphi(const std::vector &dm2d) //calculate int istep = 1; - if(VNA) - { - // calculate the (delta_Vh + Vxc) - bool delta_vh = 1; - bool vna = 0; - // istep must set to 1, other wise the charge - // density may be changed! - pot.init_pot(istep, delta_vh, vna); - } - else - { - pot.init_pot(istep); - } + pot.init_pot(istep); for(int is=0; is - // fvl_dphi must be set to zero before. - //----------------------------------------------------- - if(STRESS) {UHM.GK.svna_k_RealSpace(gtf, this->fvl_dphi, this->svl_dphi);} - else {UHM.GK.fvna_k_RealSpace(gtf, this->fvl_dphi);} - - timer::tick("Force_LCAO_k","force_vna_k",'h'); - return; -} // calculate the force due to < phi | Vlocal | dphi > void Force_LCAO_k::cal_fvl_dphi_k(double** dm2d) @@ -965,26 +923,9 @@ void Force_LCAO_k::cal_fvl_dphi_k(double** dm2d) } int istep = 1; - if(VNA) - { - // calculate the force contribution from Vna. - for(int is=0; is - void force_vna_k(void); }; #endif diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_vna.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_vna.cpp deleted file mode 100644 index 240390c961..0000000000 --- a/ABACUS.develop/source/src_lcao/gint_gamma_vna.cpp +++ /dev/null @@ -1,485 +0,0 @@ -#include "gint_gamma.h" -#include "grid_technique.h" -#include "lcao_orbitals.h" -#include "../src_pw/global.h" - -#include "global_fp.h" // mohan add 2021-01-30 - -void Gint_Gamma::cal_vna( - const double* vlocal_in) -{ - TITLE("Gint_Gamma","cal_vna"); - timer::tick("Gint_Gamma","cal_vna"); - - this->job = cal_local; - this->vlocal = vlocal_in; - this->save_atoms_on_grid(GridT); - this->gamma_vna(); - - timer::tick("Gint_Gamma","cal_vna"); - return; -} - -void Gint_Gamma::gamma_vna(void) -{ - TITLE("Grid_Integral","gamma_vna"); - - double** GridVlocal; - bool perform_gint = true; - - const int lgd_now = GridT.lgd; - if(lgd_now > 0) - { - GridVlocal = new double*[lgd_now]; - for (int i=0; igrid_index = (k-nbz_start) + j * nbz + i * nby * nbz; - - // get the value: how many atoms has orbital value on this grid. - const int size = GridT.how_many_atoms[ this->grid_index ]; - if(size==0) continue; - - ZEROS(vna3d, pw.bxyz); - - // (1) initialized the phi * Ylm. - for (int id=0; id ORB.Vna[it].rcut && - distance[ib][id] > ORB.Phi[it].getRcut()) - { - cal_flag[ib][id]=false; - continue; - } - - //if(distance[id] > GridT.orbital_rmax) continue; - // Ylm::get_ylm_real(this->nnn[it], this->dr[id], ylma); - if (distance[ib][id] < 1.0E-9) distance[ib][id] += 1.0E-9; - - Ylm::sph_harm ( ucell.atoms[it].nwl, - dr[ib][id][0] / distance[ib][id], - dr[ib][id][1] / distance[ib][id], - dr[ib][id][2] / distance[ib][id], - ylma); - // these parameters are about interpolation - // because once we know the distance from atom to grid point, - // we can get the parameters we need to do interpolation and - // store them first!! these can save a lot of effort. - const double position = distance[ib][id] / delta_r; - this->iq[id] = static_cast(position); - this->x0[id] = position - static_cast(iq[id]); - this->x1[id] = 1.0 - x0[id]; - this->x2[id] = 2.0 - x0[id]; - this->x3[id] = 3.0 - x0[id]; - this->x12[id] = x1[id]*x2[id] / 6.0; - this->x03[id] = x0[id]*x3[id] / 2.0; - - int ip; - double dx, dx2, dx3; - double c1, c2, c3, c4; - - ip = static_cast(position); - dx = position - ip; - dx2 = dx * dx; - dx3 = dx2 * dx; - - c3 = 3.0*dx2-2.0*dx3; - c1 = 1.0-c3; - c2 = (dx-2.0*dx2+dx3)*delta_r; - c4 = (dx3-dx2)*delta_r; - - double ccc; - if(distance[ib][id] <= ORB.Vna[it].rcut) - { - ccc = (x12[id]*(ORB.Vna[it].vna_u[iq[id]]*x3[id] - +ORB.Vna[it].vna_u[iq[id]+3]*x0[id]) - + x03[id]*(ORB.Vna[it].vna_u[iq[id]+1]*x2[id] - -ORB.Vna[it].vna_u[iq[id]+2]*x1[id])); - // cout << " ccc=" << ccc << endl; - // int ok; cin >> ok; - vna3d[ib] += ccc; - } - -// if(i==0 && j==7 &&k==13 && ib==6) -// { -// ofs << " dis=" << distance[ib][id] << " ccc=" << ccc << endl; -// ofs << " 1=" << ORB.Vna[it].vna_u[iq[id]] << endl; -// ofs << " 2=" << ORB.Vna[it].vna_u[iq[id]+1] << endl; -// ofs << " 3=" << ORB.Vna[it].vna_u[iq[id]+2] << endl; -// ofs << " 4=" << ORB.Vna[it].vna_u[iq[id]+3] << endl; -// } - - // int ip = this->iq[id]; - // double A = ip+1.0-position/delta_r; - // double B = 1.0-A; - // double coef1 = (A*A*A-A)/6.0*delta_r*delta_r; - // double coef2 = (B*B*B-B)/6.0*delta_r*delta_r; - - - if(distance[ib][id] <= ORB.Phi[it].getRcut()) - { - cal_flag[ib][id]=true; - } - else - { - cal_flag[ib][id]=false; - continue; - } - - - Atom* atom1 = &ucell.atoms[it]; - for (int iw=0; iw< atom1->nw; iw++) - { - if ( atom1->iw2_new[iw] ) - { - pointer = &ORB.Phi[it].PhiLN( - atom1->iw2l[iw], - atom1->iw2n[iw]); - phi = c1*pointer->psi_uniform[ip]+c2*pointer->dpsi_uniform[ip] - + c3*pointer->psi_uniform[ip+1]+c4*pointer->dpsi_uniform[ip+1]; - } - psir_ylm[ib][id][iw] = phi * ylma[atom1->iw2_ylm[iw]]; - //psir_ylm[ib][id][iw] = 1;//for test - } - }// end ib - }// end id - - - int bindex = 0; - // z is the fastest, - for(int ii=0; iivlocal[vindex[ib]] * this->vfactor; - //vna3d[ib] = ib; // tmp by mohan - vldr3[ib] = vna3d[ib] * this->vfactor; - -// if(i==0 && j==7 &&k==13 &&ib==6) -// { -// ofs << " i=" << i << " j=" << j << " k=" << k << " ib=" << ib << " vna3d=" << vna3d[ib] << endl; -// for(int id=0; idvfactor; // for checking overlap S - } - - for (int ia1=0; ia1nnn[T1], this->dr[ia1], this->ylm1); - - // attention! assume all rcut are same for this atom type now. - //if (distance[ia1] > ORB.Phi[T1].getRcut())continue; - - //for(int ia2=ia1; ia2 T1, we done all elements, for T2 == T1, - // we done about half. - if (T2 >= T1) - { - Atom *atom2 = &ucell.atoms[T2]; - const int I2 = ucell.iat2ia[ GridT.which_atom[mcell_index2]]; - const int start2 = ucell.itiaiw2iwt(T2, I2, 0); - - for (int ib=0; ibnw; iw++, ++iw1_lo) - { - v1=psi1[iw] * vldr3[ib]; - int iw2_lo = GridT.trace_lo[start2]; - double* result = &GridVlocal[iw1_lo][iw2_lo]; - double* psi2p = psi2; - double* psi2p_end = psi2p + atom2->nw; - for (;psi2p iw2_lo) - { - continue; - } - - result[0] += v1 * psi2p[0]; - - // note 1 - // why I increase both iw2_lo and iw2_all: - // Because iw2_lo is used to save element. - // And iw2_all is used to judge if we need - // to calculate the element according to - // "iw1_all > iw2_all" condition. - // note 2 - // in fact we don't need to do this. - // because GridVlocal is a symmetry matrix. - // whatever the division is , the order - // is same between iw2_lo,iw1_lo and - // iw2_all, iw1_all - }//iw2 - }//iw - }// cal_flag - }//ib - }//T - }// ia2 - }// ia1 - - }// k - }// j - }// i - - delete[] vindex; - delete[] ylma; - delete[] vldr3; - delete[] vna3d; - - if(max_size!=0) - { - for(int i=0; i= 0) - { - for (int j=0; j=0) - { - if (mu <= nu) - { - tmp[j] = GridVlocal[mu][nu]; - } - else - { - //------------------------------- - // origin: - // tmp[i] = GridVlocal[nu][mu]; - // mohan fix bug - // 2011-01-13 - //------------------------------- - tmp[j] = GridVlocal[nu][mu]; - } - } - } - } - Parallel_Reduce::reduce_double_pool( tmp, NLOCAL ); - for (int j=0; j0) - { - for(int i=0; isave_atoms_on_grid(gt); - this->gamma_vna_d(gt, matrix_type); - - timer::tick("Gint_Gamma","cal_vna_d"); - return; -} - -void Gint_Gamma::gamma_vna_d(const Grid_Technique >, const char &matrix_type) -{ - TITLE("Grid_Integral","gamma_vna_d"); -// cout << " gamma_vna_d ()" << endl; - - double** GridVlocal; - bool perform_gint = true; - - const int lgd_now = gt.lgd; - if(lgd_now > 0) - { - GridVlocal = new double*[lgd_now]; - for (int i=0; igrid_index = (k-nbz_start) + j * nbz + i * nby * nbz; - - // get the value: how many atoms has orbital value on this grid. - const int size = gt.how_many_atoms[ this->grid_index ]; - if(size==0) continue; - - ZEROS(vna3d, bxyz); - - // (1) initialized the phi * Ylm. - for (int id=0; id ORB.Vna[it].rcut && - distance[ib][id] > ORB.Phi[it].getRcut()) - { - cal_flag[ib][id]=false; - continue; - } - - //if(distance[id] > gt.orbital_rmax) continue; - // Ylm::get_ylm_real(this->nnn[it], this->dr[id], ylma); - if (distance[ib][id] < 1.0E-9) distance[ib][id] += 1.0E-9; - - Ylm::sph_harm ( ucell.atoms[it].nwl, - dr[ib][id][0] / distance[ib][id], - dr[ib][id][1] / distance[ib][id], - dr[ib][id][2] / distance[ib][id], - ylma); - // these parameters are about interpolation - // because once we know the distance from atom to grid point, - // we can get the parameters we need to do interpolation and - // store them first!! these can save a lot of effort. - const double position = distance[ib][id] / delta_r; - this->iq[id] = static_cast(position); - this->x0[id] = position - static_cast(iq[id]); - this->x1[id] = 1.0 - x0[id]; - this->x2[id] = 2.0 - x0[id]; - this->x3[id] = 3.0 - x0[id]; - this->x12[id] = x1[id]*x2[id] / 6.0; - this->x03[id] = x0[id]*x3[id] / 2.0; - - int ip; - double dx, dx2, dx3; - double c1, c2, c3, c4; - - ip = static_cast(position); - dx = position - ip; - dx2 = dx * dx; - dx3 = dx2 * dx; - - c3 = 3.0*dx2-2.0*dx3; - c1 = 1.0-c3; - c2 = (dx-2.0*dx2+dx3)*delta_r; - c4 = (dx3-dx2)*delta_r; - - double ccc; - if(distance[ib][id] <= ORB.Vna[it].rcut) - { - ccc = (x12[id]*(ORB.Vna[it].vna_u[iq[id]]*x3[id] - +ORB.Vna[it].vna_u[iq[id]+3]*x0[id]) - + x03[id]*(ORB.Vna[it].vna_u[iq[id]+1]*x2[id] - -ORB.Vna[it].vna_u[iq[id]+2]*x1[id])); - // cout << " ccc=" << ccc << endl; - // int ok; cin >> ok; - vna3d[ib] += ccc; - } - -// if(i==0 && j==7 &&k==13 && ib==6) -// { -// ofs << " dis=" << distance[ib][id] << " ccc=" << ccc << endl; -// ofs << " 1=" << ORB.Vna[it].vna_u[iq[id]] << endl; -// ofs << " 2=" << ORB.Vna[it].vna_u[iq[id]+1] << endl; -// ofs << " 3=" << ORB.Vna[it].vna_u[iq[id]+2] << endl; -// ofs << " 4=" << ORB.Vna[it].vna_u[iq[id]+3] << endl; -// } - - // int ip = this->iq[id]; - // double A = ip+1.0-position/delta_r; - // double B = 1.0-A; - // double coef1 = (A*A*A-A)/6.0*delta_r*delta_r; - // double coef2 = (B*B*B-B)/6.0*delta_r*delta_r; - - - if(distance[ib][id] <= ORB.Phi[it].getRcut()) - { - cal_flag[ib][id]=true; - } - else - { - cal_flag[ib][id]=false; - continue; - } - - - Atom* atom1 = &ucell.atoms[it]; - for (int iw=0; iw< atom1->nw; iw++) - { - if ( atom1->iw2_new[iw] ) - { - pointer = &ORB.Phi[it].PhiLN( - atom1->iw2l[iw], - atom1->iw2n[iw]); - phi = c1*pointer->psi_uniform[ip]+c2*pointer->dpsi_uniform[ip] - + c3*pointer->psi_uniform[ip+1]+c4*pointer->dpsi_uniform[ip+1]; - } - psir_ylm[ib][id][iw] = phi * ylma[atom1->iw2_ylm[iw]]; - //psir_ylm[ib][id][iw] = 1;//for test - } - }// end ib - }// end id - - - // extract the local potentials. - for(int ib=0; ibvfactor; - -// if(i==0 && j==7 &&k==13 && ib==6) -// { -// ofs << " i=" << i << " j=" << j << " k=" << k << " ib=" << ib << " vna3d=" << vna3d[ib] << endl; -// for(int id=0; idvfactor; // for checking overlap S - } - - for (int ia1=0; ia1nnn[T1], this->dr[ia1], this->ylm1); - - // attention! assume all rcut are same for this atom type now. - //if (distance[ia1] > ORB.Phi[T1].getRcut())continue; - - //for(int ia2=ia1; ia2 T1, we done all elements, for T2 == T1, - // we done about half. - if (T2 >= T1) - { - Atom *atom2 = &ucell.atoms[T2]; - const int I2 = ucell.iat2ia[ gt.which_atom[mcell_index2]]; - const int start2 = ucell.itiaiw2iwt(T2, I2, 0); - - for (int ib=0; ibnw; iw++, ++iw1_lo) - { - v1=psi1[iw] * vldr3[ib]; - int iw2_lo = gt.trace_lo[start2]; - double* result = &GridVlocal[iw1_lo][iw2_lo]; - double* psi2p = psi2; - double* psi2p_end = psi2p + atom2->nw; - for (;psi2p iw2_lo) - { - continue; - } - - result[0] += v1 * psi2p[0]; - - // note 1 - // why I increase both iw2_lo and iw2_all: - // Because iw2_lo is used to save element. - // And iw2_all is used to judge if we need - // to calculate the element according to - // "iw1_all > iw2_all" condition. - // note 2 - // in fact we don't need to do this. - // because GridVlocal is a symmetry matrix. - // whatever the division is , the order - // is same between iw2_lo,iw1_lo and - // iw2_all, iw1_all - }//iw2 - }//iw - }// cal_flag - }//ib - }//T - }// ia2 - }// ia1 - - }// k - }// j - }// i - - delete[] ylma; - delete[] vldr3; - delete[] vna3d; - - if(max_size!=0) - { - for(int i=0; i= 0) - { - for (int j=0; j=0) - { - if (mu <= nu) - { - tmp[j] = GridVlocal[mu][nu]; - } - else - { - //------------------------------- - // origin: - // tmp[i] = GridVlocal[nu][mu]; - // mohan fix bug - // 2011-01-13 - //------------------------------- - tmp[j] = GridVlocal[nu][mu]; - } - } - } - } - Parallel_Reduce::reduce_double_pool( tmp, NLOCAL ); - for (int j=0; j0) - { - for(int i=0; i0 ); - - if(this->pvnapR_alloc_flag) - { - WARNING_QUIT("Gint_k::allocate_pvnapR","pvnapR has been allocated!"); - } - - assert(LNNR.nnrg!=0); //mohan update 2012-07-01 - this->pvnapR_reduced = new double[LNNR.nnrg]; - ZEROS( pvnapR_reduced, LNNR.nnrg); - - double mem = Memory::record("allocate_pvpR", "pvnapR_reduced", LNNR.nnrg , "double"); - //xiaohui add 'OUT_LEVEL' line, 2015-09-16 - if(OUT_LEVEL != "m") ofs_running << " Memory of pvnapR : " << mem << " MB" << endl; - if( mem > 800 ) - { - ofs_warning << " memory for pvnapR = " << mem << endl; - ofs_warning << " which is larger than 800 MB ! " << endl; - WARNING_QUIT("Gint_k","allocate_pvpR"); - } - - this->pvnapR_alloc_flag = true; - - return; -} - - void Gint_k::allocate_pvpR(void) { @@ -139,23 +102,6 @@ void Gint_k::allocate_pvpR(void) } -void Gint_k::destroy_pvnapR(void) -{ - TITLE("Gint_k","destroy_pvnapR"); - - if(!pvnapR_alloc_flag) - { - WARNING_QUIT("Gint_k::destroy_pvnapR"," matrix has not been allocated yet!"); - } - - delete[] pvnapR_reduced; - - this->pvnapR_alloc_flag = false; - return; -} - - - void Gint_k::destroy_pvpR(void) { @@ -625,13 +571,12 @@ void Gint_k::folding_vl_k(const int &ik) // // 2. why the folding of vlocal is different from folding of // < phi_0i | T+Vnl | phi_Rj > ? - // Because the (i,j) is different for T+Vna and Vlocal+Vna + // Because the (i,j) is different for T+Vnl and Vlocal // The first part is due to 2D division of H and S matrix, // The second part is due to real space division. // // here we construct a temporary matrix to store the - // matrix element < phi_0 | Vlocal+Vna | phi_R > - // Vna appears when we use it. + // matrix element < phi_0 | Vlocal | phi_R > //################################################################# this->ik_now = ik; this->pvp = new complex*[GridT.lgd]; @@ -751,25 +696,12 @@ void Gint_k::folding_vl_k(const int &ik) int* iw2_lo = &GridT.trace_lo[start2]; int* iw2_end = iw2_lo + atom2->nw; - if(VNA) + // get the (R) Hamiltonian. + double *vijR = &pvpR_reduced[0][ixxx]; + // complex *vijR_soc = &pvpR_reduced_soc[ixxx]; + for(; iw2_lo(R) Hamiltonian. - double *vijR = &pvpR_reduced[0][ixxx]; - double *vijR2 = &pvnapR_reduced[ixxx]; - for(; iw2_lo(R) Hamiltonian. - double *vijR = &pvpR_reduced[0][ixxx]; -// complex *vijR_soc = &pvpR_reduced_soc[ixxx]; - for(; iw2_lonw; ++lgd; @@ -890,21 +822,6 @@ void Gint_k::folding_vl_k_nc(const int &ik) WARNING_QUIT("Gint_k::destroy_pvpR","pvpR hasnot been allocated yet!"); } - //####################### EXPLAIN ################################# - // 1. what is GridT.lgd ? - // GridT.lgd is the number of orbitals in each processor according - // to the division of real space FFT grid. - // - // 2. why the folding of vlocal is different from folding of - // < phi_0i | T+Vnl | phi_Rj > ? - // Because the (i,j) is different for T+Vna and Vlocal+Vna - // The first part is due to 2D division of H and S matrix, - // The second part is due to real space division. - // - // here we construct a temporary matrix to store the - // matrix element < phi_0 | Vlocal+Vna | phi_R > - // Vna appears when we use it. - //################################################################# this->ik_now = ik; // complex** pvp_nc[4]; for(int spin=0;spin<4;spin++) @@ -1029,28 +946,20 @@ void Gint_k::folding_vl_k_nc(const int &ik) int iw2_lo = GridT.trace_lo[start2]/NPOL; int iw2_end = iw2_lo + atom2->nw; - if(VNA) + // get the (R) Hamiltonian. +// complex *vijR_soc = &pvpR_reduced_soc[ixxx]; + double *vijR[4]; + for(int spin = 0;spin<4;spin++) { - // get the (R) Hamiltonian. - double *vijR = &pvpR_reduced[0][ixxx]; - double *vijR2 = &pvnapR_reduced[ixxx]; - for(; iw2_lo(R) Hamiltonian. -// complex *vijR_soc = &pvpR_reduced_soc[ixxx]; - double *vijR[4]; - for(int spin = 0;spin<4;spin++) vijR[spin] = &pvpR_reduced[spin][ixxx]; - for(; iw2_lonw; ++lgd; @@ -1316,361 +1225,8 @@ void Gint_k::set_ijk_atom(const int &grid_index, const int &size, } -void Gint_k::set_ijk_atom_vna(const int &grid_index, const int &size, - double*** psir_ylm, double*** dr, bool** cal_flag, - double** distance, double* ylma, const double &delta_r, - const Grid_Technique >, double* vna3d) -{ - const Numerical_Orbital_Lm* pointer; - double mt[3]; - for (int id=0; id= - if(distance[ib][id] >= ORB.Vna[it].rcut && - distance[ib][id] >= ORB.Phi[it].getRcut()) - { - cal_flag[ib][id]=false; -// ofs_running << " ibbb=" << ib << " iddd=" << id << " cal_flag=" << cal_flag[ib][id] << endl; - continue; - } - - if (distance[ib][id] < 1.0E-9) distance[ib][id] += 1.0E-9; - - - - // these parameters are about interpolation - // because once we know the distance from atom to grid point, - // we can get the parameters we need to do interpolation and - // store them first!! these can save a lot of effort. - const double position = distance[ib][id] / delta_r; - - const int iq = static_cast(position); - const double x0 = position - static_cast(iq); - const double x1 = 1.0 - x0; - const double x2 = 2.0 - x0; - const double x3 = 3.0 - x0; - const double x12 = x1*x2/6.0; - const double x03 = x0*x3/2.0; - - - - // mohan add 2012-06-13 - double ccc; - if(distance[ib][id] <= ORB.Vna[it].rcut) - { - ccc = (x12*(ORB.Vna[it].vna_u[iq]*x3 - +ORB.Vna[it].vna_u[iq+3]*x0) - + x03*(ORB.Vna[it].vna_u[iq+1]*x2 - -ORB.Vna[it].vna_u[iq+2]*x1)); - vna3d[ib] += ccc; - } - - - //if(distance[ib][id] <= ORB.Phi[it].getRcut()) - // mohan fix bug 2012-06-27 - // if use '<=', there may be atoms out of plan. - if(distance[ib][id] < ORB.Phi[it].getRcut()) - { - cal_flag[ib][id]=true; -// ofs_running << " ibbb=" << ib << " iddd=" << id << " cal_flag=" << cal_flag[ib][id] << endl; - } - else - { - cal_flag[ib][id]=false; -// ofs_running << " ibbb=" << ib << " iddd=" << id << " cal_flag=" << cal_flag[ib][id] << endl; - continue; - } - - - - Ylm::sph_harm ( ucell.atoms[it].nwl, - dr[ib][id][0] / distance[ib][id], - dr[ib][id][1] / distance[ib][id], - dr[ib][id][2] / distance[ib][id], - ylma); - - - - const int ip = static_cast(position); - - const double dx = position - ip; - const double dx2 = dx * dx; - const double dx3 = dx2 * dx; - - const double c3 = 3.0*dx2-2.0*dx3; - const double c1 = 1.0-c3; - const double c2 = (dx-2.0*dx2+dx3)*delta_r; - const double c4 = (dx3-dx2)*delta_r; - - - - - - - - Atom* atom1 = &ucell.atoms[it]; - double tmp=0.0;//mohan fix bug 2011-05-04 - for (int iw=0; iw< atom1->nw; iw++) - { - if ( atom1->iw2_new[iw] ) - { - pointer = &ORB.Phi[it].PhiLN( - atom1->iw2l[iw], - atom1->iw2n[iw]); - - // Efficient!! to get the orbital value at this point. - tmp = c1*pointer->psi_uniform[ip] - + c2*pointer->dpsi_uniform[ip] - + c3*pointer->psi_uniform[ip+1] - + c4*pointer->dpsi_uniform[ip+1]; - } - psir_ylm[ib][id][iw] = tmp * ylma[atom1->iw2_ylm[iw]]; -// psir_ylm[ib][id][iw] = 1.0; - }// end iw. - }//end ib - }// int id - - - - /* - if(grid_index==0) - { - for(int id=0; id matrix element. - void allocate_pvnapR(void); - - - // destroy the temporary matrix element. - void destroy_pvnapR(void); - //>>>>>>>>>>>>>>>>>>>> // drive routine @@ -42,19 +35,6 @@ class Gint_k : public Gint_k_init void cal_vlocal_R(const int current_spin); //LiuXh add 2019-07-15 - //>>>>>>>>>>>>>>>>>>>> - // drive routine - //>>>>>>>>>>>>>>>>>>>> - // calculate < phi_0i | Vna | phi_Rj > on regular FFT grid. - void cal_vna(const double* vrs1, const Grid_Technique >); - - - //>>>>>>>>>>>>>>>>>>>> - // drive routine - //>>>>>>>>>>>>>>>>>>>> - // calculate < phi_0i | Vna | phi_Rj > on dense grid. - void cal_vna_d(const Grid_Technique >, const double* vrs1, const char &matrix_type); - // folding the < phi_0 | V | phi_R> matrix to // @@ -91,15 +71,6 @@ class Gint_k : public Gint_k_init void svl_k_RealSpace(double** fvl_dphi, double svl_dphi[][3], const double* vl);//zhengdy add 2016-10-18 - //>>>>>>>>>>>>>>>>>>>> - // drive routine - //>>>>>>>>>>>>>>>>>>>> - // calculate the force due to Vna (neutral potential), - // The Vna is in 1D numerical form. - void fvna_k_RealSpace(const Grid_Technique >, double** fvna_dphi); - void svna_k_RealSpace(const Grid_Technique >, double** fvna_dphi, double svna_dphi[][3]); - - // reset the spin. void reset_spin(const int &spin_now); @@ -120,16 +91,6 @@ class Gint_k : public Gint_k_init double** distance, double* ylma, const double &delta_r); - //============================ - // set the orbital info - //============================ - // set the orbital/Ylm/Vna information on each real space grid. - void set_ijk_atom_vna(const int &grid_index, const int &size, - double*** psir_ylm, double*** dr, bool** cal_flag, - double** distance, double* ylma, const double &delta_r, - const Grid_Technique >, double* vna3d); - - //============================ // set the orbital info //============================ @@ -140,17 +101,6 @@ class Gint_k : public Gint_k_init double*** dphi_x, double ***dphi_y, double*** dphi_z); - //============================ - // set the orbital info - //============================ - // set the derivative information on dense real space grid. - void set_ijk_atom_fvna(const int &grid_index, const int &size, - double*** psir_ylm, double*** dr, bool** cal_flag, - double** distance, double* ylma, const double &delta_r, - double*** dphi_x, double*** dphi_y, double*** dphi_z, - const Grid_Technique >, double* vna3d); - - //---------------------------- // detail grid integration: //---------------------------- @@ -168,13 +118,6 @@ class Gint_k : public Gint_k_init double*** psir_ylm, bool** cal_flag, double* vldr3, double** distance, const Grid_Technique >); - //---------------------------- - // detail grid integration: - //---------------------------- - // reduced means the H storage take the advance of adjacent atoms. - void evaluate_pvnapR_reduced(const int &grid_index, const int &size, const int &i, const int &j, const int &k, - double*** psir_ylm, bool** cal_flag, double* vldr3, double** distance); - //---------------------------- // detail grid integration: @@ -221,13 +164,6 @@ class Gint_k : public Gint_k_init double** pvpR_reduced; - //---------------------------- - // key variable - //---------------------------- - // dimension: [LNNR.nnrg] - // save the < phi_0i | V | phi_Rj > in sparse H matrix. - double* pvnapR_reduced; - //---------------------------- // key variable @@ -243,7 +179,6 @@ class Gint_k : public Gint_k_init // just pointer. bool pvpR_alloc_flag; - bool pvnapR_alloc_flag; bool reduced; }; diff --git a/ABACUS.develop/source/src_lcao/gint_k_fvna.cpp b/ABACUS.develop/source/src_lcao/gint_k_fvna.cpp deleted file mode 100644 index 86450042c8..0000000000 --- a/ABACUS.develop/source/src_lcao/gint_k_fvna.cpp +++ /dev/null @@ -1,512 +0,0 @@ -#include "gint_k.h" -#include "gint_gamma.h" -#include "grid_technique.h" -#include "lcao_orbitals.h" -#include "../src_pw/global.h" -#include "lcao_nnr.h" - -void Gint_k::fvna_k_RealSpace(const Grid_Technique >, double** fvna_dphi) -{ - TITLE("Gint_k","fvna_k_RealSpace"); - timer::tick("Gint_k","fvna_k_RealSpace",'i'); - - - if(!this->reduced) - { - WARNING_QUIT("Gint_k::fvna_k_RealSpace","The force with k can only with reduced H."); - } - - - int nnrg = LNNR.nnrg; - ofs_running << " LNNR.nnrg in fvna_k_RealSpace = " << LNNR.nnrg << endl; - assert(nnrg>=0); - - // just because to make thea arrys meaningful. - if(LNNR.nnrg == 0) - { - nnrg = 1; - } - - - // to store < phi | vlocal | dphi> - double* pvdpx = new double[nnrg]; - double* pvdpy = new double[nnrg]; - double* pvdpz = new double[nnrg]; - ZEROS(pvdpx, nnrg); - ZEROS(pvdpy, nnrg); - ZEROS(pvdpz, nnrg); - - - - // it's a uniform grid to save orbital values, so the delta_r is a constant. - double delta_r = ORB.dr_uniform; - // possible max atom number in real space grid. - const int max_size = gt.max_atom; - // how many meshcells in bigcell. - - const int bxyz = gt.bxyz; - const int bx = gt.bx; - const int by = gt.by; - const int bz = gt.bz; - - - double*** dr;// vectors between atom and grid: [bxyz, maxsize, 3] - double** distance; // distance between atom and grid: [bxyz, maxsize] - double*** psir_ylm; // psi(r-R) * Ylm(r-R) - bool** cal_flag; - double* ylma; - - double*** dphi_x; - double*** dphi_y; - double*** dphi_z; - - - - if(max_size!=0) - { - // save the small box information for a big box. - dr = new double**[bxyz]; - distance = new double*[bxyz]; - psir_ylm = new double**[bxyz]; - cal_flag = new bool*[bxyz]; - dphi_x = new double**[bxyz]; - dphi_y = new double**[bxyz]; - dphi_z = new double**[bxyz]; - - - // mohan fix bug 2011-05-02 - // possible number of atom configureation (l,m) - int nn = 0; - for(int it=0; it0) - { - ncxyz = pw.ncxyz * VNA * VNA * VNA; - } - else if(VNA==0) - { - ncxyz = pw.ncxyz; - } - const double dv = ucell.omega/(double)ncxyz; - - int vl_index=0; - - // array to store local potential for each small box in - // a big box. - double* vldr3 = new double[bxyz]; - double* vna3d = new double[bxyz]; - ZEROS(vldr3, bxyz); - - - - - for(int i=0; iset_ijk_atom_fvna(grid_index, size, - psir_ylm, dr, cal_flag, - distance, ylma, delta_r, - dphi_x, dphi_y, dphi_z, - gt, vna3d); - - - // for test, use original vl(G)->vl(r), - // remember to turn on the potential in force_lcao_k.cpp - -/* - int bindex = 0; - // z is the fastest, - for(int ii=0; iireduced) - { - this->evaluate_vl_force(grid_index, size,i,j,k, - psir_ylm, cal_flag, vldr3, distance, - dphi_x, dphi_y, dphi_z, - pvdpx, pvdpy, pvdpz, gt); - } - - }// int k - }// int j - } // int i - - delete[] vldr3; - delete[] vna3d; - - - if(max_size!=0) - { - for(int i=0; ifolding_force(fvna_dphi,pvdpx, pvdpy, pvdpz); - - - delete[] pvdpx; - delete[] pvdpy; - delete[] pvdpz; - - timer::tick("Gint_k","fvna_k_RealSpace",'i'); - return; -} - - - -void Gint_k::svna_k_RealSpace(const Grid_Technique >, double** fvna_dphi, double svna_dphi[][3]) -{ - TITLE("Gint_k","svna_k_RealSpace"); - timer::tick("Gint_k","svna_k_RealSpace",'i'); - - - if(!this->reduced) - { - WARNING_QUIT("Gint_k::svna_k_RealSpace","The stress with k can only with reduced H."); - } - - - int nnrg = LNNR.nnrg; - ofs_running << " LNNR.nnrg in svna_k_RealSpace = " << LNNR.nnrg << endl; - assert(nnrg>=0); - - // just because to make thea arrys meaningful. - if(LNNR.nnrg == 0) - { - nnrg = 1; - } - - - // to store < phi | vlocal | dphi> - double* pvdpx = new double[nnrg]; - double* pvdpy = new double[nnrg]; - double* pvdpz = new double[nnrg]; - ZEROS(pvdpx, nnrg); - ZEROS(pvdpy, nnrg); - ZEROS(pvdpz, nnrg); - double* pvdp11 = new double[nnrg]; - double* pvdp22 = new double[nnrg]; - double* pvdp33 = new double[nnrg]; - ZEROS(pvdp11, nnrg); - ZEROS(pvdp22, nnrg); - ZEROS(pvdp33, nnrg); - double* pvdp12 = new double[nnrg]; - double* pvdp13 = new double[nnrg]; - double* pvdp23 = new double[nnrg]; - ZEROS(pvdp12, nnrg); - ZEROS(pvdp13, nnrg); - ZEROS(pvdp23, nnrg); - - - // it's a uniform grid to save orbital values, so the delta_r is a constant. - double delta_r = ORB.dr_uniform; - // possible max atom number in real space grid. - const int max_size = gt.max_atom; - // how many meshcells in bigcell. - - const int bxyz = gt.bxyz; - const int bx = gt.bx; - const int by = gt.by; - const int bz = gt.bz; - - - double*** dr;// vectors between atom and grid: [bxyz, maxsize, 3] - double** distance; // distance between atom and grid: [bxyz, maxsize] - double*** psir_ylm; // psi(r-R) * Ylm(r-R) - bool** cal_flag; - double* ylma; - - double*** dphi_x; - double*** dphi_y; - double*** dphi_z; - - - - if(max_size!=0) - { - // save the small box information for a big box. - dr = new double**[bxyz]; - distance = new double*[bxyz]; - psir_ylm = new double**[bxyz]; - cal_flag = new bool*[bxyz]; - dphi_x = new double**[bxyz]; - dphi_y = new double**[bxyz]; - dphi_z = new double**[bxyz]; - - - // mohan fix bug 2011-05-02 - // possible number of atom configureation (l,m) - int nn = 0; - for(int it=0; it0) - { - ncxyz = pw.ncxyz * VNA * VNA * VNA; - } - else if(VNA==0) - { - ncxyz = pw.ncxyz; - } - const double dv = ucell.omega/(double)ncxyz; - - int vl_index=0; - - // array to store local potential for each small box in - // a big box. - double* vldr3 = new double[bxyz]; - double* vna3d = new double[bxyz]; - ZEROS(vldr3, bxyz); - - - - - for(int i=0; iset_ijk_atom_fvna(grid_index, size, - psir_ylm, dr, cal_flag, - distance, ylma, delta_r, - dphi_x, dphi_y, dphi_z, - gt, vna3d); - - - // for test, use original vl(G)->vl(r), - // remember to turn on the potential in force_lcao_k.cpp - -/* - int bindex = 0; - // z is the fastest, - for(int ii=0; iireduced) - { - this->evaluate_vl_stress(grid_index, size,i,j,k, - psir_ylm, cal_flag, vldr3, distance, - dphi_x, dphi_y, dphi_z, - pvdpx, pvdpy, pvdpz, - pvdp11, pvdp22, pvdp33,pvdp12, pvdp13, pvdp23, dr, gt); - } - - }// int k - }// int j - } // int i - - delete[] vldr3; - delete[] vna3d; - - - if(max_size!=0) - { - for(int i=0; ifolding_stress(fvna_dphi, svna_dphi, pvdpx, pvdpy, pvdpz, - pvdp11, pvdp22, pvdp33, pvdp12, pvdp13, pvdp23); - - - delete[] pvdpx; - delete[] pvdpy; - delete[] pvdpz; - delete[] pvdp11; - delete[] pvdp22; - delete[] pvdp33; - delete[] pvdp12; - delete[] pvdp13; - delete[] pvdp23; - - timer::tick("Gint_k","svna_k_RealSpace",'i'); - return; -} - - - diff --git a/ABACUS.develop/source/src_lcao/gint_k_vna.cpp b/ABACUS.develop/source/src_lcao/gint_k_vna.cpp deleted file mode 100644 index b54402b42b..0000000000 --- a/ABACUS.develop/source/src_lcao/gint_k_vna.cpp +++ /dev/null @@ -1,347 +0,0 @@ -#include "gint_gamma.h" -#include "grid_technique.h" -#include "lcao_orbitals.h" -#include "../src_pw/global.h" -#include "lcao_nnr.h" - -#include "global_fp.h" // mohan add 2021-01-30 - -void Gint_k::cal_vna(const double* vrs1, const Grid_Technique >) -{ - - TITLE("Gint_k","cal_vna"); - - if(!pvnapR_alloc_flag) - { - WARNING_QUIT("Gint_k::destroy_pvpR","pvnapR has not been allocated yet!"); - } - else - { - // reduce the dimension of array, which - // is used to save - if(this->reduced) - { - ZEROS(this->pvnapR_reduced, LNNR.nnrg); - } - } - - timer::tick("Gint_k","cal_vna"); - - // it's a uniform grid to save orbital values, so the delta_r is a constant. - double delta_r = ORB.dr_uniform; - // possible max atom number in real space grid. - const int max_size = gt.max_atom; - // how many meshcells in bigcell. - const int bxyz = pw.bxyz; - - double*** dr;// vectors between atom and grid: [bxyz, maxsize, 3] - double** distance; // distance between atom and grid: [bxyz, maxsize] - double*** psir_ylm; // psi(r-R) * Ylm(r-R) - bool** cal_flag; - double* ylma; - - if(max_size!=0) - { - // save the small box information for a big box. - dr = new double**[bxyz]; - distance = new double*[bxyz]; - psir_ylm = new double**[bxyz]; - cal_flag = new bool*[bxyz]; - - // mohan fix bug 2011-05-02 - // possible number of atom configureation (l,m) - int nn = 0; - for(int it=0; it0) - { - ncxyz = pw.ncxyz * VNA * VNA * VNA; - } - else if(VNA==0) - { - ncxyz = pw.ncxyz; - } - const double dv = ucell.omega/(double)ncxyz; - int vl_index=0; - - // array to store local potential for each small box in - // a big box. - double* vldr3 = new double[bxyz]; - ZEROS(vldr3, bxyz); - - for(int i=0; iset_ijk_atom(grid_index, size, - psir_ylm, dr, cal_flag, - distance, ylma, delta_r); - - int bindex = 0; - // z is the fastest, - for(int ii=0; iireduced) - { - this->evaluate_pvpR_reduced(this->pvnapR_reduced,grid_index, size,i,j,k, - psir_ylm, cal_flag, vldr3, distance, gt); - } - - }// int k - }// int j - } // int i - - delete[] vldr3; - if(max_size!=0) - { - for(int i=0; i - if(this->reduced) - { - ZEROS(this->pvnapR_reduced, LNNR.nnrg); - } - } - - timer::tick("Gint_k","cal_vna_d",'F'); - - // it's a uniform grid to save orbital values, so the delta_r is a constant. - double delta_r = ORB.dr_uniform; - // possible max atom number in real space grid. - const int max_size = gt.max_atom; - // how many meshcells in bigcell. - - const int bxyz = gt.bxyz; - const int bx = gt.bx; - const int by = gt.by; - const int bz = gt.bz; - -/* - cout << " bxyz=" << bxyz << endl; - cout << " bx=" << bx << endl; - cout << " by=" << by << endl; - cout << " bz=" << bz << endl; - */ - - double*** dr;// vectors between atom and grid: [bxyz, maxsize, 3] - double** distance; // distance between atom and grid: [bxyz, maxsize] - double*** psir_ylm; // psi(r-R) * Ylm(r-R) - bool** cal_flag; - double* ylma; - - if(max_size!=0) - { - // save the small box information for a big box. - dr = new double**[bxyz]; - distance = new double*[bxyz]; - psir_ylm = new double**[bxyz]; - cal_flag = new bool*[bxyz]; - - // mohan fix bug 2011-05-02 - // possible number of atom configureation (l,m) - int nn = 0; - for(int it=0; it0) - { - ncxyz = pw.ncxyz * VNA * VNA * VNA; - } - else if(VNA==0) - { - ncxyz = pw.ncxyz; - } - - - const double dv = ucell.omega/(double)ncxyz; - int vl_index=0; - - // array to store local potential for each small box in - // a big box. - double* vldr3 = new double[bxyz]; - double* vna3d = new double[bxyz]; - ZEROS(vldr3, bxyz); - - for(int i=0; iset_ijk_atom_vna(grid_index, size, - psir_ylm, dr, cal_flag, - distance, ylma, delta_r, gt, vna3d); - - // for test - // remember to turn on the potential in lcao_vna.cpp - /* - int bindex = 0; - // z is the fastest, - for(int ii=0; ii - -Gint_Speed::Gint_Speed() -{ - nov = 0; -} -Gint_Speed::~Gint_Speed(){} - -void Gint_Speed::cal_vlocal( - const double* vlocal_in) -{ - TITLE("Gint_Speed","cal_vlocal"); - timer::tick("Gint_Speed","cal_vlocal",'J'); - - if(Local_Orbital_Elec::iter==1) - { - save_phi(); - } - - this->job = cal_local; - this->vlocal = vlocal_in; - this->max_size = GridT.max_atom; - - assert(GridT.ncxyz>0); - this->vfactor = std::abs(this->latvec0.Det())/GridT.ncxyz; - - // call function - this->gamma_vlocal(); - - timer::tick("Gint_Speed","cal_vlocal",'J'); - - // Peize Lin add 2016-12-03 - if(5==xcf.iexch_now) - throw logic_error("Exx unfinished in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); - else if(6==xcf.iexch_now) - throw logic_error("Exx unfinished in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); - - return; -} - - -// evaluate the -void Gint_Speed::gamma_vlocal(void) -{ - TITLE("Gint_Speed","gamma_vlocal"); - timer::tick("Gint_Speed","gamma_vlocal",'K'); - - const int nwmax = ucell.nwmax; - const int nat = ucell.nat; - - bool perform_gint = true; - - - //-------------------------------------------- - // allocate the matrix - //-------------------------------------------- - double** GridVlocal; - const int lgd_now = GridT.lgd; - if(lgd_now > 0) - { - GridVlocal = new double*[lgd_now]; - for (int i=0; i= 0) - { - for (int j=0; j=0) - { - if (mu <= nu) - { - tmp[j] = GridVlocal[mu][nu]; - } - else - { - //------------------------------- - // origin: - // tmp[i] = GridVlocal[nu][mu]; - // mohan fix bug - // 2011-01-13 - //------------------------------- - tmp[j] = GridVlocal[nu][mu]; - } - } - } - } - Parallel_Reduce::reduce_double_grid( tmp, NLOCAL ); - Parallel_Reduce::reduce_double_diag( tmp, NLOCAL ); - for (int j=0; j0) - { - for(int i=0; igrid_index = (k-nbz_start) + j * nbz + i * nby * nbz; - const int size = GridT.how_many_atoms[ this->grid_index ]; - - if(size==0) continue; - - int ir_now = ir_bigbox; - for(int ib=0; ib(position); - dx = position - ip; - dx2 = dx * dx; - dx3 = dx2 * dx; - - c3 = 3.0*dx2-2.0*dx3; - c1 = 1.0-c3; - c2 = (dx-2.0*dx2+dx3)*delta_r; - c4 = (dx3-dx2)*delta_r; - Atom* atom1 = &ucell.atoms[it]; - for (int iw=0; iw< atom1->nw; iw++) - { - double phi; - if ( atom1->iw2_new[iw] ) - { - pointer = &ORB.Phi[it].PhiLN( - atom1->iw2l[iw], - atom1->iw2n[iw]); - phi = c1*pointer->psi_uniform[ip]+c2*pointer->dpsi_uniform[ip] - + c3*pointer->psi_uniform[ip+1] + c4*pointer->dpsi_uniform[ip+1]; - } - phiylm[iat][iw][nr2[iat]] = phi * ylma[atom1->iw2_ylm[iw]]; - } - - // recall the global index of each grid for each orbital - // ir_bigbox = global index(i, j, k) - - //----------------------------------------------------- - // (1) - // Be careful about one special case! - // if grid_label[iat][nr_now] == grid_label[iat][nr_now+1], - // means, there are at least two 'identical' atoms - // have non-zero wave functios on this grid. - // (2) - // Because we are now circleing for ir_bigbox, so if - // there appears same 'iat', - // nr2[iat] is blind between 'different atom (same iat) on same grid' - // and 'same atom on different grid' - //----------------------------------------------------- - //assert(nr[iat]>0); - grid_label[iat][nr2[iat]] = ir_now; - ++nr2[iat]; - }//end size - ++ir_now; - }//end ibxyz - - - ir_now = ir_bigbox; - for(int ii=0; iinov=0; - for(int iat=0; iatnr[iat]; - if(nr_now == 0) continue; - - const int it = ucell.iat2it[ iat ]; - const int ia = ucell.iat2ia[ iat ]; - const int start1 = ucell.itiaiw2iwt(it, ia, 0); - const int iw_lo = GridT.trace_lo[start1]; - if(iw_lo<0)continue; - for(int iat2=iat; iat2nr[iat2]; - if(nr2_now == 0) continue; - - const int it2 = ucell.iat2it[ iat2 ]; - const int ia2 = ucell.iat2ia[ iat2 ]; - const int start2 = ucell.itiaiw2iwt(it2, ia2, 0); - const int iw2_lo = GridT.trace_lo[start2]; - if(iw2_lo<0)continue; - - - - // for example - // the positive number is the grid point. - // positive number is always increasing. - // psi1: 1 3 3 5 7 - // psi2: 2 3 3 5 9 - int is=0; - int is_rec=0; - int ir2_start=0;//start ir for atom2 - int ee=0; //count the overlap grid number. - bool same=false; - - - // searching in the range of atom 1. - for(int ir=0; ir< nr_now; ++ir) - { - if( ir>0 ) - { - //--------------------------------------- - // means 'idential' atoms have at least - // twice phi on this grid. - //--------------------------------------- - if( grid_label[iat][ir] == grid_label[iat][ir-1] ) - { - // it's the same grid. - same = true; - // again, searching begins from the previous one. - // for example, the second 3 in atom 1, - // must search from the previous one. - ir2_start = is_rec; - } - else - { - // start from the bigger one, when - // grid_label[iat2][j] > grid_label[iat][i] - same = false; - ir2_start = is; - } - } - - // is_rec: - // stop to begin record how many 'identical' - // atoms have Phi on this grid. - is_rec = ir2_start; - - //------------------------------------------ - // (1) compare betwen different atoms! - // (2) ee++ when iat and iat2 are on the same grid. - // (3) can't miss any grid_label - //------------------------------------------ - for(int jr=ir2_start; jr grid_label[iat][ir] ) - { - is=jr; - break; - } - else if( grid_label[iat2][jr] == grid_label[iat][ir]) - { - ++ee; - } - }// j - }// i -// ofs_running << "iat=" << iat << " iat2=" << iat2 << " ee=" << ee << endl; - this->nov = std::max(nov, ee); - }//iat2 - }//iat - - - ofs_running << " nov=" << nov << " nrxx=" << pw.nrxx << endl; -// cout << " nov=" << nov << " nrxx=" << pw.nrxx << endl; - -#ifdef __MPI - MPI_Barrier(MPI_COMM_WORLD); -#endif - timer::tick("Gint_Speed","save_phi",'k'); - return; -} - diff --git a/ABACUS.develop/source/src_lcao/gint_speed_rho.cpp b/ABACUS.develop/source/src_lcao/gint_speed_rho.cpp deleted file mode 100644 index f966752b3b..0000000000 --- a/ABACUS.develop/source/src_lcao/gint_speed_rho.cpp +++ /dev/null @@ -1,183 +0,0 @@ -#include "gint_speed.h" -#include "grid_technique.h" -#include "lcao_orbitals.h" -#include "../src_pw/global.h" -#include "local_orbital_elec.h" //mohan add 2012-03-29 - -#include "global_fp.h" // mohan add 2021-01-30 - - -double Gint_Speed::cal_rho(void) -{ - TITLE("Gint_Speed","cal_rho"); - timer::tick("Gint_Speed","cal_rho",'J'); - - this->job = cal_charge; - - assert(GridT.ncxyz>0); - this->vfactor = std::abs(this->latvec0.Det())/GridT.ncxyz; - - // call function - double ne = this->gamma_charge(); - - timer::tick("Gint_Speed","cal_rho",'J'); - return ne; - -} - - -double Gint_Speed::gamma_charge(void) -{ - TITLE("Gint_Speed","gamma_charge"); - timer::tick("Gint_Speed","gamma_charge",'K'); - -// cout << " gamma_charge" << endl; - - - const int nwmax = ucell.nwmax; - const int nat = ucell.nat; - - // PART3: evaluate the - assert(allocate_phiylm); - assert(nov>=0); - - - if(nov > 0) - { - int incx=1; - int incy=1; - double **p1 = new double*[nwmax]; - double **p2 = new double*[nwmax]; - for(int iw=0; iwnov]; - for(int iw=0; iwnov]; - - for(int iat=0; iat0 - - - double sum = 0.0; - for(int is=0; isorbital_rmax = std::max( ORB.Phi[T].getRcut(), this->orbital_rmax); - // mohan add 2011-05-23 - if(vna) - { - this->orbital_rmax = std::max( ORB.Vna[T].rcut,this->orbital_rmax); - } } if(test_gridt)OUT(ofs_running,"rmax of periodic grid (bohr)",orbital_rmax); diff --git a/ABACUS.develop/source/src_lcao/grid_bigcell.h b/ABACUS.develop/source/src_lcao/grid_bigcell.h index 0df0d05168..fa951fc136 100644 --- a/ABACUS.develop/source/src_lcao/grid_bigcell.h +++ b/ABACUS.develop/source/src_lcao/grid_bigcell.h @@ -29,7 +29,7 @@ class Grid_BigCell: public Grid_MeshCell //--------------------------------- - void init_grid_expansion(const bool vna); + void init_grid_expansion(void); // get the max radius of all orbitals. // which will use to generate grid expansion, diff --git a/ABACUS.develop/source/src_lcao/grid_technique.cpp b/ABACUS.develop/source/src_lcao/grid_technique.cpp index 56c1e7fa5d..ea9dc7401b 100644 --- a/ABACUS.develop/source/src_lcao/grid_technique.cpp +++ b/ABACUS.develop/source/src_lcao/grid_technique.cpp @@ -49,15 +49,13 @@ void Grid_Technique::set_pbc_grid( const int &nbz_in, const int &nbxx_in, const int &nbzp_start_in, - const int &nbzp_in, - const bool vna) + const int &nbzp_in) { TITLE("Grid_Technique","init"); timer::tick("Grid_Technique","init",'D'); //xiaohui add 'OUT_LEVEL' line, 2015-09-16 if(OUT_LEVEL != "m") ofs_running << "\n SETUP EXTENDED REAL SPACE GRID FOR GRID INTEGRATION" << endl; - if(OUT_LEVEL != "m") OUT(ofs_running,"vna",vna); // (1) init_meshcell cell and big cell. this->set_grid_dim(ncx_in,ncy_in,ncz_in, @@ -68,7 +66,7 @@ void Grid_Technique::set_pbc_grid( this->init_big_latvec(); this->init_meshcell_pos(); // (2) expand the grid - this->init_grid_expansion(vna); + this->init_grid_expansion(); // (3) calculate the extended grid. this->cal_extended_cell(this->dxe, this->dye, this->dze); this->init_tau_in_bigcell(); diff --git a/ABACUS.develop/source/src_lcao/grid_technique.h b/ABACUS.develop/source/src_lcao/grid_technique.h index 597df6bf81..a5dba02873 100644 --- a/ABACUS.develop/source/src_lcao/grid_technique.h +++ b/ABACUS.develop/source/src_lcao/grid_technique.h @@ -67,8 +67,7 @@ class Grid_Technique : public Grid_MeshBall const int &nbz_in, const int &nbxx_in, const int &nbzp_start_in, - const int &nbzp_in, - const bool vna = false); + const int &nbzp_in); private: diff --git a/ABACUS.develop/source/src_lcao/lcao_orbitals.cpp b/ABACUS.develop/source/src_lcao/lcao_orbitals.cpp index 7e6ad95b71..d2273d88c8 100644 --- a/ABACUS.develop/source/src_lcao/lcao_orbitals.cpp +++ b/ABACUS.develop/source/src_lcao/lcao_orbitals.cpp @@ -12,7 +12,6 @@ LCAO_Orbitals::LCAO_Orbitals() this->nchimax = 0;// this initialzied must specified this->Phi = new Numerical_Orbital[1]; this->Beta = new Numerical_Nonlocal[1]; - this->Vna = new Neutral_Pot[1]; this->nproj = new int[1]; this->nprojmax = 0; @@ -28,7 +27,6 @@ LCAO_Orbitals::~LCAO_Orbitals() } delete[] Phi; delete[] Beta; - delete[] Vna; delete[] nproj; } @@ -169,15 +167,6 @@ void LCAO_Orbitals::Read_Orbitals(void) //----------------------------------------------------------------- - - - - - - - - - //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> //~~~~~~~~~~~~~~~~~~~~~~ 1 ~~~~~~~~~~~~~~~~~~~~~~~~~ // Read in numerical atomic orbitals for each atom type. @@ -189,16 +178,6 @@ void LCAO_Orbitals::Read_Orbitals(void) this->Read_PAO(it); } - - - - - - - - - - //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> //~~~~~~~~~~~~~~~~~~~~~~ 2 ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -240,43 +219,6 @@ void LCAO_Orbitals::Read_Orbitals(void) - - - - - - - //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - //~~~~~~~~~~~~~~~~~~~~~~ 3 ~~~~~~~~~~~~~~~~~~~~~~~~~ - // Setup one dimensional neutral potential for each - // element. Vna = Vl_pseudo + Vh_atomic - //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - delete[] this->Vna; - this->Vna = new Neutral_Pot[ucell.ntype]; - - for(int it=0; itPhi[it], dr_uniform ); - } - } - - - - - - - - - - timer::tick("LCAO_Orbitals","Read_Orbitals",'C'); return; } diff --git a/ABACUS.develop/source/src_lcao/lcao_orbitals.h b/ABACUS.develop/source/src_lcao/lcao_orbitals.h index 4e62eddc00..2042bbff74 100644 --- a/ABACUS.develop/source/src_lcao/lcao_orbitals.h +++ b/ABACUS.develop/source/src_lcao/lcao_orbitals.h @@ -10,7 +10,6 @@ #include "numerical_orbital.h" #include "numerical_orbital_lm.h" #include "numerical_nonlocal.h" -#include "neutral_pot.h" class LCAO_Orbitals { @@ -42,7 +41,6 @@ class LCAO_Orbitals Numerical_Orbital* Phi; Numerical_Nonlocal* Beta; - Neutral_Pot* Vna; // init in input.cpp double ecutwfc; diff --git a/ABACUS.develop/source/src_lcao/lcao_vna.cpp b/ABACUS.develop/source/src_lcao/lcao_vna.cpp deleted file mode 100644 index 81ef248809..0000000000 --- a/ABACUS.develop/source/src_lcao/lcao_vna.cpp +++ /dev/null @@ -1,207 +0,0 @@ -#include "lcao_vna.h" -#include "../src_pw/global.h" -#include "global_fp.h" // mohan add 2021-01-30 - -LCAO_Vna::LCAO_Vna() -{} - -LCAO_Vna::~LCAO_Vna() -{} - -void LCAO_Vna::two_center_vna(void) -{ - cout << " two center integration for vna" << endl; - - WARNING_QUIT("LCAO_Vna::two_center_vna","not ready yet"); - return; -} - - -// be called in Use_Hamilt_Matrix::set_ion -void LCAO_Vna::dense_vna(const char &matrix_type) -{ - TITLE("LCAO_Vna","dense_vna"); - timer::tick("LCAO_Vna","dense_vna",'E'); - - ofs_running << "\n SETUP VNA." << endl; - - const int istep = 1; - const int delta_vh = 0; - const int cal_vna = 1; // tmp by mohan - - const int dense = VNA; - - //-------------------------------------- - // set up a dense grid for doing dense - // grid integration - // note that for Si the length of Vna - // may be as long as 10.0 Bohr, so if - // cal_vna is turned on, the data in - // Grid_Technique will be different. - - // for example, bx=2, by=2, bz=2 - // nbx, nby, nbz stay as unchanged. - //-------------------------------------- - Grid_Technique gtf; - gtf.set_pbc_grid( - pw.ncx*dense,pw.ncy*dense,pw.ncz*dense, - pw.bx*dense,pw.by*dense,pw.bz*dense, - pw.nbx,pw.nby,pw.nbz, - pw.nbxx,pw.nbzp_start,pw.nbzp, - cal_vna); - //0); - - //--------------------------------------------- - // delta_vh = 0 means don't need to calculate - // delta Vhartree. - // but calculate the neutral potential - //--------------------------------------------- - - //-------------------------------------------------------- - // The neutral potential can be only used when vna = 1, - // then to be used to check if the real space neutral - // potential is correct - //-------------------------------------------------------- - - // for test - bool test_G_vl = false; - - // TEST ! - if(test_G_vl) - { - pot.init_pot(istep, delta_vh, cal_vna); - for(int ir=0; ir1, do the local part except the Vna. -void LCAO_Vna::smooth_vl2(void) -{ - TITLE("LCAO_Vna","smooth_vl2"); - timer::tick("LCAO_Vna","smooth_vl2",'I'); - - - //cout << " calculate the " << endl; - const int istep = 1; - // calculate the (delta_Vh + Vxc + Vefield) - bool delta_vh = 1; - bool vna = 0; - //-------------------------------------------- - // NOTE1 : istep must set to 1, otherwise the - // charge density may be changed! - // NOTE2 : the Vna should include the efield - // contribution. The unsymmetry potential - // due to efield can be only evaluated - // using grid integration. - //-------------------------------------------- - pot.init_pot(istep, delta_vh, vna); - - for(int ir=0; irdense_vna(matrix_type); - - //------------------------------------- - // very important step! - // turn back the full local potential. - //------------------------------------- - pot.init_pot(istep); - - - timer::tick("LCAO_Vna","smooth_vl2",'I'); - return; -} - - - -void LCAO_Vna::smooth_vl1(void) -{ - TITLE("LCAO_Vna","smooth_vl1"); - - //cout << " calculate the " << endl; - const int istep=1; - // calculate the (delta_Vh + Vxc) - bool delta_vh = 1; - bool vna = 0; - // istep must set to 1, otherwise the charge - // density may be changed! - pot.init_pot(istep, delta_vh, vna); - - for(int ir=0; ir" << endl; - /* - delta_vh = 0; - vna = 1; - pot.init_pot(istep, delta_vh, vna); - - for(int ir=0; ir1) - { - LCAO_Vna lv; - lv.smooth_vl2(); - } - else if(VNA==1) - { - LCAO_Vna::smooth_vl1(); - } } } } diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index 56061f1006..4cea73e6f8 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -136,12 +136,11 @@ void Local_Orbital_Ions::opt_ions(void) // here 0 means GridT is not used for Vna. // mohan add Vna 2012-06-13 // because it must be consistent with gtf in lcao_vna. - // here VNA means considering the radius cutoff VNA. GridT.set_pbc_grid( pw.ncx, pw.ncy, pw.ncz, pw.bx, pw.by, pw.bz, pw.nbx, pw.nby, pw.nbz, - pw.nbxx, pw.nbzp_start, pw.nbzp, VNA); + pw.nbxx, pw.nbzp_start, pw.nbzp); // (2) If k point is used here, allocate HlocR after atom_arrange. if(!GAMMA_ONLY_LOCAL) @@ -724,7 +723,7 @@ void Local_Orbital_Ions::final_scf(void) pw.ncx, pw.ncy, pw.ncz, pw.bx, pw.by, pw.bz, pw.nbx, pw.nby, pw.nbz, - pw.nbxx, pw.nbzp_start, pw.nbzp, VNA); + pw.nbxx, pw.nbzp_start, pw.nbzp); // (2) If k point is used here, allocate HlocR after atom_arrange. if(!GAMMA_ONLY_LOCAL) @@ -819,11 +818,8 @@ void Local_Orbital_Ions::output_HS_R(void) { if(VL_IN_H) { - if(VNA==0) - { - //UHM.GK.cal_vlocal_k(pot.vrs1,GridT); - UHM.GK.cal_vlocal_k(pot.vrs1,GridT,CURRENT_SPIN); - } + //UHM.GK.cal_vlocal_k(pot.vrs1,GridT); + UHM.GK.cal_vlocal_k(pot.vrs1,GridT,CURRENT_SPIN); } } UHM.GK.cal_vlocal_R(CURRENT_SPIN); diff --git a/ABACUS.develop/source/src_lcao/make_vna_table.cpp b/ABACUS.develop/source/src_lcao/make_vna_table.cpp deleted file mode 100644 index e1796c84af..0000000000 --- a/ABACUS.develop/source/src_lcao/make_vna_table.cpp +++ /dev/null @@ -1,355 +0,0 @@ -#include "make_vna_table.h" -#include "../src_pw/tools.h" -#include "ylm.h" -#include "lcao_orbitals.h" - -double Make_Vna_Table::dr = -1.0; - -Make_Vna_Table::Make_Vna_Table() -{ - ntype = 0; - lmax = 0; - kmesh = 0; - Rmax = 0.0; - dr = 0.0; - dk = 0.0; - - nlm = 0; - Rmesh = 0; - - kpoint = new double[1]; - r=new double[1]; - rab=new double[1]; - kab=new double[1]; -} - -Make_Vna_Table::~Make_Vna_Table() -{ - delete[] kpoint; - delete[] r; - delete[] rab; - delete[] kab; - -} - -void Make_Vna_Table::allocate ( - const int &ntype_in, - const int &lmax_in, - const int &kmesh_in, - const double &Rmax_in, - const double &dr_in, - const double &dk_in) -{ - TITLE("Make_Vna_Table", "allocate"); - - this->ntype = ntype_in;// type of elements. - this->lmax = lmax_in; - this->kmesh = kmesh_in; - this->Rmax = Rmax_in; - this->dr = dr_in; - this->dk = dk_in; - - assert(ntype > 0); - assert(lmax >= 0); - assert(kmesh > 0.0); - assert(Rmax >= 0.0); - assert(dr>0.0); - assert(dk>0.0); - - // calculated from input parameters - this->nlm = (2*lmax+1) * (2*lmax+1); - this->Rmesh = static_cast( Rmax/dr ) + 4; - if(Rmesh%2==0) - { - ++Rmesh; - } - - // rnew the arrays - delete[] kpoint; - delete[] r; - kpoint = new double[kmesh]; - r = new double[Rmesh]; - - delete[] rab; - delete[] kab; - kab = new double[kmesh]; - rab = new double[Rmesh]; - - // set the array values - for (int ik = 0; ik < kmesh; ik++) - { - this->kpoint[ik] = ik * dk_in; - this->kab[ik] = dk_in; - } - - for (int ir = 0; ir < Rmesh; ir++) - { - this->r[ir] = ir * dr; - this->rab[ir] = dr; - } - return; -} - - -int Make_Vna_Table::get_rmesh(const double &R1, const double &R2) -{ - int rmesh = static_cast((R1+R2)/ Make_Vna_Table::dr) + 5; - //mohan update 2009-09-08 +1 ==> +5 - //considering interpolation or so on... - if (rmesh % 2 == 0) rmesh ++; - - if(rmesh <= 0) - { - ofs_warning << "\n R1 = " << R1 << " R2 = " << R2; - ofs_warning << "\n rmesh = " << rmesh; - WARNING_QUIT("Make_Vna_Table::get_rmesh", "rmesh <= 0"); - } - return rmesh; -} - - -void Make_Vna_Table::init_Vna_Tpair(void) -{ - TITLE("Make_Vna_Table","init_Vna_Tpair"); - - this->Vna_nTpairs = this->ntype * this->ntype; - this->Vna_Tpair.create( this->ntype, this->ntype); - this->Vna_L2plus1.create( this->ntype, this->ntype); - - int index = 0; - for (int T1 = 0; T1 < ntype ; T1++) - { - for (int T0 = 0 ; T0 < ntype ; T0++) - { - this->Vna_Tpair(T1,T0) = index; - ++index; - - // the pair < psi | beta > - // be careful! This is not a symmetry matrix. - this->Vna_L2plus1(T1,T0) = std::max(ORB.Phi[T1].getLmax(), ORB.Beta[T0].getLmax() )*2+1; - - // there are special situations: - // for example, two H atom without projector. - // if we use s orbital, - // Phi.getLmax = 0, - // Beta.getLmax < 0, - // so the value is 1. - // however, there are no projectors. - if(Vna_L2plus1(T1,T0) <= 0) - { - WARNING_QUIT("Make_Vna_Table::init_paris_nonlocal_type","NL_L2plus1<=0"); - } - } - } - return; -} - - -void Make_Vna_Table::init_Table_Chi(void) -{ - TITLE("Make_Vna_Table", "init_Table_Chi"); - timer::tick("Make_Vna_Table", "init_Table_Chi",'D'); - - // (1) allocate 1st dimension ( overlap, derivative) - this->Table_VnaR = new double****[2]; - // (2) allocate 2nd dimension ( overlap, derivative) - this->Table_VnaR[0] = new double*** [this->Vna_nTpairs]; - this->Table_VnaR[1] = new double*** [this->Vna_nTpairs]; - - // <1Phi|2Chi> - for (int T1 = 0; T1 < ntype ; ++T1) // type 1 is orbital - { - const int Lmax1 = ORB.Phi[T1].getLmax(); - for (int T2 = 0 ; T2 < ntype ; ++T2)// type 2 is non-local projector - { - const int Lmax2 = ORB.Vna[T2].getLmax(); - - // Tpair: type pair. - const int Tpair=this->Vna_Tpair(T1,T2); - const int nchi1 = ORB.Phi[T1].getTotal_nchi(); - - const int nchi2 = ORB.Vna[T2].getTotal_nchi(); - const int pairs_chi = nchi1 * nchi2; - - if(pairs_chi == 0)continue; - - // init 2nd dimension - this->Table_VnaR[0][Tpair] = new double** [ pairs_chi ]; - this->Table_VnaR[1][Tpair] = new double** [ pairs_chi ]; - - const int T12_2Lplus1 = this->Vna_L2plus1(T1,T2); - const double Rcut1 = ORB.Phi[T1].getRcut(); - - for (int L1 = 0; L1 <= Lmax1; ++L1) - { - for (int N1 = 0; N1 < ORB.Phi[T1].getNchi(L1); ++N1) - { - for(int L2 = 0; L2 <= Lmax2; ++L2) - { - for(int N2 = 0; N2 < ORB.Vna[T2].getNchi(L2); ++N2) - { - const double Rcut2 = ORB.Vna[T2].rcut; - const int Opair = this->Vna_Opair(Tpair,L1,N1,L2,N2); - assert( Opair < pairs_chi ); - - // init 3rd dimension - this->Table_VnaR[0][ Tpair ][ Opair ] = new double *[T12_2Lplus1]; - this->Table_VnaR[1][ Tpair ][ Opair ] = new double *[T12_2Lplus1]; - - const int rmesh = this->get_rmesh( Rcut1, Rcut2); - assert( rmesh < this->Rmesh ); - - //not all L in T12_2Lplus1 would function - //const int SL = abs(L1-L2); - //const int AL = L1+L2; - - for (int L=0; L < T12_2Lplus1 ; L++) - { - //Allocation - this->Table_VnaR[0][Tpair][Opair][L] = new double[rmesh]; - this->Table_VnaR[1][Tpair][Opair][L] = new double[rmesh]; - - } - } - } - } - } - }//end T2 - }//end T1 - - - return; -} - - - - - -// phi is the atomic orbital, chi is the projector of Vna -void Make_Vna_Table::init_Vna_Opair(void) -{ - const int lmax = ORB.get_lmax(); - const int nchimax = ORB.get_nchimax(); - assert(lmax+1 > 0); - assert(nchimax > 0); - assert(Vna_nTpairs > 0); - - this->Vna_Opair.create( this->Vna_nTpairs, lmax+1, lmax+1, nchimax, nchimax); - - for(int T1=0; T1Vna_Tpair(T1,T2); - int index=0; - for(int L1=0; L1Vna_Opair(dim1, L1, L2, N1, N2) = index; - ++index; - } - } - } - } - } - } - return; -} - - -void Make_Vna_Table::cal_Vna_PhiChi_R( - const int &l, - const Numerical_Orbital_Lm &n1, - const Neutral_Pot &n2, - const int &rmesh, - double* rs, - double* drs) -{ - timer::tick("Make_Vna_Table","cal_Vna_PhiChi_R"); - - /* - assert(kmesh > 0); - double *k1_dot_k2 = new double[kmesh]; - for (int ik = 0; ik < kmesh; ik++) - { - // k1_dot_k2[ik] = n1.getPsi_k(ik) * n2.getChi_k(ik); - } - - double* integrated_func = new double[kmesh]; - double* jl; - - for (int ir = 0; ir < rmesh; ir++) - { - ZEROS(integrated_func,kmesh); - double temp = 0.0; - jl = this->jlx[l][ir]; - - for (int ik = 0; ik < kmesh; ik++) - { - integrated_func[ik] = jl[ik] * k1_dot_k2[ik]; - } - // Call simpson integration - Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp); - rs[ir] = temp * FOUR_PI; - - //drs - double temp1, temp2; - - if (l > 0) - { - jl = this->jlx[l-1][ir]; - for (int ik = 0; ik < kmesh; ik++) - { - integrated_func[ik] = jl[ik] * k1_dot_k2[ik] * kpoint[ik]; - } - Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp1); - } - - jl = this->jlx[l+1][ir]; - - for (int ik = 0; ik < kmesh; ik++) - { - integrated_func[ik] = jl[ik] * k1_dot_k2[ik] * kpoint[ik]; - } - - Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp2); - - if (l == 0) - { - drs[ir] = -FOUR_PI*temp2; - } - else - { - drs[ir] = FOUR_PI*(temp1*l-(l+1)*temp2)/(2.0*l+1); - } - } - - - //special case for R=0 - //we store Slm(R) / R**l at the fisrt point, rather than Slm(R) - if (l > 0) - { - ZEROS(integrated_func,kmesh); - double temp = 0.0; - - for (int ik = 0; ik < kmesh; ik++) - { - integrated_func[ik] = k1_dot_k2[ik] * pow (kpoint[ik], l); - } - - // Call simpson integration - Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp); - rs[0] = FOUR_PI / Mathzone_Add1::dualfac (2*l+1) * temp; - } - - delete[] integrated_func; - delete[] k1_dot_k2; - */ - timer::tick("Make_Vna_Table","cal_Vna_PhiChi_R"); - return; -} diff --git a/ABACUS.develop/source/src_lcao/make_vna_table.h b/ABACUS.develop/source/src_lcao/make_vna_table.h deleted file mode 100644 index f4b85bbdfb..0000000000 --- a/ABACUS.develop/source/src_lcao/make_vna_table.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef MAKE_VNA_TABLE_H -#define MAKE_VNA_TABLE_H - -#include "../src_pw/tools.h" -#include "neutral_pot.h" -#include "numerical_orbital_lm.h" - -class Make_Vna_Table -{ - public: - - Make_Vna_Table(); - ~Make_Vna_Table(); - - void allocate ( - const int &ntype, - const int &lmax_in, - const int &kmesh_in, - const double &Rmax_in, - const double &dR_in, - const double &dk_in); - - - static double dr; - int Rmesh; - - static int get_rmesh( const double &R1, const double &R2); - - void init_Table_Chi(void); - void Destroy_Table_Chi(void); - - - // Five dimension: - // (1) 0: normal (S(R)) ; 1: derivative( dS/dR ) - // (2) pairs type number. - // (3) pairs chi. - // (4) Max angular momentum: L. - // (5) Distance between atoms: R. - double***** Table_VnaR; - - - void init_Vna_Tpair(void); - void init_Vna_Opair(void); - - - // number of pairs - int Vna_nTpairs; - - // index for atom type pairs - IntArray Vna_Tpair; - - IntArray Vna_Opair; - - IntArray Vna_L2plus1; - - bool destroy_Vna; - - private: - - - // phi is the atomic orbital, chi is the projector of Vna - void cal_Vna_PhiChi_R( - const int &l, - const Numerical_Orbital_Lm &n1, - const Neutral_Pot &n2, - const int &rmesh, - double* rs, - double* drs); - - - //variables - int ntype; - int lmax; - double Rmax; - double dk; - int nlm; - int kmesh; - double *kpoint; - double *r; - double *rab; - double *kab; - - -}; - -#endif diff --git a/ABACUS.develop/source/src_lcao/neutral_pot.cpp b/ABACUS.develop/source/src_lcao/neutral_pot.cpp deleted file mode 100644 index 3dfce0cd24..0000000000 --- a/ABACUS.develop/source/src_lcao/neutral_pot.cpp +++ /dev/null @@ -1,356 +0,0 @@ -#include "neutral_pot.h" -#include "../src_pw/tools.h" -#include "../src_pw/global.h" -#include "../src_global/poission.h" - -Neutral_Pot::Neutral_Pot() -{ - vna = new double[1]; - vna_u = new double[1]; - - // for Vna projector - nchi = new int[1]; - - lmax = -1; - mesh_u = 0; -} - -Neutral_Pot::~Neutral_Pot() -{ - delete[] vna; - delete[] vna_u; - - // for Vna projectors - delete[] nchi; -} - -void Neutral_Pot::setup_Vna(const int &it) -{ - TITLE("Neutral_Pot","setup_Vna"); - - ofs_running << "\n SETUP THE 1D NEUTRAL POTENTIAL VNA FOR " << ucell.atoms[it].label << endl; - //cout << " setup the neutral potential Vna." << endl; - - //================================================== - // setup the local part of pseudopotentials. - //================================================== - Atom* atom = &ucell.atoms[it]; - const int msh = atom->msh; - double* vloc = atom->vloc_at; - double* r = atom->r; - stringstream ss; - ss << global_out_dir << atom->label << "/" << atom->label << "_vl_pseudo_r.dat"; - this->output_1dv(ss.str(),msh,vloc,r); - - //================================================== - // setup the one dimensional atomic charge density. - //================================================== - double* rhoatm = new double[msh]; - double* vatom = new double[msh]; - ZEROS(rhoatm, msh); - ZEROS(vatom, msh); - - for(int ir=0; irrho_at[ir] / FOUR_PI / r2; - } - - double charge = 0.0; - Mathzone::Simpson_Integral(atom->msh,atom->rho_at,atom->rab,charge); - - OUT(ofs_running,"charge from pseudo file",charge); - - //--------------------------------------------- - // need to scale the charge if - // the charge read from the pseudopotential - // is not equal to the actul valence electron - // number - //--------------------------------------------- - assert(charge!=0.0); - double scale=1.0; - if(charge!=atom->zv) - { - OUT(ofs_running,"charge should be",atom->zv); - scale = atom->zv/charge; - } - - for(int ir=0; irlabel << "/" << atom->label << "_v_atom.dat"; - this->output_1dv(ssc.str(),msh,vatom,r); - - //================================== - // calculate the neutral potential. - //================================== - delete[] vna; - vna = new double[msh]; - ZEROS(vna, msh); - - for(int ir=0; irlabel << "/" << atom->label << "_vna.dat"; - this->output_1dv(ssn.str(),msh,vna,r); - - return; -} - -void Neutral_Pot::output_1dv(const string &fn, const int &msh, const double* target, const double* r)const -{ - if(MY_RANK!=0) return; - ofstream ofs(fn.c_str()); - for(int ir=0; ir 0.0 ); - - this->dr = dr_in; - Atom* atom = &ucell.atoms[it]; - this->rcut = atom->r[ atom->msh-1 ]; - - double threshold = 1.0e-5; //tmp by mohan - //if threshold goes down to 1.0e-5, oscillation may happen. - for(int ir=0; ir< atom->msh; ir++) - { - if( abs( vna[ir] ) < threshold ) - { - this->rcut = atom->r[ir]; - break; - } - } - - // mohan note: 2011-05-23, - // if rcut > 15, check pseudo_atom.cpp, - // the readin radius must be larger. - assert(rcut <= 15); - - OUT(ofs_running,"radius cutoff of Vna (Bohr)",rcut); - OUT(ofs_running,"threshold of Vna",threshold); - - this->nr = (int)(rcut / dr_in)+5;//mohan fix bug 2011-06-03 - - delete[] vna_u; - this->vna_u = new double[nr]; - ZEROS(vna_u, nr); - - double* r = new double[nr]; - ZEROS(r, nr); - - for (int ir = 0; ir < this->nr; ir++) - { - r[ir] = ir * this->dr; - // mohan fix serious bug 2012-01-11, - // the dimension of atom->r should be the 3rd parameter. - //this->vna_u[ir] = Mathzone::Polynomial_Interpolation_xy( atom->r, vna, this->nr, r[ir]); - this->vna_u[ir] = Mathzone::Polynomial_Interpolation_xy( atom->r, vna, atom->msh, r[ir]); - } - - stringstream ssu; - ssu << global_out_dir << atom->label << "/" << atom->label << "_vna_uniform.dat"; - this->output_1dv(ssu.str(),nr,vna_u,r); - - delete[] r; - - return; -} - - - -void Neutral_Pot::init_proj(Numerical_Orbital &Phi, const double &dr_uniform) -{ - cout << " ==> init_proj of Vna"; - // set the lmax we used - this->lmax = Phi.getLmax(); - - // set the total number of Chi, which equals the Vna projector now. - this->total_nchi; - for(int L=0; L<=lmax; ++L) - { - this->total_nchi += Phi.getNchi(L); - } - - cout << " lmax=" << lmax << " total_nchi=" << total_nchi << endl; - - delete[] nchi; - this->nchi = new int[lmax+1]; - ZEROS( nchi, lmax+1); - - for(int L=0; L<=lmax; ++L) - { - nchi[L] = Phi.getNchi(L); - } - - // initialize the Chi = Gram-Schemit ( VnaPsi ) - cout << " nr for Vna is " << this->nr << endl; - cout << " rcut fo Vna is " << this->rcut << endl; - cout << " Rcut for Orbital is " << Phi.getRcut() << endl; - - - double radius = std::min( this->rcut, Phi.getRcut() ); - assert(radius>0.0); - assert(dr_uniform>0.0); - this->mesh_u = static_cast(radius / dr_uniform); - if(mesh_u%2==0) ++mesh_u; - cout << " mesh_u = " << mesh_u << endl; - - // calculate the radius function Phi * Vna - double** VnaPhi = new double*[total_nchi]; - for(int ic=0; icset_vnaphi(VnaPhi, Phi, dr_uniform); - - - - for(int ic=0; iclmax; ++L) - { - for(int N=0; N< this->nchi[L]; ++N) - { - for(int ir=0; ir< this->mesh_u; ++ir) - { - VnaPhi[ic_index][ir] = this->vna_u[ir] * Phi.PhiLN(L,N).psi_uniform[ir]; - } - ++ic_index; - } - } - - // - for(int L=0; L<= this->lmax; ++L) - { - for(int N=0; N< this->nchi[L]; ++N) - { - double overlap = 0.0; - for(int ir=0; ir< this->mesh_u; ++ir) - { - // orbr[i] = VnaPhi[ic_index][ir] * ((double)ir*ORB.dr_uniform); - } - ++ic_index; - } - } - - - //------------------------------------- - // Schmit-Gramit orthogonalization. - //------------------------------------- - double **new_orb = new double*[this->total_nchi]; - for(int i=0; ilmax; ++L) - { - for(int N1=0; N1< this->nchi[L]; ++N1) - { - if(N1==0) - { - for(int ir=0; ir< this->mesh_u; ++ir) - { - new_orb[ic_index][ir] = vna_u[ir] * Phi.PhiLN(L,N1).psi_uniform[ir]; - } - } - - //------------------------------------------------ - // calculate the overlap < Phi_new | Vna | Phi > - // and < Phi_new | Vna | Phi_new > - //------------------------------------------------ - else if(N1>0) - { - const int NN = nchi[L] - 1; - // must orthogonal to the previous multi-zeta orbitals. - for(int N_pre=0; N_premesh_u, f, rab, overlap); - - // ddot < Phi_new | Vna | Phi > - for(int ir=0; ir -#include "numerical_orbital.h" -#include "numerical_vna_lm.h" -using namespace std; - -class Neutral_Pot -{ - public: - - Neutral_Pot(); - ~Neutral_Pot(); - - void setup_Vna(const int &it); - void uniform_Vna(const int &it, const double &dr_in ); - - double* vna; - double* vna_u; // uniform mesh. - double dr; - double rcut; - int nr; - - private: - - void output_1dv(const string &fn, const int &msh, const double* target, const double* r)const; - - - //--------------------------------------------------------- - // the following is for the exansion of Neutral Potential - //--------------------------------------------------------- - public: - - const int& getLmax(void) const {return lmax;} - const int& getTotal_nchi(void) const { return total_nchi; } - const int& getNchi(const int l) const { return this->nchi[l]; } - - - // initial lmax, nmax, etc. - void init_proj(Numerical_Orbital &Phi, const double &dr_uniform); - - - Numerical_Vna_Lm* VnaLN;// length: total_nchi (only store radial function ) - - private: - - int lmax; - int total_nchi; - int* nchi; - int mesh_u; - - void set_vnaphi(double** VnaPhi, Numerical_Orbital &Phi, const double &dr_uniform); - -}; - -#endif diff --git a/ABACUS.develop/source/src_lcao/numerical_vna_lm.cpp b/ABACUS.develop/source/src_lcao/numerical_vna_lm.cpp deleted file mode 100644 index 120ed38dae..0000000000 --- a/ABACUS.develop/source/src_lcao/numerical_vna_lm.cpp +++ /dev/null @@ -1,238 +0,0 @@ -#include "numerical_vna_lm.h" - -Numerical_Vna_Lm::Numerical_Vna_Lm() -{ - label = ""; - index_atom_type = 0; - angular_momentum_l = 0; - index_chi = 0; - - nr=1; - nk=1; - - rcut=0.0; - kcut=0.0; - dk=0.0; - - r_radial = new double[1]; - k_radial = new double[1]; - rab = new double[1]; - psi = new double[1]; - psir = new double[1]; - psik = new double[1]; - -} - -Numerical_Vna_Lm::~Numerical_Vna_Lm() -{ - delete[] r_radial; - delete[] k_radial; - delete[] rab; - delete[] psi; - delete[] psir; - delete[] psik; -} - -void Numerical_Vna_Lm::set_vna_proj_info -( - const string &label_in, - const int &index_atom_type_in, - const int &angular_momentum_l_in, - const int &index_chi_in, - const int &nr_in, - const double *rab_in, - const double *r_radial_in, - const double *psi_in, - const int &nk_in, - const double &dk_in, - const double &lat0 -) -{ - this->label = label_in; - this->index_atom_type = index_atom_type_in; - this->angular_momentum_l = angular_momentum_l_in; - this->index_chi = index_chi_in; - assert(nr_in>=2); - assert(nr_in<10000); - assert(nr%2!=0); - this->nr = nr_in; - assert(r_radial_in[nr-1]>0.0); - assert(r_radial_in[nr-1]<50); - assert(lat0 > 0); - this->rcut = r_radial_in[nr-1]; - assert(nk_in>1); - assert(nk_in<10000); - this->nk = nk_in; - assert(nk%2!=0); - assert(dk_in>0); - this->dk = dk_in; - - delete[] r_radial; - delete[] k_radial; - delete[] rab; - delete[] psi; - delete[] psir; - delete[] psik; - - r_radial = new double[nr]; - k_radial = new double[nk]; - rab = new double[nr]; - psi = new double[nr]; - psir = new double[nr]; - psik = new double[nk]; - - /*********************************************************** - be careful! LiaoChen modify on 2010/4/21 - ************************************************************/ -// this->dk = PI / rcut / 2.0; -// this->nk = this->nr; - - for (int ir = 0; ir < nr; ir++) - { - this->r_radial[ir] = r_radial_in[ir]; - this->rab[ir] = rab_in[ir]; - this->psi[ir] = psi_in[ir]; - this->psir[ir] = psi[ir] * r_radial[ir]; //mohan 2010-04-19 - } - - for (int ik = 0; ik < nk; ik++) - { - this->k_radial[ik] = ik * this->dk; - } - this->kcut = (nk-1) * this->dk; - - //liaochen modify on 2010/4/7 - //we do SBT on regular mesh - //so we first generate psi_uniform first - //we put uniform in ahead of cal_kradial - - this->cal_kradial(); - this->norm_test(); - this->plot(); - - return; -} - -//use Sbt_new -void Numerical_Vna_Lm::cal_kradial(void) -{ - assert( this->nr > 0); - double *jl = new double[nr]; - double *integrated_func = new double[nr]; - - const double pref = sqrt( 2.0 / PI ); - //Sbt method - - //integration directly - for (int ik = 0; ik < nk; ik++) - { - Mathzone::Spherical_Bessel( - this->nr, - this->r_radial, - this->k_radial[ik], - this->angular_momentum_l, - jl); - - for (int ir = 0; ir < nr; ir++) - { - integrated_func[ir] = this->psir[ir] * this->r_radial[ir] * jl[ir]; - } - - Mathzone::Simpson_Integral( - this->nr, - integrated_func, - this->rab, - this->psik[ik]); - - this->psik[ik] *= ( pref * k_radial[ik]); - } - - delete[] integrated_func; - delete[] jl; -} - -//=============================================== -//FOUND LOCAL VARIABLE -//asum : integral of psi*psi in whole space -//=============================================== -void Numerical_Vna_Lm::norm_test(void)const -{ -// TITLE(ofs_onscaling, "Numerical_Vna_Lm", "norm_test"); - //double asum_r = 0.0; - //double asum_k = 0.0; - - // note here psir = psi * r - double *f = new double[nr]; - for(int ir=0; irpsir[ir] * this->psir[ir]; - } - - double sumr = 0.0; - //double sumk = 0.0; - - Mathzone::Simpson_Integral(this->nr, f, this->rab, sumr); - - delete[] f; - f = new double[nk]; - for(int ik=0; ikpsik[ik] * this->psik[ik]; - } - -// Mathzone::Simpson_Integral(this->nk, f, this->k_radial, sumk); - - //means nothing. - //ofs_running << setw(12) << sumk << endl; - - delete[] f; - return; -} - -void Numerical_Vna_Lm::plot(void)const -{ - TITLE("Numerical_Vna_Lm","plot"); - - string orbital_type; - switch( this->angular_momentum_l ) - { - case 0: orbital_type = "s"; break; - case 1: orbital_type = "p"; break; - case 2: orbital_type = "d"; break; - case 3: orbital_type = "f"; break; - case 4: orbital_type = "g"; break; - default: WARNING_QUIT("Numerical_Vna_Lm::plot","Please check in functoin."); - } - - if(MY_RANK==0) - { - stringstream ssr, ssk, ssru; - ssr << global_out_dir << this->label << "/" - << this->label << "-" << orbital_type << index_chi+1 << "-vna-proj-r.dat"; - - ssk << global_out_dir << this->label << "/" - << this->label << "-" << orbital_type << index_chi+1 << "-vna-proj-k.dat"; - - ofstream ofsr(ssr.str().c_str()); - ofstream ofsk(ssk.str().c_str()); - - if (!ofsk || !ofsr) - { - WARNING("Numerical_Vna_Lm : plot", "Can't open files !"); - } - - for (int i = 0; i < this->nr; i++) - { - ofsr << this->r_radial[i] << " " << psi[i] << endl; - } - - for (int i = 0; i < this->nk; i++) - { - ofsk << this->k_radial[i] << " " << psik[i] << endl; - } - - ofsr.close(); - ofsk.close(); - } - return; -} diff --git a/ABACUS.develop/source/src_lcao/numerical_vna_lm.h b/ABACUS.develop/source/src_lcao/numerical_vna_lm.h deleted file mode 100644 index bfb16eb64c..0000000000 --- a/ABACUS.develop/source/src_lcao/numerical_vna_lm.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef NUMERICAL_VNA_LM_H -#define NUMERICAL_VNA_LM_H - -#include "../src_pw/tools.h" -//#include "../src_parallel/fftw.h" - -//========================================================= -//CLASS Numerical_Vna_Lm -//Note : contain information about each Vna projector -//========================================================= - -class Numerical_Vna_Lm -{ - friend class Neutral_Pot; - -public: - - Numerical_Vna_Lm(); - ~Numerical_Vna_Lm(); - - const int& getL() const { return angular_momentum_l; } - const int& getType() const { return index_atom_type; } - const int& getChi() const {return index_chi; } - - const double* getRadial() const { return r_radial; } - const double& getRadial(const int ir) const { return r_radial[ir]; } - - const double* getPsi() const { return psi;} - const double* getPsi_r() const { return psir; } - const double& getPsi_r(const int ir) const { return psir[ir]; } - - const double& getDk()const { return dk; } - const double* getKpoint()const { return k_radial; } - const double& getKpoint(const int ik) const { return k_radial[ik]; } - const double* getPsi_k() const { return psik; } - const double& getPsi_k(const int ik) const { return psik[ik]; } - -//========================================================== -// EXPLAIN : set information about Numerical_Orbital_Lm -// MEMBER FUNCTION : -//========================================================== - void set_vna_proj_info - ( - const string &label_in, - const int &index_atom_type_in, - const int &angular_momentum_l_in, - const int &index_chi_in, - - const int &nr_in, - const double *rab_in, - const double *r_radial_in, - const double *psi_in, - - const int &nk_in, - const double &dk_in, - - const double &lat0 - ); - -private: - - void cal_kradial(void); - void norm_test()const; - void plot()const; - - string label; - int index_atom_type; - int angular_momentum_l; - int index_chi; - - int nr; - int nk; - - double rcut; - double kcut; - double dk; - - double* r_radial; //points of r - double* k_radial; - - double* rab; - - double* psi;//psi(r) - double* psir; //psi(r) * r - double* psik; - -}; - -#endif - diff --git a/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp b/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp index a0bfc4341c..d033bea92b 100644 --- a/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp @@ -2,8 +2,6 @@ #include "use_hamilt_matrix.h" #include "build_st_pw.h" #include "sltk_atom_arrange.h" -#include "lcao_vna.h" - #include "global_fp.h" // mohan add 2021-01-30 Use_Hamilt_Matrix::Use_Hamilt_Matrix() @@ -30,31 +28,12 @@ void Use_Hamilt_Matrix::set_ion(void) if(GAMMA_ONLY_LOCAL) { // mohan add 2012-03-29 - if(GRID_SPEED==1) - { - // calculate the grid integration of 'Vl' matrix for gamma algorithms. - this->GG.prepare(ucell.latvec, ucell.lat0); - } - else if(GRID_SPEED==2) - { - this->GG.prepare(ucell.latvec, ucell.lat0); - this->GS.prepare(ucell.latvec, ucell.lat0); - } - else - { - WARNING_QUIT("Use_Hamilt_Matrix::set_ion","GRID_SPEED should be 1 or 2"); - } + // calculate the grid integration of 'Vl' matrix for gamma algorithms. + this->GG.prepare(ucell.latvec, ucell.lat0); // calulate the 'S', 'T' and 'Vnl' matrix for gamma algorithms. this->calculate_STNR_gamma(); - // vna only need to do once, you can check this in lcao_vna.cpp - if(VNA>=1) - { - LCAO_Vna lv; - const char matrix_type='T'; - lv.dense_vna(matrix_type); - } } else // multiple k-points { @@ -64,18 +43,6 @@ void Use_Hamilt_Matrix::set_ion(void) // calculate the grid integration of 'Vl' matrix for l-points algorithms. this->GK.init(pw.nbx, pw.nby, pw.nbzp, pw.nbzp_start, pw.ncxyz); - // do real space grid integration. - if(VNA>=1) - { - LCAO_Vna lv; - const char matrix_type='T'; - lv.dense_vna(matrix_type); - } - else if(VNA==-1) - { - LCAO_Vna lv; - lv.two_center_vna(); - } } // initial the overlap matrix is done. @@ -112,34 +79,8 @@ void Use_Hamilt_Matrix::calculate_Hgamma( const int &ik ) // Peize Lin add ik // calculate the 'Vl' matrix using gamma-algorithms. if(VL_IN_H) { - if(VNA==0) - { - if(GRID_SPEED==1) - { - this->GG.cal_vlocal(pot.vrs1); - } - else if(GRID_SPEED==2) - { - this->GS.cal_vlocal(pot.vrs1); - } - } - else if(VNA>1) - { - //------------------------------------------------ - // calculate the Vna from dense grid integration. - //------------------------------------------------ - LCAO_Vna lv; - lv.smooth_vl2(); - //LCAO_Vna::real_space_vna(); - } - else if(VNA==1) - { - //------------------------------------------------ - // calculat the Vna from normal real space grid. - //------------------------------------------------ - LCAO_Vna::smooth_vl1(); - } - + this->GG.cal_vlocal(pot.vrs1); + // Peize Lin add 2016-12-03 if( 5==xcf.iexch_now && 0==xcf.igcx_now ) // HF { diff --git a/ABACUS.develop/source/src_lcao/use_hamilt_matrix.h b/ABACUS.develop/source/src_lcao/use_hamilt_matrix.h index a8c9a61512..e3b77e9e89 100644 --- a/ABACUS.develop/source/src_lcao/use_hamilt_matrix.h +++ b/ABACUS.develop/source/src_lcao/use_hamilt_matrix.h @@ -4,7 +4,6 @@ #include "../src_pw/tools.h" #include "use_overlap_matrix.h" #include "gint_gamma.h" -#include "gint_speed.h" //mohan add 2012-03-29 #include "gint_k.h" #include "grid_integral.h" @@ -26,8 +25,6 @@ class Use_Hamilt_Matrix // used for gamma only algorithms. Gint_Gamma GG; - // fast grid integration, mohan add 2012-03-29 - Gint_Speed GS; // used for k-dependent grid integration. Gint_k GK; diff --git a/ABACUS.develop/source/src_lcao/use_overlap_table.cpp b/ABACUS.develop/source/src_lcao/use_overlap_table.cpp index 08d5ec6a32..994320defe 100644 --- a/ABACUS.develop/source/src_lcao/use_overlap_table.cpp +++ b/ABACUS.develop/source/src_lcao/use_overlap_table.cpp @@ -35,21 +35,19 @@ void Use_Overlap_Table::gen_tables( const int &job0 ) MOT.init_NL_Tpair(); MOT.init_NL_Opair(); // add 2009-5-8 + // mohan comment out 2021-02-09 // if we decompose the VNA into projectors, // we need to prepare for the vna table. - if(VNA==-1) - { - MVT.allocate( - ORB.get_ntype(),// number of atom types - ORB.get_lmax(),// max L used to calculate overlap - ORB.get_kmesh(), // kpoints, for integration in k space - ORB.get_Rmax(),// max value of radial table - ORB.get_dR(),// delta R, for making radial table - ORB.get_dk() ); // delta k, for integration in k space - - - - } + //if(VNA==-1) + //{ + // MVT.allocate( + // ORB.get_ntype(),// number of atom types + // ORB.get_lmax(),// max L used to calculate overlap + // ORB.get_kmesh(), // kpoints, for integration in k space + // ORB.get_Rmax(),// max value of radial table + // ORB.get_dR(),// delta R, for making radial table + // ORB.get_dk() ); // delta k, for integration in k space + //} //========================================= @@ -816,42 +814,4 @@ double Use_Overlap_Table::get_distance( const Vector3 &R1, const Vector3 return dR.norm() * this->lat0; } -void Use_Overlap_Table::snap_phiVna( - double VnaMat[], - const int& job, - const Vector3 &Rv, - const int& itv, - const int& l1, - const int& m1, - const int& n1, - const Vector3 &Ru, - const int& itu, - const int& l2, - const int& m2, - const int& n2, - const Vector3 &Rvna, - const int& itvna) const -{ - cout << " snap phiVna " << endl; - - - - int lmax = 2; - int nzeta = 1; - for(int L0=0; L0<=lmax; ++L0) - { - for(int m0=0; m0<2*L0+1; ++m0) - { - for(int N0=0; N0 *nlm1=NULL, const int is=0)const; - //------------------------------------------------------ - // snap_phiVna : Get Matrix Element of - //------------------------------------------------------ - void snap_phiVna( - double VnaMat[], - const int &job, - const Vector3 &Rv, - const int &itv, - const int &l1, - const int &m1, - const int &n1, - const Vector3 &Ru, - const int &itu, - const int &l2, - const int &m2, - const int &n2, - const Vector3 &Rvna, - const int &itvna) const; - Make_Overlap_Table MOT; - Make_Vna_Table MVT; // set as public because in hamilt_linear, // we need to destroy the tables: SR,TR,NR // after ionic optimization is done. + Make_Overlap_Table MOT; + + // if we want to add table for descriptors, + // we should consider here -- mohan 2021-02-09 private: From 8ec11acb2a215c57ac3f18b700040e54c1cf737a Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 9 Feb 2021 14:51:08 +0800 Subject: [PATCH 089/233] update format for gamma_vlocal --- .../source/src_global/global_function.cpp | 10 ++-- .../source/src_lcao/gint_gamma_vl.cpp | 50 ++++++++++++++++--- 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/ABACUS.develop/source/src_global/global_function.cpp b/ABACUS.develop/source/src_global/global_function.cpp index ea9b70a865..63e0fa6f8d 100644 --- a/ABACUS.develop/source/src_global/global_function.cpp +++ b/ABACUS.develop/source/src_global/global_function.cpp @@ -23,7 +23,7 @@ using namespace std; //========================================================== void TITLE(const string &class_function_name) { - return;//no output +// return;//no output cout<<" ==> "< "< "< "< "< "<grid_index, delta_r, phi, mt, dr, distance, pointer, ylma, colidx, block_iw, bsize, psir_ylm, cal_flag); - cal_psir_ylm(size, grid_index_thread, delta_r, phi, mt, dr, distance, pointer, ylma, colidx, block_iw, bsize, psir_ylm, cal_flag); - //cal_psir_ylm(size, this->grid_index, delta_r, phi, mt, dr, distance, pointer, ylma, colidx, block_iw, bsize, psir_ylm, i, j, k); + //cal_psir_ylm(size, this->grid_index, delta_r, phi, mt, dr, + // distance, pointer, ylma, colidx, block_iw, bsize, psir_ylm, cal_flag); + cal_psir_ylm(size, grid_index_thread, delta_r, phi, mt, dr, + distance, pointer, ylma, colidx, block_iw, bsize, psir_ylm, cal_flag); + //cal_psir_ylm(size, this->grid_index, delta_r, phi, mt, dr, + // distance, pointer, ylma, colidx, block_iw, bsize, psir_ylm, i, j, k); //timer::tick("Gint_Gamma","cal_vlocal_psir",'J'); //OUT(ofs_running, "psir_ylm was calculated"); //timer::tick("Gint_Gamma","cal_meshball_vlocal",'J'); - //cal_meshball_vlocal(size, LD_pool, block_iw, bsize, colidx, vldr3, psir_ylm, psir_vlbr3, vindex, lgd_now, GridVlocal); - cal_meshball_vlocal(size, LD_pool, block_iw, bsize, colidx, cal_flag, vldr3, psir_ylm, psir_vlbr3, vindex, lgd_now, GridVlocal_thread); + //cal_meshball_vlocal(size, LD_pool, block_iw, bsize, colidx, + // vldr3, psir_ylm, psir_vlbr3, vindex, lgd_now, GridVlocal); + cal_meshball_vlocal(size, LD_pool, block_iw, bsize, colidx, cal_flag, + vldr3, psir_ylm, psir_vlbr3, vindex, lgd_now, GridVlocal_thread); //timer::tick("Gint_Gamma","cal_meshball_vlocal",'J'); //OUT(ofs_running, "GridVlocal was calculated"); }// k @@ -526,8 +540,12 @@ void Gint_Gamma::gamma_vlocal(void) // Peize Lin update OpenMP 2020.09.27 #pragma omp critical(cal_vl) { for (int i=0; i Date: Tue, 9 Feb 2021 15:38:54 +0800 Subject: [PATCH 090/233] fix the bug, now the code can run for gamma_only using LCAO --- ABACUS.develop/source/Makefile.Objects | 13 - .../source/src_global/global_function.cpp | 6 +- .../source/src_lcao/local_orbital_elec.cpp | 5 +- .../source/src_parallel/subgrid_oper.cpp | 440 ++++++++++++++++++ .../source/src_parallel/subgrid_oper.h | 4 + 5 files changed, 449 insertions(+), 19 deletions(-) diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 2209c81af7..f5b5ea28bd 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -108,7 +108,6 @@ sltk_atom_input.o\ orbital_information_0.o\ make_gaunt_table.o\ make_overlap_table.o\ -make_vna_table.o\ use_overlap_table.o\ use_overlap_matrix.o\ use_hamilt_matrix.o\ @@ -119,36 +118,24 @@ grid_meshcell.o\ grid_bigcell.o\ grid_meshball.o\ grid_integral.o\ -gint_speed.o\ -gint_speed2.o\ -gint_speed_rho.o\ gint_gamma.o\ gint_gamma_fvl.o\ gint_gamma_vl.o\ gint_gamma_rho.o\ gint_gamma_mull.o\ gint_gamma_env.o \ -gint_gamma_fvna.o\ -gint_gamma_vna.o\ -gint_gamma_vna_d.o\ gint_k.o\ gint_k_init.o\ gint_k_vl.o\ gint_k_rho.o\ gint_k_fvl.o\ -gint_k_fvna.o\ -gint_k_vna.o\ -gint_k_vna_d.o\ grid_base.o\ grid_base_beta.o\ lcao_orbitals.o\ -lcao_vna.o\ -neutral_pot.o \ numerical_orbital.o\ numerical_orbital_lm.o\ numerical_nonlocal.o\ numerical_nonlocal_lm.o\ -numerical_vna_lm.o\ local_orbital_wfc.o\ local_orbital_elec.o\ local_orbital_ions.o\ diff --git a/ABACUS.develop/source/src_global/global_function.cpp b/ABACUS.develop/source/src_global/global_function.cpp index 63e0fa6f8d..df5062502c 100644 --- a/ABACUS.develop/source/src_global/global_function.cpp +++ b/ABACUS.develop/source/src_global/global_function.cpp @@ -23,7 +23,7 @@ using namespace std; //========================================================== void TITLE(const string &class_function_name) { -// return;//no output + return;//no output cout<<" ==> "< "< "<=0) + { + occupy[i] += 1; + } + } + + // reduce occupy and get the full occupations. +#ifdef __MPI + Parallel_Reduce::reduce_int_grid(occupy, NLOCAL); +#endif + + delete[] trace_aug_tot; + trace_aug_tot = new int[NLOCAL]; + ZEROS(trace_aug_tot,NLOCAL); + for(int i=0; i= 0) + { + occupy[iw] = 1; + } + } + + // reduce occupy and get the full occupations. +#ifdef __MPI + // mohan 2012-02-23 + if(ATOM_DISTRIBUTION==1) + { + ofs_running << " Because of the atom distribution." << endl; + ofs_running << " Don't reduce the trace_lo_tot here." << endl; + } + else + { + Parallel_Reduce::reduce_int_grid(occupy, NLOCAL); + } +#endif + + /* + for(int i=0; itotwfc = new double**[1]; + for(int is=0; is<1; ++is) + { + this->totwfc[is] = new double*[NBANDS]; + } + } + // for B field. + else + { + this->totwfc_B = new complex**[1]; + for(int is=0; is<1; ++is) + { + this->totwfc_B[is] = new complex*[NBANDS]; + } + } + this->allocate_totwfc=false; + return; + } + + assert(this->allocate_totwfc==false); + + static bool first_time=true; + if(first_time) + { +// LOWF.init_Cij(1); + first_time=false; + } + + + this->totwfc = new double**[1]; + for(int is=0; is<1; ++is) + { + this->totwfc[is] = new double*[NBANDS]; + for(int ib=0; ibtotwfc[is][ib] = new double[lgd]; + ZEROS(totwfc[is][ib], lgd); + + // mohan update 2012-02-10 + //if(DIAGO_TYPE!="cg") xiaohui modify 2013-09-02 + if(KS_SOLVER!="cg") //xiaohui add 2013-09-02 + { + for(int i=0; itotwfc[is][ib][i] = LOWF.WFC_GAMMA[CURRENT_SPIN][ib][i]; //mohan update 2012-02-07 + } + } + } + } + + allocate_totwfc = true; + } + + delete[] occupy; //mohan fix bug 2012-03-25 + + return; +} + + +void SubGrid_oper::dis_subwfc() +{ + TITLE("SubGrid_oper","dis_subwfc"); + +#ifdef __MPI + +// cout << " distribute the wave functions " << endl; + + //------------------------------------------ + // bcast the eigenvalues + //------------------------------------------ + for(int ik=0; ik= 0) + { + const int mu2 = this->trace_lo_tot[iw]; + + for(int ib=0; ibtotwfc[0][ib][mu2]; + }//ib + }//mu1>=0 + }//iw + }//i + else + { + int tag; + // receive trace_lo2 + tag = i * 10; + int* trace_lo2 = new int[NLOCAL]; + MPI_Recv(trace_lo2, NLOCAL, MPI_INT, i, tag, GRID_WORLD, &status); + +/* + ofs_running << " Proc " << i << endl; + for(int i=0; iusing_LAPACK(ik, wfc); } -/* -#ifdef __SELINV - //xiaohui modified 2013-03-23 - else if(DIAGO_TYPE=="selinv") //mohan add 2011-09 - { - Selinv SV; - // job=1: density matrix for charge density. - // job=2: density matrix for force. - // job=3: energy density matrix for force. - int job = 1; - SV.using_SELINV(ik, job, LM.Hloc, LM.Sloc); - } -#endif - else if(DIAGO_TYPE=="cg") - { - this->using_CG(ik, wfc); - } -*/ #ifdef __MPI - //else if(DIAGO_TYPE=="hpseps") xiaohui modify 2013-09-02 - else if(KS_SOLVER=="hpseps" || KS_SOLVER=="genelpa"|| KS_SOLVER=="scalapack_gvx") //yshen add 7/15/2016 + // yshen add 7/15/2016 + else if(KS_SOLVER=="hpseps" || KS_SOLVER=="genelpa"|| KS_SOLVER=="scalapack_gvx") { this->using_HPSEPS_double(ik, wfc, wfc_2d); } #endif else { - //cout << " Diago_LCAO_Matrix, diago_type = " << DIAGO_TYPE << endl; xiaohui modify 2013-09-02 - cout << " Diago_LCAO_Matrix, diago_type = " << KS_SOLVER << endl; //xiaohui add 2013-09-02 - //WARNING_QUIT("Diago_LCAO_Matrix::init","Check DIAGO_TYPE."); xiaohui modify 2013-09-02 - WARNING_QUIT("Diago_LCAO_Matrix::init","Check KS_SOLVER."); //xiaohui add 2013-09-02 + cout << " Diago_LCAO_Matrix, diago_type = " << KS_SOLVER << endl; + WARNING_QUIT("Diago_LCAO_Matrix::init","Check KS_SOLVER."); } time_t time_end = time(NULL); -// ofs_running << " End Time : " << ctime(&time_end); -// ofs_running << " FINAL Time : " << difftime(time_end, time_start) << " (SEC)" << endl; OUT_TIME("diago(double)",time_start, time_end); - /* - ofs_running << "\n Output c:" << endl; - for(int i=0; i 1.0e-5 ) - { - ofs_running << setw(20) << c[i][j]; - } - else - { - ofs_running << setw(20) << "0"; - } - } - ofs_running << endl; - } - */ - timer::tick("Diago_LCAO_Matrix","solve_double_matrix",'F'); return; } @@ -222,6 +161,7 @@ void Diago_LCAO_Matrix::using_LAPACK_complex(const int &ik, complex **wf hm.cdiaghg(NLOCAL, NBANDS, Htmp, Stmp, NLOCAL, en, hvec); if(NSPIN!=4) + { for(int ib=0; ib **wf LOWF.WFC_K[ik][ib][iw] = hvec(iw,ib); } } + } else + { for(int ib=0; ib **wf LOWF.WFC_K[ik][ib][iw + NLOCAL / NPOL] = hvec(iw * NPOL + 1, ib); } } + } //cout << "\n Energy for k=" << ik << endl; for(int ib=0; ibWFC_init = new complex**[kv.nks]; @@ -274,7 +277,11 @@ void Local_Orbital_Elec::scf(const int &istep) break; } - if(INPUT.dft_plus_u) dftu.cal_slater_UJ(istep, iter); // Calculate U and J if Yukawa potential is used + if(INPUT.dft_plus_u) + { + dftu.cal_slater_UJ(istep, iter); // Calculate U and J if Yukawa potential is used + } + // (1) calculate the bands. cal_bands(istep); @@ -287,7 +294,7 @@ void Local_Orbital_Elec::scf(const int &istep) // only deal with charge density after both wavefunctions. // are calculated. //----------------------------------------------------------- - if(GAMMA_ONLY_LOCAL && NSPIN == 2 && CURRENT_SPIN == 0)continue; + if(GAMMA_ONLY_LOCAL && NSPIN == 2 && CURRENT_SPIN == 0) continue; if(conv_elec) @@ -324,23 +331,6 @@ void Local_Orbital_Elec::scf(const int &istep) } } -/* if(istep==0) - { - for (int ib=0; ib < 3; ib++) - { - wf.wg(0,ib) = 2.0; - } - wf.wg(0,3) = 1.75; - wf.wg(0,4) = 0.25; - } - for (int ik = 0; ik < kv.nks; ik++) - { - for (int ib = 0; ib < NBANDS; ib++) - { - cout << "wf.wg(ik, ib): " << wf.wg(ik, ib) << endl; - } - } -*/ for(int ik=0; ikLOWF.init_Cij( 0 ); // check the orthogonality of local orbital. - //CHR.sum_band(); use local orbital in plane wave basis to calculate bands. + // this->LOWF.init_Cij( 0 ); // check the orthogonality of local orbital. + // CHR.sum_band(); use local orbital in plane wave basis to calculate bands. // but must has evc first! //------------------------------------------------------------------------- @@ -401,8 +399,12 @@ void Local_Orbital_Elec::scf(const int &istep) // Peize Lin add 2020.04.04 if(restart.info_save.save_charge) + { for(int is=0; is*** WFC_init; + this->WFC_init = new complex**[kv.nks]; for(int ik=0; ikLOWF.c, - NBANDS, // row of op( Cij ), if 'T' or 'C', in fact this means the column number - wf.wanf2[0], - NLOCAL, // row of op( wf.wanf2[0] ) - ZERO, // see formula - wf.evc[0], - NBANDS // first dimension of evc - ); - } - else - { - wf.evc[0] = this->LOWF.c * wf.wanf2[0]; - } - */ - - clock_t finish_nscf=clock(); - const double duration = static_cast(finish_nscf - start_nscf) / CLOCKS_PER_SEC; - - - //ofs_running << setw(8) << ik+1 << setw(15) << duration << endl; - -// ofs_running << " TIME FOR K=" << ik << ": " << duration << endl; } - // delete at last time. - /*LiuXh modify 2019-07-15 - if(!GAMMA_ONLY_LOCAL) - { - UHM.GK.destroy_pvpR(); - } - LiuXh modify 2019-07-15*/ + // LiuXh modify 2019-07-15*/ if(!GAMMA_ONLY_LOCAL) { if(!ParaO.out_hsR) diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.h b/ABACUS.develop/source/src_lcao/local_orbital_elec.h index f66b42bfa7..432cfc1281 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.h +++ b/ABACUS.develop/source/src_lcao/local_orbital_elec.h @@ -16,7 +16,9 @@ class Local_Orbital_Elec: private Threshold_Elec static int iter; static double avg_iter; + complex*** WFC_init; + protected: static int istep; diff --git a/ABACUS.develop/source/src_lcao/wf_local.h b/ABACUS.develop/source/src_lcao/wf_local.h index 07bb3ce0d6..c19a434f78 100644 --- a/ABACUS.develop/source/src_lcao/wf_local.h +++ b/ABACUS.develop/source/src_lcao/wf_local.h @@ -3,25 +3,20 @@ #include "../src_pw/tools.h" +// mohan add 2010-09-09 namespace WF_Local { - // mohan add 2010-09-09 void write_lowf(const string &name, double** ctot); void write_lowf_complex(const string &name, complex** ctot, const int &ik); - // mohan add 2010-09-10 void distri_lowf(double** ctot, double **c); void distri_lowf_complex(complex** ctot, complex **cc); - // mohan add 2010-09-24 void distri_lowf_aug(double** ctot, double **c_aug); - // mohan add 2012-01-09 void distri_lowf_aug_complex(complex** ctot, complex **c_aug); - // mohan add 2010-09-10 int read_lowf(double **c); - // mohan add 2012-03-04 int read_lowf_complex(complex **c, const int &ik); } From 02a9bb00cae3625dea650620fa9fe55e2f51b4b7 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 9 Feb 2021 17:03:59 +0800 Subject: [PATCH 092/233] add LCAO_cbands_gamma, LCAO_cbands_k, and LCAO_evolve three classes to perform band structure calcualtions for gamma, for k, and tddft, respectively. --- ABACUS.develop/source/Makefile.Objects | 3 + .../source/src_lcao/LCAO_cbands_gamma.cpp | 107 ++++++++ .../source/src_lcao/LCAO_cbands_gamma.h | 33 +++ .../source/src_lcao/LCAO_cbands_k.cpp | 132 ++++++++++ .../source/src_lcao/LCAO_cbands_k.h | 33 +++ .../source/src_lcao/LCAO_evolve.cpp | 135 ++++++++++ ABACUS.develop/source/src_lcao/LCAO_evolve.h | 31 +++ .../source/src_lcao/local_orbital_elec.cpp | 243 +++--------------- .../source/src_lcao/local_orbital_elec.h | 1 - 9 files changed, 511 insertions(+), 207 deletions(-) create mode 100644 ABACUS.develop/source/src_lcao/LCAO_cbands_gamma.cpp create mode 100644 ABACUS.develop/source/src_lcao/LCAO_cbands_gamma.h create mode 100644 ABACUS.develop/source/src_lcao/LCAO_cbands_k.cpp create mode 100644 ABACUS.develop/source/src_lcao/LCAO_cbands_k.h create mode 100644 ABACUS.develop/source/src_lcao/LCAO_evolve.cpp create mode 100644 ABACUS.develop/source/src_lcao/LCAO_evolve.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index f5b5ea28bd..53dfb4b2bf 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -138,6 +138,9 @@ numerical_nonlocal.o\ numerical_nonlocal_lm.o\ local_orbital_wfc.o\ local_orbital_elec.o\ +LCAO_cbands_k.o\ +LCAO_cbands_gamma.o\ +LCAO_evolve.o\ local_orbital_ions.o\ local_orbital_charge.o\ record_adj.o\ diff --git a/ABACUS.develop/source/src_lcao/LCAO_cbands_gamma.cpp b/ABACUS.develop/source/src_lcao/LCAO_cbands_gamma.cpp new file mode 100644 index 0000000000..562d8c6ff6 --- /dev/null +++ b/ABACUS.develop/source/src_lcao/LCAO_cbands_gamma.cpp @@ -0,0 +1,107 @@ +#include "LCAO_cbands_gamma.h" +#include "local_orbital_elec.h" +#include "diago_lcao_matrix.h" +#include "src_pw/global.h" +#include "src_pw/symmetry_rho.h" +#include "evolve_lcao_matrix.h" +#include "dftu.h" + + +LCAO_cbands_gamma::LCAO_cbands_gamma(){}; +LCAO_cbands_gamma::~LCAO_cbands_gamma(){}; + + +void LCAO_cbands_gamma::cal_bands(const int &istep, Use_Hamilt_Matrix &uhm) +{ + TITLE("LCAO_cbands_gamma","cal_bands"); + timer::tick("LCAO_cband_gamma","cal_bands",'E'); + + assert(NSPIN == kv.nks); + + // pool parallization in future -- mohan note 2021-02-09 + for(int ik=0; ik for a new spin. + //-------------------------------------------- + if(CURRENT_SPIN == uhm.GK.get_spin() ) + { + //ofs_running << " Same spin, same vlocal integration." << endl; + } + else + { + //ofs_running << " (spin change)" << endl; + uhm.GK.reset_spin( CURRENT_SPIN ); + + // if you change the place of the following code, + // rememeber to delete the #include + if(VL_IN_H) + { + // vlocal = Vh[rho] + Vxc[rho] + Vl(pseudo) + uhm.GK.cal_vlocal_k(pot.vrs1,GridT); + // added by zhengdy-soc, for non-collinear case + // integral 4 times, is there any method to simplify? + if(NSPIN==4) + { + for(int is=1;is<4;is++) + { + for(int ir=0; ir ***wfc) +{ + TITLE("LCAO_evolve","eveolve_psi"); + timer::tick("LCAO_evolve","evolve_psi",'E'); + + int start_spin = -1; + uhm.GK.reset_spin(start_spin); + uhm.GK.allocate_pvpR(); + + // pool parallization in future -- mohan note 2021-02-09 + for(int ik=0; ik for a new spin. + //-------------------------------------------- + if(CURRENT_SPIN == uhm.GK.get_spin() ) + { + //ofs_running << " Same spin, same vlocal integration." << endl; + } + else + { + //ofs_running << " (spin change)" << endl; + uhm.GK.reset_spin( CURRENT_SPIN ); + + if(VL_IN_H) + { + // vlocal = Vh[rho] + Vxc[rho] + Vl(pseudo) + uhm.GK.cal_vlocal_k(pot.vrs1,GridT); + // added by zhengdy-soc, for non-collinear case + // integral 4 times, is there any method to simplify? + if(NSPIN==4) + { + for(int is=1;is<4;is++) + { + for(int ir=0; ir= 1) diago = false; + if(diago) + { + timer::tick("Efficience","diago_k"); + Diago_LCAO_Matrix DLM; + DLM.solve_complex_matrix(ik, LOWF.WFC_K[ik], LOC.wfc_dm_2d.wfc_k[ik]); + timer::tick("Efficience","diago_k"); + } + else + { + timer::tick("Efficience","evolve_k"); + Evolve_LCAO_Matrix ELM; + ELM.evolve_complex_matrix(ik, LOWF.WFC_K[ik], wfc[ik]); + timer::tick("Efficience","evolve_k"); + } + } // end k + + // LiuXh modify 2019-07-15*/ + if(!ParaO.out_hsR) + { + uhm.GK.destroy_pvpR(); + } + + timer::tick("LCAO_evolve","evolve_psi",'E'); + return; +} + diff --git a/ABACUS.develop/source/src_lcao/LCAO_evolve.h b/ABACUS.develop/source/src_lcao/LCAO_evolve.h new file mode 100644 index 0000000000..c3a740f6e7 --- /dev/null +++ b/ABACUS.develop/source/src_lcao/LCAO_evolve.h @@ -0,0 +1,31 @@ +#ifndef LCAO_EVOLVE_H +#define LCAO_EVOLVE_H + +#include "../src_pw/tools.h" +#include "use_hamilt_matrix.h" + +//----------------------------------------------------------- +// mohan add 2021-02-09 +// This class is used to evolve the electronic wave functions +// in TDDFT in terms of the multiple k points +// k is the index for the points in the first Brillouin zone +//----------------------------------------------------------- + +class LCAO_evolve +{ + + friend class Local_Orbital_Elec; + + public: + + LCAO_evolve(); + ~LCAO_evolve(); + + private: + + static void evolve_psi(const int &istep, Use_Hamilt_Matrix &uhm, complex*** wfc); + + +}; + +#endif diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp index 8bac663af8..e5b0a04178 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp @@ -10,6 +10,9 @@ #include "../src_pw/berryphase.h" #include "../src_pw/toWannier90.h" #include "dftu.h" //Quxin add for DFT+U on 202011029 +#include "LCAO_cbands_k.h" +#include "LCAO_cbands_gamma.h" +#include "LCAO_evolve.h" int Local_Orbital_Elec::iter = 0; double Local_Orbital_Elec::avg_iter = 0.0; @@ -283,7 +286,23 @@ void Local_Orbital_Elec::scf(const int &istep) } // (1) calculate the bands. - cal_bands(istep); + // mohan add 2021-02-09 + if(GAMMA_ONLY_LOCAL) + { + LCAO_cbands_gamma::cal_bands(istep, UHM); + } + else + { + if(tddft) + { + LCAO_evolve::evolve_psi(istep, UHM, this->WFC_init); + } + else + { + LCAO_cbands_k::cal_bands(istep, UHM); + } + } + // for(int ib=0; ibWFC_init); + } + else + { + LCAO_cbands_k::cal_bands(istep, UHM); + } + } + time_t time_finish=std::time(NULL); OUT_TIME("cal_bands",time_start, time_finish); @@ -683,210 +718,6 @@ void Local_Orbital_Elec::nscf(void) return; } -#include "../src_parallel/subgrid_oper.h" -void Local_Orbital_Elec::cal_bands(const int &istep) -{ - TITLE("Local_Orbital_Elec","cal_bands"); - timer::tick("Local_Orbital_Elec","cal_bands",'E'); - - if(GAMMA_ONLY_LOCAL) - { - assert(NSPIN == kv.nks); - } - else - { - int start_spin = -1; - UHM.GK.reset_spin(start_spin); - UHM.GK.allocate_pvpR(); - } - - - // pool parallization in future -- mohan note 2021-02-09 - for(int ik=0; ik for a new spin. - //-------------------------------------------- - if(!GAMMA_ONLY_LOCAL) - { - if(CURRENT_SPIN == UHM.GK.get_spin() ) - { - //ofs_running << " Same spin, same vlocal integration." << endl; - } - else - { - //ofs_running << " (spin change)" << endl; - UHM.GK.reset_spin( CURRENT_SPIN ); - - // if you change the place of the following code, - // rememeber to delete the #include - if(VL_IN_H) - { - // vlocal = Vh[rho] + Vxc[rho] + Vl(pseudo) - UHM.GK.cal_vlocal_k(pot.vrs1,GridT); - // added by zhengdy-soc, for non-collinear case - // integral 4 times, is there any method to simplify? - if(NSPIN==4) - { - for(int is=1;is<4;is++) - { - for(int ir=0; ir= 1) diago = false; - if(diago) - { - timer::tick("Efficience","diago_k"); - Diago_LCAO_Matrix DLM; - DLM.solve_complex_matrix(ik, LOWF.WFC_K[ik], LOC.wfc_dm_2d.wfc_k[ik]); - timer::tick("Efficience","diago_k"); - } - else - { - timer::tick("Efficience","evolve_k"); - Evolve_LCAO_Matrix ELM; - ELM.evolve_complex_matrix(ik, LOWF.WFC_K[ik], WFC_init[ik]); - timer::tick("Efficience","evolve_k"); - } - timer::tick("Efficience","each_k"); - } - } - - // LiuXh modify 2019-07-15*/ - if(!GAMMA_ONLY_LOCAL) - { - if(!ParaO.out_hsR) - { - UHM.GK.destroy_pvpR(); - } - } - timer::tick("Local_Orbital_Elec","cal_bands",'E'); - return; -} void Local_Orbital_Elec::init_mixstep_final_scf(void) { diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.h b/ABACUS.develop/source/src_lcao/local_orbital_elec.h index 432cfc1281..7d8038755e 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.h +++ b/ABACUS.develop/source/src_lcao/local_orbital_elec.h @@ -23,7 +23,6 @@ class Local_Orbital_Elec: private Threshold_Elec static int istep; private: - void cal_bands(const int &istep); void init_mixstep_final_scf(void); From b9226b27c425ae75af6868c4a1010df282af8b3c Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 10 Feb 2021 09:43:15 +0800 Subject: [PATCH 093/233] separate out ELEC_scf and ELEC_nscf from local_orbital_elec, move electrons-related part of codes from local_orbital_ions to local_orbital_elec --- ABACUS.develop/source/Makefile | 4 +- ABACUS.develop/source/Makefile.Objects | 2 + ABACUS.develop/source/Makefile.system | 10 +- ABACUS.develop/source/Makefile.vars | 38 +- ABACUS.develop/source/src_lcao/ELEC_nscf.cpp | 95 ++ ABACUS.develop/source/src_lcao/ELEC_nscf.h | 32 + ABACUS.develop/source/src_lcao/ELEC_scf.cpp | 605 +++++++++++++ ABACUS.develop/source/src_lcao/ELEC_scf.h | 38 + .../source/src_lcao/LCAO_cbands_gamma.h | 3 +- .../source/src_lcao/LCAO_cbands_k.h | 3 +- .../source/src_lcao/LCAO_evolve.cpp | 2 +- ABACUS.develop/source/src_lcao/LCAO_evolve.h | 2 +- ABACUS.develop/source/src_lcao/hs_matrix.cpp | 10 +- ABACUS.develop/source/src_lcao/hs_matrix.h | 6 +- .../source/src_lcao/local_orbital_elec.cpp | 821 ++++-------------- .../source/src_lcao/local_orbital_elec.h | 24 +- .../source/src_lcao/local_orbital_ions.cpp | 205 +---- .../source/src_lcao/local_orbital_ions.h | 3 - 18 files changed, 1017 insertions(+), 886 deletions(-) create mode 100644 ABACUS.develop/source/src_lcao/ELEC_nscf.cpp create mode 100644 ABACUS.develop/source/src_lcao/ELEC_nscf.h create mode 100644 ABACUS.develop/source/src_lcao/ELEC_scf.cpp create mode 100644 ABACUS.develop/source/src_lcao/ELEC_scf.h diff --git a/ABACUS.develop/source/Makefile b/ABACUS.develop/source/Makefile index 8709e5a3c4..310566880e 100644 --- a/ABACUS.develop/source/Makefile +++ b/ABACUS.develop/source/Makefile @@ -21,7 +21,9 @@ HONG_SER_SELINV = -D__FP ${HONG_FFTW} -D__SELINV HONG_GDB = -g -D__FP ${HONG_FFTW} #(2)mpi HONG_MPI = -D__FP ${HONG_FFTW} -D__MPI -HONG_MPI_SELINV = -D__FP ${HONG_FFTW} -D__MPI -D__SELINV -DMETIS -DMKL_ILP64 -DEXX_DM=3 -DEXX_H_COMM=2 -DTEST_LIBXC=0 -DTEST_EXX_LCAO=0 -DTEST_EXX_RADIAL=1 -DUSE_CEREAL_SERIALIZATION +# mohan comment out 2021-02-06, add -DTEST_LIBXC=0 if you want to use LIBXC +#HONG_MPI_SELINV = -D__FP ${HONG_FFTW} -D__MPI -D__SELINV -DMETIS -DMKL_ILP64 -DEXX_DM=3 -DEXX_H_COMM=2 -DTEST_LIBXC=0 -DTEST_EXX_LCAO=0 -DTEST_EXX_RADIAL=1 -DUSE_CEREAL_SERIALIZATION +HONG_MPI_SELINV = -D__FP ${HONG_FFTW} -D__MPI -D__SELINV -DMETIS -DMKL_ILP64 -DEXX_DM=3 -DEXX_H_COMM=2 -DTEST_EXX_LCAO=0 -DTEST_EXX_RADIAL=1 -DUSE_CEREAL_SERIALIZATION #(3)memory HONG_MEM = ${HONG_FFTW} -D__FP -D_MCD_CHECK -DWIN32 -DMCD_VERBOSE diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 53dfb4b2bf..c54d37fb57 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -141,6 +141,8 @@ local_orbital_elec.o\ LCAO_cbands_k.o\ LCAO_cbands_gamma.o\ LCAO_evolve.o\ +ELEC_scf.o\ +ELEC_nscf.o\ local_orbital_ions.o\ local_orbital_charge.o\ record_adj.o\ diff --git a/ABACUS.develop/source/Makefile.system b/ABACUS.develop/source/Makefile.system index 47af841663..80237901c1 100644 --- a/ABACUS.develop/source/Makefile.system +++ b/ABACUS.develop/source/Makefile.system @@ -20,7 +20,9 @@ FFTW_LIB_DIR = ${FFTW_DIR}/lib FFTW_LIB = -L${FFTW_LIB_DIR} -lfftw3 -Wl,-rpath=${FFTW_LIB_DIR} ELPA_LIB_DIR = ${ELPA_DIR}/lib -ELPA_LIB = -L${ELPA_LIB_DIR} -lelpa_openmp -Wl,-rpath=${ELPA_LIB_DIR} +# comment out by mohan 2021-02-06 +#ELPA_LIB = -L${ELPA_LIB_DIR} -lelpa_openmp -Wl,-rpath=${ELPA_LIB_DIR} +ELPA_LIB = -L${ELPA_LIB_DIR} -lelpa -Wl,-rpath=${ELPA_LIB_DIR} LIBXC_INCLUDE_DIR = ${LIBXC_DIR}/include LIBXC_LIB_DIR = ${LIBXC_DIR}/lib @@ -31,8 +33,10 @@ CEREAL_INCLUDE_DIR = ${CEREAL_DIR}/include #========================== # LIBS and INCLUDES #========================== -LIBS = -lifcore -lm -lpthread ${LAPACK_LIB} ${FFTW_LIB} ${ELPA_LIB} ${LIBXC_LIB} -#LIBS = -liomp5 -lpthread -lm -ldl ${BOOST_LIB} ${LAPACK_LIB} ${FFTW_LIB} ${ELPA_LIB} ${LIBXC_LIB} +# comment out by mohan 2021-02-06 +#LIBS = -lifcore -lm -lpthread ${LAPACK_LIB} ${FFTW_LIB} ${ELPA_LIB} ${LIBXC_LIB} +LIBS = -lifcore -lm -lpthread ${LAPACK_LIB} ${FFTW_LIB} ${ELPA_LIB} +#LIBS = -liomp5 -lpthread -lm -ldl ${BOOST_LIB} ${LAPACK_LIB} ${FFTW_LIB} ${LPA_LIB} ${LIBXC_LIB} INCLUDES = -I. -Icommands -I${BOOST_INCLUDE_DIR} -I${LAPACK_INCLUDE_DIR} -I${FFTW_INCLUDE_DIR} -I${LIBXC_INCLUDE_DIR} -I${CEREAL_INCLUDE_DIR} diff --git a/ABACUS.develop/source/Makefile.vars b/ABACUS.develop/source/Makefile.vars index a47860c013..7611bbdcbc 100644 --- a/ABACUS.develop/source/Makefile.vars +++ b/ABACUS.develop/source/Makefile.vars @@ -1,12 +1,34 @@ -FORTRAN = ifort +FORTRAN = ifort + CPLUSPLUS = icpc -CPLUSPLUS_MPI = mpiicpc -BOOST_DIR = /public/home/linpz/software/boost-1.74.0 -LAPACK_DIR = /public/software/compiler/intel/parallel_studio_xe_2019_update3/compilers_and_libraries_2019/linux/mkl/ -FFTW_DIR = /public/home/linpz/software/fftw-3.3.8 -ELPA_DIR = /public/home/linpz/software/elpa-2016.05.004-openmp -LIBXC_DIR = /public/home/linpz/software/libxc-5.0.0 -CEREAL_DIR = /public/home/linpz/software/cereal-master +#CPLUSPLUS = /public/intel2017/bin/icpc + +CPLUSPLUS_MPI = mpiicpc +#CPLUSPLUS_MPI = /public/intel2017/impi/2017.1.132/intel64/bin/mpiicpc + +LAPACK_DIR = $(MKLROOT) +#LAPACK_DIR = /public/intel2017/compilers_and_libraries_2017.1.132/linux/mkl +#LAPACK_DIR = $(MKLROOT) +#LAPACK_DIR = /public/intel2017/mkl + +FFTW_DIR = /home/mohan/1_Software/impi_fftw-3.3.8 +#FFTW_DIR = /home/qianrui/intelcompile/impi_fftw +#FFTW_DIR = /public/udata/xiaohui/software/fftw2 +#FFTW_DIR =/opt/fftw/3.3.6-p12/intel/2017.update4 +#FFTW_DIR = /public/fftw-3.3.8 + +BOOST_DIR = /home/mohan/1_Software/impi_boost-1.70.0 +#BOOST_DIR = /home/qianrui/intelcompile/impi_boost +#BOOST_DIR = /public/udata/xiaohui/software/boost_1_39_0 +#BOOST_DIR = /opt/boost/1.64.0 + +ELPA_DIR = /home/mohan/1_Software/impi_elpa-16.05.005 +#ELPA_DIR = /home/qianrui/intelcompile/impi_elpa +#ELPA_DIR = /public/udata/xiaohui/ELPA-2016.05.004 +#ELPA_DIR = /opt/elpa/intel_2017_update4 + +CEREAL_DIR = /home/mohan/1_Software/ABACUS_Github/cereal/cereal/ OBJ_DIR = obj NP = 10 + diff --git a/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp b/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp new file mode 100644 index 0000000000..e9f9b3afc2 --- /dev/null +++ b/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp @@ -0,0 +1,95 @@ +#include "ELEC_nscf.h" +#include "../src_pw/global.h" +#include "exx_abfs.h" +#include "exx_opt_orb.h" +#include "global_fp.h" +#include "LCAO_cbands_gamma.h" +#include "LCAO_cbands_k.h" +#include "../src_pw/berryphase.h" +#include "../src_pw/toWannier90.h" + +ELEC_nscf::ELEC_nscf(){} +ELEC_nscf::~ELEC_nscf(){} + +void ELEC_nscf::nscf(Use_Hamilt_Matrix &uhm) +{ + TITLE("ELEC_nscf","nscf"); + + cout << " NON-SELF CONSISTENT CALCULATIONS" << endl; + + time_t time_start= std::time(NULL); + + // Peize Lin add 2018-08-14 + switch(exx_lcao.info.hybrid_type) + { + case Exx_Global::Hybrid_Type::HF: + case Exx_Global::Hybrid_Type::PBE0: + case Exx_Global::Hybrid_Type::HSE: + exx_lcao.cal_exx_elec_nscf(); + break; + } + + // mohan add 2021-02-09 + // in local_orbital_ions, istep starts from 1, + // then when the istep is a variable of scf or nscf, + // istep becomes istep-1, this should be fixed in future + int istep=0; + if(GAMMA_ONLY_LOCAL) + { + LCAO_cbands_gamma::cal_bands(istep, uhm); + } + else + { + LCAO_cbands_k::cal_bands(istep, uhm); + } + + time_t time_finish=std::time(NULL); + OUT_TIME("cal_bands",time_start, time_finish); + + ofs_running << " end of band structure calculation " << endl; + ofs_running << " band eigenvalue in this processor (eV) :" << endl; + + for (int ik = 0; ik < kv.nks; ik++) + { + if (NSPIN==2) + { + if (ik==0) + { + ofs_running << " spin up :" << endl; + } + if (ik==( kv.nks / 2)) + { + ofs_running << " spin down :" << endl; + } + } + + ofs_running << " k-points" + << ik+1 << "(" << kv.nkstot << "): " + << kv.kvec_c[ik].x << " " << kv.kvec_c[ik].y << " " << kv.kvec_c[ik].z << endl; + + for (int ib = 0; ib < NBANDS; ib++) + { + ofs_running << " spin" << kv.isk[ik]+1 + << "final_state " << ib+1 << " " + << wf.ekb[ik][ib] * Ry_to_eV + << " " << wf.wg(ik, ib)*kv.nks << endl; + } + ofs_running << endl; + } + + // add by jingan in 2018.11.7 + if(CALCULATION == "nscf" && INPUT.towannier90) + { + toWannier90 myWannier(kv.nkstot,ucell.G); + myWannier.init_wannier(); + } + + // add by jingan + if (BERRY_PHASE && SYMMETRY == 0) + { + berryphase bp; + bp.Macroscopic_polarization(); + } + + return; +} diff --git a/ABACUS.develop/source/src_lcao/ELEC_nscf.h b/ABACUS.develop/source/src_lcao/ELEC_nscf.h new file mode 100644 index 0000000000..1d15313b72 --- /dev/null +++ b/ABACUS.develop/source/src_lcao/ELEC_nscf.h @@ -0,0 +1,32 @@ +#ifndef ELEC_NSCF_H +#define ELEC_NSCF_H + +#include "../src_pw/tools.h" +#include "use_hamilt_matrix.h" + +//----------------------------------------------------------- +// mohan add 2021-02-09 +// This class is used to run non-self-consistent calculations +// to solve the Kohn-Sham equation by reading in electron +// charge density +//----------------------------------------------------------- + +class ELEC_nscf +{ + + friend class Local_Orbital_Ions; + friend class Local_Orbital_Elec; + + public: + + ELEC_nscf(); + ~ELEC_nscf(); + + private: + + static void nscf(Use_Hamilt_Matrix &uhm); + + +}; + +#endif diff --git a/ABACUS.develop/source/src_lcao/ELEC_scf.cpp b/ABACUS.develop/source/src_lcao/ELEC_scf.cpp new file mode 100644 index 0000000000..e57e2e461a --- /dev/null +++ b/ABACUS.develop/source/src_lcao/ELEC_scf.cpp @@ -0,0 +1,605 @@ +#include "ELEC_scf.h" +#include "src_pw/global.h" +#include "src_pw/chi0_hilbert.h" +#include "src_pw/symmetry_rho.h" +#include "dftu.h" +#include "evolve_lcao_matrix.h" +#include "LCAO_cbands_k.h" +#include "LCAO_cbands_gamma.h" +#include "LCAO_evolve.h" +#include "update_input.h" + +ELEC_scf::ELEC_scf(){} +ELEC_scf::~ELEC_scf(){} + +int ELEC_scf::iter=0; + +void ELEC_scf::scf(const int &istep) +{ + TITLE("ELEC_scf","scf"); + timer::tick("ELEC_scf","scf",'D'); + + // (1) calculate ewald energy. + en.ewld = en.ewald(); + + // mohan add 2012-02-08 + set_ethr(); + + // the electron charge density should be symmetrized, + // here is the initialization + Symmetry_rho srho; + for(int is=0; isupdate_ethr(iter); + if(FINAL_SCF && iter==1) + { + init_mixstep_final_scf(); + //CHR.irstep=0; + //CHR.idstep=0; + //CHR.totstep=0; + } + + // mohan update 2012-06-05 + en.calculate_harris(1); + + // mohan move it outside 2011-01-13 + // first need to calculate the weight according to + // electrons number. + // mohan add iter > 1 on 2011-04-02 + // because the en.ekb has not value now. + // so the smearing can not be done. + if(iter>1)Occupy::calculate_weights(); + + if(wf.start_wfc == "file") + { + if(iter==1) + { + cout << " WAVEFUN -> CHARGE " << endl; + + // The occupation should be read in together. + // Occupy::calculate_weights(); //mohan add 2012-02-15 + + // calculate the density matrix using read in wave functions + // and the ncalculate the charge density on grid. + LOC.sum_bands(); + // calculate the local potential(rho) again. + // the grid integration will do in later grid integration. + + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // a puzzle remains here. + // if I don't renew potential, + // The dr2 is very small. + // OneElectron, Hartree and + // Exc energy are all correct + // except the band energy. + // + // solved by mohan 2010-09-10 + // there are there rho here: + // rho1: formed by read in orbitals. + // rho2: atomic rho, used to construct H + // rho3: generated by after diagonalize + // here converged because rho3 and rho1 + // are very close. + // so be careful here, make sure + // rho1 and rho2 are the same rho. + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + pot.v_of_rho(CHR.rho, en.ehart, en.etxc, en.vtxc, pot.vr); + en.delta_escf(); + if (vext == 0) + { + pot.set_vrs(); + } + else + { + pot.set_vrs_tddft(istep); + } + } + } + + // fuxiang add 2016-11-1 + // need reconstruction in near future -- mohan 2021-02-09 + // the initialization of wave functions should be moved to + // somewhere else + if(tddft==1 && iter == 1) + { + this->WFC_init = new complex**[kv.nks]; + for(int ik=0; ikWFC_init[ik] = new complex*[NBANDS]; + } + for(int ik=0; ikWFC_init[ik][ib] = new complex[NLOCAL]; + } + } + if(istep>=1) + { + for (int ik=0; ik(0.0,0.0); + } + } + } + } + } + + // calculate exact-exchange + switch(xcf.iexch_now) // Peize Lin add 2018-10-30 + { + case 5: case 6: case 9: + if( !exx_global.info.separate_loop ) + { + exx_lcao.cal_exx_elec(); + } + break; + } + + if(INPUT.dft_plus_u) + { + dftu.cal_slater_UJ(istep, iter); // Calculate U and J if Yukawa potential is used + } + + // (1) calculate the bands. + // mohan add 2021-02-09 + if(GAMMA_ONLY_LOCAL) + { + LCAO_cbands_gamma::cal_bands(istep, UHM); + } + else + { + if(tddft) + { + LCAO_evolve::evolve_psi(istep, UHM, this->WFC_init); + } + else + { + LCAO_cbands_k::cal_bands(istep, UHM); + } + } + + +// for(int ib=0; ibLOWF.init_Cij( 0 ); // check the orthogonality of local orbital. + // CHR.sum_band(); use local orbital in plane wave basis to calculate bands. + // but must has evc first! + //------------------------------------------------------------------------- + + // (7) calculate delta energy + en.deband = en.delta_e(); + + // (8) Mix charge density + CHR.mix_rho(dr2,0,DRHO2,iter,conv_elec); + + // Peize Lin add 2020.04.04 + if(restart.info_save.save_charge) + { + for(int is=0; is*** WFC_init; + + void init_mixstep_final_scf(void); + +}; + +#endif diff --git a/ABACUS.develop/source/src_lcao/LCAO_cbands_gamma.h b/ABACUS.develop/source/src_lcao/LCAO_cbands_gamma.h index 9492d34e92..84077efbcb 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_cbands_gamma.h +++ b/ABACUS.develop/source/src_lcao/LCAO_cbands_gamma.h @@ -15,7 +15,8 @@ class LCAO_cbands_gamma { - friend class Local_Orbital_Elec; + friend class ELEC_scf; + friend class ELEC_nscf; public: diff --git a/ABACUS.develop/source/src_lcao/LCAO_cbands_k.h b/ABACUS.develop/source/src_lcao/LCAO_cbands_k.h index 4298a89168..a4e968348b 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_cbands_k.h +++ b/ABACUS.develop/source/src_lcao/LCAO_cbands_k.h @@ -15,7 +15,8 @@ class LCAO_cbands_k { - friend class Local_Orbital_Elec; + friend class ELEC_scf; + friend class ELEC_nscf; public: diff --git a/ABACUS.develop/source/src_lcao/LCAO_evolve.cpp b/ABACUS.develop/source/src_lcao/LCAO_evolve.cpp index 9f08006a10..1255eaf551 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_evolve.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_evolve.cpp @@ -61,7 +61,7 @@ void LCAO_evolve::evolve_psi(const int &istep, Use_Hamilt_Matrix &uhm, complex *H, const complex *S, bool bit); void save_HSR_tr(const int current_spin); //LiuXh add 2019-07-15 - void save_HS_ccf(const int &iter, const int &Hnnz, const int *colptr_H, const int *rowind_H, - const double *nzval_H, const double *nzval_S, bool bit); +// mohan comment out 2021-02-10 +// void save_HS_ccf(const int &iter, const int &Hnnz, const int *colptr_H, const int *rowind_H, +// const double *nzval_H, const double *nzval_S, bool bit); + void saving_HS_complex(complex *Hloc, complex* Sloc, bool bit, const int &out_hs); //LiuXh, 2017-03-21 void save_HS_complex(complex *H, complex *S, bool bit); //LiuXh, 2017-03-21 } diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp index e5b0a04178..ada8360f24 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp @@ -2,730 +2,229 @@ #include "diago_lcao_matrix.h" #include "src_pw/global.h" #include "src_pw/symmetry_rho.h" -// mohan add on test 2010-01-13 -//#include "../src_develop/src_onscaling/on_tests.h" #include "update_input.h" #include "src_pw/chi0_hilbert.h" #include "evolve_lcao_matrix.h" -#include "../src_pw/berryphase.h" -#include "../src_pw/toWannier90.h" -#include "dftu.h" //Quxin add for DFT+U on 202011029 -#include "LCAO_cbands_k.h" +#include "dftu.h" +// +#include "sltk_atom_arrange.h" +#include "src_lcao/lcao_nnr.h" +#include "istate_charge.h" +#include "istate_envelope.h" +#include "ELEC_scf.h" +#include "ELEC_nscf.h" #include "LCAO_cbands_gamma.h" +#include "LCAO_cbands_k.h" #include "LCAO_evolve.h" +// +#include "src_lcao/exx_abfs.h" +#include "src_lcao/exx_opt_orb.h" -int Local_Orbital_Elec::iter = 0; -double Local_Orbital_Elec::avg_iter = 0.0; -int Local_Orbital_Elec::istep = 0; -void Local_Orbital_Elec::scf(const int &istep) +void Local_Orbital_Elec::solve_elec_stru(const int &istep) { - TITLE("Local_Orbtial_Elec","scf"); - timer::tick("Local_Orbital_Elec","scf",'D'); + TITLE("Local_Orbital_Elec","solve_elec_stru"); -// ofs_running << " Local_Orbital_Electrons_relaxation begin :"<set_matrix_grid_index(); + // density matrix extrapolation and prepare S,T,VNL matrices + this->before_solver(istep); + // do self-interaction calculations / nscf/ tddft, etc. + this->solver(istep); - // (1) calculate ewald energy. - en.ewld = en.ewald(); + return; +} - set_ethr(); //mohan add 2012-02-08 - Symmetry_rho srho; - for(int is=0; is1)//xiaohui modify 2015-02-01 { - if(CALCULATION=="scf") - { - ofs_running - << "\n LCAO ALGORITHM ------------- ELEC=" << setw(4) << iter - << "--------------------------------\n"; - - ofs_warning - << "\n LCAO ALGORITHM ------------- ELEC=" << setw(4) << iter - << "--------------------------------\n"; - } - else if(CALCULATION=="relax" || CALCULATION=="cell-relax") - { - ofs_running - << "\n LCAO ALGORITHM ------------- ION=" << setw(4) << istep+1 - << " ELEC=" << setw(4) << iter - << "--------------------------------\n"; - - ofs_warning - << "\n LCAO ALGORITHM ------------- ION=" << setw(4) << istep+1 - << " ELEC=" << setw(4) << iter - << "--------------------------------\n"; - } - else if(CALCULATION=="md") - { - ofs_running - << "\n LCAO ALGORITHM ------------- MD=" << setw(4) << istep+1 - << " ELEC=" << setw(4) << iter - << "--------------------------------\n"; - - ofs_warning - << "\n LCAO ALGORITHM ------------- MD=" << setw(4) << istep+1 - << " ELEC=" << setw(4) << iter - << "--------------------------------\n"; - } - - //time_t time_start, time_finish; - clock_t clock_start; - - string ufile = "CHANGE"; - Update_input UI; - UI.init(ufile); - - if(INPUT.dft_plus_u) dftu.iter_dftu = iter; - //time_start= std::time(NULL); - clock_start = std::clock(); - conv_elec = false;//mohan add 2008-05-25 - - // mohan add 2010-07-16 - // used for pulay mixing. - if(iter==1) CHR.set_new_e_iteration(true); - else CHR.set_new_e_iteration(false); - - // set converged threshold, - // automatically updated during self consistency, only for CG. - this->update_ethr(iter); - if(FINAL_SCF && iter==1) - { - init_mixstep_final_scf(); - //CHR.irstep=0; - //CHR.idstep=0; - //CHR.totstep=0; - } - - // mohan update 2012-06-05 - en.calculate_harris(1); - - // mohan move it outside 2011-01-13 - // first need to calculate the weight according to - // electrons number. - // mohan add iter > 1 on 2011-04-02 - // because the en.ekb has not value now. - // so the smearing can not be done. - if(iter>1)Occupy::calculate_weights(); - - if(wf.start_wfc == "file") - { - if(iter==1) - { - cout << " WAVEFUN -> CHARGE " << endl; - - // The occupation should be read in together. - // Occupy::calculate_weights(); //mohan add 2012-02-15 - - // calculate the density matrix using read in wave functions - // and the ncalculate the charge density on grid. - LOC.sum_bands(); - // calculate the local potential(rho) again. - // the grid integration will do in later grid integration. - - - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // a puzzle remains here. - // if I don't renew potential, - // The dr2 is very small. - // OneElectron, Hartree and - // Exc energy are all correct - // except the band energy. - // - // solved by mohan 2010-09-10 - // there are there rho here: - // rho1: formed by read in orbitals. - // rho2: atomic rho, used to construct H - // rho3: generated by after diagonalize - // here converged because rho3 and rho1 - // are very close. - // so be careful here, make sure - // rho1 and rho2 are the same rho. - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - pot.v_of_rho(CHR.rho, en.ehart, en.etxc, en.vtxc, pot.vr); - en.delta_escf(); - if (vext == 0) - { - pot.set_vrs(); - } - else - { - pot.set_vrs_tddft(istep); - } - } - } - - // fuxiang add 2016-11-1 - // need reconstruction in near future -- mohan 2021-02-09 - // the initialization of wave functions should be moved to - // somewhere else - if(tddft==1 && iter == 1) - { - this->WFC_init = new complex**[kv.nks]; - for(int ik=0; ikWFC_init[ik] = new complex*[NBANDS]; - } - for(int ik=0; ikWFC_init[ik][ib] = new complex[NLOCAL]; - } - } - if(istep>=1) - { - for (int ik=0; ik(0.0,0.0); - } - } - } - } - } - - // calculate exact-exchange - switch(xcf.iexch_now) // Peize Lin add 2018-10-30 - { - case 5: case 6: case 9: - if( !exx_global.info.separate_loop ) - { - exx_lcao.cal_exx_elec(); - } - break; - } - - if(INPUT.dft_plus_u) + for(int is=0; isWFC_init); - } - else - { - LCAO_cbands_k::cal_bands(istep, UHM); - } - } - - -// for(int ib=0; ibLOWF.init_Cij( 0 ); // check the orthogonality of local orbital. - // CHR.sum_band(); use local orbital in plane wave basis to calculate bands. - // but must has evc first! - //------------------------------------------------------------------------- - // (7) calculate delta energy - en.deband = en.delta_e(); + // (9) compute S, T, Vnl, Vna matrix. + UHM.set_ion(); - // (8) Mix charge density - CHR.mix_rho(dr2,0,DRHO2,iter,conv_elec); - - // Peize Lin add 2020.04.04 - if(restart.info_save.save_charge) - { - for(int is=0; isWFC_init = new complex**[kv.nks]; - for(int ik=0; ikWFC_init[ik] = new complex*[NBANDS]; - } - for(int ik=0; ikWFC_init[ik][ib] = new complex[NLOCAL]; + ELEC_scf es; + es.scf(istep-1); + + } } } - - for (int ik=0; ik(0.0,0.0); - } - } + ELEC_nscf::nscf(UHM); } - - switch(exx_lcao.info.hybrid_type) // Peize Lin add 2018-08-14 + else if (CALCULATION=="istate") { - case Exx_Global::Hybrid_Type::HF: - case Exx_Global::Hybrid_Type::PBE0: - case Exx_Global::Hybrid_Type::HSE: - exx_lcao.cal_exx_elec_nscf(); - break; + IState_Charge ISC; + ISC.begin(); } - - // mohan add 2021-02-09 - if(GAMMA_ONLY_LOCAL) + else if (CALCULATION=="ienvelope") { - LCAO_cbands_gamma::cal_bands(istep, UHM); + IState_Envelope IEP; + IEP.begin(); } else { - if(tddft) - { - LCAO_evolve::evolve_psi(istep, UHM, this->WFC_init); - } - else - { - LCAO_cbands_k::cal_bands(istep, UHM); - } + WARNING_QUIT("Local_Orbital_Ions::opt_ions","What's the CALCULATION."); } - time_t time_finish=std::time(NULL); - OUT_TIME("cal_bands",time_start, time_finish); - - ofs_running << " end of band structure calculation " << endl; - ofs_running << " band eigenvalue in this processor (eV) :" << endl; - - for (int ik = 0; ik < kv.nks; ik++) - { - if (NSPIN==2) - { - if (ik == 0) ofs_running << " spin up :" << endl; - if (ik == ( kv.nks / 2)) ofs_running << " spin down :" << endl; - } - //out.printV3(ofs_running, kv.kvec_c[ik]); - - ofs_running << " k-points" - << ik+1 << "(" << kv.nkstot << "): " - << kv.kvec_c[ik].x << " " << kv.kvec_c[ik].y << " " << kv.kvec_c[ik].z << endl; - - for (int ib = 0; ib < NBANDS; ib++) - { - ofs_running << " spin" << kv.isk[ik]+1 - << "final_state " << ib+1 << " " - << wf.ekb[ik][ib] * Ry_to_eV << " " << wf.wg(ik, ib)*kv.nks << endl; - // cout << " spin" << kv.isk[ik]+1 << "final_state " - // << ib+1 << " " << wf.ekb[ik][ib] * Ry_to_eV << " " << wf.wg(ik, ib)*kv.nks << endl; - } - ofs_running << endl; - } - - // add by jingan in 2018.11.7 - if(CALCULATION == "nscf" && INPUT.towannier90) - { - toWannier90 myWannier(kv.nkstot,ucell.G); - myWannier.init_wannier(); - } - - // add by jingan - if (BERRY_PHASE && SYMMETRY == 0) - { - berryphase bp; - bp.Macroscopic_polarization(); - } - return; } - -void Local_Orbital_Elec::init_mixstep_final_scf(void) -{ - TITLE("Local_Orbital_Elec","init_mixstep_final_scf"); - - CHR.irstep=0; - CHR.idstep=0; - CHR.totstep=0; - - return; -} diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.h b/ABACUS.develop/source/src_lcao/local_orbital_elec.h index 7d8038755e..cc4b662ff3 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.h +++ b/ABACUS.develop/source/src_lcao/local_orbital_elec.h @@ -2,29 +2,25 @@ #define LOCAL_ORBITAL_ELEC #include "../src_pw/tools.h" -#include "../src_pw/threshold_elec.h" -class Local_Orbital_Elec: private Threshold_Elec +class Local_Orbital_Elec { -public: + public: + Local_Orbital_Elec(){}; ~Local_Orbital_Elec(){}; - void scf(const int &istep); - void nscf(void); + // mohan add 2021-02-09 + void solve_elec_stru(const int &istep); - static int iter; - static double avg_iter; - - - complex*** WFC_init; + private: -protected: - static int istep; + // set matrix index and grid integral + void set_matrix_grid_index(void); -private: - void init_mixstep_final_scf(void); + void before_solver(const int &istep); + void solver(const int &istep); }; diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index 4cea73e6f8..048bb23cb6 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -1,21 +1,18 @@ #include "local_orbital_ions.h" #include "src_pw/global.h" #include "src_parallel/parallel_orbitals.h" -#include "src_lcao/sltk_atom_arrange.h" #include "src_external/src_pdiag/pdiag_double.h" -#include "src_lcao/lcao_nnr.h" -#include "src_lcao/force_lcao.h" -#include "src_lcao/stress_lcao.h" -#include "src_lcao/istate_charge.h" -#include "src_lcao/istate_envelope.h" +#include "lcao_nnr.h" +#include "force_lcao.h" +#include "stress_lcao.h" #include "src_global/global_function.h" -#include "src_lcao/hs_matrix.h" +#include "hs_matrix.h" #include "src_lcao/cal_r_overlap_R.h" #include "../src_ions/variable_cell.h" // mohan add 2021-02-01 -//#include "../src_siao/selinv.h" //mohan add 2012-05-13 - #include "src_lcao/exx_abfs.h" #include "src_lcao/exx_opt_orb.h" +#include "ELEC_scf.h" +#include "src_lcao/sltk_atom_arrange.h" Local_Orbital_Ions::Local_Orbital_Ions() {} @@ -40,7 +37,7 @@ void Local_Orbital_Ions::opt_ions(void) <istep); - // (4) set the augmented orbitals index. - // after ParaO and GridT, - // this information is used to calculate - // the force. - LOWF.set_trace_aug(GridT); - // (5) init density kernel and wave functions. - LOC.allocate_dm_wfc(GridT); - - //====================================== - // do the charge extrapolation before - // the density matrix is regenerated. - // mohan add 2011-04-08 - // because once atoms are moving out of this processor, - // the density matrix will not map the new atomic configuration, - //====================================== - // THIS IS A BUG, BECAUSE THE INDEX GridT.trace_lo - // HAS BEEN REGENERATED, SO WE NEED TO - // REALLOCATE DENSITY MATRIX FIRST, THEN READ IN DENSITY MATRIX, - // AND USE DENSITY MATRIX TO DO RHO CALCULATION.-- mohan 2013-03-31 - //====================================== - if(pot.extra_pot=="dm" && istep>1)//xiaohui modify 2015-02-01 - { - for(int is=0; isforce_stress(); stop = this->force_stress(istep, force_step, stress_step); } time_t fend = time(NULL); + //xiaohui add 2014-07-07, for second-order extrapolation iat=0; if(FORCE || CALCULATION=="md" ) @@ -383,7 +220,6 @@ void Local_Orbital_Ions::opt_ions(void) } ///*LiuXh modify, 20180626 - //if(FORCE || CALCULATION=="md" ) if(CALCULATION=="md" ) { //xiaohui add CE.istep = istep 2014-07-07 @@ -392,7 +228,6 @@ void Local_Orbital_Ions::opt_ions(void) // charge extrapolation if istep>0. CE.extrapolate_charge(); - //if(pot.extra_pot==4) if(pot.extra_pot=="dm")//xiaohui modify 2015-02-01 { // done after grid technique. @@ -414,7 +249,7 @@ void Local_Orbital_Ions::opt_ions(void) cout << setiosflags(ios::scientific) << " " << setw(7) << ss.str() - << setw(5) << LOE.iter + << setw(5) << ELEC_scf::iter << setw(18) << setprecision(6) << en.etot * Ry_to_eV; cout << setprecision(2) << setiosflags(ios::scientific) @@ -427,12 +262,6 @@ void Local_Orbital_Ions::opt_ions(void) << setprecision(2) << setw(10) << etime_min + ftime_min; cout << endl; } - //xiaohui modifed 2013-07-22, adding "//" before ... - //if(DIAGO_TYPE=="selinv") - //{ - // cout << " number of selected inversion: " << Selinv::niter_ion << endl; - // Selinv::niter_ion = 0; - //} //#ifdef __MPI //2015-09-06, xiaohui //2015-05-07, 2015-10-01 @@ -767,7 +596,9 @@ void Local_Orbital_Ions::final_scf(void) { vdwd3.energy(); } - LOE.scf(0); + + ELEC_scf es; + es.scf(0); if(CALCULATION=="scf" || CALCULATION=="relax") { diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.h b/ABACUS.develop/source/src_lcao/local_orbital_ions.h index 978deaac7f..ddb957bedf 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.h +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.h @@ -4,10 +4,7 @@ #include "local_orbital_elec.h" #include "../src_ions/ions_move_methods.h" #include "../src_pw/charge_extra.h" -//#include "../src_develop/src_md/md.h" -//2014-06-06, xiaohui #include "../src_pw/md.h" -//added by daye 2014/6/19 #include "../src_pw/mdNVT.h" #include "../src_pw/mdNVE.h" #include "../src_ions/lattice_change_methods.h" From fb4e8dc347cfd3bf6e524e02f985fe1fa93e1f6b Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 10 Feb 2021 10:06:34 +0800 Subject: [PATCH 094/233] move LCAO_ files to ELEC_ files --- ABACUS.develop/source/Makefile.Objects | 8 ++--- .../update_input.cpp => input_update.cpp} | 18 +++++----- .../update_input.h => input_update.h} | 0 ...cbands_gamma.cpp => ELEC_cbands_gamma.cpp} | 14 ++++---- ...CAO_cbands_gamma.h => ELEC_cbands_gamma.h} | 10 +++--- .../{LCAO_cbands_k.cpp => ELEC_cbands_k.cpp} | 14 ++++---- .../{LCAO_cbands_k.h => ELEC_cbands_k.h} | 10 +++--- .../{LCAO_evolve.cpp => ELEC_evolve.cpp} | 36 +++++++++---------- .../src_lcao/{LCAO_evolve.h => ELEC_evolve.h} | 10 +++--- ABACUS.develop/source/src_lcao/ELEC_nscf.cpp | 8 ++--- ABACUS.develop/source/src_lcao/ELEC_scf.cpp | 14 ++++---- .../source/src_lcao/local_orbital_elec.cpp | 8 ++--- 12 files changed, 73 insertions(+), 77 deletions(-) rename ABACUS.develop/source/{src_lcao/update_input.cpp => input_update.cpp} (95%) rename ABACUS.develop/source/{src_lcao/update_input.h => input_update.h} (100%) rename ABACUS.develop/source/src_lcao/{LCAO_cbands_gamma.cpp => ELEC_cbands_gamma.cpp} (87%) rename ABACUS.develop/source/src_lcao/{LCAO_cbands_gamma.h => ELEC_cbands_gamma.h} (82%) rename ABACUS.develop/source/src_lcao/{LCAO_cbands_k.cpp => ELEC_cbands_k.cpp} (91%) rename ABACUS.develop/source/src_lcao/{LCAO_cbands_k.h => ELEC_cbands_k.h} (84%) rename ABACUS.develop/source/src_lcao/{LCAO_evolve.cpp => ELEC_evolve.cpp} (78%) rename ABACUS.develop/source/src_lcao/{LCAO_evolve.h => ELEC_evolve.h} (84%) diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index c54d37fb57..fb164bf119 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -138,9 +138,9 @@ numerical_nonlocal.o\ numerical_nonlocal_lm.o\ local_orbital_wfc.o\ local_orbital_elec.o\ -LCAO_cbands_k.o\ -LCAO_cbands_gamma.o\ -LCAO_evolve.o\ +ELEC_cbands_k.o\ +ELEC_cbands_gamma.o\ +ELEC_evolve.o\ ELEC_scf.o\ ELEC_nscf.o\ local_orbital_ions.o\ @@ -243,7 +243,7 @@ occupy.o\ cal_test0.o\ cal_test.o\ winput.o\ -update_input.o \ +input_update.o\ lattice_change_methods.o \ lattice_change_cg.o \ lattice_change_basic.o \ diff --git a/ABACUS.develop/source/src_lcao/update_input.cpp b/ABACUS.develop/source/input_update.cpp similarity index 95% rename from ABACUS.develop/source/src_lcao/update_input.cpp rename to ABACUS.develop/source/input_update.cpp index 3a6952c563..359c1cf730 100644 --- a/ABACUS.develop/source/src_lcao/update_input.cpp +++ b/ABACUS.develop/source/input_update.cpp @@ -2,15 +2,15 @@ // Author: Lixin He,mohan // DATE : 2008-11-6 //========================================================== -#include "../src_pw/global.h" -#include "../src_pw/tools.h" -#include "../input.h" -#include "update_input.h" -#include "../src_ions/ions_move_basic.h" -#include "../src_pw/optical.h" -#include "../src_lcao/force_lcao.h" -#include "../src_lcao/local_orbital_charge.h" -#include "global_fp.h" // mohan update 2021-01-30 +#include "input_update.h" +#include "src_pw/global.h" +#include "src_pw/tools.h" +#include "input.h" +#include "src_ions/ions_move_basic.h" +#include "src_pw/optical.h" +#include "src_lcao/force_lcao.h" +#include "src_lcao/local_orbital_charge.h" +#include "src_lcao/global_fp.h" // mohan update 2021-01-30 Update_input::Update_input() {} Update_input::~Update_input() {} diff --git a/ABACUS.develop/source/src_lcao/update_input.h b/ABACUS.develop/source/input_update.h similarity index 100% rename from ABACUS.develop/source/src_lcao/update_input.h rename to ABACUS.develop/source/input_update.h diff --git a/ABACUS.develop/source/src_lcao/LCAO_cbands_gamma.cpp b/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp similarity index 87% rename from ABACUS.develop/source/src_lcao/LCAO_cbands_gamma.cpp rename to ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp index 562d8c6ff6..e7b3ceb052 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_cbands_gamma.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp @@ -1,4 +1,4 @@ -#include "LCAO_cbands_gamma.h" +#include "ELEC_cbands_gamma.h" #include "local_orbital_elec.h" #include "diago_lcao_matrix.h" #include "src_pw/global.h" @@ -7,14 +7,14 @@ #include "dftu.h" -LCAO_cbands_gamma::LCAO_cbands_gamma(){}; -LCAO_cbands_gamma::~LCAO_cbands_gamma(){}; +ELEC_cbands_gamma::ELEC_cbands_gamma(){}; +ELEC_cbands_gamma::~ELEC_cbands_gamma(){}; -void LCAO_cbands_gamma::cal_bands(const int &istep, Use_Hamilt_Matrix &uhm) +void ELEC_cbands_gamma::cal_bands(const int &istep, Use_Hamilt_Matrix &uhm) { - TITLE("LCAO_cbands_gamma","cal_bands"); - timer::tick("LCAO_cband_gamma","cal_bands",'E'); + TITLE("ELEC_cbands_gamma","cal_bands"); + timer::tick("ELEC_cband_gamma","cal_bands",'E'); assert(NSPIN == kv.nks); @@ -101,7 +101,7 @@ void LCAO_cbands_gamma::cal_bands(const int &istep, Use_Hamilt_Matrix &uhm) SGO.dis_subwfc(); }// end k points - timer::tick("LCAO_cband_gamma","cal_bands",'E'); + timer::tick("ELEC_cband_gamma","cal_bands",'E'); return; } diff --git a/ABACUS.develop/source/src_lcao/LCAO_cbands_gamma.h b/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.h similarity index 82% rename from ABACUS.develop/source/src_lcao/LCAO_cbands_gamma.h rename to ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.h index 84077efbcb..a131d1d089 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_cbands_gamma.h +++ b/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.h @@ -1,5 +1,5 @@ -#ifndef LCAO_CBANDS_GAMMA_H -#define LCAO_CBANDS_GAMMA_H +#ifndef ELEC_CBANDS_GAMMA_H +#define ELEC_CBANDS_GAMMA_H #include "../src_pw/tools.h" #include "use_hamilt_matrix.h" @@ -12,7 +12,7 @@ // k is the index for the points in the first Brillouin zone //----------------------------------------------------------- -class LCAO_cbands_gamma +class ELEC_cbands_gamma { friend class ELEC_scf; @@ -20,8 +20,8 @@ class LCAO_cbands_gamma public: - LCAO_cbands_gamma(); - ~LCAO_cbands_gamma(); + ELEC_cbands_gamma(); + ~ELEC_cbands_gamma(); private: diff --git a/ABACUS.develop/source/src_lcao/LCAO_cbands_k.cpp b/ABACUS.develop/source/src_lcao/ELEC_cbands_k.cpp similarity index 91% rename from ABACUS.develop/source/src_lcao/LCAO_cbands_k.cpp rename to ABACUS.develop/source/src_lcao/ELEC_cbands_k.cpp index 0145fbaa10..53a22dd2a6 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_cbands_k.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_cbands_k.cpp @@ -1,4 +1,4 @@ -#include "LCAO_cbands_k.h" +#include "ELEC_cbands_k.h" #include "local_orbital_elec.h" #include "diago_lcao_matrix.h" #include "src_pw/global.h" @@ -6,14 +6,14 @@ #include "evolve_lcao_matrix.h" #include "dftu.h" -LCAO_cbands_k::LCAO_cbands_k(){}; -LCAO_cbands_k::~LCAO_cbands_k(){}; +ELEC_cbands_k::ELEC_cbands_k(){}; +ELEC_cbands_k::~ELEC_cbands_k(){}; -void LCAO_cbands_k::cal_bands(const int &istep, Use_Hamilt_Matrix &uhm) +void ELEC_cbands_k::cal_bands(const int &istep, Use_Hamilt_Matrix &uhm) { - TITLE("LCAO_cbands_k","cal_bands"); - timer::tick("LCAO_cbands_k","cal_bands",'E'); + TITLE("ELEC_cbands_k","cal_bands"); + timer::tick("ELEC_cbands_k","cal_bands",'E'); int start_spin = -1; uhm.GK.reset_spin(start_spin); @@ -126,7 +126,7 @@ void LCAO_cbands_k::cal_bands(const int &istep, Use_Hamilt_Matrix &uhm) uhm.GK.destroy_pvpR(); } - timer::tick("LCAO_cbands_k","cal_bands",'E'); + timer::tick("ELEC_cbands_k","cal_bands",'E'); return; } diff --git a/ABACUS.develop/source/src_lcao/LCAO_cbands_k.h b/ABACUS.develop/source/src_lcao/ELEC_cbands_k.h similarity index 84% rename from ABACUS.develop/source/src_lcao/LCAO_cbands_k.h rename to ABACUS.develop/source/src_lcao/ELEC_cbands_k.h index a4e968348b..6d49d7483a 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_cbands_k.h +++ b/ABACUS.develop/source/src_lcao/ELEC_cbands_k.h @@ -1,5 +1,5 @@ -#ifndef LCAO_CBANDS_K_H -#define LCAO_CBANDS_K_H +#ifndef ELEC_CBANDS_K_H +#define ELEC_CBANDS_K_H #include "../src_pw/tools.h" #include "use_hamilt_matrix.h" @@ -12,7 +12,7 @@ // k is the index for the points in the first Brillouin zone //----------------------------------------------------------- -class LCAO_cbands_k +class ELEC_cbands_k { friend class ELEC_scf; @@ -20,8 +20,8 @@ class LCAO_cbands_k public: - LCAO_cbands_k(); - ~LCAO_cbands_k(); + ELEC_cbands_k(); + ~ELEC_cbands_k(); private: diff --git a/ABACUS.develop/source/src_lcao/LCAO_evolve.cpp b/ABACUS.develop/source/src_lcao/ELEC_evolve.cpp similarity index 78% rename from ABACUS.develop/source/src_lcao/LCAO_evolve.cpp rename to ABACUS.develop/source/src_lcao/ELEC_evolve.cpp index 1255eaf551..0d3b5ce362 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_evolve.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_evolve.cpp @@ -1,4 +1,4 @@ -#include "LCAO_evolve.h" +#include "ELEC_evolve.h" #include "local_orbital_elec.h" #include "diago_lcao_matrix.h" #include "src_pw/global.h" @@ -6,14 +6,14 @@ #include "evolve_lcao_matrix.h" #include "dftu.h" -LCAO_evolve::LCAO_evolve(){}; -LCAO_evolve::~LCAO_evolve(){}; +ELEC_evolve::ELEC_evolve(){}; +ELEC_evolve::~ELEC_evolve(){}; // this routine only serves for TDDFT using LCAO basis set -void LCAO_evolve::evolve_psi(const int &istep, Use_Hamilt_Matrix &uhm, complex ***wfc) +void ELEC_evolve::evolve_psi(const int &istep, Use_Hamilt_Matrix &uhm, complex ***wfc) { - TITLE("LCAO_evolve","eveolve_psi"); - timer::tick("LCAO_evolve","evolve_psi",'E'); + TITLE("ELEC_evolve","eveolve_psi"); + timer::tick("ELEC_evolve","evolve_psi",'E'); int start_spin = -1; uhm.GK.reset_spin(start_spin); @@ -46,25 +46,21 @@ void LCAO_evolve::evolve_psi(const int &istep, Use_Hamilt_Matrix &uhm, complexWFC_init); + ELEC_evolve::evolve_psi(istep, UHM, this->WFC_init); } else { - LCAO_cbands_k::cal_bands(istep, UHM); + ELEC_cbands_k::cal_bands(istep, UHM); } } diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp index ada8360f24..45958c9a33 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp @@ -2,7 +2,7 @@ #include "diago_lcao_matrix.h" #include "src_pw/global.h" #include "src_pw/symmetry_rho.h" -#include "update_input.h" +#include "input_update.h" #include "src_pw/chi0_hilbert.h" #include "evolve_lcao_matrix.h" #include "dftu.h" @@ -13,9 +13,9 @@ #include "istate_envelope.h" #include "ELEC_scf.h" #include "ELEC_nscf.h" -#include "LCAO_cbands_gamma.h" -#include "LCAO_cbands_k.h" -#include "LCAO_evolve.h" +#include "ELEC_cbands_gamma.h" +#include "ELEC_cbands_k.h" +#include "ELEC_evolve.h" // #include "src_lcao/exx_abfs.h" #include "src_lcao/exx_opt_orb.h" From acf8e578d1e80cfa5c5b65a520bfe8d4cb314b5e Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 10 Feb 2021 10:43:39 +0800 Subject: [PATCH 095/233] move sltk to src_global --- ABACUS.develop/source/Makefile | 2 ++ ABACUS.develop/source/run_lcao.cpp | 2 +- .../source/src_external/src_pdiag/pdiag_basic.cpp | 2 +- .../source/src_external/src_pdiag/pdiag_double.cpp | 2 +- .../{src_lcao => src_global}/sltk_adjacent_set.cpp | 0 .../{src_lcao => src_global}/sltk_adjacent_set.h | 0 .../source/{src_lcao => src_global}/sltk_atom.cpp | 0 .../source/{src_lcao => src_global}/sltk_atom.h | 2 +- .../{src_lcao => src_global}/sltk_atom_arrange.cpp | 0 .../{src_lcao => src_global}/sltk_atom_arrange.h | 0 .../{src_lcao => src_global}/sltk_atom_input.cpp | 0 .../source/{src_lcao => src_global}/sltk_atom_input.h | 0 .../source/{src_lcao => src_global}/sltk_grid.cpp | 0 .../source/{src_lcao => src_global}/sltk_grid.h | 2 +- .../{src_lcao => src_global}/sltk_grid_driver.cpp | 0 .../{src_lcao => src_global}/sltk_grid_driver.h | 11 ----------- .../{src_lcao/util.h => src_global/sltk_util.h} | 0 .../source/{src_lcao => src_io}/hs_matrix.cpp | 1 - .../source/{src_lcao => src_io}/hs_matrix.h | 0 .../source/{src_lcao => src_io}/wf_local.cpp | 0 ABACUS.develop/source/{src_lcao => src_io}/wf_local.h | 0 ABACUS.develop/source/src_lcao/ELEC_scf.h | 1 - ABACUS.develop/source/src_lcao/Mulliken_Charge.cpp | 2 +- ABACUS.develop/source/src_lcao/Mulliken_Charge.h | 4 ++-- ABACUS.develop/source/src_lcao/diago_lcao_matrix.cpp | 2 +- ABACUS.develop/source/src_lcao/evolve_lcao_matrix.cpp | 2 +- ABACUS.develop/source/src_lcao/gint_gamma.cpp | 2 +- ABACUS.develop/source/src_lcao/global_fp.h | 2 +- ABACUS.develop/source/src_lcao/hamilt_linear.cpp | 2 +- ABACUS.develop/source/src_lcao/local_orbital_elec.cpp | 2 +- ABACUS.develop/source/src_lcao/local_orbital_ions.cpp | 4 ++-- ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp | 2 +- ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp | 2 +- ABACUS.develop/source/src_lcao/use_overlap_matrix.h | 2 +- ABACUS.develop/source/src_pw/cal_test0.cpp | 2 +- ABACUS.develop/source/src_pw/energy.cpp | 2 +- ABACUS.develop/source/src_pw/md.cpp | 2 +- 37 files changed, 24 insertions(+), 35 deletions(-) rename ABACUS.develop/source/{src_lcao => src_global}/sltk_adjacent_set.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_global}/sltk_adjacent_set.h (100%) rename ABACUS.develop/source/{src_lcao => src_global}/sltk_atom.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_global}/sltk_atom.h (98%) rename ABACUS.develop/source/{src_lcao => src_global}/sltk_atom_arrange.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_global}/sltk_atom_arrange.h (100%) rename ABACUS.develop/source/{src_lcao => src_global}/sltk_atom_input.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_global}/sltk_atom_input.h (100%) rename ABACUS.develop/source/{src_lcao => src_global}/sltk_grid.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_global}/sltk_grid.h (99%) rename ABACUS.develop/source/{src_lcao => src_global}/sltk_grid_driver.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_global}/sltk_grid_driver.h (87%) rename ABACUS.develop/source/{src_lcao/util.h => src_global/sltk_util.h} (100%) rename ABACUS.develop/source/{src_lcao => src_io}/hs_matrix.cpp (99%) rename ABACUS.develop/source/{src_lcao => src_io}/hs_matrix.h (100%) rename ABACUS.develop/source/{src_lcao => src_io}/wf_local.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_io}/wf_local.h (100%) diff --git a/ABACUS.develop/source/Makefile b/ABACUS.develop/source/Makefile index 310566880e..06edf83e99 100644 --- a/ABACUS.develop/source/Makefile +++ b/ABACUS.develop/source/Makefile @@ -8,6 +8,8 @@ VPATH=./src_global\ :./src_external/src_pdiag\ :./src_pw\ :./src_lcao\ +:./src_ri\ +:./src_io\ :./src_ions\ :./src_external/src_pdiag/MRRR\ :./\ diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index 0f8df3be56..890c584871 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -11,7 +11,7 @@ #include "src_pw/cal_test.h" #include "src_lcao/dftu.h" //Quxin add for DFT+U on 20201029 #include "src_pw/winput.h" -#include "src_lcao/sltk_atom_arrange.h" +#include "src_global/sltk_atom_arrange.h" #include "src_lcao/local_orbital_ions.h" Run_lcao::Run_lcao(){} diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.cpp b/ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.cpp index b2554cfdc4..5babadf655 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.cpp +++ b/ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.cpp @@ -1,7 +1,7 @@ #include "pdiag_basic.h" #include "../../src_parallel/parallel_common.h" #include "../../src_pw/global.h" -#include "../../src_lcao/wf_local.h" +#include "../../src_io/wf_local.h" #include "src_global/lapack_connector.h" Pdiag_Basic::Pdiag_Basic() diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp b/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp index 591ab80ec1..3d2f417400 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp +++ b/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp @@ -6,7 +6,7 @@ //#include "../src_pw/global.h" //xiaohui add 2014-06-20 #include "src_lcao/local_orbital_charge.h" -#include "src_lcao/wf_local.h" +#include "src_io/wf_local.h" #ifdef __MPI extern "C" { diff --git a/ABACUS.develop/source/src_lcao/sltk_adjacent_set.cpp b/ABACUS.develop/source/src_global/sltk_adjacent_set.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/sltk_adjacent_set.cpp rename to ABACUS.develop/source/src_global/sltk_adjacent_set.cpp diff --git a/ABACUS.develop/source/src_lcao/sltk_adjacent_set.h b/ABACUS.develop/source/src_global/sltk_adjacent_set.h similarity index 100% rename from ABACUS.develop/source/src_lcao/sltk_adjacent_set.h rename to ABACUS.develop/source/src_global/sltk_adjacent_set.h diff --git a/ABACUS.develop/source/src_lcao/sltk_atom.cpp b/ABACUS.develop/source/src_global/sltk_atom.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/sltk_atom.cpp rename to ABACUS.develop/source/src_global/sltk_atom.cpp diff --git a/ABACUS.develop/source/src_lcao/sltk_atom.h b/ABACUS.develop/source/src_global/sltk_atom.h similarity index 98% rename from ABACUS.develop/source/src_lcao/sltk_atom.h rename to ABACUS.develop/source/src_global/sltk_atom.h index fe787f4bec..c6959b34a9 100644 --- a/ABACUS.develop/source/src_lcao/sltk_atom.h +++ b/ABACUS.develop/source/src_global/sltk_atom.h @@ -6,7 +6,7 @@ #ifndef INCLUDE_FATOM #define INCLUDE_FATOM -#include "util.h" +#include "sltk_util.h" #include "sltk_adjacent_set.h" class AdjacentSet; diff --git a/ABACUS.develop/source/src_lcao/sltk_atom_arrange.cpp b/ABACUS.develop/source/src_global/sltk_atom_arrange.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/sltk_atom_arrange.cpp rename to ABACUS.develop/source/src_global/sltk_atom_arrange.cpp diff --git a/ABACUS.develop/source/src_lcao/sltk_atom_arrange.h b/ABACUS.develop/source/src_global/sltk_atom_arrange.h similarity index 100% rename from ABACUS.develop/source/src_lcao/sltk_atom_arrange.h rename to ABACUS.develop/source/src_global/sltk_atom_arrange.h diff --git a/ABACUS.develop/source/src_lcao/sltk_atom_input.cpp b/ABACUS.develop/source/src_global/sltk_atom_input.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/sltk_atom_input.cpp rename to ABACUS.develop/source/src_global/sltk_atom_input.cpp diff --git a/ABACUS.develop/source/src_lcao/sltk_atom_input.h b/ABACUS.develop/source/src_global/sltk_atom_input.h similarity index 100% rename from ABACUS.develop/source/src_lcao/sltk_atom_input.h rename to ABACUS.develop/source/src_global/sltk_atom_input.h diff --git a/ABACUS.develop/source/src_lcao/sltk_grid.cpp b/ABACUS.develop/source/src_global/sltk_grid.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/sltk_grid.cpp rename to ABACUS.develop/source/src_global/sltk_grid.cpp diff --git a/ABACUS.develop/source/src_lcao/sltk_grid.h b/ABACUS.develop/source/src_global/sltk_grid.h similarity index 99% rename from ABACUS.develop/source/src_lcao/sltk_grid.h rename to ABACUS.develop/source/src_global/sltk_grid.h index 27b00b379f..27fcd5a397 100644 --- a/ABACUS.develop/source/src_lcao/sltk_grid.h +++ b/ABACUS.develop/source/src_global/sltk_grid.h @@ -8,7 +8,7 @@ #include #include -#include "util.h" +#include "sltk_util.h" #include "sltk_atom.h" #include "sltk_atom_input.h" #include "../src_pw/tools.h" diff --git a/ABACUS.develop/source/src_lcao/sltk_grid_driver.cpp b/ABACUS.develop/source/src_global/sltk_grid_driver.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/sltk_grid_driver.cpp rename to ABACUS.develop/source/src_global/sltk_grid_driver.cpp diff --git a/ABACUS.develop/source/src_lcao/sltk_grid_driver.h b/ABACUS.develop/source/src_global/sltk_grid_driver.h similarity index 87% rename from ABACUS.develop/source/src_lcao/sltk_grid_driver.h rename to ABACUS.develop/source/src_global/sltk_grid_driver.h index 27c8cdf260..07e05a9b7e 100644 --- a/ABACUS.develop/source/src_lcao/sltk_grid_driver.h +++ b/ABACUS.develop/source/src_global/sltk_grid_driver.h @@ -1,14 +1,3 @@ -// ============================================================================= -// C++ Header File -// Project: Find Adjacent Atom -// File: grid_driver.hpp -// Principal Class: grid_driver -// Author: ywcui -// Comment: -// Warning: -// Start time: 2008-11-10 -// Last modified: -// ============================================================================= #ifndef GRID_DRIVER_H #define GRID_DRIVER_H diff --git a/ABACUS.develop/source/src_lcao/util.h b/ABACUS.develop/source/src_global/sltk_util.h similarity index 100% rename from ABACUS.develop/source/src_lcao/util.h rename to ABACUS.develop/source/src_global/sltk_util.h diff --git a/ABACUS.develop/source/src_lcao/hs_matrix.cpp b/ABACUS.develop/source/src_io/hs_matrix.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/hs_matrix.cpp rename to ABACUS.develop/source/src_io/hs_matrix.cpp index c57af04a50..fa698dd35b 100644 --- a/ABACUS.develop/source/src_lcao/hs_matrix.cpp +++ b/ABACUS.develop/source/src_io/hs_matrix.cpp @@ -1,6 +1,5 @@ #include "hs_matrix.h" #include "../src_pw/global.h" -#include "ELEC_scf.h" void HS_Matrix::saving_HS(const double *Hloc, const double* Sloc, bool bit, const int &out_hs) { diff --git a/ABACUS.develop/source/src_lcao/hs_matrix.h b/ABACUS.develop/source/src_io/hs_matrix.h similarity index 100% rename from ABACUS.develop/source/src_lcao/hs_matrix.h rename to ABACUS.develop/source/src_io/hs_matrix.h diff --git a/ABACUS.develop/source/src_lcao/wf_local.cpp b/ABACUS.develop/source/src_io/wf_local.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/wf_local.cpp rename to ABACUS.develop/source/src_io/wf_local.cpp diff --git a/ABACUS.develop/source/src_lcao/wf_local.h b/ABACUS.develop/source/src_io/wf_local.h similarity index 100% rename from ABACUS.develop/source/src_lcao/wf_local.h rename to ABACUS.develop/source/src_io/wf_local.h diff --git a/ABACUS.develop/source/src_lcao/ELEC_scf.h b/ABACUS.develop/source/src_lcao/ELEC_scf.h index 8d3ac17c26..20ee25607b 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_scf.h +++ b/ABACUS.develop/source/src_lcao/ELEC_scf.h @@ -3,7 +3,6 @@ #include "../src_pw/tools.h" #include "../src_pw/threshold_elec.h" -#include "hs_matrix.h" //----------------------------------------------------------- // mohan add 2021-02-09 diff --git a/ABACUS.develop/source/src_lcao/Mulliken_Charge.cpp b/ABACUS.develop/source/src_lcao/Mulliken_Charge.cpp index 5fcbbe078f..7922a826dc 100644 --- a/ABACUS.develop/source/src_lcao/Mulliken_Charge.cpp +++ b/ABACUS.develop/source/src_lcao/Mulliken_Charge.cpp @@ -29,7 +29,7 @@ #include "../src_global/complexmatrix.h" #include #include -#include "../src_lcao/sltk_atom_arrange.h" +#include "../src_global/sltk_atom_arrange.h" #include "../src_lcao/lcao_nnr.h" diff --git a/ABACUS.develop/source/src_lcao/Mulliken_Charge.h b/ABACUS.develop/source/src_lcao/Mulliken_Charge.h index 625e9f4646..0b7ab56621 100644 --- a/ABACUS.develop/source/src_lcao/Mulliken_Charge.h +++ b/ABACUS.develop/source/src_lcao/Mulliken_Charge.h @@ -4,7 +4,7 @@ //#include "../src_pw/tools.h" #include "../src_pw/tools.h" #include "use_overlap_table.h" -#include "sltk_grid_driver.h" +#include "../src_global/sltk_grid_driver.h" #include "lcao_matrix.h" #include "lcao_matrix.h" #include "../src_lcao/global_fp.h" @@ -46,4 +46,4 @@ class Mulliken_Charge private: }; -#endif \ No newline at end of file +#endif diff --git a/ABACUS.develop/source/src_lcao/diago_lcao_matrix.cpp b/ABACUS.develop/source/src_lcao/diago_lcao_matrix.cpp index 27d3383c39..f3795170ab 100644 --- a/ABACUS.develop/source/src_lcao/diago_lcao_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/diago_lcao_matrix.cpp @@ -2,7 +2,7 @@ #include "../src_pw/algorithms.h" #include "../src_pw/global.h" #include "../src_external/src_pdiag/pdiag_double.h" -#include "../src_lcao/hs_matrix.h" +#include "../src_io/hs_matrix.h" //xiaohui modified 2013-03-23 //#include "../src_develop/src_siao/selinv.h" diff --git a/ABACUS.develop/source/src_lcao/evolve_lcao_matrix.cpp b/ABACUS.develop/source/src_lcao/evolve_lcao_matrix.cpp index f0bc3c8067..61d7448210 100644 --- a/ABACUS.develop/source/src_lcao/evolve_lcao_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/evolve_lcao_matrix.cpp @@ -2,7 +2,7 @@ #include "../src_pw/algorithms.h" #include "../src_pw/global.h" #include "../src_external/src_pdiag/pdiag_double.h" -#include "../src_lcao/hs_matrix.h" +#include "../src_io/hs_matrix.h" #include"../input.h" #include //fuxiang add 2016-10-28 diff --git a/ABACUS.develop/source/src_lcao/gint_gamma.cpp b/ABACUS.develop/source/src_lcao/gint_gamma.cpp index 0816d4ed84..241eea32e4 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma.cpp @@ -1,7 +1,7 @@ #include "gint_gamma.h" #include "../src_pw/global.h" #include "ylm.h" -#include "sltk_atom_arrange.h" +#include "../src_global/sltk_atom_arrange.h" Gint_Gamma::Gint_Gamma() { diff --git a/ABACUS.develop/source/src_lcao/global_fp.h b/ABACUS.develop/source/src_lcao/global_fp.h index 01e3384f5f..9dc895c3e0 100644 --- a/ABACUS.develop/source/src_lcao/global_fp.h +++ b/ABACUS.develop/source/src_lcao/global_fp.h @@ -1,7 +1,7 @@ #ifndef GLOBAL_FP_H #define GLOBAL_FP_H -#include "src_lcao/sltk_grid_driver.h" +#include "src_global/sltk_grid_driver.h" #include "src_lcao/grid_technique.h" #include "src_parallel/parallel_atoms.h" #include "src_parallel/parallel_orbitals.h" diff --git a/ABACUS.develop/source/src_lcao/hamilt_linear.cpp b/ABACUS.develop/source/src_lcao/hamilt_linear.cpp index a443634ec2..448a00bcbc 100644 --- a/ABACUS.develop/source/src_lcao/hamilt_linear.cpp +++ b/ABACUS.develop/source/src_lcao/hamilt_linear.cpp @@ -1,7 +1,7 @@ #include "../src_pw/tools.h" #include "../src_pw/global.h" #include "hamilt_linear.h" -#include "sltk_atom_arrange.h" +#include "src_global/sltk_atom_arrange.h" #include "use_overlap_table.h" #include "grid_integral.h" #include "build_st_pw.h" diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp index 45958c9a33..f31da1161d 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp @@ -7,7 +7,7 @@ #include "evolve_lcao_matrix.h" #include "dftu.h" // -#include "sltk_atom_arrange.h" +#include "../src_global/sltk_atom_arrange.h" #include "src_lcao/lcao_nnr.h" #include "istate_charge.h" #include "istate_envelope.h" diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index 048bb23cb6..bbde532e51 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -6,13 +6,13 @@ #include "force_lcao.h" #include "stress_lcao.h" #include "src_global/global_function.h" -#include "hs_matrix.h" +#include "../src_io/hs_matrix.h" #include "src_lcao/cal_r_overlap_R.h" #include "../src_ions/variable_cell.h" // mohan add 2021-02-01 #include "src_lcao/exx_abfs.h" #include "src_lcao/exx_opt_orb.h" #include "ELEC_scf.h" -#include "src_lcao/sltk_atom_arrange.h" +#include "src_global/sltk_atom_arrange.h" Local_Orbital_Ions::Local_Orbital_Ions() {} diff --git a/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp b/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp index 8d2d638fd4..8e03b98d4a 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp @@ -1,7 +1,7 @@ #include "local_orbital_wfc.h" #include "../src_pw/global.h" #include "../src_pw/algorithms.h" -#include "../src_lcao/wf_local.h" +#include "../src_io/wf_local.h" #include "global_fp.h" // mohan add 2021-01-30 diff --git a/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp b/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp index d033bea92b..449ff4a0a8 100644 --- a/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp @@ -1,7 +1,7 @@ #include "../src_pw/global.h" #include "use_hamilt_matrix.h" #include "build_st_pw.h" -#include "sltk_atom_arrange.h" +#include "../src_global/sltk_atom_arrange.h" #include "global_fp.h" // mohan add 2021-01-30 Use_Hamilt_Matrix::Use_Hamilt_Matrix() diff --git a/ABACUS.develop/source/src_lcao/use_overlap_matrix.h b/ABACUS.develop/source/src_lcao/use_overlap_matrix.h index ad9f314f2f..b59de55999 100644 --- a/ABACUS.develop/source/src_lcao/use_overlap_matrix.h +++ b/ABACUS.develop/source/src_lcao/use_overlap_matrix.h @@ -6,7 +6,7 @@ #include "../src_pw/tools.h" #include "use_overlap_table.h" -#include "sltk_grid_driver.h" +#include "../src_global/sltk_grid_driver.h" class Use_Overlap_Matrix { diff --git a/ABACUS.develop/source/src_pw/cal_test0.cpp b/ABACUS.develop/source/src_pw/cal_test0.cpp index 9899f2497f..84d876760d 100644 --- a/ABACUS.develop/source/src_pw/cal_test0.cpp +++ b/ABACUS.develop/source/src_pw/cal_test0.cpp @@ -1,7 +1,7 @@ #include "global.h" #include "tools.h" #include "cal_test0.h" -#include "../src_lcao/sltk_atom_arrange.h" +#include "../src_global/sltk_atom_arrange.h" //xiaohui modified 2013-03-23, adding "//" before #include... //#include "../src_develop/src_siao/trace_rho_hs.h" diff --git a/ABACUS.develop/source/src_pw/energy.cpp b/ABACUS.develop/source/src_pw/energy.cpp index a5c2087ffa..5c88d36594 100644 --- a/ABACUS.develop/source/src_pw/energy.cpp +++ b/ABACUS.develop/source/src_pw/energy.cpp @@ -13,7 +13,7 @@ #include "../src_lcao/lcao_nnr.h" //#include "../src_lcao/Mulliken_Charge.h" #include "../src_lcao/use_overlap_matrix.h" -#include "../src_lcao/sltk_atom_arrange.h"//qifeng-2019-01-21 +#include "../src_global/sltk_atom_arrange.h"//qifeng-2019-01-21 #include "../src_lcao/local_orbital_charge.h" #include "../src_pw/global.h" diff --git a/ABACUS.develop/source/src_pw/md.cpp b/ABACUS.develop/source/src_pw/md.cpp index 7df0f26e1b..3d3485369d 100644 --- a/ABACUS.develop/source/src_pw/md.cpp +++ b/ABACUS.develop/source/src_pw/md.cpp @@ -8,7 +8,7 @@ #include"md.h" #include"../input.h" #include"../src_lcao/local_orbital_ions.h" -#include "../src_lcao/sltk_atom_arrange.h" //2015-10-01, xiaohui +#include "../src_global/sltk_atom_arrange.h" //2015-10-01, xiaohui md::md(int n) { From 18fe93e73133b0562868e05ec65e551e92100fc9 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 10 Feb 2021 11:15:19 +0800 Subject: [PATCH 096/233] move istate_charge and istate_envelope to src_io --- .../{src_lcao => src_io}/istate_charge.cpp | 0 .../{src_lcao => src_io}/istate_charge.h | 0 .../{src_lcao => src_io}/istate_envelope.cpp | 8 +- .../{src_lcao => src_io}/istate_envelope.h | 0 ABACUS.develop/source/src_lcao/gint_gamma.cpp | 2 - ABACUS.develop/source/src_lcao/gint_gamma.h | 69 +- .../source/src_lcao/gint_gamma_fvna.cpp | 619 ------------------ .../source/src_lcao/gint_gamma_vl.cpp | 17 +- .../source/src_lcao/local_orbital_elec.cpp | 4 +- 9 files changed, 41 insertions(+), 678 deletions(-) rename ABACUS.develop/source/{src_lcao => src_io}/istate_charge.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_io}/istate_charge.h (100%) rename ABACUS.develop/source/{src_lcao => src_io}/istate_envelope.cpp (99%) rename ABACUS.develop/source/{src_lcao => src_io}/istate_envelope.h (100%) delete mode 100644 ABACUS.develop/source/src_lcao/gint_gamma_fvna.cpp diff --git a/ABACUS.develop/source/src_lcao/istate_charge.cpp b/ABACUS.develop/source/src_io/istate_charge.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/istate_charge.cpp rename to ABACUS.develop/source/src_io/istate_charge.cpp diff --git a/ABACUS.develop/source/src_lcao/istate_charge.h b/ABACUS.develop/source/src_io/istate_charge.h similarity index 100% rename from ABACUS.develop/source/src_lcao/istate_charge.h rename to ABACUS.develop/source/src_io/istate_charge.h diff --git a/ABACUS.develop/source/src_lcao/istate_envelope.cpp b/ABACUS.develop/source/src_io/istate_envelope.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/istate_envelope.cpp rename to ABACUS.develop/source/src_io/istate_envelope.cpp index b36b85a1d7..0519d76b08 100644 --- a/ABACUS.develop/source/src_lcao/istate_envelope.cpp +++ b/ABACUS.develop/source/src_io/istate_envelope.cpp @@ -3,14 +3,10 @@ #include "../src_pw/tools.h" IState_Envelope::IState_Envelope() -{ - -} +{} IState_Envelope::~IState_Envelope() -{ - -} +{} void IState_Envelope::begin(void) diff --git a/ABACUS.develop/source/src_lcao/istate_envelope.h b/ABACUS.develop/source/src_io/istate_envelope.h similarity index 100% rename from ABACUS.develop/source/src_lcao/istate_envelope.h rename to ABACUS.develop/source/src_io/istate_envelope.h diff --git a/ABACUS.develop/source/src_lcao/gint_gamma.cpp b/ABACUS.develop/source/src_lcao/gint_gamma.cpp index 241eea32e4..3575992e78 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma.cpp @@ -76,5 +76,3 @@ void Gint_Gamma::save_atoms_on_grid(const Grid_Technique >) return; } - - diff --git a/ABACUS.develop/source/src_lcao/gint_gamma.h b/ABACUS.develop/source/src_lcao/gint_gamma.h index bb23cddb13..b824e88c96 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma.h +++ b/ABACUS.develop/source/src_lcao/gint_gamma.h @@ -10,16 +10,37 @@ #include "grid_technique.h" #include "lcao_matrix.h" #include + //========================================================= -//CLASS Grid_Integral_Beta -//Note : Integral On 3D Grids, different from Grid_Integral -//Feature : Matrix Elements Of Local Potential For -//Numerical Orbitals +// Integral On 3D Grids, different from Grid_Integral +// Feature : Matrix Elements Of Local Potential For +// Numerical Orbitals //========================================================= class Gint_Gamma : public Grid_Base_Beta { -private: + public: + + Gint_Gamma(); + ~Gint_Gamma(); + + // (1) calculate the H matrix in terms of effective potentials + void cal_vlocal( const double* vlocal_in); + + // (2) calculate charge density + double cal_rho(void); + + // (3) calcualte the forces related to grid + void cal_force( const double* vlocal_in); + + // (4) calcualte the envelope function + void cal_env(const double* wfc, double* rho); + + // (5) calculate the Mulliken charge + void cal_mulliken(double** mulliken); + + + private: double* transformer; double psiv1; @@ -45,29 +66,16 @@ class Gint_Gamma : public Grid_Base_Beta omp_lock_t lock; void save_atoms_on_grid(const Grid_Technique >); - - - // for calculation of < phi_i | Vna | phi_j > - // on normal real space FFT grid. - void gamma_vna(void); - - - // for calculation of < phi_i | Vna | phi_j > - // on dense real space FFT grid. - void gamma_vna_d(const Grid_Technique >, const char &matrix_type);// d stands for 'dense' // for calculation of < phi_i | Vlocal | phi_j > void gamma_vlocal(void); - // for calculation of charege double gamma_charge(void); - // for calculation of Mulliken charge. void gamma_mulliken(double** mulliken); - // for calculation of envelope functions. void gamma_envelope(const double* wfc, double* rho);// mohan add 2011-07-01 @@ -77,11 +85,6 @@ class Gint_Gamma : public Grid_Base_Beta void gamma_force(void); - // for calculation of < dphi_i | Vlocal | phi_j> for force calculation - // on dense FFT grid. - void gamma_force_vna(const Grid_Technique >, LCAO_Matrix &lm); - - void cal_meshball_vlocal(int size, int LD_pool, int* block_iw, int* bsize, int* colidx, int** cal_flag, double* vldr3, double** psir_ylm, double** psir_vlbr3, int* vindex, int lgd_now, double** GridVlocal); @@ -98,26 +101,6 @@ class Gint_Gamma : public Grid_Base_Beta int** cal_flag, double** psir_ylm); -public: - - Gint_Gamma(); - ~Gint_Gamma(); - - double cal_rho(void); - void cal_mulliken(double** mulliken); - void cal_env(const double* wfc, double* rho); - void cal_vna( const double* vlocal_in); - void cal_vna_d( const Grid_Technique >, const double* vlocal_in, const char &matrix_type);// d stands for 'dense' - void cal_vlocal( const double* vlocal_in); - void cal_force( const double* vlocal_in); - void cal_force_vna( const double* vlocal_in, const Grid_Technique >, LCAO_Matrix &lm ); - void cal_vnl_B(complex **Tab); // mohan add 2011-04-08 - - - - // needed while for gauge-invarient B-field. - void cal_S_T_AP(char type, const Grid_Technique >);//for calculating S,T,and A*P. sun zhiyuan add 2012-01-03 - }; diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_fvna.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_fvna.cpp deleted file mode 100644 index 0491bbd29a..0000000000 --- a/ABACUS.develop/source/src_lcao/gint_gamma_fvna.cpp +++ /dev/null @@ -1,619 +0,0 @@ -#include "gint_gamma.h" -#include "grid_technique.h" -#include "lcao_orbitals.h" -#include "../src_pw/global.h" - -#include "global_fp.h" // mohan add 2021-01-30 - -void Gint_Gamma::cal_force_vna(const double* vlocal_in, const Grid_Technique >, LCAO_Matrix &lm) -{ - timer::tick("Gint_Gamma","cal_force_vna",'I'); - this->vlocal = vlocal_in; - this->save_atoms_on_grid(gt); - this->gamma_force_vna(gt, lm); - timer::tick("Gint_Gamma","cal_force_vna",'I'); -} - - -//------------------------------------------------------------- -// Because this part calculat -// so there are many reasons make this part very expensive. -// (1) Dense grid. (dx*2,dy*2,dz*2) 8 times at least -// (2) All the matrix are needed, it's non-symmetric. 2 times at least -// (3) Need to calculate three components of force: Fx,Fy,Fz -// However, 3 times may be -// 8*2*3=48 (20) -// we must know, -// once we have the lattice structure and the atom positions, -// and of course the local orbitals. -// we can do the neutral potential force right away, -// why should we bother so many processors to do at the same -// time after the charge density is converged. -// we can begin to do it in another set of processors!! -// -// The same principle applys to the -//------------------------------------------------------------- -void Gint_Gamma::gamma_force_vna(const Grid_Technique >, LCAO_Matrix &lm) -{ - TITLE("Grid_Integral","gamma_force_vna"); - timer::tick("Gint_Gamma","gamma_force_vna",'J'); - // gt.lgd: local grid dimension (sub-FFT-mesh). - double** DGridV = new double*[gt.lgd]; - double** DGridV_s; - if(STRESS) DGridV_s = new double*[gt.lgd]; - for (int i=0; i rly; - vector> grly; - - double mt[3]={0,0,0}; - double *vldr3 = new double[bxyz]; - ZEROS(vldr3, bxyz); - - double* vna3d = new double[bxyz]; - ZEROS(vna3d, bxyz); - - - int* nww = new int[max_size]; - int* iw0_all = new int[max_size]; - ZEROS(nww,max_size); - ZEROS(iw0_all,max_size); - -// ofstream ofs_x("vna_x.dat"); -// ofstream ofs_y("vna_y.dat"); -// ofstream ofs_z("vna_z.dat"); - - const int nbx = gt.nbx; - const int nby = gt.nby; - const int nbz_start = gt.nbzp_start; - const int nbz = gt.nbzp; - - - // needed in the inner circle. - double vv; - double* psi1; - double* dphi2; - double* dpvp; - double* dpvpr; - double* dphi3; - double* phi2_end; - int iw1_lo; - - for (int i=0; igrid_index = (k-nbz_start) + j * nbz + i * nby * nbz; - const int size = gt.how_many_atoms[ this->grid_index ]; - if(size==0)continue; // tmp by mohan - - ZEROS(vna3d, bxyz);//vna - - for (int id=0; id ORB.Vna[it].rcut && - distance[ib][id] > ORB.Phi[it].getRcut()) - { - cal_flag[ib][id]=false; - continue; - } - - Ylm::grad_rl_sph_harm(ucell.atoms[it].nwl, dr[ib][id][0], - dr[ib][id][1], dr[ib][id][2], rly, grly); - - // 1E-7 is necessary in case of R is just on one grid - const double position = distance[ib][id] / delta_r; - this->iq[id] = static_cast(position); - this->x0[id] = position - static_cast(iq[id]); - this->x1[id] = 1.0 - x0[id]; - this->x2[id] = 2.0 - x0[id]; - this->x3[id] = 3.0 - x0[id]; - this->x12[id] = x1[id]*x2[id] / 6.0; - this->x03[id] = x0[id]*x3[id] / 2.0; - - - // vna - if(distance[ib][id] <= ORB.Vna[it].rcut) - { - double ccc = (x12[id]*(ORB.Vna[it].vna_u[iq[id]]*x3[id] - +ORB.Vna[it].vna_u[iq[id]+3]*x0[id]) - + x03[id]*(ORB.Vna[it].vna_u[iq[id]+1]*x2[id] - -ORB.Vna[it].vna_u[iq[id]+2]*x1[id])); - - vna3d[ib] += ccc; - -// cout << " size=" << size << " distance=" << distance[ib][id] << " ccc=" << ccc << endl; - -// vna3d[ib] += (x12[id]*(ORB.Vna[it].vna_u[iq[id]]*x3[id] -// +ORB.Vna[it].vna_u[iq[id]+3]*x0[id]) -// + x03[id]*(ORB.Vna[it].vna_u[iq[id]+1]*x2[id] -// -ORB.Vna[it].vna_u[iq[id]+2]*x1[id]));/// sqrt(FOUR_PI); - } - - - if(distance[ib][id] <= ORB.Phi[it].getRcut()) - { - cal_flag[ib][id]=true; - } - else - { - cal_flag[ib][id]=false; - continue; - } - - - - double tmp, dtmp; - for (int iw=0; iw< atom->nw; iw++) - { - if ( atom->iw2_new[iw] ) - { - pointer = &ORB.Phi[it].PhiLN( - atom->iw2l[iw], - atom->iw2n[iw]); - - if ( iq[id] >= pointer->nr_uniform-4) - { - tmp = dtmp = 0.0; - } - else - { - tmp = x12[id]*(pointer->psi_uniform[iq[id]]*x3[id] - +pointer->psi_uniform[iq[id]+3]*x0[id]) - + x03[id]*(pointer->psi_uniform[iq[id]+1]*x2[id] - -pointer->psi_uniform[iq[id]+2]*x1[id]); - - dtmp = x12[id]*(pointer->dpsi_uniform[iq[id]]*x3[id] - +pointer->dpsi_uniform[iq[id]+3]*x0[id]) - + x03[id]*(pointer->dpsi_uniform[iq[id]+1]*x2[id] - -pointer->dpsi_uniform[iq[id]+2]*x1[id]); - } - }//new l is used. - - int ll = atom->iw2l[iw]; - int idx_lm = atom->iw2_ylm[iw]; - - //special case for distance[id] -> 0 - //Problems Remained - //You have to add this two lines - double rr = distance[ib][id]; - if (rr < 1e-9) - { - if (ll == 0) - { - psir_ylm[ib][id][iw] = tmp * rly[idx_lm]; - dphi[ib][id][3*iw] = dphi[ib][id][3*iw+1] = dphi[ib][id][3*iw+2] = 0.0; - } - else - { - pointer = &ORB.Phi[it]. - PhiLN(atom->iw2l[iw], atom->iw2n[iw]); - - double Zty = pointer->zty; - psir_ylm[ib][id][iw] = Zty * rly[idx_lm]; - - const int iww = 3*iw; - dphi[ib][id][iww] = Zty * grly[idx_lm][0]; - dphi[ib][id][iww+1] = Zty * grly[idx_lm][1]; - dphi[ib][id][iww+2] = Zty * grly[idx_lm][2]; - } - } - else - { - double rl; - if(ll==0) - { - rl = 1.0; - } - else if(ll==1) - { - rl = rr; - } - else - { - rl = pow(rr, ll); - } - - psir_ylm[ib][id][iw] = tmp * rly[idx_lm] / rl; - - double tmpdphi_rly = (dtmp - tmp * ll / rr) / rl * rly[idx_lm] / rr; - double tmprl = tmp/rl; - - dphi[ib][id][iw*3] = tmpdphi_rly * dr[ib][id][0] + tmprl * grly[idx_lm][0]; - dphi[ib][id][iw*3+1] = tmpdphi_rly * dr[ib][id][1] + tmprl * grly[idx_lm][1]; - dphi[ib][id][iw*3+2] = tmpdphi_rly * dr[ib][id][2] + tmprl * grly[idx_lm][2]; - } - } - }// ib - }//!id //finish loop of calc pre-info for each adjacent atom - - int bindex = 0; - // z is the fastest, - for(int ii=0; iivfactor; - vldr3[bindex] = vna3d[bindex] * this->vfactor; - ++bindex; - } - } - } - - - - for(int ia1=0; ia1=0 and nu>=0 in previous version. - if(mu >=0) - { - for (int j=0; j=0) - { - tmp[3*j] = DGridV[mu][3*nu]; - tmp[3*j+1] = DGridV[mu][3*nu+1]; - tmp[3*j+2] = DGridV[mu][3*nu+2]; - if(STRESS) - { - tmpr[6*j] = DGridV_s[mu][6*nu]; - tmpr[6*j+1] = DGridV_s[mu][6*nu+1]; - tmpr[6*j+2] = DGridV_s[mu][6*nu+2]; - tmpr[6*j+3] = DGridV_s[mu][6*nu+3]; - tmpr[6*j+4] = DGridV_s[mu][6*nu+4]; - tmpr[6*j+5] = DGridV_s[mu][6*nu+5]; - } - } - } - } - - Parallel_Reduce::reduce_double_pool( tmp, 3*NLOCAL ); - if(STRESS) Parallel_Reduce::reduce_double_pool( tmpr, 6*NLOCAL ); - const int i2d = ParaO.trace_loc_row[i]; - if(i2d<0) continue; - for (int j=0; j ORB.Phi[it].getRcut()) if(distance[ib][id] > (ORB.Phi[it].getRcut()- 1.0e-15)) { @@ -97,10 +100,10 @@ inline void cal_psir_ylm(int size, int grid_index, double delta_r, double phi, dr[ib][id][1] / distance[ib][id], dr[ib][id][2] / distance[ib][id], ylma); - // these parameters are about interpolation - // because once we know the distance from atom to grid point, - // we can get the parameters we need to do interpolation and - // store them first!! these can save a lot of effort. + // these parameters are related to interpolation + // because once the distance from atom to grid point is known, + // we can obtain the parameters for interpolation and + // store them first! these operations save lots of efforts. const double position=distance[ib][id] / delta_r; int ip; double dx, dx2, dx3; @@ -412,7 +415,9 @@ void Gint_Gamma::gamma_vlocal(void) // Peize Lin update OpenMP 2020.09.27 // allocate 1 int nnnmax=0; for(int T=0; T Date: Wed, 10 Feb 2021 11:31:47 +0800 Subject: [PATCH 097/233] delete gradcorr.f90 interpol_3d, update the format of Mulliken_Charge --- .../source/src_lcao/Mulliken_Charge.cpp | 796 +++++++++--------- .../source/src_lcao/Mulliken_Charge.h | 28 +- ABACUS.develop/source/src_lcao/gradcorr.f90 | 220 ----- .../source/src_lcao/interpol_3d.cpp | 604 ------------- ABACUS.develop/source/src_lcao/interpol_3d.h | 40 - 5 files changed, 403 insertions(+), 1285 deletions(-) delete mode 100644 ABACUS.develop/source/src_lcao/gradcorr.f90 delete mode 100644 ABACUS.develop/source/src_lcao/interpol_3d.cpp delete mode 100644 ABACUS.develop/source/src_lcao/interpol_3d.h diff --git a/ABACUS.develop/source/src_lcao/Mulliken_Charge.cpp b/ABACUS.develop/source/src_lcao/Mulliken_Charge.cpp index 7922a826dc..c7a922033e 100644 --- a/ABACUS.develop/source/src_lcao/Mulliken_Charge.cpp +++ b/ABACUS.develop/source/src_lcao/Mulliken_Charge.cpp @@ -37,84 +37,81 @@ Mulliken_Charge::Mulliken_Charge() { - M.init(); - if(GAMMA_ONLY_LOCAL) - { - for(int in=0;in [NLOCAL]; - - - DecMulP = new double* [NSPIN]; - for(int is=0; is [NLOCAL]; + + + DecMulP = new double* [NSPIN]; + for(int is=0; is mud; - mud.resize(1); - mud[0].create(ParaO.ncol,ParaO.nrow); - - - matrix Dwf = M.wfc_gamma[is]; - for (int i=0; i mud; - mud.resize(1); - mud[0].create(ParaO.ncol,ParaO.nrow); - atom_arrange::set_sr_NL(); - atom_arrange::search( SEARCH_RADIUS );//qifeng-2019-01-21 - hm.hon.set_orb_tables(); - LM.allocate_HS_R(LNNR.nnr); - LM.zeros_HSR('S', LNNR.nnr); - UHM.UOM.calculate_S_no(); - UHM.UOM.build_ST_new('S', false); - - - - for(int ik=0;ik mud; + mud.resize(1); + mud[0].create(ParaO.ncol,ParaO.nrow); + + matrix Dwf = M.wfc_gamma[is]; + for (int i=0; i mud; + mud.resize(1); + mud[0].create(ParaO.ncol,ParaO.nrow); + atom_arrange::set_sr_NL(); + atom_arrange::search( SEARCH_RADIUS );//qifeng-2019-01-21 + hm.hon.set_orb_tables(); + LM.allocate_HS_R(LNNR.nnr); + LM.zeros_HSR('S', LNNR.nnr); + UHM.UOM.calculate_S_no(); + UHM.UOM.build_ST_new('S', false); + + for(int ik=0;iknw; ++j) - { - int k = ucell.itiaiw2iwt(t,a,j); - ADecMulP[is][i][j] = DecMulP[is][k]; - - } - } - - } - - }//is - - + hm.hon.clear_after_ions(); + + }//else + MPI_Reduce(MecMulP[is], DecMulP[is] , NLOCAL , MPI_DOUBLE , MPI_SUM, 0, MPI_COMM_WORLD); + + if(MY_RANK == 0) + { + for (int i=0; inw; ++j) + { + int k = ucell.itiaiw2iwt(t,a,j); + ADecMulP[is][i][j] = DecMulP[is][k]; + + } + } + + } + + }//is + + return; } void Mulliken_Charge::stdout_mulliken(void) { this->cal_mulliken(); - if(MY_RANK == 0) - { - - TITLE("Dos","calculate_Mulliken"); - ofstream fout; - const char * fn= "mulliken.txt"; - fout.open(fn); - // ofstream fout; - // string wordqf="mulliken.txt"; - // wordqf += char(MY_RANK + 48); - // wordqf += ".txt"; - // fout.open(wordqf.c_str(),ios::app); - int num,l,m,mul; - double Tcharge; - double* sum_l = new double[2]; - double* sum_mul = new double[2]; - - - string Name_Angular[5][11]; - /* decomposed Mulliken charge */ - - Name_Angular[0][0] = "s "; - Name_Angular[1][0] = "px "; - Name_Angular[1][1] = "py "; - Name_Angular[1][2] = "pz "; - Name_Angular[2][0] = "d3z^2-r^2 "; - Name_Angular[2][1] = "dxy "; - Name_Angular[2][2] = "dxz "; - Name_Angular[2][3] = "dx^2-y^2 "; - Name_Angular[2][4] = "dyz "; - Name_Angular[3][0] = "f5z^2-3r^2 "; - Name_Angular[3][1] = "f5xz^2-xr^2"; - Name_Angular[3][2] = "f5yz^2-yr^2"; - Name_Angular[3][3] = "fzx^2-zy^2 "; - Name_Angular[3][4] = "fxyz "; - Name_Angular[3][5] = "fx^3-3*xy^2"; - Name_Angular[3][6] = "f3yx^2-y^3 "; - Name_Angular[4][0] = "g1 "; - Name_Angular[4][1] = "g2 "; - Name_Angular[4][2] = "g3 "; - Name_Angular[4][3] = "g4 "; - Name_Angular[4][4] = "g5 "; - Name_Angular[4][5] = "g6 "; - Name_Angular[4][6] = "g7 "; - Name_Angular[4][7] = "g8 "; - Name_Angular[4][8] = "g9 "; + if(MY_RANK == 0) + { + TITLE("Dos","calculate_Mulliken"); + ofstream fout; + const char * fn= "mulliken.txt"; + fout.open(fn); + // ofstream fout; + // string wordqf="mulliken.txt"; + // wordqf += char(MY_RANK + 48); + // wordqf += ".txt"; + // fout.open(wordqf.c_str(),ios::app); + int num,l,m,mul; + double Tcharge; + double* sum_l = new double[2]; + double* sum_mul = new double[2]; + + string Name_Angular[5][11]; + /* decomposed Mulliken charge */ + + Name_Angular[0][0] = "s "; + Name_Angular[1][0] = "px "; + Name_Angular[1][1] = "py "; + Name_Angular[1][2] = "pz "; + Name_Angular[2][0] = "d3z^2-r^2 "; + Name_Angular[2][1] = "dxy "; + Name_Angular[2][2] = "dxz "; + Name_Angular[2][3] = "dx^2-y^2 "; + Name_Angular[2][4] = "dyz "; + Name_Angular[3][0] = "f5z^2-3r^2 "; + Name_Angular[3][1] = "f5xz^2-xr^2"; + Name_Angular[3][2] = "f5yz^2-yr^2"; + Name_Angular[3][3] = "fzx^2-zy^2 "; + Name_Angular[3][4] = "fxyz "; + Name_Angular[3][5] = "fx^3-3*xy^2"; + Name_Angular[3][6] = "f3yx^2-y^3 "; + Name_Angular[4][0] = "g1 "; + Name_Angular[4][1] = "g2 "; + Name_Angular[4][2] = "g3 "; + Name_Angular[4][3] = "g4 "; + Name_Angular[4][4] = "g5 "; + Name_Angular[4][5] = "g6 "; + Name_Angular[4][6] = "g7 "; + Name_Angular[4][7] = "g8 "; + Name_Angular[4][8] = "g9 "; fout << "\n CALCULATE THE MULLIkEN ANALYSIS FOR EACH ATOM" << endl; + // calculate the total charge of the system. - double sch = 0.0; - fout << setprecision(8); - for(int is=0; isnw; ++j) { - int t = ucell.iat2it[i]; - Atom* atom1 = &ucell.atoms[t]; - fout << i << " " << ucell.atoms[t].label << " " << "Up spin" << " " << "Down spin" << endl; - fout << " " << "multiple" << endl; - //num = 0; - for(int j=0; jnw; ++j) - { - const int L1 = atom1->iw2l[j]; - const int N1 = atom1->iw2n[j]; - const int m1 = atom1->iw2m[j]; - fout << Name_Angular[L1][m1] << " " << N1 << " " << ADecMulP[0][i][j] << " " << ADecMulP[0][i][j] << endl; - } + const int L1 = atom1->iw2l[j]; + const int N1 = atom1->iw2n[j]; + const int m1 = atom1->iw2m[j]; + fout << Name_Angular[L1][m1] << " " << N1 << " " << ADecMulP[0][i][j] << " " << ADecMulP[0][i][j] << endl; + } }*/ - for (int i=0; i *mug ; - + double** DecMulP ; + double** MecMulP ; + double*** ADecMulP ; + Wfc_Dm_2d M; - - - - void cal_mulliken(void); + complex *mug; - void stdout_mulliken(void); - + void cal_mulliken(void); -private: + void stdout_mulliken(void); + + private: }; #endif diff --git a/ABACUS.develop/source/src_lcao/gradcorr.f90 b/ABACUS.develop/source/src_lcao/gradcorr.f90 deleted file mode 100644 index 024cbed3ae..0000000000 --- a/ABACUS.develop/source/src_lcao/gradcorr.f90 +++ /dev/null @@ -1,220 +0,0 @@ -SUBROUTINE gradcorr( rho, rhog, rho_core, rhog_core, etxc, vtxc, v ) - IF ( .NOT. dft_is_gradient() ) RETURN - - igcc_is_lyp = (get_igcc() == 3 .or. get_igcc() == 7) - ! - etxcgc = 0.D0 - vtxcgc = 0.D0 - ! - nspin0=nspin - fac = 1.D0 / DBLE( nspin0 ) - ! - ALLOCATE( h( 3, nrxx, nspin0) ) - ALLOCATE( grho( 3, nrxx, nspin0) ) - ALLOCATE( rhoout( nrxx, nspin0) ) - ! - ALLOCATE( rhogsum( ngm, nspin0 ) ) - ! - ! ... calculate the gradient of rho + rho_core in real space - ! - IF ( nspin == 4 .AND. domag ) THEN - ! - CALL compute_rho(rho,rhoout,segni,nrxx) - ! - ! ... bring starting rhoout to G-space - ! - DO is = 1, nspin0 - ! - psic(:) = rhoout(:,is) - ! - CALL cft3( psic, nr1, nr2, nr3, nrx1, nrx2, nrx3, -1 ) - ! - rhogsum(:,is) = psic(nl(:)) - ! - END DO - ELSE - ! - rhoout(:,1:nspin0) = rho(:,1:nspin0) - rhogsum(:,1:nspin0) = rhog(:,1:nspin0) - ! - ENDIF - DO is = 1, nspin0 - ! - rhoout(:,is) = fac * rho_core(:) + rhoout(:,is) - rhogsum(:,is) = fac * rhog_core(:) + rhogsum(:,is) - ! - CALL gradrho( nrx1, nrx2, nrx3, nr1, nr2, nr3, nrxx, & - rhogsum(1,is), ngm, g, nl, grho(1,1,is) ) - ! - END DO - ! - DEALLOCATE( rhogsum ) - ! - IF ( nspin0 == 1 ) THEN - ! - ! ... This is the spin-unpolarised case - ! - DO k = 1, nrxx - ! - arho = ABS( rhoout(k,1) ) - ! - IF ( arho > epsr ) THEN - ! - grho2(1) = grho(1,k,1)**2 + grho(2,k,1)**2 + grho(3,k,1)**2 - ! - IF ( grho2(1) > epsg ) THEN - ! - segno = SIGN( 1.D0, rhoout(k,1) ) - ! - CALL gcxc( arho, grho2(1), sx, sc, v1x, v2x, v1c, v2c ) - ! - ! ... first term of the gradient correction : D(rho*Exc)/D(rho) - ! - v(k,1) = v(k,1) + e2 * ( v1x + v1c ) - ! - ! ... h contains : - ! - ! ... D(rho*Exc) / D(|grad rho|) * (grad rho) / |grad rho| - ! - h(:,k,1) = e2 * ( v2x + v2c ) * grho(:,k,1) - ! - vtxcgc = vtxcgc+e2*( v1x + v1c ) * ( rhoout(k,1) - rho_core(k) ) - etxcgc = etxcgc+e2*( sx + sc ) * segno - ! - ELSE - h(:,k,1)=0.D0 - END IF - ! - ELSE - ! - h(:,k,1) = 0.D0 - ! - END IF - ! - END DO - ! - ELSE - ! - ! ... spin-polarised case - ! -!$omp parallel do private( rh, grho2, sx, v1xup, v1xdw, v2xup, v2xdw, rup, rdw, & -!$omp grhoup, grhodw, grhoud, sc, v1cup, v1cdw, v2cup, v2cdw, v2cud, & -!$omp zeta, grh2, v2c, grup, grdw ), & -!$omp reduction(+:etxcgc,vtxcgc) - DO k = 1, nrxx - ! - rh = rhoout(k,1) + rhoout(k,2) - ! - grho2(:) = grho(1,k,:)**2 + grho(2,k,:)**2 + grho(3,k,:)**2 - ! - CALL gcx_spin( rhoout(k,1), rhoout(k,2), grho2(1), & - grho2(2), sx, v1xup, v1xdw, v2xup, v2xdw ) - ! - IF ( rh > epsr ) THEN - ! - IF ( igcc_is_lyp ) THEN - ! - rup = rhoout(k,1) - rdw = rhoout(k,2) - ! - grhoup = grho(1,k,1)**2 + grho(2,k,1)**2 + grho(3,k,1)**2 - grhodw = grho(1,k,2)**2 + grho(2,k,2)**2 + grho(3,k,2)**2 - ! - grhoud = grho(1,k,1) * grho(1,k,2) + & - grho(2,k,1) * grho(2,k,2) + & - grho(3,k,1) * grho(3,k,2) - ! - CALL gcc_spin_more( rup, rdw, grhoup, grhodw, grhoud, & - sc, v1cup, v1cdw, v2cup, v2cdw, v2cud ) - ! - ELSE - ! - zeta = ( rhoout(k,1) - rhoout(k,2) ) / rh - if (nspin.eq.4.and.domag) zeta=abs(zeta)*segni(k) - ! - grh2 = ( grho(1,k,1) + grho(1,k,2) )**2 + & - ( grho(2,k,1) + grho(2,k,2) )**2 + & - ( grho(3,k,1) + grho(3,k,2) )**2 - ! - CALL gcc_spin( rh, zeta, grh2, sc, v1cup, v1cdw, v2c ) - ! - v2cup = v2c - v2cdw = v2c - v2cud = v2c - ! - END IF - ! - ELSE - ! - sc = 0.D0 - v1cup = 0.D0 - v1cdw = 0.D0 - v2c = 0.D0 - v2cup = 0.D0 - v2cdw = 0.D0 - v2cud = 0.D0 - ! - ENDIF - ! - ! ... first term of the gradient correction : D(rho*Exc)/D(rho) - ! - v(k,1) = v(k,1) + e2 * ( v1xup + v1cup ) - v(k,2) = v(k,2) + e2 * ( v1xdw + v1cdw ) - ! - ! ... h contains D(rho*Exc)/D(|grad rho|) * (grad rho) / |grad rho| - ! - DO ipol = 1, 3 - ! - grup = grho(ipol,k,1) - grdw = grho(ipol,k,2) - h(ipol,k,1) = e2 * ( ( v2xup + v2cup ) * grup + v2cud * grdw ) - h(ipol,k,2) = e2 * ( ( v2xdw + v2cdw ) * grdw + v2cud * grup ) - ! - END DO - ! - vtxcgc = vtxcgc + & - e2 * ( v1xup + v1cup ) * ( rhoout(k,1) - rho_core(k) * fac ) - vtxcgc = vtxcgc + & - e2 * ( v1xdw + v1cdw ) * ( rhoout(k,2) - rho_core(k) * fac ) - etxcgc = etxcgc + e2 * ( sx + sc ) - ! - END DO -!$omp end parallel do - ! - END IF - ! - DO is = 1, nspin0 - ! - rhoout(:,is) = rhoout(:,is) - fac * rho_core(:) - ! - END DO - ! - DEALLOCATE( grho ) - ! - ALLOCATE( dh( nrxx ) ) - ! - ! ... second term of the gradient correction : - ! ... \sum_alpha (D / D r_alpha) ( D(rho*Exc)/D(grad_alpha rho) ) - ! - DO is = 1, nspin0 - ! - CALL grad_dot( nrx1, nrx2, nrx3, nr1, nr2, nr3, & - nrxx, h(1,1,is), ngm, g, nl, alat, dh ) - ! - v(:,is) = v(:,is) - dh(:) - ! - vtxcgc = vtxcgc - SUM( dh(:) * rhoout(:,is) ) - ! - END DO - ! - vtxc = vtxc + omega * vtxcgc / ( nr1 * nr2 * nr3 ) - etxc = etxc + omega * etxcgc / ( nr1 * nr2 * nr3 ) - - ! - DEALLOCATE( dh ) - DEALLOCATE( h ) - DEALLOCATE( rhoout ) - ! - RETURN - ! -END SUBROUTINE gradcorr diff --git a/ABACUS.develop/source/src_lcao/interpol_3d.cpp b/ABACUS.develop/source/src_lcao/interpol_3d.cpp deleted file mode 100644 index 0ef4ab625f..0000000000 --- a/ABACUS.develop/source/src_lcao/interpol_3d.cpp +++ /dev/null @@ -1,604 +0,0 @@ -#include "Interpolation_3D.h" -#include "../src_pw/tools.h" -#include "random_def.h" -IPL_3D :: IPL_3D(): psi(NULL), result(NULL), pos(NULL) -{ - cout << " 3D_Interpolation " << endl; - - this->test = 3; - this->flag = 0; - - if (flag) - { - if (test > 0) - { - cout << "Prepare Interpolation Infomation and write them to the hard disk!" << endl; - } - - write(); - } - else - { - if (test > 0) - { - cout << "Read Interpolation Information from hard disk and ready for Interpolate!" << endl; - } - - read(); - } -} - -IPL_3D :: ~IPL_3D() -{ -// delete[] psi; -// delete[] pos; -}; - -void IPL_3D :: write() -{ - this -> init(); - - this -> Cal_Coord(); - - this -> QSort_Indata(psi, pos, 0, psi_num - 1); - - if (test > 1) - { - cout << "Correctness of Sort Function" << endl; - - for (int i = 0; i < psi_num; i++) - { - Vector3 temp = Get_Index(pos[i], v_min, cell_length); - cout << "pos = " << pos[i].x << setw(5) << pos[i].y << setw(5) << pos[i].z << setw(5); - cout << "index = (" << temp.x << ", " << temp.y << ", " << temp.z << ")" << endl; - int key = temp.x * length.y * length.z + temp.y * length.z + temp.z; - cout << " key = " << key << " i = " << i << endl; - } - } - - ofstream outf("IPL_3D.dat"); - - if (outf) - { - outf << IPL_nbnd << endl; - outf << psi_num << endl; - outf << old_lat0 << endl; - outf << setw(12) << v_min.x - << setw(12) << v_min.y - << setw(12) << v_min.z << endl; - outf << setw(12) << v_max.x - << setw(12) << v_max.y - << setw(12) << v_max.z << endl; - outf << setw(12) << length.x - << setw(12) << length.y - << setw(12) << length.z << endl; - outf << setw(12) << cell_length.x - << setw(12) << cell_length.y - << setw(12) << cell_length.z << endl; - - for (int i = 0; i < IPL_nbnd; i++) - { - for (int j = 0; j < psi_num;j++) - { - outf << setw(12) << psi[i][j].real() << setw(12) << psi[i][j].imag() << endl; - } - } - - for (int i = 0; i < psi_num; i++) - { - outf << setw(12) << pos[i].x - << setw(12) << pos[i].y - << setw(12) << pos[i].z << endl; - } - - outf << setw(12) << old_latvec.e11 << setw(12) << old_latvec.e12 << setw(12) << old_latvec.e13 << endl - - << setw(12) << old_latvec.e21 << setw(12) << old_latvec.e22 << setw(12) << old_latvec.e23 << endl - << setw(12) << old_latvec.e31 << setw(12) << old_latvec.e32 << setw(12) << old_latvec.e33 << endl; - } - else - { - cout << "Cannot open file IPL_3D!!" << endl; - exit(0); - } - - outf.close(); - - if (test > 0) - cout << "Finish the write process!" << endl; -} - -void IPL_3D :: read() -{ - ifstream input("IPL_3D.dat"); - - if (!input) - { - cout << "IPL_3D has not been saved yet!!" << endl; - exit(0); - } - - input >> IPL_nbnd; - - input >> this->psi_num; - input >> this->old_lat0; - input >> this->v_min.x >> this->v_min.y >> this->v_min.z; - input >> this->v_max.x >> this->v_max.y >> this->v_max.z; - input >> this->length.x >> this->length.y >> this->length.z; - input >> this->cell_length.x >> this->cell_length.y >> this->cell_length.z; - - this->psi = new complex* [IPL_nbnd](); - - for (int i = 0; i < IPL_nbnd; i++) - this->psi[i] = new complex [psi_num]; - - for (int i = 0; i < nbnd; i++) - { - for (int j = 0; j < psi_num; j++) - { - double real, img; - input >> real >> img; - psi[i][j] = complex (real, img); - } - } - - - this->pos = new Vector3 [psi_num]; - - for (int i = 0; i < psi_num; i++) - { - input >> this->pos[i].x >> this->pos[i].y >> this->pos[i].z; - } - - input >> this->old_latvec.e11 >> this->old_latvec.e12 >> this->old_latvec.e13 - - >> this->old_latvec.e21 >> this->old_latvec.e22 >> this->old_latvec.e23 - >> this->old_latvec.e31 >> this->old_latvec.e32 >> this->old_latvec.e33; - input.close(); - - if (test > 0) - { - cout << "Finish Reading!" << endl; - } - -// this->Cal_Result(); -} - -void IPL_3D::init() -{ - if (test > 0) - { - cout << "\n init " << endl; - - cout << "\n kv.nks = " << kv.nks << endl; - cout << "\n st.kgxyz = " << st.kgxyz << endl; - cout << "\n st.qtot = " << st.qtot << endl; - } - - this->length.x = st.kg[0]; - - this->length.y = st.kg[1]; - this->length.z = st.kg[2]; - this->psi_num = st.kgxyz; - this->old_latvec = pw.latvec; - this->old_lat0 = pw.lat0; - - if (nbnd > pw.natomwfc) - { - IPL_nbnd = nbnd; - } - else IPL_nbnd = pw.natomwfc; - - this->psi = new complex* [IPL_nbnd]; - - for (int i = 0; i < IPL_nbnd; i++) - this->psi[i] = new complex [psi_num]; - - for (int iw = 0;iw < IPL_nbnd; iw++) - { - int iq = 0; - - for (int ik = 0;ik < kv.nks; ik++) - { - for (int ig = 0;ig < kv.ngk[ik];ig++) - { - const int num = st.kg2fftw[iq]; - psi[iw][num] = wf.evc[ik](iw, ig); - /* if(test > 1) - { - cout<<"psi["< 0) - cout << "\n Cal_Coord : " << endl; - - this->pos = new Vector3 [psi_num]; - - this->v_min = Vector3(0, 0, 0); - - this->v_max = Vector3(0, 0, 0); - - int x = st.kg[0]; - - int y = st.kg[1]; - - int z = st.kg[2]; - - this->length = Vector3(x, y, z); - - int xy = x * y; - - int xz = x * z; - - int yz = y * z; - - int x2 = x / 2; - - int y2 = y / 2; - - int z2 = z / 2; - - for (int i = 0;i < st.kgxyz; i++) - { - Vector3 temp; - temp.x = i / xy; - temp.y = i / x - temp.x * z; - temp.z = i - temp.y * y - temp.x * yz; - - if (test > 1) - { - cout << "\ntemp = ( " << temp.x - << ", " << temp.y << ", " << temp.z - << ")" << setw(5); - } - - const int num = static_cast(temp.x * yz + temp .y * z + temp.z); - - if (temp.x > x2) temp.x -= x; - - if (temp.y > y2) temp.y -= y; - - if (temp.z > z2) temp.z -= z; - - pos[num] = temp; - - if (test > 1) - { - cout << "pos[ " << num << "] = ( " << pos[num].x - << ", " << pos[num].y << ", " << pos[num].z - << ")" << endl; - } - - if (pos[num].x < v_min.x) v_min.x = pos[num].x; - - if (pos[num].y < v_min.y) v_min.y = pos[num].y; - - if (pos[num].z < v_min.z) v_min.z = pos[num].z; - - if (pos[num].x > v_max.x) v_max.x = pos[num].x; - - if (pos[num].y > v_max.y) v_max.y = pos[num].y; - - if (pos[num].x > v_max.z) v_max.z = pos[num].z; - - } - - cell_length.x = (v_max.x - v_min.x) / (length.x - 1); - - cell_length.y = (v_max.y - v_min.y) / (length.y - 1); - cell_length.z = (v_max.z - v_min.z) / (length.z - 1); - - if (test > 0) - { - cout << "\nv_min = ( " << v_min.x << " , " << v_min.y << " , " << v_min.z << " )\n" - << "v_max = ( " << v_max.x << " , " << v_max.y << " , " << v_max.z << " )\n" - << "\nlength.x = " << length.x - << "\nlength.y = " << length.y - << "\nlength.z = " << length.z - << "\ncell_length.x = " << cell_length.x - << "\ncell_length.y = " << cell_length.y - << "\ncell_length.z = " << cell_length.z << endl; - } -} - -Vector3 IPL_3D :: Get_Index(Vector3 pos, Vector3 Origin, Vector3 length) -{ - Vector3 Index; - Index.x = static_cast(std::floor((pos.x - Origin.x) / length.x)); - Index.y = static_cast(std::floor((pos.y - Origin.y) / length.y)); - Index.z = static_cast(std::floor((pos.z - Origin.z) / length.z)); - return Index; -} - -int IPL_3D :: Sort_Partition(complex **val, Vector3 *pos, int low, int high) -{ - if (test > 1) - cout << "Begin Sort_Partition." << endl; - - Vector3 temp_pos = pos[low]; - - complex * temp_psi ; - - temp_psi = new complex [IPL_nbnd]; - - for (int i = 0;i < IPL_nbnd; i++) - { - temp_psi[i] = val[i][low]; - } - - Vector3 low_index = Get_Index(pos[low], v_min, cell_length); - - Vector3 high_index = Get_Index(pos[high], v_min, cell_length); - - int low_key = low_index.x * length.y * length.z + low_index.y * length.z + low_index.z; - int pivotkey = low_key; - int high_key = high_index.x * length.y * length.z + high_index.y * length.z + high_index.z; - int times = 0; - - while (low < high) - { - if (test > 2) - { - cout << "Loop times: " << times << endl; - cout << "Low = " << low << endl; - cout << "high = " << high << endl; - cout << "low_key = " << low_key << endl; - cout << "high_key = " << high_key << endl; - cout << "pivotkey = " << pivotkey << endl; - cout << "pos[low] = (" << pos[low].x - << " ," << pos[low].y - << " ," << pos[low].z << ")" << endl; - cout << "pos[high] = (" << pos[high].x - << " ," << pos[high].y - << " ," << pos[high].z << ")" << endl; - } - - times++; - - while (low < high && high_key >= pivotkey) - { - --high; - high_index = Get_Index(pos[high], v_min, cell_length); - high_key = high_index.x * length.y * length.z + high_index.y * length.z + high_index.z; - } - - pos[low] = pos[high]; - - for (int i = 0; i < IPL_nbnd; i++) - { - val[i][low] = val[i][high]; - } - - if (test > 2) - { - cout << "pos[low] = (" << pos[low].x - << " ," << pos[low].y - << " ," << pos[low].z << ")" << endl; - cout << "low_key = " << low_key << endl; - } - - low_index = Get_Index(pos[low], v_min, cell_length); - - low_key = low_index.x * length.y * length.z + low_index.y * length.z + low_index.z; - - while (low < high && low_key <= pivotkey) - { - ++low; - low_index = Get_Index(pos[low], v_min, cell_length); - low_key = low_index.x * length.y * length.z + low_index.y * length.z + low_index.z; - } - - pos[high] = pos[low]; - - for (int i = 0; i < IPL_nbnd; i++) - { - val[i][high] = val[i][low]; - } - - high_index = Get_Index(pos[high], v_min, cell_length); - - high_key = high_index.x * length.y * length.z + high_index.y * length.z + high_index.z; - } - - if (test > 1) - cout << "Loop times: " << times << endl; - - pos[low] = temp_pos; - - for (int i = 0; i < IPL_nbnd; i++) - { - val[i][low] = temp_psi[i]; - } - - return low; -} - -int IPL_3D::count = 0; -void IPL_3D::QSort_Indata(complex **val, Vector3 *pos, int low, int high) -{ - if (test > 1) - { - cout << "\n<==========================Ready for the " << count - << " times Qsort=============================" << endl; - - if (test > 2) - { - for (int i = 0; i < psi_num; i++) - { - Vector3 temp = Get_Index(pos[i], v_min, cell_length); - cout << "pos = (" << pos[i].x << setw(5) << pos[i].y << setw(5) << pos[i].z << ") " << setw(5); - cout << "index = (" << temp.x << ", " << temp.y << ", " << temp.z << ")" << endl; - int key = temp.x * length.y * length.z + temp.y * length.z + temp.z; - cout << " key = " << key << " i = " << i << endl; - } - } - - cout << "\nlength of the Sqlist" << high - low + 1 << endl; - } - - if (low < high) - { - if (test > 1) - cout << "Iterate Time = " << count << endl; - - count++; - - int pivotloc = this->Sort_Partition(val, pos, low, high); - - if (test > 1) - cout << "pivotloc = " << pivotloc << endl; - -// if(count == 1)exit(0); - QSort_Indata(val, pos, low, pivotloc - 1); - - QSort_Indata(val, pos, pivotloc + 1, high); - } -} - -complex IPL_3D::Interpolation_3D(complex **psi, const double &x, const double &y, const double &z, const int seq) -{ -// transform the coordinate - Vector3 cor = Vector3(x, y, z); - cor = cor * this->old_latvec; - cor = (old_lat0 / pw.lat0) * cor; - cor = cor * pw.GT; - - if (test > 1) - { - cout << "band number = " << seq << endl; - cout << "Direct Coordinate in old Coordinates: (" - << cor.x << ", " << cor.y << ", " << cor.z << ")" << endl; - } - - Vector3 index = Get_Index(cor, v_min, cell_length); - - if (test > 1) - { - cout << "index in the old system: (" << index.x << ", " << index.y << ", " << index.z << ")" << endl; - cout << length.x << setw(5) << length.y << setw(5) << length.z << endl; - } - - if (index.x > length.x || index.y > length.y || index.z > length.z) - { - cout << "Input Coordinates of is beyond the bound of the box!!" << endl; - exit(0); - } - - int pos = index.x * length.y * length.z + index.y * length.z + index.z; - - complex V_000 = psi[seq][pos]; - - pos = index.x * length.y * length.z + index.y * length.z + index.z + 1; - complex V_001 = psi[seq][pos]; - - pos = index.x * length.y * length.z + (index.y + 1) * length.z + index.z; - complex V_010 = psi[seq][pos]; - - pos = index.x * length.y * length.z + (index.y + 1) * length.z + index.z + 1; - complex V_011 = psi[seq][pos]; - - pos = (index.x + 1) * length.y * length.z + index.y * length.z + index.z; - complex V_100 = psi[seq][pos]; - - pos = (index.x + 1) * length.y * length.z + index.y * length.z + index.z + 1; - complex V_101 = psi[seq][pos]; - - pos = (index.x + 1) * length.y * length.z + (index.y + 1) * length.z + index.z; - complex V_110 = psi[seq][pos]; - - pos = (index.x + 1) * length.y * length.z + (index.y + 1) * length.z + index.z + 1; - complex V_111 = psi[seq][pos]; - - complex V_IPL; - V_IPL = (1 - cor.x) * (1 - cor.y) * (1 - cor.z) * V_000 + - cor.x * (1 - cor.y) * (1 - cor.z) * V_100 + - (1 - cor.x) * cor.y * (1 - cor.z) * V_010 + - (1 - cor.x) * (1 - cor.y) * cor.z * V_001 + - cor.x * (1 - cor.y) * cor.z * V_101 + - (1 - cor.x) * cor.y * cor.z * V_011 + - cor.x * cor.y * (1 - cor.z) * V_110 + - cor.x * cor.y * cor.z * V_111 ; - - if (test > 1) - { - cout << "Interpolation Result: (" << V_IPL.real() << ", " << - V_IPL.imag() << ")" << endl; - } - - return V_IPL; -} - -void IPL_3D :: Cal_Result() -{ - if (test > 0) - cout << "Cai_Result" << endl; - - int x = st.kg[0]; - - int y = st.kg[1]; - - int z = st.kg[2]; - - int xy = x * y; - - int xz = x * z; - - int yz = y * z; - - int x2 = x / 2; - - int y2 = y / 2; - - int z2 = z / 2; - - this->result = new complex* [IPL_nbnd]; - - for (int i = 0; i < IPL_nbnd; i++) - { - this->result[i] = new complex [st.kgxyz](); - } - - for (int i = 0; i < IPL_nbnd; i++) - { - for (int j = 0;j < st.kgxyz; j++) - { - Vector3 temp; - temp.x = j / xy; - temp.y = j / x - temp.x * z; - temp.z = j - temp.y * y - temp.x * yz; - const int num = static_cast(temp.x * yz + temp .y * z + temp.z); - - if (temp.x > x2) temp.x -= x; - - if (temp.y > y2) temp.y -= y; - - if (temp.z > z2) temp.z -= z; - - - if (test > 1) - { - cout << "Direct Coordinate in new Coordinates: (" - << temp.x << ", " << temp.y << ", " << temp.z << ")" << endl; - } - - result[i][num] = this->Interpolation_3D(psi, temp.x, temp.y, temp.z, i); - - } - } - - return; -} diff --git a/ABACUS.develop/source/src_lcao/interpol_3d.h b/ABACUS.develop/source/src_lcao/interpol_3d.h deleted file mode 100644 index 54d3617c6b..0000000000 --- a/ABACUS.develop/source/src_lcao/interpol_3d.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef INCLUDE_IPL_3D -#define INCLUDE_IPL_3D - -#include "../src_pw/global.h" -#include "../src_pw/tools.h" - -class IPL_3D -{ -public: - IPL_3D(); - ~IPL_3D(); - - complex **psi; - int psi_num; - Vector3 *pos; - complex **result; -private: - static int count ;//count iterater time in the Sort function - Vector3 v_min;//origin of the box - Vector3 v_max;//farthest points of the box - Vector3 length;//number of cells on each dim - Vector3 cell_length;// distance between two adjacent points in each dim - Matrix3 old_latvec; - double old_lat0; - int IPL_nbnd; - int test;//switch of output information - bool flag;//"0" for read,"1"for write -public: - void write();//Prepare information for Interpolation,write to the hard disk - void read();//read information from file and conduct interpolation - void init(void);//initial psi - void Cal_Coord();//initial pos,and other parameters - Vector3 Get_Index(Vector3 pos, Vector3 Origin, Vector3 length); - int Sort_Partition(complex **val, Vector3 *pos, int low, int high); - void QSort_Indata(complex **val, Vector3 *pos, int low, int high); - complex Interpolation_3D(complex **psi, const double &x, const double &y, const double &z, const int seq); - void Cal_Result(); -}; - -#endif From da6ae03db3c555e4f9f5004f0d23d23a3588c839 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 10 Feb 2021 15:07:16 +0800 Subject: [PATCH 098/233] delete useless local_orbital_pairs class --- ABACUS.develop/source/Makefile.Objects | 1 - .../source/src_lcao/hamilt_linear.h | 4 +- .../source/src_lcao/local_orbital_pairs.cpp | 76 ------------------- .../source/src_lcao/local_orbital_pairs.h | 33 -------- 4 files changed, 1 insertion(+), 113 deletions(-) delete mode 100644 ABACUS.develop/source/src_lcao/local_orbital_pairs.cpp delete mode 100644 ABACUS.develop/source/src_lcao/local_orbital_pairs.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index fb164bf119..8b9a617269 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -157,7 +157,6 @@ force_lcao.o\ force_lcao_gamma.o\ force_lcao_k.o\ stress_lcao.o\ -local_orbital_pairs.o\ hamilt_linear.o \ parallel_atoms.o \ parallel_orbitals.o \ diff --git a/ABACUS.develop/source/src_lcao/hamilt_linear.h b/ABACUS.develop/source/src_lcao/hamilt_linear.h index d3a3fda2a2..5dc499f7d5 100644 --- a/ABACUS.develop/source/src_lcao/hamilt_linear.h +++ b/ABACUS.develop/source/src_lcao/hamilt_linear.h @@ -8,8 +8,7 @@ #include "../src_pw/tools.h" #include "../src_pw/algorithms.h" -#include "use_overlap_table.h" // (2) -#include "local_orbital_pairs.h" // (5) pairs basis +#include "use_overlap_table.h" #include "../src_external/src_pdiag/pdiag_double.h" class Hamilt_Linear @@ -44,6 +43,5 @@ class Hamilt_Linear double *en// band energy ); - Local_Orbital_Pairs pairs; }; #endif diff --git a/ABACUS.develop/source/src_lcao/local_orbital_pairs.cpp b/ABACUS.develop/source/src_lcao/local_orbital_pairs.cpp deleted file mode 100644 index b2591005ca..0000000000 --- a/ABACUS.develop/source/src_lcao/local_orbital_pairs.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "local_orbital_pairs.h" -#include "lcao_orbitals.h" - -Local_Orbital_Pairs::Local_Orbital_Pairs() -{ - // xinguo: lmax of orbital + 1 - lmax_aux = 3; - naux = 0; -} -Local_Orbital_Pairs::~Local_Orbital_Pairs(){} - -void Local_Orbital_Pairs::init() -{ - TITLE("Local_Orbital_Pairs","init"); - - // calculate the number of auxiliary basis. - this->naux = 0; - for(int it=0; it=L0) - { - for(int N1=0; N1 Date: Wed, 10 Feb 2021 16:51:15 +0800 Subject: [PATCH 099/233] move rwstream to src_io --- .../{src_global => src_io}/rwstream.cpp | 0 .../source/{src_global => src_io}/rwstream.h | 0 .../source/src_lcao/hamilt_linear.h | 4 +- .../source/src_lcao/lcao_orbitals.cpp | 1 + .../source/src_lcao/lcao_orbitals.h | 5 + .../source/src_lcao/orbital_information_0.cpp | 100 ------------------ .../source/src_lcao/orbital_information_0.h | 41 ------- .../source/src_lcao/use_overlap_matrix.h | 4 +- ABACUS.develop/source/src_pw/wf_io.h | 2 +- 9 files changed, 13 insertions(+), 144 deletions(-) rename ABACUS.develop/source/{src_global => src_io}/rwstream.cpp (100%) rename ABACUS.develop/source/{src_global => src_io}/rwstream.h (100%) delete mode 100644 ABACUS.develop/source/src_lcao/orbital_information_0.cpp delete mode 100644 ABACUS.develop/source/src_lcao/orbital_information_0.h diff --git a/ABACUS.develop/source/src_global/rwstream.cpp b/ABACUS.develop/source/src_io/rwstream.cpp similarity index 100% rename from ABACUS.develop/source/src_global/rwstream.cpp rename to ABACUS.develop/source/src_io/rwstream.cpp diff --git a/ABACUS.develop/source/src_global/rwstream.h b/ABACUS.develop/source/src_io/rwstream.h similarity index 100% rename from ABACUS.develop/source/src_global/rwstream.h rename to ABACUS.develop/source/src_io/rwstream.h diff --git a/ABACUS.develop/source/src_lcao/hamilt_linear.h b/ABACUS.develop/source/src_lcao/hamilt_linear.h index 5dc499f7d5..930d582dd0 100644 --- a/ABACUS.develop/source/src_lcao/hamilt_linear.h +++ b/ABACUS.develop/source/src_lcao/hamilt_linear.h @@ -13,7 +13,9 @@ class Hamilt_Linear { -public: + + public: + Hamilt_Linear(); ~Hamilt_Linear(); diff --git a/ABACUS.develop/source/src_lcao/lcao_orbitals.cpp b/ABACUS.develop/source/src_lcao/lcao_orbitals.cpp index d2273d88c8..ab34eadbf6 100644 --- a/ABACUS.develop/source/src_lcao/lcao_orbitals.cpp +++ b/ABACUS.develop/source/src_lcao/lcao_orbitals.cpp @@ -19,6 +19,7 @@ LCAO_Orbitals::LCAO_Orbitals() this->dr_uniform = 0.001; } + LCAO_Orbitals::~LCAO_Orbitals() { if(test_deconstructor) diff --git a/ABACUS.develop/source/src_lcao/lcao_orbitals.h b/ABACUS.develop/source/src_lcao/lcao_orbitals.h index 2042bbff74..073956e2b4 100644 --- a/ABACUS.develop/source/src_lcao/lcao_orbitals.h +++ b/ABACUS.develop/source/src_lcao/lcao_orbitals.h @@ -14,17 +14,22 @@ class LCAO_Orbitals { public: + LCAO_Orbitals(); ~LCAO_Orbitals(); void Read_Orbitals(void); + void Read_PAO(const int& it); // in order to get rid of the .NONLOCAL file. void Set_NonLocal(const int &it, int &n_projectors); + // read in the NONLOCAL projector from file. void Read_NonLocal(const int& it, int &n_projectors); + void set_nl_index(void); + #ifdef __MPI void bcast_files(void); #endif diff --git a/ABACUS.develop/source/src_lcao/orbital_information_0.cpp b/ABACUS.develop/source/src_lcao/orbital_information_0.cpp deleted file mode 100644 index fcb924ff26..0000000000 --- a/ABACUS.develop/source/src_lcao/orbital_information_0.cpp +++ /dev/null @@ -1,100 +0,0 @@ -//========================================================= -//AUTHOR : mohan -//DATE : 2008-11-29 -//========================================================= -#include "orbital_information_0.h" - -Orbital_Information_0::Orbital_Information_0() -{ -} - -Orbital_Information_0::~Orbital_Information_0() -{ - if (init_done) - { - delete[] label; - delete[] enviroment; - delete[] transparence; - delete[] lmax; - - for (int i = 0; i < ntype; i++) - { - delete[] nchi[i]; - } - - delete[] nchi; - } -} - -void Orbital_Information_0::Read(const string &fn, ofstream &ofs) -{ - if (test_overlap)TITLE("Orbital_Information_0", "Read"); - - ifstream ifs(fn.c_str()); - - if (!ofs) - { - WARNING_QUIT("Orbital_Information_0::Read","Can not find the file."); - } - else - { - cout << "\n Read in file : " << fn; - } - - CHECK_NAME(ifs, "INPUT_ORBITAL_INFORMATION_0"); - - CHECK_NAME(ifs, "ntype"); - ifs >> ntype; - OUT(ofs, "ntype", ntype); - - if (ntype <= 0 || ntype > 50) - { - WARNING_QUIT("Orbital_Information_0::Read", "ntype<=0 || ntype>50"); - } - - this->init_done = false; - - this->label = new string[ntype]; - this->enviroment = new string[ntype]; - this->transparence = new double[ntype]; - this->lmax = new int[ntype]; - this->nchi = new int*[ntype]; - - for (int i = 0; i < ntype; i++) - { - CHECK_NAME(ifs, "label"); - ifs >> label[i]; - OUT(ofs, "label", label[i]); - - CHECK_NAME(ifs, "enviroment"); - ifs >> enviroment[i]; - OUT(ofs, "enviroment", enviroment[i]); - - CHECK_NAME(ifs, "transparence"); - ifs >> transparence[i]; - OUT(ofs, "transparence", transparence[i]); - - CHECK_NAME(ifs, "Lmax"); - ifs >> lmax[i]; - OUT(ofs, "Lmax", lmax[i]); - nchi[i] = new int[ lmax[i] ]; - - for (int j = 0;j <= lmax[i];j++) - { - CHECK_NAME(ifs, "L"); - OUT(ofs, "L", j); - int k; - ifs >> k; - assert(k == j); - - CHECK_NAME(ifs, "nchi"); - int m; - ifs >> nchi[i][j]; - OUT(ofs, "nchi", nchi[i][j]); - } - } - - this->init_done = true; - - return; -} diff --git a/ABACUS.develop/source/src_lcao/orbital_information_0.h b/ABACUS.develop/source/src_lcao/orbital_information_0.h deleted file mode 100644 index 422ebc6499..0000000000 --- a/ABACUS.develop/source/src_lcao/orbital_information_0.h +++ /dev/null @@ -1,41 +0,0 @@ -//========================================================= -//AUTHOR : mohan -//DATE : 2008-11-29 -//========================================================= -#ifndef ORBITAL_INFORMATION_0_H -#define ORBITAL_INFORMATION_0_H - -#include "../src_pw/tools.h" - -class Orbital_Information_0 -{ - public: - - Orbital_Information_0(); - ~Orbital_Information_0(); - - void Read(const string &fn,ofstream &ofs); - - const int& getNtype(void) const {return ntype;} - const string& getLabel(const int it) const {return label[it];} - const string& getEnv(const int it)const {return enviroment[it]; } - const double& getTran(const int it)const {return transparence[it];} - const int* getNchi(const int it) const { return nchi[it]; } - const int& getNchi_l(const int it,const int il){ return nchi[it][il]; } - const int& getLmax(const int it) const { return lmax[it]; } - - private: - - int ntype; - string *label; - string *enviroment; - double *transparence; - int* lmax; - int** nchi; - - bool init_done; - - -}; - -#endif diff --git a/ABACUS.develop/source/src_lcao/use_overlap_matrix.h b/ABACUS.develop/source/src_lcao/use_overlap_matrix.h index b59de55999..dc311f1bfd 100644 --- a/ABACUS.develop/source/src_lcao/use_overlap_matrix.h +++ b/ABACUS.develop/source/src_lcao/use_overlap_matrix.h @@ -13,8 +13,10 @@ class Use_Overlap_Matrix friend class Force_LCAO_gamma; friend class Force_LCAO_k; friend class energy;//qifeng 2019/9/10 - friend class Mulliken_Charge;//qifeng 2019/9/10 + friend class Mulliken_Charge;//qifeng 2019/9/10 + public: + Use_Overlap_Matrix(); ~Use_Overlap_Matrix(); diff --git a/ABACUS.develop/source/src_pw/wf_io.h b/ABACUS.develop/source/src_pw/wf_io.h index 5bd7e96797..622a8af18c 100644 --- a/ABACUS.develop/source/src_pw/wf_io.h +++ b/ABACUS.develop/source/src_pw/wf_io.h @@ -2,7 +2,7 @@ #define WF_IO_H #include "../src_pw/tools.h" -#include "../src_global/rwstream.h" +#include "../src_io/rwstream.h" namespace WF_io { From 8eebe5b225720c65013e074d32e5f40f672c18a3 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 10 Feb 2021 17:11:36 +0800 Subject: [PATCH 100/233] change use_overlap_table.cpp to ORB_gen_tables.cpp --- ABACUS.develop/source/Makefile.Objects | 9 ++++----- ABACUS.develop/source/Makefile.vars | 2 +- .../{use_overlap_table.cpp => ORB_gen_tables.cpp} | 2 +- .../src_lcao/{use_overlap_table.h => ORB_gen_tables.h} | 0 ABACUS.develop/source/src_lcao/dftu.cpp | 2 +- ABACUS.develop/source/src_lcao/dftu_relax.cpp | 2 +- ABACUS.develop/source/src_lcao/global_fp.h | 2 +- ABACUS.develop/source/src_lcao/hamilt_linear.cpp | 2 +- ABACUS.develop/source/src_lcao/hamilt_linear.h | 2 +- .../{Mulliken_Charge.cpp => mulliken_charge.cpp} | 2 +- .../src_lcao/{Mulliken_Charge.h => mulliken_charge.h} | 2 +- .../{unkOverlap_lcao.cpp => unk_overlap_lcao.cpp} | 2 +- .../src_lcao/{unkOverlap_lcao.h => unk_overlap_lcao.h} | 0 ABACUS.develop/source/src_lcao/use_overlap_matrix.h | 2 +- ABACUS.develop/source/src_pw/berryphase.h | 4 ++-- ABACUS.develop/source/src_pw/energy.cpp | 4 +--- ABACUS.develop/source/src_pw/pseudopot_cell_vnl.cpp | 2 +- ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h | 2 +- .../src_pw/{unkOverlap_pw.cpp => unk_overlap_pw.cpp} | 2 +- .../source/src_pw/{unkOverlap_pw.h => unk_overlap_pw.h} | 0 20 files changed, 21 insertions(+), 24 deletions(-) rename ABACUS.develop/source/src_lcao/{use_overlap_table.cpp => ORB_gen_tables.cpp} (99%) rename ABACUS.develop/source/src_lcao/{use_overlap_table.h => ORB_gen_tables.h} (100%) rename ABACUS.develop/source/src_lcao/{Mulliken_Charge.cpp => mulliken_charge.cpp} (99%) rename ABACUS.develop/source/src_lcao/{Mulliken_Charge.h => mulliken_charge.h} (96%) rename ABACUS.develop/source/src_lcao/{unkOverlap_lcao.cpp => unk_overlap_lcao.cpp} (99%) rename ABACUS.develop/source/src_lcao/{unkOverlap_lcao.h => unk_overlap_lcao.h} (100%) rename ABACUS.develop/source/src_pw/{unkOverlap_pw.cpp => unk_overlap_pw.cpp} (99%) rename ABACUS.develop/source/src_pw/{unkOverlap_pw.h => unk_overlap_pw.h} (100%) diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 8b9a617269..bf4588d2d4 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -66,7 +66,7 @@ mdNVT.o\ exx_lip.o\ soc.o\ toWannier90.o \ -unkOverlap_pw.o \ +unk_overlap_pw.o \ berryphase.o \ sto_elec.o\ sto_wf.o\ @@ -105,10 +105,9 @@ sltk_atom_arrange.o\ sltk_atom.o\ sltk_adjacent_set.o\ sltk_atom_input.o\ -orbital_information_0.o\ make_gaunt_table.o\ make_overlap_table.o\ -use_overlap_table.o\ +ORB_gen_tables.o\ use_overlap_matrix.o\ use_hamilt_matrix.o\ build_st_pw.o\ @@ -201,7 +200,7 @@ exx_lcao.o \ exx_opt_orb.o \ exx_opt_orb-print.o \ wfc_dm_2d.o \ -unkOverlap_lcao.o \ +unk_overlap_lcao.o \ cal_r_overlap_R.o \ OBJS_WANNIER=wan_global.o\ @@ -279,7 +278,7 @@ symmetry_rho.o \ symm_book.o \ symm_other.o \ eximport.o \ -Mulliken_Charge.o\ +mulliken_charge.o\ #OBJS_MLWF=mlwf_kmesh.o\ mlwf_overlap.o\ diff --git a/ABACUS.develop/source/Makefile.vars b/ABACUS.develop/source/Makefile.vars index 7611bbdcbc..83a160f5f2 100644 --- a/ABACUS.develop/source/Makefile.vars +++ b/ABACUS.develop/source/Makefile.vars @@ -30,5 +30,5 @@ ELPA_DIR = /home/mohan/1_Software/impi_elpa-16.05.005 CEREAL_DIR = /home/mohan/1_Software/ABACUS_Github/cereal/cereal/ OBJ_DIR = obj -NP = 10 +NP = 14 diff --git a/ABACUS.develop/source/src_lcao/use_overlap_table.cpp b/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/use_overlap_table.cpp rename to ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp index 994320defe..c9b56739ce 100644 --- a/ABACUS.develop/source/src_lcao/use_overlap_table.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp @@ -1,4 +1,4 @@ -#include "use_overlap_table.h" +#include "ORB_gen_tables.h" #include "ylm.h" #include "lcao_orbitals.h" #include "../src_pw/global.h" diff --git a/ABACUS.develop/source/src_lcao/use_overlap_table.h b/ABACUS.develop/source/src_lcao/ORB_gen_tables.h similarity index 100% rename from ABACUS.develop/source/src_lcao/use_overlap_table.h rename to ABACUS.develop/source/src_lcao/ORB_gen_tables.h diff --git a/ABACUS.develop/source/src_lcao/dftu.cpp b/ABACUS.develop/source/src_lcao/dftu.cpp index 0a3f8b4e09..f94349db69 100644 --- a/ABACUS.develop/source/src_lcao/dftu.cpp +++ b/ABACUS.develop/source/src_lcao/dftu.cpp @@ -23,7 +23,7 @@ #include "local_orbital_ions.h" #include "lcao_matrix.h" #include "../src_pw/magnetism.h" -#include "use_overlap_table.h" +#include "ORB_gen_tables.h" #include "../src_pw/charge.h" DFTU dftu; diff --git a/ABACUS.develop/source/src_lcao/dftu_relax.cpp b/ABACUS.develop/source/src_lcao/dftu_relax.cpp index 16e3a4d1fb..790a2a4575 100644 --- a/ABACUS.develop/source/src_lcao/dftu_relax.cpp +++ b/ABACUS.develop/source/src_lcao/dftu_relax.cpp @@ -22,7 +22,7 @@ #include "local_orbital_ions.h" #include "lcao_matrix.h" #include "../src_pw/magnetism.h" -#include "use_overlap_table.h" +#include "ORB_gen_tables.h" #include "../src_pw/charge.h" diff --git a/ABACUS.develop/source/src_lcao/global_fp.h b/ABACUS.develop/source/src_lcao/global_fp.h index 9dc895c3e0..f077337cb6 100644 --- a/ABACUS.develop/source/src_lcao/global_fp.h +++ b/ABACUS.develop/source/src_lcao/global_fp.h @@ -11,7 +11,7 @@ #include "src_lcao/use_overlap_matrix.h" #include "src_lcao/use_hamilt_matrix.h" #include "src_lcao/lcao_orbitals.h" -#include "src_lcao/use_overlap_table.h" +#include "src_lcao/ORB_gen_tables.h" #include "src_parallel/subgrid_oper.h" #include "src_lcao/exx_lcao.h" diff --git a/ABACUS.develop/source/src_lcao/hamilt_linear.cpp b/ABACUS.develop/source/src_lcao/hamilt_linear.cpp index 448a00bcbc..1a3c3369d9 100644 --- a/ABACUS.develop/source/src_lcao/hamilt_linear.cpp +++ b/ABACUS.develop/source/src_lcao/hamilt_linear.cpp @@ -2,7 +2,7 @@ #include "../src_pw/global.h" #include "hamilt_linear.h" #include "src_global/sltk_atom_arrange.h" -#include "use_overlap_table.h" +#include "ORB_gen_tables.h" #include "grid_integral.h" #include "build_st_pw.h" diff --git a/ABACUS.develop/source/src_lcao/hamilt_linear.h b/ABACUS.develop/source/src_lcao/hamilt_linear.h index 930d582dd0..1c05bc5432 100644 --- a/ABACUS.develop/source/src_lcao/hamilt_linear.h +++ b/ABACUS.develop/source/src_lcao/hamilt_linear.h @@ -8,7 +8,7 @@ #include "../src_pw/tools.h" #include "../src_pw/algorithms.h" -#include "use_overlap_table.h" +#include "ORB_gen_tables.h" #include "../src_external/src_pdiag/pdiag_double.h" class Hamilt_Linear diff --git a/ABACUS.develop/source/src_lcao/Mulliken_Charge.cpp b/ABACUS.develop/source/src_lcao/mulliken_charge.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/Mulliken_Charge.cpp rename to ABACUS.develop/source/src_lcao/mulliken_charge.cpp index c7a922033e..e6cf34a784 100644 --- a/ABACUS.develop/source/src_lcao/Mulliken_Charge.cpp +++ b/ABACUS.develop/source/src_lcao/mulliken_charge.cpp @@ -10,7 +10,7 @@ ***********************************************************************/ //#include "../src_pw/global.h" -#include "Mulliken_Charge.h" +#include "mulliken_charge.h" #include "../src_lcao/local_orbital_charge.h" //#include "../src_lcao/sltk_grid_driver.h" #include "use_overlap_matrix.h" diff --git a/ABACUS.develop/source/src_lcao/Mulliken_Charge.h b/ABACUS.develop/source/src_lcao/mulliken_charge.h similarity index 96% rename from ABACUS.develop/source/src_lcao/Mulliken_Charge.h rename to ABACUS.develop/source/src_lcao/mulliken_charge.h index 8a244fdcd8..e2fc20f5f5 100644 --- a/ABACUS.develop/source/src_lcao/Mulliken_Charge.h +++ b/ABACUS.develop/source/src_lcao/mulliken_charge.h @@ -3,7 +3,7 @@ //#include "../src_pw/tools.h" #include "../src_pw/tools.h" -#include "use_overlap_table.h" +#include "ORB_gen_tables.h" #include "../src_global/sltk_grid_driver.h" #include "lcao_matrix.h" #include "lcao_matrix.h" diff --git a/ABACUS.develop/source/src_lcao/unkOverlap_lcao.cpp b/ABACUS.develop/source/src_lcao/unk_overlap_lcao.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/unkOverlap_lcao.cpp rename to ABACUS.develop/source/src_lcao/unk_overlap_lcao.cpp index d074b23b03..c345a02c41 100644 --- a/ABACUS.develop/source/src_lcao/unkOverlap_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/unk_overlap_lcao.cpp @@ -1,4 +1,4 @@ -#include "unkOverlap_lcao.h" +#include "unk_overlap_lcao.h" #include "../src_lcao/lcao_nnr.h" #include "ctime" #include "src_global/scalapack_connector.h" diff --git a/ABACUS.develop/source/src_lcao/unkOverlap_lcao.h b/ABACUS.develop/source/src_lcao/unk_overlap_lcao.h similarity index 100% rename from ABACUS.develop/source/src_lcao/unkOverlap_lcao.h rename to ABACUS.develop/source/src_lcao/unk_overlap_lcao.h diff --git a/ABACUS.develop/source/src_lcao/use_overlap_matrix.h b/ABACUS.develop/source/src_lcao/use_overlap_matrix.h index dc311f1bfd..973343a14a 100644 --- a/ABACUS.develop/source/src_lcao/use_overlap_matrix.h +++ b/ABACUS.develop/source/src_lcao/use_overlap_matrix.h @@ -5,7 +5,7 @@ #define USE_OVERLAP_MATRIX_H #include "../src_pw/tools.h" -#include "use_overlap_table.h" +#include "ORB_gen_tables.h" #include "../src_global/sltk_grid_driver.h" class Use_Overlap_Matrix diff --git a/ABACUS.develop/source/src_pw/berryphase.h b/ABACUS.develop/source/src_pw/berryphase.h index cd21383e51..e88210dfb4 100644 --- a/ABACUS.develop/source/src_pw/berryphase.h +++ b/ABACUS.develop/source/src_pw/berryphase.h @@ -2,8 +2,8 @@ #define BERRYPHASE -#include "../src_pw/unkOverlap_pw.h" -#include "../src_lcao/unkOverlap_lcao.h" +#include "../src_pw/unk_overlap_pw.h" +#include "../src_lcao/unk_overlap_lcao.h" diff --git a/ABACUS.develop/source/src_pw/energy.cpp b/ABACUS.develop/source/src_pw/energy.cpp index 5c88d36594..a6dc8eae71 100644 --- a/ABACUS.develop/source/src_pw/energy.cpp +++ b/ABACUS.develop/source/src_pw/energy.cpp @@ -8,10 +8,8 @@ #include "energy.h" #include "algorithms.h" #include "mymath.h" -//#include "../src_develop/src_siao/selinv.h" -#include "../src_lcao/Mulliken_Charge.h" +#include "../src_lcao/mulliken_charge.h" #include "../src_lcao/lcao_nnr.h" -//#include "../src_lcao/Mulliken_Charge.h" #include "../src_lcao/use_overlap_matrix.h" #include "../src_global/sltk_atom_arrange.h"//qifeng-2019-01-21 #include "../src_lcao/local_orbital_charge.h" diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.cpp b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.cpp index d2522eff4c..ebc6cc56f3 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.cpp +++ b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.cpp @@ -7,7 +7,7 @@ #include "pseudopot_cell_vnl.h" #include "tools.h" #include "wavefunc.h" -#include "../src_lcao/use_overlap_table.h" +#include "../src_lcao/ORB_gen_tables.h" pseudopot_cell_vnl::pseudopot_cell_vnl() { diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h index d1dfeededc..2b0af115d4 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h +++ b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h @@ -7,7 +7,7 @@ #include "tools.h" #include "pseudopot_cell_vl.h" -#include "../src_lcao/use_overlap_table.h" +#include "../src_lcao/ORB_gen_tables.h" //========================================================== // CLASS : diff --git a/ABACUS.develop/source/src_pw/unkOverlap_pw.cpp b/ABACUS.develop/source/src_pw/unk_overlap_pw.cpp similarity index 99% rename from ABACUS.develop/source/src_pw/unkOverlap_pw.cpp rename to ABACUS.develop/source/src_pw/unk_overlap_pw.cpp index 24b187ccdf..5becc9f52d 100644 --- a/ABACUS.develop/source/src_pw/unkOverlap_pw.cpp +++ b/ABACUS.develop/source/src_pw/unk_overlap_pw.cpp @@ -1,4 +1,4 @@ -#include "unkOverlap_pw.h" +#include "unk_overlap_pw.h" unkOverlap_pw::unkOverlap_pw() { diff --git a/ABACUS.develop/source/src_pw/unkOverlap_pw.h b/ABACUS.develop/source/src_pw/unk_overlap_pw.h similarity index 100% rename from ABACUS.develop/source/src_pw/unkOverlap_pw.h rename to ABACUS.develop/source/src_pw/unk_overlap_pw.h From 7f0cccc7c1d0aee5b9fdcbafa68dfda47ed2215f Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 10 Feb 2021 17:34:19 +0800 Subject: [PATCH 101/233] move lcao_orbitals.cpp to ORB_read.cpp, move numerical_nonlocal.cpp to ORB_nonlocal.cpp, move numerical_nonlocal_lm.cpp to ORB_nonlocal_lm.cpp, move numerical_orbital.cpp to ORB_atomic.cpp, and move numerical_orbital_lm.cpp to ORB_atomic_lm.cpp --- ABACUS.develop/source/Makefile.Objects | 10 +++++----- ABACUS.develop/source/input_conv.cpp | 2 +- ABACUS.develop/source/src_lcao/1 | 13 +++++++++++++ .../{numerical_orbital.cpp => ORB_atomic.cpp} | 2 +- .../src_lcao/{numerical_orbital.h => ORB_atomic.h} | 2 +- .../{numerical_orbital_lm.cpp => ORB_atomic_lm.cpp} | 4 ++-- .../{numerical_orbital_lm.h => ORB_atomic_lm.h} | 0 ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp | 2 +- .../{numerical_nonlocal.cpp => ORB_nonlocal.cpp} | 2 +- .../{numerical_nonlocal.h => ORB_nonlocal.h} | 2 +- ...umerical_nonlocal_lm.cpp => ORB_nonlocal_lm.cpp} | 2 +- .../{numerical_nonlocal_lm.h => ORB_nonlocal_lm.h} | 0 .../src_lcao/{lcao_orbitals.cpp => ORB_read.cpp} | 2 +- .../source/src_lcao/{lcao_orbitals.h => ORB_read.h} | 6 +++--- ABACUS.develop/source/src_lcao/cal_r_overlap_R.h | 4 ++-- ABACUS.develop/source/src_lcao/center2_orb-orb11.h | 2 +- ABACUS.develop/source/src_lcao/center2_orb-orb21.h | 2 +- ABACUS.develop/source/src_lcao/center2_orb-orb22.h | 2 +- ABACUS.develop/source/src_lcao/conv_coulomb_pot.h | 2 +- .../source/src_lcao/conv_coulomb_pot_k.cpp | 2 +- .../source/src_lcao/exx_abfs-abfs_index.cpp | 2 +- .../source/src_lcao/exx_abfs-abfs_index.h | 2 +- .../source/src_lcao/exx_abfs-construct_orbs.cpp | 2 +- .../source/src_lcao/exx_abfs-construct_orbs.h | 2 +- ABACUS.develop/source/src_lcao/exx_abfs-io.cpp | 2 +- ABACUS.develop/source/src_lcao/exx_abfs-io.h | 2 +- ABACUS.develop/source/src_lcao/exx_abfs-jle.cpp | 2 +- ABACUS.develop/source/src_lcao/exx_abfs-jle.h | 2 +- .../exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp | 2 +- .../source/src_lcao/exx_abfs-matrix_orbs11.cpp | 2 +- .../source/src_lcao/exx_abfs-matrix_orbs21.cpp | 2 +- .../source/src_lcao/exx_abfs-matrix_orbs22.cpp | 2 +- ABACUS.develop/source/src_lcao/exx_abfs-pca.h | 2 +- ABACUS.develop/source/src_lcao/exx_abfs.cpp | 2 +- ABACUS.develop/source/src_lcao/exx_abfs.h | 2 +- ABACUS.develop/source/src_lcao/exx_opt_orb.cpp | 4 ++-- ABACUS.develop/source/src_lcao/gint_gamma_env.cpp | 2 +- ABACUS.develop/source/src_lcao/gint_gamma_fvl.cpp | 2 +- ABACUS.develop/source/src_lcao/gint_gamma_mull.cpp | 2 +- ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp | 2 +- ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp | 2 +- ABACUS.develop/source/src_lcao/gint_k.cpp | 2 +- ABACUS.develop/source/src_lcao/gint_k.h | 2 +- ABACUS.develop/source/src_lcao/gint_k_rho.cpp | 2 +- ABACUS.develop/source/src_lcao/gint_k_vl.cpp | 2 +- ABACUS.develop/source/src_lcao/global_fp.h | 2 +- ABACUS.develop/source/src_lcao/grid_base.cpp | 2 +- ABACUS.develop/source/src_lcao/grid_base.h | 2 +- ABACUS.develop/source/src_lcao/grid_base_beta.h | 2 +- ABACUS.develop/source/src_lcao/grid_integral.cpp | 2 +- .../source/src_lcao/make_overlap_table.cpp | 2 +- ABACUS.develop/source/src_lcao/make_overlap_table.h | 12 ++++++------ ABACUS.develop/source/src_lcao/unk_overlap_lcao.h | 4 ++-- ABACUS.develop/source/src_pw/unitcell_pseudo.cpp | 2 +- 54 files changed, 79 insertions(+), 66 deletions(-) create mode 100644 ABACUS.develop/source/src_lcao/1 rename ABACUS.develop/source/src_lcao/{numerical_orbital.cpp => ORB_atomic.cpp} (98%) rename ABACUS.develop/source/src_lcao/{numerical_orbital.h => ORB_atomic.h} (98%) rename ABACUS.develop/source/src_lcao/{numerical_orbital_lm.cpp => ORB_atomic_lm.cpp} (99%) rename ABACUS.develop/source/src_lcao/{numerical_orbital_lm.h => ORB_atomic_lm.h} (100%) rename ABACUS.develop/source/src_lcao/{numerical_nonlocal.cpp => ORB_nonlocal.cpp} (99%) rename ABACUS.develop/source/src_lcao/{numerical_nonlocal.h => ORB_nonlocal.h} (98%) rename ABACUS.develop/source/src_lcao/{numerical_nonlocal_lm.cpp => ORB_nonlocal_lm.cpp} (99%) rename ABACUS.develop/source/src_lcao/{numerical_nonlocal_lm.h => ORB_nonlocal_lm.h} (100%) rename ABACUS.develop/source/src_lcao/{lcao_orbitals.cpp => ORB_read.cpp} (99%) rename ABACUS.develop/source/src_lcao/{lcao_orbitals.h => ORB_read.h} (94%) diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index bf4588d2d4..c90d4436ff 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -130,11 +130,11 @@ gint_k_rho.o\ gint_k_fvl.o\ grid_base.o\ grid_base_beta.o\ -lcao_orbitals.o\ -numerical_orbital.o\ -numerical_orbital_lm.o\ -numerical_nonlocal.o\ -numerical_nonlocal_lm.o\ +ORB_read.o\ +ORB_atomic.o\ +ORB_atomic_lm.o\ +ORB_nonlocal.o\ +ORB_nonlocal_lm.o\ local_orbital_wfc.o\ local_orbital_elec.o\ ELEC_cbands_k.o\ diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index 3b1539e431..9a38864b0c 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -6,7 +6,7 @@ #include "src_pw/optical.h" #include "src_lcao/force_lcao.h" #include "src_lcao/local_orbital_charge.h" -#include "src_lcao/lcao_orbitals.h" +#include "src_lcao/ORB_read.h" #include "src_pw/efield.h" #include "src_lcao/global_fp.h" diff --git a/ABACUS.develop/source/src_lcao/1 b/ABACUS.develop/source/src_lcao/1 new file mode 100644 index 0000000000..744097cb1d --- /dev/null +++ b/ABACUS.develop/source/src_lcao/1 @@ -0,0 +1,13 @@ +diff --git a/ABACUS.develop/source/src_lcao/grid_base.cpp b/ABACUS.develop/source/src_lcao/grid_base.cpp +index e7bbbb0..072abb9 100644 +--- a/ABACUS.develop/source/src_lcao/grid_base.cpp ++++ b/ABACUS.develop/source/src_lcao/grid_base.cpp +@@ -1,7 +1,7 @@ + #include "grid_integral.h" + #include "../src_pw/global.h" + #include "ylm.h" +-#include "lcao_orbitals.h" ++#include "ORB_read.h" + + #include "global_fp.h" // mohan add 2021-01-30 + diff --git a/ABACUS.develop/source/src_lcao/numerical_orbital.cpp b/ABACUS.develop/source/src_lcao/ORB_atomic.cpp similarity index 98% rename from ABACUS.develop/source/src_lcao/numerical_orbital.cpp rename to ABACUS.develop/source/src_lcao/ORB_atomic.cpp index 75c805d781..9d68cbfb44 100644 --- a/ABACUS.develop/source/src_lcao/numerical_orbital.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_atomic.cpp @@ -2,7 +2,7 @@ //AUTHOR : liaochen //DATE : 2008-11-12 //========================================================= -#include "numerical_orbital.h" +#include "ORB_atomic.h" Vector3 Numerical_Orbital::R1; Vector3 Numerical_Orbital::R2; diff --git a/ABACUS.develop/source/src_lcao/numerical_orbital.h b/ABACUS.develop/source/src_lcao/ORB_atomic.h similarity index 98% rename from ABACUS.develop/source/src_lcao/numerical_orbital.h rename to ABACUS.develop/source/src_lcao/ORB_atomic.h index ea64d84621..6f4e2defea 100644 --- a/ABACUS.develop/source/src_lcao/numerical_orbital.h +++ b/ABACUS.develop/source/src_lcao/ORB_atomic.h @@ -7,7 +7,7 @@ #define NUMERICAL_ORBITAL_H #include "../src_pw/tools.h" -#include "numerical_orbital_lm.h" +#include "ORB_atomic_lm.h" //========================================================= //CLASS Num_Orbital diff --git a/ABACUS.develop/source/src_lcao/numerical_orbital_lm.cpp b/ABACUS.develop/source/src_lcao/ORB_atomic_lm.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/numerical_orbital_lm.cpp rename to ABACUS.develop/source/src_lcao/ORB_atomic_lm.cpp index c7aac35b05..7a6d724c19 100644 --- a/ABACUS.develop/source/src_lcao/numerical_orbital_lm.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_atomic_lm.cpp @@ -2,10 +2,10 @@ //AUTHOR : liaochen, mohan //DATE : 2008-11-12 //========================================================= -#include "numerical_orbital_lm.h" +#include "ORB_atomic_lm.h" #include "src_global/sph_bessel_recursive.h" #include "src_global/lapack_connector.h" -#include +#include Numerical_Orbital_Lm::Numerical_Orbital_Lm() { diff --git a/ABACUS.develop/source/src_lcao/numerical_orbital_lm.h b/ABACUS.develop/source/src_lcao/ORB_atomic_lm.h similarity index 100% rename from ABACUS.develop/source/src_lcao/numerical_orbital_lm.h rename to ABACUS.develop/source/src_lcao/ORB_atomic_lm.h diff --git a/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp b/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp index c9b56739ce..c6041e61a3 100644 --- a/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp @@ -1,6 +1,6 @@ #include "ORB_gen_tables.h" #include "ylm.h" -#include "lcao_orbitals.h" +#include "ORB_read.h" #include "../src_pw/global.h" Use_Overlap_Table UOT; diff --git a/ABACUS.develop/source/src_lcao/numerical_nonlocal.cpp b/ABACUS.develop/source/src_lcao/ORB_nonlocal.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/numerical_nonlocal.cpp rename to ABACUS.develop/source/src_lcao/ORB_nonlocal.cpp index d5f06a709d..7d8f912ac8 100644 --- a/ABACUS.develop/source/src_lcao/numerical_nonlocal.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_nonlocal.cpp @@ -2,7 +2,7 @@ //AUTHOR : liaochen //DATE : 2008-03-04 //========================================================= -#include "numerical_nonlocal.h" +#include "ORB_nonlocal.h" Numerical_Nonlocal::Numerical_Nonlocal() { diff --git a/ABACUS.develop/source/src_lcao/numerical_nonlocal.h b/ABACUS.develop/source/src_lcao/ORB_nonlocal.h similarity index 98% rename from ABACUS.develop/source/src_lcao/numerical_nonlocal.h rename to ABACUS.develop/source/src_lcao/ORB_nonlocal.h index 012036c61a..308fa52ee8 100644 --- a/ABACUS.develop/source/src_lcao/numerical_nonlocal.h +++ b/ABACUS.develop/source/src_lcao/ORB_nonlocal.h @@ -6,7 +6,7 @@ #define NUMERICAL_NONLOCAL_H #include "../src_pw/tools.h" -#include "numerical_nonlocal_lm.h" +#include "ORB_nonlocal_lm.h" //========================================================= //CLASS Numerical_Nonlocal //Note : contain nonlocal ps(:pseudopotential) information diff --git a/ABACUS.develop/source/src_lcao/numerical_nonlocal_lm.cpp b/ABACUS.develop/source/src_lcao/ORB_nonlocal_lm.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/numerical_nonlocal_lm.cpp rename to ABACUS.develop/source/src_lcao/ORB_nonlocal_lm.cpp index 52283bd3fd..d693f7a6da 100644 --- a/ABACUS.develop/source/src_lcao/numerical_nonlocal_lm.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_nonlocal_lm.cpp @@ -2,7 +2,7 @@ //AUTHOR : liaochen //DATE : 2008-03-04 //========================================================= -#include "numerical_nonlocal_lm.h" +#include "ORB_nonlocal_lm.h" #include "../src_pw/global.h" Numerical_Nonlocal_Lm::Numerical_Nonlocal_Lm() diff --git a/ABACUS.develop/source/src_lcao/numerical_nonlocal_lm.h b/ABACUS.develop/source/src_lcao/ORB_nonlocal_lm.h similarity index 100% rename from ABACUS.develop/source/src_lcao/numerical_nonlocal_lm.h rename to ABACUS.develop/source/src_lcao/ORB_nonlocal_lm.h diff --git a/ABACUS.develop/source/src_lcao/lcao_orbitals.cpp b/ABACUS.develop/source/src_lcao/ORB_read.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/lcao_orbitals.cpp rename to ABACUS.develop/source/src_lcao/ORB_read.cpp index ab34eadbf6..897e446906 100644 --- a/ABACUS.develop/source/src_lcao/lcao_orbitals.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_read.cpp @@ -1,4 +1,4 @@ -#include "lcao_orbitals.h" +#include "ORB_read.h" #include "../src_pw/global.h" // only use ucell.atoms[it] #include // Peize Lin fix bug about strcmp 2016-08-02 diff --git a/ABACUS.develop/source/src_lcao/lcao_orbitals.h b/ABACUS.develop/source/src_lcao/ORB_read.h similarity index 94% rename from ABACUS.develop/source/src_lcao/lcao_orbitals.h rename to ABACUS.develop/source/src_lcao/ORB_read.h index 073956e2b4..3adccb2eff 100644 --- a/ABACUS.develop/source/src_lcao/lcao_orbitals.h +++ b/ABACUS.develop/source/src_lcao/ORB_read.h @@ -7,9 +7,9 @@ #define LCAO_ORBITALS_H #include "../src_pw/tools.h" -#include "numerical_orbital.h" -#include "numerical_orbital_lm.h" -#include "numerical_nonlocal.h" +#include "ORB_atomic.h" +#include "ORB_atomic_lm.h" +#include "ORB_nonlocal.h" class LCAO_Orbitals { diff --git a/ABACUS.develop/source/src_lcao/cal_r_overlap_R.h b/ABACUS.develop/source/src_lcao/cal_r_overlap_R.h index f8dbfc6274..3f5e1abd11 100644 --- a/ABACUS.develop/source/src_lcao/cal_r_overlap_R.h +++ b/ABACUS.develop/source/src_lcao/cal_r_overlap_R.h @@ -14,8 +14,8 @@ using std::set; #include "../src_lcao/make_overlap_table.h" #include "../src_lcao/make_gaunt_table.h" -#include "../src_lcao/numerical_orbital_lm.h" -#include "../src_lcao/lcao_orbitals.h" +#include "../src_lcao/ORB_atomic_lm.h" +#include "../src_lcao/ORB_read.h" #include "../src_global/vector3.h" #include "../src_lcao/ylm.h" #include "../src_lcao/global_fp.h" diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb11.h b/ABACUS.develop/source/src_lcao/center2_orb-orb11.h index e48db6b7f8..d32567a3cc 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb11.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb11.h @@ -17,7 +17,7 @@ using std::set; #include "src_lcao/make_overlap_table.h" #include "src_lcao/make_gaunt_table.h" -#include "src_lcao/numerical_orbital_lm.h" +#include "src_lcao/ORB_atomic_lm.h" #include "src_global/vector3.h" class Center2_Orb::Orb11 diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb21.h b/ABACUS.develop/source/src_lcao/center2_orb-orb21.h index c60d388a15..410afd3a00 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb21.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb21.h @@ -18,7 +18,7 @@ using std::set; #include "src_lcao/make_overlap_table.h" #include "src_lcao/make_gaunt_table.h" -#include "src_lcao/numerical_orbital_lm.h" +#include "src_lcao/ORB_atomic_lm.h" #include "src_global/vector3.h" class Center2_Orb::Orb21 diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb22.h b/ABACUS.develop/source/src_lcao/center2_orb-orb22.h index 646b3876fc..532721b141 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb22.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb22.h @@ -18,7 +18,7 @@ using std::set; #include "src_lcao/make_overlap_table.h" #include "src_lcao/make_gaunt_table.h" -#include "src_lcao/numerical_orbital_lm.h" +#include "src_lcao/ORB_atomic_lm.h" #include "src_global/vector3.h" class Center2_Orb::Orb22 diff --git a/ABACUS.develop/source/src_lcao/conv_coulomb_pot.h b/ABACUS.develop/source/src_lcao/conv_coulomb_pot.h index c856b207e7..14fe75ef24 100644 --- a/ABACUS.develop/source/src_lcao/conv_coulomb_pot.h +++ b/ABACUS.develop/source/src_lcao/conv_coulomb_pot.h @@ -4,7 +4,7 @@ #include using std::vector; -#include "numerical_orbital_lm.h" +#include "ORB_atomic_lm.h" // out of conv_coulomb_pot.size(), imagine all rab(i.e. dr) are equal to rab[conv_coulomb_pot.size()-1] class Conv_Coulomb_Pot diff --git a/ABACUS.develop/source/src_lcao/conv_coulomb_pot_k.cpp b/ABACUS.develop/source/src_lcao/conv_coulomb_pot_k.cpp index e5b65762b7..9d4c4a237c 100644 --- a/ABACUS.develop/source/src_lcao/conv_coulomb_pot_k.cpp +++ b/ABACUS.develop/source/src_lcao/conv_coulomb_pot_k.cpp @@ -1,6 +1,6 @@ #include "conv_coulomb_pot_k.h" #include "src_global/constants.h" -#include "src_lcao/numerical_orbital_lm.h" +#include "src_lcao/ORB_atomic_lm.h" std::vector Conv_Coulomb_Pot_K::cal_psi_ccp( const std::vector & psif ) { diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-abfs_index.cpp b/ABACUS.develop/source/src_lcao/exx_abfs-abfs_index.cpp index aab2c404c8..db383d63e2 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-abfs_index.cpp +++ b/ABACUS.develop/source/src_lcao/exx_abfs-abfs_index.cpp @@ -1,5 +1,5 @@ #include "exx_abfs-abfs_index.h" -#include "lcao_orbitals.h" +#include "ORB_read.h" Element_Basis_Index::Range Exx_Abfs::Abfs_Index::construct_range( const LCAO_Orbitals &orb ) diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-abfs_index.h b/ABACUS.develop/source/src_lcao/exx_abfs-abfs_index.h index e44344af3b..ff36084333 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-abfs_index.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs-abfs_index.h @@ -5,7 +5,7 @@ #include #include "src_global/element_basis_index.h" -#include "src_lcao/numerical_orbital_lm.h" +#include "src_lcao/ORB_atomic_lm.h" class LCAO_Orbitals; diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-construct_orbs.cpp b/ABACUS.develop/source/src_lcao/exx_abfs-construct_orbs.cpp index 2488cc3e1f..cad4a3a273 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-construct_orbs.cpp +++ b/ABACUS.develop/source/src_lcao/exx_abfs-construct_orbs.cpp @@ -1,7 +1,7 @@ #include "exx_abfs-construct_orbs.h" #include "exx_abfs-pca.h" -#include "src_lcao/lcao_orbitals.h" +#include "src_lcao/ORB_read.h" #include "src_global/gram_schmidt_orth.h" #include "src_global/gram_schmidt_orth-inl.h" diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-construct_orbs.h b/ABACUS.develop/source/src_lcao/exx_abfs-construct_orbs.h index 85b82346c2..f62e9d38af 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-construct_orbs.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs-construct_orbs.h @@ -4,7 +4,7 @@ #include "exx_abfs.h" #include -#include "numerical_orbital_lm.h" +#include "ORB_atomic_lm.h" class LCAO_Orbitals; diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-io.cpp b/ABACUS.develop/source/src_lcao/exx_abfs-io.cpp index 8264c60d69..d390bcb293 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-io.cpp +++ b/ABACUS.develop/source/src_lcao/exx_abfs-io.cpp @@ -5,7 +5,7 @@ #include "exx_abfs-jle.h" #include "exx_abfs-abfs_index.h" #include "src_pw/global.h" -#include "src_lcao/lcao_orbitals.h" +#include "src_lcao/ORB_read.h" #include "src_global/global_function.h" diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-io.h b/ABACUS.develop/source/src_lcao/exx_abfs-io.h index ae3a9e87c1..cbe6feca28 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-io.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs-io.h @@ -5,7 +5,7 @@ #include #include -#include "src_lcao/numerical_orbital_lm.h" +#include "src_lcao/ORB_atomic_lm.h" #include "src_global/matrix.h" #include "src_global/element_basis_index.h" diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-jle.cpp b/ABACUS.develop/source/src_lcao/exx_abfs-jle.cpp index 3dd461f827..80934983d0 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-jle.cpp +++ b/ABACUS.develop/source/src_lcao/exx_abfs-jle.cpp @@ -1,7 +1,7 @@ #include "exx_abfs-jle.h" #include "../src_pw/global.h" -#include "lcao_orbitals.h" +#include "ORB_read.h" #include "../src_global/global_function.h" #include "../src_global/mathzone.h" diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-jle.h b/ABACUS.develop/source/src_lcao/exx_abfs-jle.h index f1441a1b25..8c23e3a4d0 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-jle.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs-jle.h @@ -4,7 +4,7 @@ #include "exx_abfs.h" #include -#include "numerical_orbital_lm.h" +#include "ORB_atomic_lm.h" class Exx_Abfs::Jle { diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp b/ABACUS.develop/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp index de8150b10c..bb7eb2a247 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp +++ b/ABACUS.develop/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp @@ -1,7 +1,7 @@ #include "exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h" #include "../src_pw/global.h" -#include "lcao_orbitals.h" +#include "ORB_read.h" #include "ylm.h" #include "../src_external/src_test/test_function.h" // Peize Lin test 2016-04-05 diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs11.cpp b/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs11.cpp index baaa804c4b..52ce03b3f3 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs11.cpp +++ b/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs11.cpp @@ -3,7 +3,7 @@ #include #include #include "src_pw/global.h" -#include "src_lcao/lcao_orbitals.h" +#include "src_lcao/ORB_read.h" #include "src_lcao/ylm.h" #include "src_global/global_function.h" diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs21.cpp b/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs21.cpp index 6258b2acfe..008e5a285b 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs21.cpp +++ b/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs21.cpp @@ -6,7 +6,7 @@ #include #include #include "src_pw/global.h" -#include "src_lcao/lcao_orbitals.h" +#include "src_lcao/ORB_read.h" #include "src_lcao/ylm.h" #include // Peize Lin test diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs22.cpp b/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs22.cpp index adffdcdc62..462c6b5f78 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs22.cpp +++ b/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs22.cpp @@ -4,7 +4,7 @@ #include "exx_abfs-abfs_index.h" #include "src_pw/global.h" -#include "src_lcao/lcao_orbitals.h" +#include "src_lcao/ORB_read.h" #include "src_lcao/ylm.h" #include "../src_external/src_test/test_function.h" // Peize Lin test 2016-04-05 diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-pca.h b/ABACUS.develop/source/src_lcao/exx_abfs-pca.h index b19406ea10..eafab3e480 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-pca.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs-pca.h @@ -2,7 +2,7 @@ #define EXX_ABFS_PCA_H #include "exx_abfs.h" -#include "src_lcao/numerical_orbital_lm.h" +#include "src_lcao/ORB_atomic_lm.h" #include "src_global/matrix.h" #include "src_global/element_basis_index.h" #include diff --git a/ABACUS.develop/source/src_lcao/exx_abfs.cpp b/ABACUS.develop/source/src_lcao/exx_abfs.cpp index 569bdc5a4a..5c21df8320 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs.cpp +++ b/ABACUS.develop/source/src_lcao/exx_abfs.cpp @@ -10,7 +10,7 @@ #include "exx_abfs-matrix_orbs21.h" #include "exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h" -#include "lcao_orbitals.h" +#include "ORB_read.h" #include "conv_coulomb_pot.h" #include "conv_coulomb_pot-inl.h" diff --git a/ABACUS.develop/source/src_lcao/exx_abfs.h b/ABACUS.develop/source/src_lcao/exx_abfs.h index 3db9932fa7..8a0587268a 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs.h @@ -7,7 +7,7 @@ using std::vector; using std::map; #include -#include "src_lcao/numerical_orbital_lm.h" +#include "src_lcao/ORB_atomic_lm.h" #include "src_global/element_basis_index.h" #include "src_global/matrix.h" #include "src_global/vector3.h" diff --git a/ABACUS.develop/source/src_lcao/exx_opt_orb.cpp b/ABACUS.develop/source/src_lcao/exx_opt_orb.cpp index b6ab65e532..b9f4fa8799 100644 --- a/ABACUS.develop/source/src_lcao/exx_opt_orb.cpp +++ b/ABACUS.develop/source/src_lcao/exx_opt_orb.cpp @@ -1,12 +1,12 @@ #include "exx_opt_orb.h" #include "src_pw/global.h" -#include "src_lcao/numerical_orbital_lm.h" +#include "src_lcao/ORB_atomic_lm.h" #include "src_lcao/exx_abfs.h" #include "src_lcao/exx_abfs-abfs_index.h" #include "src_lcao/exx_abfs-construct_orbs.h" #include "src_lcao/exx_abfs-inverse_matrix_double.h" #include "src_lcao/exx_abfs-jle.h" -#include "src_lcao/lcao_orbitals.h" +#include "src_lcao/ORB_read.h" #include "src_lcao/exx_abfs-matrix_orbs11.h" #include "src_lcao/exx_abfs-matrix_orbs21.h" #include "src_lcao/exx_abfs-matrix_orbs22.h" diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_env.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_env.cpp index 0e9d386956..23a2f1209d 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_env.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_env.cpp @@ -1,6 +1,6 @@ #include "gint_gamma.h" #include "grid_technique.h" -#include "lcao_orbitals.h" +#include "ORB_read.h" #include "../src_pw/global.h" void Gint_Gamma::cal_env(const double* wfc, double* rho) diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_fvl.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_fvl.cpp index 26aa0880ed..df1d2edfcd 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_fvl.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_fvl.cpp @@ -1,6 +1,6 @@ #include "gint_gamma.h" #include "grid_technique.h" -#include "lcao_orbitals.h" +#include "ORB_read.h" #include "../src_pw/global.h" #include "src_global/blas_connector.h" diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_mull.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_mull.cpp index 1a8d4845f6..8fdde578e0 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_mull.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_mull.cpp @@ -1,6 +1,6 @@ #include "gint_gamma.h" #include "grid_technique.h" -#include "lcao_orbitals.h" +#include "ORB_read.h" #include "../src_pw/global.h" #include "global_fp.h" // mohan add 2021-01-30 diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp index dfa4643b06..5925bb3c3f 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp @@ -1,6 +1,6 @@ #include "gint_gamma.h" #include "grid_technique.h" -#include "lcao_orbitals.h" +#include "ORB_read.h" #include "../src_pw/global.h" #include "src_global/blas_connector.h" #include diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp index 522411484e..c4d7687d77 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp @@ -1,6 +1,6 @@ #include "gint_gamma.h" #include "grid_technique.h" -#include "lcao_orbitals.h" +#include "ORB_read.h" #include "../src_pw/global.h" #include "src_global/blas_connector.h" #include diff --git a/ABACUS.develop/source/src_lcao/gint_k.cpp b/ABACUS.develop/source/src_lcao/gint_k.cpp index 33f2a9d0df..72a8af14f6 100644 --- a/ABACUS.develop/source/src_lcao/gint_k.cpp +++ b/ABACUS.develop/source/src_lcao/gint_k.cpp @@ -1,7 +1,7 @@ #include "../src_pw/tools.h" #include "gint_k.h" #include "lcao_nnr.h" -#include "lcao_orbitals.h" +#include "ORB_read.h" #include "grid_technique.h" #include "ylm.h" #include "../src_pw/global.h" diff --git a/ABACUS.develop/source/src_lcao/gint_k.h b/ABACUS.develop/source/src_lcao/gint_k.h index f85c061ad7..efeda3bf1a 100644 --- a/ABACUS.develop/source/src_lcao/gint_k.h +++ b/ABACUS.develop/source/src_lcao/gint_k.h @@ -2,7 +2,7 @@ #define GINT_K_H #include "gint_k_init.h" -#include "numerical_orbital_lm.h" +#include "ORB_atomic_lm.h" #include "grid_technique.h" //#include "lcao_matrix.h" diff --git a/ABACUS.develop/source/src_lcao/gint_k_rho.cpp b/ABACUS.develop/source/src_lcao/gint_k_rho.cpp index ded706f8ff..57ae39db5f 100644 --- a/ABACUS.develop/source/src_lcao/gint_k_rho.cpp +++ b/ABACUS.develop/source/src_lcao/gint_k_rho.cpp @@ -1,7 +1,7 @@ #include "../src_pw/tools.h" #include "gint_k.h" #include "lcao_nnr.h" -#include "lcao_orbitals.h" +#include "ORB_read.h" #include "grid_technique.h" #include "ylm.h" #include "../src_pw/global.h" diff --git a/ABACUS.develop/source/src_lcao/gint_k_vl.cpp b/ABACUS.develop/source/src_lcao/gint_k_vl.cpp index 1028a11f15..a994e5e66c 100644 --- a/ABACUS.develop/source/src_lcao/gint_k_vl.cpp +++ b/ABACUS.develop/source/src_lcao/gint_k_vl.cpp @@ -1,7 +1,7 @@ #include "../src_pw/tools.h" #include "gint_k.h" #include "lcao_nnr.h" -#include "lcao_orbitals.h" +#include "ORB_read.h" #include "grid_technique.h" #include "ylm.h" #include "../src_pw/global.h" diff --git a/ABACUS.develop/source/src_lcao/global_fp.h b/ABACUS.develop/source/src_lcao/global_fp.h index f077337cb6..b1b68de5e9 100644 --- a/ABACUS.develop/source/src_lcao/global_fp.h +++ b/ABACUS.develop/source/src_lcao/global_fp.h @@ -10,7 +10,7 @@ #include "src_lcao/lcao_matrix.h" #include "src_lcao/use_overlap_matrix.h" #include "src_lcao/use_hamilt_matrix.h" -#include "src_lcao/lcao_orbitals.h" +#include "src_lcao/ORB_read.h" #include "src_lcao/ORB_gen_tables.h" #include "src_parallel/subgrid_oper.h" #include "src_lcao/exx_lcao.h" diff --git a/ABACUS.develop/source/src_lcao/grid_base.cpp b/ABACUS.develop/source/src_lcao/grid_base.cpp index e7bbbb0b2e..072abb9d8d 100644 --- a/ABACUS.develop/source/src_lcao/grid_base.cpp +++ b/ABACUS.develop/source/src_lcao/grid_base.cpp @@ -1,7 +1,7 @@ #include "grid_integral.h" #include "../src_pw/global.h" #include "ylm.h" -#include "lcao_orbitals.h" +#include "ORB_read.h" #include "global_fp.h" // mohan add 2021-01-30 diff --git a/ABACUS.develop/source/src_lcao/grid_base.h b/ABACUS.develop/source/src_lcao/grid_base.h index 9fdeaee558..a968b551a9 100644 --- a/ABACUS.develop/source/src_lcao/grid_base.h +++ b/ABACUS.develop/source/src_lcao/grid_base.h @@ -6,7 +6,7 @@ #define GRID_BASE_H #include "../src_pw/tools.h" -#include "numerical_orbital_lm.h" +#include "ORB_atomic_lm.h" class Grid_Base { diff --git a/ABACUS.develop/source/src_lcao/grid_base_beta.h b/ABACUS.develop/source/src_lcao/grid_base_beta.h index d1566feebb..3e5c8cc2c5 100644 --- a/ABACUS.develop/source/src_lcao/grid_base_beta.h +++ b/ABACUS.develop/source/src_lcao/grid_base_beta.h @@ -6,7 +6,7 @@ #define GRID_BASE_BETA_H #include "../src_pw/tools.h" -#include "numerical_orbital_lm.h" +#include "ORB_atomic_lm.h" // this class is inherited by Grid_Integral_Beta.h // this class provides basic Grid operation and the diff --git a/ABACUS.develop/source/src_lcao/grid_integral.cpp b/ABACUS.develop/source/src_lcao/grid_integral.cpp index 7f4c865077..5f9529a0ee 100644 --- a/ABACUS.develop/source/src_lcao/grid_integral.cpp +++ b/ABACUS.develop/source/src_lcao/grid_integral.cpp @@ -1,7 +1,7 @@ #include "grid_integral.h" #include "../src_pw/global.h" #include "ylm.h" -#include "lcao_orbitals.h" +#include "ORB_read.h" #include "global_fp.h" // mohan add 2021-01-30 diff --git a/ABACUS.develop/source/src_lcao/make_overlap_table.cpp b/ABACUS.develop/source/src_lcao/make_overlap_table.cpp index 022560d85a..e8e8e66670 100644 --- a/ABACUS.develop/source/src_lcao/make_overlap_table.cpp +++ b/ABACUS.develop/source/src_lcao/make_overlap_table.cpp @@ -1,5 +1,5 @@ #include "make_overlap_table.h" -#include "lcao_orbitals.h" +#include "ORB_read.h" #include #include "exx_abfs.h" diff --git a/ABACUS.develop/source/src_lcao/make_overlap_table.h b/ABACUS.develop/source/src_lcao/make_overlap_table.h index 3d6477f599..8e80ab3ceb 100644 --- a/ABACUS.develop/source/src_lcao/make_overlap_table.h +++ b/ABACUS.develop/source/src_lcao/make_overlap_table.h @@ -6,12 +6,12 @@ #define MAKE_OVERLAP_TABLE_H #include "src_pw/tools.h" -#include "src_lcao/numerical_orbital.h" -#include "src_lcao/numerical_orbital_lm.h" -#include "src_lcao/numerical_nonlocal.h" -#include "src_lcao/numerical_nonlocal_lm.h" -#include "src_lcao/make_gaunt_table.h" -#include "src_lcao/center2_orb.h" +#include "ORB_atomic.h" +#include "ORB_atomic_lm.h" +#include "ORB_nonlocal.h" +#include "ORB_nonlocal_lm.h" +#include "make_gaunt_table.h" +#include "center2_orb.h" #include "src_global/sph_bessel_recursive.h" #include diff --git a/ABACUS.develop/source/src_lcao/unk_overlap_lcao.h b/ABACUS.develop/source/src_lcao/unk_overlap_lcao.h index a68029d66e..c8f828eb56 100644 --- a/ABACUS.develop/source/src_lcao/unk_overlap_lcao.h +++ b/ABACUS.develop/source/src_lcao/unk_overlap_lcao.h @@ -14,8 +14,8 @@ using std::set; #include "../src_lcao/make_overlap_table.h" #include "../src_lcao/make_gaunt_table.h" -#include "../src_lcao/numerical_orbital_lm.h" -#include "../src_lcao/lcao_orbitals.h" +#include "../src_lcao/ORB_atomic_lm.h" +#include "../src_lcao/ORB_read.h" #include "../src_global/vector3.h" #include "../src_lcao/ylm.h" diff --git a/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp b/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp index 4f42e7de90..4a38c3fe23 100644 --- a/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp +++ b/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp @@ -3,7 +3,7 @@ // DATE : 2008-11-10 //========================================================== #include "unitcell_pseudo.h" -#include "../src_lcao/lcao_orbitals.h" // to use 'ORB' -- mohan 2021-01-30 +#include "../src_lcao/ORB_read.h" // to use 'ORB' -- mohan 2021-01-30 #include "global.h" #include // Peize Lin fix bug about strcmp 2016-08-02 From a355bf6224f67315e2ea11a2153f9a263d1e2d87 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 10 Feb 2021 17:43:29 +0800 Subject: [PATCH 102/233] move make_overlap_table.cpp to ORB_radial_table.cpp, move make_gaunt_table.cpp to ORB_gaunt_table.cpp --- ABACUS.develop/source/Makefile.Objects | 6 +++--- .../src_test/src_lcao/make_gaunt_table-unittest.h | 4 ++-- .../src_lcao/{make_gaunt_table.cpp => ORB_gaunt_table.cpp} | 2 +- .../src_lcao/{make_gaunt_table.h => ORB_gaunt_table.h} | 0 ABACUS.develop/source/src_lcao/ORB_gen_tables.h | 4 ++-- .../{make_overlap_table.cpp => ORB_radial_table.cpp} | 2 +- .../src_lcao/{make_overlap_table.h => ORB_radial_table.h} | 2 +- ABACUS.develop/source/src_lcao/cal_r_overlap_R.h | 4 ++-- ABACUS.develop/source/src_lcao/center2_orb-orb11.h | 4 ++-- ABACUS.develop/source/src_lcao/center2_orb-orb21.h | 4 ++-- ABACUS.develop/source/src_lcao/center2_orb-orb22.h | 4 ++-- .../source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h | 4 ++-- ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs11.h | 4 ++-- ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs21.h | 4 ++-- ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs22.h | 4 ++-- ABACUS.develop/source/src_lcao/unk_overlap_lcao.h | 4 ++-- 16 files changed, 28 insertions(+), 28 deletions(-) rename ABACUS.develop/source/src_lcao/{make_gaunt_table.cpp => ORB_gaunt_table.cpp} (99%) rename ABACUS.develop/source/src_lcao/{make_gaunt_table.h => ORB_gaunt_table.h} (100%) rename ABACUS.develop/source/src_lcao/{make_overlap_table.cpp => ORB_radial_table.cpp} (99%) rename ABACUS.develop/source/src_lcao/{make_overlap_table.h => ORB_radial_table.h} (99%) diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index c90d4436ff..f3865ad9f0 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -105,9 +105,6 @@ sltk_atom_arrange.o\ sltk_atom.o\ sltk_adjacent_set.o\ sltk_atom_input.o\ -make_gaunt_table.o\ -make_overlap_table.o\ -ORB_gen_tables.o\ use_overlap_matrix.o\ use_hamilt_matrix.o\ build_st_pw.o\ @@ -135,6 +132,9 @@ ORB_atomic.o\ ORB_atomic_lm.o\ ORB_nonlocal.o\ ORB_nonlocal_lm.o\ +ORB_gaunt_table.o\ +ORB_radial_table.o\ +ORB_gen_tables.o\ local_orbital_wfc.o\ local_orbital_elec.o\ ELEC_cbands_k.o\ diff --git a/ABACUS.develop/source/src_external/src_test/src_lcao/make_gaunt_table-unittest.h b/ABACUS.develop/source/src_external/src_test/src_lcao/make_gaunt_table-unittest.h index 517b08a7ed..c1b0acfc09 100644 --- a/ABACUS.develop/source/src_external/src_test/src_lcao/make_gaunt_table-unittest.h +++ b/ABACUS.develop/source/src_external/src_test/src_lcao/make_gaunt_table-unittest.h @@ -6,7 +6,7 @@ #ifndef MAKE_GAUNT_TABLE_UNITTEST_H #define MAKE_GAUNT_TABLE_UNITTEST_H -#include "src_lcao/make_gaunt_table.h" +#include "src_lcao/ORB_gaunt_table.h" static void cout_MGT ( const Make_Gaunt_Table & MGT, const int Lmax ) { @@ -43,4 +43,4 @@ static void cout_MGT ( const Make_Gaunt_Table & MGT, const int Lmax ) } } } -#endif \ No newline at end of file +#endif diff --git a/ABACUS.develop/source/src_lcao/make_gaunt_table.cpp b/ABACUS.develop/source/src_lcao/ORB_gaunt_table.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/make_gaunt_table.cpp rename to ABACUS.develop/source/src_lcao/ORB_gaunt_table.cpp index ed6a1b65f4..5a3ce0c5b9 100644 --- a/ABACUS.develop/source/src_lcao/make_gaunt_table.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_gaunt_table.cpp @@ -1,4 +1,4 @@ -#include "make_gaunt_table.h" +#include "ORB_gaunt_table.h" Make_Gaunt_Table::Make_Gaunt_Table(){} Make_Gaunt_Table::~Make_Gaunt_Table(){} diff --git a/ABACUS.develop/source/src_lcao/make_gaunt_table.h b/ABACUS.develop/source/src_lcao/ORB_gaunt_table.h similarity index 100% rename from ABACUS.develop/source/src_lcao/make_gaunt_table.h rename to ABACUS.develop/source/src_lcao/ORB_gaunt_table.h diff --git a/ABACUS.develop/source/src_lcao/ORB_gen_tables.h b/ABACUS.develop/source/src_lcao/ORB_gen_tables.h index 989bf76601..159291a98f 100644 --- a/ABACUS.develop/source/src_lcao/ORB_gen_tables.h +++ b/ABACUS.develop/source/src_lcao/ORB_gen_tables.h @@ -6,8 +6,8 @@ #define USE_OVERLAP_TABLE_H #include "../src_pw/tools.h" -#include "make_overlap_table.h" -#include "make_gaunt_table.h" +#include "ORB_radial_table.h" +#include "ORB_gaunt_table.h" #include "ylm.h" class Use_Overlap_Table diff --git a/ABACUS.develop/source/src_lcao/make_overlap_table.cpp b/ABACUS.develop/source/src_lcao/ORB_radial_table.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/make_overlap_table.cpp rename to ABACUS.develop/source/src_lcao/ORB_radial_table.cpp index e8e8e66670..5557614345 100644 --- a/ABACUS.develop/source/src_lcao/make_overlap_table.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_radial_table.cpp @@ -1,4 +1,4 @@ -#include "make_overlap_table.h" +#include "ORB_radial_table.h" #include "ORB_read.h" #include diff --git a/ABACUS.develop/source/src_lcao/make_overlap_table.h b/ABACUS.develop/source/src_lcao/ORB_radial_table.h similarity index 99% rename from ABACUS.develop/source/src_lcao/make_overlap_table.h rename to ABACUS.develop/source/src_lcao/ORB_radial_table.h index 8e80ab3ceb..6bb5143040 100644 --- a/ABACUS.develop/source/src_lcao/make_overlap_table.h +++ b/ABACUS.develop/source/src_lcao/ORB_radial_table.h @@ -10,7 +10,7 @@ #include "ORB_atomic_lm.h" #include "ORB_nonlocal.h" #include "ORB_nonlocal_lm.h" -#include "make_gaunt_table.h" +#include "ORB_gaunt_table.h" #include "center2_orb.h" #include "src_global/sph_bessel_recursive.h" diff --git a/ABACUS.develop/source/src_lcao/cal_r_overlap_R.h b/ABACUS.develop/source/src_lcao/cal_r_overlap_R.h index 3f5e1abd11..b20ee6d31a 100644 --- a/ABACUS.develop/source/src_lcao/cal_r_overlap_R.h +++ b/ABACUS.develop/source/src_lcao/cal_r_overlap_R.h @@ -12,8 +12,8 @@ using std::set; #include "../src_lcao/center2_orb-orb11.h" #include "../src_lcao/center2_orb-orb21.h" -#include "../src_lcao/make_overlap_table.h" -#include "../src_lcao/make_gaunt_table.h" +#include "../src_lcao/ORB_radial_table.h" +#include "../src_lcao/ORB_gaunt_table.h" #include "../src_lcao/ORB_atomic_lm.h" #include "../src_lcao/ORB_read.h" #include "../src_global/vector3.h" diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb11.h b/ABACUS.develop/source/src_lcao/center2_orb-orb11.h index d32567a3cc..4015a6388e 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb11.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb11.h @@ -15,8 +15,8 @@ using std::set; #include "center2_orb.h" -#include "src_lcao/make_overlap_table.h" -#include "src_lcao/make_gaunt_table.h" +#include "src_lcao/ORB_radial_table.h" +#include "src_lcao/ORB_gaunt_table.h" #include "src_lcao/ORB_atomic_lm.h" #include "src_global/vector3.h" diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb21.h b/ABACUS.develop/source/src_lcao/center2_orb-orb21.h index 410afd3a00..955599579e 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb21.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb21.h @@ -16,8 +16,8 @@ using std::set; #include "center2_orb.h" #include "center2_orb-orb11.h" -#include "src_lcao/make_overlap_table.h" -#include "src_lcao/make_gaunt_table.h" +#include "src_lcao/ORB_radial_table.h" +#include "src_lcao/ORB_gaunt_table.h" #include "src_lcao/ORB_atomic_lm.h" #include "src_global/vector3.h" diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb22.h b/ABACUS.develop/source/src_lcao/center2_orb-orb22.h index 532721b141..2bb5b28ec4 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb22.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb22.h @@ -16,8 +16,8 @@ using std::set; #include "center2_orb.h" #include "center2_orb-orb21.h" -#include "src_lcao/make_overlap_table.h" -#include "src_lcao/make_gaunt_table.h" +#include "src_lcao/ORB_radial_table.h" +#include "src_lcao/ORB_gaunt_table.h" #include "src_lcao/ORB_atomic_lm.h" #include "src_global/vector3.h" diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h b/ABACUS.develop/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h index c24b2371a7..3abca01ab8 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h @@ -9,8 +9,8 @@ using std::map; using std::set; #include "exx_abfs.h" -#include "make_overlap_table.h" -#include "make_gaunt_table.h" +#include "ORB_radial_table.h" +#include "ORB_gaunt_table.h" #include "center2_orb-orb22.h" class LCAO_Orbitals; diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs11.h b/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs11.h index 1707e5151f..5292e00c3b 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs11.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs11.h @@ -9,8 +9,8 @@ using std::map; using std::set; #include "exx_abfs.h" -#include "make_overlap_table.h" -#include "make_gaunt_table.h" +#include "ORB_radial_table.h" +#include "ORB_gaunt_table.h" #include "center2_orb-orb11.h" class LCAO_Orbitals; diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs21.h b/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs21.h index f6eac7229d..6a2f3dfa08 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs21.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs21.h @@ -14,8 +14,8 @@ using std::map; using std::set; #include "exx_abfs.h" -#include "make_overlap_table.h" -#include "make_gaunt_table.h" +#include "ORB_radial_table.h" +#include "ORB_gaunt_table.h" #include "center2_orb-orb21.h" class LCAO_Orbitals; diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs22.h b/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs22.h index ff5f045140..67c32c2d78 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs22.h +++ b/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs22.h @@ -5,8 +5,8 @@ using std::map; #include "exx_abfs.h" -#include "make_overlap_table.h" -#include "make_gaunt_table.h" +#include "ORB_radial_table.h" +#include "ORB_gaunt_table.h" #include "center2_orb-orb22.h" class LCAO_Orbitals; diff --git a/ABACUS.develop/source/src_lcao/unk_overlap_lcao.h b/ABACUS.develop/source/src_lcao/unk_overlap_lcao.h index c8f828eb56..6b97bd2c6e 100644 --- a/ABACUS.develop/source/src_lcao/unk_overlap_lcao.h +++ b/ABACUS.develop/source/src_lcao/unk_overlap_lcao.h @@ -12,8 +12,8 @@ using std::set; #include "../src_lcao/center2_orb-orb11.h" #include "../src_lcao/center2_orb-orb21.h" -#include "../src_lcao/make_overlap_table.h" -#include "../src_lcao/make_gaunt_table.h" +#include "../src_lcao/ORB_radial_table.h" +#include "../src_lcao/ORB_gaunt_table.h" #include "../src_lcao/ORB_atomic_lm.h" #include "../src_lcao/ORB_read.h" #include "../src_global/vector3.h" From f12c087f2705c6e7c0ea86d628aabb8204cef0dd Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 10 Feb 2021 20:34:15 +0800 Subject: [PATCH 103/233] move hamilt_linear.cpp to ORB_control.cpp --- ABACUS.develop/source/Makefile.Objects | 2 +- ABACUS.develop/source/driver.cpp | 2 +- .../{hamilt_linear.cpp => ORB_control.cpp} | 22 +++---- ABACUS.develop/source/src_lcao/ORB_control.h | 27 +++++++++ .../source/src_lcao/ORB_gen_tables.cpp | 47 +++++++-------- .../source/src_lcao/ORB_gen_tables.h | 14 +++-- .../source/src_lcao/hamilt_linear.h | 49 --------------- .../source/src_lcao/local_orbital_ions.cpp | 4 +- .../source/src_lcao/mulliken_charge.cpp | 4 +- ABACUS.develop/source/src_pw/energy.cpp | 59 ++++++++----------- ABACUS.develop/source/src_pw/hamilt.h | 11 ++-- 11 files changed, 107 insertions(+), 134 deletions(-) rename ABACUS.develop/source/src_lcao/{hamilt_linear.cpp => ORB_control.cpp} (74%) create mode 100644 ABACUS.develop/source/src_lcao/ORB_control.h delete mode 100644 ABACUS.develop/source/src_lcao/hamilt_linear.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index f3865ad9f0..a85dccbe75 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -127,6 +127,7 @@ gint_k_rho.o\ gint_k_fvl.o\ grid_base.o\ grid_base_beta.o\ +ORB_control.o\ ORB_read.o\ ORB_atomic.o\ ORB_atomic_lm.o\ @@ -156,7 +157,6 @@ force_lcao.o\ force_lcao_gamma.o\ force_lcao_k.o\ stress_lcao.o\ -hamilt_linear.o \ parallel_atoms.o \ parallel_orbitals.o \ global_fp.o \ diff --git a/ABACUS.develop/source/driver.cpp b/ABACUS.develop/source/driver.cpp index 1cd77c115b..44b45d6ae1 100644 --- a/ABACUS.develop/source/driver.cpp +++ b/ABACUS.develop/source/driver.cpp @@ -123,7 +123,7 @@ void Driver::reading(void) // init overlap matrix table, which is 'S Table' // init kinetical matrix element table, which is 'T Table' // init non-local pseudopotential matrix element table, which is 'NL Table' - hm.hon.set_orb_tables(); + hm.orb_con.set_orb_tables(); // xiaohui add 2015-09-06 // (1) divide the H and S matrix into each CPU, count the dimensions diff --git a/ABACUS.develop/source/src_lcao/hamilt_linear.cpp b/ABACUS.develop/source/src_lcao/ORB_control.cpp similarity index 74% rename from ABACUS.develop/source/src_lcao/hamilt_linear.cpp rename to ABACUS.develop/source/src_lcao/ORB_control.cpp index 1a3c3369d9..020e84ebb6 100644 --- a/ABACUS.develop/source/src_lcao/hamilt_linear.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_control.cpp @@ -1,26 +1,26 @@ #include "../src_pw/tools.h" #include "../src_pw/global.h" -#include "hamilt_linear.h" +#include "ORB_control.h" #include "src_global/sltk_atom_arrange.h" #include "ORB_gen_tables.h" #include "grid_integral.h" #include "build_st_pw.h" -Hamilt_Linear::Hamilt_Linear() +ORB_control::ORB_control() {} -Hamilt_Linear::~Hamilt_Linear() +ORB_control::~ORB_control() { if(test_deconstructor) { - cout << " ~Hamilt_Linear()" << endl; + cout << " ~ORB_control()" << endl; } } -void Hamilt_Linear::set_orb_tables(void) +void ORB_control::set_orb_tables(void) { - TITLE("Hamilt_Linear","set_orb_tables"); - timer::tick("Hamilt_Linear","set_orb_tables",'B'); + TITLE("ORB_control","set_orb_tables"); + timer::tick("ORB_control","set_orb_tables",'B'); //============================================================================= // (1) FUNCTION : use 'info' to generate 'Numerical Orbital' @@ -30,7 +30,7 @@ void Hamilt_Linear::set_orb_tables(void) if(CALCULATION=="test") { - timer::tick("Hamilt_Linear","set_orb_tables",'B'); + timer::tick("ORB_control","set_orb_tables",'B'); return; } @@ -49,13 +49,13 @@ void Hamilt_Linear::set_orb_tables(void) UOT.set_unit(ucell.lat0); - timer::tick("Hamilt_Linear","set_orb_tables",'B'); + timer::tick("ORB_control","set_orb_tables",'B'); return; } -void Hamilt_Linear::clear_after_ions() +void ORB_control::clear_after_ions() { - TITLE("Hamilt_Linear","clear_after_ions"); + TITLE("ORB_control","clear_after_ions"); UOT.MOT.Destroy_Table(); UOT.MOT.Destroy_Table_Beta(); return; diff --git a/ABACUS.develop/source/src_lcao/ORB_control.h b/ABACUS.develop/source/src_lcao/ORB_control.h new file mode 100644 index 0000000000..afe17979fe --- /dev/null +++ b/ABACUS.develop/source/src_lcao/ORB_control.h @@ -0,0 +1,27 @@ +//========================================================== +// AUTHOR : mohan, ywcui +// Last Update: 2021-02-10 +//========================================================== +#ifndef ORB_CONTROL_H +#define ORB_CONTROL_H + +#include "../src_pw/tools.h" +#include "../src_pw/algorithms.h" + +#include "ORB_gen_tables.h" +#include "../src_external/src_pdiag/pdiag_double.h" + +class ORB_control +{ + + public: + + ORB_control(); + ~ORB_control(); + + // Generate the S(overlap),T,NL matrix. + void set_orb_tables(); + void clear_after_ions(); + +}; +#endif diff --git a/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp b/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp index c6041e61a3..f96c37eba2 100644 --- a/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp @@ -1,18 +1,19 @@ +#include "../src_pw/global.h" +#include "ORB_read.h" #include "ORB_gen_tables.h" #include "ylm.h" -#include "ORB_read.h" -#include "../src_pw/global.h" -Use_Overlap_Table UOT; +// here is a member of ORB_gen_tables class +ORB_gen_tables UOT; -Use_Overlap_Table::Use_Overlap_Table(){} -Use_Overlap_Table::~Use_Overlap_Table(){} +ORB_gen_tables::ORB_gen_tables(){} +ORB_gen_tables::~ORB_gen_tables(){} // call in hamilt_linear::init_before_ions. -void Use_Overlap_Table::gen_tables( const int &job0 ) +void ORB_gen_tables::gen_tables( const int &job0 ) { - TITLE("Use_Overlap_Table","gen_tables"); - timer::tick("Use_Overlap_Table","gen_tables",'C'); + TITLE("ORB_gen_tables","gen_tables"); + timer::tick("ORB_gen_tables","gen_tables",'C'); ofs_running << "\n SETUP THE TWO-CENTER INTEGRATION TABLES" << endl; @@ -76,11 +77,11 @@ void Use_Overlap_Table::gen_tables( const int &job0 ) - timer::tick("Use_Overlap_Table","gen_tables",'C'); + timer::tick("ORB_gen_tables","gen_tables",'C'); return; } -void Use_Overlap_Table::snap_psibeta( +void ORB_gen_tables::snap_psibeta( double nlm[], const int& job, const Vector3 &R1, @@ -98,8 +99,8 @@ void Use_Overlap_Table::snap_psibeta( complex *nlm1, const int is) const { - //TITLE ("Use_Overlap_Table","snap_psibeta"); - //timer::tick ("Use_Overlap_Table","snap_psibeta"); + //TITLE ("ORB_gen_tables","snap_psibeta"); + //timer::tick ("ORB_gen_tables","snap_psibeta"); //optimized by zhengdy-soc if(NSPIN==4 && ORB.Beta[T0].get_count_soc(is)==0) return; @@ -459,7 +460,7 @@ void Use_Overlap_Table::snap_psibeta( } else { - WARNING_QUIT("Use_Overlap_Table::snap_psibeta","something wrong with snap_psibeta."); + WARNING_QUIT("ORB_gen_tables::snap_psibeta","something wrong with snap_psibeta."); }*/ break; } @@ -502,7 +503,7 @@ void Use_Overlap_Table::snap_psibeta( else if(NSPIN!=4) nlm[0] += (term_a_nc[p1] * term_b_nc[p2] * ORB.Beta[T0].getCoefficient_D_so(0, p2, p1)).real(); else - WARNING_QUIT("Use_Overlap_Table::snap_psibeta","Conflict! Didn't count non-local part"); + WARNING_QUIT("ORB_gen_tables::snap_psibeta","Conflict! Didn't count non-local part"); } break; case 1://need to be added later @@ -515,11 +516,11 @@ void Use_Overlap_Table::snap_psibeta( delete[] rmesh1; delete[] rmesh2; -// timer::tick("Use_Overlap_Table","snap_psibeta"); +// timer::tick("ORB_gen_tables","snap_psibeta"); return; } -void Use_Overlap_Table::snap_psipsi( +void ORB_gen_tables::snap_psipsi( double olm[], const int &job, //0, 1 const char &dtype, // derivative type: S or T @@ -535,11 +536,11 @@ void Use_Overlap_Table::snap_psipsi( const int &N2, complex *olm1)const { - //TITLE("Use_Overlap_Table","snap_psipsi"); - //timer::tick ("Use_Overlap_Table", "snap_psipsi"); + //TITLE("ORB_gen_tables","snap_psipsi"); + //timer::tick ("ORB_gen_tables", "snap_psipsi"); if(job != 0 && job != 1) { - WARNING_QUIT("Use_Overlap_Table::snap_psipsi","job must be equal to 0 or 1!"); + WARNING_QUIT("ORB_gen_tables::snap_psipsi","job must be equal to 0 or 1!"); } Numerical_Orbital::set_position(R1, R2); @@ -693,7 +694,7 @@ void Use_Overlap_Table::snap_psipsi( } else { - WARNING_QUIT("Use_Overlap_Table::snap_psipsi","something wrong!"); + WARNING_QUIT("ORB_gen_tables::snap_psipsi","something wrong!"); } @@ -784,7 +785,7 @@ void Use_Overlap_Table::snap_psipsi( } else { - WARNING_QUIT("Use_Overlap_Table::snap_psipsi","something wrong in T."); + WARNING_QUIT("ORB_gen_tables::snap_psipsi","something wrong in T."); } break; } @@ -803,11 +804,11 @@ void Use_Overlap_Table::snap_psipsi( }// end T: : break; } -// timer::tick ("Use_Overlap_Table", "snap_psipsi"); +// timer::tick ("ORB_gen_tables", "snap_psipsi"); return; } -double Use_Overlap_Table::get_distance( const Vector3 &R1, const Vector3 &R2)const +double ORB_gen_tables::get_distance( const Vector3 &R1, const Vector3 &R2)const { assert( this->lat0 > 0.0); Vector3 dR = R1 - R2; diff --git a/ABACUS.develop/source/src_lcao/ORB_gen_tables.h b/ABACUS.develop/source/src_lcao/ORB_gen_tables.h index 159291a98f..4201237e1f 100644 --- a/ABACUS.develop/source/src_lcao/ORB_gen_tables.h +++ b/ABACUS.develop/source/src_lcao/ORB_gen_tables.h @@ -10,14 +10,18 @@ #include "ORB_gaunt_table.h" #include "ylm.h" -class Use_Overlap_Table +//------------------------------------ +// used to be 'Use_Overlap_Table', +// now the name is 'ORB_gen_tables' +//------------------------------------ +class ORB_gen_tables { public: - friend class Hamilt_Linear; + friend class ORB_control; - Use_Overlap_Table(); - ~Use_Overlap_Table(); + ORB_gen_tables(); + ~ORB_gen_tables(); void gen_tables( const int &job0 ); void set_unit( const double &v ){lat0=v;} @@ -77,6 +81,6 @@ class Use_Overlap_Table }; -extern Use_Overlap_Table UOT; +extern ORB_gen_tables UOT; #endif diff --git a/ABACUS.develop/source/src_lcao/hamilt_linear.h b/ABACUS.develop/source/src_lcao/hamilt_linear.h deleted file mode 100644 index 1c05bc5432..0000000000 --- a/ABACUS.develop/source/src_lcao/hamilt_linear.h +++ /dev/null @@ -1,49 +0,0 @@ -//========================================================== -// AUTHOR : mohan, ywcui -// Last Update: 2009-4-22 -//========================================================== -#ifndef HAMILT_LINEAR_H -#define HAMILT_LINEAR_H - -#include "../src_pw/tools.h" -#include "../src_pw/algorithms.h" - -#include "ORB_gen_tables.h" -#include "../src_external/src_pdiag/pdiag_double.h" - -class Hamilt_Linear -{ - - public: - - Hamilt_Linear(); - ~Hamilt_Linear(); - - // Generate the S(overlap),T,NL matrix. - void set_orb_tables(); - void clear_after_ions(); - - // For test - void solve_using_lapack - ( - const int ik, - const ComplexMatrix &lpsi,// localized psi - const int nstart, - const int nbands, - ComplexMatrix &evc,// wave functions - double *en// band energy - ); - - // Main routine - void solve_using_cg - ( - const int ik, - const ComplexMatrix &lpsi,// localized psi - const int nstart, - const int nbands, - ComplexMatrix &evc,// wave functions - double *en// band energy - ); - -}; -#endif diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index bbde532e51..b55b547c67 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -308,8 +308,8 @@ void Local_Orbital_Ions::opt_ions(void) */ } - - hm.hon.clear_after_ions(); + // mohan update 2021-02-10 + hm.orb_con.clear_after_ions(); timer::tick("Local_Orbital_Ions","opt_ions",'C'); return; diff --git a/ABACUS.develop/source/src_lcao/mulliken_charge.cpp b/ABACUS.develop/source/src_lcao/mulliken_charge.cpp index e6cf34a784..895d370727 100644 --- a/ABACUS.develop/source/src_lcao/mulliken_charge.cpp +++ b/ABACUS.develop/source/src_lcao/mulliken_charge.cpp @@ -174,7 +174,7 @@ void Mulliken_Charge::cal_mulliken(void) mud[0].create(ParaO.ncol,ParaO.nrow); atom_arrange::set_sr_NL(); atom_arrange::search( SEARCH_RADIUS );//qifeng-2019-01-21 - hm.hon.set_orb_tables(); + hm.orb_con.set_orb_tables(); LM.allocate_HS_R(LNNR.nnr); LM.zeros_HSR('S', LNNR.nnr); UHM.UOM.calculate_S_no(); @@ -241,7 +241,7 @@ void Mulliken_Charge::cal_mulliken(void) #ifdef __MPI atom_arrange::delete_vector( SEARCH_RADIUS ); #endif - hm.hon.clear_after_ions(); + hm.orb_con.clear_after_ions(); }//else MPI_Reduce(MecMulP[is], DecMulP[is] , NLOCAL , MPI_DOUBLE , MPI_SUM, 0, MPI_COMM_WORLD); diff --git a/ABACUS.develop/source/src_pw/energy.cpp b/ABACUS.develop/source/src_pw/energy.cpp index a6dc8eae71..c7de5ecd43 100644 --- a/ABACUS.develop/source/src_pw/energy.cpp +++ b/ABACUS.develop/source/src_pw/energy.cpp @@ -1002,8 +1002,6 @@ void energy::perform_dos(void) MC.stdout_mulliken(); }//qifeng add 2019/9/10 - - int nspin0=1; if(NSPIN==2) nspin0=2; @@ -1085,12 +1083,12 @@ void energy::perform_dos(void) } double a = bcoeff; - double c=2*3.141592653; - double b = sqrt(c)*a; + double c=2*3.141592653; + double b = sqrt(c)*a; - complex *waveg = new complex [NLOCAL]; + complex*waveg = new complex[NLOCAL]; - double* Gauss = new double [np]; + double*Gauss = new double[np]; for(int is=0; isiw2l[j]; const int N1 = atom1->iw2n[j]; const int m1 = atom1->iw2m[j]; - out <out_band) //pengfei 2014-10-13 - { - - int nks; - if(nspin0==1) nks = kv.nkstot; - else if(nspin0==2) nks = kv.nkstot/2; + if(this->out_band) //pengfei 2014-10-13 + { + int nks; + if(nspin0==1) nks = kv.nkstot; + else if(nspin0==2) nks = kv.nkstot/2; - for(int is=0; isef*0, wf.ekb); - } - } + for(int is=0; isef*0, wf.ekb); + } + } + return; } diff --git a/ABACUS.develop/source/src_pw/hamilt.h b/ABACUS.develop/source/src_pw/hamilt.h index 03c3a74aff..a358b0bfa4 100644 --- a/ABACUS.develop/source/src_pw/hamilt.h +++ b/ABACUS.develop/source/src_pw/hamilt.h @@ -2,11 +2,7 @@ #define HAMILT_H #include "tools.h" - -#ifdef __FP -#include "../src_lcao/hamilt_linear.h" -#endif - +#include "../src_lcao/ORB_control.h" #include "hamilt_pw.h" class Hamilt @@ -41,7 +37,10 @@ class Hamilt void h_psi( const int dim, const complex *psi,complex *hpsi); Hamilt_PW hpw; - Hamilt_Linear hon; + + // mohan update 2021-02-10 + ORB_control orb_con; + private: bool test_exit_cond( const int &ntry, const int ¬conv); From 34619e0312170bf9758605322b680fc007a26fe7 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 10 Feb 2021 21:22:25 +0800 Subject: [PATCH 104/233] move exx codes to src_ri --- ABACUS.develop/source/input_conv.cpp | 2 +- .../src_test/{src_lcao => src_ri}/abfs-test.h | 4 +- .../conv_coulomb_pot-unittest.h | 0 .../exx_abfs-construct_orbs-test.h | 0 .../{src_lcao => src_ri}/exx_abfs-dm-test.h | 0 .../exx_abfs-inverse_matrix_double-test.h | 0 .../exx_abfs-screen-test.h | 4 +- .../{src_lcao => src_ri}/exx_abfs-unittest.h | 6 +- .../{src_lcao => src_ri}/exx_lcao-test.h | 0 .../make_gaunt_table-unittest.h | 0 .../{src_lcao => src_ri}/wfc_dm_2d-test.h | 0 .../source/src_global/serialization_cereal.h | 4 +- .../src_global/sph_bessel_recursive-d2.cpp | 2 +- ABACUS.develop/source/src_lcao/1 | 13 ---- ABACUS.develop/source/src_lcao/ELEC_nscf.cpp | 4 +- .../source/src_lcao/ORB_radial_table.cpp | 64 ++++++++++++++++++- ABACUS.develop/source/src_lcao/global_fp.h | 2 +- .../source/src_lcao/local_orbital_elec.cpp | 4 +- .../source/src_lcao/local_orbital_ions.cpp | 4 +- ABACUS.develop/source/src_pw/charge_pulay.h | 4 +- .../{src_lcao => src_ri}/abfs-template.h | 0 .../abfs-vector3_order.cpp | 0 .../{src_lcao => src_ri}/abfs-vector3_order.h | 2 +- .../source/{src_lcao => src_ri}/abfs.cpp | 0 .../source/{src_lcao => src_ri}/abfs.h | 2 +- .../conv_coulomb_pot-inl.h | 0 .../{src_lcao => src_ri}/conv_coulomb_pot.cpp | 0 .../{src_lcao => src_ri}/conv_coulomb_pot.h | 4 +- .../conv_coulomb_pot_k-template.h | 2 +- .../conv_coulomb_pot_k.cpp | 0 .../{src_lcao => src_ri}/conv_coulomb_pot_k.h | 0 .../exx_abfs-abfs_index.cpp | 2 +- .../exx_abfs-abfs_index.h | 0 .../exx_abfs-construct_orbs.cpp | 2 +- .../exx_abfs-construct_orbs.h | 4 +- .../{src_lcao => src_ri}/exx_abfs-dm.cpp | 4 +- .../source/{src_lcao => src_ri}/exx_abfs-dm.h | 2 +- .../{src_lcao => src_ri}/exx_abfs-inl.h | 0 .../exx_abfs-inverse_matrix_double.cpp | 0 .../exx_abfs-inverse_matrix_double.h | 0 .../exx_abfs-io-template.h | 2 +- .../{src_lcao => src_ri}/exx_abfs-io.cpp | 0 .../source/{src_lcao => src_ri}/exx_abfs-io.h | 0 .../{src_lcao => src_ri}/exx_abfs-jle.cpp | 4 +- .../{src_lcao => src_ri}/exx_abfs-jle.h | 6 +- .../exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp | 8 +-- .../exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h | 8 +-- .../exx_abfs-matrix_orbs11.cpp | 2 +- .../exx_abfs-matrix_orbs11.h | 8 +-- .../exx_abfs-matrix_orbs21.cpp | 2 +- .../exx_abfs-matrix_orbs21.h | 8 +-- .../exx_abfs-matrix_orbs22.cpp | 2 +- .../exx_abfs-matrix_orbs22.h | 8 +-- ...-parallel-communicate-allreduce-template.h | 2 +- ...xx_abfs-parallel-communicate-allreduce.cpp | 0 .../exx_abfs-parallel-communicate-allreduce.h | 0 ...abfs-parallel-communicate-dm-allreduce.cpp | 2 +- .../exx_abfs-parallel-communicate-dm.cpp | 2 +- .../exx_abfs-parallel-communicate-dm.h | 2 +- .../exx_abfs-parallel-communicate-dm2.cpp | 0 .../exx_abfs-parallel-communicate-dm2.h | 2 +- ...bfs-parallel-communicate-dm3-allreduce.cpp | 0 ...x_abfs-parallel-communicate-dm3-template.h | 0 .../exx_abfs-parallel-communicate-dm3.cpp | 2 +- .../exx_abfs-parallel-communicate-dm3.h | 4 +- ...exx_abfs-parallel-communicate-function.cpp | 0 .../exx_abfs-parallel-communicate-function.h | 0 ...fs-parallel-communicate-hexx-allreduce.cpp | 0 ...s-parallel-communicate-hexx-allreduce2.cpp | 0 ..._abfs-parallel-communicate-hexx-template.h | 0 .../exx_abfs-parallel-communicate-hexx.cpp | 2 +- .../exx_abfs-parallel-communicate-hexx.h | 2 +- .../exx_abfs-parallel-distribute-htime.cpp | 2 +- .../exx_abfs-parallel-distribute-htime.h | 2 +- .../exx_abfs-parallel-distribute-kmeans.cpp | 0 .../exx_abfs-parallel-distribute-kmeans.h | 0 .../exx_abfs-parallel-distribute-order.cpp | 2 +- .../exx_abfs-parallel-distribute-order.h | 2 +- .../{src_lcao => src_ri}/exx_abfs-parallel.h | 0 .../{src_lcao => src_ri}/exx_abfs-pca.cpp | 2 +- .../{src_lcao => src_ri}/exx_abfs-pca.h | 0 .../exx_abfs-screen-cauchy.cpp | 2 +- .../exx_abfs-screen-cauchy.h | 2 +- .../exx_abfs-screen-schwarz.cpp | 4 +- .../exx_abfs-screen-schwarz.h | 0 .../{src_lcao => src_ri}/exx_abfs-util.cpp | 0 .../{src_lcao => src_ri}/exx_abfs-util.h | 0 .../source/{src_lcao => src_ri}/exx_abfs.cpp | 8 +-- .../source/{src_lcao => src_ri}/exx_abfs.h | 0 .../source/{src_lcao => src_ri}/exx_lcao.cpp | 4 +- .../source/{src_lcao => src_ri}/exx_lcao.h | 22 +++---- .../exx_opt_orb-print.cpp | 2 +- .../{src_lcao => src_ri}/exx_opt_orb.cpp | 20 +++--- .../source/{src_lcao => src_ri}/exx_opt_orb.h | 0 94 files changed, 169 insertions(+), 124 deletions(-) rename ABACUS.develop/source/src_external/src_test/{src_lcao => src_ri}/abfs-test.h (94%) rename ABACUS.develop/source/src_external/src_test/{src_lcao => src_ri}/conv_coulomb_pot-unittest.h (100%) rename ABACUS.develop/source/src_external/src_test/{src_lcao => src_ri}/exx_abfs-construct_orbs-test.h (100%) rename ABACUS.develop/source/src_external/src_test/{src_lcao => src_ri}/exx_abfs-dm-test.h (100%) rename ABACUS.develop/source/src_external/src_test/{src_lcao => src_ri}/exx_abfs-inverse_matrix_double-test.h (100%) rename ABACUS.develop/source/src_external/src_test/{src_lcao => src_ri}/exx_abfs-screen-test.h (92%) rename ABACUS.develop/source/src_external/src_test/{src_lcao => src_ri}/exx_abfs-unittest.h (95%) rename ABACUS.develop/source/src_external/src_test/{src_lcao => src_ri}/exx_lcao-test.h (100%) rename ABACUS.develop/source/src_external/src_test/{src_lcao => src_ri}/make_gaunt_table-unittest.h (100%) rename ABACUS.develop/source/src_external/src_test/{src_lcao => src_ri}/wfc_dm_2d-test.h (100%) delete mode 100644 ABACUS.develop/source/src_lcao/1 rename ABACUS.develop/source/{src_lcao => src_ri}/abfs-template.h (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/abfs-vector3_order.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/abfs-vector3_order.h (98%) rename ABACUS.develop/source/{src_lcao => src_ri}/abfs.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/abfs.h (99%) rename ABACUS.develop/source/{src_lcao => src_ri}/conv_coulomb_pot-inl.h (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/conv_coulomb_pot.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/conv_coulomb_pot.h (94%) rename ABACUS.develop/source/{src_lcao => src_ri}/conv_coulomb_pot_k-template.h (95%) rename ABACUS.develop/source/{src_lcao => src_ri}/conv_coulomb_pot_k.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/conv_coulomb_pot_k.h (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-abfs_index.cpp (96%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-abfs_index.h (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-construct_orbs.cpp (99%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-construct_orbs.h (97%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-dm.cpp (98%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-dm.h (97%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-inl.h (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-inverse_matrix_double.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-inverse_matrix_double.h (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-io-template.h (98%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-io.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-io.h (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-jle.cpp (97%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-jle.h (78%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp (99%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h (91%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-matrix_orbs11.cpp (99%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-matrix_orbs11.h (93%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-matrix_orbs21.cpp (99%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-matrix_orbs21.h (95%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-matrix_orbs22.cpp (99%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-matrix_orbs22.h (94%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-allreduce-template.h (98%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-allreduce.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-allreduce.h (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-dm-allreduce.cpp (99%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-dm.cpp (99%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-dm.h (98%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-dm2.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-dm2.h (95%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-dm3-allreduce.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-dm3-template.h (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-dm3.cpp (96%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-dm3.h (95%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-function.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-function.h (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-hexx-allreduce.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-hexx-allreduce2.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-hexx-template.h (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-hexx.cpp (98%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-communicate-hexx.h (99%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-distribute-htime.cpp (99%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-distribute-htime.h (96%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-distribute-kmeans.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-distribute-kmeans.h (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-distribute-order.cpp (98%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel-distribute-order.h (91%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-parallel.h (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-pca.cpp (98%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-pca.h (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-screen-cauchy.cpp (99%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-screen-cauchy.h (98%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-screen-schwarz.cpp (97%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-screen-schwarz.h (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-util.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs-util.h (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs.cpp (99%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_abfs.h (100%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_lcao.cpp (99%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_lcao.h (86%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_opt_orb-print.cpp (99%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_opt_orb.cpp (96%) rename ABACUS.develop/source/{src_lcao => src_ri}/exx_opt_orb.h (100%) diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index 9a38864b0c..3c30749480 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -19,7 +19,7 @@ #include "src_pw/epsilon0_pwscf.h" #include "src_pw/epsilon0_vasp.h" #include "src_pw/unitcell.h" -#include "src_lcao/exx_abfs-jle.h" +#include "src_ri/exx_abfs-jle.h" //xiaohui modified 2013-03-23, adding "//" before #include... //#include "../../src_develop/src_siao/selinv.h" diff --git a/ABACUS.develop/source/src_external/src_test/src_lcao/abfs-test.h b/ABACUS.develop/source/src_external/src_test/src_ri/abfs-test.h similarity index 94% rename from ABACUS.develop/source/src_external/src_test/src_lcao/abfs-test.h rename to ABACUS.develop/source/src_external/src_test/src_ri/abfs-test.h index e026fcb71e..dd3e7982ce 100644 --- a/ABACUS.develop/source/src_external/src_test/src_lcao/abfs-test.h +++ b/ABACUS.develop/source/src_external/src_test/src_ri/abfs-test.h @@ -1,4 +1,4 @@ -#include "src_lcao/abfs.h" +#include "src_ri/abfs.h" #include static void test_adjs( ostream & os ) @@ -16,4 +16,4 @@ static void test_adjs( ostream & os ) os< #include -#include "src_lcao/abfs.h" +#include "src_ri/abfs.h" static void test_screen( const string & file_name, const map,double>>> & m ) { @@ -15,4 +15,4 @@ static void test_screen( const string & file_name, const map using namespace std; -#include "src_lcao/exx_abfs.h" +#include "src_ri/exx_abfs.h" #include "src_external/src_test/src_global/matrix-test.h" -#include "src_external/src_test/src_lcao/exx_abfs-unittest.h" +#include "src_external/src_test/src_ri/exx_abfs-unittest.h" static void of_abfs_cpp( const string &file_name, const vector>> &orb ) { @@ -92,4 +92,4 @@ static void ofs_ms( ofs.close(); } -#endif \ No newline at end of file +#endif diff --git a/ABACUS.develop/source/src_external/src_test/src_lcao/exx_lcao-test.h b/ABACUS.develop/source/src_external/src_test/src_ri/exx_lcao-test.h similarity index 100% rename from ABACUS.develop/source/src_external/src_test/src_lcao/exx_lcao-test.h rename to ABACUS.develop/source/src_external/src_test/src_ri/exx_lcao-test.h diff --git a/ABACUS.develop/source/src_external/src_test/src_lcao/make_gaunt_table-unittest.h b/ABACUS.develop/source/src_external/src_test/src_ri/make_gaunt_table-unittest.h similarity index 100% rename from ABACUS.develop/source/src_external/src_test/src_lcao/make_gaunt_table-unittest.h rename to ABACUS.develop/source/src_external/src_test/src_ri/make_gaunt_table-unittest.h diff --git a/ABACUS.develop/source/src_external/src_test/src_lcao/wfc_dm_2d-test.h b/ABACUS.develop/source/src_external/src_test/src_ri/wfc_dm_2d-test.h similarity index 100% rename from ABACUS.develop/source/src_external/src_test/src_lcao/wfc_dm_2d-test.h rename to ABACUS.develop/source/src_external/src_test/src_ri/wfc_dm_2d-test.h diff --git a/ABACUS.develop/source/src_global/serialization_cereal.h b/ABACUS.develop/source/src_global/serialization_cereal.h index 2b9949d554..d017095ff5 100644 --- a/ABACUS.develop/source/src_global/serialization_cereal.h +++ b/ABACUS.develop/source/src_global/serialization_cereal.h @@ -8,7 +8,7 @@ #include #include "src_global/vector3.h" -#include "src_lcao/abfs-vector3_order.h" +#include "src_ri/abfs-vector3_order.h" #include "src_global/matrix.h" @@ -29,4 +29,4 @@ template void load( Archive & ar, matrix & m ) ar(cereal::binary_data(m.c, m.nr*m.nc*sizeof(double))); } -#endif \ No newline at end of file +#endif diff --git a/ABACUS.develop/source/src_global/sph_bessel_recursive-d2.cpp b/ABACUS.develop/source/src_global/sph_bessel_recursive-d2.cpp index 686a6cf84f..945f691f69 100644 --- a/ABACUS.develop/source/src_global/sph_bessel_recursive-d2.cpp +++ b/ABACUS.develop/source/src_global/sph_bessel_recursive-d2.cpp @@ -13,7 +13,7 @@ // Peize Lin test #include #include -#include"src_external/src_test/src_lcao/exx_lcao-test.h" +#include"src_external/src_test/src_ri/exx_lcao-test.h" #include"src_lcao/global_fp.h" using namespace std; diff --git a/ABACUS.develop/source/src_lcao/1 b/ABACUS.develop/source/src_lcao/1 deleted file mode 100644 index 744097cb1d..0000000000 --- a/ABACUS.develop/source/src_lcao/1 +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/ABACUS.develop/source/src_lcao/grid_base.cpp b/ABACUS.develop/source/src_lcao/grid_base.cpp -index e7bbbb0..072abb9 100644 ---- a/ABACUS.develop/source/src_lcao/grid_base.cpp -+++ b/ABACUS.develop/source/src_lcao/grid_base.cpp -@@ -1,7 +1,7 @@ - #include "grid_integral.h" - #include "../src_pw/global.h" - #include "ylm.h" --#include "lcao_orbitals.h" -+#include "ORB_read.h" - - #include "global_fp.h" // mohan add 2021-01-30 - diff --git a/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp b/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp index 58eae636e3..adbedc8a3c 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp @@ -1,7 +1,7 @@ #include "ELEC_nscf.h" #include "../src_pw/global.h" -#include "exx_abfs.h" -#include "exx_opt_orb.h" +#include "../src_ri/exx_abfs.h" +#include "../src_ri/exx_opt_orb.h" #include "global_fp.h" #include "ELEC_cbands_gamma.h" #include "ELEC_cbands_k.h" diff --git a/ABACUS.develop/source/src_lcao/ORB_radial_table.cpp b/ABACUS.develop/source/src_lcao/ORB_radial_table.cpp index 5557614345..ecf6a95cf6 100644 --- a/ABACUS.develop/source/src_lcao/ORB_radial_table.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_radial_table.cpp @@ -2,7 +2,8 @@ #include "ORB_read.h" #include -#include "exx_abfs.h" +#include "../src_ri/exx_abfs.h" + double Make_Overlap_Table::dr = -1.0; Make_Overlap_Table::Make_Overlap_Table() @@ -142,23 +143,40 @@ void Make_Overlap_Table::cal_ST_Phi12_R { case 1: // calculate overlap if( !n1.get_psif().empty() && !n2.get_psi_k2().empty() ) + { for (int ik = 0; ik < kmesh; ik++) + { k1_dot_k2[ik] = n1.getPsif(ik) * n2.getPsi_k2(ik); + } + } else if( !n1.get_psi_k().empty() && !n2.get_psi_k().empty() ) + { for (int ik = 0; ik < kmesh; ik++) + { k1_dot_k2[ik] = n1.getPsi_k(ik) * n2.getPsi_k(ik); + } + } else if( !n1.get_psi_k2().empty() && !n2.get_psif().empty() ) + { for (int ik = 0; ik < kmesh; ik++) + { k1_dot_k2[ik] = n1.getPsi_k2(ik) * n2.getPsif(ik); + } + } break; + case 2: // calculate kinetic energy for (int ik = 0; ik < kmesh; ik++) + { k1_dot_k2[ik] = n1.getPsi_k2(ik) * n2.getPsi_k2(ik); + } break; } for (int ik = 0; ik < kmesh; ik++) + { k1_dot_k2_dot_kpoint[ik] = k1_dot_k2[ik] * this->kpoint[ik]; + } // Mathzone_Add1::Sbt_new (3, l, r, dr, rmesh, kpoint, dk, kmesh, k1_dot_k2, 2, rs); // for (int ir = 0; ir < rmesh; ir++) rs[ir] *= FOUR_PI; @@ -214,7 +232,9 @@ void Make_Overlap_Table::cal_ST_Phi12_R const vector &jl_r = jl[ir]; for (int ik=0; ik &jlp1_r = jlp1[ir]; const double fac = l/(l+1.0); if( l==0 ) + { for (int ik=0; ik k1_dot_k2_dot_kpoint(kmesh); for (int ik = 0; ik < kmesh; ik++) + { k1_dot_k2_dot_kpoint[ik] = k1_dot_k2[ik] * this->kpoint[ik]; - + } vector integrated_func(kmesh); @@ -479,7 +523,9 @@ void Make_Overlap_Table::cal_ST_Phi12_R const vector &jl_r = jl[ir]; for (int ik=0; ik &jlp1_r = jlp1[ir]; const double fac = l/(l+1.0); if( l==0 ) + { for (int ik=0; ikkmesh,this->kpoint,this->r[ir], l-1, jl); for (int ik = 0; ik < kmesh; ik++) + { integrated_func[ik] = jlm1[ir][ik] * k1_dot_k2[ik] * kpoint[ik]; + } Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp1); } @@ -609,7 +667,9 @@ void Make_Overlap_Table::cal_VNL_PhiBeta_R( // Mathzone::Spherical_Bessel(this->kmesh,this->kpoint,this->r[ir], l+1, jl); for (int ik = 0; ik < kmesh; ik++) + { integrated_func[ik] = jlp1[ir][ik] * k1_dot_k2[ik] * kpoint[ik]; + } Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp2); diff --git a/ABACUS.develop/source/src_lcao/global_fp.h b/ABACUS.develop/source/src_lcao/global_fp.h index b1b68de5e9..81b873df59 100644 --- a/ABACUS.develop/source/src_lcao/global_fp.h +++ b/ABACUS.develop/source/src_lcao/global_fp.h @@ -13,7 +13,7 @@ #include "src_lcao/ORB_read.h" #include "src_lcao/ORB_gen_tables.h" #include "src_parallel/subgrid_oper.h" -#include "src_lcao/exx_lcao.h" +#include "src_ri/exx_lcao.h" extern Grid_Driver GridD; extern Parallel_Atoms ParaA; diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp index a2ba86429d..693ef8425e 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp @@ -17,8 +17,8 @@ #include "ELEC_cbands_k.h" #include "ELEC_evolve.h" // -#include "src_lcao/exx_abfs.h" -#include "src_lcao/exx_opt_orb.h" +#include "src_ri/exx_abfs.h" +#include "src_ri/exx_opt_orb.h" void Local_Orbital_Elec::solve_elec_stru(const int &istep) diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index b55b547c67..e8a8764055 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -9,8 +9,8 @@ #include "../src_io/hs_matrix.h" #include "src_lcao/cal_r_overlap_R.h" #include "../src_ions/variable_cell.h" // mohan add 2021-02-01 -#include "src_lcao/exx_abfs.h" -#include "src_lcao/exx_opt_orb.h" +#include "src_ri/exx_abfs.h" +#include "src_ri/exx_opt_orb.h" #include "ELEC_scf.h" #include "src_global/sltk_atom_arrange.h" diff --git a/ABACUS.develop/source/src_pw/charge_pulay.h b/ABACUS.develop/source/src_pw/charge_pulay.h index 4ec84e284d..25bfdfb88f 100644 --- a/ABACUS.develop/source/src_pw/charge_pulay.h +++ b/ABACUS.develop/source/src_pw/charge_pulay.h @@ -12,8 +12,8 @@ //=================================== #include "tools.h" #include "charge_mixing.h" -#include "src_lcao/exx_abfs-dm.h" -#include "src_lcao/exx_abfs-parallel-communicate-hexx.h" +#include "src_ri/exx_abfs-dm.h" +#include "src_ri/exx_abfs-parallel-communicate-hexx.h" class Charge_Pulay: public Charge_Mixing { diff --git a/ABACUS.develop/source/src_lcao/abfs-template.h b/ABACUS.develop/source/src_ri/abfs-template.h similarity index 100% rename from ABACUS.develop/source/src_lcao/abfs-template.h rename to ABACUS.develop/source/src_ri/abfs-template.h diff --git a/ABACUS.develop/source/src_lcao/abfs-vector3_order.cpp b/ABACUS.develop/source/src_ri/abfs-vector3_order.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/abfs-vector3_order.cpp rename to ABACUS.develop/source/src_ri/abfs-vector3_order.cpp diff --git a/ABACUS.develop/source/src_lcao/abfs-vector3_order.h b/ABACUS.develop/source/src_ri/abfs-vector3_order.h similarity index 98% rename from ABACUS.develop/source/src_lcao/abfs-vector3_order.h rename to ABACUS.develop/source/src_ri/abfs-vector3_order.h index c15cca3e3e..510d751e74 100644 --- a/ABACUS.develop/source/src_lcao/abfs-vector3_order.h +++ b/ABACUS.develop/source/src_ri/abfs-vector3_order.h @@ -6,7 +6,7 @@ #ifndef ABFS_VECTOR3_ORDER_H #define ABFS_VECTOR3_ORDER_H -#include "src_lcao/abfs.h" +#include "src_ri/abfs.h" // mohan comment out 2021-02-06 //#include diff --git a/ABACUS.develop/source/src_lcao/abfs.cpp b/ABACUS.develop/source/src_ri/abfs.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/abfs.cpp rename to ABACUS.develop/source/src_ri/abfs.cpp diff --git a/ABACUS.develop/source/src_lcao/abfs.h b/ABACUS.develop/source/src_ri/abfs.h similarity index 99% rename from ABACUS.develop/source/src_lcao/abfs.h rename to ABACUS.develop/source/src_ri/abfs.h index 4a072e2140..7e23c99445 100644 --- a/ABACUS.develop/source/src_lcao/abfs.h +++ b/ABACUS.develop/source/src_ri/abfs.h @@ -3,7 +3,7 @@ #include "src_global/vector3.h" #include "src_global/matrix.h" -#include "src_lcao/exx_abfs.h" +#include "src_ri/exx_abfs.h" #include #include diff --git a/ABACUS.develop/source/src_lcao/conv_coulomb_pot-inl.h b/ABACUS.develop/source/src_ri/conv_coulomb_pot-inl.h similarity index 100% rename from ABACUS.develop/source/src_lcao/conv_coulomb_pot-inl.h rename to ABACUS.develop/source/src_ri/conv_coulomb_pot-inl.h diff --git a/ABACUS.develop/source/src_lcao/conv_coulomb_pot.cpp b/ABACUS.develop/source/src_ri/conv_coulomb_pot.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/conv_coulomb_pot.cpp rename to ABACUS.develop/source/src_ri/conv_coulomb_pot.cpp diff --git a/ABACUS.develop/source/src_lcao/conv_coulomb_pot.h b/ABACUS.develop/source/src_ri/conv_coulomb_pot.h similarity index 94% rename from ABACUS.develop/source/src_lcao/conv_coulomb_pot.h rename to ABACUS.develop/source/src_ri/conv_coulomb_pot.h index 14fe75ef24..7ddfcd1414 100644 --- a/ABACUS.develop/source/src_lcao/conv_coulomb_pot.h +++ b/ABACUS.develop/source/src_ri/conv_coulomb_pot.h @@ -4,7 +4,7 @@ #include using std::vector; -#include "ORB_atomic_lm.h" +#include "../src_lcao/ORB_atomic_lm.h" // out of conv_coulomb_pot.size(), imagine all rab(i.e. dr) are equal to rab[conv_coulomb_pot.size()-1] class Conv_Coulomb_Pot @@ -31,4 +31,4 @@ class Conv_Coulomb_Pot inline double get_r_radial_outofrange( size_t ir ) const; }; -#endif \ No newline at end of file +#endif diff --git a/ABACUS.develop/source/src_lcao/conv_coulomb_pot_k-template.h b/ABACUS.develop/source/src_ri/conv_coulomb_pot_k-template.h similarity index 95% rename from ABACUS.develop/source/src_lcao/conv_coulomb_pot_k-template.h rename to ABACUS.develop/source/src_ri/conv_coulomb_pot_k-template.h index 244a3947d3..656bd00740 100644 --- a/ABACUS.develop/source/src_lcao/conv_coulomb_pot_k-template.h +++ b/ABACUS.develop/source/src_ri/conv_coulomb_pot_k-template.h @@ -5,7 +5,7 @@ #include #include -#include "src_external/src_test/src_lcao/exx_abfs-construct_orbs-test.h" +#include "src_external/src_test/src_ri/exx_abfs-construct_orbs-test.h" template T Conv_Coulomb_Pot_K::cal_orbs_ccp_rmesh( diff --git a/ABACUS.develop/source/src_lcao/conv_coulomb_pot_k.cpp b/ABACUS.develop/source/src_ri/conv_coulomb_pot_k.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/conv_coulomb_pot_k.cpp rename to ABACUS.develop/source/src_ri/conv_coulomb_pot_k.cpp diff --git a/ABACUS.develop/source/src_lcao/conv_coulomb_pot_k.h b/ABACUS.develop/source/src_ri/conv_coulomb_pot_k.h similarity index 100% rename from ABACUS.develop/source/src_lcao/conv_coulomb_pot_k.h rename to ABACUS.develop/source/src_ri/conv_coulomb_pot_k.h diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-abfs_index.cpp b/ABACUS.develop/source/src_ri/exx_abfs-abfs_index.cpp similarity index 96% rename from ABACUS.develop/source/src_lcao/exx_abfs-abfs_index.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-abfs_index.cpp index db383d63e2..a8763279b5 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-abfs_index.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-abfs_index.cpp @@ -1,5 +1,5 @@ #include "exx_abfs-abfs_index.h" -#include "ORB_read.h" +#include "src_lcao/ORB_read.h" Element_Basis_Index::Range Exx_Abfs::Abfs_Index::construct_range( const LCAO_Orbitals &orb ) diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-abfs_index.h b/ABACUS.develop/source/src_ri/exx_abfs-abfs_index.h similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-abfs_index.h rename to ABACUS.develop/source/src_ri/exx_abfs-abfs_index.h diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-construct_orbs.cpp b/ABACUS.develop/source/src_ri/exx_abfs-construct_orbs.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/exx_abfs-construct_orbs.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-construct_orbs.cpp index cad4a3a273..59daf83038 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-construct_orbs.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-construct_orbs.cpp @@ -5,7 +5,7 @@ #include "src_global/gram_schmidt_orth.h" #include "src_global/gram_schmidt_orth-inl.h" -#include "src_external/src_test/src_lcao/exx_abfs-construct_orbs-test.h" // Peize Lin test +#include "src_external/src_test/src_ri/exx_abfs-construct_orbs-test.h" // Peize Lin test #include "src_lcao/global_fp.h" vector>> Exx_Abfs::Construct_Orbs::change_orbs( diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-construct_orbs.h b/ABACUS.develop/source/src_ri/exx_abfs-construct_orbs.h similarity index 97% rename from ABACUS.develop/source/src_lcao/exx_abfs-construct_orbs.h rename to ABACUS.develop/source/src_ri/exx_abfs-construct_orbs.h index f62e9d38af..ff8aff1be0 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-construct_orbs.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-construct_orbs.h @@ -4,7 +4,7 @@ #include "exx_abfs.h" #include -#include "ORB_atomic_lm.h" +#include "src_lcao/ORB_atomic_lm.h" class LCAO_Orbitals; @@ -58,4 +58,4 @@ class Exx_Abfs::Construct_Orbs const vector>> &orbs ); }; -#endif // EXX_ABFS_IO_ASA_H \ No newline at end of file +#endif // EXX_ABFS_IO_ASA_H diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-dm.cpp b/ABACUS.develop/source/src_ri/exx_abfs-dm.cpp similarity index 98% rename from ABACUS.develop/source/src_lcao/exx_abfs-dm.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-dm.cpp index a7171426db..afb50a6b08 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-dm.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-dm.cpp @@ -7,8 +7,8 @@ #include "src_external/src_test/src_global/matrix-test.h" #include "src_external/src_test/src_global/complexmatrix-test.h" -#include "src_external/src_test/src_lcao/exx_lcao-test.h" -#include "src_external/src_test/src_lcao/exx_abfs-dm-test.h" +#include "src_external/src_test/src_ri/exx_lcao-test.h" +#include "src_external/src_test/src_ri/exx_abfs-dm-test.h" void Exx_Abfs::DM::cal_DM( const set> &atom_pairs, diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-dm.h b/ABACUS.develop/source/src_ri/exx_abfs-dm.h similarity index 97% rename from ABACUS.develop/source/src_lcao/exx_abfs-dm.h rename to ABACUS.develop/source/src_ri/exx_abfs-dm.h index 5c645fe8e4..3c5f7ff74f 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-dm.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-dm.h @@ -2,7 +2,7 @@ #define EXX_ABFS_DM_H #include "exx_abfs.h" -#include "src_lcao/abfs-vector3_order.h" +#include "src_ri/abfs-vector3_order.h" #include #include diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-inl.h b/ABACUS.develop/source/src_ri/exx_abfs-inl.h similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-inl.h rename to ABACUS.develop/source/src_ri/exx_abfs-inl.h diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-inverse_matrix_double.cpp b/ABACUS.develop/source/src_ri/exx_abfs-inverse_matrix_double.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-inverse_matrix_double.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-inverse_matrix_double.cpp diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-inverse_matrix_double.h b/ABACUS.develop/source/src_ri/exx_abfs-inverse_matrix_double.h similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-inverse_matrix_double.h rename to ABACUS.develop/source/src_ri/exx_abfs-inverse_matrix_double.h diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-io-template.h b/ABACUS.develop/source/src_ri/exx_abfs-io-template.h similarity index 98% rename from ABACUS.develop/source/src_lcao/exx_abfs-io-template.h rename to ABACUS.develop/source/src_ri/exx_abfs-io-template.h index 0d078c8396..a5782ea357 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-io-template.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-io-template.h @@ -1,7 +1,7 @@ #ifndef EXX_ABFS_IO_TEMPLATE_H #define EXX_ABFS_IO_TEMPLATE_H -#include "src_lcao/exx_abfs-io.h" +#include "src_ri/exx_abfs-io.h" #include #include diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-io.cpp b/ABACUS.develop/source/src_ri/exx_abfs-io.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-io.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-io.cpp diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-io.h b/ABACUS.develop/source/src_ri/exx_abfs-io.h similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-io.h rename to ABACUS.develop/source/src_ri/exx_abfs-io.h diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-jle.cpp b/ABACUS.develop/source/src_ri/exx_abfs-jle.cpp similarity index 97% rename from ABACUS.develop/source/src_lcao/exx_abfs-jle.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-jle.cpp index 80934983d0..cc0d707b9d 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-jle.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-jle.cpp @@ -1,7 +1,7 @@ #include "exx_abfs-jle.h" #include "../src_pw/global.h" -#include "ORB_read.h" +#include "src_lcao/ORB_read.h" #include "../src_global/global_function.h" #include "../src_global/mathzone.h" @@ -53,4 +53,4 @@ void Exx_Abfs::Jle::init_jle( const double kmesh_times ) } } } -} \ No newline at end of file +} diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-jle.h b/ABACUS.develop/source/src_ri/exx_abfs-jle.h similarity index 78% rename from ABACUS.develop/source/src_lcao/exx_abfs-jle.h rename to ABACUS.develop/source/src_ri/exx_abfs-jle.h index 8c23e3a4d0..f85c643ef3 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-jle.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-jle.h @@ -3,8 +3,8 @@ #include "exx_abfs.h" -#include -#include "ORB_atomic_lm.h" +#include +#include "src_lcao/ORB_atomic_lm.h" class Exx_Abfs::Jle { @@ -22,4 +22,4 @@ class Exx_Abfs::Jle static double tolerence; }; -#endif // EXX_ABFS_JLE_H \ No newline at end of file +#endif // EXX_ABFS_JLE_H diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp b/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp index bb7eb2a247..499d3e1524 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp @@ -1,9 +1,7 @@ #include "exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h" - #include "../src_pw/global.h" -#include "ORB_read.h" -#include "ylm.h" - +#include "src_lcao/ORB_read.h" +#include "src_lcao/ylm.h" #include "../src_external/src_test/test_function.h" // Peize Lin test 2016-04-05 void Exx_Abfs::Matrix_Lcaoslcaos_Lcaoslcaos::init( @@ -307,4 +305,4 @@ map>>> Exx_Abfs::Matrix_Lcaoslca } } } -*/ \ No newline at end of file +*/ diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h b/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h similarity index 91% rename from ABACUS.develop/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h rename to ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h index 3abca01ab8..8720126cca 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h @@ -9,9 +9,9 @@ using std::map; using std::set; #include "exx_abfs.h" -#include "ORB_radial_table.h" -#include "ORB_gaunt_table.h" -#include "center2_orb-orb22.h" +#include "src_lcao/ORB_radial_table.h" +#include "src_lcao/ORB_gaunt_table.h" +#include "src_lcao/center2_orb-orb22.h" class LCAO_Orbitals; @@ -52,4 +52,4 @@ class Exx_Abfs::Matrix_Lcaoslcaos_Lcaoslcaos map>>>>> center2_orb22_s; }; -#endif \ No newline at end of file +#endif diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs11.cpp b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs11.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs11.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs11.cpp index 52ce03b3f3..cc4fc86b35 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs11.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs11.cpp @@ -9,7 +9,7 @@ #include // Peize Lin test #include "src_external/src_test/test_function.h" // Peize Lin test 2016-04-05 -#include "src_external/src_test/src_lcao/exx_lcao-test.h" +#include "src_external/src_test/src_ri/exx_lcao-test.h" #include "src_lcao/global_fp.h" void Exx_Abfs::Matrix_Orbs11::init( diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs11.h b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs11.h similarity index 93% rename from ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs11.h rename to ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs11.h index 5292e00c3b..057aa97aa0 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs11.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs11.h @@ -9,9 +9,9 @@ using std::map; using std::set; #include "exx_abfs.h" -#include "ORB_radial_table.h" -#include "ORB_gaunt_table.h" -#include "center2_orb-orb11.h" +#include "src_lcao/ORB_radial_table.h" +#include "src_lcao/ORB_gaunt_table.h" +#include "src_lcao/center2_orb-orb11.h" class LCAO_Orbitals; @@ -62,4 +62,4 @@ class Exx_Abfs::Matrix_Orbs11 // this->center2_orb11_s[TA][TB][LA][NA][LB][NB] -#endif \ No newline at end of file +#endif diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs21.cpp b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs21.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs21.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs21.cpp index 008e5a285b..6507c6352d 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs21.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs21.cpp @@ -11,7 +11,7 @@ #include // Peize Lin test #include "src_external/src_test/test_function.h" // Peize Lin test 2016-04-05 -#include "src_external/src_test/src_lcao/exx_lcao-test.h" +#include "src_external/src_test/src_ri/exx_lcao-test.h" #include "src_lcao/global_fp.h" void Exx_Abfs::Matrix_Orbs21::init( diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs21.h b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs21.h similarity index 95% rename from ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs21.h rename to ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs21.h index 6a2f3dfa08..501e6b2164 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs21.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs21.h @@ -14,9 +14,9 @@ using std::map; using std::set; #include "exx_abfs.h" -#include "ORB_radial_table.h" -#include "ORB_gaunt_table.h" -#include "center2_orb-orb21.h" +#include "src_lcao/ORB_radial_table.h" +#include "src_lcao/ORB_gaunt_table.h" +#include "src_lcao/center2_orb-orb21.h" class LCAO_Orbitals; @@ -82,4 +82,4 @@ class Exx_Abfs::Matrix_Orbs21 // this->center2_orb21_s[TA][TB][LA1][NA1][LA2][NA2][LB][NB] -#endif \ No newline at end of file +#endif diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs22.cpp b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs22.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs22.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs22.cpp index 462c6b5f78..2999026054 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs22.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs22.cpp @@ -8,7 +8,7 @@ #include "src_lcao/ylm.h" #include "../src_external/src_test/test_function.h" // Peize Lin test 2016-04-05 -#include "src_external/src_test/src_lcao/exx_lcao-test.h" +#include "src_external/src_test/src_ri/exx_lcao-test.h" #include "src_lcao/global_fp.h" void Exx_Abfs::Matrix_Orbs22::init( diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs22.h b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs22.h similarity index 94% rename from ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs22.h rename to ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs22.h index 67c32c2d78..7c8db9635d 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-matrix_orbs22.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs22.h @@ -5,9 +5,9 @@ using std::map; #include "exx_abfs.h" -#include "ORB_radial_table.h" -#include "ORB_gaunt_table.h" -#include "center2_orb-orb22.h" +#include "src_lcao/ORB_radial_table.h" +#include "src_lcao/ORB_gaunt_table.h" +#include "src_lcao/center2_orb-orb22.h" class LCAO_Orbitals; @@ -69,4 +69,4 @@ class Exx_Abfs::Matrix_Orbs22 map>>>>>>>>> center2_orb22_s; }; -#endif \ No newline at end of file +#endif diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-allreduce-template.h b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-allreduce-template.h similarity index 98% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-allreduce-template.h rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-allreduce-template.h index e781bb6e5a..e60ed17ef8 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-allreduce-template.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-allreduce-template.h @@ -16,7 +16,7 @@ #include #endif -#include "src_external/src_test/src_lcao/exx_lcao-test.h" +#include "src_external/src_test/src_ri/exx_lcao-test.h" template< typename T > diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-allreduce.cpp b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-allreduce.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-allreduce.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-allreduce.cpp diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-allreduce.h b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-allreduce.h similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-allreduce.h rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-allreduce.h diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm-allreduce.cpp b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm-allreduce.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm-allreduce.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm-allreduce.cpp index d06f9fc128..f4f34895b0 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm-allreduce.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm-allreduce.cpp @@ -6,7 +6,7 @@ #include #endif -#include "src_external/src_test/src_lcao/exx_lcao-test.h" +#include "src_external/src_test/src_ri/exx_lcao-test.h" Exx_Abfs::Parallel::Communicate::DM::Allreduce::Allreduce( const MPI_Comm & mpi_comm_in, diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm.cpp b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm.cpp index 64a18710c0..1090133487 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm.cpp @@ -3,7 +3,7 @@ #include "src_pw/global.h" #include "src_lcao/record_adj.h" -#include "src_external/src_test/src_lcao/exx_lcao-test.h" +#include "src_external/src_test/src_ri/exx_lcao-test.h" #include "lcao_nnr.h" //#include diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm.h b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm.h similarity index 98% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm.h rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm.h index 60e8ef77dc..d15182a39f 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm.h @@ -4,7 +4,7 @@ #include "exx_abfs-parallel.h" #include "src_global/matrix.h" #include "src_global/matrix_wrapper.h" -#include "src_lcao/abfs-vector3_order.h" +#include "src_ri/abfs-vector3_order.h" #include #include #include diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm2.cpp b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm2.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm2.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm2.cpp diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm2.h b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm2.h similarity index 95% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm2.h rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm2.h index b23d30705d..80f9d7f19d 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm2.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm2.h @@ -3,7 +3,7 @@ #include "exx_abfs-parallel.h" #include "src_global/matrix.h" -#include "src_lcao/abfs-vector3_order.h" +#include "src_ri/abfs-vector3_order.h" #include #include diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3-allreduce.cpp b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm3-allreduce.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3-allreduce.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm3-allreduce.cpp diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3-template.h b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm3-template.h similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3-template.h rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm3-template.h diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3.cpp b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm3.cpp similarity index 96% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm3.cpp index 5417b8b2aa..6330d6d509 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm3.cpp @@ -2,7 +2,7 @@ #include "exx_abfs-parallel-communicate-dm3-template.h" #include "src_pw/global.h" #include "src_lcao/global_fp.h" -#include "src_lcao/abfs-template.h" +#include "src_ri/abfs-template.h" #include "src_external/src_test/test_function.h" #include "src_external/src_test/src_global/complexmatrix-test.h" diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3.h b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm3.h similarity index 95% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3.h rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm3.h index b2e59aa9ec..05dbe241c0 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-dm3.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm3.h @@ -1,8 +1,8 @@ #ifndef EXX_ABFS_PARALLEL_COMMUNICATE_DM3_H #define EXX_ABFS_PARALLEL_COMMUNICATE_DM3_H -#include "src_lcao/exx_abfs-parallel.h" -#include "src_lcao/abfs-vector3_order.h" +#include "src_ri/exx_abfs-parallel.h" +#include "src_ri/abfs-vector3_order.h" #include #include diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-function.cpp b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-function.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-function.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-function.cpp diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-function.h b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-function.h similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-function.h rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-function.h diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce.cpp b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-hexx-allreduce.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-hexx-allreduce.cpp diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-hexx-allreduce2.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx-allreduce2.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-hexx-allreduce2.cpp diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx-template.h b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-hexx-template.h similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx-template.h rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-hexx-template.h diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-hexx.cpp similarity index 98% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-hexx.cpp index fe94154564..41a5b5b8b2 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-hexx.cpp @@ -10,7 +10,7 @@ #include "exx_abfs-io-template.h" -#include "src_external/src_test/src_lcao/exx_lcao-test.h" +#include "src_external/src_test/src_ri/exx_lcao-test.h" #include "src_external/src_test/test_function.h" //#include diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.h b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-hexx.h similarity index 99% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.h rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-hexx.h index a37a543f6a..b41cf01bed 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-communicate-hexx.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-hexx.h @@ -5,7 +5,7 @@ #include "src_global/matrix.h" #include "src_global/matrix_wrapper.h" #include "src_global/complexmatrix.h" -#include "src_lcao/abfs-vector3_order.h" +#include "src_ri/abfs-vector3_order.h" #include #include #include diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-distribute-htime.cpp b/ABACUS.develop/source/src_ri/exx_abfs-parallel-distribute-htime.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-distribute-htime.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-distribute-htime.cpp index 3f65440af5..385d167380 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-distribute-htime.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-parallel-distribute-htime.cpp @@ -1,7 +1,7 @@ #include "exx_abfs-parallel-distribute-htime.h" #include "src_pw/global.h" -#include "src_lcao/abfs.h" +#include "src_ri/abfs.h" #include vector> Exx_Abfs::Parallel::Distribute::Htime::distribute( diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-distribute-htime.h b/ABACUS.develop/source/src_ri/exx_abfs-parallel-distribute-htime.h similarity index 96% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-distribute-htime.h rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-distribute-htime.h index 8ef727a77b..46d3495bd3 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-distribute-htime.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-parallel-distribute-htime.h @@ -3,7 +3,7 @@ #include "exx_abfs-parallel.h" -#include "src_lcao/abfs.h" +#include "src_ri/abfs.h" #include #include diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-distribute-kmeans.cpp b/ABACUS.develop/source/src_ri/exx_abfs-parallel-distribute-kmeans.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-distribute-kmeans.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-distribute-kmeans.cpp diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-distribute-kmeans.h b/ABACUS.develop/source/src_ri/exx_abfs-parallel-distribute-kmeans.h similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-distribute-kmeans.h rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-distribute-kmeans.h diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-distribute-order.cpp b/ABACUS.develop/source/src_ri/exx_abfs-parallel-distribute-order.cpp similarity index 98% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-distribute-order.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-distribute-order.cpp index 0ce40cd0e3..385ffb7a35 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-distribute-order.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-parallel-distribute-order.cpp @@ -1,7 +1,7 @@ #include "exx_abfs-parallel-distribute-order.h" #include "src_pw/global.h" -#include "src_lcao/abfs.h" +#include "src_ri/abfs.h" #include vector> Exx_Abfs::Parallel::Distribute::Order::distribute( diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-distribute-order.h b/ABACUS.develop/source/src_ri/exx_abfs-parallel-distribute-order.h similarity index 91% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel-distribute-order.h rename to ABACUS.develop/source/src_ri/exx_abfs-parallel-distribute-order.h index 6441ec5972..57242093ad 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-parallel-distribute-order.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-parallel-distribute-order.h @@ -3,7 +3,7 @@ #include "exx_abfs-parallel.h" -#include "src_lcao/abfs.h" +#include "src_ri/abfs.h" #include #include diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-parallel.h b/ABACUS.develop/source/src_ri/exx_abfs-parallel.h similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-parallel.h rename to ABACUS.develop/source/src_ri/exx_abfs-parallel.h diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-pca.cpp b/ABACUS.develop/source/src_ri/exx_abfs-pca.cpp similarity index 98% rename from ABACUS.develop/source/src_lcao/exx_abfs-pca.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-pca.cpp index a39101b3a4..7feaa03e81 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-pca.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-pca.cpp @@ -12,7 +12,7 @@ #include #include "src_external/src_test/src_global/element_basis_index-test.h" // Peize Lin test -#include "src_external/src_test/src_lcao/exx_lcao-test.h" // Peize Lin test +#include "src_external/src_test/src_ri/exx_lcao-test.h" // Peize Lin test #include // Peize Lin test #include "src_lcao/global_fp.h" // Peize Lin test diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-pca.h b/ABACUS.develop/source/src_ri/exx_abfs-pca.h similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-pca.h rename to ABACUS.develop/source/src_ri/exx_abfs-pca.h diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-screen-cauchy.cpp b/ABACUS.develop/source/src_ri/exx_abfs-screen-cauchy.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/exx_abfs-screen-cauchy.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-screen-cauchy.cpp index 649a8e73bb..da8a7dc4bc 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-screen-cauchy.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-screen-cauchy.cpp @@ -2,7 +2,7 @@ #include "src_pw/global.h" -#include "src_external/src_test/src_lcao/exx_abfs-screen-test.h" +#include "src_external/src_test/src_ri/exx_abfs-screen-test.h" //double Exx_Abfs::Screen::Cauchy::num_screen1 = 0; //double Exx_Abfs::Screen::Cauchy::num_screen2 = 0; //double Exx_Abfs::Screen::Cauchy::num_screen3 = 0; diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-screen-cauchy.h b/ABACUS.develop/source/src_ri/exx_abfs-screen-cauchy.h similarity index 98% rename from ABACUS.develop/source/src_lcao/exx_abfs-screen-cauchy.h rename to ABACUS.develop/source/src_ri/exx_abfs-screen-cauchy.h index d0965c45c6..3baa3ba737 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-screen-cauchy.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-screen-cauchy.h @@ -2,7 +2,7 @@ #define EXX_ABFS_SCREEN_CAUCHY_H #include "exx_abfs.h" -#include "src_lcao/abfs-vector3_order.h" +#include "src_ri/abfs-vector3_order.h" #include #include diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-screen-schwarz.cpp b/ABACUS.develop/source/src_ri/exx_abfs-screen-schwarz.cpp similarity index 97% rename from ABACUS.develop/source/src_lcao/exx_abfs-screen-schwarz.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-screen-schwarz.cpp index ede5741de6..748dd162c7 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs-screen-schwarz.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-screen-schwarz.cpp @@ -6,8 +6,8 @@ #include #include -#include "src_external/src_test/src_lcao/exx_abfs-screen-test.h" -#include "src_external/src_test/src_lcao/exx_lcao-test.h" +#include "src_external/src_test/src_ri/exx_abfs-screen-test.h" +#include "src_external/src_test/src_ri/exx_lcao-test.h" //double Exx_Abfs::Screen::Schwarz::num_screen = 0; //double Exx_Abfs::Screen::Schwarz::num_cal = 0; diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-screen-schwarz.h b/ABACUS.develop/source/src_ri/exx_abfs-screen-schwarz.h similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-screen-schwarz.h rename to ABACUS.develop/source/src_ri/exx_abfs-screen-schwarz.h diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-util.cpp b/ABACUS.develop/source/src_ri/exx_abfs-util.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-util.cpp rename to ABACUS.develop/source/src_ri/exx_abfs-util.cpp diff --git a/ABACUS.develop/source/src_lcao/exx_abfs-util.h b/ABACUS.develop/source/src_ri/exx_abfs-util.h similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs-util.h rename to ABACUS.develop/source/src_ri/exx_abfs-util.h diff --git a/ABACUS.develop/source/src_lcao/exx_abfs.cpp b/ABACUS.develop/source/src_ri/exx_abfs.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/exx_abfs.cpp rename to ABACUS.develop/source/src_ri/exx_abfs.cpp index 5c21df8320..6c35bb7c7a 100644 --- a/ABACUS.develop/source/src_lcao/exx_abfs.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs.cpp @@ -10,15 +10,15 @@ #include "exx_abfs-matrix_orbs21.h" #include "exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h" -#include "ORB_read.h" +#include "src_lcao/ORB_read.h" #include "conv_coulomb_pot.h" #include "conv_coulomb_pot-inl.h" #include "src_global/global_function.h" #include "src_external/src_test/test_function.h" // Peize Lin test -#include "src_external/src_test/src_lcao/exx_abfs-unittest.h" -#include "src_external/src_test/src_lcao/make_gaunt_table-unittest.h" +#include "src_external/src_test/src_ri/exx_abfs-unittest.h" +#include "src_external/src_test/src_ri/make_gaunt_table-unittest.h" #include "src_external/src_test/src_global/element_basis_index-test.h" // Peize Lin test 2016-04-05 #include "src_pw/global.h" #include // Peize Lin test @@ -1077,4 +1077,4 @@ void density_matrix() } } } -*/ \ No newline at end of file +*/ diff --git a/ABACUS.develop/source/src_lcao/exx_abfs.h b/ABACUS.develop/source/src_ri/exx_abfs.h similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_abfs.h rename to ABACUS.develop/source/src_ri/exx_abfs.h diff --git a/ABACUS.develop/source/src_lcao/exx_lcao.cpp b/ABACUS.develop/source/src_ri/exx_lcao.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/exx_lcao.cpp rename to ABACUS.develop/source/src_ri/exx_lcao.cpp index 7b186a62dd..407861122a 100644 --- a/ABACUS.develop/source/src_lcao/exx_lcao.cpp +++ b/ABACUS.develop/source/src_ri/exx_lcao.cpp @@ -31,8 +31,8 @@ #include "src_external/src_test/src_global/matrix-test.h" #include "src_external/src_test/print_tmp.h" #include "src_external/src_test/src_global/sph_bessel-unittest.h" -#include "src_external/src_test/src_lcao/exx_lcao-test.h" -#include "src_external/src_test/src_lcao/abfs-test.h" +#include "src_external/src_test/src_ri/exx_lcao-test.h" +#include "src_external/src_test/src_ri/abfs-test.h" #include "src_lcao/lcao_nnr.h" /* diff --git a/ABACUS.develop/source/src_lcao/exx_lcao.h b/ABACUS.develop/source/src_ri/exx_lcao.h similarity index 86% rename from ABACUS.develop/source/src_lcao/exx_lcao.h rename to ABACUS.develop/source/src_ri/exx_lcao.h index 927565457d..a1d50d00d8 100644 --- a/ABACUS.develop/source/src_lcao/exx_lcao.h +++ b/ABACUS.develop/source/src_ri/exx_lcao.h @@ -1,24 +1,24 @@ #ifndef EXX_LCAO_H #define EXX_LCAO_H -#include "src_lcao/abfs.h" -#include "src_lcao/abfs-vector3_order.h" -#include "src_lcao/exx_abfs-matrix_orbs11.h" -#include "src_lcao/exx_abfs-matrix_orbs21.h" -#include "src_lcao/exx_abfs-dm.h" -#include "src_lcao/exx_abfs-parallel-communicate-hexx.h" -#include "src_lcao/exx_abfs-screen-schwarz.h" -#include "src_lcao/exx_abfs-screen-cauchy.h" +#include "src_ri/abfs.h" +#include "src_ri/abfs-vector3_order.h" +#include "src_ri/exx_abfs-matrix_orbs11.h" +#include "src_ri/exx_abfs-matrix_orbs21.h" +#include "src_ri/exx_abfs-dm.h" +#include "src_ri/exx_abfs-parallel-communicate-hexx.h" +#include "src_ri/exx_abfs-screen-schwarz.h" +#include "src_ri/exx_abfs-screen-cauchy.h" #include "src_global/element_basis_index.h" #include "src_pw/functional.h" #include "src_pw/exx_global.h" #if EXX_DM==1 -#include "src_lcao/exx_abfs-parallel-communicate-dm.h" +#include "src_ri/exx_abfs-parallel-communicate-dm.h" #elif EXX_DM==2 -#include "src_lcao/exx_abfs-parallel-communicate-dm2.h" +#include "src_ri/exx_abfs-parallel-communicate-dm2.h" #elif EXX_DM==3 -#include "src_lcao/exx_abfs-parallel-communicate-dm3.h" +#include "src_ri/exx_abfs-parallel-communicate-dm3.h" #endif #include diff --git a/ABACUS.develop/source/src_lcao/exx_opt_orb-print.cpp b/ABACUS.develop/source/src_ri/exx_opt_orb-print.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/exx_opt_orb-print.cpp rename to ABACUS.develop/source/src_ri/exx_opt_orb-print.cpp index b64b14b3a2..31efc75646 100644 --- a/ABACUS.develop/source/src_lcao/exx_opt_orb-print.cpp +++ b/ABACUS.develop/source/src_ri/exx_opt_orb-print.cpp @@ -1,6 +1,6 @@ #include "exx_opt_orb.h" #include "src_pw/global.h" -#include "src_lcao/exx_abfs-jle.h" +#include "src_ri/exx_abfs-jle.h" void Exx_Opt_Orb::print_matrix( const string &file_name, diff --git a/ABACUS.develop/source/src_lcao/exx_opt_orb.cpp b/ABACUS.develop/source/src_ri/exx_opt_orb.cpp similarity index 96% rename from ABACUS.develop/source/src_lcao/exx_opt_orb.cpp rename to ABACUS.develop/source/src_ri/exx_opt_orb.cpp index b9f4fa8799..a72fa66c0e 100644 --- a/ABACUS.develop/source/src_lcao/exx_opt_orb.cpp +++ b/ABACUS.develop/source/src_ri/exx_opt_orb.cpp @@ -1,18 +1,18 @@ #include "exx_opt_orb.h" #include "src_pw/global.h" #include "src_lcao/ORB_atomic_lm.h" -#include "src_lcao/exx_abfs.h" -#include "src_lcao/exx_abfs-abfs_index.h" -#include "src_lcao/exx_abfs-construct_orbs.h" -#include "src_lcao/exx_abfs-inverse_matrix_double.h" -#include "src_lcao/exx_abfs-jle.h" +#include "src_ri/exx_abfs.h" +#include "src_ri/exx_abfs-abfs_index.h" +#include "src_ri/exx_abfs-construct_orbs.h" +#include "src_ri/exx_abfs-inverse_matrix_double.h" +#include "src_ri/exx_abfs-jle.h" #include "src_lcao/ORB_read.h" -#include "src_lcao/exx_abfs-matrix_orbs11.h" -#include "src_lcao/exx_abfs-matrix_orbs21.h" -#include "src_lcao/exx_abfs-matrix_orbs22.h" +#include "src_ri/exx_abfs-matrix_orbs11.h" +#include "src_ri/exx_abfs-matrix_orbs21.h" +#include "src_ri/exx_abfs-matrix_orbs22.h" -#include "src_external/src_test/src_lcao/exx_abfs-unittest.h" -#include "src_external/src_test/src_lcao/exx_lcao-test.h" +#include "src_external/src_test/src_ri/exx_abfs-unittest.h" +#include "src_external/src_test/src_ri/exx_lcao-test.h" #include "src_external/src_test/src_global/element_basis_index-test.h" #include "src_external/src_test/test_function.h" diff --git a/ABACUS.develop/source/src_lcao/exx_opt_orb.h b/ABACUS.develop/source/src_ri/exx_opt_orb.h similarity index 100% rename from ABACUS.develop/source/src_lcao/exx_opt_orb.h rename to ABACUS.develop/source/src_ri/exx_opt_orb.h From 3be204a5e1de4f6720db718ba98db522bc41fcd1 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 10 Feb 2021 21:56:39 +0800 Subject: [PATCH 105/233] move lcao_matrix to LCAO_matrix, move use_hamilt_matrix to LCAO_hamilt, move use_overlap_matrix to LCAO_gen_fixedH, move lcao_nnr to LCAO_nnr, move diago_lcao_matrix to LCAO_diago, move evolve_lcao_matrix to LCAO_evolve --- ABACUS.develop/source/Makefile.Objects | 12 ++++++------ .../source/src_lcao/ELEC_cbands_gamma.cpp | 4 ++-- .../source/src_lcao/ELEC_cbands_gamma.h | 2 +- ABACUS.develop/source/src_lcao/ELEC_cbands_k.cpp | 4 ++-- ABACUS.develop/source/src_lcao/ELEC_cbands_k.h | 2 +- ABACUS.develop/source/src_lcao/ELEC_evolve.cpp | 4 ++-- ABACUS.develop/source/src_lcao/ELEC_evolve.h | 2 +- ABACUS.develop/source/src_lcao/ELEC_nscf.h | 2 +- ABACUS.develop/source/src_lcao/ELEC_scf.cpp | 2 +- .../{diago_lcao_matrix.cpp => LCAO_diago.cpp} | 2 +- .../{diago_lcao_matrix.h => LCAO_diago.h} | 0 .../{evolve_lcao_matrix.cpp => LCAO_evolve.cpp} | 2 +- .../{evolve_lcao_matrix.h => LCAO_evolve.h} | 0 ...use_overlap_matrix.cpp => LCAO_gen_fixedH.cpp} | 4 ++-- .../{use_overlap_matrix.h => LCAO_gen_fixedH.h} | 0 .../{use_hamilt_matrix.cpp => LCAO_hamilt.cpp} | 4 ++-- .../{use_hamilt_matrix.h => LCAO_hamilt.h} | 2 +- .../src_lcao/{lcao_matrix.cpp => LCAO_matrix.cpp} | 2 +- .../src_lcao/{lcao_matrix.h => LCAO_matrix.h} | 0 .../src_lcao/{lcao_nnr.cpp => LCAO_nnr.cpp} | 15 +++++++++++---- .../source/src_lcao/{lcao_nnr.h => LCAO_nnr.h} | 5 +++-- ABACUS.develop/source/src_lcao/dftu.cpp | 2 +- ABACUS.develop/source/src_lcao/dftu_relax.cpp | 2 +- ABACUS.develop/source/src_lcao/dftu_yukawa.cpp | 2 +- ABACUS.develop/source/src_lcao/force_lcao_gamma.h | 2 +- ABACUS.develop/source/src_lcao/force_lcao_k.cpp | 4 ++-- ABACUS.develop/source/src_lcao/force_lcao_k.h | 2 +- ABACUS.develop/source/src_lcao/gint_gamma.h | 2 +- ABACUS.develop/source/src_lcao/gint_k.cpp | 2 +- ABACUS.develop/source/src_lcao/gint_k.h | 2 +- ABACUS.develop/source/src_lcao/gint_k_fvl.cpp | 2 +- ABACUS.develop/source/src_lcao/gint_k_rho.cpp | 2 +- ABACUS.develop/source/src_lcao/gint_k_vl.cpp | 2 +- ABACUS.develop/source/src_lcao/global_fp.h | 6 +++--- .../source/src_lcao/local_orbital_charge.cpp | 2 +- .../source/src_lcao/local_orbital_elec.cpp | 6 +++--- .../source/src_lcao/local_orbital_ions.cpp | 2 +- .../source/src_lcao/mulliken_charge.cpp | 11 +++-------- ABACUS.develop/source/src_lcao/mulliken_charge.h | 4 ++-- ABACUS.develop/source/src_lcao/record_adj.cpp | 2 +- .../source/src_lcao/unk_overlap_lcao.cpp | 2 +- ABACUS.develop/source/src_pw/energy.cpp | 8 +++----- ABACUS.develop/source/src_ri/exx_lcao.cpp | 2 +- 43 files changed, 71 insertions(+), 70 deletions(-) rename ABACUS.develop/source/src_lcao/{diago_lcao_matrix.cpp => LCAO_diago.cpp} (99%) rename ABACUS.develop/source/src_lcao/{diago_lcao_matrix.h => LCAO_diago.h} (100%) rename ABACUS.develop/source/src_lcao/{evolve_lcao_matrix.cpp => LCAO_evolve.cpp} (99%) rename ABACUS.develop/source/src_lcao/{evolve_lcao_matrix.h => LCAO_evolve.h} (100%) rename ABACUS.develop/source/src_lcao/{use_overlap_matrix.cpp => LCAO_gen_fixedH.cpp} (99%) rename ABACUS.develop/source/src_lcao/{use_overlap_matrix.h => LCAO_gen_fixedH.h} (100%) rename ABACUS.develop/source/src_lcao/{use_hamilt_matrix.cpp => LCAO_hamilt.cpp} (99%) rename ABACUS.develop/source/src_lcao/{use_hamilt_matrix.h => LCAO_hamilt.h} (96%) rename ABACUS.develop/source/src_lcao/{lcao_matrix.cpp => LCAO_matrix.cpp} (99%) rename ABACUS.develop/source/src_lcao/{lcao_matrix.h => LCAO_matrix.h} (100%) rename ABACUS.develop/source/src_lcao/{lcao_nnr.cpp => LCAO_nnr.cpp} (98%) rename ABACUS.develop/source/src_lcao/{lcao_nnr.h => LCAO_nnr.h} (96%) diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index a85dccbe75..2f4b4181bf 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -105,8 +105,6 @@ sltk_atom_arrange.o\ sltk_atom.o\ sltk_adjacent_set.o\ sltk_atom_input.o\ -use_overlap_matrix.o\ -use_hamilt_matrix.o\ build_st_pw.o\ grid_technique.o\ grid_meshk.o\ @@ -146,12 +144,14 @@ ELEC_nscf.o\ local_orbital_ions.o\ local_orbital_charge.o\ record_adj.o\ -lcao_matrix.o\ -lcao_nnr.o \ istate_charge.o \ istate_envelope.o \ -diago_lcao_matrix.o\ -evolve_lcao_matrix.o\ +LCAO_gen_fixedH.o\ +LCAO_hamilt.o\ +LCAO_matrix.o\ +LCAO_nnr.o \ +LCAO_diago.o\ +LCAO_evolve.o\ ylm.o\ force_lcao.o\ force_lcao_gamma.o\ diff --git a/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp b/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp index e7b3ceb052..838cd7a2f9 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp @@ -1,9 +1,9 @@ #include "ELEC_cbands_gamma.h" #include "local_orbital_elec.h" -#include "diago_lcao_matrix.h" +#include "LCAO_diago.h" #include "src_pw/global.h" #include "src_pw/symmetry_rho.h" -#include "evolve_lcao_matrix.h" +#include "LCAO_evolve.h" #include "dftu.h" diff --git a/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.h b/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.h index a131d1d089..55d6d50178 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.h +++ b/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.h @@ -2,7 +2,7 @@ #define ELEC_CBANDS_GAMMA_H #include "../src_pw/tools.h" -#include "use_hamilt_matrix.h" +#include "LCAO_hamilt.h" //----------------------------------------------------------- // mohan add 2021-02-09 diff --git a/ABACUS.develop/source/src_lcao/ELEC_cbands_k.cpp b/ABACUS.develop/source/src_lcao/ELEC_cbands_k.cpp index 53a22dd2a6..89446d35ba 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_cbands_k.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_cbands_k.cpp @@ -1,9 +1,9 @@ #include "ELEC_cbands_k.h" #include "local_orbital_elec.h" -#include "diago_lcao_matrix.h" +#include "LCAO_diago.h" #include "src_pw/global.h" #include "src_pw/symmetry_rho.h" -#include "evolve_lcao_matrix.h" +#include "LCAO_evolve.h" #include "dftu.h" ELEC_cbands_k::ELEC_cbands_k(){}; diff --git a/ABACUS.develop/source/src_lcao/ELEC_cbands_k.h b/ABACUS.develop/source/src_lcao/ELEC_cbands_k.h index 6d49d7483a..c3d8d01b26 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_cbands_k.h +++ b/ABACUS.develop/source/src_lcao/ELEC_cbands_k.h @@ -2,7 +2,7 @@ #define ELEC_CBANDS_K_H #include "../src_pw/tools.h" -#include "use_hamilt_matrix.h" +#include "LCAO_hamilt.h" //----------------------------------------------------------- // mohan add 2021-02-09 diff --git a/ABACUS.develop/source/src_lcao/ELEC_evolve.cpp b/ABACUS.develop/source/src_lcao/ELEC_evolve.cpp index 0d3b5ce362..2f316f9057 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_evolve.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_evolve.cpp @@ -1,9 +1,9 @@ #include "ELEC_evolve.h" #include "local_orbital_elec.h" -#include "diago_lcao_matrix.h" +#include "LCAO_diago.h" #include "src_pw/global.h" #include "src_pw/symmetry_rho.h" -#include "evolve_lcao_matrix.h" +#include "LCAO_evolve.h" #include "dftu.h" ELEC_evolve::ELEC_evolve(){}; diff --git a/ABACUS.develop/source/src_lcao/ELEC_evolve.h b/ABACUS.develop/source/src_lcao/ELEC_evolve.h index d7299cdbfa..39691d1b1b 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_evolve.h +++ b/ABACUS.develop/source/src_lcao/ELEC_evolve.h @@ -2,7 +2,7 @@ #define ELEC_EVOLVE_H #include "../src_pw/tools.h" -#include "use_hamilt_matrix.h" +#include "LCAO_hamilt.h" //----------------------------------------------------------- // mohan add 2021-02-09 diff --git a/ABACUS.develop/source/src_lcao/ELEC_nscf.h b/ABACUS.develop/source/src_lcao/ELEC_nscf.h index 1d15313b72..84f9426dce 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_nscf.h +++ b/ABACUS.develop/source/src_lcao/ELEC_nscf.h @@ -2,7 +2,7 @@ #define ELEC_NSCF_H #include "../src_pw/tools.h" -#include "use_hamilt_matrix.h" +#include "LCAO_hamilt.h" //----------------------------------------------------------- // mohan add 2021-02-09 diff --git a/ABACUS.develop/source/src_lcao/ELEC_scf.cpp b/ABACUS.develop/source/src_lcao/ELEC_scf.cpp index 4e0da3e649..ab6a015ab8 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_scf.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_scf.cpp @@ -3,7 +3,7 @@ #include "src_pw/chi0_hilbert.h" #include "src_pw/symmetry_rho.h" #include "dftu.h" -#include "evolve_lcao_matrix.h" +#include "LCAO_evolve.h" #include "ELEC_cbands_k.h" #include "ELEC_cbands_gamma.h" #include "ELEC_evolve.h" diff --git a/ABACUS.develop/source/src_lcao/diago_lcao_matrix.cpp b/ABACUS.develop/source/src_lcao/LCAO_diago.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/diago_lcao_matrix.cpp rename to ABACUS.develop/source/src_lcao/LCAO_diago.cpp index f3795170ab..8dd180a9cb 100644 --- a/ABACUS.develop/source/src_lcao/diago_lcao_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_diago.cpp @@ -1,4 +1,4 @@ -#include "diago_lcao_matrix.h" +#include "LCAO_diago.h" #include "../src_pw/algorithms.h" #include "../src_pw/global.h" #include "../src_external/src_pdiag/pdiag_double.h" diff --git a/ABACUS.develop/source/src_lcao/diago_lcao_matrix.h b/ABACUS.develop/source/src_lcao/LCAO_diago.h similarity index 100% rename from ABACUS.develop/source/src_lcao/diago_lcao_matrix.h rename to ABACUS.develop/source/src_lcao/LCAO_diago.h diff --git a/ABACUS.develop/source/src_lcao/evolve_lcao_matrix.cpp b/ABACUS.develop/source/src_lcao/LCAO_evolve.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/evolve_lcao_matrix.cpp rename to ABACUS.develop/source/src_lcao/LCAO_evolve.cpp index 61d7448210..a9714c7e38 100644 --- a/ABACUS.develop/source/src_lcao/evolve_lcao_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_evolve.cpp @@ -1,4 +1,4 @@ -#include "evolve_lcao_matrix.h" +#include "LCAO_evolve.h" #include "../src_pw/algorithms.h" #include "../src_pw/global.h" #include "../src_external/src_pdiag/pdiag_double.h" diff --git a/ABACUS.develop/source/src_lcao/evolve_lcao_matrix.h b/ABACUS.develop/source/src_lcao/LCAO_evolve.h similarity index 100% rename from ABACUS.develop/source/src_lcao/evolve_lcao_matrix.h rename to ABACUS.develop/source/src_lcao/LCAO_evolve.h diff --git a/ABACUS.develop/source/src_lcao/use_overlap_matrix.cpp b/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/use_overlap_matrix.cpp rename to ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.cpp index 21b1dae741..3eab07ed64 100644 --- a/ABACUS.develop/source/src_lcao/use_overlap_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.cpp @@ -1,8 +1,8 @@ -#include "use_overlap_matrix.h" +#include "LCAO_gen_fixedH.h" #include "../src_pw/global.h" #include "../src_pw/wavefunc.h" //#include "../src_develop/src_wannier/manipulation.h" -#include "lcao_nnr.h" +#include "LCAO_nnr.h" #include "global_fp.h" // mohan add 2021-01-30 diff --git a/ABACUS.develop/source/src_lcao/use_overlap_matrix.h b/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.h similarity index 100% rename from ABACUS.develop/source/src_lcao/use_overlap_matrix.h rename to ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.h diff --git a/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp b/ABACUS.develop/source/src_lcao/LCAO_hamilt.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp rename to ABACUS.develop/source/src_lcao/LCAO_hamilt.cpp index 449ff4a0a8..7ab448f494 100644 --- a/ABACUS.develop/source/src_lcao/use_hamilt_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_hamilt.cpp @@ -1,5 +1,5 @@ #include "../src_pw/global.h" -#include "use_hamilt_matrix.h" +#include "LCAO_hamilt.h" #include "build_st_pw.h" #include "../src_global/sltk_atom_arrange.h" #include "global_fp.h" // mohan add 2021-01-30 @@ -179,7 +179,7 @@ void Use_Hamilt_Matrix::calculate_STNR_gamma(void) } -#include "lcao_nnr.h" +#include "LCAO_nnr.h" // be called in Local_Orbital_Elec::cal_bands(). void Use_Hamilt_Matrix::calculate_Hk(const int &ik) { diff --git a/ABACUS.develop/source/src_lcao/use_hamilt_matrix.h b/ABACUS.develop/source/src_lcao/LCAO_hamilt.h similarity index 96% rename from ABACUS.develop/source/src_lcao/use_hamilt_matrix.h rename to ABACUS.develop/source/src_lcao/LCAO_hamilt.h index e3b77e9e89..e3c7e9ac0f 100644 --- a/ABACUS.develop/source/src_lcao/use_hamilt_matrix.h +++ b/ABACUS.develop/source/src_lcao/LCAO_hamilt.h @@ -2,7 +2,7 @@ #define USE_HAMILT_MATRIX_H #include "../src_pw/tools.h" -#include "use_overlap_matrix.h" +#include "LCAO_gen_fixedH.h" #include "gint_gamma.h" #include "gint_k.h" #include "grid_integral.h" diff --git a/ABACUS.develop/source/src_lcao/lcao_matrix.cpp b/ABACUS.develop/source/src_lcao/LCAO_matrix.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/lcao_matrix.cpp rename to ABACUS.develop/source/src_lcao/LCAO_matrix.cpp index 3f85d570c0..34b406f2c5 100644 --- a/ABACUS.develop/source/src_lcao/lcao_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_matrix.cpp @@ -1,4 +1,4 @@ -#include "lcao_matrix.h" +#include "LCAO_matrix.h" #include "global_fp.h" LCAO_Matrix::LCAO_Matrix() diff --git a/ABACUS.develop/source/src_lcao/lcao_matrix.h b/ABACUS.develop/source/src_lcao/LCAO_matrix.h similarity index 100% rename from ABACUS.develop/source/src_lcao/lcao_matrix.h rename to ABACUS.develop/source/src_lcao/LCAO_matrix.h diff --git a/ABACUS.develop/source/src_lcao/lcao_nnr.cpp b/ABACUS.develop/source/src_lcao/LCAO_nnr.cpp similarity index 98% rename from ABACUS.develop/source/src_lcao/lcao_nnr.cpp rename to ABACUS.develop/source/src_lcao/LCAO_nnr.cpp index 76d90652e4..ea43f86367 100644 --- a/ABACUS.develop/source/src_lcao/lcao_nnr.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_nnr.cpp @@ -1,4 +1,4 @@ -#include "lcao_nnr.h" +#include "LCAO_nnr.h" #include "../src_pw/global.h" #include "record_adj.h" //mohan add 2012-07-06 #include "dftu.h" //quxin add 2020-10-29 @@ -565,7 +565,10 @@ void LCAO_nnr::folding_fixedH(const int &ik) // RA.for_2d(); //Quxin added for DFT+U calculation - if(INPUT.dft_plus_u) ZEROS( VECTOR_TO_PTR(dftu.Sm_k.at(ik)), ParaO.nloc); + if(INPUT.dft_plus_u) + { + ZEROS( VECTOR_TO_PTR(dftu.Sm_k.at(ik)), ParaO.nloc); + } int iat = 0; int index = 0; @@ -679,7 +682,8 @@ void LCAO_nnr::folding_fixedH(const int &ik) // Hloc_fixed2 is used to diagonalize (eliminate index R). //################################################################### - if(NSPIN!=4){ + if(NSPIN!=4) + { LM.Sloc2[iic] += LM.SlocR[index] * kphase; LM.Hloc_fixed2[iic] += LM.Hloc_fixedR[index] * kphase; @@ -692,7 +696,10 @@ void LCAO_nnr::folding_fixedH(const int &ik) LM.Hloc_fixed2[iic] += LM.Hloc_fixedR_soc[index] * kphase; //quxin added for DFT+U calculation - if(INPUT.dft_plus_u) dftu.Sm_k.at(ik).at(iic) += LM.SlocR_soc[index] * kphase; + if(INPUT.dft_plus_u) + { + dftu.Sm_k.at(ik).at(iic) += LM.SlocR_soc[index] * kphase; + } } ++index; diff --git a/ABACUS.develop/source/src_lcao/lcao_nnr.h b/ABACUS.develop/source/src_lcao/LCAO_nnr.h similarity index 96% rename from ABACUS.develop/source/src_lcao/lcao_nnr.h rename to ABACUS.develop/source/src_lcao/LCAO_nnr.h index a0d9012545..4760aab422 100644 --- a/ABACUS.develop/source/src_lcao/lcao_nnr.h +++ b/ABACUS.develop/source/src_lcao/LCAO_nnr.h @@ -1,11 +1,12 @@ -#ifndef LCAO_NNR -#define LCAO_NNR +#ifndef LCAO_NNR_H +#define LCAO_NNR_H #include "grid_technique.h" class LCAO_nnr { public: + LCAO_nnr(); ~LCAO_nnr(); diff --git a/ABACUS.develop/source/src_lcao/dftu.cpp b/ABACUS.develop/source/src_lcao/dftu.cpp index f94349db69..a8686afbdd 100644 --- a/ABACUS.develop/source/src_lcao/dftu.cpp +++ b/ABACUS.develop/source/src_lcao/dftu.cpp @@ -21,7 +21,7 @@ #include "../src_global/lapack_connector.h" #include "../src_pw/inverse_matrix.h" #include "local_orbital_ions.h" -#include "lcao_matrix.h" +#include "LCAO_matrix.h" #include "../src_pw/magnetism.h" #include "ORB_gen_tables.h" #include "../src_pw/charge.h" diff --git a/ABACUS.develop/source/src_lcao/dftu_relax.cpp b/ABACUS.develop/source/src_lcao/dftu_relax.cpp index 790a2a4575..7f6bc27303 100644 --- a/ABACUS.develop/source/src_lcao/dftu_relax.cpp +++ b/ABACUS.develop/source/src_lcao/dftu_relax.cpp @@ -20,7 +20,7 @@ #include "../src_global/lapack_connector.h" #include "../src_pw/inverse_matrix.h" #include "local_orbital_ions.h" -#include "lcao_matrix.h" +#include "LCAO_matrix.h" #include "../src_pw/magnetism.h" #include "ORB_gen_tables.h" #include "../src_pw/charge.h" diff --git a/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp b/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp index 8b9adf5f99..9338c9061b 100644 --- a/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp +++ b/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp @@ -18,7 +18,7 @@ #include "global_fp.h" #include "../src_global/global_function.h" #include "local_orbital_ions.h" -#include "lcao_matrix.h" +#include "LCAO_matrix.h" extern "C" diff --git a/ABACUS.develop/source/src_lcao/force_lcao_gamma.h b/ABACUS.develop/source/src_lcao/force_lcao_gamma.h index 8eb5531975..db2c260c81 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao_gamma.h +++ b/ABACUS.develop/source/src_lcao/force_lcao_gamma.h @@ -2,7 +2,7 @@ #define FORCE_LCAO_GAMMA_H #include "../src_pw/tools.h" -#include "lcao_matrix.h" +#include "LCAO_matrix.h" class Force_LCAO_gamma { diff --git a/ABACUS.develop/source/src_lcao/force_lcao_k.cpp b/ABACUS.develop/source/src_lcao/force_lcao_k.cpp index 439d6e3aa4..a69afcdea5 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao_k.cpp +++ b/ABACUS.develop/source/src_lcao/force_lcao_k.cpp @@ -10,7 +10,7 @@ Force_LCAO_k::~Force_LCAO_k () { } -#include "lcao_nnr.h" +#include "LCAO_nnr.h" // be called in Force_LCAO::start_force_calculation void Force_LCAO_k::ftable_k (void) { @@ -190,7 +190,7 @@ void Force_LCAO_k::finish_k(void) } #include "record_adj.h" -#include "lcao_nnr.h" +#include "LCAO_nnr.h" void Force_LCAO_k::set_EDM_k(double** dm2d, const bool with_energy) { TITLE("Force_LCAO_k","set_EDM_k"); diff --git a/ABACUS.develop/source/src_lcao/force_lcao_k.h b/ABACUS.develop/source/src_lcao/force_lcao_k.h index c18f6f644d..f59ac892bb 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao_k.h +++ b/ABACUS.develop/source/src_lcao/force_lcao_k.h @@ -2,7 +2,7 @@ #define FORCE_LCAO_K_H #include "../src_pw/tools.h" -#include "lcao_matrix.h" +#include "LCAO_matrix.h" #include "force_lcao_gamma.h" class Force_LCAO_k : public Force_LCAO_gamma diff --git a/ABACUS.develop/source/src_lcao/gint_gamma.h b/ABACUS.develop/source/src_lcao/gint_gamma.h index b824e88c96..e9633b9971 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma.h +++ b/ABACUS.develop/source/src_lcao/gint_gamma.h @@ -8,7 +8,7 @@ #include "../src_pw/tools.h" #include "grid_base_beta.h" #include "grid_technique.h" -#include "lcao_matrix.h" +#include "LCAO_matrix.h" #include //========================================================= diff --git a/ABACUS.develop/source/src_lcao/gint_k.cpp b/ABACUS.develop/source/src_lcao/gint_k.cpp index 72a8af14f6..f5ede0f3a8 100644 --- a/ABACUS.develop/source/src_lcao/gint_k.cpp +++ b/ABACUS.develop/source/src_lcao/gint_k.cpp @@ -1,6 +1,6 @@ #include "../src_pw/tools.h" #include "gint_k.h" -#include "lcao_nnr.h" +#include "LCAO_nnr.h" #include "ORB_read.h" #include "grid_technique.h" #include "ylm.h" diff --git a/ABACUS.develop/source/src_lcao/gint_k.h b/ABACUS.develop/source/src_lcao/gint_k.h index efeda3bf1a..a8d1c22906 100644 --- a/ABACUS.develop/source/src_lcao/gint_k.h +++ b/ABACUS.develop/source/src_lcao/gint_k.h @@ -4,7 +4,7 @@ #include "gint_k_init.h" #include "ORB_atomic_lm.h" #include "grid_technique.h" -//#include "lcao_matrix.h" +//#include "LCAO_matrix.h" class Gint_k : public Gint_k_init { diff --git a/ABACUS.develop/source/src_lcao/gint_k_fvl.cpp b/ABACUS.develop/source/src_lcao/gint_k_fvl.cpp index 1eec6b2155..23a314cb64 100644 --- a/ABACUS.develop/source/src_lcao/gint_k_fvl.cpp +++ b/ABACUS.develop/source/src_lcao/gint_k_fvl.cpp @@ -1,6 +1,6 @@ #include "gint_k.h" #include "../src_pw/global.h" -#include "lcao_nnr.h" +#include "LCAO_nnr.h" #include "global_fp.h" // mohan add 2021-01-30 diff --git a/ABACUS.develop/source/src_lcao/gint_k_rho.cpp b/ABACUS.develop/source/src_lcao/gint_k_rho.cpp index 57ae39db5f..634e0271f3 100644 --- a/ABACUS.develop/source/src_lcao/gint_k_rho.cpp +++ b/ABACUS.develop/source/src_lcao/gint_k_rho.cpp @@ -1,6 +1,6 @@ #include "../src_pw/tools.h" #include "gint_k.h" -#include "lcao_nnr.h" +#include "LCAO_nnr.h" #include "ORB_read.h" #include "grid_technique.h" #include "ylm.h" diff --git a/ABACUS.develop/source/src_lcao/gint_k_vl.cpp b/ABACUS.develop/source/src_lcao/gint_k_vl.cpp index a994e5e66c..0969dfe3cf 100644 --- a/ABACUS.develop/source/src_lcao/gint_k_vl.cpp +++ b/ABACUS.develop/source/src_lcao/gint_k_vl.cpp @@ -1,6 +1,6 @@ #include "../src_pw/tools.h" #include "gint_k.h" -#include "lcao_nnr.h" +#include "LCAO_nnr.h" #include "ORB_read.h" #include "grid_technique.h" #include "ylm.h" diff --git a/ABACUS.develop/source/src_lcao/global_fp.h b/ABACUS.develop/source/src_lcao/global_fp.h index 81b873df59..fd12dc1c1a 100644 --- a/ABACUS.develop/source/src_lcao/global_fp.h +++ b/ABACUS.develop/source/src_lcao/global_fp.h @@ -7,9 +7,9 @@ #include "src_parallel/parallel_orbitals.h" #include "src_lcao/local_orbital_wfc.h" #include "src_lcao/local_orbital_charge.h" -#include "src_lcao/lcao_matrix.h" -#include "src_lcao/use_overlap_matrix.h" -#include "src_lcao/use_hamilt_matrix.h" +#include "src_lcao/LCAO_matrix.h" +#include "src_lcao/LCAO_gen_fixedH.h" +#include "src_lcao/LCAO_hamilt.h" #include "src_lcao/ORB_read.h" #include "src_lcao/ORB_gen_tables.h" #include "src_parallel/subgrid_oper.h" diff --git a/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp b/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp index 05c343cef0..becd4c9360 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp @@ -108,7 +108,7 @@ void Local_Orbital_Charge::allocate_dm_wfc(const Grid_Technique >) } -#include "lcao_nnr.h" +#include "LCAO_nnr.h" void Local_Orbital_Charge::allocate_DM_k(void) { TITLE("Local_Orbital_Charge","allocate_k"); diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp index 693ef8425e..d471076fed 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp @@ -1,14 +1,14 @@ #include "local_orbital_elec.h" -#include "diago_lcao_matrix.h" +#include "LCAO_diago.h" #include "src_pw/global.h" #include "src_pw/symmetry_rho.h" #include "input_update.h" #include "src_pw/chi0_hilbert.h" -#include "evolve_lcao_matrix.h" +#include "LCAO_evolve.h" #include "dftu.h" // #include "../src_global/sltk_atom_arrange.h" -#include "src_lcao/lcao_nnr.h" +#include "src_lcao/LCAO_nnr.h" #include "../src_io/istate_charge.h" #include "../src_io/istate_envelope.h" #include "ELEC_scf.h" diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index e8a8764055..35c9acc4d9 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -2,7 +2,7 @@ #include "src_pw/global.h" #include "src_parallel/parallel_orbitals.h" #include "src_external/src_pdiag/pdiag_double.h" -#include "lcao_nnr.h" +#include "LCAO_nnr.h" #include "force_lcao.h" #include "stress_lcao.h" #include "src_global/global_function.h" diff --git a/ABACUS.develop/source/src_lcao/mulliken_charge.cpp b/ABACUS.develop/source/src_lcao/mulliken_charge.cpp index 895d370727..d93365f3ad 100644 --- a/ABACUS.develop/source/src_lcao/mulliken_charge.cpp +++ b/ABACUS.develop/source/src_lcao/mulliken_charge.cpp @@ -9,18 +9,13 @@ ***********************************************************************/ -//#include "../src_pw/global.h" #include "mulliken_charge.h" #include "../src_lcao/local_orbital_charge.h" -//#include "../src_lcao/sltk_grid_driver.h" -#include "use_overlap_matrix.h" +#include "LCAO_gen_fixedH.h" #include "../src_pw/global.h" #include "../src_pw/wavefunc.h" -#include "../src_lcao/lcao_matrix.h" #include "global_fp.h" -//#include "../src_develop/src_wannier/manipulation.h" -//#include "lcao_nnr.h" -#include "lcao_matrix.h" +#include "LCAO_matrix.h" #include "../src_lcao/global_fp.h" #include "../src_lcao/wfc_dm_2d.h" #include "../src_global/lapack_connector.h" @@ -30,7 +25,7 @@ #include #include #include "../src_global/sltk_atom_arrange.h" -#include "../src_lcao/lcao_nnr.h" +#include "../src_lcao/LCAO_nnr.h" diff --git a/ABACUS.develop/source/src_lcao/mulliken_charge.h b/ABACUS.develop/source/src_lcao/mulliken_charge.h index e2fc20f5f5..4050745a22 100644 --- a/ABACUS.develop/source/src_lcao/mulliken_charge.h +++ b/ABACUS.develop/source/src_lcao/mulliken_charge.h @@ -5,8 +5,8 @@ #include "../src_pw/tools.h" #include "ORB_gen_tables.h" #include "../src_global/sltk_grid_driver.h" -#include "lcao_matrix.h" -#include "lcao_matrix.h" +#include "LCAO_matrix.h" +#include "LCAO_matrix.h" #include "../src_lcao/global_fp.h" #include "../src_lcao/wfc_dm_2d.h" #include "../src_global/lapack_connector.h" diff --git a/ABACUS.develop/source/src_lcao/record_adj.cpp b/ABACUS.develop/source/src_lcao/record_adj.cpp index a7219241fe..4dbb2f3661 100644 --- a/ABACUS.develop/source/src_lcao/record_adj.cpp +++ b/ABACUS.develop/source/src_lcao/record_adj.cpp @@ -26,7 +26,7 @@ void Record_adj::delete_grid(void) // This will record the orbitals according to // HPSEPS's 2D block division. //-------------------------------------------- -#include "lcao_nnr.h" +#include "LCAO_nnr.h" void Record_adj::for_2d(void) { TITLE("Record_adj","for_2d"); diff --git a/ABACUS.develop/source/src_lcao/unk_overlap_lcao.cpp b/ABACUS.develop/source/src_lcao/unk_overlap_lcao.cpp index c345a02c41..82e6c6b57e 100644 --- a/ABACUS.develop/source/src_lcao/unk_overlap_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/unk_overlap_lcao.cpp @@ -1,5 +1,5 @@ #include "unk_overlap_lcao.h" -#include "../src_lcao/lcao_nnr.h" +#include "../src_lcao/LCAO_nnr.h" #include "ctime" #include "src_global/scalapack_connector.h" diff --git a/ABACUS.develop/source/src_pw/energy.cpp b/ABACUS.develop/source/src_pw/energy.cpp index c7de5ecd43..61e0c9f280 100644 --- a/ABACUS.develop/source/src_pw/energy.cpp +++ b/ABACUS.develop/source/src_pw/energy.cpp @@ -9,16 +9,14 @@ #include "algorithms.h" #include "mymath.h" #include "../src_lcao/mulliken_charge.h" -#include "../src_lcao/lcao_nnr.h" -#include "../src_lcao/use_overlap_matrix.h" +#include "../src_lcao/LCAO_nnr.h" +#include "../src_lcao/LCAO_gen_fixedH.h" #include "../src_global/sltk_atom_arrange.h"//qifeng-2019-01-21 #include "../src_lcao/local_orbital_charge.h" - #include "../src_pw/global.h" #include "../src_pw/wavefunc.h" -#include "../src_lcao/lcao_matrix.h" +#include "../src_lcao/LCAO_matrix.h" #include "../src_lcao/dftu.h" //Quxin adds for DFT+U on 20201029 - #include "../src_lcao/global_fp.h" #include "../src_lcao/wfc_dm_2d.h" #include "../src_global/lapack_connector.h" diff --git a/ABACUS.develop/source/src_ri/exx_lcao.cpp b/ABACUS.develop/source/src_ri/exx_lcao.cpp index 407861122a..b8c5252c3b 100644 --- a/ABACUS.develop/source/src_ri/exx_lcao.cpp +++ b/ABACUS.develop/source/src_ri/exx_lcao.cpp @@ -33,7 +33,7 @@ #include "src_external/src_test/src_global/sph_bessel-unittest.h" #include "src_external/src_test/src_ri/exx_lcao-test.h" #include "src_external/src_test/src_ri/abfs-test.h" -#include "src_lcao/lcao_nnr.h" +#include "src_lcao/LCAO_nnr.h" /* // m_new( i2*n1+i1, i3 ) = m( i1*n2+i2, i3 ) From d8fc9444e3d2404f6a5740ffc609be6bc198195e Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 10 Feb 2021 22:12:01 +0800 Subject: [PATCH 106/233] move some output files to src_io --- ABACUS.develop/source/Makefile.Objects | 20 +++---------------- ABACUS.develop/source/driver.cpp | 2 +- .../source/{src_pw => src_io}/eximport.cpp | 2 +- .../source/{src_pw => src_io}/eximport.h | 0 .../source/{src_pw => src_io}/output.cpp | 0 .../source/{src_pw => src_io}/output.h | 0 .../{src_global => src_io}/print_info.cpp | 5 +---- .../{src_global => src_io}/print_info.h | 0 .../source/{src_pw => src_io}/wf_io.cpp | 0 .../source/{src_pw => src_io}/wf_io.h | 0 ABACUS.develop/source/src_lcao/ELEC_nscf.cpp | 2 +- ABACUS.develop/source/src_pw/electrons.cpp | 4 ++-- ABACUS.develop/source/src_pw/global.h | 5 ++--- ABACUS.develop/source/src_pw/pseudo_us.cpp | 4 +--- .../source/src_pw/pseudopot_cell_us.cpp | 2 -- .../source/src_pw/pseudopot_upf.cpp | 3 +-- ABACUS.develop/source/src_pw/sto_elec.cpp | 2 +- .../{toWannier90.cpp => to_wannier90.cpp} | 2 +- .../src_pw/{toWannier90.h => to_wannier90.h} | 0 ...d2-parameters.cpp => vdwd2_parameters.cpp} | 0 ...d3-parameters.cpp => vdwd3_parameters.cpp} | 0 21 files changed, 15 insertions(+), 38 deletions(-) rename ABACUS.develop/source/{src_pw => src_io}/eximport.cpp (99%) rename ABACUS.develop/source/{src_pw => src_io}/eximport.h (100%) rename ABACUS.develop/source/{src_pw => src_io}/output.cpp (100%) rename ABACUS.develop/source/{src_pw => src_io}/output.h (100%) rename ABACUS.develop/source/{src_global => src_io}/print_info.cpp (98%) rename ABACUS.develop/source/{src_global => src_io}/print_info.h (100%) rename ABACUS.develop/source/{src_pw => src_io}/wf_io.cpp (100%) rename ABACUS.develop/source/{src_pw => src_io}/wf_io.h (100%) rename ABACUS.develop/source/src_pw/{toWannier90.cpp => to_wannier90.cpp} (99%) rename ABACUS.develop/source/src_pw/{toWannier90.h => to_wannier90.h} (100%) rename ABACUS.develop/source/src_pw/{vdwd2-parameters.cpp => vdwd2_parameters.cpp} (100%) rename ABACUS.develop/source/src_pw/{vdwd3-parameters.cpp => vdwd3_parameters.cpp} (100%) diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 2f4b4181bf..83e5aa587a 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -9,23 +9,9 @@ # machine specific and depend on the local installation. Hence the name. # -#xiaohui modify 2015-03-25 -#VERSION = MESIA-ALPHA VERSION = ABACUS HEADERS = *.h -#xiaohui modified 2013-03-23, adding "#" before OBJS_SELINV -#OBJS_SELINV=selinv.o\ -cal_reduce_rho.o\ -getpolef.o\ -siao_interf.o\ -trace_rho_hs.o\ -chem_pot.o\ - -#OBJS_CG=hpsi_ao.o\ -cg_lcao.o\ -cg_precon.o\ - OBJS_DC=driver.o\ input.o \ input_conv.o\ @@ -52,10 +38,10 @@ stress.o\ myfunc1.o\ myfunc2.o\ vdwd2.o\ -vdwd2-parameters.o\ +vdwd2_parameters.o\ dftd3_subroutine.o\ vdwd3.o\ -vdwd3-parameters.o\ +vdwd3_parameters.o\ chi0_hilbert.o\ chi0_standard.o\ epsilon0_pwscf.o\ @@ -65,7 +51,7 @@ mdNVE.o\ mdNVT.o\ exx_lip.o\ soc.o\ -toWannier90.o \ +to_wannier90.o \ unk_overlap_pw.o \ berryphase.o \ sto_elec.o\ diff --git a/ABACUS.develop/source/driver.cpp b/ABACUS.develop/source/driver.cpp index 44b45d6ae1..a62c24b813 100644 --- a/ABACUS.develop/source/driver.cpp +++ b/ABACUS.develop/source/driver.cpp @@ -5,7 +5,7 @@ #include "input_conv.h" #include "src_lcao/global_fp.h" #include "src_pw/global.h" -#include "src_global/print_info.h" +#include "src_io/print_info.h" #include "src_pw/cal_test.h" #include "src_pw/cal_test0.h" #include "src_pw/winput.h" diff --git a/ABACUS.develop/source/src_pw/eximport.cpp b/ABACUS.develop/source/src_io/eximport.cpp similarity index 99% rename from ABACUS.develop/source/src_pw/eximport.cpp rename to ABACUS.develop/source/src_io/eximport.cpp index 94a68d4b62..da56746d5d 100644 --- a/ABACUS.develop/source/src_pw/eximport.cpp +++ b/ABACUS.develop/source/src_io/eximport.cpp @@ -2,7 +2,7 @@ // AUTHOR : mohan // DATE : 2008-11-5 //========================================================== -#include "wan_global.h" +#include "../src_pw/wan_global.h" #include "eximport.h" eximport::eximport() diff --git a/ABACUS.develop/source/src_pw/eximport.h b/ABACUS.develop/source/src_io/eximport.h similarity index 100% rename from ABACUS.develop/source/src_pw/eximport.h rename to ABACUS.develop/source/src_io/eximport.h diff --git a/ABACUS.develop/source/src_pw/output.cpp b/ABACUS.develop/source/src_io/output.cpp similarity index 100% rename from ABACUS.develop/source/src_pw/output.cpp rename to ABACUS.develop/source/src_io/output.cpp diff --git a/ABACUS.develop/source/src_pw/output.h b/ABACUS.develop/source/src_io/output.h similarity index 100% rename from ABACUS.develop/source/src_pw/output.h rename to ABACUS.develop/source/src_io/output.h diff --git a/ABACUS.develop/source/src_global/print_info.cpp b/ABACUS.develop/source/src_io/print_info.cpp similarity index 98% rename from ABACUS.develop/source/src_global/print_info.cpp rename to ABACUS.develop/source/src_io/print_info.cpp index 24bf3fb47f..86bbf57640 100644 --- a/ABACUS.develop/source/src_global/print_info.cpp +++ b/ABACUS.develop/source/src_io/print_info.cpp @@ -1,8 +1,5 @@ #include "print_info.h" -#include "global_variable.h" -//#include "../input.h" -//#include "../input_conv.h" -//#include "../src_lcao/global_fp.h" +#include "../src_global/global_variable.h" #include "../src_pw/global.h" Print_Info::Print_Info(){} diff --git a/ABACUS.develop/source/src_global/print_info.h b/ABACUS.develop/source/src_io/print_info.h similarity index 100% rename from ABACUS.develop/source/src_global/print_info.h rename to ABACUS.develop/source/src_io/print_info.h diff --git a/ABACUS.develop/source/src_pw/wf_io.cpp b/ABACUS.develop/source/src_io/wf_io.cpp similarity index 100% rename from ABACUS.develop/source/src_pw/wf_io.cpp rename to ABACUS.develop/source/src_io/wf_io.cpp diff --git a/ABACUS.develop/source/src_pw/wf_io.h b/ABACUS.develop/source/src_io/wf_io.h similarity index 100% rename from ABACUS.develop/source/src_pw/wf_io.h rename to ABACUS.develop/source/src_io/wf_io.h diff --git a/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp b/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp index adbedc8a3c..0c13cf820d 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp @@ -6,7 +6,7 @@ #include "ELEC_cbands_gamma.h" #include "ELEC_cbands_k.h" #include "../src_pw/berryphase.h" -#include "../src_pw/toWannier90.h" +#include "../src_pw/to_wannier90.h" ELEC_nscf::ELEC_nscf(){} ELEC_nscf::~ELEC_nscf(){} diff --git a/ABACUS.develop/source/src_pw/electrons.cpp b/ABACUS.develop/source/src_pw/electrons.cpp index 890aaf579f..9b758021de 100644 --- a/ABACUS.develop/source/src_pw/electrons.cpp +++ b/ABACUS.develop/source/src_pw/electrons.cpp @@ -3,12 +3,12 @@ #include "electrons.h" #include "algorithms.h" #include "symmetry_rho.h" -#include "../src_pw/wf_io.h" +#include "../src_io/wf_io.h" #include "chi0_hilbert.h" // pengfei 2016-11-23 #include "chi0_standard.h" #include "epsilon0_pwscf.h" #include "epsilon0_vasp.h" -#include "../src_pw/toWannier90.h" +#include "../src_pw/to_wannier90.h" #include "../src_pw/berryphase.h" double Electrons::avg_iter = 0; diff --git a/ABACUS.develop/source/src_pw/global.h b/ABACUS.develop/source/src_pw/global.h index 601bee7e62..2e2f0dd5a4 100644 --- a/ABACUS.develop/source/src_pw/global.h +++ b/ABACUS.develop/source/src_pw/global.h @@ -6,13 +6,13 @@ #ifndef GLOBAL_H #define GLOBAL_H +#include "../run_pw.h" #include "src_global/global_variable.h" #include "src_global/global_function.h" #include "pw_basis.h" #include "energy.h" #include "occupy.h" #include "pseudopot_cell_vnl.h" -#include "../run_pw.h" #include "charge_broyden.h" #include "potential.h" #include "functional.h" @@ -21,7 +21,7 @@ #include "wavefunc.h" #include "use_fft.h" #include "klist.h" -#include "../src_pw/output.h" +#include "../src_io/output.h" #include "magnetism.h" #include "vdwd2.h" #include "vdwd3.h" @@ -29,7 +29,6 @@ #include "exx_global.h" #include "exx_lip.h" #include "soc.h" - #include "../src_parallel/ft.h" //========================================================== diff --git a/ABACUS.develop/source/src_pw/pseudo_us.cpp b/ABACUS.develop/source/src_pw/pseudo_us.cpp index e819c0aa3c..2bdabf1615 100644 --- a/ABACUS.develop/source/src_pw/pseudo_us.cpp +++ b/ABACUS.develop/source/src_pw/pseudo_us.cpp @@ -1,6 +1,4 @@ -/* pseudo_us.cpp */ - -#include "../src_pw/output.h" +#include "../src_io/output.h" #include "pseudo_us.h" pseudo_us::pseudo_us() diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_us.cpp b/ABACUS.develop/source/src_pw/pseudopot_cell_us.cpp index d07a1d827c..61fb08a7c6 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_us.cpp +++ b/ABACUS.develop/source/src_pw/pseudopot_cell_us.cpp @@ -1,5 +1,3 @@ -//#include "../mymath.h" -//#include "../output.h" #include "global.h" #include "pseudopot_cell_us.h" #include "tools.h" diff --git a/ABACUS.develop/source/src_pw/pseudopot_upf.cpp b/ABACUS.develop/source/src_pw/pseudopot_upf.cpp index f7e78f31d1..2b6a76f8fa 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_upf.cpp +++ b/ABACUS.develop/source/src_pw/pseudopot_upf.cpp @@ -1,9 +1,8 @@ -/* pseudopot_upf.cpp */ //========================================================== // Author: Lixin He,mohan // DATE : 2009-02-26 //========================================================== -#include "../src_pw/output.h" +#include "../src_io/output.h" #include "pseudopot_upf.h" #include #include diff --git a/ABACUS.develop/source/src_pw/sto_elec.cpp b/ABACUS.develop/source/src_pw/sto_elec.cpp index a1b7a55f54..ed51595e4c 100644 --- a/ABACUS.develop/source/src_pw/sto_elec.cpp +++ b/ABACUS.develop/source/src_pw/sto_elec.cpp @@ -3,7 +3,7 @@ #include "sto_elec.h" #include "algorithms.h" #include "symmetry_rho.h" -#include "../src_pw/wf_io.h" +#include "../src_io/wf_io.h" double Stochastic_Elec::avg_iter = 0; diff --git a/ABACUS.develop/source/src_pw/toWannier90.cpp b/ABACUS.develop/source/src_pw/to_wannier90.cpp similarity index 99% rename from ABACUS.develop/source/src_pw/toWannier90.cpp rename to ABACUS.develop/source/src_pw/to_wannier90.cpp index 19e918a454..14759a31a6 100644 --- a/ABACUS.develop/source/src_pw/toWannier90.cpp +++ b/ABACUS.develop/source/src_pw/to_wannier90.cpp @@ -1,4 +1,4 @@ -#include "toWannier90.h" +#include "to_wannier90.h" #include "../src_lcao/global_fp.h" // mohan add 2021-01-30, this module should be modified diff --git a/ABACUS.develop/source/src_pw/toWannier90.h b/ABACUS.develop/source/src_pw/to_wannier90.h similarity index 100% rename from ABACUS.develop/source/src_pw/toWannier90.h rename to ABACUS.develop/source/src_pw/to_wannier90.h diff --git a/ABACUS.develop/source/src_pw/vdwd2-parameters.cpp b/ABACUS.develop/source/src_pw/vdwd2_parameters.cpp similarity index 100% rename from ABACUS.develop/source/src_pw/vdwd2-parameters.cpp rename to ABACUS.develop/source/src_pw/vdwd2_parameters.cpp diff --git a/ABACUS.develop/source/src_pw/vdwd3-parameters.cpp b/ABACUS.develop/source/src_pw/vdwd3_parameters.cpp similarity index 100% rename from ABACUS.develop/source/src_pw/vdwd3-parameters.cpp rename to ABACUS.develop/source/src_pw/vdwd3_parameters.cpp From a2443f6dbe47daaad41dee2d380d985b393224f3 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 10 Feb 2021 22:30:03 +0800 Subject: [PATCH 107/233] update src_pw directory by moving some files to src_io, delete useless wan_global.h and .cpp --- ABACUS.develop/source/Makefile.Objects | 3 +- ABACUS.develop/source/input_conv.cpp | 2 +- ABACUS.develop/source/input_update.cpp | 2 +- ABACUS.develop/source/run_lcao.cpp | 2 +- ABACUS.develop/source/run_pw.cpp | 2 +- .../source/{src_pw => src_io}/berryphase.cpp | 0 .../source/{src_pw => src_io}/berryphase.h | 11 ++---- ABACUS.develop/source/src_io/eximport.cpp | 2 +- .../source/{src_pw => src_io}/optical.cpp | 4 +- .../source/{src_pw => src_io}/optical.h | 0 .../{src_pw => src_io}/to_wannier90.cpp | 0 .../source/{src_pw => src_io}/to_wannier90.h | 0 .../{src_lcao => src_io}/unk_overlap_lcao.cpp | 0 .../{src_lcao => src_io}/unk_overlap_lcao.h | 0 .../{src_pw => src_io}/unk_overlap_pw.cpp | 0 .../{src_pw => src_io}/unk_overlap_pw.h | 0 ABACUS.develop/source/src_lcao/ELEC_nscf.cpp | 4 +- ABACUS.develop/source/src_pw/chi0_hilbert.cpp | 3 +- .../source/src_pw/chi0_standard.cpp | 2 +- ABACUS.develop/source/src_pw/electrons.cpp | 4 +- .../source/src_pw/epsilon0_pwscf.cpp | 2 +- .../source/src_pw/epsilon0_vasp.cpp | 2 +- ABACUS.develop/source/src_pw/hamilt_pw.cpp | 2 +- ABACUS.develop/source/src_pw/wan_global.cpp | 20 ---------- ABACUS.develop/source/src_pw/wan_global.h | 38 ------------------- ABACUS.develop/source/src_pw/winput.cpp | 3 +- 26 files changed, 24 insertions(+), 84 deletions(-) rename ABACUS.develop/source/{src_pw => src_io}/berryphase.cpp (100%) rename ABACUS.develop/source/{src_pw => src_io}/berryphase.h (82%) rename ABACUS.develop/source/{src_pw => src_io}/optical.cpp (98%) rename ABACUS.develop/source/{src_pw => src_io}/optical.h (100%) rename ABACUS.develop/source/{src_pw => src_io}/to_wannier90.cpp (100%) rename ABACUS.develop/source/{src_pw => src_io}/to_wannier90.h (100%) rename ABACUS.develop/source/{src_lcao => src_io}/unk_overlap_lcao.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_io}/unk_overlap_lcao.h (100%) rename ABACUS.develop/source/{src_pw => src_io}/unk_overlap_pw.cpp (100%) rename ABACUS.develop/source/{src_pw => src_io}/unk_overlap_pw.h (100%) delete mode 100644 ABACUS.develop/source/src_pw/wan_global.cpp delete mode 100644 ABACUS.develop/source/src_pw/wan_global.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 83e5aa587a..f84b14db27 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -189,8 +189,7 @@ wfc_dm_2d.o \ unk_overlap_lcao.o \ cal_r_overlap_R.o \ -OBJS_WANNIER=wan_global.o\ -bessel_basis.o\ +OBJS_WANNIER=bessel_basis.o\ numerical_basis.o\ numerical_descriptor.o\ wavefunc_in_pw.o\ diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index 3c30749480..d391646512 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -3,7 +3,7 @@ #include "input.h" #include "input_conv.h" #include "src_ions/ions_move_basic.h" -#include "src_pw/optical.h" +#include "src_io/optical.h" #include "src_lcao/force_lcao.h" #include "src_lcao/local_orbital_charge.h" #include "src_lcao/ORB_read.h" diff --git a/ABACUS.develop/source/input_update.cpp b/ABACUS.develop/source/input_update.cpp index 359c1cf730..d4ae855df5 100644 --- a/ABACUS.develop/source/input_update.cpp +++ b/ABACUS.develop/source/input_update.cpp @@ -7,7 +7,7 @@ #include "src_pw/tools.h" #include "input.h" #include "src_ions/ions_move_basic.h" -#include "src_pw/optical.h" +#include "src_io/optical.h" #include "src_lcao/force_lcao.h" #include "src_lcao/local_orbital_charge.h" #include "src_lcao/global_fp.h" // mohan update 2021-01-30 diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index 890c584871..5f168e4682 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -7,7 +7,7 @@ #include "input.h" #include "src_pw/algorithms.h" #include "src_pw/pseudopot_cell_us.h" -#include "src_pw/optical.h" +#include "src_io/optical.h" #include "src_pw/cal_test.h" #include "src_lcao/dftu.h" //Quxin add for DFT+U on 20201029 #include "src_pw/winput.h" diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp index 0d120fbac9..5aafb1548f 100644 --- a/ABACUS.develop/source/run_pw.cpp +++ b/ABACUS.develop/source/run_pw.cpp @@ -3,7 +3,7 @@ #include "input.h" #include "src_pw/algorithms.h" #include "src_pw/pseudopot_cell_us.h" -#include "src_pw/optical.h" +#include "src_io/optical.h" #include "src_pw/cal_test.h" #include "src_pw/winput.h" diff --git a/ABACUS.develop/source/src_pw/berryphase.cpp b/ABACUS.develop/source/src_io/berryphase.cpp similarity index 100% rename from ABACUS.develop/source/src_pw/berryphase.cpp rename to ABACUS.develop/source/src_io/berryphase.cpp diff --git a/ABACUS.develop/source/src_pw/berryphase.h b/ABACUS.develop/source/src_io/berryphase.h similarity index 82% rename from ABACUS.develop/source/src_pw/berryphase.h rename to ABACUS.develop/source/src_io/berryphase.h index e88210dfb4..b2e54b79c6 100644 --- a/ABACUS.develop/source/src_pw/berryphase.h +++ b/ABACUS.develop/source/src_io/berryphase.h @@ -1,11 +1,8 @@ -#ifndef BERRYPHASE -#define BERRYPHASE - - -#include "../src_pw/unk_overlap_pw.h" -#include "../src_lcao/unk_overlap_lcao.h" - +#ifndef BERRYPHASE_H +#define BERRYPHASE_H +#include "../src_io/unk_overlap_pw.h" +#include "../src_io/unk_overlap_lcao.h" class berryphase { diff --git a/ABACUS.develop/source/src_io/eximport.cpp b/ABACUS.develop/source/src_io/eximport.cpp index da56746d5d..47ba886eb2 100644 --- a/ABACUS.develop/source/src_io/eximport.cpp +++ b/ABACUS.develop/source/src_io/eximport.cpp @@ -2,7 +2,7 @@ // AUTHOR : mohan // DATE : 2008-11-5 //========================================================== -#include "../src_pw/wan_global.h" +#include "../src_pw/global.h" #include "eximport.h" eximport::eximport() diff --git a/ABACUS.develop/source/src_pw/optical.cpp b/ABACUS.develop/source/src_io/optical.cpp similarity index 98% rename from ABACUS.develop/source/src_pw/optical.cpp rename to ABACUS.develop/source/src_io/optical.cpp index 7e5646bd53..ce7eba161a 100644 --- a/ABACUS.develop/source/src_pw/optical.cpp +++ b/ABACUS.develop/source/src_io/optical.cpp @@ -1,6 +1,6 @@ #include "optical.h" -#include "tools.h" -#include "global.h" +#include "../src_pw/tools.h" +#include "../src_pw/global.h" bool Optical::opt_epsilon2 = false; int Optical::opt_nbands = 0; diff --git a/ABACUS.develop/source/src_pw/optical.h b/ABACUS.develop/source/src_io/optical.h similarity index 100% rename from ABACUS.develop/source/src_pw/optical.h rename to ABACUS.develop/source/src_io/optical.h diff --git a/ABACUS.develop/source/src_pw/to_wannier90.cpp b/ABACUS.develop/source/src_io/to_wannier90.cpp similarity index 100% rename from ABACUS.develop/source/src_pw/to_wannier90.cpp rename to ABACUS.develop/source/src_io/to_wannier90.cpp diff --git a/ABACUS.develop/source/src_pw/to_wannier90.h b/ABACUS.develop/source/src_io/to_wannier90.h similarity index 100% rename from ABACUS.develop/source/src_pw/to_wannier90.h rename to ABACUS.develop/source/src_io/to_wannier90.h diff --git a/ABACUS.develop/source/src_lcao/unk_overlap_lcao.cpp b/ABACUS.develop/source/src_io/unk_overlap_lcao.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/unk_overlap_lcao.cpp rename to ABACUS.develop/source/src_io/unk_overlap_lcao.cpp diff --git a/ABACUS.develop/source/src_lcao/unk_overlap_lcao.h b/ABACUS.develop/source/src_io/unk_overlap_lcao.h similarity index 100% rename from ABACUS.develop/source/src_lcao/unk_overlap_lcao.h rename to ABACUS.develop/source/src_io/unk_overlap_lcao.h diff --git a/ABACUS.develop/source/src_pw/unk_overlap_pw.cpp b/ABACUS.develop/source/src_io/unk_overlap_pw.cpp similarity index 100% rename from ABACUS.develop/source/src_pw/unk_overlap_pw.cpp rename to ABACUS.develop/source/src_io/unk_overlap_pw.cpp diff --git a/ABACUS.develop/source/src_pw/unk_overlap_pw.h b/ABACUS.develop/source/src_io/unk_overlap_pw.h similarity index 100% rename from ABACUS.develop/source/src_pw/unk_overlap_pw.h rename to ABACUS.develop/source/src_io/unk_overlap_pw.h diff --git a/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp b/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp index 0c13cf820d..983a8b34e1 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp @@ -5,8 +5,8 @@ #include "global_fp.h" #include "ELEC_cbands_gamma.h" #include "ELEC_cbands_k.h" -#include "../src_pw/berryphase.h" -#include "../src_pw/to_wannier90.h" +#include "../src_io/berryphase.h" +#include "../src_io/to_wannier90.h" ELEC_nscf::ELEC_nscf(){} ELEC_nscf::~ELEC_nscf(){} diff --git a/ABACUS.develop/source/src_pw/chi0_hilbert.cpp b/ABACUS.develop/source/src_pw/chi0_hilbert.cpp index 019778c5cc..351cb095af 100644 --- a/ABACUS.develop/source/src_pw/chi0_hilbert.cpp +++ b/ABACUS.develop/source/src_pw/chi0_hilbert.cpp @@ -12,10 +12,11 @@ #include "algorithms.h" #include "hamilt_pw.h" #include "wavefunc_in_pw.h" -#include "optical.h" +#include "../src_io/optical.h" #include "klist.h" #include #include "../src_lcao/global_fp.h" + using namespace std; Chi0_hilbert chi0_hilbert; diff --git a/ABACUS.develop/source/src_pw/chi0_standard.cpp b/ABACUS.develop/source/src_pw/chi0_standard.cpp index d27b6a79c5..409fac850b 100644 --- a/ABACUS.develop/source/src_pw/chi0_standard.cpp +++ b/ABACUS.develop/source/src_pw/chi0_standard.cpp @@ -11,7 +11,7 @@ #include "algorithms.h" #include "hamilt_pw.h" #include "wavefunc_in_pw.h" -#include "optical.h" +#include "src_io/optical.h" #include "klist.h" #include #include diff --git a/ABACUS.develop/source/src_pw/electrons.cpp b/ABACUS.develop/source/src_pw/electrons.cpp index 9b758021de..332aac1261 100644 --- a/ABACUS.develop/source/src_pw/electrons.cpp +++ b/ABACUS.develop/source/src_pw/electrons.cpp @@ -8,8 +8,8 @@ #include "chi0_standard.h" #include "epsilon0_pwscf.h" #include "epsilon0_vasp.h" -#include "../src_pw/to_wannier90.h" -#include "../src_pw/berryphase.h" +#include "../src_io/to_wannier90.h" +#include "../src_io/berryphase.h" double Electrons::avg_iter = 0; diff --git a/ABACUS.develop/source/src_pw/epsilon0_pwscf.cpp b/ABACUS.develop/source/src_pw/epsilon0_pwscf.cpp index bedf1c0519..c297a0fca5 100644 --- a/ABACUS.develop/source/src_pw/epsilon0_pwscf.cpp +++ b/ABACUS.develop/source/src_pw/epsilon0_pwscf.cpp @@ -10,7 +10,7 @@ #include "algorithms.h" #include "hamilt_pw.h" #include "../src_pw/wavefunc_in_pw.h" -#include "optical.h" +#include "src_io/optical.h" #include "epsilon0_pwscf.h" #include #include diff --git a/ABACUS.develop/source/src_pw/epsilon0_vasp.cpp b/ABACUS.develop/source/src_pw/epsilon0_vasp.cpp index 7eaa2feebe..e506faca9b 100644 --- a/ABACUS.develop/source/src_pw/epsilon0_vasp.cpp +++ b/ABACUS.develop/source/src_pw/epsilon0_vasp.cpp @@ -10,7 +10,7 @@ #include "algorithms.h" #include "hamilt_pw.h" #include "../src_pw/wavefunc_in_pw.h" -#include "optical.h" +#include "./src_io/optical.h" #include "epsilon0_vasp.h" #include #include diff --git a/ABACUS.develop/source/src_pw/hamilt_pw.cpp b/ABACUS.develop/source/src_pw/hamilt_pw.cpp index 7516dcc943..46fa936958 100644 --- a/ABACUS.develop/source/src_pw/hamilt_pw.cpp +++ b/ABACUS.develop/source/src_pw/hamilt_pw.cpp @@ -4,7 +4,7 @@ #include "algorithms.h" #include "hamilt_pw.h" #include "src_global/blas_connector.h" -#include "optical.h" // only get judgement to calculate optical matrix or not. +#include "../src_io/optical.h" // only get judgement to calculate optical matrix or not. int Hamilt_PW::moved = 0; diff --git a/ABACUS.develop/source/src_pw/wan_global.cpp b/ABACUS.develop/source/src_pw/wan_global.cpp deleted file mode 100644 index c03692f41b..0000000000 --- a/ABACUS.develop/source/src_pw/wan_global.cpp +++ /dev/null @@ -1,20 +0,0 @@ -//#include "wannier.h" -#include "winput.h" -//#include "operation.h" -//#include "setout.h" -//#include "efficient.h" -//#include "build.h" -//#include "spheri.h" -//#include "recons.h" -//#include "improve_pao.h" - -//#include "quality.h" -//#include "eximport.h" -//#include "compare.h" - -//operation op; -//setout st; - -//quality ql; -//eximport ei; -//efficient eff; diff --git a/ABACUS.develop/source/src_pw/wan_global.h b/ABACUS.develop/source/src_pw/wan_global.h deleted file mode 100644 index fb475aec9f..0000000000 --- a/ABACUS.develop/source/src_pw/wan_global.h +++ /dev/null @@ -1,38 +0,0 @@ -//========================================================== -#ifndef WAN_GLOBAL_H -#define WAN_GLOBAL_H -//part 1 -//#include "wannier.h" -#include "winput.h" -//#include "operation.h" -//#include "setout.h" -//#include "efficient.h" -//#include "build.h" -//#include "geometry.h" -//#include "spheri.h" -//#include "improve_pao.h" -//part 2 -//#include "quality.h" -//#include "eximport.h" -//#include "figure.h" -//#include "compare.h" - -//part5 -#include "global.h" -#include "../src_parallel/parallel_global.h" -//part 6 -#include "tools.h" -//part 7 -#include "../input.h" - -//#include "recons.h" -//#include "truncate.h" - -//extern operation op; -//extern setout st; - -//extern quality ql; -//extern eximport ei; -//extern efficient eff; - -#endif diff --git a/ABACUS.develop/source/src_pw/winput.cpp b/ABACUS.develop/source/src_pw/winput.cpp index 6fe482e86f..e2fc636b1b 100644 --- a/ABACUS.develop/source/src_pw/winput.cpp +++ b/ABACUS.develop/source/src_pw/winput.cpp @@ -3,7 +3,8 @@ #endif #include #include -#include "wan_global.h" +#include "winput.h" +#include "global.h" string winput::target;//add 2008-06-04 From b97987331ee6c93752e78844dae338ae4fceb426 Mon Sep 17 00:00:00 2001 From: mohan Date: Thu, 11 Feb 2021 15:28:59 +0800 Subject: [PATCH 108/233] move dos to src_io, delete useless field_electric --- .../source/{src_pw => src_io}/dos.cpp | 0 .../source/{src_pw => src_io}/dos.h | 0 ABACUS.develop/source/src_pw/cal_test0.cpp | 51 ----------------- ABACUS.develop/source/src_pw/cal_test0.h | 10 ---- ABACUS.develop/source/src_pw/efield.h | 2 + .../source/src_pw/field_electric.cpp | 3 - ABACUS.develop/source/src_pw/field_electric.h | 19 ------- .../source/src_pw/potential_libxc.h | 2 + ABACUS.develop/source/src_pw/soc.h | 57 +++++++++++++------ 9 files changed, 43 insertions(+), 101 deletions(-) rename ABACUS.develop/source/{src_pw => src_io}/dos.cpp (100%) rename ABACUS.develop/source/{src_pw => src_io}/dos.h (100%) delete mode 100644 ABACUS.develop/source/src_pw/cal_test0.cpp delete mode 100644 ABACUS.develop/source/src_pw/cal_test0.h delete mode 100644 ABACUS.develop/source/src_pw/field_electric.cpp delete mode 100644 ABACUS.develop/source/src_pw/field_electric.h diff --git a/ABACUS.develop/source/src_pw/dos.cpp b/ABACUS.develop/source/src_io/dos.cpp similarity index 100% rename from ABACUS.develop/source/src_pw/dos.cpp rename to ABACUS.develop/source/src_io/dos.cpp diff --git a/ABACUS.develop/source/src_pw/dos.h b/ABACUS.develop/source/src_io/dos.h similarity index 100% rename from ABACUS.develop/source/src_pw/dos.h rename to ABACUS.develop/source/src_io/dos.h diff --git a/ABACUS.develop/source/src_pw/cal_test0.cpp b/ABACUS.develop/source/src_pw/cal_test0.cpp deleted file mode 100644 index 84d876760d..0000000000 --- a/ABACUS.develop/source/src_pw/cal_test0.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "global.h" -#include "tools.h" -#include "cal_test0.h" -#include "../src_global/sltk_atom_arrange.h" -//xiaohui modified 2013-03-23, adding "//" before #include... -//#include "../src_develop/src_siao/trace_rho_hs.h" - -int Cal_Test::Hnnz=0; - -void Cal_Test::adjacent_atoms(void) -{ - TITLE("Cal_Test","adjacent_atoms"); - - // (1) Find adjacent atoms for each atom. - atom_arrange::set_sr_NL(); - atom_arrange::search( SEARCH_RADIUS ); - - return; -} -// xiaohui modified 2013-03-23 -/* -void Cal_Test::sparsity(void) -{ - TITLE("Cal_Test","sparsity"); - - Trace_Rho_HS TRHS; - // nonzero need to be update later. - bool** nonzero = new bool*[NLOCAL]; - for(int col=0; col init_func(); // [ rho, sigma, gdr ] + static std::tuple< std::vector, std::vector, std::vector>> > cal_input( const std::vector &funcs, diff --git a/ABACUS.develop/source/src_pw/soc.h b/ABACUS.develop/source/src_pw/soc.h index 7871712055..9bae52bcc2 100644 --- a/ABACUS.develop/source/src_pw/soc.h +++ b/ABACUS.develop/source/src_pw/soc.h @@ -2,53 +2,74 @@ #define SOC_H #include "tools.h" + class Fcoef { + public: + Fcoef(); ~Fcoef(); + int ind1,ind4,ind5; + complex *p; + inline complex &operator()(const int &i1,const int &i2,const int &i3,const int &i4,const int &i5) { return p[ind2*ind3*ind4*ind5*i1 + ind3*ind4*ind5*i2 + ind4*ind5*i3 + ind5*i4 + i5]; } inline const complex &operator()(const int &i1,const int &i2,const int &i3,const int &i4,const int &i5)const { return p[ind2*ind3*ind4*ind5*i1 + ind3*ind4*ind5*i2 + ind4*ind5*i3 + ind5*i4 + i5]; } + void create(const int i1, const int i2, const int i3); + // void free(); + private: + int ind2,ind3; }; +//----------------------- +// spin-orbital coupling +//----------------------- class Soc { -public: + + public: + Soc(); ~Soc(); - void init(); - double spinor(const int l, const double j, const int m, const int spin); - int sph_ind(const int l, const double j, const int m, const int spin); - void rot_ylm(const int lmax); -// complex **rotylm; + void init(); + + double spinor(const int l, const double j, const int m, const int spin); + + int sph_ind(const int l, const double j, const int m, const int spin); + + void rot_ylm(const int lmax); + // complex **rotylm; + complex *p_rot; + complex & rotylm(const int &i1,const int &i2) { return p_rot[l_max*i1 + i2]; } - Fcoef fcoef; - + Fcoef fcoef; - Vector3 *m_loc; //magnetization for each atom axis - double *angle1; - double *angle2; + Vector3 *m_loc; //magnetization for each atom axis + double *angle1; + double *angle2; + + double ux[3]; + void cal_ux(const int ntype); + bool lsign ; + + //int npol; + private: + + bool judge_parallel(double a[3],Vector3 b); - double ux[3]; - void cal_ux(const int ntype); - bool lsign ; - - //int npol; -private: - bool judge_parallel(double a[3],Vector3 b); int l_max; }; #endif From 2b0f6e772091c38efee7b5b4486fe45cb4d4cd45 Mon Sep 17 00:00:00 2001 From: mohan Date: Thu, 11 Feb 2021 20:38:44 +0800 Subject: [PATCH 109/233] move some files in src_pw to src_io, including epsilon0, chi0, winput, numerical_basis, numerical_descriptor, etc. delete useless symm_book --- ABACUS.develop/source/Makefile.Objects | 2 - ABACUS.develop/source/driver.cpp | 8 +- ABACUS.develop/source/input_conv.cpp | 8 +- ABACUS.develop/source/run_lcao.cpp | 4 +- ABACUS.develop/source/run_pw.cpp | 4 +- .../{src_pw => src_global}/inverse_matrix.cpp | 0 .../{src_pw => src_global}/inverse_matrix.h | 0 .../{src_pw => src_io}/bessel_basis.cpp | 0 .../source/{src_pw => src_io}/bessel_basis.h | 0 .../source/{src_pw => src_io}/cal_test.cpp | 8 +- .../source/{src_pw => src_io}/cal_test.h | 0 .../{src_pw => src_io}/chi0_hilbert.cpp | 10 +- .../source/{src_pw => src_io}/chi0_hilbert.h | 17 ++- .../{src_pw => src_io}/chi0_standard.cpp | 12 +- .../source/{src_pw => src_io}/chi0_standard.h | 11 +- .../{src_pw => src_io}/epsilon0_pwscf.cpp | 7 +- .../{src_pw => src_io}/epsilon0_pwscf.h | 9 +- .../{src_pw => src_io}/epsilon0_vasp.cpp | 7 +- .../source/{src_pw => src_io}/epsilon0_vasp.h | 7 +- .../{src_pw => src_io}/numerical_basis.cpp | 0 .../{src_pw => src_io}/numerical_basis.h | 0 .../numerical_descriptor.cpp | 0 .../{src_pw => src_io}/numerical_descriptor.h | 0 .../source/{src_pw => src_io}/winput.cpp | 2 +- .../source/{src_pw => src_io}/winput.h | 0 ABACUS.develop/source/src_lcao/ELEC_scf.cpp | 2 +- ABACUS.develop/source/src_lcao/dftu.cpp | 2 +- ABACUS.develop/source/src_lcao/dftu_relax.cpp | 2 +- .../source/src_lcao/local_orbital_elec.cpp | 2 +- ABACUS.develop/source/src_pw/algorithms.h | 15 ++- .../source/src_pw/charge_broyden.cpp | 2 +- .../source/src_pw/charge_mixing.cpp | 2 +- ABACUS.develop/source/src_pw/charge_pulay.cpp | 3 +- ABACUS.develop/source/src_pw/efield.cpp | 1 + ABACUS.develop/source/src_pw/electrons.cpp | 15 +-- ABACUS.develop/source/src_pw/symm_book.cpp | 108 ------------------ ABACUS.develop/source/src_pw/symm_book.h | 23 ---- ABACUS.develop/source/src_pw/symmetry.cpp | 5 - ABACUS.develop/source/src_pw/wavefunc.cpp | 7 +- 39 files changed, 73 insertions(+), 232 deletions(-) rename ABACUS.develop/source/{src_pw => src_global}/inverse_matrix.cpp (100%) rename ABACUS.develop/source/{src_pw => src_global}/inverse_matrix.h (100%) rename ABACUS.develop/source/{src_pw => src_io}/bessel_basis.cpp (100%) rename ABACUS.develop/source/{src_pw => src_io}/bessel_basis.h (100%) rename ABACUS.develop/source/{src_pw => src_io}/cal_test.cpp (97%) rename ABACUS.develop/source/{src_pw => src_io}/cal_test.h (100%) rename ABACUS.develop/source/{src_pw => src_io}/chi0_hilbert.cpp (99%) rename ABACUS.develop/source/{src_pw => src_io}/chi0_hilbert.h (89%) rename ABACUS.develop/source/{src_pw => src_io}/chi0_standard.cpp (99%) rename ABACUS.develop/source/{src_pw => src_io}/chi0_standard.h (85%) rename ABACUS.develop/source/{src_pw => src_io}/epsilon0_pwscf.cpp (99%) rename ABACUS.develop/source/{src_pw => src_io}/epsilon0_pwscf.h (76%) rename ABACUS.develop/source/{src_pw => src_io}/epsilon0_vasp.cpp (96%) rename ABACUS.develop/source/{src_pw => src_io}/epsilon0_vasp.h (80%) rename ABACUS.develop/source/{src_pw => src_io}/numerical_basis.cpp (100%) rename ABACUS.develop/source/{src_pw => src_io}/numerical_basis.h (100%) rename ABACUS.develop/source/{src_pw => src_io}/numerical_descriptor.cpp (100%) rename ABACUS.develop/source/{src_pw => src_io}/numerical_descriptor.h (100%) rename ABACUS.develop/source/{src_pw => src_io}/winput.cpp (99%) rename ABACUS.develop/source/{src_pw => src_io}/winput.h (100%) delete mode 100644 ABACUS.develop/source/src_pw/symm_book.cpp delete mode 100644 ABACUS.develop/source/src_pw/symm_book.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index f84b14db27..99f8b6e227 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -223,7 +223,6 @@ ions_move_sd.o\ ions_move_basic.o\ bfgs_basic.o\ occupy.o\ -cal_test0.o\ cal_test.o\ winput.o\ input_update.o\ @@ -260,7 +259,6 @@ global.o \ symmetry.o \ symmetry_basic.o \ symmetry_rho.o \ -symm_book.o \ symm_other.o \ eximport.o \ mulliken_charge.o\ diff --git a/ABACUS.develop/source/driver.cpp b/ABACUS.develop/source/driver.cpp index a62c24b813..8e2cef1b0a 100644 --- a/ABACUS.develop/source/driver.cpp +++ b/ABACUS.develop/source/driver.cpp @@ -6,9 +6,8 @@ #include "src_lcao/global_fp.h" #include "src_pw/global.h" #include "src_io/print_info.h" -#include "src_pw/cal_test.h" -#include "src_pw/cal_test0.h" -#include "src_pw/winput.h" +#include "src_io/cal_test.h" +#include "src_io/winput.h" Driver::Driver(){} @@ -149,11 +148,8 @@ void Driver::reading(void) // mohan add 2010-10-10, just to test the symmetry of a variety // of systems. - //xiaohui modified 2013-03-23,adding "/*" if(CALCULATION == "test") { - Cal_Test::adjacent_atoms(); - //Cal_Test::sparsity(); Cal_Test::test_memory(); QUIT(); } diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index d391646512..369ae8b8c8 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -14,10 +14,10 @@ // mohan 2021-01-30 #include "src_pw/vdwd2.h" #include "src_pw/vdwd3.h" -#include "src_pw/chi0_hilbert.h" -#include "src_pw/chi0_standard.h" -#include "src_pw/epsilon0_pwscf.h" -#include "src_pw/epsilon0_vasp.h" +#include "src_io/chi0_hilbert.h" +#include "src_io/chi0_standard.h" +#include "src_io/epsilon0_pwscf.h" +#include "src_io/epsilon0_vasp.h" #include "src_pw/unitcell.h" #include "src_ri/exx_abfs-jle.h" diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index 5f168e4682..0c98ae9134 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -8,9 +8,9 @@ #include "src_pw/algorithms.h" #include "src_pw/pseudopot_cell_us.h" #include "src_io/optical.h" -#include "src_pw/cal_test.h" +#include "src_io/cal_test.h" #include "src_lcao/dftu.h" //Quxin add for DFT+U on 20201029 -#include "src_pw/winput.h" +#include "src_io/winput.h" #include "src_global/sltk_atom_arrange.h" #include "src_lcao/local_orbital_ions.h" diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp index 5aafb1548f..d456e50ee2 100644 --- a/ABACUS.develop/source/run_pw.cpp +++ b/ABACUS.develop/source/run_pw.cpp @@ -4,8 +4,8 @@ #include "src_pw/algorithms.h" #include "src_pw/pseudopot_cell_us.h" #include "src_io/optical.h" -#include "src_pw/cal_test.h" -#include "src_pw/winput.h" +#include "src_io/cal_test.h" +#include "src_io/winput.h" Run_pw::Run_pw(){} Run_pw::~Run_pw(){} diff --git a/ABACUS.develop/source/src_pw/inverse_matrix.cpp b/ABACUS.develop/source/src_global/inverse_matrix.cpp similarity index 100% rename from ABACUS.develop/source/src_pw/inverse_matrix.cpp rename to ABACUS.develop/source/src_global/inverse_matrix.cpp diff --git a/ABACUS.develop/source/src_pw/inverse_matrix.h b/ABACUS.develop/source/src_global/inverse_matrix.h similarity index 100% rename from ABACUS.develop/source/src_pw/inverse_matrix.h rename to ABACUS.develop/source/src_global/inverse_matrix.h diff --git a/ABACUS.develop/source/src_pw/bessel_basis.cpp b/ABACUS.develop/source/src_io/bessel_basis.cpp similarity index 100% rename from ABACUS.develop/source/src_pw/bessel_basis.cpp rename to ABACUS.develop/source/src_io/bessel_basis.cpp diff --git a/ABACUS.develop/source/src_pw/bessel_basis.h b/ABACUS.develop/source/src_io/bessel_basis.h similarity index 100% rename from ABACUS.develop/source/src_pw/bessel_basis.h rename to ABACUS.develop/source/src_io/bessel_basis.h diff --git a/ABACUS.develop/source/src_pw/cal_test.cpp b/ABACUS.develop/source/src_io/cal_test.cpp similarity index 97% rename from ABACUS.develop/source/src_pw/cal_test.cpp rename to ABACUS.develop/source/src_io/cal_test.cpp index 885689cb11..9cefcaa5c7 100644 --- a/ABACUS.develop/source/src_pw/cal_test.cpp +++ b/ABACUS.develop/source/src_io/cal_test.cpp @@ -1,7 +1,6 @@ -#include "global.h" -#include "tools.h" +#include "src_pw/global.h" +#include "src_pw/tools.h" #include "cal_test.h" -#include "cal_test0.h" double Cal_Test::mporter; @@ -86,7 +85,8 @@ void Cal_Test::test_memory(void) mhs = Memory::calculate_mem( NLOCAL*NLOCAL, "double" ); mwf = Memory::calculate_mem( NLOCAL*NBANDS, "double" ); mnonzero = Memory::calculate_mem( NLOCAL*(NLOCAL+1)/2, "bool"); - mspar_hsrho = Memory::calculate_mem( Hnnz*3, "double"); +// mohan comment out 2021-02-11 +// mspar_hsrho = Memory::calculate_mem( Hnnz*3, "double"); mgvec = Memory::calculate_mem( ngmc * 3 * 2, "double" ); diff --git a/ABACUS.develop/source/src_pw/cal_test.h b/ABACUS.develop/source/src_io/cal_test.h similarity index 100% rename from ABACUS.develop/source/src_pw/cal_test.h rename to ABACUS.develop/source/src_io/cal_test.h diff --git a/ABACUS.develop/source/src_pw/chi0_hilbert.cpp b/ABACUS.develop/source/src_io/chi0_hilbert.cpp similarity index 99% rename from ABACUS.develop/source/src_pw/chi0_hilbert.cpp rename to ABACUS.develop/source/src_io/chi0_hilbert.cpp index 351cb095af..ca9a78e919 100644 --- a/ABACUS.develop/source/src_pw/chi0_hilbert.cpp +++ b/ABACUS.develop/source/src_io/chi0_hilbert.cpp @@ -7,13 +7,13 @@ //theory . and it is a basic work and use the hilbert-transform to reduce the //calculated quantities. //------------------------------------------------------------------------------- -#include "global.h" +#include "src_pw/global.h" #include "chi0_hilbert.h" -#include "algorithms.h" -#include "hamilt_pw.h" -#include "wavefunc_in_pw.h" +#include "src_pw/algorithms.h" +#include "src_pw/hamilt_pw.h" +#include "src_pw/wavefunc_in_pw.h" #include "../src_io/optical.h" -#include "klist.h" +#include "src_pw/klist.h" #include #include "../src_lcao/global_fp.h" diff --git a/ABACUS.develop/source/src_pw/chi0_hilbert.h b/ABACUS.develop/source/src_io/chi0_hilbert.h similarity index 89% rename from ABACUS.develop/source/src_pw/chi0_hilbert.h rename to ABACUS.develop/source/src_io/chi0_hilbert.h index eb7501db4d..391a5d3fff 100644 --- a/ABACUS.develop/source/src_pw/chi0_hilbert.h +++ b/ABACUS.develop/source/src_io/chi0_hilbert.h @@ -1,21 +1,18 @@ //========================================================== -// AUTHOR : Pengfei Li -// DATE : 2016-12-14 +// AUTHOR : Pengfei Li +// DATE : 2016-12-14 //========================================================== #ifndef CHI0_HILBERT_H #define CHI0_HILBERT_H #include "../input_conv.h" -#include "wavefunc.h" -#include "../src_parallel/parallel_global.h" -//#if defined __FFTW2 -//#include "../src_parallel/fftw.h" -//#elif defined __FFTW3 -//#include "../src_parallel/fftw3.h" -//#endif +#include "src_pw/wavefunc.h" +#include "src_parallel/parallel_global.h" class Chi0_hilbert { -public: + + public: + Chi0_hilbert(); ~Chi0_hilbert(); diff --git a/ABACUS.develop/source/src_pw/chi0_standard.cpp b/ABACUS.develop/source/src_io/chi0_standard.cpp similarity index 99% rename from ABACUS.develop/source/src_pw/chi0_standard.cpp rename to ABACUS.develop/source/src_io/chi0_standard.cpp index 409fac850b..db72ad591b 100644 --- a/ABACUS.develop/source/src_pw/chi0_standard.cpp +++ b/ABACUS.develop/source/src_io/chi0_standard.cpp @@ -6,16 +6,18 @@ //this part is for calculating some optical properties using the linear response //theory . //------------------------------------------------------------------------------- -#include "global.h" + +#include "src_pw/global.h" #include "chi0_standard.h" -#include "algorithms.h" -#include "hamilt_pw.h" -#include "wavefunc_in_pw.h" +#include "src_pw/algorithms.h" +#include "src_pw/hamilt_pw.h" +#include "src_pw/wavefunc_in_pw.h" #include "src_io/optical.h" -#include "klist.h" +#include "src_pw/klist.h" #include #include #include + using namespace std; Chi0_standard chi0_standard; diff --git a/ABACUS.develop/source/src_pw/chi0_standard.h b/ABACUS.develop/source/src_io/chi0_standard.h similarity index 85% rename from ABACUS.develop/source/src_pw/chi0_standard.h rename to ABACUS.develop/source/src_io/chi0_standard.h index 29a6a3d515..fe8341adc0 100644 --- a/ABACUS.develop/source/src_pw/chi0_standard.h +++ b/ABACUS.develop/source/src_io/chi0_standard.h @@ -1,13 +1,8 @@ #ifndef CHI0_STANDARD_H #define CHI0_STANDARD_H -#include "wavefunc.h" -#include "../src_parallel/parallel_global.h" -//#if defined __FFTW2 -//#include "../src_parallel/fftw.h" -//#elif defined __FFTW3 -//#include "../src_parallel/fftw3.h" -//#endif +#include "src_pw/wavefunc.h" +#include "src_parallel/parallel_global.h" class Chi0_standard { @@ -85,4 +80,4 @@ class Chi0_standard extern Chi0_standard chi0_standard; -#endif \ No newline at end of file +#endif diff --git a/ABACUS.develop/source/src_pw/epsilon0_pwscf.cpp b/ABACUS.develop/source/src_io/epsilon0_pwscf.cpp similarity index 99% rename from ABACUS.develop/source/src_pw/epsilon0_pwscf.cpp rename to ABACUS.develop/source/src_io/epsilon0_pwscf.cpp index c297a0fca5..3293d27439 100644 --- a/ABACUS.develop/source/src_pw/epsilon0_pwscf.cpp +++ b/ABACUS.develop/source/src_io/epsilon0_pwscf.cpp @@ -6,14 +6,15 @@ //this part is for calculating the macroscopic dielectric tensor using the linear //response theory . //------------------------------------------------------------------------------- -#include "global.h" -#include "algorithms.h" -#include "hamilt_pw.h" +#include "src_pw/global.h" +#include "src_pw/algorithms.h" +#include "src_pw/hamilt_pw.h" #include "../src_pw/wavefunc_in_pw.h" #include "src_io/optical.h" #include "epsilon0_pwscf.h" #include #include + using namespace std; Epsilon0_pwscf epsilon0_pwscf; diff --git a/ABACUS.develop/source/src_pw/epsilon0_pwscf.h b/ABACUS.develop/source/src_io/epsilon0_pwscf.h similarity index 76% rename from ABACUS.develop/source/src_pw/epsilon0_pwscf.h rename to ABACUS.develop/source/src_io/epsilon0_pwscf.h index dd9fa5cbdc..bd086fcb45 100644 --- a/ABACUS.develop/source/src_pw/epsilon0_pwscf.h +++ b/ABACUS.develop/source/src_io/epsilon0_pwscf.h @@ -1,13 +1,8 @@ #ifndef EPSILON0_PWSCF_H #define EPSILON0_PWSCF_H -#include "wavefunc.h" +#include "src_pw/wavefunc.h" #include "../src_parallel/parallel_global.h" -//#if defined __FFTW2 -//#include "../src_parallel/fftw.h" -//#elif defined __FFTW3 -//#include "../src_parallel/fftw3.h" -//#endif class Epsilon0_pwscf { @@ -46,4 +41,4 @@ class Epsilon0_pwscf extern Epsilon0_pwscf epsilon0_pwscf; -#endif \ No newline at end of file +#endif diff --git a/ABACUS.develop/source/src_pw/epsilon0_vasp.cpp b/ABACUS.develop/source/src_io/epsilon0_vasp.cpp similarity index 96% rename from ABACUS.develop/source/src_pw/epsilon0_vasp.cpp rename to ABACUS.develop/source/src_io/epsilon0_vasp.cpp index e506faca9b..4d31cd86c5 100644 --- a/ABACUS.develop/source/src_pw/epsilon0_vasp.cpp +++ b/ABACUS.develop/source/src_io/epsilon0_vasp.cpp @@ -6,14 +6,15 @@ //this part is for calculating the macroscopic dielectric tensor using the linear //response theory . //------------------------------------------------------------------------------- -#include "global.h" -#include "algorithms.h" -#include "hamilt_pw.h" +#include "src_pw/global.h" +#include "src_pw/algorithms.h" +#include "src_pw/hamilt_pw.h" #include "../src_pw/wavefunc_in_pw.h" #include "./src_io/optical.h" #include "epsilon0_vasp.h" #include #include + using namespace std; Epsilon0_vasp epsilon0_vasp; diff --git a/ABACUS.develop/source/src_pw/epsilon0_vasp.h b/ABACUS.develop/source/src_io/epsilon0_vasp.h similarity index 80% rename from ABACUS.develop/source/src_pw/epsilon0_vasp.h rename to ABACUS.develop/source/src_io/epsilon0_vasp.h index d6a073954e..dfb7e3c3ef 100644 --- a/ABACUS.develop/source/src_pw/epsilon0_vasp.h +++ b/ABACUS.develop/source/src_io/epsilon0_vasp.h @@ -1,13 +1,8 @@ #ifndef EPSILON0_VASP_H #define EPSILON0_VASP_H -#include "wavefunc.h" +#include "src_pw/wavefunc.h" #include "../src_parallel/parallel_global.h" -//#if defined __FFTW2 -//#include "../src_parallel/fftw.h" -//#elif defined __FFTW3 -//#include "../src_parallel/fftw3.h" -//#endif class Epsilon0_vasp { diff --git a/ABACUS.develop/source/src_pw/numerical_basis.cpp b/ABACUS.develop/source/src_io/numerical_basis.cpp similarity index 100% rename from ABACUS.develop/source/src_pw/numerical_basis.cpp rename to ABACUS.develop/source/src_io/numerical_basis.cpp diff --git a/ABACUS.develop/source/src_pw/numerical_basis.h b/ABACUS.develop/source/src_io/numerical_basis.h similarity index 100% rename from ABACUS.develop/source/src_pw/numerical_basis.h rename to ABACUS.develop/source/src_io/numerical_basis.h diff --git a/ABACUS.develop/source/src_pw/numerical_descriptor.cpp b/ABACUS.develop/source/src_io/numerical_descriptor.cpp similarity index 100% rename from ABACUS.develop/source/src_pw/numerical_descriptor.cpp rename to ABACUS.develop/source/src_io/numerical_descriptor.cpp diff --git a/ABACUS.develop/source/src_pw/numerical_descriptor.h b/ABACUS.develop/source/src_io/numerical_descriptor.h similarity index 100% rename from ABACUS.develop/source/src_pw/numerical_descriptor.h rename to ABACUS.develop/source/src_io/numerical_descriptor.h diff --git a/ABACUS.develop/source/src_pw/winput.cpp b/ABACUS.develop/source/src_io/winput.cpp similarity index 99% rename from ABACUS.develop/source/src_pw/winput.cpp rename to ABACUS.develop/source/src_io/winput.cpp index e2fc636b1b..b5c415b695 100644 --- a/ABACUS.develop/source/src_pw/winput.cpp +++ b/ABACUS.develop/source/src_io/winput.cpp @@ -4,7 +4,7 @@ #include #include #include "winput.h" -#include "global.h" +#include "src_pw/global.h" string winput::target;//add 2008-06-04 diff --git a/ABACUS.develop/source/src_pw/winput.h b/ABACUS.develop/source/src_io/winput.h similarity index 100% rename from ABACUS.develop/source/src_pw/winput.h rename to ABACUS.develop/source/src_io/winput.h diff --git a/ABACUS.develop/source/src_lcao/ELEC_scf.cpp b/ABACUS.develop/source/src_lcao/ELEC_scf.cpp index ab6a015ab8..50c9abd06c 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_scf.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_scf.cpp @@ -1,6 +1,6 @@ #include "ELEC_scf.h" #include "src_pw/global.h" -#include "src_pw/chi0_hilbert.h" +#include "src_io/chi0_hilbert.h" #include "src_pw/symmetry_rho.h" #include "dftu.h" #include "LCAO_evolve.h" diff --git a/ABACUS.develop/source/src_lcao/dftu.cpp b/ABACUS.develop/source/src_lcao/dftu.cpp index a8686afbdd..511f233a8e 100644 --- a/ABACUS.develop/source/src_lcao/dftu.cpp +++ b/ABACUS.develop/source/src_lcao/dftu.cpp @@ -19,7 +19,7 @@ #include "../src_global/global_function.h" #include "../src_global/scalapack_connector.h" #include "../src_global/lapack_connector.h" -#include "../src_pw/inverse_matrix.h" +#include "../src_global/inverse_matrix.h" #include "local_orbital_ions.h" #include "LCAO_matrix.h" #include "../src_pw/magnetism.h" diff --git a/ABACUS.develop/source/src_lcao/dftu_relax.cpp b/ABACUS.develop/source/src_lcao/dftu_relax.cpp index 7f6bc27303..2c3747e78c 100644 --- a/ABACUS.develop/source/src_lcao/dftu_relax.cpp +++ b/ABACUS.develop/source/src_lcao/dftu_relax.cpp @@ -18,7 +18,7 @@ #include "../src_global/global_function.h" #include "../src_global/scalapack_connector.h" #include "../src_global/lapack_connector.h" -#include "../src_pw/inverse_matrix.h" +#include "../src_global/inverse_matrix.h" #include "local_orbital_ions.h" #include "LCAO_matrix.h" #include "../src_pw/magnetism.h" diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp index d471076fed..10104846d7 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp @@ -3,7 +3,7 @@ #include "src_pw/global.h" #include "src_pw/symmetry_rho.h" #include "input_update.h" -#include "src_pw/chi0_hilbert.h" +#include "src_io/chi0_hilbert.h" #include "LCAO_evolve.h" #include "dftu.h" // diff --git a/ABACUS.develop/source/src_pw/algorithms.h b/ABACUS.develop/source/src_pw/algorithms.h index 122f6558fa..2468562326 100644 --- a/ABACUS.develop/source/src_pw/algorithms.h +++ b/ABACUS.develop/source/src_pw/algorithms.h @@ -3,14 +3,13 @@ #include "diago_cg.h" #include "diago_david.h" -#include "../src_ions/ions_move_bfgs.h" - -#include "../src_pw/dos.h" - -#include "../src_pw/myfunc.h" -#include "numerical_basis.h" -#include "numerical_descriptor.h" // mohan added 2021-01-04 -#include "bessel_basis.h" +#include "src_ions/ions_move_bfgs.h" +#include "src_io/dos.h" +#include "src_pw/myfunc.h" +// +#include "src_io/numerical_basis.h" +#include "src_io/numerical_descriptor.h" // mohan added 2021-01-04 +#include "src_io/bessel_basis.h" //#include "../src_algorithms/spillage.h" //#include "../src_algorithms/mymath.h" diff --git a/ABACUS.develop/source/src_pw/charge_broyden.cpp b/ABACUS.develop/source/src_pw/charge_broyden.cpp index 0146adc8cc..04db391a62 100644 --- a/ABACUS.develop/source/src_pw/charge_broyden.cpp +++ b/ABACUS.develop/source/src_pw/charge_broyden.cpp @@ -1,6 +1,6 @@ #include "charge_broyden.h" #include "global.h" -#include "../src_pw/inverse_matrix.h" +#include "../src_global/inverse_matrix.h" Charge_Broyden::Charge_Broyden() { diff --git a/ABACUS.develop/source/src_pw/charge_mixing.cpp b/ABACUS.develop/source/src_pw/charge_mixing.cpp index 2a9b16b019..06446118d5 100644 --- a/ABACUS.develop/source/src_pw/charge_mixing.cpp +++ b/ABACUS.develop/source/src_pw/charge_mixing.cpp @@ -1,6 +1,6 @@ #include "charge_mixing.h" #include "global.h" -#include "../src_pw/inverse_matrix.h" +#include "../src_global/inverse_matrix.h" Charge_Mixing::Charge_Mixing(){} Charge_Mixing::~Charge_Mixing(){} diff --git a/ABACUS.develop/source/src_pw/charge_pulay.cpp b/ABACUS.develop/source/src_pw/charge_pulay.cpp index 1946d3f306..2fcd4ff931 100644 --- a/ABACUS.develop/source/src_pw/charge_pulay.cpp +++ b/ABACUS.develop/source/src_pw/charge_pulay.cpp @@ -1,7 +1,6 @@ #include "charge_pulay.h" #include "global.h" -#include "../src_pw/inverse_matrix.h" - +#include "../src_global/inverse_matrix.h" #include "../src_global/random.h" Charge_Pulay::Charge_Pulay() diff --git a/ABACUS.develop/source/src_pw/efield.cpp b/ABACUS.develop/source/src_pw/efield.cpp index 3a8fa63cdb..be6140706e 100644 --- a/ABACUS.develop/source/src_pw/efield.cpp +++ b/ABACUS.develop/source/src_pw/efield.cpp @@ -1,6 +1,7 @@ #include "efield.h" #include "tools.h" #include "global.h" + Efield::Efield(){} Efield::~Efield(){} diff --git a/ABACUS.develop/source/src_pw/electrons.cpp b/ABACUS.develop/source/src_pw/electrons.cpp index 332aac1261..42f941b14a 100644 --- a/ABACUS.develop/source/src_pw/electrons.cpp +++ b/ABACUS.develop/source/src_pw/electrons.cpp @@ -3,13 +3,14 @@ #include "electrons.h" #include "algorithms.h" #include "symmetry_rho.h" -#include "../src_io/wf_io.h" -#include "chi0_hilbert.h" // pengfei 2016-11-23 -#include "chi0_standard.h" -#include "epsilon0_pwscf.h" -#include "epsilon0_vasp.h" -#include "../src_io/to_wannier90.h" -#include "../src_io/berryphase.h" +// src_io functions +#include "src_io/wf_io.h" +#include "src_io/chi0_hilbert.h" +#include "src_io/chi0_standard.h" +#include "src_io/epsilon0_pwscf.h" +#include "src_io/epsilon0_vasp.h" +#include "src_io/to_wannier90.h" +#include "src_io/berryphase.h" double Electrons::avg_iter = 0; diff --git a/ABACUS.develop/source/src_pw/symm_book.cpp b/ABACUS.develop/source/src_pw/symm_book.cpp deleted file mode 100644 index 48e98bc850..0000000000 --- a/ABACUS.develop/source/src_pw/symm_book.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include "tools.h" -#include "symm_book.h" - -Symm_Book::Symm_Book() -{ - -} - - -Symm_Book::~Symm_Book() -{ - -} - - -void Symm_Book::Bravais() -{ - TITLE("Symm_Book","Bravais"); - - write("There are only 7 crystal systems"); - write("Any other point groups are the subgroup of the 7"); - write("The 7 are: S2, C2h, D2h, D4h, D3d, D6h, Oh"); - - write("There are 32 point groups:"); - ofs_running << setw(5) << " S2" << setw(2) << ":" << - setw(5) << "S2" << - setw(5) << "C1" << endl; - - ofs_running << setw(5) << " C2h" << setw(2) << ":" << - setw(5) << "C2h" << - setw(5) << "C2" << - setw(5) << "C1h" << endl; - - ofs_running << setw(5) << " D2h" << setw(2) << ":" << - setw(5) << "D2h" << - setw(5) << "D2" << - setw(5) << "C2v" << endl; - - ofs_running << setw(5) << " D4h" << setw(2) << ":" << - setw(5) << "D4h" << - setw(5) << "C4" << - setw(5) << "S4" << - setw(5) << "D4" << - setw(5) << "C4v" << - setw(5) << "C4h" << - setw(5) << "D2d" << endl; - - ofs_running << setw(5) << " D3d" << setw(2) << ":" << - setw(5) << "D3d" << - setw(5) << "S6" << - setw(5) << "C3" << - setw(5) << "C3v" << - setw(5) << "D3" << endl; - - ofs_running << setw(5) << " D6h" << setw(2) << ":" << - setw(5) << "D6h" << - setw(5) << "C6" << - setw(5) << "C3h" << - setw(5) << "C6h" << - setw(5) << "C6v" << - setw(5) << "D6" << - setw(5) << "D3h" << endl; - - ofs_running << setw(5) << " Oh" << setw(2) << ":" << - setw(5) << "Oh" << - setw(5) << "T" << - setw(5) << "O" << - setw(5) << "Th" << - setw(5) << "Td" << endl; - - write("There are two types of point groups"); - write("1: C1.C2.C3.C4.C6.D2.D3.D4.D6.T.O"); - write("2: S2.S4.S6.C1h.C2h.C3h.C4h.C6h.C2v.C3v.C4v.C6v.D2h.D3h.D4h.D6h.D2d.D3d.Th.Oh.Td"); - - write("The 14 Bravais Lattices are"); - write("01. Cubic P (a=b=c) (sc)"); - write("02. Cubic I (a=b=c) (bcc)"); - write("03. Cubic F (a=b=c) (fcc)"); - write("04. Trigonal and hexagonal P"); - write("05. Tetragonal P"); - write("06. Tetragonal I"); - write("07. Trigonal R"); - write("08. Orthorhombic P (a!=b!=c)"); - write("09. Orthorhombic I"); - write("10. Orthorhombic F"); - write("11. Orthorhombic C"); - write("12. Monoclinic P"); - write("13. Monoclinic A"); - write("14. Triclinic P"); - - write("The rank of the point groups"); - write("48: Oh"); - write("24: D6h. Th. O. Td"); - write("16: D4h"); - write("12: D3h. C6h. D3d. C6v. D6. T"); - write("08: D2h. C4h. D2d. C4v. D4"); - write("06: C6. C3h. S6. C3v. D3"); - write("04: C4. C2h. S4. C2v. D2"); - write("03: C3"); - write("02: C2, C1h, S2"); - write("01: C1"); - -} - -void Symm_Book::write(const string &name) -{ - ofs_running << " " << name << "." << endl; -} diff --git a/ABACUS.develop/source/src_pw/symm_book.h b/ABACUS.develop/source/src_pw/symm_book.h deleted file mode 100644 index 1f9a4466d8..0000000000 --- a/ABACUS.develop/source/src_pw/symm_book.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef SYMM_BOOK_H -#define SYMM_BOOK_H - -#include -using namespace std; - -class Symm_Book -{ - public: - Symm_Book(); - ~Symm_Book(); - - void Bravais(); - - private: - - void write(const string &name); - -}; - - - -#endif diff --git a/ABACUS.develop/source/src_pw/symmetry.cpp b/ABACUS.develop/source/src_pw/symmetry.cpp index c72badf30e..2cd4600577 100644 --- a/ABACUS.develop/source/src_pw/symmetry.cpp +++ b/ABACUS.develop/source/src_pw/symmetry.cpp @@ -19,7 +19,6 @@ Symmetry::~Symmetry() } -#include "symm_book.h" void Symmetry::analy_sys(void) { if (available == false) return; @@ -40,10 +39,6 @@ void Symmetry::analy_sys(void) ofs_running << "\n\n\n\n"; - Symm_Book SB; -// SB.Bravais(); - - this->ibrav = 0; // number of total atoms this->nat = ucell.nat; diff --git a/ABACUS.develop/source/src_pw/wavefunc.cpp b/ABACUS.develop/source/src_pw/wavefunc.cpp index 1164c27faa..c6f0c39fa3 100644 --- a/ABACUS.develop/source/src_pw/wavefunc.cpp +++ b/ABACUS.develop/source/src_pw/wavefunc.cpp @@ -3,11 +3,8 @@ #include "algorithms.h" #include "../src_pw/wavefunc_in_pw.h" //xiaohui add 2013 -08-01 -#include "winput.h" -#include "chi0_hilbert.h" -#ifdef __FP -//#include "../src_develop/src_wannier/manipulation.h" -#endif +#include "src_io/winput.h" +#include "src_io/chi0_hilbert.h" wavefunc::wavefunc() { From 9f760cf6088276bd0af655c610c20cf3f4fa3889 Mon Sep 17 00:00:00 2001 From: mohan Date: Thu, 11 Feb 2021 21:02:26 +0800 Subject: [PATCH 110/233] change the class name Use_Overlap_Matrix to LCAO_gen_fixedH, substitue UOM with genH. --- ABACUS.develop/source/README | 23 ++------ .../source/src_lcao/LCAO_gen_fixedH.cpp | 54 +++++++++---------- .../source/src_lcao/LCAO_gen_fixedH.h | 10 ++-- .../source/src_lcao/LCAO_hamilt.cpp | 16 +++--- ABACUS.develop/source/src_lcao/LCAO_hamilt.h | 4 +- ABACUS.develop/source/src_lcao/ORB_read.cpp | 5 +- ABACUS.develop/source/src_lcao/ORB_read.h | 9 ++-- .../source/src_lcao/force_lcao_gamma.cpp | 39 +++----------- .../source/src_lcao/force_lcao_gamma.h | 1 - .../source/src_lcao/force_lcao_k.cpp | 6 +-- .../source/src_lcao/mulliken_charge.cpp | 4 +- ABACUS.develop/source/src_pw/energy.cpp | 4 +- 12 files changed, 66 insertions(+), 109 deletions(-) diff --git a/ABACUS.develop/source/README b/ABACUS.develop/source/README index d8f5f76ca5..7c8bf12f78 100644 --- a/ABACUS.develop/source/README +++ b/ABACUS.develop/source/README @@ -1,21 +1,4 @@ +Currently we are working on optimizing the code structure of ABACUS, +implementing new functions, and adding more autotests. -Currently we are working on: -1) fix the parallel bug when using plane wave basis (pw is not enough) -2) SDFT -3) DeepKS - ------------------------------------------------------------------------ - -The code should be reconstructed with the following details: - -1) the TDDFT module should be relocated. -2) the inclusion of files in vdw3 should be changed. -3) Is is necessary to include -4) There is a segmental fault when use ABACUS compiled with gnu-mpich -5) solve the memory problem regarding gamma wave functions in LCAO -6) delete VNA codes - ------------------------------------------------------------------------ -Unitesets should include -1) initialization after cell variation -2) +-- mohan 2021-02-11 diff --git a/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.cpp b/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.cpp index 3eab07ed64..41fec2bf1c 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.cpp @@ -1,21 +1,19 @@ #include "LCAO_gen_fixedH.h" #include "../src_pw/global.h" #include "../src_pw/wavefunc.h" -//#include "../src_develop/src_wannier/manipulation.h" #include "LCAO_nnr.h" +#include "global_fp.h" -#include "global_fp.h" // mohan add 2021-01-30 - -Use_Overlap_Matrix::Use_Overlap_Matrix() +LCAO_gen_fixedH::LCAO_gen_fixedH() {} -Use_Overlap_Matrix::~Use_Overlap_Matrix() +LCAO_gen_fixedH::~LCAO_gen_fixedH() {} -void Use_Overlap_Matrix::calculate_NL_no(void) +void LCAO_gen_fixedH::calculate_NL_no(void) { - TITLE("Use_Overlap_Matrix","calculate_NL_no"); + TITLE("LCAO_gen_fixedH","calculate_NL_no"); if(GAMMA_ONLY_LOCAL) { @@ -35,27 +33,27 @@ void Use_Overlap_Matrix::calculate_NL_no(void) } -void Use_Overlap_Matrix::calculate_T_no(void) +void LCAO_gen_fixedH::calculate_T_no(void) { - TITLE("Use_Overlap_Matrix","calculate_T_no"); + TITLE("LCAO_gen_fixedH","calculate_T_no"); this->build_ST_new('T', false); return; } -void Use_Overlap_Matrix::calculate_S_no(void) +void LCAO_gen_fixedH::calculate_S_no(void) { - TITLE("Use_Overlap_Matrix", "calculate_S_no"); - timer::tick("Use_Overlap_Matrix","calculate_S_no"); + TITLE("LCAO_gen_fixedH", "calculate_S_no"); + timer::tick("LCAO_gen_fixedH","calculate_S_no"); this->build_ST_new('S', false); - timer::tick("Use_Overlap_Matrix","calculate_S_no"); + timer::tick("LCAO_gen_fixedH","calculate_S_no"); return; } //liaochen modify interface 2010-3-22 -void Use_Overlap_Matrix::build_ST_new(const char& dtype, const bool& calc_deri) +void LCAO_gen_fixedH::build_ST_new(const char& dtype, const bool& calc_deri) { - TITLE("Use_Overlap_Matrix","build_ST_new"); + TITLE("LCAO_gen_fixedH","build_ST_new"); //array to store data double olm[3]={0.0,0.0,0.0}; @@ -262,14 +260,14 @@ void Use_Overlap_Matrix::build_ST_new(const char& dtype, const bool& calc_deri) { cout << " nnr=" << nnr << " LNNR.nnr=" << LNNR.nnr << endl; ofs_running << " nnr=" << nnr << " LNNR.nnr=" << LNNR.nnr << endl; - WARNING_QUIT("Use_Overlap_Matrix::build_ST_new","nnr != LNNR.nnr"); + WARNING_QUIT("LCAO_gen_fixedH::build_ST_new","nnr != LNNR.nnr"); } } return; } -void Use_Overlap_Matrix::test_Nonlocal() +void LCAO_gen_fixedH::test_Nonlocal() { int nnr = 0; Vector3 tau1, tau2, dtau_12, tau0, dtau_10, dtau_20; @@ -396,10 +394,10 @@ void Use_Overlap_Matrix::test_Nonlocal() #include "record_adj.h" //mohan add 2012-07-06 -void Use_Overlap_Matrix::build_Nonlocal_mu(const bool &calc_deri) +void LCAO_gen_fixedH::build_Nonlocal_mu(const bool &calc_deri) { - TITLE("Use_Overlap_Matrix","build_Nonlocal_mu"); - timer::tick ("Use_Overlap_Matrix","build_Nonlocal_mu",'G'); + TITLE("LCAO_gen_fixedH","build_Nonlocal_mu"); + timer::tick ("LCAO_gen_fixedH","build_Nonlocal_mu",'G'); // < phi1 | beta > < beta | phi2 > // phi1 is within the unitcell. @@ -633,21 +631,21 @@ void Use_Overlap_Matrix::build_Nonlocal_mu(const bool &calc_deri) // ofs_running << " LNNR.nnr=" << LNNR.nnr << endl; if( nnr!=LNNR.nnr) { - WARNING_QUIT("Use_Overlap_Matrix::build_Nonlocal_mu","nnr!=LNNR.nnr"); + WARNING_QUIT("LCAO_gen_fixedH::build_Nonlocal_mu","nnr!=LNNR.nnr"); } } // cout << " build_Nonlocal_mu done" << endl; - timer::tick ("Use_Overlap_Matrix","build_Nonlocal_mu",'G'); + timer::tick ("LCAO_gen_fixedH","build_Nonlocal_mu",'G'); return; } -void Use_Overlap_Matrix::build_Nonlocal_beta(const bool& calc_deri) +void LCAO_gen_fixedH::build_Nonlocal_beta(const bool& calc_deri) { - TITLE("Use_Overlap_Matrix","build_Nonlocal_beta"); - timer::tick ("Use_Overlap_Matrix","build_Nonlocal_beta",'G'); + TITLE("LCAO_gen_fixedH","build_Nonlocal_beta"); + timer::tick ("LCAO_gen_fixedH","build_Nonlocal_beta",'G'); for (int T0 = 0; T0 < ucell.ntype; T0++) { @@ -725,7 +723,7 @@ void Use_Overlap_Matrix::build_Nonlocal_beta(const bool& calc_deri) } else { - WARNING_QUIT("Use_Overlap_Matrix::build_Nonlocal_beta","not consistent with k point algorithm."); + WARNING_QUIT("LCAO_gen_fixedH::build_Nonlocal_beta","not consistent with k point algorithm."); // assert( nnr < LNNR.nnr ); // LM.Hloc_fixedR[ nnr ] += nlm[0]; // ++nnr; @@ -752,7 +750,7 @@ void Use_Overlap_Matrix::build_Nonlocal_beta(const bool& calc_deri) } else { - WARNING_QUIT("Use_Overlap_Matrix::build_Nonlocal_beta","not consistent with k point algorithm."); + WARNING_QUIT("LCAO_gen_fixedH::build_Nonlocal_beta","not consistent with k point algorithm."); //LM.DHloc_fixedR_x[ nnr ] += nlm[0]; //LM.DHloc_fixedR_y[ nnr ] += nlm[1]; //LM.DHloc_fixedR_z[ nnr ] += nlm[2]; @@ -782,7 +780,7 @@ void Use_Overlap_Matrix::build_Nonlocal_beta(const bool& calc_deri) }// end I0 }// end T0 - timer::tick ("Use_Overlap_Matrix","build_Nonlocal_beta",'G'); + timer::tick ("LCAO_gen_fixedH","build_Nonlocal_beta",'G'); return; } diff --git a/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.h b/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.h index 973343a14a..8f4bf94f25 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.h +++ b/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.h @@ -1,14 +1,14 @@ /************************************ //LiaoChen Modify on 2010-3-22 ***********************************/ -#ifndef USE_OVERLAP_MATRIX_H -#define USE_OVERLAP_MATRIX_H +#ifndef LCAO_gen_fixedH_H +#define LCAO_gen_fixedH_H #include "../src_pw/tools.h" #include "ORB_gen_tables.h" #include "../src_global/sltk_grid_driver.h" -class Use_Overlap_Matrix +class LCAO_gen_fixedH { friend class Force_LCAO_gamma; friend class Force_LCAO_k; @@ -17,8 +17,8 @@ class Use_Overlap_Matrix public: - Use_Overlap_Matrix(); - ~Use_Overlap_Matrix(); + LCAO_gen_fixedH(); + ~LCAO_gen_fixedH(); void calculate_NL_no(void); void calculate_T_no(void); diff --git a/ABACUS.develop/source/src_lcao/LCAO_hamilt.cpp b/ABACUS.develop/source/src_lcao/LCAO_hamilt.cpp index 7ab448f494..824a0e5d20 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_hamilt.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_hamilt.cpp @@ -133,7 +133,7 @@ void Use_Hamilt_Matrix::calculate_STNR_gamma(void) LM.zeros_HSgamma('S'); - this->UOM.calculate_S_no(); + this->genH.calculate_S_no(); //LM.print_HSgamma('S'); @@ -154,7 +154,7 @@ void Use_Hamilt_Matrix::calculate_STNR_gamma(void) time_t time_vnl_start = time(NULL); if(VNL_IN_H) { - UOM.calculate_NL_no(); + genH.calculate_NL_no(); } time_t time_vnl_end = time(NULL); @@ -164,7 +164,7 @@ void Use_Hamilt_Matrix::calculate_STNR_gamma(void) time_t time_t_start = time(NULL); if(T_IN_H) { - UOM.calculate_T_no(); + genH.calculate_T_no(); // LM.print_HSgamma('T'); } time_t time_t_end = time(NULL); @@ -273,7 +273,7 @@ void Use_Hamilt_Matrix::calculate_STNR_k(void) // and store in LM.SlocR. //-------------------------------------------- LM.zeros_HSR('S', LNNR.nnr); - this->UOM.calculate_S_no(); + this->genH.calculate_S_no(); //------------------------------ // set T(R) and Vnl(R) to zero. @@ -286,13 +286,13 @@ void Use_Hamilt_Matrix::calculate_STNR_k(void) if(T_IN_H) { - this->UOM.calculate_T_no(); + this->genH.calculate_T_no(); } if(VNL_IN_H) { - this->UOM.calculate_NL_no(); + this->genH.calculate_NL_no(); } @@ -348,11 +348,11 @@ void Use_Hamilt_Matrix::calculate_STNR_k(void) // GAMMA_ONLY_LOCAL = true; // LM.allocate_HS_gamma(ParaO.nloc); // LM.zeros_HSgamma('H'); -// UHM.UOM.calculate_NL_no( nstart ); +// UHM.genH.calculate_NL_no( nstart ); // GAMMA_ONLY_LOCAL = false; // cout << " Correct LCAO Vnl " << endl; // LM.print_HSgamma('H'); -// UHM.UOM.calculate_NL_no( nstart ); +// UHM.genH.calculate_NL_no( nstart ); // GAMMA_ONLY_LOCAL = false; // cout << " Correct LCAO Vnl " << endl; // LM.print_HSgamma('H'); diff --git a/ABACUS.develop/source/src_lcao/LCAO_hamilt.h b/ABACUS.develop/source/src_lcao/LCAO_hamilt.h index e3c7e9ac0f..1c98757418 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_hamilt.h +++ b/ABACUS.develop/source/src_lcao/LCAO_hamilt.h @@ -29,8 +29,8 @@ class Use_Hamilt_Matrix // used for k-dependent grid integration. Gint_k GK; - // use overlap matrix. - Use_Overlap_Matrix UOM; + // use overlap matrix to generate fixed Hamiltonian + LCAO_gen_fixedH genH; // init S (overlap matrix) flag. bool init_s; diff --git a/ABACUS.develop/source/src_lcao/ORB_read.cpp b/ABACUS.develop/source/src_lcao/ORB_read.cpp index 897e446906..a2390d80b8 100644 --- a/ABACUS.develop/source/src_lcao/ORB_read.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_read.cpp @@ -3,7 +3,7 @@ #include // Peize Lin fix bug about strcmp 2016-08-02 //============================== -// Define a object here! +// Define an object here! //============================== LCAO_Orbitals ORB; @@ -88,6 +88,7 @@ void LCAO_Orbitals::bcast_files(void) } #endif + void LCAO_Orbitals::Read_Orbitals(void) { TITLE("LCAO_Orbitals", "Read_Orbitals"); @@ -107,8 +108,6 @@ void LCAO_Orbitals::Read_Orbitals(void) ofs_running << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << endl; ofs_running << "\n\n\n\n"; - - //-------------------------- //(1) check dk, dR, Rmax. //-------------------------- diff --git a/ABACUS.develop/source/src_lcao/ORB_read.h b/ABACUS.develop/source/src_lcao/ORB_read.h index 3adccb2eff..d2ebd53f24 100644 --- a/ABACUS.develop/source/src_lcao/ORB_read.h +++ b/ABACUS.develop/source/src_lcao/ORB_read.h @@ -1,7 +1,7 @@ //========================================================= //AUTHOR : mohan //DATE : 2009-04-23 -//Last Update : 2009-04-23 +//Last Update : 2021-02-11 //========================================================= #ifndef LCAO_ORBITALS_H #define LCAO_ORBITALS_H @@ -44,10 +44,13 @@ class LCAO_Orbitals const int& get_ntype(void) const {return ntype;} const double& get_dr_uniform(void) const {return dr_uniform;} + // numerical atomic orbitals Numerical_Orbital* Phi; + + // nonlocal projectors (1-dimension array) Numerical_Nonlocal* Beta; - // init in input.cpp + // initialized in input.cpp double ecutwfc; double dk; double dR; @@ -60,7 +63,7 @@ class LCAO_Orbitals double dr_uniform; - // init in unitcell_pseudo + // initalized in unitcell_pseudo // assume ntype < 20. bool read_in_flag; std::vector orbital_file; diff --git a/ABACUS.develop/source/src_lcao/force_lcao_gamma.cpp b/ABACUS.develop/source/src_lcao/force_lcao_gamma.cpp index 9c63bcc83f..bce5066dc1 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao_gamma.cpp +++ b/ABACUS.develop/source/src_lcao/force_lcao_gamma.cpp @@ -148,7 +148,7 @@ void Force_LCAO_gamma::allocate_gamma(void) //calculate dS in LCAO basis // tips: build_ST_new --> ParaO.set_force //timer::tick("Force_LCAO_gamma","build_S_new",'H'); - UHM.UOM.build_ST_new ('S', cal_deri); + UHM.genH.build_ST_new ('S', cal_deri); //timer::tick("Force_LCAO_gamma","build_S_new",'H'); Memory::record("force_lo", "dS", ParaO.nloc*3, "double"); @@ -166,13 +166,13 @@ void Force_LCAO_gamma::allocate_gamma(void) //calculate dT //calculate T + VNL(P1) in LCAO basis //timer::tick("Force_LCAO_gamma","build_T_new",'H'); - UHM.UOM.build_ST_new ('T', cal_deri); + UHM.genH.build_ST_new ('T', cal_deri); //timer::tick("Force_LCAO_gamma","build_T_new",'H'); //test_gamma(LM.DHloc_fixed_x, "dHloc_fixed_x T part"); - //UHM.UOM.build_Nonlocal_beta (cal_deri); + //UHM.genH.build_Nonlocal_beta (cal_deri); //timer::tick("Force_LCAO_gamma","build_Nonlocal_mu",'H'); - UHM.UOM.build_Nonlocal_mu (cal_deri); + UHM.genH.build_Nonlocal_mu (cal_deri); //timer::tick("Force_LCAO_gamma","build_Nonlocal_mu",'H'); //test_gamma(LM.DHloc_fixed_x, "dHloc_fixed_x Vnl part"); @@ -852,11 +852,11 @@ void Force_LCAO_gamma::DerivT_PW(void) //TEST OUTPUT OF S Deriv Matrix in PW //------------------------------------------ //test under pw basis - hm.hon.UOM.ForcedT = new matrix[3]; - this->dt = hm.hon.UOM.ForcedT; + hm.hon.genH.ForcedT = new matrix[3]; + this->dt = hm.hon.genH.ForcedT; for (int i = 0; i < 3; i++) this->dt[i].create (NLOCAL, NLOCAL); - hm.hon.UOM.build_ST (1, 'T', true); + hm.hon.genH.build_ST (1, 'T', true); cout << "\n===========================================================================" << endl; out.printrm("Force_LCAO_gamma, X Directional Derivatives of T Matrix in PW", this->dt[0]); @@ -1408,31 +1408,6 @@ void Force_LCAO_gamma::cal_fvnl_dbeta(double** dm2d) return; } -void Force_LCAO_gamma::DerivS_PW (void) -{ - WARNING_QUIT("Force_LCAO_gamma::DerivT_PW","no use for a long time."); - // no use for a long time. - // mohan 2010-08-10 - /* - //----------------------------------------- - //TEST OUTPUT OF S Deriv Matrix in PW - //----------------------------------------- - //test under pw basis - hm.hon.UOM.ForcedS = new matrix[3]; - this->ds = hm.hon.UOM.ForcedS; - for (int i = 0; i < 3; i++) this->ds[i].create (NLOCAL, NLOCAL); - - hm.hon.UOM.build_ST (1, 'S', true); - - // cout << "\n===========================================================================" << endl; - // out.printrm("Force_LCAO_gamma, X Directional Derivatives of S Matrix in PW", this->ds[2]); - // cout << "\n===========================================================================" << endl; - - for (int i = 0; i < 3; i++) this->ds[i].freemem (); - delete[] this->ds; - */ - return; -} void Force_LCAO_gamma::cal_ftvnl_dphi(const std::vector &dm2d) { diff --git a/ABACUS.develop/source/src_lcao/force_lcao_gamma.h b/ABACUS.develop/source/src_lcao/force_lcao_gamma.h index db2c260c81..031e8d4924 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao_gamma.h +++ b/ABACUS.develop/source/src_lcao/force_lcao_gamma.h @@ -49,7 +49,6 @@ class Force_LCAO_gamma void cal_fvnl_dbeta(const std::vector &dm2d); void cal_fvl_dphi(const std::vector &dm2d); - void DerivS_PW (void); void DerivT_PW (void); void average_force(double* fm); diff --git a/ABACUS.develop/source/src_lcao/force_lcao_k.cpp b/ABACUS.develop/source/src_lcao/force_lcao_k.cpp index a69afcdea5..40e0b1f58e 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao_k.cpp +++ b/ABACUS.develop/source/src_lcao/force_lcao_k.cpp @@ -142,7 +142,7 @@ void Force_LCAO_k::allocate_k(void) //----------------------------- // tips: build_ST_new --> ParaO.set_force bool cal_deri = true; - UHM.UOM.build_ST_new ('S', cal_deri); + UHM.genH.build_ST_new ('S', cal_deri); //----------------------------------------- // (2) allocate for @@ -157,11 +157,11 @@ void Force_LCAO_k::allocate_k(void) // calculate dT= in LCAO // calculate T + VNL(P1) in LCAO basis - UHM.UOM.build_ST_new ('T', cal_deri); + UHM.genH.build_ST_new ('T', cal_deri); //test(LM.DHloc_fixedR_x,"LM.DHloc_fixedR_x T part"); // calculate dVnl= in LCAO - UHM.UOM.build_Nonlocal_mu (cal_deri); + UHM.genH.build_Nonlocal_mu (cal_deri); //test(LM.DHloc_fixedR_x,"LM.DHloc_fixedR_x Vnl part"); timer::tick("Force_LCAO_k","allocate"); diff --git a/ABACUS.develop/source/src_lcao/mulliken_charge.cpp b/ABACUS.develop/source/src_lcao/mulliken_charge.cpp index d93365f3ad..e2feb43261 100644 --- a/ABACUS.develop/source/src_lcao/mulliken_charge.cpp +++ b/ABACUS.develop/source/src_lcao/mulliken_charge.cpp @@ -172,8 +172,8 @@ void Mulliken_Charge::cal_mulliken(void) hm.orb_con.set_orb_tables(); LM.allocate_HS_R(LNNR.nnr); LM.zeros_HSR('S', LNNR.nnr); - UHM.UOM.calculate_S_no(); - UHM.UOM.build_ST_new('S', false); + UHM.genH.calculate_S_no(); + UHM.genH.build_ST_new('S', false); for(int ik=0;ik Mulk; Mulk.resize(1); Mulk[0].create(ParaO.ncol,ParaO.nrow); From 34fe0c2cae530be3320df261b2597e9b3b3c1ee8 Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 12 Feb 2021 20:00:16 +0800 Subject: [PATCH 111/233] delete global variable test_hm, and BFIELD --- .../src_external/src_pdiag/pdiag_basic.cpp | 26 ++----- .../src_external/src_pdiag/pdiag_double.cpp | 76 +++++-------------- .../source/src_global/global_variable.cpp | 2 - .../source/src_global/global_variable.h | 1 - .../source/src_parallel/subgrid_oper.cpp | 19 +---- .../source/src_parallel/subgrid_oper.h | 1 - ABACUS.develop/source/src_pw/hamilt.cpp | 57 +------------- ABACUS.develop/source/src_pw/hamilt_pw.cpp | 30 ++++---- 8 files changed, 47 insertions(+), 165 deletions(-) diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.cpp b/ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.cpp index 5babadf655..1ba9a960ca 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.cpp +++ b/ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.cpp @@ -707,17 +707,10 @@ MPI_Barrier(comm); // when the third dimension is zero, we don't need to call // this function, however, as proc 0, it needs all the procssors // to give reports to it. - if(BFIELD) - { - cout << " not implement distri_lowf_aug yet." << endl; - WARNING_QUIT("Pdiag_Basic::gath_eig","not implement distri_lowf_aug yet for Bfield"); - } - else - { -// cout << " block distri_lowf_aug" << endl; - WF_Local::distri_lowf_aug( ctot, LOWF.WFC_GAMMA_aug[CURRENT_SPIN]); - } - + // cout << " block distri_lowf_aug" << endl; + // mohan update 2021-02-12, delte BFIELD option + WF_Local::distri_lowf_aug( ctot, LOWF.WFC_GAMMA_aug[CURRENT_SPIN]); + // clean staff. if(myid==0) { @@ -899,15 +892,8 @@ void Pdiag_Basic::gath_eig_complex(MPI_Comm comm,int n,complex **cc,comp // mohan add 2012-01-09 // // for complex - if(BFIELD) - { - ofs_running << " not augmented wave functions are implemented with B field" << endl; - //WF_Local::distri_lowf_aug_complex( ctot, LOWF.WFC_GAMMA_B_aug[ik]); - } - else - { - WF_Local::distri_lowf_aug_complex( ctot, LOWF.WFC_K_aug[ik]); //mohan add 2012-01-09 - } + // mohan update 2021-02-12, delete BFIELD option + WF_Local::distri_lowf_aug_complex( ctot, LOWF.WFC_K_aug[ik]); //mohan add 2012-01-09 // clean staff. diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp b/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp index 3d2f417400..92015b0f41 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp +++ b/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp @@ -586,21 +586,11 @@ void Pdiag_Double::diago_double_begin(const int &ik, double **wfc, matrix &wfc_2 } Memory::record("Pdiag_Basic","ctot",NBANDS*NLOCAL,"double"); } - if(BFIELD) - { - cout << " not implement distri_lowf_aug yet." << endl; - WARNING_QUIT("Pdiag_Basic::gath_eig","not implement distri_lowf_aug yet for Bfield"); - info=q2ZLOC_WFC_CTOT(myid, pos, naroc, nb, - dim0, dim1, iprow, ipcol, this->loc_size, - work, Z_LOC[ik], wfc, ctot); - } - else - { - info=q2ZLOC_WFC_WFCAUG_CTOT(myid, pos, naroc, nb, - dim0, dim1, iprow, ipcol, this->loc_size, - work, Z_LOC[ik], wfc, LOWF.WFC_GAMMA_aug[CURRENT_SPIN], ctot); - } - stringstream ss; + // mohan delete Bfield option 2021-02-12 + info=q2ZLOC_WFC_WFCAUG_CTOT(myid, pos, naroc, nb, + dim0, dim1, iprow, ipcol, this->loc_size, + work, Z_LOC[ik], wfc, LOWF.WFC_GAMMA_aug[CURRENT_SPIN], ctot); + stringstream ss; ss << global_out_dir << "LOWF_GAMMA_S" << CURRENT_SPIN+1 << ".dat"; // mohan add 2012-04-03, because we need the occupations for the // first iteration. @@ -616,21 +606,11 @@ void Pdiag_Double::diago_double_begin(const int &ik, double **wfc, matrix &wfc_2 } else { - if(BFIELD) - { - cout << " not implement distri_lowf_aug yet." << endl; - WARNING_QUIT("Pdiag_Basic::gath_eig","not implement distri_lowf_aug yet for Bfield"); - info=q2ZLOC_WFC(pos, naroc, nb, - dim0, dim1, iprow, ipcol, this->loc_size, - work, Z_LOC[ik], wfc); - } - else - { - info=q2ZLOC_WFC_WFCAUG(pos, naroc, nb, - dim0, dim1, iprow, ipcol, this->loc_size, - work, Z_LOC[ik], wfc, LOWF.WFC_GAMMA_aug[CURRENT_SPIN]); - } - } + // mohan update 2021-02-12, delete Bfield option + info=q2ZLOC_WFC_WFCAUG(pos, naroc, nb, + dim0, dim1, iprow, ipcol, this->loc_size, + work, Z_LOC[ik], wfc, LOWF.WFC_GAMMA_aug[CURRENT_SPIN]); + } } } } @@ -943,19 +923,10 @@ void Pdiag_Double::diago_complex_begin(const int &ik, complex **wfc, Com } Memory::record("Pdiag_Basic","ctot",NBANDS*NLOCAL,"cdouble"); } - if(BFIELD) - { - ofs_running << " not augmented wave functions are implemented with B field" << endl; - info=q2WFC_CTOT_complex(myid, naroc, nb, - dim0, dim1, iprow, ipcol, - work, wfc, ctot); - } - else - { - info=q2WFC_WFCAUG_CTOT_complex(myid, naroc, nb, - dim0, dim1, iprow, ipcol, - work, wfc, LOWF.WFC_K_aug[ik], ctot); - } + // mohan update 2021-02-12, delete BFIELD option + info=q2WFC_WFCAUG_CTOT_complex(myid, naroc, nb, + dim0, dim1, iprow, ipcol, + work, wfc, LOWF.WFC_K_aug[ik], ctot); stringstream ss; ss << global_out_dir << "LOWF_K_" << ik+1 << ".dat"; // mohan add 2012-04-03, because we need the occupations for the @@ -972,20 +943,11 @@ void Pdiag_Double::diago_complex_begin(const int &ik, complex **wfc, Com } else { - if(BFIELD) - { - ofs_running << " not augmented wave functions are implemented with B field" << endl; - info=q2WFC_complex(naroc, nb, - dim0, dim1, iprow, ipcol, - work, wfc); - } - else - { - info=q2WFC_WFCAUG_complex(naroc, nb, - dim0, dim1, iprow, ipcol, - work, wfc, LOWF.WFC_K_aug[ik]); - } - } + // mohan update 2021-02-12, delte BFIELD option + info=q2WFC_WFCAUG_complex(naroc, nb, + dim0, dim1, iprow, ipcol, + work, wfc, LOWF.WFC_K_aug[ik]); + } } } delete[] work; diff --git a/ABACUS.develop/source/src_global/global_variable.cpp b/ABACUS.develop/source/src_global/global_variable.cpp index fc8aa2a59a..5a542370e6 100644 --- a/ABACUS.develop/source/src_global/global_variable.cpp +++ b/ABACUS.develop/source/src_global/global_variable.cpp @@ -25,7 +25,6 @@ string CALCULATION = "scf"; bool BERRY_PHASE = false; bool LDA_PLUS_U = false; int EFIELD = 0; // 5: add electric field -int BFIELD = 0; // 6: add magnetic field int DIPOLE = 0; // 7: add dipole field string DFT_FUNCTIONAL = "none"; @@ -150,7 +149,6 @@ int test_symmetry = 0; int test_fft = 0; int test_pw = 0; int test_elec = 0; -int test_hm = 0; int test_wf = 0; int test_charge = 0; diff --git a/ABACUS.develop/source/src_global/global_variable.h b/ABACUS.develop/source/src_global/global_variable.h index 8e77f84123..0de0756434 100644 --- a/ABACUS.develop/source/src_global/global_variable.h +++ b/ABACUS.develop/source/src_global/global_variable.h @@ -178,7 +178,6 @@ extern int test_symmetry; extern int test_fft; extern int test_pw; extern int test_elec; -extern int test_hm; extern int test_wf; extern int test_charge; diff --git a/ABACUS.develop/source/src_parallel/subgrid_oper.cpp b/ABACUS.develop/source/src_parallel/subgrid_oper.cpp index a889f527b4..93aa3a8497 100644 --- a/ABACUS.develop/source/src_parallel/subgrid_oper.cpp +++ b/ABACUS.develop/source/src_parallel/subgrid_oper.cpp @@ -180,22 +180,11 @@ void SubGrid_oper::cal_totwfc() // need to allocate the pointer, // because it would be some array's // entrance parameters. - if(!BFIELD) + // mohan update 2021-02-12 + this->totwfc = new double**[1]; + for(int is=0; is<1; ++is) { - this->totwfc = new double**[1]; - for(int is=0; is<1; ++is) - { - this->totwfc[is] = new double*[NBANDS]; - } - } - // for B field. - else - { - this->totwfc_B = new complex**[1]; - for(int is=0; is<1; ++is) - { - this->totwfc_B[is] = new complex*[NBANDS]; - } + this->totwfc[is] = new double*[NBANDS]; } this->allocate_totwfc=false; return; diff --git a/ABACUS.develop/source/src_parallel/subgrid_oper.h b/ABACUS.develop/source/src_parallel/subgrid_oper.h index 43a2de921f..667ca6a4e5 100644 --- a/ABACUS.develop/source/src_parallel/subgrid_oper.h +++ b/ABACUS.develop/source/src_parallel/subgrid_oper.h @@ -28,7 +28,6 @@ class SubGrid_oper int* trace_lo_tot; double*** totwfc; - complex*** totwfc_B;//mohan add 2012-04-13 bool allocate_totwfc; int lgd; diff --git a/ABACUS.develop/source/src_pw/hamilt.cpp b/ABACUS.develop/source/src_pw/hamilt.cpp index d77acca576..15101cf7e3 100644 --- a/ABACUS.develop/source/src_pw/hamilt.cpp +++ b/ABACUS.develop/source/src_pw/hamilt.cpp @@ -13,7 +13,7 @@ Hamilt::~Hamilt() void Hamilt::init(const bool use_pw) { - if (test_hm)TITLE("Hamilt","init"); + TITLE("Hamilt","init"); // ofs_running << " use_pw=" << use_pw << endl; if (use_pw) { @@ -363,7 +363,7 @@ void Hamilt::cdiaghg( double *e, ComplexMatrix &hvec) { - if (test_hm==1) TITLE("Hamilt","cdiaghg"); + TITLE("Hamilt","cdiaghg"); timer::tick("Hamilt","cdiaghg"); //==================================================================== // calculates eigenvalues and eigenvectors of the generalized problem @@ -511,56 +511,3 @@ void Hamilt::cdiaghg( timer::tick("Hamilt","cdiaghg"); return; } - -//#include "../src_develop/src_cg/hpsi_ao.h" -//void Hamilt::h_1psi_real( const int dim, const double* psi, double* hpsi, double* spsi) -//{ -//#ifdef __FP -// /* -// for(int i=0; i 2) - { +/* cout << setprecision(3); out.printV3(ofs_running,kv.kvec_c[ik]); out.printcm_norm("sc",sc,1.0e-4); out.printcm_norm("hvec",hvec,1.0e-4); out.printcm_norm("hc",hc,1.0e-4); cout << endl; - } +*/ + // cout << " ----------------------------- ik=" << ik << endl; // out.printV3( kv.kvec_c[ik] ); // cout << " cinitcgg" << endl; @@ -375,6 +375,7 @@ void Hamilt_PW::cinitcgg( return; } //end subroutine cinitcgg + void Hamilt_PW::h_1psi( const int npw_in, const complex < double> *psi, complex *hpsi, complex < double> *spsi) { @@ -387,6 +388,7 @@ void Hamilt_PW::h_1psi( const int npw_in, const complex < double> *psi, return; } + void Hamilt_PW::s_1psi ( const int dim, @@ -538,16 +540,16 @@ void Hamilt_PW::add_vuspsi(complex *hpsi_in,const complex *becp) { for (int ip2=0; ip2Ps[sum+ip2] += ppcell.deeq(CURRENT_SPIN, iat, ip, ip2) * becp[sum+ip]; - else - { - this->Ps[sum+ ip2*2] += ppcell.deeq_nc(0, iat, ip2, ip) * becp[sum+ip*2] + if(NSPIN!=4) + this->Ps[sum+ip2] += ppcell.deeq(CURRENT_SPIN, iat, ip, ip2) * becp[sum+ip]; + else + { + this->Ps[sum+ ip2*2] += ppcell.deeq_nc(0, iat, ip2, ip) * becp[sum+ip*2] +ppcell.deeq_nc(1, iat, ip2, ip) * becp[sum+ip*2+1]; - this->Ps[sum+ ip2*2+1] += ppcell.deeq_nc(2, iat, ip2, ip) * becp[sum+ip*2] + this->Ps[sum+ ip2*2+1] += ppcell.deeq_nc(2, iat, ip2, ip) * becp[sum+ip*2] +ppcell.deeq_nc(3, iat, ip2, ip) * becp[sum+ip*2+1]; - } - }// end ih + } + }// end ih }//end jh if(NSPIN!=4) sum += Nprojs; else sum += 2 * Nprojs; From d2d836b1db846b70cf1eb4d432197ec102a864ca Mon Sep 17 00:00:00 2001 From: mohan Date: Sat, 13 Feb 2021 19:25:35 +0800 Subject: [PATCH 112/233] add some comments to ORB_ files --- ABACUS.develop/source/src_lcao/ORB_atomic_lm.h | 10 ++++++---- ABACUS.develop/source/src_lcao/ORB_nonlocal_lm.h | 7 ++++--- ABACUS.develop/source/src_lcao/ORB_radial_table.h | 5 +++-- ABACUS.develop/source/src_lcao/ORB_read.cpp | 4 ++-- ABACUS.develop/source/src_lcao/ORB_read.h | 7 +++++++ 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/ORB_atomic_lm.h b/ABACUS.develop/source/src_lcao/ORB_atomic_lm.h index 4374ac5950..cc1388aab8 100644 --- a/ABACUS.develop/source/src_lcao/ORB_atomic_lm.h +++ b/ABACUS.develop/source/src_lcao/ORB_atomic_lm.h @@ -22,7 +22,8 @@ class Numerical_Orbital_Lm { friend class Numerical_Orbital; -public: + public: + vector psi_uniform;// mohan add 2009-5-10 vector dpsi_uniform; //liaochen add 2010/5/11 @@ -30,8 +31,6 @@ class Numerical_Orbital_Lm double dr_uniform;// mohan add 2009-5-10 double zty; // the valus of psi at 0. -public: - Numerical_Orbital_Lm(); ~Numerical_Orbital_Lm(); @@ -39,7 +38,9 @@ class Numerical_Orbital_Lm // EXPLAIN : set information about Numerical_Orbital_Lm // MEMBER FUNCTION : //========================================================== - enum class Psi_Type{ Psi, Psif, Psik, Psik2 }; // Peize Lin add 2017-12-12 + // Peize Lin add 2017-12-12 + enum class Psi_Type{ Psi, Psif, Psik, Psik2 }; + void set_orbital_info ( const string &label_in, @@ -77,6 +78,7 @@ class Numerical_Orbital_Lm const int &nk_in, const double &dk_in, const double &dr_uniform_in); + void cal_kradial(void); void cal_kradial_sbpool(void); void cal_rradial_sbpool(void); diff --git a/ABACUS.develop/source/src_lcao/ORB_nonlocal_lm.h b/ABACUS.develop/source/src_lcao/ORB_nonlocal_lm.h index 5718d0a43a..4f3eaf42f5 100644 --- a/ABACUS.develop/source/src_lcao/ORB_nonlocal_lm.h +++ b/ABACUS.develop/source/src_lcao/ORB_nonlocal_lm.h @@ -15,13 +15,14 @@ class Numerical_Nonlocal_Lm { -public: + public: + double* beta_uniform; double* dbeta_uniform; int nr_uniform; double dr_uniform; -public: + public: Numerical_Nonlocal_Lm(); ~Numerical_Nonlocal_Lm(); @@ -57,7 +58,7 @@ class Numerical_Nonlocal_Lm void plot()const; -private: + private: void freemem(void); void renew(void); diff --git a/ABACUS.develop/source/src_lcao/ORB_radial_table.h b/ABACUS.develop/source/src_lcao/ORB_radial_table.h index 6bb5143040..585537a99d 100644 --- a/ABACUS.develop/source/src_lcao/ORB_radial_table.h +++ b/ABACUS.develop/source/src_lcao/ORB_radial_table.h @@ -59,13 +59,13 @@ class Make_Overlap_Table void init_Lmax (const int orb_num, const int mode, int &Lmax_used, int &Lmax) const; void init_Table_Spherical_Bessel (const int orb_num, const int mode, int &Lmax_used, int &Lmax); - Sph_Bessel_Recursive::D2* pSB = nullptr; // Peize Lin add 2017-04-24, and change all jlx in this class + // Peize Lin add 2017-04-24, and change all jlx in this class + Sph_Bessel_Recursive::D2* pSB = nullptr; //============================================== // make the index, in order to get the element // from Table_SR and Table_TR quickly. //============================================== - //------------------------- // OV stands for 'overlap' @@ -109,6 +109,7 @@ class Make_Overlap_Table const int &rmesh, double *rs, double *drs) const; + // Peize Lin add 2017-10-13 void cal_ST_Phi12_R( const int &job, diff --git a/ABACUS.develop/source/src_lcao/ORB_read.cpp b/ABACUS.develop/source/src_lcao/ORB_read.cpp index a2390d80b8..a6cb043ee9 100644 --- a/ABACUS.develop/source/src_lcao/ORB_read.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_read.cpp @@ -639,7 +639,7 @@ void LCAO_Orbitals::Read_PAO(const int& it) TITLE("LCAO_Orbitals","Read_PAO"); int lmaxt = ucell.atoms[it].nwl; -// OUT(ofs_running,"Lmax for this type",lmaxt); + // OUT(ofs_running,"Lmax for this type",lmaxt); // allocate space // number of chi for each L. @@ -656,7 +656,7 @@ void LCAO_Orbitals::Read_PAO(const int& it) { total_nchi += nchi[l]; } -// OUT(ofs_running,"Total number of chi(l,n)",total_nchi); + // OUT(ofs_running,"Total number of chi(l,n)",total_nchi); delete[] Phi[it].phiLN; this->Phi[it].phiLN = new Numerical_Orbital_Lm[total_nchi]; diff --git a/ABACUS.develop/source/src_lcao/ORB_read.h b/ABACUS.develop/source/src_lcao/ORB_read.h index d2ebd53f24..d987565b11 100644 --- a/ABACUS.develop/source/src_lcao/ORB_read.h +++ b/ABACUS.develop/source/src_lcao/ORB_read.h @@ -11,6 +11,13 @@ #include "ORB_atomic_lm.h" #include "ORB_nonlocal.h" +//--------------------------------------------------------------------- +// advices for reconstructions: +// each set of orbitals should have: lmax, dr, dk, rmax, lmax, etc. +// the orbitals include : NAO, non-local projectors, descriptors, etc. +// mohan note 2021-02-13 +//--------------------------------------------------------------------- + class LCAO_Orbitals { public: From c03aa6a063444bc2f7e2aae3bb987e9f3a12d2e5 Mon Sep 17 00:00:00 2001 From: mohan Date: Sat, 13 Feb 2021 19:30:16 +0800 Subject: [PATCH 113/233] delete a few mlwf-related useless parameters --- ABACUS.develop/source/input_conv.cpp | 3 --- .../source/src_global/global_variable.cpp | 14 +------------- ABACUS.develop/source/src_global/global_variable.h | 7 ++----- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index 369ae8b8c8..f86b24a1a7 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -137,9 +137,6 @@ void Input_Conv::Convert(void) // new function (5/5) //---------------------------------------------------------- SYMMETRY = INPUT.symmetry; // 9 - MLWF_FLAG = INPUT.mlwf_flag; // 9.1 - //LOCAL_BASIS = INPUT.local_basis; xiaohui modify 2013-09-01 // 10 - //LINEAR_SCALING = INPUT.linear_scaling; xiaohui modify 2013-09-01 // 11 BASIS_TYPE = INPUT.basis_type; //xiaohui add 2013-09-01 KS_SOLVER = INPUT.ks_solver; //xiaohui add 2013-09-01 SEARCH_RADIUS = INPUT.search_radius; // 11.1 diff --git a/ABACUS.develop/source/src_global/global_variable.cpp b/ABACUS.develop/source/src_global/global_variable.cpp index 5a542370e6..486ab7a31d 100644 --- a/ABACUS.develop/source/src_global/global_variable.cpp +++ b/ABACUS.develop/source/src_global/global_variable.cpp @@ -44,9 +44,6 @@ int NSTEP = 20; int NITER = 50; bool SYMMETRY = false; -bool MLWF_FLAG = false; -//int LOCAL_BASIS = 0; xiaohui modify 2013-09-01 // 0: plane wave; 1:radial wave functions; 2: PAO; 3: Jlq coef; -//int LINEAR_SCALING = false; xiaohui modify 2013-09-01 string BASIS_TYPE = "pw"; //xiaohui add 2013-09-01 string KS_SOLVER = "cg"; //xiaohui add 2013-09-01 double SEARCH_RADIUS = -1.0; @@ -54,7 +51,6 @@ bool SEARCH_PBC = true; bool SPARSE_MATRIX = false; int ATOM_DISTRIBUTION = false; -//string DIAGO_TYPE = "cg"; xiaohui modify 2013-09-01 int DIAGO_PROC = 0; int DIAGO_CG_MAXITER = 30; int DIAGO_CG_PREC = 1; //mohan add 2012-03-31 @@ -179,20 +175,12 @@ int test_sph_proj = 0; int test_build = 0; int test_setout = 0; //---------------------------------------------------------- -// src_epm || src_pseudo +// src_pseudo //---------------------------------------------------------- -#ifdef __EPM -int test_epm = 10; -int test_epm_unitcell = 10; -int test_epm_nscf = 10; -#else int test_pseudo_cell = 0;// 2 : output readin data int test_pp = 0;// pp: pseudopotential int test_kmesh = 0; -int test_mlwf_overlap = 0; -int test_mlwf_optimize = 0; int test_ion_dynamics = 0; -#endif //---------------------------------------------------------- // src_tools //---------------------------------------------------------- diff --git a/ABACUS.develop/source/src_global/global_variable.h b/ABACUS.develop/source/src_global/global_variable.h index 0de0756434..89e2607986 100644 --- a/ABACUS.develop/source/src_global/global_variable.h +++ b/ABACUS.develop/source/src_global/global_variable.h @@ -48,11 +48,8 @@ extern int NSTEP; // 8.3 extern int NITER; // 8.4 extern bool SYMMETRY; // 9 -extern bool MLWF_FLAG; // 9.1 mohan add 2010-01-26 -//extern int LOCAL_BASIS; xiaohui modify 2013-09-01 // 10 -//extern int LINEAR_SCALING; xiaohui modify 2013-09-01 // 11 // -1: test 0: pw 1:lcao 2:O(N) -extern string BASIS_TYPE; //xiaohui add 2013-09-01 -extern string KS_SOLVER; //xiaohui add 2013-09-01 +extern string BASIS_TYPE; //xiaohui add 2013-09-01 +extern string KS_SOLVER; //xiaohui add 2013-09-01 extern double SEARCH_RADIUS; // 11.1 // mohan add 2011-03-10 extern bool SEARCH_PBC; // 11.2 // mohan add 2011-03-10 extern bool SPARSE_MATRIX; // 11.3 // mohan add 2009-03-13 From 2b18d34aef67b42c33978ac86d7a0a5b050cd489 Mon Sep 17 00:00:00 2001 From: mohan Date: Sat, 13 Feb 2021 20:25:13 +0800 Subject: [PATCH 114/233] move perform_dos from energy.cpp to energy_dos.cpp --- ABACUS.develop/source/Makefile.Objects | 1 + ABACUS.develop/source/src_pw/diago_david.cpp | 4 +- ABACUS.develop/source/src_pw/energy.cpp | 781 +------------------ ABACUS.develop/source/src_pw/energy.h | 6 +- ABACUS.develop/source/src_pw/energy_dos.cpp | 752 ++++++++++++++++++ ABACUS.develop/source/src_pw/hamilt.h | 5 +- 6 files changed, 797 insertions(+), 752 deletions(-) create mode 100644 ABACUS.develop/source/src_pw/energy_dos.cpp diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 99f8b6e227..dc0b7c1bd8 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -248,6 +248,7 @@ output.o \ dos.o \ inverse_matrix.o \ energy.o \ +energy_dos.o\ wavefunc.o\ wf_io.o \ rwstream.o\ diff --git a/ABACUS.develop/source/src_pw/diago_david.cpp b/ABACUS.develop/source/src_pw/diago_david.cpp index a61a781e6f..5096095038 100644 --- a/ABACUS.develop/source/src_pw/diago_david.cpp +++ b/ABACUS.develop/source/src_pw/diago_david.cpp @@ -11,9 +11,11 @@ Diago_David::Diago_David() // default: no check } -Diago_David::~Diago_David() { +Diago_David::~Diago_David() +{ } + void Diago_David::diag ( ComplexMatrix &psi, diff --git a/ABACUS.develop/source/src_pw/energy.cpp b/ABACUS.develop/source/src_pw/energy.cpp index 11b54af910..72e85c3ede 100644 --- a/ABACUS.develop/source/src_pw/energy.cpp +++ b/ABACUS.develop/source/src_pw/energy.cpp @@ -8,25 +8,11 @@ #include "energy.h" #include "algorithms.h" #include "mymath.h" -#include "../src_lcao/mulliken_charge.h" -#include "../src_lcao/LCAO_nnr.h" -#include "../src_lcao/LCAO_gen_fixedH.h" -#include "../src_global/sltk_atom_arrange.h"//qifeng-2019-01-21 -#include "../src_lcao/local_orbital_charge.h" -#include "../src_pw/global.h" -#include "../src_pw/wavefunc.h" -#include "../src_lcao/LCAO_matrix.h" -#include "../src_lcao/dftu.h" //Quxin adds for DFT+U on 20201029 -#include "../src_lcao/global_fp.h" -#include "../src_lcao/wfc_dm_2d.h" -#include "../src_global/lapack_connector.h" -#include "../src_global/scalapack_connector.h" -#include "../src_global/matrix.h" -#include "../src_global/complexmatrix.h" #include #include #include #include "../src_pw/tools.h" +#include "../src_lcao/dftu.h" //Quxin adds for DFT+U on 20201029 int energy::mxr = 50; energy::energy() @@ -69,7 +55,10 @@ void energy::calculate_harris(const int &flag) this->etot_harris = eband + deband_harris + (etxc - etxcc) + ewld + ehart + demet + exx + Efield::etotefield; - if(INPUT.dft_plus_u) this->etot_harris += dftu.EU; //Energy correction from DFT+U; Quxin adds on 20201029 + if(INPUT.dft_plus_u) + { + this->etot_harris += dftu.EU; //Energy correction from DFT+U; Quxin adds on 20201029 + } } return; @@ -82,17 +71,22 @@ void energy::calculate_etot(void) this->etot = eband + deband + (etxc - etxcc) + ewld + ehart + demet + descf + exx + Efield::etotefield; - if(vdwd2.vdwD2) //Peize Lin add 2014-04-03, update 2019-04-26 + // Peize Lin add 2014-04-03, update 2019-04-26 + if(vdwd2.vdwD2) { this->etot += vdwd2.energy_result; } - if(vdwd3.vdwD3) //jiyy add 2019-05-18 + // jiyy add 2019-05-18 + else if(vdwd3.vdwD3) { this->etot += vdwd3.energy_result; } //Quxin adds for DFT+U energy correction on 20201029 - if(INPUT.dft_plus_u) this->etot += dftu.EU; + if(INPUT.dft_plus_u) + { + this->etot += dftu.EU; + } /* cout << resetiosflags(ios::scientific) << endl; @@ -285,7 +279,9 @@ bool print) else if(NSPIN==4 && NONCOLIN) { cout << setprecision(2); - cout<1.0) @@ -844,734 +840,6 @@ void energy::delta_escf(void) return; } -void energy::perform_dos(void) -{ - TITLE("energy","perform_dos"); - - - if(out_dos !=0 || out_band !=0) - { - ofs_running << "\n\n\n\n"; - ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl; - ofs_running << " | |" << endl; - ofs_running << " | Post-processing of data: |" << endl; - ofs_running << " | DOS (density of states) and bands will be output here. |" << endl; - ofs_running << " | If atomic orbitals are used, Mulliken charge analysis can be done. |" << endl; - ofs_running << " | Also the .bxsf file containing fermi surface information can be |" << endl; - ofs_running << " | done here. |" << endl; - ofs_running << " | |" << endl; - ofs_running << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << endl; - ofs_running << "\n\n\n\n"; - } - - - if(MY_RANK==0) - { - if(CALCULATION=="scf" || CALCULATION=="md" || CALCULATION=="relax") - { - stringstream ss; - ss << global_out_dir << "istate.info" ; - ofstream ofsi( ss.str().c_str() ); - /*for(int ib=0; ibout_dos) - { - // find the maximal and minimal band energy. - double emax = wf.ekb[0][0]; - double emin = wf.ekb[0][0]; - for(int ik=0; ikdos_edelta_ev; - - - const int npoints = static_cast(std::floor ( ( emax - emin ) / de_ev )); - - int NUM=NLOCAL*npoints; - - Wfc_Dm_2d D; - D.init(); - if(GAMMA_ONLY_LOCAL) - { - for(int in=0;in*waveg = new complex[NLOCAL]; - - double*Gauss = new double[np]; - - for(int is=0; is Mulk; - Mulk.resize(1); - Mulk[0].create(ParaO.ncol,ParaO.nrow); - - - matrix Dwf = D.wfc_gamma[is]; - for (int i=0; i Mulk; - Mulk.resize(1); - Mulk[0].create(ParaO.ncol,ParaO.nrow); - - - for(int ik=0;ik" <" << NSPIN<< "<"<<"/"<<"nspin"<<">"<< endl; - out << "<"<<"norbitals"<<">" <"<< endl; - out << "<"<<"energy"<<"_"<<"values units"<<"="<<"\""<<"eV"<<"\""<<">"<" <nw; ++j) - { - const int L1 = atom1->iw2l[j]; - const int N1 = atom1->iw2n[j]; - const int m1 = atom1->iw2m[j]; - const int w = ucell.itiaiw2iwt(t, a, j); - - //out << "<"<<"/"<<"energy"<<"_"<<"values"<<">" <" <" <" <" <" <nw; ++j) - { - const int L1 = atom1->iw2l[j]; - const int N1 = atom1->iw2n[j]; - const int m1 = atom1->iw2m[j]; - out <dos_edelta_ev, - emax, - emin, - kv.nks, kv.nkstot, kv.wk, wf.wg, NBANDS, wf.ekb ); - ifstream in(ss.str().c_str()); - if(!in) - { - // cout<<"\n Can't find file : "<< name << endl; - // return 0; - } - - //---------------------------------------------------------- - // FOUND LOCAL VARIABLES : - // NAME : number(number of DOS points) - // NAME : nk(number of k point used) - // NAME : energy(energy range,from emin_ev to emax_ev) - // NAME : dos(old,count k points in the energy range) - // NAME : dos2(new,count k points in the energy range) - //---------------------------------------------------------- - int number=0; - int nk=0; - in >> number; - in >> nk; - double *energy = new double[number]; - double *dos = new double[number]; - double *dos2 = new double[number]; - for(int i=0 ;i> energy[i] >> dos[i]; - } - if(!in.eof()) - { - //cout<<"\n Read Over!"<ef << " Rydberg" << endl; - } - else if(nspin0==2) - { - ofs_running << " Fermi energy (spin = 1) is " << this->ef_up << " Rydberg" << endl; - ofs_running << " Fermi energy (spin = 2) is " << this->ef_dw << " Rydberg" << endl; - } - - //int nks; - //if(nspin0==1) nks = kv.nkstot; - //else if(nspin0==2) nks = kv.nkstot/2; - - - - /*for(int is=0; isef, wf.ekb); - }*/ - - if(out_dos==3) - { - for(int i=0; iout_band) //pengfei 2014-10-13 - { - - int nks; - if(nspin0==1) nks = kv.nkstot; - else if(nspin0==2) nks = kv.nkstot/2; - - - - for(int is=0; isef*0, wf.ekb); - } - - } - return; -} - void energy::print_band(const int &ik) { @@ -1625,19 +893,36 @@ void energy::print_band(const int &ik) // Peize Lin add 2016-12-03 void energy::set_exx() { + TITLE("energy", "set_exx"); + auto exx_energy = []() -> double { if("lcao_in_pw"==BASIS_TYPE) + { return exx_lip.get_exx_energy(); + } else if("lcao"==BASIS_TYPE) + { return exx_lcao.get_energy(); + } else + { throw invalid_argument(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + } }; + if( 5==xcf.iexch_now && 0==xcf.igcx_now ) // HF + { this->exx = exx_energy(); + } else if( 6==xcf.iexch_now && 8==xcf.igcx_now ) // PBE0 + { this->exx = exx_global.info.hybrid_alpha * exx_energy(); + } else if( 9==xcf.iexch_now && 12==xcf.igcx_now ) // HSE + { this->exx = exx_global.info.hybrid_alpha * exx_energy(); + } + + return; } diff --git a/ABACUS.develop/source/src_pw/energy.h b/ABACUS.develop/source/src_pw/energy.h index 987bb78993..d30fd30bb6 100644 --- a/ABACUS.develop/source/src_pw/energy.h +++ b/ABACUS.develop/source/src_pw/energy.h @@ -25,6 +25,7 @@ class energy friend class Force_Lo; friend class Exx_pw; friend class ON_Tests; + energy(); ~energy(); @@ -60,10 +61,11 @@ class energy int out_dos; // control dos calculation int out_band; // control band calculation pengfei 2014-10-13 - double dos_emin_ev; + + double dos_emin_ev; double dos_emax_ev; double dos_edelta_ev; - double bcoeff; + double bcoeff; double ewald(); diff --git a/ABACUS.develop/source/src_pw/energy_dos.cpp b/ABACUS.develop/source/src_pw/energy_dos.cpp new file mode 100644 index 0000000000..d760cbd6ed --- /dev/null +++ b/ABACUS.develop/source/src_pw/energy_dos.cpp @@ -0,0 +1,752 @@ +#include "tools.h" +#include "global.h" +#include "energy.h" +#include "algorithms.h" +#include "mymath.h" +#include "../src_lcao/mulliken_charge.h" +#include "../src_lcao/LCAO_nnr.h" +#include "../src_lcao/LCAO_gen_fixedH.h" +#include "../src_global/sltk_atom_arrange.h"//qifeng-2019-01-21 +#include "../src_lcao/local_orbital_charge.h" +#include "../src_pw/global.h" +#include "../src_pw/wavefunc.h" +#include "../src_lcao/LCAO_matrix.h" +#include "../src_lcao/global_fp.h" +#include "../src_lcao/wfc_dm_2d.h" +#include "../src_global/lapack_connector.h" +#include "../src_global/scalapack_connector.h" +#include "../src_global/matrix.h" +#include "../src_global/complexmatrix.h" +#include +#include +#include +#include "../src_pw/tools.h" + + +void energy::perform_dos(void) +{ + TITLE("energy","perform_dos"); + + + if(out_dos !=0 || out_band !=0) + { + ofs_running << "\n\n\n\n"; + ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl; + ofs_running << " | |" << endl; + ofs_running << " | Post-processing of data: |" << endl; + ofs_running << " | DOS (density of states) and bands will be output here. |" << endl; + ofs_running << " | If atomic orbitals are used, Mulliken charge analysis can be done. |" << endl; + ofs_running << " | Also the .bxsf file containing fermi surface information can be |" << endl; + ofs_running << " | done here. |" << endl; + ofs_running << " | |" << endl; + ofs_running << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << endl; + ofs_running << "\n\n\n\n"; + } + + + if(MY_RANK==0) + { + if(CALCULATION=="scf" || CALCULATION=="md" || CALCULATION=="relax") + { + stringstream ss; + ss << global_out_dir << "istate.info" ; + ofstream ofsi( ss.str().c_str() ); + /*for(int ib=0; ibout_dos) + { + // find the maximal and minimal band energy. + double emax = wf.ekb[0][0]; + double emin = wf.ekb[0][0]; + for(int ik=0; ikdos_edelta_ev; + + + const int npoints = static_cast(std::floor ( ( emax - emin ) / de_ev )); + + int NUM=NLOCAL*npoints; + + Wfc_Dm_2d D; + D.init(); + if(GAMMA_ONLY_LOCAL) + { + for(int in=0;in*waveg = new complex[NLOCAL]; + + double*Gauss = new double[np]; + + for(int is=0; is Mulk; + Mulk.resize(1); + Mulk[0].create(ParaO.ncol,ParaO.nrow); + + + matrix Dwf = D.wfc_gamma[is]; + for (int i=0; i Mulk; + Mulk.resize(1); + Mulk[0].create(ParaO.ncol,ParaO.nrow); + + + for(int ik=0;ik" <" << NSPIN<< "<"<<"/"<<"nspin"<<">"<< endl; + out << "<"<<"norbitals"<<">" <"<< endl; + out << "<"<<"energy"<<"_"<<"values units"<<"="<<"\""<<"eV"<<"\""<<">"<" <nw; ++j) + { + const int L1 = atom1->iw2l[j]; + const int N1 = atom1->iw2n[j]; + const int m1 = atom1->iw2m[j]; + const int w = ucell.itiaiw2iwt(t, a, j); + + //out << "<"<<"/"<<"energy"<<"_"<<"values"<<">" <" <" <" <" <" <nw; ++j) + { + const int L1 = atom1->iw2l[j]; + const int N1 = atom1->iw2n[j]; + const int m1 = atom1->iw2m[j]; + out <dos_edelta_ev, + emax, + emin, + kv.nks, kv.nkstot, kv.wk, wf.wg, NBANDS, wf.ekb ); + ifstream in(ss.str().c_str()); + if(!in) + { + // cout<<"\n Can't find file : "<< name << endl; + // return 0; + } + + //---------------------------------------------------------- + // FOUND LOCAL VARIABLES : + // NAME : number(number of DOS points) + // NAME : nk(number of k point used) + // NAME : energy(energy range,from emin_ev to emax_ev) + // NAME : dos(old,count k points in the energy range) + // NAME : dos2(new,count k points in the energy range) + //---------------------------------------------------------- + int number=0; + int nk=0; + in >> number; + in >> nk; + double *energy = new double[number]; + double *dos = new double[number]; + double *dos2 = new double[number]; + for(int i=0 ;i> energy[i] >> dos[i]; + } + if(!in.eof()) + { + //cout<<"\n Read Over!"<ef << " Rydberg" << endl; + } + else if(nspin0==2) + { + ofs_running << " Fermi energy (spin = 1) is " << this->ef_up << " Rydberg" << endl; + ofs_running << " Fermi energy (spin = 2) is " << this->ef_dw << " Rydberg" << endl; + } + + //int nks; + //if(nspin0==1) nks = kv.nkstot; + //else if(nspin0==2) nks = kv.nkstot/2; + + + + /*for(int is=0; isef, wf.ekb); + }*/ + + if(out_dos==3) + { + for(int i=0; iout_band) //pengfei 2014-10-13 + { + + int nks; + if(nspin0==1) nks = kv.nkstot; + else if(nspin0==2) nks = kv.nkstot/2; + + + + for(int is=0; isef*0, wf.ekb); + } + + } + return; +} diff --git a/ABACUS.develop/source/src_pw/hamilt.h b/ABACUS.develop/source/src_pw/hamilt.h index a358b0bfa4..1a084f24f0 100644 --- a/ABACUS.develop/source/src_pw/hamilt.h +++ b/ABACUS.develop/source/src_pw/hamilt.h @@ -7,7 +7,8 @@ class Hamilt { -public: + public: + Hamilt(); ~Hamilt(); @@ -16,7 +17,9 @@ class Hamilt void init_k(const int ik); void init_before_ions(void); + void init_before_electrons(void); + void clear_after_ions(void); void cinitcgg(const int ik, const int nstart,const int nbnd, From da53f0b69046df153879b12093bfbef0ec7fdbe7 Mon Sep 17 00:00:00 2001 From: mohan Date: Sun, 14 Feb 2021 21:23:45 +0800 Subject: [PATCH 115/233] add some comments in cal_r_overlap_R and center2_orb-orb11 --- .../source/src_lcao/cal_r_overlap_R.cpp | 63 ++++++++++++++----- .../source/src_lcao/cal_r_overlap_R.h | 16 +++-- .../source/src_lcao/center2_orb-orb11.cpp | 7 ++- .../source/src_lcao/center2_orb-orb11.h | 13 ++-- .../source/src_lcao/center2_orb-orb21.h | 12 +++- 5 files changed, 80 insertions(+), 31 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/cal_r_overlap_R.cpp b/ABACUS.develop/source/src_lcao/cal_r_overlap_R.cpp index 27b89cbcb3..5451668168 100644 --- a/ABACUS.develop/source/src_lcao/cal_r_overlap_R.cpp +++ b/ABACUS.develop/source/src_lcao/cal_r_overlap_R.cpp @@ -214,17 +214,23 @@ void cal_r_overlap_R::init() co6.second.init_radial_table(); + return; } void cal_r_overlap_R::out_r_overlap_R(const int nspin) { + TITLE("cal_r_overlap_R","out_r_overlap_R"); + timer::tick("cal_r_overlap_R","out_r_overlap_R"); + Vector3 tau1, tau2, dtau; Vector3 origin_point(0.0,0.0,0.0); int R_x; int R_y; int R_z; + + double factor = sqrt(FOUR_PI/3.0); for(int ix = 0; ix < R_x_num; ix++) { @@ -239,34 +245,53 @@ void cal_r_overlap_R::out_r_overlap_R(const int nspin) Vector3 R_car = Vector3(dRx,dRy,dRz) * ucell.latvec; int ir,ic; - for(int orb_index_in_NLOCAL_1 = 0; orb_index_in_NLOCAL_1 < NLOCAL; orb_index_in_NLOCAL_1++) + for(int iw1 = 0; iw1 < NLOCAL; iw1++) { - ir = ParaO.trace_loc_row[orb_index_in_NLOCAL_1]; + ir = ParaO.trace_loc_row[iw1]; if(ir >= 0) { - for(int orb_index_in_NLOCAL_2 = 0; orb_index_in_NLOCAL_2 < NLOCAL; orb_index_in_NLOCAL_2++) + for(int iw2 = 0; iw2 < NLOCAL; iw2++) { - ic = ParaO.trace_loc_col[orb_index_in_NLOCAL_2]; + ic = ParaO.trace_loc_col[iw2]; if(ic >= 0) { int icc = ir + ic * ParaO.nrow; - int orb_index_row = orb_index_in_NLOCAL_1 / NPOL; - int orb_index_col = orb_index_in_NLOCAL_2 / NPOL; + int orb_index_row = iw1 / NPOL; + int orb_index_col = iw2 / NPOL; // soc中éžå¯¹è§’é¡¹ä¸ºé›¶ï¼Œä¸¤ä¸ªå¯¹è§’é¡¹ç›¸åŒ - int new_index = orb_index_in_NLOCAL_1 - NPOL*orb_index_row + (orb_index_in_NLOCAL_2 - NPOL*orb_index_col)*NPOL; + int new_index = iw1 - NPOL*orb_index_row + + (iw2 - NPOL*orb_index_col)*NPOL; if(new_index == 0 || new_index == 3) { - int atomType1 = iw2it(orb_index_row); int ia1 = iw2ia(orb_index_row); int N1 = iw2iN(orb_index_row); int L1 = iw2iL(orb_index_row); int m1 = iw2im(orb_index_row); - int atomType2 = iw2it(orb_index_col); int ia2 = iw2ia(orb_index_col); int N2 = iw2iN(orb_index_col); int L2 = iw2iL(orb_index_col); int m2 = iw2im(orb_index_col); - Vector3 r_distance = ( ucell.atoms[atomType2].tau[ia2] - ucell.atoms[atomType1].tau[ia1] + R_car ) * ucell.lat0; - double overlap_o = center2_orb11[atomType1][atomType2][L1][N1][L2].at(N2).cal_overlap( origin_point, r_distance, m1, m2 ); - double overlap_x = -1 * sqrt(FOUR_PI/3.0) * center2_orb21_r[atomType1][atomType2][L1][N1][L2].at(N2).cal_overlap( origin_point, r_distance, m1, 1, m2 ); // m = 1 - double overlap_y = -1 * sqrt(FOUR_PI/3.0) * center2_orb21_r[atomType1][atomType2][L1][N1][L2].at(N2).cal_overlap( origin_point, r_distance, m1, 2, m2 ); // m = -1 - double overlap_z = sqrt(FOUR_PI/3.0) * center2_orb21_r[atomType1][atomType2][L1][N1][L2].at(N2).cal_overlap( origin_point, r_distance, m1, 0, m2 ); // m = 0 - psi_r_psi[ix][iy][iz][icc] = Vector3( overlap_x,overlap_y,overlap_z ) + ucell.atoms[atomType1].tau[ia1] * ucell.lat0 * overlap_o; + int it1 = iw2it(orb_index_row); + int ia1 = iw2ia(orb_index_row); + int N1 = iw2iN(orb_index_row); + int L1 = iw2iL(orb_index_row); + int m1 = iw2im(orb_index_row); + + int it2 = iw2it(orb_index_col); + int ia2 = iw2ia(orb_index_col); + int N2 = iw2iN(orb_index_col); + int L2 = iw2iL(orb_index_col); + int m2 = iw2im(orb_index_col); + + Vector3 r_distance = ( ucell.atoms[it2].tau[ia2] + - ucell.atoms[it1].tau[ia1] + R_car ) * ucell.lat0; + +double overlap_o = center2_orb11[it1][it2][L1][N1][L2].at(N2).cal_overlap( origin_point, r_distance, m1, m2 ); + double overlap_x = -1 * factor * +center2_orb21_r[it1][it2][L1][N1][L2].at(N2).cal_overlap( origin_point, r_distance, m1, 1, m2 ); // m = 1 + double overlap_y = -1 * factor * +center2_orb21_r[it1][it2][L1][N1][L2].at(N2).cal_overlap( origin_point, r_distance, m1, 2, m2 ); // m = -1 + double overlap_z = factor * +center2_orb21_r[it1][it2][L1][N1][L2].at(N2).cal_overlap( origin_point, r_distance, m1, 0, m2 ); // m = 0 + + psi_r_psi[ix][iy][iz][icc] = Vector3( overlap_x,overlap_y,overlap_z ) ++ ucell.atoms[it1].tau[ia1] * ucell.lat0 * overlap_o; + } else { @@ -339,7 +364,8 @@ void cal_r_overlap_R::out_r_overlap_R(const int nspin) { if(i==0 && j==0) { - out_r << dRx << " " << dRy << " " << dRz << " //R vector(R2 - R1,unit: lattice vector)" <>> orbital_phi; int R_x_num; @@ -56,11 +65,6 @@ class cal_r_overlap_R map>>>>> center2_orb21_r; - - - cal_r_overlap_R(); - ~cal_r_overlap_R(); - void init(); void out_r_overlap_R(const int nspin); diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb11.cpp b/ABACUS.develop/source/src_lcao/center2_orb-orb11.cpp index d849886bd9..098fee8536 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb11.cpp +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb11.cpp @@ -22,14 +22,16 @@ Center2_Orb::Orb11::Orb11( MGT(MGT_in) {} -void Center2_Orb::Orb11::init_radial_table() +void Center2_Orb::Orb11::init_radial_table(void) { const int LA = nA.getL(); const int LB = nB.getL(); for( int LAB = std::abs(LA-LB); LAB<=LA+LB; ++LAB) { if( (LAB-std::abs(LA-LB))%2==1 ) // if LA+LB-LAB == odd, then Gaunt_Coefficients = 0 + { continue; + } const int rmesh = MOT.get_rmesh(nA.getRcut(),nB.getRcut()) ; @@ -45,6 +47,7 @@ void Center2_Orb::Orb11::init_radial_table() VECTOR_TO_PTR(Table_r[LAB]), VECTOR_TO_PTR(Table_dr[LAB])); } + return; } void Center2_Orb::Orb11::init_radial_table( const set &radials ) @@ -146,4 +149,4 @@ double Center2_Orb::Orb11::cal_overlap( } return overlap; -} \ No newline at end of file +} diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb11.h b/ABACUS.develop/source/src_lcao/center2_orb-orb11.h index 4015a6388e..3ae4fab883 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb11.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb11.h @@ -22,19 +22,24 @@ using std::set; class Center2_Orb::Orb11 { -public: + public: + Orb11( const Numerical_Orbital_Lm &nA_in, const Numerical_Orbital_Lm &nB_in, const Make_Overlap_Table &MOT_in, const Make_Gaunt_Table &MGT_in ); - void init_radial_table(); + + void init_radial_table(void); + void init_radial_table( const set &radials ); // unit: Bohr/MOT.dr + double cal_overlap( const Vector3 &RA, const Vector3 &RB, // unit: Bohr const int &mA, const int &mB) const; -private: + private: + const Numerical_Orbital_Lm &nA; const Numerical_Orbital_Lm &nB; @@ -47,4 +52,4 @@ class Center2_Orb::Orb11 // this->Table_r[LAB][ir] -#endif // CENTER2_ORB_ORB11_H \ No newline at end of file +#endif // CENTER2_ORB_ORB11_H diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb21.h b/ABACUS.develop/source/src_lcao/center2_orb-orb21.h index 955599579e..451dbb3302 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb21.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb21.h @@ -23,20 +23,26 @@ using std::set; class Center2_Orb::Orb21 { -public: + + public: + Orb21( const Numerical_Orbital_Lm &nA1_in, const Numerical_Orbital_Lm &nA2_in, const Numerical_Orbital_Lm &nB_in, const Make_Overlap_Table &MOT_in, const Make_Gaunt_Table &MGT_in ); + void init_radial_table(); + void init_radial_table( const set &radials ); // unit: Bohr/MOT.dr + double cal_overlap( const Vector3 &RA, const Vector3 &RB, // unit: Bohr const int &mA1, const int &mA2, const int &mB ) const; -private: + private: + const Numerical_Orbital_Lm &nA1; const Numerical_Orbital_Lm &nA2; const Numerical_Orbital_Lm &nB; @@ -50,4 +56,4 @@ class Center2_Orb::Orb21 // this->orb11s[LA].Table_r[LAB][ir] -#endif // CENTER2_ORB_ORB21_H \ No newline at end of file +#endif // CENTER2_ORB_ORB21_H From c9a95edb9ec0c77cdac98eaf16e5afd7bfa267a4 Mon Sep 17 00:00:00 2001 From: mohan Date: Sun, 14 Feb 2021 21:37:24 +0800 Subject: [PATCH 116/233] delete occupy.h in global.h --- ABACUS.develop/source/input_conv.cpp | 2 ++ ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.cpp | 1 + ABACUS.develop/source/src_io/chi0_hilbert.cpp | 1 + ABACUS.develop/source/src_lcao/ELEC_scf.cpp | 1 + ABACUS.develop/source/src_pw/electrons.cpp | 1 + ABACUS.develop/source/src_pw/global.h | 1 - ABACUS.develop/source/src_pw/sto_elec.cpp | 1 + ABACUS.develop/source/src_pw/unitcell_pseudo.cpp | 1 + ABACUS.develop/source/src_pw/wavefunc.cpp | 1 + 9 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index f86b24a1a7..7a1d47952f 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -26,6 +26,8 @@ //#include "../src_develop/src_dc/dc_info.h" //#include "../../src_develop/src_md/md.h" +#include "src_pw/occupy.h" + void Input_Conv::Convert(void) { TITLE("Input_Conv","Convert"); diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.cpp b/ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.cpp index 1ba9a960ca..437576aae3 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.cpp +++ b/ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.cpp @@ -503,6 +503,7 @@ void Pdiag_Basic::data_distribution( #endif #ifdef __MPI +#include "src_pw/occupy.h" void Pdiag_Basic::gath_eig(MPI_Comm comm,int n,double **wfc,double *Z) { TITLE("Pdiag_Basic","gath_eig"); diff --git a/ABACUS.develop/source/src_io/chi0_hilbert.cpp b/ABACUS.develop/source/src_io/chi0_hilbert.cpp index ca9a78e919..8608f515e9 100644 --- a/ABACUS.develop/source/src_io/chi0_hilbert.cpp +++ b/ABACUS.develop/source/src_io/chi0_hilbert.cpp @@ -52,6 +52,7 @@ Chi0_hilbert::~Chi0_hilbert() } // begin calculate +#include "src_pw/occupy.h" void Chi0_hilbert::Chi() { TITLE("Chi0_hilbert","Chi"); diff --git a/ABACUS.develop/source/src_lcao/ELEC_scf.cpp b/ABACUS.develop/source/src_lcao/ELEC_scf.cpp index 50c9abd06c..8cc556eff9 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_scf.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_scf.cpp @@ -8,6 +8,7 @@ #include "ELEC_cbands_gamma.h" #include "ELEC_evolve.h" #include "input_update.h" +#include "src_pw/occupy.h" ELEC_scf::ELEC_scf(){} ELEC_scf::~ELEC_scf(){} diff --git a/ABACUS.develop/source/src_pw/electrons.cpp b/ABACUS.develop/source/src_pw/electrons.cpp index 42f941b14a..f7c8d27c27 100644 --- a/ABACUS.develop/source/src_pw/electrons.cpp +++ b/ABACUS.develop/source/src_pw/electrons.cpp @@ -82,6 +82,7 @@ void Electrons::non_self_consistent(const int &istep) } +#include "occupy.h" void Electrons::self_consistent(const int &istep) { timer::tick("Electrons","self_consistent",'D'); diff --git a/ABACUS.develop/source/src_pw/global.h b/ABACUS.develop/source/src_pw/global.h index 2e2f0dd5a4..b411107a99 100644 --- a/ABACUS.develop/source/src_pw/global.h +++ b/ABACUS.develop/source/src_pw/global.h @@ -11,7 +11,6 @@ #include "src_global/global_function.h" #include "pw_basis.h" #include "energy.h" -#include "occupy.h" #include "pseudopot_cell_vnl.h" #include "charge_broyden.h" #include "potential.h" diff --git a/ABACUS.develop/source/src_pw/sto_elec.cpp b/ABACUS.develop/source/src_pw/sto_elec.cpp index ed51595e4c..2d6499caa1 100644 --- a/ABACUS.develop/source/src_pw/sto_elec.cpp +++ b/ABACUS.develop/source/src_pw/sto_elec.cpp @@ -2,6 +2,7 @@ #include "global.h" #include "sto_elec.h" #include "algorithms.h" +#include "occupy.h" #include "symmetry_rho.h" #include "../src_io/wf_io.h" diff --git a/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp b/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp index 4a38c3fe23..9b2bdee40f 100644 --- a/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp +++ b/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp @@ -1207,6 +1207,7 @@ void UnitCell_pseudo::read_pseudopot(const string &pp_dir) // calculate total number of electrons (nelec) and default // number of bands (NBANDS). //========================================================= +#include "occupy.h" void UnitCell_pseudo::cal_nelec(void) { if(test_pseudo_cell) TITLE("UnitCell_pseudo","cal_nelec"); diff --git a/ABACUS.develop/source/src_pw/wavefunc.cpp b/ABACUS.develop/source/src_pw/wavefunc.cpp index c6f0c39fa3..c9a523c808 100644 --- a/ABACUS.develop/source/src_pw/wavefunc.cpp +++ b/ABACUS.develop/source/src_pw/wavefunc.cpp @@ -166,6 +166,7 @@ LiuXh modify 20180619*/ // This routine computes an estimate of the start_ wavefunctions // from superposition of atomic wavefunctions or random wave functions. //=================================================================== +#include "occupy.h" void wavefunc::wfcinit(void) { TITLE("wavefunc","wfcinit"); From 84ec9e76fc86b1bc3004d45c50631a486ca2ee26 Mon Sep 17 00:00:00 2001 From: mohan Date: Mon, 15 Feb 2021 21:29:05 +0800 Subject: [PATCH 117/233] change functional.h to xc_type.h, change gga_pw.h to xc_gga_pw.h --- ABACUS.develop/source/Makefile.Objects | 4 ++-- ABACUS.develop/source/src_lcao/stress_lcao.cpp | 2 +- ABACUS.develop/source/src_pw/exx_global.h | 4 ++-- ABACUS.develop/source/src_pw/global.h | 2 +- ABACUS.develop/source/src_pw/myfunc1.cpp | 2 +- ABACUS.develop/source/src_pw/myfunc2.cpp | 2 +- ABACUS.develop/source/src_pw/potential.cpp | 2 +- ABACUS.develop/source/src_pw/pseudo_h.cpp | 2 +- ABACUS.develop/source/src_pw/stress.cpp | 2 +- ABACUS.develop/source/src_pw/xc_functional.cpp | 4 +--- ABACUS.develop/source/src_pw/{gga_pw.cpp => xc_gga_pw.cpp} | 6 ++++-- ABACUS.develop/source/src_pw/{gga_pw.h => xc_gga_pw.h} | 3 ++- .../source/src_pw/{functional.cpp => xc_type.cpp} | 5 ++--- ABACUS.develop/source/src_pw/{functional.h => xc_type.h} | 4 +++- ABACUS.develop/source/src_ri/exx_lcao.h | 4 ++-- 15 files changed, 25 insertions(+), 23 deletions(-) rename ABACUS.develop/source/src_pw/{gga_pw.cpp => xc_gga_pw.cpp} (99%) rename ABACUS.develop/source/src_pw/{gga_pw.h => xc_gga_pw.h} (99%) rename ABACUS.develop/source/src_pw/{functional.cpp => xc_type.cpp} (99%) rename ABACUS.develop/source/src_pw/{functional.h => xc_type.h} (99%) diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index dc0b7c1bd8..b5ba0e3fbf 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -18,7 +18,7 @@ input_conv.o\ run_pw.o\ run_lcao.o\ -OBJS_PW_BASIC=functional.o \ +OBJS_PW_BASIC=xc_type.o \ xc_functional.o\ pseudopot_upf.o\ pseudo_h.o \ @@ -209,7 +209,7 @@ charge_mixing.o \ charge_pulay.o \ charge_broyden.o \ charge_extra.o \ -gga_pw.o \ +xc_gga_pw.o \ potential.o \ potential_libxc.o \ efield.o \ diff --git a/ABACUS.develop/source/src_lcao/stress_lcao.cpp b/ABACUS.develop/source/src_lcao/stress_lcao.cpp index 6238ec91d8..b66ba76a17 100644 --- a/ABACUS.develop/source/src_lcao/stress_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/stress_lcao.cpp @@ -1,7 +1,7 @@ #include "stress_lcao.h" #include "../src_pw/global.h" #include "../src_pw/xc_functional.h" -#include "../src_pw/gga_pw.h" +#include "../src_pw/xc_gga_pw.h" double Stress_LCAO::stress_invalid_threshold_ev = 0.00; diff --git a/ABACUS.develop/source/src_pw/exx_global.h b/ABACUS.develop/source/src_pw/exx_global.h index 67d74186d0..47d8f4b49c 100644 --- a/ABACUS.develop/source/src_pw/exx_global.h +++ b/ABACUS.develop/source/src_pw/exx_global.h @@ -1,7 +1,7 @@ #ifndef EXX_GLOBAL_H #define EXX_GLOBAL_H -#include "src_pw/functional.h" +#include "src_pw/xc_type.h" struct Exx_Global { @@ -38,4 +38,4 @@ struct Exx_Global Exx_Info info; }; -#endif \ No newline at end of file +#endif diff --git a/ABACUS.develop/source/src_pw/global.h b/ABACUS.develop/source/src_pw/global.h index b411107a99..a124262bdd 100644 --- a/ABACUS.develop/source/src_pw/global.h +++ b/ABACUS.develop/source/src_pw/global.h @@ -14,7 +14,7 @@ #include "pseudopot_cell_vnl.h" #include "charge_broyden.h" #include "potential.h" -#include "functional.h" +#include "xc_type.h" #include "hamilt.h" #include "ions.h" #include "wavefunc.h" diff --git a/ABACUS.develop/source/src_pw/myfunc1.cpp b/ABACUS.develop/source/src_pw/myfunc1.cpp index 6a3b89e7b9..2272da6063 100644 --- a/ABACUS.develop/source/src_pw/myfunc1.cpp +++ b/ABACUS.develop/source/src_pw/myfunc1.cpp @@ -1,6 +1,6 @@ #include "../src_pw/tools.h" #include "../src_pw/global.h" -#include "../src_pw/functional.h" +#include "../src_pw/xc_type.h" #include "myfunc.h" //----------------------------------------------------------------------- diff --git a/ABACUS.develop/source/src_pw/myfunc2.cpp b/ABACUS.develop/source/src_pw/myfunc2.cpp index 601a8862e5..de2691569d 100644 --- a/ABACUS.develop/source/src_pw/myfunc2.cpp +++ b/ABACUS.develop/source/src_pw/myfunc2.cpp @@ -8,7 +8,7 @@ using namespace std; #include "../src_pw/global.h" -#include "../src_pw/functional.h" +#include "../src_pw/xc_type.h" #include "../src_pw/xc_functional.h" #include "myfunc.h" diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index 463d59b003..b20c611e71 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -2,7 +2,7 @@ #include "global.h" #include "potential.h" #include "xc_functional.h" -#include "gga_pw.h" +#include "xc_gga_pw.h" #include "efield.h" #include "math.h" #include "potential_libxc.h" diff --git a/ABACUS.develop/source/src_pw/pseudo_h.cpp b/ABACUS.develop/source/src_pw/pseudo_h.cpp index d804cb5618..5cdb66b4e2 100644 --- a/ABACUS.develop/source/src_pw/pseudo_h.cpp +++ b/ABACUS.develop/source/src_pw/pseudo_h.cpp @@ -2,7 +2,7 @@ // AUTHOR : Lixin He,mohan // DATE : 2008-11-11 //========================================================== -#include "functional.h" +#include "xc_type.h" #include "global.h" #include "pseudo_h.h" #include "tools.h" diff --git a/ABACUS.develop/source/src_pw/stress.cpp b/ABACUS.develop/source/src_pw/stress.cpp index ccfcabfc42..fc1458d0f9 100644 --- a/ABACUS.develop/source/src_pw/stress.cpp +++ b/ABACUS.develop/source/src_pw/stress.cpp @@ -2,7 +2,7 @@ #include "global.h" #include "potential.h" #include "xc_functional.h" -#include "gga_pw.h" +#include "xc_gga_pw.h" #include "efield.h" void Stress::cal_stress() diff --git a/ABACUS.develop/source/src_pw/xc_functional.cpp b/ABACUS.develop/source/src_pw/xc_functional.cpp index b9740ddf37..a3364d15ee 100644 --- a/ABACUS.develop/source/src_pw/xc_functional.cpp +++ b/ABACUS.develop/source/src_pw/xc_functional.cpp @@ -1,10 +1,8 @@ #include "xc_functional.h" -#include "functional.h" - +#include "xc_type.h" #include "src_pw/global.h" #include "src_pw/myfunc.h" #include "src_global/global_function.h" - #include XC_Functional::XC_Functional(){} diff --git a/ABACUS.develop/source/src_pw/gga_pw.cpp b/ABACUS.develop/source/src_pw/xc_gga_pw.cpp similarity index 99% rename from ABACUS.develop/source/src_pw/gga_pw.cpp rename to ABACUS.develop/source/src_pw/xc_gga_pw.cpp index 3f98667eb7..9b850ef0af 100644 --- a/ABACUS.develop/source/src_pw/gga_pw.cpp +++ b/ABACUS.develop/source/src_pw/xc_gga_pw.cpp @@ -1,4 +1,4 @@ -#include "gga_pw.h" +#include "xc_gga_pw.h" #include "global.h" #include "xc_functional.h" #include "../src_pw/myfunc.h" @@ -6,10 +6,12 @@ // from gradcorr.f90 void GGA_PW::gradcorr(double &etxc, double &vtxc, matrix &v) { - TITLE("GGA::gradcorr"); + TITLE("GGA_PW","gradcorr"); if (xcf.igcx_now == 0 && xcf.igcc_now == 0) + { return; + } bool igcc_is_lyp = false; if( xcf.igcc_now == 3 || xcf.igcc_now == 7) diff --git a/ABACUS.develop/source/src_pw/gga_pw.h b/ABACUS.develop/source/src_pw/xc_gga_pw.h similarity index 99% rename from ABACUS.develop/source/src_pw/gga_pw.h rename to ABACUS.develop/source/src_pw/xc_gga_pw.h index d905af99ea..74044ed0d4 100644 --- a/ABACUS.develop/source/src_pw/gga_pw.h +++ b/ABACUS.develop/source/src_pw/xc_gga_pw.h @@ -9,16 +9,17 @@ #include "src_pw/tools.h" #include "src_global/vector3.h" #include "src_parallel/parallel_global.h" + //========================================================== // Calculate the charge gradient using plane wave basis. //========================================================== + namespace GGA_PW { void gradcorr(double &etxc, double &vtxc, matrix &v); void grad_rho( const complex *rhog, Vector3 *gdr ); void grad_dot( const Vector3 *h, double *dh); void noncolin_rho(double *rhoout1,double *rhoout2,double *seg); - } #endif diff --git a/ABACUS.develop/source/src_pw/functional.cpp b/ABACUS.develop/source/src_pw/xc_type.cpp similarity index 99% rename from ABACUS.develop/source/src_pw/functional.cpp rename to ABACUS.develop/source/src_pw/xc_type.cpp index 96c2b261e5..0299cc1877 100644 --- a/ABACUS.develop/source/src_pw/functional.cpp +++ b/ABACUS.develop/source/src_pw/xc_type.cpp @@ -2,8 +2,7 @@ // AUTHOR : Lixin He ,mohan // DATE : 2008-11-08 //========================================================== -#include "functional.h" - +#include "xc_type.h" #include "src_global/global_function.h" #include "src_pw/global.h" #include "src_pw/exx_global.h" @@ -305,4 +304,4 @@ void xcfunc::hybrid_first() iexch_now = 1; igcx_now = 3; } -} \ No newline at end of file +} diff --git a/ABACUS.develop/source/src_pw/functional.h b/ABACUS.develop/source/src_pw/xc_type.h similarity index 99% rename from ABACUS.develop/source/src_pw/functional.h rename to ABACUS.develop/source/src_pw/xc_type.h index ad0253f1cf..8299aa1dcc 100644 --- a/ABACUS.develop/source/src_pw/functional.h +++ b/ABACUS.develop/source/src_pw/xc_type.h @@ -8,7 +8,9 @@ #include "tools.h" class xcfunc { -public: + + public: + //module funct // char dft[20]; // dft is the exchange-correlation functional, described by diff --git a/ABACUS.develop/source/src_ri/exx_lcao.h b/ABACUS.develop/source/src_ri/exx_lcao.h index a1d50d00d8..509a72269e 100644 --- a/ABACUS.develop/source/src_ri/exx_lcao.h +++ b/ABACUS.develop/source/src_ri/exx_lcao.h @@ -10,7 +10,7 @@ #include "src_ri/exx_abfs-screen-schwarz.h" #include "src_ri/exx_abfs-screen-cauchy.h" #include "src_global/element_basis_index.h" -#include "src_pw/functional.h" +#include "src_pw/xc_type.h" #include "src_pw/exx_global.h" #if EXX_DM==1 @@ -116,4 +116,4 @@ class Exx_Lcao friend class Local_Orbital_Charge; }; -#endif // EXX_LCAO_H \ No newline at end of file +#endif // EXX_LCAO_H From 0218d5e8e91dc30291b8b0cd6cd5e918844d0c42 Mon Sep 17 00:00:00 2001 From: mohan Date: Mon, 15 Feb 2021 21:45:02 +0800 Subject: [PATCH 118/233] delete the define of __FP --- ABACUS.develop/source/src_io/dos.cpp | 3 +-- ABACUS.develop/source/src_lcao/global_fp.cpp | 4 ---- ABACUS.develop/source/src_pw/algorithms.h | 6 ------ ABACUS.develop/source/src_pw/klist.cpp | 2 -- ABACUS.develop/source/src_pw/pseudo_atom.cpp | 2 -- ABACUS.develop/source/src_pw/unitcell_pseudo.cpp | 3 --- ABACUS.develop/source/src_pw/wavefunc.cpp | 16 +--------------- ABACUS.develop/source/src_pw/wavefunc.h | 2 -- ABACUS.develop/source/src_pw/wf_igk.h | 10 ++++++++-- 9 files changed, 10 insertions(+), 38 deletions(-) diff --git a/ABACUS.develop/source/src_io/dos.cpp b/ABACUS.develop/source/src_io/dos.cpp index 1606cdf318..7059a9b6f0 100644 --- a/ABACUS.develop/source/src_io/dos.cpp +++ b/ABACUS.develop/source/src_io/dos.cpp @@ -3,7 +3,6 @@ void Dos::calculate_Mulliken(const string &fa) { -#ifdef __FP TITLE("Dos","calculate_Mulliken"); ofstream ofs; @@ -134,7 +133,7 @@ void Dos::calculate_Mulliken(const string &fa) if(MY_RANK==0) ofs.close(); -#endif + return; } diff --git a/ABACUS.develop/source/src_lcao/global_fp.cpp b/ABACUS.develop/source/src_lcao/global_fp.cpp index 26f71f90dc..c5f2bb6a74 100644 --- a/ABACUS.develop/source/src_lcao/global_fp.cpp +++ b/ABACUS.develop/source/src_lcao/global_fp.cpp @@ -1,7 +1,6 @@ #include "global_fp.h" #include "src_pw/global.h" -#ifdef __FP Grid_Driver GridD; Parallel_Atoms ParaA; Parallel_Orbitals ParaO; @@ -11,6 +10,3 @@ LCAO_Matrix LM; Use_Hamilt_Matrix UHM; SubGrid_oper SGO; //mohan add 2012-01-12 Exx_Lcao exx_lcao(exx_global.info); // Peize Lin add 2016-12-03 - -#endif - diff --git a/ABACUS.develop/source/src_pw/algorithms.h b/ABACUS.develop/source/src_pw/algorithms.h index 2468562326..f0d8bf79ad 100644 --- a/ABACUS.develop/source/src_pw/algorithms.h +++ b/ABACUS.develop/source/src_pw/algorithms.h @@ -6,14 +6,8 @@ #include "src_ions/ions_move_bfgs.h" #include "src_io/dos.h" #include "src_pw/myfunc.h" -// #include "src_io/numerical_basis.h" #include "src_io/numerical_descriptor.h" // mohan added 2021-01-04 #include "src_io/bessel_basis.h" -//#include "../src_algorithms/spillage.h" -//#include "../src_algorithms/mymath.h" - -#ifdef __FP -#endif #endif diff --git a/ABACUS.develop/source/src_pw/klist.cpp b/ABACUS.develop/source/src_pw/klist.cpp index 308a060c35..567f427f7c 100644 --- a/ABACUS.develop/source/src_pw/klist.cpp +++ b/ABACUS.develop/source/src_pw/klist.cpp @@ -164,7 +164,6 @@ bool kvect::read_kpoints(const string &fn) if (MY_RANK != 0) return 1; // mohan add 2010-09-04 -#ifdef __FP if(GAMMA_ONLY_LOCAL) { ofs_warning << " Auto generating k-points file: " << fn << endl; @@ -175,7 +174,6 @@ bool kvect::read_kpoints(const string &fn) ofs << "1 1 1 0 0 0" << endl; ofs.close(); } -#endif ifstream ifk(fn.c_str()); if (!ifk) diff --git a/ABACUS.develop/source/src_pw/pseudo_atom.cpp b/ABACUS.develop/source/src_pw/pseudo_atom.cpp index 04e4dc1d95..0177a0e8e2 100644 --- a/ABACUS.develop/source/src_pw/pseudo_atom.cpp +++ b/ABACUS.develop/source/src_pw/pseudo_atom.cpp @@ -30,13 +30,11 @@ void pseudo_atom::set_pseudo_at(const Pseudopot_upf &upf) // in order to calculate more accurate Vna. rcut = 15.0;//(a.u.); -#ifdef __FP //if(!LOCAL_BASIS) xiaohui modify 2013-09-02 // mohan modified 2009-1-21 if(BASIS_TYPE=="pw") //xiaohui add 2013-09-02 { //rcut = winput::rcut; } -#endif // remember to update here if you need it. // rcut = 25.0; diff --git a/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp b/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp index 9b2bdee40f..ba49b71e0c 100644 --- a/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp +++ b/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp @@ -927,8 +927,6 @@ void UnitCell_pseudo::print_stru_file(const string &fn, const int &type)const ofs << atom_label[it] << " " << atom_mass[it] << " " << pseudo_fn[it] << endl; } -#ifdef __FP - //if(LOCAL_BASIS) xiaohui modify 2013-09-02 //mohan fix bug 2011-05-01 if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-02. Attention... { ofs << "\nNUMERICAL_ORBITAL" << endl; @@ -943,7 +941,6 @@ void UnitCell_pseudo::print_stru_file(const string &fn, const int &type)const ofs << ORB.orbital_file[it] << endl; } } -#endif ofs << "\nLATTICE_CONSTANT" << endl; //modified by zhengdy 2015-07-24 diff --git a/ABACUS.develop/source/src_pw/wavefunc.cpp b/ABACUS.develop/source/src_pw/wavefunc.cpp index c9a523c808..2f95bdf936 100644 --- a/ABACUS.develop/source/src_pw/wavefunc.cpp +++ b/ABACUS.develop/source/src_pw/wavefunc.cpp @@ -29,7 +29,6 @@ wavefunc::~wavefunc() } } -#ifdef __FP void wavefunc::init_local(void) { TITLE("wavefunc","init_local"); @@ -52,7 +51,6 @@ void wavefunc::init_local(void) if(test_wf)ofs_running << " Allocate : EigenValue; Weight;" << endl; return; } -#endif void wavefunc::init(const int nks) { @@ -113,7 +111,6 @@ LiuXh modify 20180619*/ this->wanf2 = new ComplexMatrix[1]; evc[0].create(NBANDS, npwx * NPOL);//added by zhengdy-soc -#ifdef __FP //if(LOCAL_BASIS && LINEAR_SCALING==0) xiaohui modify 2013-09-02 if(BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-02 { @@ -121,7 +118,6 @@ LiuXh modify 20180619*/ cout << " Memory for wanf2 (MB): " << Memory::record("wavefunc","wanf2",NLOCAL*(prefactor*npwx),"complexmatrix") << endl; } -#endif cout << " MEMORY FOR PSI (MB) : " << Memory::record("wavefunc","evc",NBANDS*(prefactor*npwx),"complexmatrix") << endl; } @@ -135,14 +131,12 @@ LiuXh modify 20180619*/ this->evc[ik].create(NBANDS, npwx * NPOL);//added by zhengdy-soc //Mohan add 2010-1-10 -#ifdef __FP //xiaohui add 2013 -08-01 //if (LOCAL_BASIS || winput::out_spillage==2) xiaohui modify 2013-09-02 if((BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") || winput::out_spillage==2) //xiaohui add 2013-09-02 { this->wanf2[ik].create(NLOCAL, npwx * NPOL);//added by zhengdy-soc } -#endif }; cout << " MEMORY FOR PSI (MB) : " << @@ -254,7 +248,6 @@ void wavefunc::LCAO_in_pw_k(const int &ik, ComplexMatrix &wvf) TITLE("wavefunc","LCAO_in_pw_k"); timer::tick("wavefunc","LCAO_in_pw_k",'G'); -#ifdef __FP //assert(LOCAL_BASIS==4); xiaohui modify 2013-09-01 assert(BASIS_TYPE=="lcao_in_pw"); //xiaohui add 2013-09-01. Attention! How about "BASIS_TYPE=="lcao""??? @@ -281,7 +274,7 @@ void wavefunc::LCAO_in_pw_k(const int &ik, ComplexMatrix &wvf) // } // DONE(ofs_running,"CONSTRUCT_LOCAL_BASIS_IN_PW"); -#endif + timer::tick("wavefunc","LCAO_in_pw_k",'G'); return; } @@ -294,11 +287,8 @@ void wavefunc::LCAO_in_pw_k_q(const int &ik, ComplexMatrix &wvf, Vector3 //assert(LOCAL_BASIS==4); xiaohui modify 2013-09-01 assert(BASIS_TYPE=="lcao_in_pw"); //xiaohui add 2013-09-01. Attention! How about "BASIS_TYPE=="lcao""??? -#ifdef __FP - Wavefunc_in_pw::produce_local_basis_q_in_pw(ik, wvf, this->table_local, q); -#endif timer::tick("wavefunc","LCAO_in_pw_k_q",'G'); return; } @@ -812,14 +802,12 @@ void wavefunc::init_after_vc(const int nks) this->wanf2 = new ComplexMatrix[1]; evc[0].create(NBANDS*prefactor, npwx); -#ifdef __FP if(BASIS_TYPE=="lcao_in_pw") { wanf2[0].create(NLOCAL*prefactor, npwx); cout << " Memory for wanf2 (MB): " << Memory::record("wavefunc","wanf2",(NLOCAL*prefactor)*npwx,"complexmatrix") << endl; } -#endif cout << " MEMORY FOR PSI (MB) : " << Memory::record("wavefunc","evc",(NBANDS*prefactor)*npwx,"complexmatrix") << endl; } @@ -832,12 +820,10 @@ void wavefunc::init_after_vc(const int nks) { this->evc[ik].create(NBANDS*prefactor, npwx); -#ifdef __FP if((BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") || winput::out_spillage==2) { this->wanf2[ik].create(NLOCAL, npwx); } -#endif } cout << " MEMORY FOR PSI (MB) : " << diff --git a/ABACUS.develop/source/src_pw/wavefunc.h b/ABACUS.develop/source/src_pw/wavefunc.h index b00e8974aa..d129335811 100644 --- a/ABACUS.develop/source/src_pw/wavefunc.h +++ b/ABACUS.develop/source/src_pw/wavefunc.h @@ -17,9 +17,7 @@ class wavefunc : public WF_atomic // allocate memory void init(const int nks); -#ifdef __FP void init_local(void); -#endif int out_wf; //qianrui modify 2020-10-19 diff --git a/ABACUS.develop/source/src_pw/wf_igk.h b/ABACUS.develop/source/src_pw/wf_igk.h index 33989c354c..1857dfc203 100644 --- a/ABACUS.develop/source/src_pw/wf_igk.h +++ b/ABACUS.develop/source/src_pw/wf_igk.h @@ -14,18 +14,24 @@ class WF_igk // for each k point , find the number of pws int setupIndGk(const PW_Basis &pwb,const int nks); - // g2kin : [npw],kinetic energy for current k point int npwx; int npw; IntArray igk; + + // g2kin : [npw],kinetic energy for current k point double *g2kin; // Calculate kinetic energy void ekin(const int ik); + double* get_qvec_cartesian(const int &ik); + Vector3 get_1qvec_cartesian(const int ik,const int ig)const; + complex* get_sk(const int ik, const int it, const int ia)const; - complex* get_skq(int ik, int it, int ia, Vector3 q); // pengfei 2016-11-23 + + // pengfei 2016-11-23 + complex* get_skq(int ik, int it, int ia, Vector3 q); }; #endif From bc39e5a619df62f2876db411e8799d93276b7e54 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 16 Feb 2021 13:19:55 +0800 Subject: [PATCH 119/233] change myfunc files to xc_ files --- ABACUS.develop/source/Makefile.Objects | 6 +++--- ABACUS.develop/source/src_pw/{myfunc1.cpp => xc_1.cpp} | 0 ABACUS.develop/source/src_pw/{myfunc2.cpp => xc_2.cpp} | 0 ABACUS.develop/source/src_pw/{myfunc3.cpp => xc_3.cpp} | 0 ABACUS.develop/source/src_pw/{myfunc5.cpp => xc_4.cpp} | 0 5 files changed, 3 insertions(+), 3 deletions(-) rename ABACUS.develop/source/src_pw/{myfunc1.cpp => xc_1.cpp} (100%) rename ABACUS.develop/source/src_pw/{myfunc2.cpp => xc_2.cpp} (100%) rename ABACUS.develop/source/src_pw/{myfunc3.cpp => xc_3.cpp} (100%) rename ABACUS.develop/source/src_pw/{myfunc5.cpp => xc_4.cpp} (100%) diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index b5ba0e3fbf..f480e0deff 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -35,8 +35,9 @@ threshold_elec.o\ electrons.o \ forces.o\ stress.o\ -myfunc1.o\ -myfunc2.o\ +xc_1.o\ +xc_2.o\ +xc_4.o \ vdwd2.o\ vdwd2_parameters.o\ dftd3_subroutine.o\ @@ -270,7 +271,6 @@ mlwf_optimize.o\ OBJS_OTHER=mymath1.o \ mymath3.o \ -myfunc5.o \ OBJS_PDIAG=pdgseps.o \ pzgseps.o \ diff --git a/ABACUS.develop/source/src_pw/myfunc1.cpp b/ABACUS.develop/source/src_pw/xc_1.cpp similarity index 100% rename from ABACUS.develop/source/src_pw/myfunc1.cpp rename to ABACUS.develop/source/src_pw/xc_1.cpp diff --git a/ABACUS.develop/source/src_pw/myfunc2.cpp b/ABACUS.develop/source/src_pw/xc_2.cpp similarity index 100% rename from ABACUS.develop/source/src_pw/myfunc2.cpp rename to ABACUS.develop/source/src_pw/xc_2.cpp diff --git a/ABACUS.develop/source/src_pw/myfunc3.cpp b/ABACUS.develop/source/src_pw/xc_3.cpp similarity index 100% rename from ABACUS.develop/source/src_pw/myfunc3.cpp rename to ABACUS.develop/source/src_pw/xc_3.cpp diff --git a/ABACUS.develop/source/src_pw/myfunc5.cpp b/ABACUS.develop/source/src_pw/xc_4.cpp similarity index 100% rename from ABACUS.develop/source/src_pw/myfunc5.cpp rename to ABACUS.develop/source/src_pw/xc_4.cpp From 01386fe0a276b288618fb4bf78b5960c7923592a Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 16 Feb 2021 13:30:25 +0800 Subject: [PATCH 120/233] update some formats in Makefile, mv xc_4 to xc_3 --- ABACUS.develop/source/Makefile | 8 +- ABACUS.develop/source/Makefile.Objects | 39 +- ABACUS.develop/source/src_pw/potential.h | 2 + ABACUS.develop/source/src_pw/xc_3.cpp | 1462 ++++++++++++++++------ ABACUS.develop/source/src_pw/xc_4.cpp | 1194 ------------------ 5 files changed, 1130 insertions(+), 1575 deletions(-) delete mode 100644 ABACUS.develop/source/src_pw/xc_4.cpp diff --git a/ABACUS.develop/source/Makefile b/ABACUS.develop/source/Makefile index 06edf83e99..fde4962b7f 100644 --- a/ABACUS.develop/source/Makefile +++ b/ABACUS.develop/source/Makefile @@ -47,16 +47,10 @@ OPTS_GDB = -g -W -I${BOOST_INCLUDE_DIR} #========================== # OBJECTS NEEDED #========================== -FP_OBJS_0=$(OBJS_OTHER)\ -$(OBJS_FIRST_PRINCIPLE)\ +FP_OBJS_0=$(OBJS_FIRST_PRINCIPLES)\ $(OBJS_PARALLEL)\ $(OBJS_TOOLS) \ -$(OBJS_ONSCALING)\ -$(OBJS_SELINV)\ -$(OBJS_CG)\ -$(OBJS_WANNIER)\ $(OBJS_COMMON)\ -$(OBJS_MLWF)\ main.o\ FP_OBJS=$(patsubst %.o, ${OBJ_DIR}/%.o, ${FP_OBJS_0}) diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index f480e0deff..f8a34722a6 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -12,14 +12,22 @@ VERSION = ABACUS HEADERS = *.h -OBJS_DC=driver.o\ +OBJS_MAIN=driver.o\ input.o \ input_conv.o\ run_pw.o\ run_lcao.o\ -OBJS_PW_BASIC=xc_type.o \ +OBJS_PW=xc_type.o \ xc_functional.o\ +xc_1.o\ +xc_2.o\ +xc_3.o \ +vdwd2.o\ +vdwd2_parameters.o\ +dftd3_subroutine.o\ +vdwd3.o\ +vdwd3_parameters.o\ pseudopot_upf.o\ pseudo_h.o \ pseudo_atom.o \ @@ -35,14 +43,6 @@ threshold_elec.o\ electrons.o \ forces.o\ stress.o\ -xc_1.o\ -xc_2.o\ -xc_4.o \ -vdwd2.o\ -vdwd2_parameters.o\ -dftd3_subroutine.o\ -vdwd3.o\ -vdwd3_parameters.o\ chi0_hilbert.o\ chi0_standard.o\ epsilon0_pwscf.o\ @@ -85,8 +85,10 @@ global_function.o \ global_file.o \ element_basis_index.o \ restart.o \ +mymath1.o \ +mymath3.o \ -OBJS_ONSCALING=sltk_grid.o\ +OBJS_LCAO=sltk_grid.o\ sltk_grid_driver.o \ sltk_atom_arrange.o\ sltk_atom.o\ @@ -189,8 +191,7 @@ exx_opt_orb-print.o \ wfc_dm_2d.o \ unk_overlap_lcao.o \ cal_r_overlap_R.o \ - -OBJS_WANNIER=bessel_basis.o\ +bessel_basis.o\ numerical_basis.o\ numerical_descriptor.o\ wavefunc_in_pw.o\ @@ -203,8 +204,9 @@ parallel_pw.o\ ft.o\ parallel_grid.o\ -OBJS_FIRST_PRINCIPLE=$(OBJS_PW_BASIC)\ -$(OBJS_DC)\ +OBJS_FIRST_PRINCIPLES=$(OBJS_MAIN)\ +$(OBJS_PW)\ +$(OBJS_LCAO)\ charge.o \ charge_mixing.o \ charge_pulay.o \ @@ -265,13 +267,6 @@ symm_other.o \ eximport.o \ mulliken_charge.o\ -#OBJS_MLWF=mlwf_kmesh.o\ -mlwf_overlap.o\ -mlwf_optimize.o\ - -OBJS_OTHER=mymath1.o \ -mymath3.o \ - OBJS_PDIAG=pdgseps.o \ pzgseps.o \ pdst2g.o \ diff --git a/ABACUS.develop/source/src_pw/potential.h b/ABACUS.develop/source/src_pw/potential.h index 1ec7f9737a..2bbaf0f6f3 100644 --- a/ABACUS.develop/source/src_pw/potential.h +++ b/ABACUS.develop/source/src_pw/potential.h @@ -67,6 +67,7 @@ class potential // here vh is complex because the array is got after complex FFT. void write_potential(const int &is, const int &iter, const string &fn, const matrix &v, const int &precision, const int &hartree = 0)const; + void write_elecstat_pot(const string &fn, const string &fn_ave); private: @@ -74,6 +75,7 @@ class potential // use fft to set vltot. // do once in demo.cpp void set_local(double *vl_pseudo)const; + void v_h( int nspin, double &ehart, matrix &v, double** rho); int test; diff --git a/ABACUS.develop/source/src_pw/xc_3.cpp b/ABACUS.develop/source/src_pw/xc_3.cpp index 081e697a16..b2eccaf0d0 100644 --- a/ABACUS.develop/source/src_pw/xc_3.cpp +++ b/ABACUS.develop/source/src_pw/xc_3.cpp @@ -1,436 +1,1194 @@ -#include "../src_pw/global.h" +/* myfunc.cpp */ +// from LPACK +#include +#include +#include +#include +#include + +using namespace std; #include "myfunc.h" -#include "mymath.h" +#include "src_global/blas_connector.h" +#include "../src_pw/global.h" + +// dscal compute y = alpha * y, where alpha is a scalar and +void dscal(const int n,const double &alpha,double *y,const int incy) +{ + if (incy <= 0 || n < 1) + { + cout << "\n error in dscal,incy <= 0 or n < 1"; + return; + } + for (int i = 0; i < n; i += incy) + { + y[i] *= alpha; + } -// from gradcorr.f90 -void gradcorr(double &etxc, double &vtxc, matrix &v) + return; +} + +// a(i,:) = alpha * a(i,:) where a is a matrix +// i line +void dscal(const double &alpha,matrix &a,const int i) { - BLOCK_HERE("gradcorr"); - if (xcf.igcx_now == 0 && xcf.igcc_now == 0) + int nc = a.nc; + int nr = a.nr; + + if (nc <= 0 || nr <= 0 || i < 0 || i >= nr) { + cerr << "\n error in dscal,nc <= 0 or nr <= 0 or i < 0 or i >= nr, "; return; } - double zeta, rh, grh2; - int k, ipol, is; + for (int j = 0;j < nc;j++) + { + a(i,j) = a(i,j) * alpha; + } +} - double *dh; - double grho2[2], sx, sc, v1x, v2x, v1c, v2c, v1xup, v1xdw, - v2xup, v2xdw, v1cup, v1cdw , etxcgc, vtxcgc, segno, arho, fac; +// daxpy compute y := alpha * x + y where alpha is a scalar and x and y +void daxpy(const int n, const double &alpha, const double *x, const int incx, double *y, const int incy) +{ + if (n < 1 || incy <= 0 || incx <= 0) + { + cerr << "\n error in daxpy, n < 1 or incx <= 0 or incy <= 0, "; + return; + } + for (int ix = 0, iy = 0;ix < n && iy < n;ix += incx, iy += incy) + { + y[iy] += alpha * x[ix]; + } + return; +} - etxcgc = 0.0; - vtxcgc = 0.0; +void zaxpy(int n, double alpha, complex < double> *x, int incx, complex < double> *y, int incy) +{ - realArray h(NSPIN, pw.nrxx, 3); - realArray grho(NSPIN, pw.nrxx, 3); + if (n < 1 || incy <= 0 || incx <= 0) + { + cerr << "\n error in daxpy, n < 1 or incx <= 0 or incy <= 0, "; + return; + } - // calculate the gradient of rho+rho_core in real space - Vector3 *grho_v3 = new Vector3[pw.nrxx]; - Vector3 *h_v3 = new Vector3[pw.nrxx]; + for (int ix = 0, iy = 0;ix < n && iy < n;ix += incx, iy += incy) // y := alpha * x + y + { + y[iy] += alpha * x[ix]; + } +} - fac = 1.0 / NSPIN; - for (is=0; is alpha, complex < double> *x, + int incx, complex < double> *y, int incy) +{ + // zaxpy compute y := alpha * x + y where alpha is a scalar and + // x and y are n-vectors. + // DOUBLE COMPLEX ALPHA + // DOUBLE COMPLEX X(*), Y(*) + // INTEGER N, INCX, INCY + + // ARGUMENTS + + // N (input) + // On entry, N specifies the number of elements in + // the vector. N must be at least one for the sub- + // routine to have any visible effect. Unchanged on + // exit. + + // ALPHA (input) + // On entry, ALPHA specifies the scalar alpha. + // Unchanged on exit. + + // X (input) + // array of DIMENSION at least ( 1 + ( n - 1 )*abs( + // INCX ) ). Before entry, the incremented array X + // must contain the vector x. Unchanged on exit. + + // INCX (input) + // On entry, INCX specifies the increment for the + // elements of X. Unchanged on exit. + + // Y (input/output) + // array of DIMENSION at least ( 1 + ( n - 1 )*abs( + // INCY ) ). On entry, the incremented array Y must + // contain the vector y. On exit, Y is overwritten by + // the updated vector y. + + // INCY (input) + // On entry, INCY specifies the increment for the + // elements of Y. Unchanged on exit. + + if (n < 1 || incy <= 0 || incx <= 0) { - for (k = 0; k epsr && grho2 [1] > epsg) - { - gcxc(arho, grho2[1], sx, sc, v1x, v2x, v1c, v2c); //?grho2[0] - // first term of the gradient correction : D(rho*Exc)/D(rho) - v(0, k) = v(0, k) + e2 * (v1x + v1c); - // h contains D(rho*Exc)/D(|grad rho|) * (grad rho) / |grad rho| - - for (ipol = 0;ipol < 3;ipol++) // do ipol = 1, 3 - { - h(0, k, ipol) = e2 * (v2x + v2c) * grho(0, k, ipol); - } // enddo - - vtxcgc = vtxcgc + e2 * (v1x + v1c) * ( chr.rho1[k] - chr.rho_core[k]); - - etxcgc = etxcgc + e2 * (sx + sc) * segno; - } - else - { - for (ipol = 0;ipol < 3;ipol++) // do ipol = 1, 3 - { - h(0, k, ipol) = 0.0; - } // enddo - } // endif - } - else - { - // spin-polarised case - gcx_spin( chr.rho1[k], chr.rho2[k], grho2 [0], grho2 [1], - sx, v1xup, v1xdw, v2xup, v2xdw); - rh = chr.rho1[k] + chr.rho2[k]; - - if (rh > epsr) - { - zeta = ( chr.rho1[k] - chr.rho2[k] ) / rh; - Vector3 < double> v3; - v3.x = grho(0, k, 0) + grho(1, k, 0); - v3.y = grho(0, k, 1) + grho(1, k, 1); - v3.z = grho(0, k, 2) + grho(1, k, 2); - grh2 = v3 * v3; - // grh2 = (grho (k, 1, 1) + grho (k, 1, 2) ) **2 + - // (grho (k, 2, 1) + grho (k, 2, 2) ) **2 + - // (grho (k, 3, 1) + grho (k, 3, 2) ) **2; - gcc_spin(rh, zeta, grh2, sc, v1cup, v1cdw, v2c); - } - else - { - sc = 0.0; - v1cup = 0.0; - v1cdw = 0.0; - v2c = 0.0; - } // endif - - // first term of the gradient correction : D(rho*Exc)/D(rho) - v(0, k) = v(0, k) + e2 * (v1xup + v1cup); - - v(1, k) = v(1, k) + e2 * (v1xdw + v1cdw); - - // h contains D(rho*Exc)/D(|grad rho|) * (grad rho) / |grad rho| - for (ipol = 0;ipol < 3;ipol++) // do ipol = 1, 3 - { - h(0, k, ipol) = e2 * ((v2xup + v2c) * grho(0, k, ipol) - + v2c * grho(1, k, ipol)); - h(1, k, ipol) = e2 * ((v2xdw + v2c) * grho(1, k, ipol) - + v2c * grho(0, k, ipol)); - } // enddo - - vtxcgc = vtxcgc + e2 * (v1xup + v1cup) * ( chr.rho1[k] - - chr.rho_core[k] * fac); - - vtxcgc = vtxcgc + e2 * (v1xdw + v1cdw) * ( chr.rho2[k] - - chr.rho_core[k] * fac); - - etxcgc = etxcgc + e2 * (sx + sc); - } // endif - } // enddo - - - daxpy(pw.nrxx, -fac, chr.rho_core, 1, chr.rho1, 1); - if(NSPIN==2) - { - daxpy(pw.nrxx, -fac, chr.rho_core, 1, chr.rho2, 1); - } - - dh = new double [pw.nrxx]; +} // end zaxpy - // second term of the gradient correction : - // \sum_alpha (D / D r_alpha) ( D(rho*Exc)/D(grad_alpha rho) ) +// y(i,:) = alpha * x + y(i,:) where y is a matrix +void zaxpy(double alpha, + complex < double> *x, + ComplexMatrix &y, + int i) +{ + int nr, nc; + nr = y.nr; + nc = y.nc; - for (is = 0;is < NSPIN;is++) // do is = 1, n_spin + if (nr < 1 || nc < 1 || i < 0 || i >= nr) { - for (k = 0; k < pw.nrxx; k++) - { - h_v3[k].x = h(is, k, 0); - h_v3[k].y = h(is, k, 1); - h_v3[k].z = h(is, k, 2); - } + cerr << "\n error in daxpy, nr < 1 or nc < 1 or i out of range, "; + return; + } - grad_dot(pw.ncx, pw.ncy, pw.ncz, pw.ncxyz, h_v3, pw.ngmc, pw.g, pw.ig2fftc, ucell.lat0, dh); + for (int j = 0;j < nc;j ++) // y := alpha * x + y + { + y(i, j) += alpha * x[j]; + } - for (k = 0;k < pw.nrxx;k++) // do k = 1, ncxyz - { - v(is, k) = v(is, k) - dh [k]; - } +// cout << "\n End daxpy() " << endl; +} - if(is==0) - { - for (k = 0;k < pw.nrxx;k++) - { - vtxcgc = vtxcgc - dh [k] * chr.rho1[k]; - } - } - else if(is==1) - { - for (k = 0;k < pw.nrxx;k++) - { - vtxcgc = vtxcgc - dh [k] * chr.rho2[k]; - } - } - - } // enddo - - double vtxcaux = vtxc; - double etxcaux = etxc; - -#ifdef __MPI - MPI_Allreduce(&vtxcaux,&vtxc,1,MPI_DOUBLE,MPI_SUM,POOL_WORLD); - MPI_Allreduce(&etxcaux,&etxc,1,MPI_DOUBLE,MPI_SUM,POOL_WORLD); -#endif - - vtxc += ucell.omega * vtxcgc / pw.ncxyz;//(nr1 * nr2 * nr3); - etxc += ucell.omega * etxcgc / pw.ncxyz;//(nr1 * nr2 * nr3); - - delete [] grho_v3; - delete [] h_v3; - delete [] dh; +// y = alpha * x(i,:) + y +void zaxpy(double alpha, + const ComplexMatrix &x, + int i, + complex < double> *y) +{ + int nr, nc; + nr = x.nr; + nc = x.nc; - return; -} // end subroutine gradcorr + if (nr < 1 || nc < 1 || i < 0 || i >= nr) + { + cerr << "\n error in daxpy, nr < 1 or nc < 1 or i out of range, "; + return; + } + + for (int j = 0;j < nc;j ++) // y := alpha * x + y + { + y[j] += alpha * x(i, j); + } +} -// from gradcorr.f90 -void gradient( double *a, Vector3 *ga) +void zaxpy(complex < double> alpha, + const ComplexMatrix &x, + int i, + complex < double> *y) { - //------------------------------------------------------- - // Calculates ga = \grad a in R-space (a is also in R-space) - // use gvect, only: int *nlm; - // use wvfct, only: bool gamma_only; - double tpiba = TWO_PI / lat0; + int nr, nc; + nr = x.nr; + nc = x.nc; - int n=0; - int ipol=0; - matrix aux(2, pw.nrxx); - matrix gaux(2, pw.nrxx); + if (nr < 1 || nc < 1 || i < 0 || i >= nr) + { + cerr << "\n error in daxpy, nr < 1 or nc < 1 or i out of range, "; + return; + } - double *aux_1d= new double[pw.nrxx]; - double *gaux_1d= new double[pw.nrxx]; - double *ga_1d= new double[pw.nrxx]; + for (int j = 0;j < nc;j ++) // y := alpha * x + y + { + y[j] += alpha * x(i, j); + } +} + +// y(j,:) = alpha * x(i,:) + y(j,:) +void zaxpy(complex < double> alpha, + const ComplexMatrix &x, + int i, + ComplexMatrix &y, + int j) +{ + int nr, nc; + nr = y.nr; + nc = y.nc; - matrix gx(ngmc, 3); + if (nr < 1 || nc < 1 || i < 0 || i >= nr || j < 0 || j >= nr) + { + cerr << "\n error in daxpy, nr < 1 or nc < 1 or i or j out of range, "; + return; + } - for (n = 0;n < ngmc;n++) + for (int k = 0;k < nc;k ++) // y := alpha * x + y { - gx(n, 0) = g[n].x; - gx(n, 1) = g[n].y; - gx(n, 2) = g[n].z; + y(j, k) += alpha * x(i, k); } +} - // copy a(r) to complex array... - // aux(2,:) = 0.0l; ? - for (n = 0;n < ncxyz;n++) +//----------------------------------------------------------------- +void dcopy(int n, double *x, int incx, double *y, int incy) +{ + // dcopy Copy x to y where x and y are n-vectors. + if (n < 1 || incx <= 0 || incy <= 0) { - aux(0, n) = 0.01; - aux(1, n) = 0.01; + cerr << "\n error in dcopy, n < 1 or incx <= 0 or incy <= 0, "; + return; } - for (n = 0;n < ncxyz;n++) + for (int ix = 0, iy = 0;ix < n && iy < n;ix += incx, iy += incy) { - aux_1d[n] = aux(1, n); + y[iy] = x[ix]; } +} // end dcopy - dcopy(ncxyz, a, 1, aux_1d, 1); - // bring a(r) to G-space, a(G) ... +//------------------------------------------------------------------ +void dcopy(int n, complex < double> *x, int incx, complex < double> *y, int incy) +{ + // zcopy Copy x to y where x and y are n-vectors. + if (n < 1 || incx <= 0 || incy <= 0) + { + cerr << "\n error in dcopy, n < 1 or incx <= 0 or incy <= 0, "; + return; + } - // cft3 (aux, nr1, nr2, nr3, nrx1, nrx2, nrx3, - 1); - // setupFFT( ncx, ncy,ncz); -#ifdef __MPI -#else -// fftchg.FFT3D(aux, -1); -#endif - // multiply by (iG) to get (\grad_ipol a)(G) ... + for (int ix = 0, iy = 0;ix < n && iy < n;ix += incx, iy += incy) + { + y[iy] = x[ix]; + } - // ga(:,:) = 0.0; - // ga.zero_out(); +} // end dcopy - for (ipol = 0;ipol < 3;ipol++) +void dcopy(int n, int *x, int incx, int *y, int incy) +{ + if (n < 1 || incx <= 0 || incy <= 0) { - // gaux(:,:) = 0.0; - gaux.zero_out(); + cerr << "\n error in dcopy, n < 1 or incx <= 0 or incy <= 0, "; + return; + } - for (n = 0;n < ngmc;n++) // do n = 1, ngm - { - gaux(0, ig2fftc[n]) = - gx(n, 0) * aux(1, ig2fftc[n]); - gaux(1, ig2fftc[n]) = gx(n, 1) * aux(0, ig2fftc[n]); - } // enddo + for (int ix = 0, iy = 0;ix < n && iy < n;ix += incx, iy += incy) + { + y[iy] = x[ix]; + } +} - if (wf.gamma_only) - { -// for(n=0;n= nr) + { + cerr << "\n error in dcopy((matrix a, int i, double *y)), " + << "nr or nc < 1 or i out of range "; + return; + } + + for (int j = 0;j < nc; j++) + { + y[j] = a(i, j); + } - //call DAXPY (nrxx, tpiba, gaux, 2, ga (ipol, 1), 3) - daxpy(ncxyz, tpiba, gaux_1d, 1, ga_1d, 1); - } // enddo +} // end dcopy - delete [] aux_1d; - aux_1d = 0; - delete [] gaux_1d; - gaux_1d = 0; - delete [] ga_1d; - ga_1d = 0; +//------------------------------------- +void dcopy(const matrix &a, + int i, + int *y) +{ + int nr, nc; + nr = a.nr; + nc = a.nc; + + if (nr < 1 || nc < 1 || i < 0 || i >= nr) + { + cerr << "\n error in dcopy(matrix a, int i, int *y)," + << " nr or nc < 1 or i out of range "; + return; + } + + for (int j = 0;j < nc; j++) + { + y[j] = (int) a(i, j); + } + +} // end dcopy + +//----------------------------------------------------------------- +void dcopy(const ComplexMatrix &a, + int i, + complex < double> *y) +{ + // dcopy Copy a(i,:) to y where a is complex matrix, and y are n-vectors. + const int nr = a.nr; + const int nc = a.nc; + + if (nr < 1 || nc < 1 || i < 0 || i >= nr) + { + cerr << "\n error in dcopy(ComplexMatrix a, int i, complex < double> *)," + << " nr or nc < 1 or i out of range "; + return; + } + + for (int j = 0;j < nc; j++) + { + y[j] = a(i, j); + } +} // end dcopy + +// ------------------------------------ +void dcopy(double *x, matrix &b, int i) +{ + // copy x to ith row of b where b is a matrix and x is a vector + int nr, nc; + nr = b.nr; + nc = b.nc; + + if (nr < 1 || nc < 1 || i < 0 || i >= nr) + { + cerr << "\n error in dcopy(double *x, matrix &b, int i), " + << "nr or nc < 1 or i out of range "; + return; + } + + for (int j = 0;j < nc; j++) + { + b(i, j) = x[j]; + } +} + +void dcopy(complex < double> *x, ComplexMatrix &b, int i) +{ + // copy x to ith row of b where b is a complex matrix and x is a vector + int nr, nc; + nr = b.nr; + nc = b.nc; + + if (nr < 1 || nc < 1 || i < 0 || i >= nr) + { + cerr << "\n error in dcopy(double> *x, ComplexMatrix &b, int i), " + << "nr or nc < 1 or i out of range "; + return; + } + + for (int j = 0;j < nc; j++) + { + b(i, j) = x[j]; + } +} + +// b(j,:) = a(i,:) +void dcopy(const matrix &a, + int i, + matrix &b, + int j) +{ + int nr, nc; + nr = b.nr; + nc = b.nc; + + if (nr < 1 || nc < 1 || i < 0 || i >= nr) + { + cerr << "\n error in dcopy(matrix a, int i,matrix &b, int ), " + << "nr or nc < 1 or i out of range "; + return; + } + + for (int k = 0;k < nc; k++) + { + b(j, k) = a(i, k); + } +} + +void dcopy(const ComplexMatrix &a, + int i, + ComplexMatrix &b, + int j) +{ + int nr, nc; + nr = b.nr; + nc = b.nc; + + if (nr < 1 || nc < 1 || i < 0 || i >= nr) + { + cerr << "\n error in dcopy(ComplexMatrix a, int i,ComplexMatrix &b, int j), " + << " nr or nc < 1 or i out of range "; + return; + } + + for (int k = 0;k < nc; k++) + { + b(j, k) = a(i, k); + } +} + +void dcopy(int n, + const ComplexMatrix &a, + int inca, + ComplexMatrix &b, + int i, + int incb) +{ + cout << "\n do nothing, in dcopy() "; +} - return; -} // end subroutine gradient -// from gradcorr.f90 -//--------------------------------------------------------------- -//void grad_dot (int nrx1, int nrx2, int nrx3, int ncx, int ncy, int ncz, -// int ncxyz, matrix a, int ngm, Vector3 < double> *g, int *nl, double alat, -// double *da) -void grad_dot(int ncx, int ncy, int ncz, int ncxyz, Vector3 < double> *a, int ngmc, - Vector3 < double> *g, int *ig2fftc, double lat0, double *da) + +//------------------------------------------------------------------- +//void dsytrf(char uplo, int n, double *a, int lda, int *ipivot, +// int *info) +void dsytrf(char , int iter_used, matrix beta, int maxter, int *iwork, + double *work, int , int &info) +{ + // dsytrf computes the factorization of a real symmetric matrix + // A using the Bunch-Kaufman diagonal pivoting method. The + // form of the factorization is + // A = U*D*U**T or A = L*D*L**T + // where U (or L) is a product of permutation and unit upper + // (lower) triangular matrices, and D is symmetric and block + // diagonal with 1-by-1 and 2-by-2 diagonal blocks. + // This is the blocked version of the algorithm, calling Level + // 3 BLAS. + + // CHARACTER * 1 UPLO + // INTEGER N, LDA, LDWORK, INFO + // INTEGER IPIVOT(*) + // DOUBLE PRECISION A(LDA,*), WORK(*) + /*********************************************************** + // UPLO (input) + // = 'U': Upper triangle of A is stored; + // = 'L': Lower triangle of A is stored. + + // N (input) The order of the matrix A. N >= 0. + + // A (input/output) + On entry, the symmetric matrix A. If UPLO = 'U', + the leading N-by-N upper triangular part of A con- + tains the upper triangular part of the matrix A, + and the strictly lower triangular part of A is not + referenced. If UPLO = 'L', the leading N-by-N + lower triangular part of A contains the lower tri- + angular part of the matrix A, and the strictly + upper triangular part of A is not referenced. + + On exit, the block diagonal matrix D and the mul- + tipliers used to obtain the factor U or L (see + below for further details). + + LDA (input) + The leading dimension of the array A. LDA >= + max(1,N). + + IPIVOT (output) + Details of the interchanges and the block struc- + ture of D. If IPIVOT(k) > 0, then rows and + columns k and IPIVOT(k) were interchanged and + D(k,k) is a 1-by-1 diagonal block. If UPLO = 'U' + and IPIVOT(k) = IPIVOT(k-1) < 0, then rows and + columns k-1 and -IPIVOT(k) were interchanged and + D(k-1:k,k-1:k) is a 2-by-2 diagonal block. If + UPLO = 'L' and IPIVOT(k) = IPIVOT(k+1) < 0, then + rows and columns k+1 and -IPIVOT(k) were inter- + changed and D(k:k+1,k:k+1) is a 2-by-2 diagonal + block. + + WORK (workspace) + On exit, if INFO = 0, WORK(1) returns the optimal + LDWORK. + + LDWORK (input) + The length of WORK. LDWORK >=1. For best perfor- + mance LDWORK >= N*NB, where NB is the block size + returned by ILAENV. + + If LDWORK = -1, then a workspace query is assumed; + the routine only calculates the optimal size of + the WORK array, returns this value as the first + entry of the WORK array, and no error message + related to LDWORK is issued by XERBLA. + + INFO (output) + = 0: successful exit + < 0: if INFO = -i, the i-th argument had an ille- + gal value + > 0: if INFO = i, D(i,i) is exactly zero. The + factorization has been completed, but the block + diagonal matrix D is exactly singular, and divi- + sion by zero will occur if it is used to solve a + system of equations. + + FURTHER DETAILS + + If UPLO = 'U', then A = U*D*U', where + U = P(n)*U(n)* ... *P(k)U(k)* ..., + i.e., U is a product of terms P(k)*U(k), where k decreases + from n to 1 in steps of 1 or 2, and D is a block diagonal + matrix with 1-by-1 and 2-by-2 diagonal blocks D(k). P(k) is + a permutation matrix as defined by IPIVOT(k), and U(k) is a + unit upper triangular matrix, such that if the diagonal + block D(k) is of order s (s = 1 or 2), then + + ( I v 0 ) k-s + U(k) = ( 0 I 0 ) s + ( 0 0 I ) n-k + k-s s n-k + + If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k- + 1,k). If s = 2, the upper triangle of D(k) overwrites A(k- + 1,k-1), A(k-1,k), and A(k,k), and v overwrites A(1:k-2,k- + 1:k). + + If UPLO = 'L', then A = L*D*L', where + L = P(1)*L(1)* ... *P(k)*L(k)* ..., + i.e., L is a product of terms P(k)*L(k), where k increases + from 1 to n in steps of 1 or 2, and D is a block diagonal + matrix with 1-by-1 and 2-by-2 diagonal blocks D(k). P(k) is + a permutation matrix as defined by IPIVOT(k), and L(k) is a + unit lower triangular matrix, such that if the diagonal + block D(k) is of order s (s = 1 or 2), then + + ( I 0 0 ) k-1 + L(k) = ( 0 I 0 ) s + ( 0 v I ) n-k-s+1 + k-1 s n-k-s+1 + + If s = 1, D(k) overwrites A(k,k), and v overwrites + A(k+1:n,k). If s = 2, the lower triangle of D(k) overwrites + A(k,k), A(k+1,k), and A(k+1,k+1), and v overwrites + A(k+2:n,k:k+1). + ******************************************************************/ + cout << "\n do nothing, in dsytrf() "; +} // end dsytrf + +//-------------------------------------------------------------------- +//void dsytri(char uplo, int n, double *a, int lda, int +// *ipivot, int *info) +void dsytri(char, int iter_used, matrix beta, int maxter, int *iwork, + double *work, int &info) { - //----------------------------------------------------------- + cout << "\n do nothing, in dsytri() "; + // dsytri computes the inverse of a real symmetric indefinite + // matrix A using the factorization A = U*D*U**T or A = + // L*D*L**T computed by DSYTRF. + + // CHARACTER * 1 UPLO + // INTEGER N, LDA, INFO + // INTEGER IPIVOT(*) + // DOUBLE PRECISION A(LDA,*), WORK(*) + + /************************************************************** + UPLO (input) + Specifies whether the details of the factorization + are stored as an upper or lower triangular matrix. + = 'U': Upper triangular, form is A = U*D*U**T; + = 'L': Lower triangular, form is A = L*D*L**T. + + N (input) The order of the matrix A. N >= 0. + + A (input/output) + On entry, the block diagonal matrix D and the mul- + tipliers used to obtain the factor U or L as com- + puted by DSYTRF. + + On exit, if INFO = 0, the (symmetric) inverse of + the original matrix. If UPLO = 'U', the upper + triangular part of the inverse is formed and the + part of A below the diagonal is not referenced; if + UPLO = 'L' the lower triangular part of the + inverse is formed and the part of A above the + diagonal is not referenced. + + LDA (input) + The leading dimension of the array A. LDA >= + max(1,N). + + IPIVOT (input) + Details of the interchanges and the block struc- + ture of D as determined by DSYTRF. + + WORK (workspace) + dimension(N) + + INFO (output) + = 0: successful exit + < 0: if INFO = -i, the i-th argument had an ille- + gal value + > 0: if INFO = i, D(i,i) = 0; the matrix is singu- + lar and its inverse could not be computed. + *****************************************************************/ +} // end dsytri + +//--------------------------------------------------------- +double ddot(int n, + double *x, + int incx, + double *y, + int incy) +{ + // ddot compute the dot product of x and y where x and y are + // n-vectors. + double prod; - // Calculates da = \sum_i \grad_i a_i in R-space + if (n < 1 || incx <= 0 || incy <= 0) + { + cerr << "\n error in ddot, n < 1 or incx <= 0 or incy <= 0, "; + return 0; + } - // use gvect, only: nlm - // use wvfct, only: gamma_only + prod = 0.0; - // integer :: nrx1, nrx2, nrx3, nr1, nr2, nr3, ncxyz, ngm, nl (ngm); - // real(kind=DP) :: a (3, ncxyz), g (3, ngm), da (ncxyz), alat; - int n, ipol; - matrix aux; // (:,:), - matrix gaux; // (:,:); - aux.create(2, ncxyz); // allocate (aux( 2,ncxyz)); - gaux.create(2, ncxyz); // allocate (gaux(2,ncxyz)); + for (int ix = 0, iy = 0;ix < n && iy < n;ix += incx, iy += incy) + { + prod += x[ix] * y[iy]; + } - double tpiba= TWO_PI / lat0; - matrix gx; - gx.create(ngmc, 3); + return prod; +} // end ddot - for (n = 0;n < ngmc;n++) +//----------------------------------------------------------------------- +complex < double> ddot(int n, + complex < double> *x, + int incx, + complex < double> *y, + int incy) +{ + // zdotc compute the dot product of conjg(x) and y where x and + // y are n-vectors. + complex < double> prod; + + if (n < 1 || incx <= 0 || incy <= 0) { - gx(n, 0) = g[n].x; - gx(n, 1) = g[n].y; - gx(n, 2) = g[n].z; + cerr << "\n error in ddot, n < 1 or incx <= 0 or incy <= 0, "; + return 0; } - for (ipol = 0;ipol < 3;ipol++) // do ipol = 1, 3 + prod = complex < double>(0.0, 0.0); + + for (int ix = 0, iy = 0;ix < n && iy < n;ix += incx, iy += incy) { - // copy a(ipol,r) to a complex array... + prod += conj(x[ix]) * y[iy]; + } + + return prod; +} // end zdotc - for (n = 0;n < ncxyz;n++) +// ----------------------------------------------------------------------- +complex < double> ddot(const ComplexMatrix &a, + int i, + complex < double> *y) +{ + //compute the dot product of i_th row of matrix a and y where + // y are a vector. + int nr, nc; + nr = a.nr; + nc = a.nc; + + if (nr <= 1 || nc <= 1 || i < 0 || i >= nr) + { + cout << "\n error in ddot, nr or nc < 1 or i out of range "; + return 0; + } + + complex < double> z; + + z = complex < double> (0, 0); + + for (int k = 0; k < nc; k++) + { + z += conj(a(i, k)) * y[k]; + } + + return z; +} + +//-------------------------------- +double ddot(const matrix &a, + int i, + double *y) +{ + int nr, nc; + nr = a.nr; + nc = a.nc; + + if (nr <= 1 || nc <= 1 || i < 0 || i >= nr) + { + cout << "\n error in ddot, nr or nc < 1 or i out of range "; + return 0; + } + + double z = 0; + + for (int k = 0; k < nc; k++) + { + z += a(i, k) * y[k]; + } + + return z; +} + +double ddot(const matrix &a, + int i, + const matrix &b, + int j) +{ + int nr, nc; + nr = a.nr; + nc = a.nc; + + if (nr <= 1 || nc <= 1 || i < 0 || i >= nr || + j < 0 || j >= nr) + { + cout << "\n error in ddot, nr or nc < 1 or i or j out of range "; + return 0; + } + + double z = 0; + + for (int k = 0; k < nc; k++) + { + z += a(i, k) * b(j, k); + } + + return z; +} + +double dnrm2(const int n, const double *x, const int incx) +{ + // compute Euclidean length (12 norm) of vector x, + if (n < 0 || incx <= 0) + { + cerr << "\n error in dnrm2, n < 0 or incx <= 0, "; + return 0; + } + if (n == 0) + { + return 0; + } + + double norm2=0.0; + for (int ix=0; ix= nr) + { + cerr << "\n error in dnrm2, nr or nc < 1 or i out of range "; + return 0; + } + + for (int j = 0;j < nc; j++) + { + norm2 += a(i, j) * a(i, j); + } + + return sqrt(norm2); +} + +void zgemm(char tra, + char trb, + int m, + int n, + int k, + complex < double> alpha, + const complex *a, + int lda, + const ComplexMatrix &b, + int ldb, + complex < double> beta, + complex *c, + int ldc) +{ + TITLE("myfunc5","zgemm1"); + //int nra=1; + int nca=k; + int nrb=b.nr; + int ncb=b.nc; + int nrc=1; + int ncc=n; + + //double alpha0[2] = {alpha.real(), alpha.imag()}; + //double beta0[2] = {beta.real(), beta.imag()}; + + double *aux, *bux, *cux; //HLX: bug fixed on 12/20/2006 + aux = new double[2*nca]; + bux = new double[2*nrb*ncb]; + cux = new double[2*ncc]; + + int i; + int j; + int ij; + + for (i = 0; i < nca; i++) + { + ij = 2*i; + aux[ij] = a[i].real(); + aux[ij+1] = a[i].imag(); + } + for (i = 0; i < ncb; i++) + { + for (j = 0; j < nrb; j++) { - aux(0, n) = 0.0; + ij = 2 * (j + i * nrb); + bux[ij] = b(j, i).real(); + bux[ij+1] = b(j, i).imag(); } + } - //dcopy (ncxyz, a (ipol, 1), 3, aux, 2); - //if(ipol = 0){ - if (ipol == 0) //mohan modify 2007-01-23 + + for (i = 0; i < ncc; i++) + { + for (j = 0; j < nrc; j++) { - for (n = 0; n < ncxyz; n++) - { - aux(0, n) = a[n].x; - } + ij = 2 * i; + cux[ij] = c[i].real(); + cux[ij+1] = c[i].imag(); + } + } - //}else if(ipol = 1){ + //WARNING_QUIT("reset zgemm","reset zgemm"); +// zgemm_(&tra, &trb, &m, &n, &k, alpha0, aux, &lda, bux, &ldb, beta0, cux, &ldc); + WARNING_QUIT("myfunc_5::zgemm","please don't ever use it again."); + + for (i = 0; i < ncc; i++) + { + ij = 2 * i * ldc; + c[i] = cux[ij] + complex< double>(0, 1) * cux[ij+1]; + } + + delete [] aux; + delete [] bux; + delete [] cux; +} + + +void zgemm(char tra, + char trb, + int m, + int n, + int k, + complex < double> alpha, + const complex *a, + int lda, + const ComplexMatrix &b, + int ldb, + complex < double> beta, + ComplexMatrix &c, + int ldc) +{ + TITLE("myfunc5","zgemm2"); + //int nra = 1; + int nca = k; + int nrb = b.nr; + int ncb = b.nc; + int nrc = c.nr; + int ncc = c.nc; + + //double alpha0[2] = {alpha.real(), alpha.imag()}; + //double beta0[2] = {beta.real(), beta.imag()}; + + double *aux, *bux, *cux; //HLX: bug fixed on 12/20/2006 + aux = new double[2*nca]; + bux = new double[2*nrb*ncb]; + cux = new double[2*nrc*ncc]; + + int i; + int j; + int ij; + + for (i = 0; i < nca; i++) + { + ij = 2*i; + aux[ij] = a[i].real(); + aux[ij+1] = a[i].imag(); + } + for (i = 0; i < ncb; i++) + { + for (j = 0; j < nrb; j++) + { + ij = 2 * (j + i * nrb); + bux[ij] = b(j, i).real(); + bux[ij+1] = b(j, i).imag(); + } + } + + + for (i = 0; i < ncc; i++) + { + for (j = 0; j < nrc; j++) + { + ij = 2 * (j + i * nrc); + cux[ij] = c(j, i).real(); + cux[ij+1] = c(j, i).imag(); + } + } + + //WARNING_QUIT("reset zgemm","reset zgemm"); + //zgemm_(&tra, &trb, &m, &n, &k, alpha0, aux, &lda, bux, &ldb, beta0, cux, &ldc); + WARNING_QUIT("myfunc_5::zgemm","please don't ever use it again."); + + for (i = 0; i < ncc; i++) + { + for (j = 0; j < nrc; j++) + { + ij = 2*(j+i*ldc); + c(j,i) = cux[ij] + complex< double>(0,1) * cux[ij+1]; + // cout< alpha, + const ComplexMatrix &a, + int lda, + const ComplexMatrix &b, + int ldb, + complex < double> beta, + ComplexMatrix &c, + int ldc) +{ +// TITLE("myfunc5","zgemm3"); + int nra, nca, nrb, ncb, nrc, ncc ; + nra = a.nr, nca = a.nc; + nrb = b.nr, ncb = b.nc; + nrc = c.nr, ncc = c.nc; + + //double alpha0[2] = {alpha.real(), alpha.imag()}; + //double beta0[2] = {beta.real(), beta.imag()}; + + double *aux, *bux, *cux; //HLX: bug fixed on 12/20/2006 + aux = new double[2*nra*nca]; + bux = new double[2*nrb*ncb]; + cux = new double[2*nrc*ncc]; + + int i; + int j; + int ij; + + for (i = 0; i < nca; i++) + { + for (j = 0; j < nra; j++) { - for (n = 0; n < ncxyz; n++) - { - aux(0, n) = a[n].y; - } + ij = 2 * (j + i * nra); + aux[ij] = a(j, i).real(); + aux[ij+1] = a(j, i).imag(); } - else + } + + for (i = 0; i < ncb; i++) + { + for (j = 0; j < nrb; j++) { - for (n = 0; n < ncxyz; n++) - { - aux(0, n) = a[n].z; - } + ij = 2 * (j + i * nrb); + bux[ij] = b(j, i).real(); + bux[ij+1] = b(j, i).imag(); } + } + - // bring a(ipol,r) to G-space, a(G) ... - // cft3 (aux, nr1, nr2, nr3, nrx1, nrx2, nrx3, - 1); -// setupFFT3D( ncx, ncy,ncz); -// -#ifdef __MPI -#else - // fftchg.FFT3D(aux, -1); -#endif - - // multiply by (iG) to get (\grad_ipol a)(G) ... - for (n = 0;n < ngmc;n++) // do n = 1, ngm + for (i = 0; i < ncc; i++) + { + for (j = 0; j < nrc; j++) { - gaux(0, ig2fftc[n]) -= gx(n, ipol) * aux(1, ig2fftc[n]); - gaux(1, ig2fftc[n]) += gx(n, ipol) * aux(0, ig2fftc[n]); - } // enddo - } // enddo + ij = 2 * (j + i * nrc); + cux[ij] = c(j, i).real(); + cux[ij+1] = c(j, i).imag(); + } + } + + //WARNING_QUIT("reset zgemm","reset zgemm"); + //zgemm_(&tra, &trb, &m, &n, &k, alpha0, aux, &lda, bux, &ldb, beta0, cux, &ldc); + WARNING_QUIT("myfunc_5::zgemm","please don't ever use it again."); - if (wf.gamma_only) + for (i = 0; i < ncc; i++) { -// for(n=0;n(0, 1) * cux[ij+1]; + } + } + + delete [] aux; + + delete [] bux; + delete [] cux; +}//end zgemm + + +// C = alpha * op(A) * op(B) + beta * C +void dgemm(char tra, char trb, int m, int n, int k, double alpha, + const matrix a, int lda, const matrix b, int ldb, double beta, + matrix &c, int ldc) +{ +// cout << "\n === ZGEMM() ===" << endl; + matrix a1; + + if (tra == 'n' || tra == 'N') + a1.create(a.nr, a.nc); + else + a1.create(a.nc, a.nr); + +// cout << "\n a1.nr = " << a1.nr +// << " a1.nc = " << a1.nc << endl; + + c = beta * c; + + if (tra == 'n' || tra == 'N') + a1 = alpha * a; + else + a1 = alpha * transpose(a); - // bring back to R-space, (\grad_ipol a)(r) ... - // cft3 (gaux, nr1, nr2, nr3, nrx1, nrx2, nrx3, 1); -// setupFFT( ncx, ncy,ncz); -// + if (trb == 'n' || trb == 'N') + c += a1 * b; + else + c += a1 * transpose(b); + +// a1.freemem(); +// cout << "\n end ZGEMM() " << endl; + return; +}//end dgemm + +int ILAENV(int ispec, char *name, char *opts, + const int n1, const int n2, const int n3, const int n4) +{ + const int nb = ilaenv_(&ispec, name, opts, &n1, &n2, &n3, &n4); + return nb; +} + +void ZHPEV(int , + complex < double> *hp, + double *e, + ComplexMatrix &v, + int ldh, + int n, + complex < double> *aux, + int naux) +{ + cout << "\n do nothing, in ZHPEV() "; +} + +complex < double> ZDOTU(int nstart, + complex < double>, + int , + complex < double> *psi, + int npwx) +{ + cout << "\n do nothing in ZDOTU(), only return ZERO,"; + return ZERO; +} + +void zgemv(char , + int , + int , + complex < double> alpha , + ComplexMatrix overlap, + int , + complex < double> swfcatom , + int npwx, + complex < double> , + ComplexMatrix work, int) +{ + cout << "\n do nothing, in dgemv () "; +} + +/* +void ZHEGVX(int itype, + char jobz, + char range , + char uplo , + const int n, + const ComplexMatrix &a, + const int lda, + const ComplexMatrix &b, + const int ldb, + double vl, + double vu, + int il , + int iu, + double abstol, + int &m, + double *w, + ComplexMatrix &z, + const int ldz, + double *work, + int lwork, + double *rwork, + int *iwork, + int *ifail, + int &info ) +{ +// TITLE("myfunc5","ZHEGVX"); + double *aux, *bux, *zux; + aux = new double[2*lda*n];//mohan fix + --> * 2007-10-22 + bux = new double[2*ldb*n]; + zux = new double[2*ldz*iu]; // mohan fix 2007-10-15 + int i, j; + + cout << "\n n = " << n; + cout << "\n iu = " << iu << endl; -#ifdef __MPI -#else -// fftchg.FFT3D(gaux, 1); -#endif + for (i = 0;i < n;i++) + { + for (j = 0;j < lda;j++) + { + aux[2*(j+i*lda)] = a(j, i).real(); + aux[2*(j+i*lda)+1] = a(j, i).imag(); + } + } - // ...add the factor 2\pi/a missing in the definition of G and sum -// tpiba = tpi / alat; - for (n = 0;n < ncxyz;n++) // do n=1,ncxyz + for (i = 0; i < n; i++) { - da[n] = gaux(n, 0) * tpiba; - } // end do + for (j = 0; j < ldb; j++) + { + bux[2*(j+i*ldb)] = b(j, i).real(); + bux[2*(j+i*ldb)+1] = b(j, i).imag(); + } + } +// BLOCK_HERE("adf"); + zhegvx_(&itype, &jobz, &range, &uplo, &n, aux, &lda, bux, &ldb, &vl, &vu, &il, &iu, &abstol, + &m, w, zux, &ldz, work, &lwork, rwork, iwork, ifail, &info); + //BLOCK_HERE("adf2"); + + for (i = 0;i < iu;i++) + { + for (j = 0;j < ldz;j++) + { + z(j, i) = zux[2*(j+i*ldz)] + complex< double>(0, 1) * zux[2*(j+i*ldz)+1]; + } + } + delete[] aux; + delete[] bux; + delete[] zux; return; -} // end subroutine grad_dot +} +*/ + diff --git a/ABACUS.develop/source/src_pw/xc_4.cpp b/ABACUS.develop/source/src_pw/xc_4.cpp deleted file mode 100644 index b2eccaf0d0..0000000000 --- a/ABACUS.develop/source/src_pw/xc_4.cpp +++ /dev/null @@ -1,1194 +0,0 @@ -/* myfunc.cpp */ -// from LPACK -#include -#include -#include -#include -#include - -using namespace std; -#include "myfunc.h" -#include "src_global/blas_connector.h" -#include "../src_pw/global.h" - -// dscal compute y = alpha * y, where alpha is a scalar and -void dscal(const int n,const double &alpha,double *y,const int incy) -{ - if (incy <= 0 || n < 1) - { - cout << "\n error in dscal,incy <= 0 or n < 1"; - return; - } - - for (int i = 0; i < n; i += incy) - { - y[i] *= alpha; - } - - return; -} - -// a(i,:) = alpha * a(i,:) where a is a matrix -// i line -void dscal(const double &alpha,matrix &a,const int i) -{ - int nc = a.nc; - int nr = a.nr; - - if (nc <= 0 || nr <= 0 || i < 0 || i >= nr) - { - cerr << "\n error in dscal,nc <= 0 or nr <= 0 or i < 0 or i >= nr, "; - return; - } - - for (int j = 0;j < nc;j++) - { - a(i,j) = a(i,j) * alpha; - } -} - -// daxpy compute y := alpha * x + y where alpha is a scalar and x and y -void daxpy(const int n, const double &alpha, const double *x, const int incx, double *y, const int incy) -{ - if (n < 1 || incy <= 0 || incx <= 0) - { - cerr << "\n error in daxpy, n < 1 or incx <= 0 or incy <= 0, "; - return; - } - for (int ix = 0, iy = 0;ix < n && iy < n;ix += incx, iy += incy) - { - y[iy] += alpha * x[ix]; - } - return; -} - -void zaxpy(int n, double alpha, complex < double> *x, int incx, complex < double> *y, int incy) -{ - - if (n < 1 || incy <= 0 || incx <= 0) - { - cerr << "\n error in daxpy, n < 1 or incx <= 0 or incy <= 0, "; - return; - } - - for (int ix = 0, iy = 0;ix < n && iy < n;ix += incx, iy += incy) // y := alpha * x + y - { - y[iy] += alpha * x[ix]; - } -} - - -//------------------------------------------------------------- -void zaxpy(int n, complex < double> alpha, complex < double> *x, - int incx, complex < double> *y, int incy) -{ - // zaxpy compute y := alpha * x + y where alpha is a scalar and - // x and y are n-vectors. - // DOUBLE COMPLEX ALPHA - // DOUBLE COMPLEX X(*), Y(*) - // INTEGER N, INCX, INCY - - // ARGUMENTS - - // N (input) - // On entry, N specifies the number of elements in - // the vector. N must be at least one for the sub- - // routine to have any visible effect. Unchanged on - // exit. - - // ALPHA (input) - // On entry, ALPHA specifies the scalar alpha. - // Unchanged on exit. - - // X (input) - // array of DIMENSION at least ( 1 + ( n - 1 )*abs( - // INCX ) ). Before entry, the incremented array X - // must contain the vector x. Unchanged on exit. - - // INCX (input) - // On entry, INCX specifies the increment for the - // elements of X. Unchanged on exit. - - // Y (input/output) - // array of DIMENSION at least ( 1 + ( n - 1 )*abs( - // INCY ) ). On entry, the incremented array Y must - // contain the vector y. On exit, Y is overwritten by - // the updated vector y. - - // INCY (input) - // On entry, INCY specifies the increment for the - // elements of Y. Unchanged on exit. - - if (n < 1 || incy <= 0 || incx <= 0) - { - cerr << "\n error in daxpy, n < 1 or incx <= 0 or incy <= 0, "; - return; - } - - for (int ix = 0, iy = 0;ix < n && iy < n;ix += incx, iy += incy) // y := alpha * x + y - { - y[iy] += alpha * x[ix]; - } - -} // end zaxpy - -// y(i,:) = alpha * x + y(i,:) where y is a matrix -void zaxpy(double alpha, - complex < double> *x, - ComplexMatrix &y, - int i) -{ - int nr, nc; - nr = y.nr; - nc = y.nc; - - if (nr < 1 || nc < 1 || i < 0 || i >= nr) - { - cerr << "\n error in daxpy, nr < 1 or nc < 1 or i out of range, "; - return; - } - - for (int j = 0;j < nc;j ++) // y := alpha * x + y - { - y(i, j) += alpha * x[j]; - } - -// cout << "\n End daxpy() " << endl; -} - -// y = alpha * x(i,:) + y -void zaxpy(double alpha, - const ComplexMatrix &x, - int i, - complex < double> *y) -{ - int nr, nc; - nr = x.nr; - nc = x.nc; - - if (nr < 1 || nc < 1 || i < 0 || i >= nr) - { - cerr << "\n error in daxpy, nr < 1 or nc < 1 or i out of range, "; - return; - } - - for (int j = 0;j < nc;j ++) // y := alpha * x + y - { - y[j] += alpha * x(i, j); - } -} - -void zaxpy(complex < double> alpha, - const ComplexMatrix &x, - int i, - complex < double> *y) -{ - int nr, nc; - nr = x.nr; - nc = x.nc; - - if (nr < 1 || nc < 1 || i < 0 || i >= nr) - { - cerr << "\n error in daxpy, nr < 1 or nc < 1 or i out of range, "; - return; - } - - for (int j = 0;j < nc;j ++) // y := alpha * x + y - { - y[j] += alpha * x(i, j); - } -} - -// y(j,:) = alpha * x(i,:) + y(j,:) -void zaxpy(complex < double> alpha, - const ComplexMatrix &x, - int i, - ComplexMatrix &y, - int j) -{ - int nr, nc; - nr = y.nr; - nc = y.nc; - - if (nr < 1 || nc < 1 || i < 0 || i >= nr || j < 0 || j >= nr) - { - cerr << "\n error in daxpy, nr < 1 or nc < 1 or i or j out of range, "; - return; - } - - for (int k = 0;k < nc;k ++) // y := alpha * x + y - { - y(j, k) += alpha * x(i, k); - } -} - -//----------------------------------------------------------------- -void dcopy(int n, double *x, int incx, double *y, int incy) -{ - // dcopy Copy x to y where x and y are n-vectors. - if (n < 1 || incx <= 0 || incy <= 0) - { - cerr << "\n error in dcopy, n < 1 or incx <= 0 or incy <= 0, "; - return; - } - - for (int ix = 0, iy = 0;ix < n && iy < n;ix += incx, iy += incy) - { - y[iy] = x[ix]; - } -} // end dcopy - -//------------------------------------------------------------------ -void dcopy(int n, complex < double> *x, int incx, complex < double> *y, int incy) -{ - // zcopy Copy x to y where x and y are n-vectors. - if (n < 1 || incx <= 0 || incy <= 0) - { - cerr << "\n error in dcopy, n < 1 or incx <= 0 or incy <= 0, "; - return; - } - - for (int ix = 0, iy = 0;ix < n && iy < n;ix += incx, iy += incy) - { - y[iy] = x[ix]; - } - -} // end dcopy - -void dcopy(int n, int *x, int incx, int *y, int incy) -{ - if (n < 1 || incx <= 0 || incy <= 0) - { - cerr << "\n error in dcopy, n < 1 or incx <= 0 or incy <= 0, "; - return; - } - - for (int ix = 0, iy = 0;ix < n && iy < n;ix += incx, iy += incy) - { - y[iy] = x[ix]; - } -} - -/* Copy a(i,:) to y where x is matrix, and y are n-vectors. */ -void dcopy(const matrix &a, - int i, - double *y) -{ - int nr, nc; - nr = a.nr; - nc = a.nc; - - if (nr < 1 || nc < 1 || i < 0 || i >= nr) - { - cerr << "\n error in dcopy((matrix a, int i, double *y)), " - << "nr or nc < 1 or i out of range "; - return; - } - - for (int j = 0;j < nc; j++) - { - y[j] = a(i, j); - } - -} // end dcopy - -//------------------------------------- -void dcopy(const matrix &a, - int i, - int *y) -{ - int nr, nc; - nr = a.nr; - nc = a.nc; - - if (nr < 1 || nc < 1 || i < 0 || i >= nr) - { - cerr << "\n error in dcopy(matrix a, int i, int *y)," - << " nr or nc < 1 or i out of range "; - return; - } - - for (int j = 0;j < nc; j++) - { - y[j] = (int) a(i, j); - } - -} // end dcopy - -//----------------------------------------------------------------- -void dcopy(const ComplexMatrix &a, - int i, - complex < double> *y) -{ - // dcopy Copy a(i,:) to y where a is complex matrix, and y are n-vectors. - const int nr = a.nr; - const int nc = a.nc; - - if (nr < 1 || nc < 1 || i < 0 || i >= nr) - { - cerr << "\n error in dcopy(ComplexMatrix a, int i, complex < double> *)," - << " nr or nc < 1 or i out of range "; - return; - } - - for (int j = 0;j < nc; j++) - { - y[j] = a(i, j); - } -} // end dcopy - -// ------------------------------------ -void dcopy(double *x, matrix &b, int i) -{ - // copy x to ith row of b where b is a matrix and x is a vector - int nr, nc; - nr = b.nr; - nc = b.nc; - - if (nr < 1 || nc < 1 || i < 0 || i >= nr) - { - cerr << "\n error in dcopy(double *x, matrix &b, int i), " - << "nr or nc < 1 or i out of range "; - return; - } - - for (int j = 0;j < nc; j++) - { - b(i, j) = x[j]; - } -} - -void dcopy(complex < double> *x, ComplexMatrix &b, int i) -{ - // copy x to ith row of b where b is a complex matrix and x is a vector - int nr, nc; - nr = b.nr; - nc = b.nc; - - if (nr < 1 || nc < 1 || i < 0 || i >= nr) - { - cerr << "\n error in dcopy(double> *x, ComplexMatrix &b, int i), " - << "nr or nc < 1 or i out of range "; - return; - } - - for (int j = 0;j < nc; j++) - { - b(i, j) = x[j]; - } -} - -// b(j,:) = a(i,:) -void dcopy(const matrix &a, - int i, - matrix &b, - int j) -{ - int nr, nc; - nr = b.nr; - nc = b.nc; - - if (nr < 1 || nc < 1 || i < 0 || i >= nr) - { - cerr << "\n error in dcopy(matrix a, int i,matrix &b, int ), " - << "nr or nc < 1 or i out of range "; - return; - } - - for (int k = 0;k < nc; k++) - { - b(j, k) = a(i, k); - } -} - -void dcopy(const ComplexMatrix &a, - int i, - ComplexMatrix &b, - int j) -{ - int nr, nc; - nr = b.nr; - nc = b.nc; - - if (nr < 1 || nc < 1 || i < 0 || i >= nr) - { - cerr << "\n error in dcopy(ComplexMatrix a, int i,ComplexMatrix &b, int j), " - << " nr or nc < 1 or i out of range "; - return; - } - - for (int k = 0;k < nc; k++) - { - b(j, k) = a(i, k); - } -} - -void dcopy(int n, - const ComplexMatrix &a, - int inca, - ComplexMatrix &b, - int i, - int incb) -{ - cout << "\n do nothing, in dcopy() "; -} - - - -//------------------------------------------------------------------- -//void dsytrf(char uplo, int n, double *a, int lda, int *ipivot, -// int *info) -void dsytrf(char , int iter_used, matrix beta, int maxter, int *iwork, - double *work, int , int &info) -{ - // dsytrf computes the factorization of a real symmetric matrix - // A using the Bunch-Kaufman diagonal pivoting method. The - // form of the factorization is - // A = U*D*U**T or A = L*D*L**T - // where U (or L) is a product of permutation and unit upper - // (lower) triangular matrices, and D is symmetric and block - // diagonal with 1-by-1 and 2-by-2 diagonal blocks. - // This is the blocked version of the algorithm, calling Level - // 3 BLAS. - - // CHARACTER * 1 UPLO - // INTEGER N, LDA, LDWORK, INFO - // INTEGER IPIVOT(*) - // DOUBLE PRECISION A(LDA,*), WORK(*) - /*********************************************************** - // UPLO (input) - // = 'U': Upper triangle of A is stored; - // = 'L': Lower triangle of A is stored. - - // N (input) The order of the matrix A. N >= 0. - - // A (input/output) - On entry, the symmetric matrix A. If UPLO = 'U', - the leading N-by-N upper triangular part of A con- - tains the upper triangular part of the matrix A, - and the strictly lower triangular part of A is not - referenced. If UPLO = 'L', the leading N-by-N - lower triangular part of A contains the lower tri- - angular part of the matrix A, and the strictly - upper triangular part of A is not referenced. - - On exit, the block diagonal matrix D and the mul- - tipliers used to obtain the factor U or L (see - below for further details). - - LDA (input) - The leading dimension of the array A. LDA >= - max(1,N). - - IPIVOT (output) - Details of the interchanges and the block struc- - ture of D. If IPIVOT(k) > 0, then rows and - columns k and IPIVOT(k) were interchanged and - D(k,k) is a 1-by-1 diagonal block. If UPLO = 'U' - and IPIVOT(k) = IPIVOT(k-1) < 0, then rows and - columns k-1 and -IPIVOT(k) were interchanged and - D(k-1:k,k-1:k) is a 2-by-2 diagonal block. If - UPLO = 'L' and IPIVOT(k) = IPIVOT(k+1) < 0, then - rows and columns k+1 and -IPIVOT(k) were inter- - changed and D(k:k+1,k:k+1) is a 2-by-2 diagonal - block. - - WORK (workspace) - On exit, if INFO = 0, WORK(1) returns the optimal - LDWORK. - - LDWORK (input) - The length of WORK. LDWORK >=1. For best perfor- - mance LDWORK >= N*NB, where NB is the block size - returned by ILAENV. - - If LDWORK = -1, then a workspace query is assumed; - the routine only calculates the optimal size of - the WORK array, returns this value as the first - entry of the WORK array, and no error message - related to LDWORK is issued by XERBLA. - - INFO (output) - = 0: successful exit - < 0: if INFO = -i, the i-th argument had an ille- - gal value - > 0: if INFO = i, D(i,i) is exactly zero. The - factorization has been completed, but the block - diagonal matrix D is exactly singular, and divi- - sion by zero will occur if it is used to solve a - system of equations. - - FURTHER DETAILS - - If UPLO = 'U', then A = U*D*U', where - U = P(n)*U(n)* ... *P(k)U(k)* ..., - i.e., U is a product of terms P(k)*U(k), where k decreases - from n to 1 in steps of 1 or 2, and D is a block diagonal - matrix with 1-by-1 and 2-by-2 diagonal blocks D(k). P(k) is - a permutation matrix as defined by IPIVOT(k), and U(k) is a - unit upper triangular matrix, such that if the diagonal - block D(k) is of order s (s = 1 or 2), then - - ( I v 0 ) k-s - U(k) = ( 0 I 0 ) s - ( 0 0 I ) n-k - k-s s n-k - - If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k- - 1,k). If s = 2, the upper triangle of D(k) overwrites A(k- - 1,k-1), A(k-1,k), and A(k,k), and v overwrites A(1:k-2,k- - 1:k). - - If UPLO = 'L', then A = L*D*L', where - L = P(1)*L(1)* ... *P(k)*L(k)* ..., - i.e., L is a product of terms P(k)*L(k), where k increases - from 1 to n in steps of 1 or 2, and D is a block diagonal - matrix with 1-by-1 and 2-by-2 diagonal blocks D(k). P(k) is - a permutation matrix as defined by IPIVOT(k), and L(k) is a - unit lower triangular matrix, such that if the diagonal - block D(k) is of order s (s = 1 or 2), then - - ( I 0 0 ) k-1 - L(k) = ( 0 I 0 ) s - ( 0 v I ) n-k-s+1 - k-1 s n-k-s+1 - - If s = 1, D(k) overwrites A(k,k), and v overwrites - A(k+1:n,k). If s = 2, the lower triangle of D(k) overwrites - A(k,k), A(k+1,k), and A(k+1,k+1), and v overwrites - A(k+2:n,k:k+1). - ******************************************************************/ - cout << "\n do nothing, in dsytrf() "; -} // end dsytrf - -//-------------------------------------------------------------------- -//void dsytri(char uplo, int n, double *a, int lda, int -// *ipivot, int *info) -void dsytri(char, int iter_used, matrix beta, int maxter, int *iwork, - double *work, int &info) -{ - cout << "\n do nothing, in dsytri() "; - // dsytri computes the inverse of a real symmetric indefinite - // matrix A using the factorization A = U*D*U**T or A = - // L*D*L**T computed by DSYTRF. - - // CHARACTER * 1 UPLO - // INTEGER N, LDA, INFO - // INTEGER IPIVOT(*) - // DOUBLE PRECISION A(LDA,*), WORK(*) - - /************************************************************** - UPLO (input) - Specifies whether the details of the factorization - are stored as an upper or lower triangular matrix. - = 'U': Upper triangular, form is A = U*D*U**T; - = 'L': Lower triangular, form is A = L*D*L**T. - - N (input) The order of the matrix A. N >= 0. - - A (input/output) - On entry, the block diagonal matrix D and the mul- - tipliers used to obtain the factor U or L as com- - puted by DSYTRF. - - On exit, if INFO = 0, the (symmetric) inverse of - the original matrix. If UPLO = 'U', the upper - triangular part of the inverse is formed and the - part of A below the diagonal is not referenced; if - UPLO = 'L' the lower triangular part of the - inverse is formed and the part of A above the - diagonal is not referenced. - - LDA (input) - The leading dimension of the array A. LDA >= - max(1,N). - - IPIVOT (input) - Details of the interchanges and the block struc- - ture of D as determined by DSYTRF. - - WORK (workspace) - dimension(N) - - INFO (output) - = 0: successful exit - < 0: if INFO = -i, the i-th argument had an ille- - gal value - > 0: if INFO = i, D(i,i) = 0; the matrix is singu- - lar and its inverse could not be computed. - *****************************************************************/ -} // end dsytri - -//--------------------------------------------------------- -double ddot(int n, - double *x, - int incx, - double *y, - int incy) -{ - // ddot compute the dot product of x and y where x and y are - // n-vectors. - double prod; - - if (n < 1 || incx <= 0 || incy <= 0) - { - cerr << "\n error in ddot, n < 1 or incx <= 0 or incy <= 0, "; - return 0; - } - - prod = 0.0; - - for (int ix = 0, iy = 0;ix < n && iy < n;ix += incx, iy += incy) - { - prod += x[ix] * y[iy]; - } - - return prod; -} // end ddot - -//----------------------------------------------------------------------- -complex < double> ddot(int n, - complex < double> *x, - int incx, - complex < double> *y, - int incy) -{ - // zdotc compute the dot product of conjg(x) and y where x and - // y are n-vectors. - complex < double> prod; - - if (n < 1 || incx <= 0 || incy <= 0) - { - cerr << "\n error in ddot, n < 1 or incx <= 0 or incy <= 0, "; - return 0; - } - - prod = complex < double>(0.0, 0.0); - - for (int ix = 0, iy = 0;ix < n && iy < n;ix += incx, iy += incy) - { - prod += conj(x[ix]) * y[iy]; - } - - return prod; -} // end zdotc - -// ----------------------------------------------------------------------- -complex < double> ddot(const ComplexMatrix &a, - int i, - complex < double> *y) -{ - //compute the dot product of i_th row of matrix a and y where - // y are a vector. - int nr, nc; - nr = a.nr; - nc = a.nc; - - if (nr <= 1 || nc <= 1 || i < 0 || i >= nr) - { - cout << "\n error in ddot, nr or nc < 1 or i out of range "; - return 0; - } - - complex < double> z; - - z = complex < double> (0, 0); - - for (int k = 0; k < nc; k++) - { - z += conj(a(i, k)) * y[k]; - } - - return z; -} - -//-------------------------------- -double ddot(const matrix &a, - int i, - double *y) -{ - int nr, nc; - nr = a.nr; - nc = a.nc; - - if (nr <= 1 || nc <= 1 || i < 0 || i >= nr) - { - cout << "\n error in ddot, nr or nc < 1 or i out of range "; - return 0; - } - - double z = 0; - - for (int k = 0; k < nc; k++) - { - z += a(i, k) * y[k]; - } - - return z; -} - -double ddot(const matrix &a, - int i, - const matrix &b, - int j) -{ - int nr, nc; - nr = a.nr; - nc = a.nc; - - if (nr <= 1 || nc <= 1 || i < 0 || i >= nr || - j < 0 || j >= nr) - { - cout << "\n error in ddot, nr or nc < 1 or i or j out of range "; - return 0; - } - - double z = 0; - - for (int k = 0; k < nc; k++) - { - z += a(i, k) * b(j, k); - } - - return z; -} - -double dnrm2(const int n, const double *x, const int incx) -{ - // compute Euclidean length (12 norm) of vector x, - if (n < 0 || incx <= 0) - { - cerr << "\n error in dnrm2, n < 0 or incx <= 0, "; - return 0; - } - if (n == 0) - { - return 0; - } - - double norm2=0.0; - for (int ix=0; ix= nr) - { - cerr << "\n error in dnrm2, nr or nc < 1 or i out of range "; - return 0; - } - - for (int j = 0;j < nc; j++) - { - norm2 += a(i, j) * a(i, j); - } - - return sqrt(norm2); -} - -void zgemm(char tra, - char trb, - int m, - int n, - int k, - complex < double> alpha, - const complex *a, - int lda, - const ComplexMatrix &b, - int ldb, - complex < double> beta, - complex *c, - int ldc) -{ - TITLE("myfunc5","zgemm1"); - //int nra=1; - int nca=k; - int nrb=b.nr; - int ncb=b.nc; - int nrc=1; - int ncc=n; - - //double alpha0[2] = {alpha.real(), alpha.imag()}; - //double beta0[2] = {beta.real(), beta.imag()}; - - double *aux, *bux, *cux; //HLX: bug fixed on 12/20/2006 - aux = new double[2*nca]; - bux = new double[2*nrb*ncb]; - cux = new double[2*ncc]; - - int i; - int j; - int ij; - - for (i = 0; i < nca; i++) - { - ij = 2*i; - aux[ij] = a[i].real(); - aux[ij+1] = a[i].imag(); - } - for (i = 0; i < ncb; i++) - { - for (j = 0; j < nrb; j++) - { - ij = 2 * (j + i * nrb); - bux[ij] = b(j, i).real(); - bux[ij+1] = b(j, i).imag(); - } - } - - - for (i = 0; i < ncc; i++) - { - for (j = 0; j < nrc; j++) - { - ij = 2 * i; - cux[ij] = c[i].real(); - cux[ij+1] = c[i].imag(); - } - } - - //WARNING_QUIT("reset zgemm","reset zgemm"); -// zgemm_(&tra, &trb, &m, &n, &k, alpha0, aux, &lda, bux, &ldb, beta0, cux, &ldc); - WARNING_QUIT("myfunc_5::zgemm","please don't ever use it again."); - - for (i = 0; i < ncc; i++) - { - ij = 2 * i * ldc; - c[i] = cux[ij] + complex< double>(0, 1) * cux[ij+1]; - } - - delete [] aux; - delete [] bux; - delete [] cux; -} - - -void zgemm(char tra, - char trb, - int m, - int n, - int k, - complex < double> alpha, - const complex *a, - int lda, - const ComplexMatrix &b, - int ldb, - complex < double> beta, - ComplexMatrix &c, - int ldc) -{ - TITLE("myfunc5","zgemm2"); - //int nra = 1; - int nca = k; - int nrb = b.nr; - int ncb = b.nc; - int nrc = c.nr; - int ncc = c.nc; - - //double alpha0[2] = {alpha.real(), alpha.imag()}; - //double beta0[2] = {beta.real(), beta.imag()}; - - double *aux, *bux, *cux; //HLX: bug fixed on 12/20/2006 - aux = new double[2*nca]; - bux = new double[2*nrb*ncb]; - cux = new double[2*nrc*ncc]; - - int i; - int j; - int ij; - - for (i = 0; i < nca; i++) - { - ij = 2*i; - aux[ij] = a[i].real(); - aux[ij+1] = a[i].imag(); - } - for (i = 0; i < ncb; i++) - { - for (j = 0; j < nrb; j++) - { - ij = 2 * (j + i * nrb); - bux[ij] = b(j, i).real(); - bux[ij+1] = b(j, i).imag(); - } - } - - - for (i = 0; i < ncc; i++) - { - for (j = 0; j < nrc; j++) - { - ij = 2 * (j + i * nrc); - cux[ij] = c(j, i).real(); - cux[ij+1] = c(j, i).imag(); - } - } - - //WARNING_QUIT("reset zgemm","reset zgemm"); - //zgemm_(&tra, &trb, &m, &n, &k, alpha0, aux, &lda, bux, &ldb, beta0, cux, &ldc); - WARNING_QUIT("myfunc_5::zgemm","please don't ever use it again."); - - for (i = 0; i < ncc; i++) - { - for (j = 0; j < nrc; j++) - { - ij = 2*(j+i*ldc); - c(j,i) = cux[ij] + complex< double>(0,1) * cux[ij+1]; - // cout< alpha, - const ComplexMatrix &a, - int lda, - const ComplexMatrix &b, - int ldb, - complex < double> beta, - ComplexMatrix &c, - int ldc) -{ -// TITLE("myfunc5","zgemm3"); - int nra, nca, nrb, ncb, nrc, ncc ; - nra = a.nr, nca = a.nc; - nrb = b.nr, ncb = b.nc; - nrc = c.nr, ncc = c.nc; - - //double alpha0[2] = {alpha.real(), alpha.imag()}; - //double beta0[2] = {beta.real(), beta.imag()}; - - double *aux, *bux, *cux; //HLX: bug fixed on 12/20/2006 - aux = new double[2*nra*nca]; - bux = new double[2*nrb*ncb]; - cux = new double[2*nrc*ncc]; - - int i; - int j; - int ij; - - for (i = 0; i < nca; i++) - { - for (j = 0; j < nra; j++) - { - ij = 2 * (j + i * nra); - aux[ij] = a(j, i).real(); - aux[ij+1] = a(j, i).imag(); - } - } - - for (i = 0; i < ncb; i++) - { - for (j = 0; j < nrb; j++) - { - ij = 2 * (j + i * nrb); - bux[ij] = b(j, i).real(); - bux[ij+1] = b(j, i).imag(); - } - } - - - for (i = 0; i < ncc; i++) - { - for (j = 0; j < nrc; j++) - { - ij = 2 * (j + i * nrc); - cux[ij] = c(j, i).real(); - cux[ij+1] = c(j, i).imag(); - } - } - - //WARNING_QUIT("reset zgemm","reset zgemm"); - //zgemm_(&tra, &trb, &m, &n, &k, alpha0, aux, &lda, bux, &ldb, beta0, cux, &ldc); - WARNING_QUIT("myfunc_5::zgemm","please don't ever use it again."); - - for (i = 0; i < ncc; i++) - { - for (j = 0; j < nrc; j++) - { - ij = 2 * (j + i * ldc); - c(j, i) = cux[ij] + complex< double>(0, 1) * cux[ij+1]; - } - } - - delete [] aux; - - delete [] bux; - delete [] cux; -}//end zgemm - - -// C = alpha * op(A) * op(B) + beta * C -void dgemm(char tra, char trb, int m, int n, int k, double alpha, - const matrix a, int lda, const matrix b, int ldb, double beta, - matrix &c, int ldc) -{ -// cout << "\n === ZGEMM() ===" << endl; - matrix a1; - - if (tra == 'n' || tra == 'N') - a1.create(a.nr, a.nc); - else - a1.create(a.nc, a.nr); - -// cout << "\n a1.nr = " << a1.nr -// << " a1.nc = " << a1.nc << endl; - - c = beta * c; - - if (tra == 'n' || tra == 'N') - a1 = alpha * a; - else - a1 = alpha * transpose(a); - - if (trb == 'n' || trb == 'N') - c += a1 * b; - else - c += a1 * transpose(b); - -// a1.freemem(); -// cout << "\n end ZGEMM() " << endl; - return; -}//end dgemm - -int ILAENV(int ispec, char *name, char *opts, - const int n1, const int n2, const int n3, const int n4) -{ - const int nb = ilaenv_(&ispec, name, opts, &n1, &n2, &n3, &n4); - return nb; -} - -void ZHPEV(int , - complex < double> *hp, - double *e, - ComplexMatrix &v, - int ldh, - int n, - complex < double> *aux, - int naux) -{ - cout << "\n do nothing, in ZHPEV() "; -} - -complex < double> ZDOTU(int nstart, - complex < double>, - int , - complex < double> *psi, - int npwx) -{ - cout << "\n do nothing in ZDOTU(), only return ZERO,"; - return ZERO; -} - -void zgemv(char , - int , - int , - complex < double> alpha , - ComplexMatrix overlap, - int , - complex < double> swfcatom , - int npwx, - complex < double> , - ComplexMatrix work, int) -{ - cout << "\n do nothing, in dgemv () "; -} - -/* -void ZHEGVX(int itype, - char jobz, - char range , - char uplo , - const int n, - const ComplexMatrix &a, - const int lda, - const ComplexMatrix &b, - const int ldb, - double vl, - double vu, - int il , - int iu, - double abstol, - int &m, - double *w, - ComplexMatrix &z, - const int ldz, - double *work, - int lwork, - double *rwork, - int *iwork, - int *ifail, - int &info ) -{ -// TITLE("myfunc5","ZHEGVX"); - double *aux, *bux, *zux; - aux = new double[2*lda*n];//mohan fix + --> * 2007-10-22 - bux = new double[2*ldb*n]; - zux = new double[2*ldz*iu]; // mohan fix 2007-10-15 - int i, j; - - cout << "\n n = " << n; - cout << "\n iu = " << iu << endl; - - for (i = 0;i < n;i++) - { - for (j = 0;j < lda;j++) - { - aux[2*(j+i*lda)] = a(j, i).real(); - aux[2*(j+i*lda)+1] = a(j, i).imag(); - } - } - - for (i = 0; i < n; i++) - { - for (j = 0; j < ldb; j++) - { - bux[2*(j+i*ldb)] = b(j, i).real(); - bux[2*(j+i*ldb)+1] = b(j, i).imag(); - } - } - -// BLOCK_HERE("adf"); - zhegvx_(&itype, &jobz, &range, &uplo, &n, aux, &lda, bux, &ldb, &vl, &vu, &il, &iu, &abstol, - &m, w, zux, &ldz, work, &lwork, rwork, iwork, ifail, &info); - //BLOCK_HERE("adf2"); - - for (i = 0;i < iu;i++) - { - for (j = 0;j < ldz;j++) - { - z(j, i) = zux[2*(j+i*ldz)] + complex< double>(0, 1) * zux[2*(j+i*ldz)+1]; - } - } - delete[] aux; - delete[] bux; - delete[] zux; - return; -} -*/ - - From a0068fa851fa0e315164b86dccd576e0bc6b4dab Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 16 Feb 2021 14:04:49 +0800 Subject: [PATCH 121/233] move mymath to src_global --- ABACUS.develop/source/{src_pw => src_global}/mymath.h | 11 ----------- .../source/{src_pw => src_global}/mymath1.cpp | 0 .../source/{src_pw => src_global}/mymath3.cpp | 0 ABACUS.develop/source/src_pw/energy.cpp | 5 ++--- ABACUS.develop/source/src_pw/energy_dos.cpp | 1 - ABACUS.develop/source/src_pw/occupy.cpp | 2 +- ABACUS.develop/source/src_pw/pw_complement.cpp | 2 +- ABACUS.develop/source/src_pw/symmetry_basic.cpp | 2 +- 8 files changed, 5 insertions(+), 18 deletions(-) rename ABACUS.develop/source/{src_pw => src_global}/mymath.h (68%) rename ABACUS.develop/source/{src_pw => src_global}/mymath1.cpp (100%) rename ABACUS.develop/source/{src_pw => src_global}/mymath3.cpp (100%) diff --git a/ABACUS.develop/source/src_pw/mymath.h b/ABACUS.develop/source/src_global/mymath.h similarity index 68% rename from ABACUS.develop/source/src_pw/mymath.h rename to ABACUS.develop/source/src_global/mymath.h index 18c6442884..c035071f1b 100644 --- a/ABACUS.develop/source/src_pw/mymath.h +++ b/ABACUS.develop/source/src_global/mymath.h @@ -1,5 +1,3 @@ -/* mymath.h file */ - #ifndef MYMATH_H #define MYMATH_H #include "../src_pw/tools.h" @@ -18,26 +16,17 @@ void fftw_zeros(fftw_complex *data,int n); #endif - -// in mymath1.cpp double rndm(); void simpson(const int mesh,const double *func,const double *rab, double &asum); -//void simpson_cp90( int mesh, double *func, double *rab, double intg ); -//void simpson_fpmd(int n, double *func, double dx, double s); double my_erf(double x); double my_erfc(double x); double gauss_freq(double x); -// in mymath3.cpp void heapsort(int n, double *r, int *ind); void heapAjust(double r[], int ind[], int s, int m); void hpsort(int n, double *ra, int *ind); - -// in mymath4.cpp -//void Jacobi(ComplexMatrix &Ain,double *evals, ComplexMatrix &evecs); - #endif // MYMATH_H diff --git a/ABACUS.develop/source/src_pw/mymath1.cpp b/ABACUS.develop/source/src_global/mymath1.cpp similarity index 100% rename from ABACUS.develop/source/src_pw/mymath1.cpp rename to ABACUS.develop/source/src_global/mymath1.cpp diff --git a/ABACUS.develop/source/src_pw/mymath3.cpp b/ABACUS.develop/source/src_global/mymath3.cpp similarity index 100% rename from ABACUS.develop/source/src_pw/mymath3.cpp rename to ABACUS.develop/source/src_global/mymath3.cpp diff --git a/ABACUS.develop/source/src_pw/energy.cpp b/ABACUS.develop/source/src_pw/energy.cpp index 72e85c3ede..986ab668ee 100644 --- a/ABACUS.develop/source/src_pw/energy.cpp +++ b/ABACUS.develop/source/src_pw/energy.cpp @@ -2,15 +2,14 @@ // AUTHOR : Lixin He, mohan // DATE : 2008-11-21 //========================================================== - #include "tools.h" #include "global.h" #include "energy.h" #include "algorithms.h" -#include "mymath.h" +#include "src_global/mymath.h" #include #include -#include +#include #include "../src_pw/tools.h" #include "../src_lcao/dftu.h" //Quxin adds for DFT+U on 20201029 int energy::mxr = 50; diff --git a/ABACUS.develop/source/src_pw/energy_dos.cpp b/ABACUS.develop/source/src_pw/energy_dos.cpp index d760cbd6ed..8ee0eb6d90 100644 --- a/ABACUS.develop/source/src_pw/energy_dos.cpp +++ b/ABACUS.develop/source/src_pw/energy_dos.cpp @@ -2,7 +2,6 @@ #include "global.h" #include "energy.h" #include "algorithms.h" -#include "mymath.h" #include "../src_lcao/mulliken_charge.h" #include "../src_lcao/LCAO_nnr.h" #include "../src_lcao/LCAO_gen_fixedH.h" diff --git a/ABACUS.develop/source/src_pw/occupy.cpp b/ABACUS.develop/source/src_pw/occupy.cpp index 11569097c7..8e25bb2fa0 100644 --- a/ABACUS.develop/source/src_pw/occupy.cpp +++ b/ABACUS.develop/source/src_pw/occupy.cpp @@ -1,7 +1,7 @@ #include "global.h" #include "occupy.h" #include "algorithms.h" -#include "mymath.h" +#include "src_global/mymath.h" Occupy::Occupy(){} Occupy::~Occupy(){} diff --git a/ABACUS.develop/source/src_pw/pw_complement.cpp b/ABACUS.develop/source/src_pw/pw_complement.cpp index 56d406911e..0635c88c77 100644 --- a/ABACUS.develop/source/src_pw/pw_complement.cpp +++ b/ABACUS.develop/source/src_pw/pw_complement.cpp @@ -1,5 +1,5 @@ #include "pw_complement.h" -#include "mymath.h" +#include "src_global/mymath.h" int PW_complement::get_total_pw_number( const double& ggcut_start, diff --git a/ABACUS.develop/source/src_pw/symmetry_basic.cpp b/ABACUS.develop/source/src_pw/symmetry_basic.cpp index d9664c7e48..fc21510409 100644 --- a/ABACUS.develop/source/src_pw/symmetry_basic.cpp +++ b/ABACUS.develop/source/src_pw/symmetry_basic.cpp @@ -4,7 +4,7 @@ //========================================================== #include "symmetry.h" #include "global.h" -#include "mymath.h" +#include "src_global/mymath.h" #include "symm_other.h" Symmetry_Basic::Symmetry_Basic() From c6a7ff397c51c6fad617ecfe73d429669dca8f82 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 16 Feb 2021 21:03:52 +0800 Subject: [PATCH 122/233] delte some global variables, delete BERRY_PHASE, add static variable in berryphase class --- ABACUS.develop/source/driver.cpp | 30 +-- ABACUS.develop/source/input_conv.cpp | 198 ++++++++---------- .../source/src_global/global_variable.cpp | 15 -- .../source/src_global/global_variable.h | 19 +- ABACUS.develop/source/src_io/berryphase.cpp | 21 +- ABACUS.develop/source/src_io/berryphase.h | 18 +- ABACUS.develop/source/src_io/bessel_basis.cpp | 20 +- ABACUS.develop/source/src_io/eximport.cpp | 26 +-- .../source/src_io/numerical_basis.cpp | 8 +- .../source/src_io/numerical_descriptor.cpp | 2 +- ABACUS.develop/source/src_lcao/ELEC_nscf.cpp | 2 +- ABACUS.develop/source/src_pw/electrons.cpp | 2 +- 12 files changed, 163 insertions(+), 198 deletions(-) diff --git a/ABACUS.develop/source/driver.cpp b/ABACUS.develop/source/driver.cpp index 8e2cef1b0a..3a76970bf7 100644 --- a/ABACUS.develop/source/driver.cpp +++ b/ABACUS.develop/source/driver.cpp @@ -41,8 +41,6 @@ void Driver::reading(void) //--------------------------------------------------------------------------------- // (1) read INPUT - // although I suggest you keep the parameters to be as - // local as possible -- mohan 2021-01-31 INPUT.Init( global_in_card ); // (2) copy the variables from INPUT to each class @@ -65,35 +63,28 @@ void Driver::reading(void) // (5) Read in parameters about wannier functions. winput::Init( global_wannier_card ); - //xiaohui move 3 lines, 2015-09-30 - //stringstream ss2; - //ss2 << global_out_dir << "INPUTw"; - //winput::Print( ss2.str() ); - - // (3) Print the parameters into INPUT file. + // (6) Print the parameters into INPUT file. stringstream ss1; ss1 << global_out_dir << global_in_card; INPUT.Print( ss1.str() ); //DONE(ofs_running,"READING CARDS"); - - // (4) Setup the unitcell. + // (7) Setup the unitcell. ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running); DONE(ofs_running, "SETUP UNITCELL"); - // (5) symmetry analysize. + // (8) symmetry analysize. if (SYMMETRY) { symm.analy_sys(); DONE(ofs_running, "SYMMETRY"); } - // (6) Setup the k points according to symmetry. + // (9) Setup the k points according to symmetry. kv.set( symm, global_kpoint_card, NSPIN, ucell.G, ucell.latvec ); DONE(ofs_running,"INIT K-POINTS"); - - // (7) check the number of basis, the warning should be moved to + // (10) check the number of basis, the warning should be moved to // other places -- mohan 2021-01-30 // mohan add 2011-01-5 if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") @@ -112,8 +103,7 @@ void Driver::reading(void) //--------------------------------------------------------------------------------- - - // for LCAO basis, reading the orbitals and construct + // (11) for LCAO basis, reading the orbitals and construct // the interpolation tables. // this part should be moved somewher else -- mohan 2021-01-30 if(BASIS_TYPE=="lcao") //xiaohui add 2013-09-01 @@ -131,7 +121,7 @@ void Driver::reading(void) LM.divide_HS_in_frag(); } - + // (12) print information // mohan add 2021-01-30 Print_Info PI; PI.screen_output(); @@ -139,14 +129,14 @@ void Driver::reading(void) //--------------------------------------------------------------------------------- - // Initalize the plane wave basis set + // (12) Initalize the plane wave basis set pw.gen_pw(ofs_running, ucell, kv); DONE(ofs_running,"INIT PLANEWAVE"); cout << " UNIFORM GRID DIM : " << pw.nx <<" * " << pw.ny <<" * "<< pw.nz << endl; cout << " UNIFORM GRID DIM(BIG): " << pw.nbx <<" * " << pw.nby <<" * "<< pw.nbz << endl; - // mohan add 2010-10-10, just to test the symmetry of a variety + // (13) mohan add 2010-10-10, just to test the symmetry of a variety // of systems. if(CALCULATION == "test") { @@ -154,7 +144,7 @@ void Driver::reading(void) QUIT(); } - // mohan add 2010-09-13 + // (14) mohan add 2010-09-13 // initialize the real-space uniform grid for FFT and parallel // distribution of plane waves Pgrid.init(pw.ncx, pw.ncy, pw.ncz, pw.nczp, diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index 7a1d47952f..4baafa2a09 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -9,9 +9,6 @@ #include "src_lcao/ORB_read.h" #include "src_pw/efield.h" #include "src_lcao/global_fp.h" - -// those included filese below this comment should not appear here -// mohan 2021-01-30 #include "src_pw/vdwd2.h" #include "src_pw/vdwd3.h" #include "src_io/chi0_hilbert.h" @@ -20,13 +17,8 @@ #include "src_io/epsilon0_vasp.h" #include "src_pw/unitcell.h" #include "src_ri/exx_abfs-jle.h" - -//xiaohui modified 2013-03-23, adding "//" before #include... -//#include "../../src_develop/src_siao/selinv.h" -//#include "../src_develop/src_dc/dc_info.h" -//#include "../../src_develop/src_md/md.h" - #include "src_pw/occupy.h" +#include "src_io/berryphase.h" void Input_Conv::Convert(void) { @@ -36,46 +28,44 @@ void Input_Conv::Convert(void) // main parameters / electrons / spin ( 10/16 ) //---------------------------------------------------------- // suffix - if(INPUT.atom_file!="")global_atom_card = INPUT.atom_file;//xiaohui modify 2015-02-01 + if(INPUT.atom_file!="") global_atom_card = INPUT.atom_file; global_wannier_card = INPUT.wannier_card; - if(INPUT.kpoint_file!= "")global_kpoint_card = INPUT.kpoint_file;//xiaohui modify 2015-02-01 - if(INPUT.pseudo_dir != "")global_pseudo_dir = INPUT.pseudo_dir + "/"; // mohan add slash 2013-04-13 (xiaohui add 2013-06-23) - global_pseudo_type = INPUT.pseudo_type; // mohan add this on 2013-05-20 (xiaohui add 2013-06-23) + if(INPUT.kpoint_file!= "") global_kpoint_card = INPUT.kpoint_file; + if(INPUT.pseudo_dir != "") global_pseudo_dir = INPUT.pseudo_dir + "/"; + global_pseudo_type = INPUT.pseudo_type; ucell.latName = INPUT.latname; ucell.ntype = INPUT.ntype; ucell.nelec = INPUT.nelec; -// ucell.lmaxmax = INPUT.lmaxmax; +// ucell.lmaxmax = INPUT.lmaxmax; + NBANDS = INPUT.nbands; + NBANDS_ISTATE = INPUT.nbands_istate; + NPOOL = INPUT.npool; + CALCULATION = INPUT.calculation; -// calculation : 2 - NBANDS = INPUT.nbands; // 1 - NBANDS_ISTATE = INPUT.nbands_istate;// 1 - NPOOL = INPUT.npool; // mohan add 2010-06-09 - CALCULATION = INPUT.calculation; // 2 - BERRY_PHASE = INPUT.berry_phase; // 3 - STO_WF.nchi = INPUT.nbands_sto; // qianrui add 2021-2-5 + // qianrui add 2021-2-5 + STO_WF.nchi = INPUT.nbands_sto; STO_WF.nche_sto = INPUT.nche_sto; - + // Electrical Field EFIELD = INPUT.efield; Efield::edir = INPUT.edir; Efield::emaxpos = INPUT.emaxpos; Efield::eopreg = INPUT.eopreg; Efield::eamp = INPUT.eamp; - + // optical Optical::opt_epsilon2=INPUT.opt_epsilon2; // mohan add 2010-03-24 Optical::opt_nbands=INPUT.opt_nbands; // number of bands for optical transition. - LDA_PLUS_U = INPUT.lda_plus_u; // 5 - DFT_FUNCTIONAL = INPUT.dft_functional; // 6.5 - NSPIN = INPUT.nspin; // 7 - CURRENT_SPIN = 0; // 8 + DFT_FUNCTIONAL = INPUT.dft_functional; + NSPIN = INPUT.nspin; + CURRENT_SPIN = 0; - FORCE = INPUT.force; // 8.1 - FORCE_THR = INPUT.force_thr; // 8.2 + FORCE = INPUT.force; + FORCE_THR = INPUT.force_thr; - STRESS_THR = INPUT.stress_thr; //LiuXh add 20180515 + STRESS_THR = INPUT.stress_thr; PRESS1 = INPUT.press1; PRESS2 = INPUT.press2; PRESS3 = INPUT.press3; @@ -91,7 +81,9 @@ void Input_Conv::Convert(void) STRESS = INPUT.stress; - if(INPUT.fixed_axes == "None") // pengfei Li add 2018-11-11 + + // pengfei Li add 2018-11-11 + if(INPUT.fixed_axes == "None") { ucell.lc[0] = 1; ucell.lc[1] = 1; ucell.lc[2] = 1; } @@ -131,20 +123,18 @@ void Input_Conv::Convert(void) { WARNING_QUIT("Input", "fixed_axes should be None,a,b,c,ab,ac,bc or abc!"); } + MOVE_IONS = INPUT.ion_dynamics; OUT_LEVEL = INPUT.out_level; Ions_Move_CG::CG_THRESHOLD = INPUT.cg_threshold; // pengfei add 2013-09-09 -//---------------------------------------------------------- -// new function (5/5) -//---------------------------------------------------------- SYMMETRY = INPUT.symmetry; // 9 - BASIS_TYPE = INPUT.basis_type; //xiaohui add 2013-09-01 - KS_SOLVER = INPUT.ks_solver; //xiaohui add 2013-09-01 - SEARCH_RADIUS = INPUT.search_radius; // 11.1 - SEARCH_PBC = INPUT.search_pbc; // 11.2 - SPARSE_MATRIX = INPUT.sparse_matrix; // 11.3 - ATOM_DISTRIBUTION = INPUT.atom_distribution; // 11.4 + BASIS_TYPE = INPUT.basis_type; + KS_SOLVER = INPUT.ks_solver; + SEARCH_RADIUS = INPUT.search_radius; + SEARCH_PBC = INPUT.search_pbc; + SPARSE_MATRIX = INPUT.sparse_matrix; + ATOM_DISTRIBUTION = INPUT.atom_distribution; //---------------------------------------------------------- // planewave (8/8) @@ -164,28 +154,28 @@ void Input_Conv::Convert(void) INPUT.bz ); GAMMA_ONLY_LOCAL = INPUT.gamma_only_local; + //---------------------------------------------------------- // diagonalization (5/5) //---------------------------------------------------------- - //DIAGO_TYPE = INPUT.diago_type; xiaohui modify 2013-09-01 // 12 - DIAGO_PROC = INPUT.diago_proc; // 12.1 mohan add 2012-01-13 - DIAGO_CG_MAXITER = INPUT.diago_cg_maxiter; // 13 - DIAGO_CG_PREC = INPUT.diago_cg_prec; // 13.1 - DIAGO_DAVID_NDIM = INPUT.diago_david_ndim; // 14 - ETHR = INPUT.ethr; // 15 + DIAGO_PROC = INPUT.diago_proc; + DIAGO_CG_MAXITER = INPUT.diago_cg_maxiter; + DIAGO_CG_PREC = INPUT.diago_cg_prec; + DIAGO_DAVID_NDIM = INPUT.diago_david_ndim; + ETHR = INPUT.ethr; NB2D = INPUT.nb2d; - NURSE = INPUT.nurse; // 21 + NURSE = INPUT.nurse; COLOUR = INPUT.colour; - T_IN_H = INPUT.t_in_h; // 23 - VL_IN_H = INPUT.vl_in_h; // 24 - VNL_IN_H = INPUT.vnl_in_h; // 25 - TEST_FORCE = INPUT.test_force; // 26 + T_IN_H = INPUT.t_in_h; + VL_IN_H = INPUT.vl_in_h; + VNL_IN_H = INPUT.vnl_in_h; + TEST_FORCE = INPUT.test_force; TEST_STRESS = INPUT.test_stress; //---------------------------------------------------------- // iteration (1/3) //---------------------------------------------------------- - DRHO2 = INPUT.dr2; // 17 + DRHO2 = INPUT.dr2; //---------------------------------------------------------- // wavefunction / charge / potential / (2/4) @@ -195,31 +185,8 @@ void Input_Conv::Convert(void) wf.mem_saver = INPUT.mem_saver; //mohan add 2010-09-07 en.printe = INPUT.printe; // mohan add 2011-03-16 - //DC_Info::dcnx = INPUT.dc_nx; - //DC_Info::dcny = INPUT.dc_ny; - //DC_Info::dcnz = INPUT.dc_nz; - -/* //---------------------------------------------------------- -// about vdwD2 //Peize Lin add 2014-03-31 -//---------------------------------------------------------- - if(INPUT.vdwD2) - { - vdwd2.vdwD2 = INPUT.vdwD2; - vdwd2.scaling = INPUT.vdwD2_scaling; - vdwd2.damping = INPUT.vdwD2_d; - vdwd2.C6_input(INPUT.vdwD2_C6_file, INPUT.vdwD2_C6_unit); - vdwd2.R0_input(INPUT.vdwD2_R0_file, INPUT.vdwD2_R0_unit); - vdwd2.model = INPUT.vdwD2_model; - if(INPUT.vdwD2_model=="radius") - if(INPUT.vdwD2_radius_unit=="Bohr") - vdwd2.radius = INPUT.vdwD2_radius; - else - vdwd2.radius = INPUT.vdwD2_radius * BOHR_TO_A; - else if(INPUT.vdwD2_model=="period") - vdwd2.period = INPUT.vdwD2_period; - } */ //---------------------------------------------------------- -// about vdw //jiyy add 2019-08-04 +// about vdw, jiyy add 2019-08-04 //---------------------------------------------------------- if(INPUT.vdw_method=="d2") { @@ -290,11 +257,13 @@ void Input_Conv::Convert(void) } //---------------------------------------------------------- -// about spectrum // pengfei 2016-12-14 +// about spectrum, pengfei 2016-12-14 //---------------------------------------------------------- - //if( (INPUT.epsilon && (INPUT.epsilon_choice == 0)) || ((!INPUT.epsilon) && (INPUT.epsilon_choice == 0) && INPUT.kmesh_interpolation)) - if( (INPUT.spectral_type == "eels" && INPUT.eels_method == 0) || (INPUT.spectral_type == "None" && INPUT.eels_method == 0 && INPUT.kmesh_interpolation) ) + if( (INPUT.spectral_type == "eels" && INPUT.eels_method == 0) + || (INPUT.spectral_type == "None" + && INPUT.eels_method == 0 + && INPUT.kmesh_interpolation) ) { if(INPUT.spectral_type == "eels") { @@ -352,8 +321,12 @@ void Input_Conv::Convert(void) chi0_standard.nomega = INPUT.nomega; chi0_standard.dim = INPUT.ecut_chi; //chi0_standard.oband = INPUT.oband; - chi0_standard.q_start[0] = INPUT.q_start[0]; chi0_standard.q_start[1] = INPUT.q_start[1]; chi0_standard.q_start[2] = INPUT.q_start[2]; - chi0_standard.direct[0] = INPUT.q_direct[0]; chi0_standard.direct[1] = INPUT.q_direct[1]; chi0_standard.direct[2] = INPUT.q_direct[2]; + chi0_standard.q_start[0] = INPUT.q_start[0]; + chi0_standard.q_start[1] = INPUT.q_start[1]; + chi0_standard.q_start[2] = INPUT.q_start[2]; + chi0_standard.direct[0] = INPUT.q_direct[0]; + chi0_standard.direct[1] = INPUT.q_direct[1]; + chi0_standard.direct[2] = INPUT.q_direct[2]; //chi0_standard.start_q = INPUT.start_q; //chi0_standard.interval_q = INPUT.interval_q; chi0_standard.nq = INPUT.nq; @@ -384,8 +357,11 @@ void Input_Conv::Convert(void) epsilon0_vasp.eta = INPUT.eta; } - //added by zhengdy-soc - if(INPUT.noncolin||INPUT.lspinorb) { +//-------------------------------------------- +// added by zhengdy-soc +//-------------------------------------------- + if(INPUT.noncolin||INPUT.lspinorb) + { NSPIN = 4; } if(NSPIN == 4) @@ -462,7 +438,9 @@ void Input_Conv::Convert(void) pos2 = ocp_set.find(c, pos1); } if(pos1 != ocp_set.length()) + { str.push_back(ocp_set.substr(pos1)); + } regex_t reg; regcomp(®, pattern.c_str(), REG_EXTENDED); @@ -471,7 +449,9 @@ void Input_Conv::Convert(void) for(int i=0; i NBANDS) WARNING_QUIT("berryphase::get_occupation_bands","you set the band numer is not enough for berryphase, please add bands number."); + if(occ_nbands > NBANDS) + { + WARNING_QUIT("berryphase::get_occupation_bands","not enough bands for berryphase, increase band numbers."); + } //ofs_running << "the berryphase's occ_nbands is " << occ_nbands << endl; } void berryphase::lcao_init() { + TITLE("berryphase","lcao_init"); lcao_method.init(); lcao_method.cal_R_number(); lcao_method.cal_orb_overlap(); - + return; } // this routine ä¾èµ–于 kpointçš„mpç”Ÿæˆæ–¹å¼ void berryphase::set_kpoints(const int direction) { + TITLE("berryphase","set_kpoints"); + const int mp_x = kv.nmp[0]; // x,y,zæ–¹å‘k点的数目 const int mp_y = kv.nmp[1]; const int mp_z = kv.nmp[2]; - const int num_k = int(kv.nkstot/2); - + const int num_k = int(kv.nkstot/2); if( direction == 1 ) // 计算xæ–¹å‘ { @@ -63,6 +70,7 @@ void berryphase::set_kpoints(const int direction) int string_index = -1; for(int iz = 0; iz < mp_z; iz++) + { for(int iy = 0; iy < mp_y; iy++) { string_index++; @@ -72,6 +80,7 @@ void berryphase::set_kpoints(const int direction) if( ix == (mp_x-1) ) k_index[string_index][ix+1] = k_index[string_index][0]; } } + } if( NSPIN == 2 ) { @@ -109,6 +118,7 @@ void berryphase::set_kpoints(const int direction) int string_index = -1; for(int iz = 0; iz < mp_z; iz++) + { for(int ix = 0; ix < mp_x; ix++) { string_index++; @@ -118,6 +128,7 @@ void berryphase::set_kpoints(const int direction) if( iy == (mp_y-1) ) k_index[string_index][iy+1] = k_index[string_index][0]; } } + } if( NSPIN == 2 ) { @@ -155,6 +166,7 @@ void berryphase::set_kpoints(const int direction) int string_index = -1; for(int iy = 0; iy < mp_y; iy++) + { for(int ix = 0; ix < mp_x; ix++) { string_index++; @@ -164,6 +176,7 @@ void berryphase::set_kpoints(const int direction) if( iz == (mp_z-1) ) k_index[string_index][iz+1] = k_index[string_index][0]; } } + } if( NSPIN == 2 ) { diff --git a/ABACUS.develop/source/src_io/berryphase.h b/ABACUS.develop/source/src_io/berryphase.h index b2e54b79c6..c368bec2e9 100644 --- a/ABACUS.develop/source/src_io/berryphase.h +++ b/ABACUS.develop/source/src_io/berryphase.h @@ -6,9 +6,19 @@ class berryphase { + public: + + berryphase(); + ~berryphase(); + + // mohan add 2021-02-16 + static bool berry_phase_flag; + unkOverlap_pw pw_method; + unkOverlap_lcao lcao_method; + int total_string; vector> k_index; int nppstr; @@ -16,14 +26,18 @@ class berryphase int occ_nbands; int GDIR; - berryphase(); - ~berryphase(); void get_occupation_bands(); + void lcao_init(); + void set_kpoints(const int direction); + double stringPhase(int index_str, int nbands); + void Berry_Phase(int nbands, double &pdl_elec_tot, int &mod_elec_tot); + void Macroscopic_polarization(); + string outFormat(const double polarization, const double modulus, const Vector3 project); }; diff --git a/ABACUS.develop/source/src_io/bessel_basis.cpp b/ABACUS.develop/source/src_io/bessel_basis.cpp index 6a3f49df6c..ff5e90519b 100644 --- a/ABACUS.develop/source/src_io/bessel_basis.cpp +++ b/ABACUS.develop/source/src_io/bessel_basis.cpp @@ -120,7 +120,7 @@ void Bessel_Basis::init_Faln( const int &nmax, const int &ecut_number) { - if(test_spillage) TITLE("Bessel_Basis","init_Faln"); + TITLE("Bessel_Basis","init_Faln"); timer::tick("Spillage","init_Faln"); assert( this->kmesh > 0); @@ -144,7 +144,7 @@ void Bessel_Basis::init_Faln( } } } - if(test_spillage)OUT("nwfc = ",nwfc); + OUT("nwfc = ",nwfc); timer::tick("Spillage","init_Faln"); return; @@ -162,7 +162,7 @@ void Bessel_Basis::init_TableOne( const int &ecut_number, const double &tolerence) { - if(test_spillage) TITLE("Bessel_Basis","init_TableOne"); + TITLE("Bessel_Basis","init_TableOne"); timer::tick("Spillage","TableONe"); // check assert(ecutwfc > 0.0); @@ -283,7 +283,7 @@ void Bessel_Basis::readin_C4( const int &ecut_number, const double &tolerence) { - if(test_spillage) TITLE("Bessel_Basis","readin_C4"); + TITLE("Bessel_Basis","readin_C4"); if(MY_RANK != 0) return; @@ -306,8 +306,9 @@ void Bessel_Basis::readin_C4( { for(int in=0; in< ucell.atoms[it].l_nchi[il]; in++) { - if(test_spillage>1)cout << "\n" << setw(5) << it << setw(5) << il << setw(5) << in; - if(test_spillage>1)cout << "\n file=" << filec4; + //for tests + //cout << "\n" << setw(5) << it << setw(5) << il << setw(5) << in; + //cout << "\n file=" << filec4; ifstream inc4( filec4.c_str() ); if(!inc4) @@ -354,7 +355,8 @@ void Bessel_Basis::readin_C4( for(int ie=0; ie> this->C4(it, il, in, ie); - if(test_spillage>1)cout << "\n" << setw(5) << ie << setw(25) << this->C4(it, il, in, ie); + // for tests + //cout << "\n" << setw(5) << ie << setw(25) << this->C4(it, il, in, ie); } } else @@ -389,7 +391,7 @@ void Bessel_Basis::allocate_C4( const int &nmax, const int &ecut_number) { - if(test_spillage) TITLE("Bessel_Basis","allocate_C4"); + TITLE("Bessel_Basis","allocate_C4"); this->C4.create(ntype, lmax+1, nmax, ecut_number); @@ -412,7 +414,7 @@ void Bessel_Basis::allocate_C4( void Bessel_Basis::bcast(void) { #ifdef __MPI - if(test_spillage) TITLE("Bessel_Basis", "bcast"); + TITLE("Bessel_Basis", "bcast"); Parallel_Common::bcast_double( ecut ); Parallel_Common::bcast_double( rcut ); diff --git a/ABACUS.develop/source/src_io/eximport.cpp b/ABACUS.develop/source/src_io/eximport.cpp index 47ba886eb2..cc1f19b938 100644 --- a/ABACUS.develop/source/src_io/eximport.cpp +++ b/ABACUS.develop/source/src_io/eximport.cpp @@ -23,7 +23,7 @@ void eximport::write_data const string &type ) { - if(test_eximport) TITLE("eximport","write_data"); + TITLE("eximport","write_data"); ofstream ofs(fn.c_str()); this->out_input(ofs); @@ -81,7 +81,7 @@ void eximport::write_data void eximport::read_data(const string &fn) { - if(test_eximport) TITLE("eximport","read_data"); + TITLE("eximport","read_data"); ifstream ifs(fn.c_str()); if(!ifs) @@ -107,7 +107,7 @@ void eximport::read_data(const string &fn) void eximport::print_data(const string &fn) const { - if(test_eximport) TITLE("eximport","print_data"); + TITLE("eximport","print_data"); ofstream ofs( fn.c_str() ); ofs << setw(20) << "basis" << setw(20) << this->basis << endl; @@ -202,7 +202,7 @@ void eximport::fir_wf(ComplexMatrix *psi, const int npsi, const string &fn) void eximport::out_gspace_wan(const ComplexMatrix *psi,const int iw,const string &file_name) { - if(test_eximport)cout<<"\n ==> ei.wanG_for_fit"; + //cout<<"\n ==> ei.wanG_for_fit"; ofstream out_gwan(file_name.c_str()); int qtot = 0; for(int ik=0; ik ***psi, const int npsi, const string &fn //****************** void eximport::out_wannier(ofstream &out_data) { - if(test_eximport) cout<<"\n ==> out_wannier"< out_wannier"< out_unitcell" << endl; + //cout << "\n ==> out_unitcell" << endl; out_data << setw(20) << "UNITCELL" << endl; //2.0 out_data << setw(20) << ucell.lat0 << endl; //2.1 @@ -413,7 +413,7 @@ void eximport::in_unitcell(ifstream &in) //*************** void eximport::out_kpoints(ofstream &out_data) { - if(test_eximport)cout << "\n ==> out_k-points" << endl; + //cout << "\n ==> out_k-points" << endl; out_data << "\n"; out_data << "\n" << kv.nkstot << " Number of total k points"; //3.1 int sumq = 0; @@ -440,7 +440,7 @@ void eximport::out_kpoints(ofstream &out_data) void eximport::out_planewave(ofstream &out_data) { - if(test_eximport)cout << "\n ==> out_planewave" << endl; + //cout << "\n ==> out_planewave" << endl; out_data << "\n"; out_data << "\n" << ucell.lat0 << " Lattice constant"; out_data << "\n" << pw.ngmc_g << " Number of plane waves."< out_igk" << endl; + //cout << "\n ==> out_igk" << endl; out_data << "\n"; for(int ik=0; ik out_input" << endl; + //cout << "\n ==> out_input" << endl; out_data << "
"; //1.0 out_data << "\n" << ucell.latName << " Lattice Name";//1.1 @@ -583,7 +583,7 @@ void eximport::in_input(ifstream &in) //********** void eximport::out_band(ofstream &out_data) { - if(test_eximport)cout << "\n ==> out_band" << endl; + //cout << "\n ==> out_band" << endl; out_data << setw(20) << "BAND" << endl;//6.0 for (int ik = 0; ik < kv.nks; ik++) { @@ -628,7 +628,7 @@ void eximport::in_band(ifstream &in) //***** void eximport::out_evc(ofstream &out_data) { - if(test_eximport)cout << "=== out_evc ===" << endl; + //cout << "=== out_evc ===" << endl; out_data << setw(20) << "EVC" << endl; out_data << setw(20) << ucell.natomwfc << endl; //4.1 int iw; @@ -701,7 +701,7 @@ void eximport::in_evc(ifstream &in) //=========== void eximport::out_energy(ofstream &out_data) { - if(test_eximport)cout << "\n ==> out_energy" << endl; + //cout << "\n ==> out_energy" << endl; out_data << setw(20) << "ENERGY" << endl; //6.0 out_data << setw(20) << en.etot << endl; //6.2 //out_data << setw(20) << elec.dE << endl; //6.3 diff --git a/ABACUS.develop/source/src_io/numerical_basis.cpp b/ABACUS.develop/source/src_io/numerical_basis.cpp index fa2a29b5f7..9053eb7c0f 100644 --- a/ABACUS.develop/source/src_io/numerical_basis.cpp +++ b/ABACUS.develop/source/src_io/numerical_basis.cpp @@ -28,7 +28,7 @@ Numerical_Basis::~Numerical_Basis() {} //============================================================ void Numerical_Basis::start_from_file_k( const int &ik, ComplexMatrix &psi) { - if (test_spillage>1) TITLE("Numerical_Basis","start_from_file_k"); + TITLE("Numerical_Basis","start_from_file_k"); if (!Numerical_Basis::init_label) { @@ -383,7 +383,7 @@ void Numerical_Basis::Sq_overlap( const int &ik, const int &np) { - if (test_spillage>1) TITLE("Numerical_Basis","Sq_overlap"); + TITLE("Numerical_Basis","Sq_overlap"); timer::tick("Numerical_Basis","Sq_overlap"); ofs_running << " OUTPUT THE OVERLAP BETWEEN SPHERICAL BESSEL FUNCTIONS" << endl; @@ -515,7 +515,7 @@ void Numerical_Basis::jlq3d_overlap( const int &np, const ComplexMatrix &psi) { - if (test_spillage>1) TITLE("Numerical_Basis","jlq3d_overlap"); + TITLE("Numerical_Basis","jlq3d_overlap"); timer::tick("Numerical_Basis","jlq3d_overlap"); ofs_running << " OUTPUT THE OVERLAP BETWEEN SPHERICAL BESSEL FUNCTIONS AND BLOCH WAVE FUNCTIONS" << endl; @@ -639,7 +639,7 @@ void Numerical_Basis::numerical_atomic_wfc( const int &np, ComplexMatrix &psi) { - if (test_spillage > 2) TITLE("Numerical_Basis", "numerical_atomic_wfc"); + TITLE("Numerical_Basis", "numerical_atomic_wfc"); const int total_lm = ( ucell.lmax + 1) * ( ucell.lmax + 1); matrix ylm(total_lm, np); diff --git a/ABACUS.develop/source/src_io/numerical_descriptor.cpp b/ABACUS.develop/source/src_io/numerical_descriptor.cpp index fcc197dd5b..f7843b675d 100644 --- a/ABACUS.develop/source/src_io/numerical_descriptor.cpp +++ b/ABACUS.develop/source/src_io/numerical_descriptor.cpp @@ -232,7 +232,7 @@ void Numerical_Descriptor::jlq3d_overlap( const int &np, const ComplexMatrix &psi) { - if (test_spillage>1) TITLE("Numerical_Descriptor","jlq3d_overlap"); + TITLE("Numerical_Descriptor","jlq3d_overlap"); timer::tick("Numerical_Descriptor","jlq3d_overlap"); ofs_running << " OUTPUT THE OVERLAP BETWEEN SPHERICAL BESSEL FUNCTIONS AND BLOCH WAVE FUNCTIONS" << endl; diff --git a/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp b/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp index 983a8b34e1..cbf90cb96c 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp @@ -85,7 +85,7 @@ void ELEC_nscf::nscf(Use_Hamilt_Matrix &uhm) } // add by jingan - if (BERRY_PHASE && SYMMETRY == 0) + if (berryphase::berry_phase_flag && SYMMETRY == 0) { berryphase bp; bp.Macroscopic_polarization(); diff --git a/ABACUS.develop/source/src_pw/electrons.cpp b/ABACUS.develop/source/src_pw/electrons.cpp index f7c8d27c27..b38c77513c 100644 --- a/ABACUS.develop/source/src_pw/electrons.cpp +++ b/ABACUS.develop/source/src_pw/electrons.cpp @@ -71,7 +71,7 @@ void Electrons::non_self_consistent(const int &istep) // Do a Berry phase polarization calculation if required //======================================================= - if (BERRY_PHASE && SYMMETRY == 0) + if (berryphase::berry_phase_flag && SYMMETRY == 0) { berryphase bp; bp.Macroscopic_polarization(); From 76d782114e83e349920c06734d55e4edb7152996 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 16 Feb 2021 21:58:14 +0800 Subject: [PATCH 123/233] comment on local_orbital_charge and wfc_dm_2d --- .../source/src_lcao/local_orbital_charge.cpp | 205 +++--------------- .../source/src_lcao/local_orbital_charge.h | 20 +- .../source/src_lcao/mulliken_charge.h | 5 +- ABACUS.develop/source/src_lcao/wfc_dm_2d.cpp | 28 ++- ABACUS.develop/source/src_lcao/wfc_dm_2d.h | 11 +- 5 files changed, 79 insertions(+), 190 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp b/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp index becd4c9360..ec3613aa6e 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp @@ -4,7 +4,7 @@ //#include "../src_onscaling/on_tests.h" //#include "../src_siao/selinv.h" -// 2014.10.29 add memory pool for DM and DM_B by yshen +// 2014.10.29 add memory pool for DM and by yshen // Shen Yu add 2019/5/9 extern "C" @@ -24,7 +24,10 @@ Local_Orbital_Charge::Local_Orbital_Charge() // for k-dependent algorithms. this->init_DM_R = false; - out_dm = 0; + + // whether to printout density matrix + this->out_dm = 0; + //xiaohui add 2014-06-19 //band_local = nullptr; //Z_wg = nullptr; @@ -68,23 +71,6 @@ Local_Orbital_Charge::~Local_Orbital_Charge() } delete[] DM_R; } - - //xiaohui add 2014-06-19 - //delete[] loc_bands; - //delete[] Z_wg; - //delete[] Z_LOC; -/* - //xiaohui add 2014-06-20 - for (int is=0; isnnrg_now = LNNR.nnrg; //xiaohui add 'OUT_LEVEL' line, 2015-09-16 @@ -150,10 +136,13 @@ void Local_Orbital_Charge::allocate_DM_k(void) WARNING_QUIT("Local_Orbital_Charge::allocate_k","check init_DM_R."); } - wfc_dm_2d.init(); // Peize Lin test 2019-01-16 + // Peize Lin test 2019-01-16 + wfc_dm_2d.init(); + return; } + // setup buffer parameters for tranforming 2D block-cyclic distributed DM matrix inline int globalIndex(int localIndex, int nblk, int nprocs, int myproc) { @@ -164,6 +153,7 @@ inline int globalIndex(int localIndex, int nblk, int nprocs, int myproc) //return (localIndex/nblk*nprocs+myproc)*nblk+localIndex%nblk; } + inline int localIndex(int globalIndex, int nblk, int nprocs, int& myproc) { myproc=int((globalIndex%(nblk*nprocs))/nblk); @@ -339,41 +329,13 @@ int Local_Orbital_Charge::setAlltoallvParameter(MPI_Comm comm_2D, int blacs_ctxt return 0; } + // allocate density kernel may change once the ion // positions change void Local_Orbital_Charge::allocate_gamma(const Grid_Technique >) { TITLE("Local_Orbital_Charge","allocate_gamma"); - //xiaohui add 2014-06-20 - //for(int is=0; isinit_DM) - //{ - // this->DM = new double**[NSPIN]; - // for(int is=0; isDM[is] = new double*[NLOCAL]; - - // for (int i=0; iinit_DM = true; - // Memory::record("LocalOrbital_Charge","Density_Kernal",NSPIN*NLOCAL*NLOCAL,"double"); - // } - //} - - //for (int i=0; iDM[is][NLOCAL], NLOCAL); - //} - //} - - //xiaohui modify 2014-06-18 - // mohan fix serious bug 2010-09-06 this->lgd_now = gt.lgd; //xiaohui add 'OUT_LEVEL' line, 2015-09-16 @@ -429,7 +391,8 @@ void Local_Orbital_Charge::allocate_gamma(const Grid_Technique >) setAlltoallvParameter(ParaO.comm_2D, ParaO.blacs_ctxt, ParaO.nb); - wfc_dm_2d.init(); // Peize Lin test 2019-01-16 + // Peize Lin test 2019-01-16 + wfc_dm_2d.init(); return; } @@ -440,35 +403,6 @@ void Local_Orbital_Charge::sum_bands(void) timer::tick("Local_Orbital_Cha","sum_bands",'E'); en.eband = 0.0; - //xiaohui modify 2013-09-02 - //if(LINEAR_SCALING == 2) - //{ - // //en.eband = ON.eband; - //} - //else if(LINEAR_SCALING == 1) - //{ - // //xiaohui modified 2013-07-22 - // //if(DIAGO_TYPE=="selinv") - // //{ - // // en.eband = Selinv::eband; - // //} - // //else - // //{ - // // ofs_running << " calculate eband " << endl; - // for(int ik=0; ikcal_dk_gamma();//calculate the density matrix. - // } - // // @@@@@@@ - // // test - // // @@@@@@@ - // /* - // cout << " Density Matrix:"; - // double sum = 0.0; - // for(int i=0; ical_dk_k( GridT ); - // } - //} xiaohui modify 2013-09-02. Attention... + } //xiaohui add 2013-09-02 if(GAMMA_ONLY_LOCAL) @@ -554,8 +442,10 @@ void Local_Orbital_Charge::sum_bands(void) NOTE("Calculate the density matrix!"); this->cal_dk_k( GridT ); if(KS_SOLVER=="genelpa" || KS_SOLVER=="scalapack_gvx") // Peize Lin test 2019-05-15 + { wfc_dm_2d.cal_dm(wf.wg); - } //xiaohui add 2013-09-02. Attention... + } + } for(int is=0; is fac, Record_adj RA, const int ia1, const int iw1_lo, const int nw1, const int gstart, complex *WFC_PHASE, complex **DM_ATOM) @@ -756,9 +645,13 @@ void Local_Orbital_Charge::cal_dk_k(const Grid_Technique >) { DM_ATOM_SIZE=ng; for(int is=0; is[DM_ATOM_SIZE]; + } } for(int is=0; isDM[is][i], lgd_now); - } - } - for(int is=0; is **DM_B_pool; // Buffer parameters for tranforming 2D block-cyclic distributed DM matrix // to grid distributed DM matrix @@ -68,6 +75,7 @@ class Local_Orbital_Charge double* receiver_buffer; int setAlltoallvParameter(MPI_Comm comm_2D, int blacs_ctxt, int nblk); + void cal_dk_gamma_from_2D(void); }; diff --git a/ABACUS.develop/source/src_lcao/mulliken_charge.h b/ABACUS.develop/source/src_lcao/mulliken_charge.h index 4050745a22..fea1d3887d 100644 --- a/ABACUS.develop/source/src_lcao/mulliken_charge.h +++ b/ABACUS.develop/source/src_lcao/mulliken_charge.h @@ -1,5 +1,5 @@ -#ifndef Mulliken_Charge_H -#define Mulliken_Charge_H +#ifndef MULLIKEN_CHARGE_H +#define MULLIKEN_CHARGE_H //#include "../src_pw/tools.h" #include "../src_pw/tools.h" @@ -18,7 +18,6 @@ #include "../src_external/src_pdiag/GenELPA.h" - class Mulliken_Charge { public: diff --git a/ABACUS.develop/source/src_lcao/wfc_dm_2d.cpp b/ABACUS.develop/source/src_lcao/wfc_dm_2d.cpp index 87d31a7059..cbe87159e3 100644 --- a/ABACUS.develop/source/src_lcao/wfc_dm_2d.cpp +++ b/ABACUS.develop/source/src_lcao/wfc_dm_2d.cpp @@ -34,9 +34,13 @@ void Wfc_Dm_2d::cal_dm(const matrix &wg) static int istep=0; ofstream ofs("wfc_"+TO_STRING(istep++)+"_"+TO_STRING(MY_RANK)); if(GAMMA_ONLY_LOCAL) + { ofs<=0) + { wg_local[ib_local] = wg(ik,ib_global); + } } // wg_wfc(ib,iw) = wg[ib] * wfc(ib,iw); matrix wg_wfc(wfc_gamma[ik]); for(int ir=0; ir!=wg_wfc.nr; ++ir) + { LapackConnector::scal( wg_wfc.nc, wg_local[ir], wg_wfc.c+ir*wg_wfc.nc, 1 ); + } // C++: dm(iw1,iw2) = wfc(ib,iw1).T * wg_wfc(ib,iw2) const double one_float=1.0, zero_float=0.0; @@ -109,13 +129,17 @@ void Wfc_Dm_2d::cal_dm(const matrix &wg, const int ik) { const int ib_local = ParaO.trace_loc_col[ib_global]; if(ib_local>=0) + { wg_local[ib_local] = wg(ik,ib_global); + } } // wg_wfc(ib,iw) = wg[ib] * wfc(ib,iw).conj(); ComplexMatrix wg_wfc = conj(wfc_k[ik]); for(int ir=0; ir!=wg_wfc.nr; ++ir) + { LapackConnector::scal( wg_wfc.nc, wg_local[ir], wg_wfc.c+ir*wg_wfc.nc, 1 ); + } // C++: dm(iw1,iw2) = wfc(ib,iw1).T * wg_wfc(ib,iw2) const double one_float=1.0, zero_float=0.0; @@ -131,4 +155,6 @@ void Wfc_Dm_2d::cal_dm(const matrix &wg, const int ik) &zero_float, dm_k[ik].c, &one_int, &one_int, ParaO.desc); } -} \ No newline at end of file + + return; +} diff --git a/ABACUS.develop/source/src_lcao/wfc_dm_2d.h b/ABACUS.develop/source/src_lcao/wfc_dm_2d.h index e86c2bbff4..f126c0b9f7 100644 --- a/ABACUS.develop/source/src_lcao/wfc_dm_2d.h +++ b/ABACUS.develop/source/src_lcao/wfc_dm_2d.h @@ -15,15 +15,22 @@ class Wfc_Dm_2d public: + // wfc stands for wave functions std::vector wfc_gamma; // wfc_gamma[is](ib,iw); + std::vector wfc_k; // wfc_k[ik](ib,iw); + + // dm stands for density matrix std::vector dm_gamma; // dm_gamma[is](iw1,iw2); + std::vector dm_k; // dm_k[ik](iw1,iw2); - void init(); + void init(void); + void cal_dm(const matrix &wg); // wg(ik,ib), cal all dm + void cal_dm(const matrix &wg, const int ik); // wg(ik,ib), cal only dm[ik] - // dm = wfc.T * wg * wfc.conj() + // dm = wfc.T * wg * wfc.conj() }; #endif From da48babcc9f98fd30566fc300327aa1015b50f9a Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 16 Feb 2021 22:44:00 +0800 Subject: [PATCH 124/233] delete useless comments in pseudo files --- ABACUS.develop/source/src_pw/1 | 136 ++++++++++++++++++ ABACUS.develop/source/src_pw/charge.h | 20 ++- ABACUS.develop/source/src_pw/pseudo_atom.h | 13 +- ABACUS.develop/source/src_pw/pseudo_h.h | 51 +------ ABACUS.develop/source/src_pw/pseudo_nc.h | 18 +-- ABACUS.develop/source/src_pw/pseudo_us.h | 23 +-- ABACUS.develop/source/src_pw/pseudo_vl.h | 12 +- .../source/src_pw/pseudopot_cell_vl.h | 7 - 8 files changed, 169 insertions(+), 111 deletions(-) create mode 100644 ABACUS.develop/source/src_pw/1 diff --git a/ABACUS.develop/source/src_pw/1 b/ABACUS.develop/source/src_pw/1 new file mode 100644 index 0000000000..61d875a2cb --- /dev/null +++ b/ABACUS.develop/source/src_pw/1 @@ -0,0 +1,136 @@ + 11 sto_iter.cpp + 12 sto_che.cpp + 13 algorithms.h + 15 param + 16 symm_other.h + 18 wavefunc_in_pw.h + 20 symmetry_rho.h + 25 threshold_elec.h + 25 xc_gga_pw.h + 26 sto_che.h + 30 pseudo_vl.h + 31 sto_iter.h + 32 mdNVT.h + 36 sto_elec.h + 36 sto_hchi.h + 37 wf_igk.h + 38 atom_pseudo.h + 38 sto_hchi.cpp + 39 efield.h + 39 pseudo_vl.cpp + 41 exx_global.h + 41 potential_libxc.h + 42 global.cpp + 43 pseudo_nc.h + 43 sto_wf.cpp + 44 mdNVE.h + 45 charge_broyden.h + 45 electrons.h + 46 forces.h + 46 pseudo_atom.h + 46 pseudo_us.h + 46 sto_wf.h + 46 wf_atomic.h + 47 charge_extra.h + 48 tools.h + 49 atom_spec.h + 49 ions.h + 49 magnetism.h + 51 use_fft.h + 52 hamilt.h + 52 pseudopot_cell_vl.h + 52 vdwd2.h + 53 charge_mixing.h + 61 pw_complement.h + 64 wavefunc.h + 69 unitcell_pseudo.h + 70 global.h + 70 Makefile + 70 symmetry_basic.h + 72 charge_pulay.h + 73 pseudo_us.cpp + 75 pseudo_nc.cpp + 75 pseudopot_cell_us.h + 75 soc.h + 81 charge.h + 84 potential.h + 84 pseudopot_cell_vnl.h + 85 occupy.h + 86 symmetry_rho.cpp + 86 xc_functional.h + 89 hamilt_pw.h + 89 pseudo_h.h + 90 unitcell.h + 91 klist.h + 93 exx_lip.h + 105 symmetry.h + 107 diago_david.h + 109 energy.h + 111 md.h + 114 diago_cg.h + 117 pseudopot_upf.h + 128 magnetism.cpp + 131 symm_other.cpp + 133 vdwd3.h + 137 stress.h + 138 xc_type.h + 140 pseudo_atom.cpp + 147 use_fft.cpp + 161 pseudo_h.cpp + 163 atom_spec.cpp + 173 pw_basis.h + 191 vdwd2.cpp + 192 vdwd2_parameters.cpp + 199 atom_pseudo.cpp + 212 wf_igk.cpp + 213 threshold_elec.cpp + 223 soc.cpp + 247 pseudopot_cell_vl.cpp + 252 myfunc.h + 260 vdwd3.cpp + 268 unitcell.cpp + 287 efield.cpp + 290 charge_mixing.cpp + 307 xc_type.cpp + 316 potential_libxc.cpp + 373 xc_1.cpp + 401 sto_elec.cpp + 436 mdNVE.cpp + 450 pw_complement.cpp + 456 mdNVT.cpp + 471 ions.cpp + 474 xc_gga_pw.cpp + 483 wf_atomic.cpp + 491 charge_broyden.cpp + 513 hamilt.cpp + 534 charge_extra.cpp + 539 diago_cg.cpp + 542 electrons.cpp + 573 diago_david.cpp + 610 pseudopot_cell_us.cpp + 624 xc_2.cpp + 632 pseudopot_cell_vnl.cpp + 648 wavefunc_in_pw.cpp + 728 charge_pulay.cpp + 751 energy_dos.cpp + 843 wavefunc.cpp + 877 forces.cpp + 919 hamilt_pw.cpp + 927 energy.cpp + 929 exx_lip.cpp + 1144 pw_basis.cpp + 1157 occupy.cpp + 1175 symmetry_basic.cpp + 1177 xc_functional.cpp + 1194 xc_3.cpp + 1216 md.cpp + 1229 klist.cpp + 1654 potential.cpp + 1712 unitcell_pseudo.cpp + 1767 symmetry.cpp + 1786 charge.cpp + 1827 stress.cpp + 2298 pseudopot_upf.cpp + 2719 dftd3_subroutine.f + 32444 vdwd3_parameters.cpp + 78639 total diff --git a/ABACUS.develop/source/src_pw/charge.h b/ABACUS.develop/source/src_pw/charge.h index da215cd662..355cf2984d 100644 --- a/ABACUS.develop/source/src_pw/charge.h +++ b/ABACUS.develop/source/src_pw/charge.h @@ -44,14 +44,25 @@ class Charge double *start_mag_atom; void init(); + void atomic_rho(const int spin_number_need, double **rho_in)const; + void set_rho_core(const ComplexMatrix &structure_factor); - void write_rho(const int &is, const int &iter, const string &fn, const int &precision = 11, const bool for_plot = false);//mohan add 2007-10-17 - void write_rho_dipole(const int &is, const int &iter, const string &fn, const int &precision = 11, const bool for_plot = false);//fuxiang add 2017-3-15 + + void write_rho(const int &is, const int &iter, const string &fn, + const int &precision = 11, const bool for_plot = false);//mohan add 2007-10-17 + + void write_rho_dipole(const int &is, const int &iter, const string &fn, + const int &precision = 11, const bool for_plot = false);//fuxiang add 2017-3-15 + bool read_rho(const int &is, const string &fn);//mohan add 2007-10-17 + void sum_band(void); + void renormalize_rho(void); + void save_rho_before_sum_band(void); + void non_linear_core_correction// drhoc ( const bool &numeric, @@ -66,13 +77,16 @@ class Charge void init_final_scf(); //LiuXh add 20180619 -private: + private: void sum_band_k(); + void rho_mpi(void); + double sum_rho(void) const; bool allocate_rho; + bool allocate_rho_final_scf; //LiuXh add 20180606 }; diff --git a/ABACUS.develop/source/src_pw/pseudo_atom.h b/ABACUS.develop/source/src_pw/pseudo_atom.h index fcfbf41712..470dfc910f 100644 --- a/ABACUS.develop/source/src_pw/pseudo_atom.h +++ b/ABACUS.develop/source/src_pw/pseudo_atom.h @@ -1,13 +1,3 @@ -//===================================================================== -// Atomic part -// ... // the mesh where the PP is defined -// ... // non-linear core correction, optional -// ... // atomic charge density -// ... // atomic wavfunctions -// The variables needed to describe the atoms and related quantities -// based on atom.f90 -// USE parameters, ONLY : npsx, ndmx, nchix //maybe not necessary -//===================================================================== #ifndef PSEUDO_ATOM_H #define PSEUDO_ATOM_H @@ -17,7 +7,8 @@ class pseudo_atom: public pseudo_h { -public: + public: + // double *r; // radial logaritmic mesh, r[0:mesh-1] double *rab; // derivative of the radial mesh, rab[0:mesh-1] diff --git a/ABACUS.develop/source/src_pw/pseudo_h.h b/ABACUS.develop/source/src_pw/pseudo_h.h index 097ba808ce..24eda08d38 100644 --- a/ABACUS.develop/source/src_pw/pseudo_h.h +++ b/ABACUS.develop/source/src_pw/pseudo_h.h @@ -1,9 +1,3 @@ -/***************************************************************** -// General information part -// base on pseudo_type.f90, -// ... // for reader's information only -// ... // general information about the pseudopotential -*******************************************************************/ #ifndef PSEUDOH_H #define PSEUDOH_H @@ -19,6 +13,9 @@ class pseudo_h { public: + pseudo_h(); + ~pseudo_h(); + // bool has_so; // if .true. includes spin-orbit int nv; // UPF file version number @@ -39,51 +36,13 @@ class pseudo_h int *lchi; // lchi[nchi] double *oc; // oc[nchi] - /* */ -// char generated[80]; // author -// char date_author[80]; // Misc info -// char comment[80]; // -// int * nn; // nn(nwfc) -// double * rcut; // cut-off radius(nwfc) ?? -// double * rcutus; // cut-off ultrasoft radius (nwfc) -// double * epseu; // energy (nwfc) -// double xmin; // the minimum x of the linear mesh -// double rmax; // the maximum radius of the mesh -// double zmesh; // the nuclear charge used for mesh -// double dx; // the deltax of the linear mesh -// double *jchi; // jchi(nwfc) - double *jjj; // total angual momentum, jjj[nbeta] - double *jchi; //jchi(nwfc), added by zhengdy-soc + double *jjj; // total angual momentum, jjj[nbeta] + double *jchi; //jchi(nwfc), added by zhengdy-soc int *nn; - pseudo_h(); - ~pseudo_h(); - // member functions void set_pseudo_h(const Pseudopot_upf &upf); void print_pseudo_h(ofstream &ofs); }; #endif // PSEUDOH_H - -/* -// pseudo-potential that has spin-orboit term -// We are not going to implement this PP in the first version -// USE parameters, ONLY : lqmax, nbrx, npsx, nqfx, ndmx - -#ifndef PSEUDO_SO_H -#define PSEUDO_SO_H - -class pseudo_so:public pseudo_us -{ - double *jjj; //(nbrx,npsx), &! total angular momentum of the beta function -// pseudo_us uspp; // if SO+USPP - - pseudo_so(); - ~pseudo_so(); - - void set_pseudo_upf(); - -}; -#endif // PSEUDO_SO_H -*/ diff --git a/ABACUS.develop/source/src_pw/pseudo_nc.h b/ABACUS.develop/source/src_pw/pseudo_nc.h index 99ee5b104b..80b8f4f61d 100644 --- a/ABACUS.develop/source/src_pw/pseudo_nc.h +++ b/ABACUS.develop/source/src_pw/pseudo_nc.h @@ -1,14 +1,3 @@ -/************************************************************* -// Norm conserving NON-LOCAL pseudopotential (NCNL-PP) -// include pseudo_vl -// ... // projector -// ... // d(i,j) - -// Norm-conserving (atomitic) potential -// based on MODULE uspp_param -// USE parameters, ONLY : lqmax, nbrx, npsx, nqfx, ndmx -*************************************************************/ - #ifndef PSEUDO_NC_H #define PSEUDO_NC_H @@ -18,9 +7,11 @@ class pseudo_nc: public pseudo_vl { - public: + pseudo_nc(); + ~pseudo_nc(); + // int *lll; // lll(nbeta), angular momentum of the beta function int kkbeta; // kkbeta(nbeta), point where the beta are zero @@ -32,9 +23,6 @@ class pseudo_nc: public pseudo_vl // other int nh; // number of beta functions per atomic type - pseudo_nc(); - ~pseudo_nc(); - void set_pseudo_nc(const Pseudopot_upf &upf); void print_pseudo_nc(ofstream &ofs); diff --git a/ABACUS.develop/source/src_pw/pseudo_us.h b/ABACUS.develop/source/src_pw/pseudo_us.h index 5b7a8ff66d..5a2897b2b5 100644 --- a/ABACUS.develop/source/src_pw/pseudo_us.h +++ b/ABACUS.develop/source/src_pw/pseudo_us.h @@ -1,17 +1,3 @@ -/************************************************************ -// Ultrasoft pseudopotential (US-PP) -// include pseudo_nc -// ... //psudo-charge - -//We are not going to implement this PP in the first version -//but we still construct the PP here for future reference - -// based on MODULE uspp_param -// USE parameters, ONLY : lqmax, nbrx, npsx, nqfx, ndmx -#ifndef PSEUDO_US_H -#define PSEUDO_US_H -************************************************************/ - #ifndef PSEUDO_US_H #define PSEUDO_US_H @@ -21,7 +7,11 @@ class pseudo_us: public pseudo_nc { -public: + public: + + pseudo_us(); + ~pseudo_us(); + // int nqf; // @@ -35,9 +25,6 @@ class pseudo_us: public pseudo_nc // other ? int nqlc; // number of angular momenta in Q - pseudo_us(); - ~pseudo_us(); - void set_pseudo_us(const Pseudopot_upf &upf); void print_pseudo_us(ofstream &ofs); diff --git a/ABACUS.develop/source/src_pw/pseudo_vl.h b/ABACUS.develop/source/src_pw/pseudo_vl.h index 0768333991..458cf14084 100644 --- a/ABACUS.develop/source/src_pw/pseudo_vl.h +++ b/ABACUS.develop/source/src_pw/pseudo_vl.h @@ -1,14 +1,3 @@ -/********************************************************************** -// LOCAL pseudopotential (PP) -// include pseudo_info,pseudo_atom -// ... // local part of the potential - -// Local part of the (atomitic) potential -// based on MODULE uspp_param -// USE parameters, ONLY : lqmax, nbrx, npsx, nqfx, ndmx - -**********************************************************************/ - #ifndef PSEUDO_VL_H #define PSEUDO_VL_H @@ -18,6 +7,7 @@ class pseudo_vl: public pseudo_atom { public: + double *vloc_at; // [mesh], local potential( = pseudopot_upf.vloc ) pseudo_vl(); diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_vl.h b/ABACUS.develop/source/src_pw/pseudopot_cell_vl.h index 1b51af0673..18469bedce 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_vl.h +++ b/ABACUS.develop/source/src_pw/pseudopot_cell_vl.h @@ -21,13 +21,7 @@ class pseudopot_cell_vl private: - // MODULE pseud - // The variables describing pseudopotentials in analytical form -// matrix cc; // (2,npsx); the coefficients of the erf functions -// matrix alpc; // (2,npsx); the alpha of the erf functions double *zp; // (npsx),the charge of the pseudopotential -// realArray aps; // (6,0:3,npsx); the a_l coefficient -// realArray alps; // (3,0:3,npsx); the b_l coefficient // double *a_nlcc; // (npsx), nonlinear core correction coefficients: // double *b_nlcc; // (npsx), rho_c(r) = (a_c + b_c*r^2) exp(-alpha_c*r^2) @@ -37,7 +31,6 @@ class pseudopot_cell_vl // int *nnl; //(npsx), number of the gaussian functions // int *lmax; //(npsx), maximum angular momentum of the pseudopot // int *lloc; //(npsx), angular momentum of the part taken as local - // END MODULE pseud void allocate(void); From e9abf2ef4f65c13623d37d3b57f7afb223a63b93 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 17 Feb 2021 07:04:47 +0800 Subject: [PATCH 125/233] update README, delete useless variables in global_variable --- ABACUS.develop/source/README | 20 +++++++++++++++++++ .../source/src_global/global_variable.cpp | 4 ---- .../source/src_global/global_variable.h | 14 ++++--------- .../source/src_lcao/gint_gamma_rho.cpp | 18 +++++++++++++++++ 4 files changed, 42 insertions(+), 14 deletions(-) diff --git a/ABACUS.develop/source/README b/ABACUS.develop/source/README index 7c8bf12f78..f6c80e1a9b 100644 --- a/ABACUS.develop/source/README +++ b/ABACUS.develop/source/README @@ -2,3 +2,23 @@ Currently we are working on optimizing the code structure of ABACUS, implementing new functions, and adding more autotests. -- mohan 2021-02-11 + +URGENT: + +Ask Xiaohui Liu: all functions named with 'after_vc' should be reconstructed +(condition: need to reconstruct these codes within a given time) + +Ask Fuxiang He: we need to remove all TDDFT-related global variables +in global_variable.h +(condition: need to reconstruct these codes within a given time) + +Ask Daye Zheng: MD, force, stress modules need reconstruction + +NEED TO DO: + +Ask Xiaohui: we need to remove DQ and NQX in global_variable.h, +but the NQX is computed in ./src_pw/pseudopot_cell_vnl.cpp + +Ask Peize: explain exx_lip.h + + diff --git a/ABACUS.develop/source/src_global/global_variable.cpp b/ABACUS.develop/source/src_global/global_variable.cpp index 7068c2d09d..d7f33e1b98 100644 --- a/ABACUS.develop/source/src_global/global_variable.cpp +++ b/ABACUS.develop/source/src_global/global_variable.cpp @@ -131,8 +131,6 @@ ofstream ofs_warning; //---------------------------------------------------------- // EXPLAIN : test level for each class //---------------------------------------------------------- -int test_run = 0; - int test_input = 0; int test_winput = 0; int test_kpoint = 0; @@ -148,8 +146,6 @@ int test_wf = 0; int test_charge = 0; int test_potential = 0; int test_energy = 0; - -int test_geo; //---------------------------------------------------------- // src_lcao //---------------------------------------------------------- diff --git a/ABACUS.develop/source/src_global/global_variable.h b/ABACUS.develop/source/src_global/global_variable.h index 1519c4a555..30c41a585c 100644 --- a/ABACUS.develop/source/src_global/global_variable.h +++ b/ABACUS.develop/source/src_global/global_variable.h @@ -17,7 +17,7 @@ using namespace std; // EXPLAIN : Basic Global Variables //========================================================== -extern int NBANDS; // 1 +extern int NBANDS; extern int NBANDS_ISTATE; // 1.05 // mohan add 2011-03-22 extern int NLOCAL; // 1.1 // mohan add 2009-05-29 @@ -38,8 +38,8 @@ extern double PRESS1; extern double PRESS2; extern double PRESS3; extern double PRESSURE; -extern string MOVE_IONS; // 8.26 -extern string OUT_LEVEL; // 8.27 +extern string MOVE_IONS; +extern string OUT_LEVEL; extern int NSTEP; // 8.3 extern int NITER; // 8.4 @@ -60,8 +60,7 @@ extern bool DOMAG_Z; //1 : constrain the magnetism to z axis extern int NPOL; //1 : no soc; 2 : has soc extern int PRENSPIN; //NSPIN used before, for restart with soc -// diagonalization (5) -//extern string DIAGO_TYPE; xiaohui modify 2013-09-01 // 12 "cg","davidson","fs","hpseps" + extern int DIAGO_PROC; // 12.1 number of processors used to diag. extern int DIAGO_CG_MAXITER; // 13 extern int DIAGO_CG_PREC; // 13.1 @@ -159,8 +158,6 @@ extern ofstream ofs_warning; //========================================================== // EXPLAIN : test level for each class //========================================================== -extern int test_run; - extern int test_input; extern int test_winput; extern int test_kpoint; @@ -176,7 +173,6 @@ extern int test_wf; extern int test_charge; extern int test_potential; extern int test_energy; -extern int test_geo; // mohan add 2011-03-17 //========================================================== // src_onscaling //========================================================== @@ -194,8 +190,6 @@ extern int test_gridt; // mohan add 2011-03-17 extern int test_pseudo_cell; extern int test_pp; extern int test_kmesh; -extern int test_mlwf_overlap; -extern int test_mlwf_optimize; extern int test_ion_dynamics; //========================================================== // src_tools diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp index 5925bb3c3f..41bd5bc8b9 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp @@ -338,19 +338,33 @@ double Gint_Gamma::gamma_charge(void) // Peize Lin update OpenMP 2020.09.28 int *block_size=new int[max_size]; //band size: number of columns of a band int *block_index=new int[max_size+1]; int *at=new int[max_size]; + double *psir_ylm_pool=new double[pw.bxyz*LD_pool]; ZEROS(psir_ylm_pool, pw.bxyz*LD_pool); + double **psir_ylm=new double *[pw.bxyz]; + for(int i=0; i Date: Wed, 17 Feb 2021 14:40:07 +0800 Subject: [PATCH 126/233] delete ParaA global class, delete parallel_atoms.h and .cpp, delete ATOM_DISTRIBUTION input option in input.h and input.cpp --- ABACUS.develop/source/Makefile.Objects | 1 - ABACUS.develop/source/driver.cpp | 2 +- ABACUS.develop/source/input.cpp | 10 -- ABACUS.develop/source/input.h | 1 - ABACUS.develop/source/input_conv.cpp | 1 - .../source/src_global/global_variable.cpp | 1 - .../source/src_global/global_variable.h | 1 - ABACUS.develop/source/src_lcao/LCAO_diago.cpp | 159 ------------------ .../source/src_lcao/LCAO_matrix.cpp | 154 +---------------- ABACUS.develop/source/src_lcao/global_fp.cpp | 1 - ABACUS.develop/source/src_lcao/global_fp.h | 2 - .../source/src_lcao/local_orbital_charge.h | 4 +- .../source/src_parallel/parallel_atoms.cpp | 143 ---------------- .../source/src_parallel/parallel_atoms.h | 24 --- .../source/src_parallel/parallel_kpoints.cpp | 2 +- .../source/src_parallel/parallel_kpoints.h | 3 +- .../source/src_parallel/parallel_orbitals.cpp | 79 +++------ .../source/src_parallel/parallel_orbitals.h | 1 + .../source/src_parallel/subgrid_oper.cpp | 10 +- 19 files changed, 35 insertions(+), 564 deletions(-) delete mode 100644 ABACUS.develop/source/src_parallel/parallel_atoms.cpp delete mode 100644 ABACUS.develop/source/src_parallel/parallel_atoms.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index f8a34722a6..890b5b6957 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -146,7 +146,6 @@ force_lcao.o\ force_lcao_gamma.o\ force_lcao_k.o\ stress_lcao.o\ -parallel_atoms.o \ parallel_orbitals.o \ global_fp.o \ pdiag_double.o \ diff --git a/ABACUS.develop/source/driver.cpp b/ABACUS.develop/source/driver.cpp index 3a76970bf7..a9f198f57b 100644 --- a/ABACUS.develop/source/driver.cpp +++ b/ABACUS.develop/source/driver.cpp @@ -57,7 +57,7 @@ void Driver::reading(void) #ifdef __MPI // (4) divide the NPROC processors into NPOOL for k-points parallelization. - Pkpoints.init(); + Pkpoints.init_pools(); #endif // (5) Read in parameters about wannier functions. diff --git a/ABACUS.develop/source/input.cpp b/ABACUS.develop/source/input.cpp index 41f413289c..1e4e686df3 100644 --- a/ABACUS.develop/source/input.cpp +++ b/ABACUS.develop/source/input.cpp @@ -160,7 +160,6 @@ void Input::Default(void) search_radius=-1.0; // unit: a.u. -1.0 has no meaning. search_pbc=true; sparse_matrix=false; - atom_distribution=0; symmetry=false; mlwf_flag=false; vna = 0; @@ -696,10 +695,6 @@ bool Input::Read(const string &fn) { read_value(ifs, sparse_matrix); } - else if (strcmp("atom_distribution", word) == 0) - { - read_value(ifs, atom_distribution); - } else if (strcmp("symmetry", word) == 0) { read_value(ifs, symmetry); @@ -1996,7 +1991,6 @@ void Input::Bcast() Parallel_Common::bcast_double( search_radius ); Parallel_Common::bcast_bool( search_pbc ); Parallel_Common::bcast_bool ( sparse_matrix ); - Parallel_Common::bcast_int ( atom_distribution ); Parallel_Common::bcast_double( search_radius ); Parallel_Common::bcast_bool( symmetry ); Parallel_Common::bcast_bool( mlwf_flag ); @@ -2671,9 +2665,6 @@ void Input::Check(void) //else if(diago_type == "cg" ) else if (ks_solver == "cg") { - //ofs_warning << " Use CG method in LCAO." << endl; xiaohui 2013-09-04 - //atom_distribution=1; xiaohui 2013-09-04 - //AUTO_SET("atom_distribution",1); xiaohui 2013-09-04 WARNING_QUIT("Input","not ready for cg method in lcao ."); //xiaohui add 2013-09-04 } //else if( diago_type == "hpseps" ) @@ -3191,7 +3182,6 @@ void Input::Print(const string &fn)const //OUTP(ofs,"gamma_only_pw",gamma_only,"gamma only in pw"); OUTP(ofs,"npool",npool,"number of pools for k points, pw only"); OUTP(ofs,"sparse_matrix",sparse_matrix,"use sparse matrix, in DMM"); - OUTP(ofs,"atom_distribution",atom_distribution,"distribute atoms, in DMM"); OUTP(ofs,"mem_saver",mem_saver,"memory saver for many k points used"); OUTP(ofs,"printe",printe,"print band energy for selectively ionic steps"); diff --git a/ABACUS.develop/source/input.h b/ABACUS.develop/source/input.h index e0d4a81c0b..1a25760ab1 100644 --- a/ABACUS.develop/source/input.h +++ b/ABACUS.develop/source/input.h @@ -90,7 +90,6 @@ class Input string basis_type; //xiaohui add 2013-09-01, for structural adjustment string ks_solver; //xiaohui add 2013-09-01 bool sparse_matrix; - int atom_distribution; int vna; //control the vna term. int grid_speed; //1:normal 2:fast, mohan add 2012-03-29 diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index 4baafa2a09..6eaa24b5fa 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -134,7 +134,6 @@ void Input_Conv::Convert(void) SEARCH_RADIUS = INPUT.search_radius; SEARCH_PBC = INPUT.search_pbc; SPARSE_MATRIX = INPUT.sparse_matrix; - ATOM_DISTRIBUTION = INPUT.atom_distribution; //---------------------------------------------------------- // planewave (8/8) diff --git a/ABACUS.develop/source/src_global/global_variable.cpp b/ABACUS.develop/source/src_global/global_variable.cpp index d7f33e1b98..e689d1bd7c 100644 --- a/ABACUS.develop/source/src_global/global_variable.cpp +++ b/ABACUS.develop/source/src_global/global_variable.cpp @@ -47,7 +47,6 @@ string KS_SOLVER = "cg"; //xiaohui add 2013-09-01 double SEARCH_RADIUS = -1.0; bool SEARCH_PBC = true; bool SPARSE_MATRIX = false; -int ATOM_DISTRIBUTION = false; int DIAGO_PROC = 0; int DIAGO_CG_MAXITER = 30; diff --git a/ABACUS.develop/source/src_global/global_variable.h b/ABACUS.develop/source/src_global/global_variable.h index 30c41a585c..7dcef7b269 100644 --- a/ABACUS.develop/source/src_global/global_variable.h +++ b/ABACUS.develop/source/src_global/global_variable.h @@ -50,7 +50,6 @@ extern string KS_SOLVER; //xiaohui add 2013-09-01 extern double SEARCH_RADIUS; // 11.1 // mohan add 2011-03-10 extern bool SEARCH_PBC; // 11.2 // mohan add 2011-03-10 extern bool SPARSE_MATRIX; // 11.3 // mohan add 2009-03-13 -extern int ATOM_DISTRIBUTION; // 11.4 // mohan add 2010-06-28 //added by zhengdy-soc extern bool NONCOLIN; //0 : collinear ; 1 : non-collinear diff --git a/ABACUS.develop/source/src_lcao/LCAO_diago.cpp b/ABACUS.develop/source/src_lcao/LCAO_diago.cpp index 8dd180a9cb..1c8fa0028f 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_diago.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_diago.cpp @@ -272,162 +272,3 @@ void Diago_LCAO_Matrix::using_LAPACK(const int &ik, double** wfc)const delete[] work; return; } - - -#include "local_orbital_elec.h" -//#include "../src_develop/src_cg/cg_lcao.h" -//#include "../src_develop/src_cg/cg_precon.h" -/* -void Diago_LCAO_Matrix::using_CG(const int &ik, double **c)const -{ - TITLE("Diago_LCAO_Matrix","using_CG"); - timer::tick("Diago_LCAO_Matrix","using_CG",'I'); - int notconv = 0; - double cg_iter=0.0; - - // out.printcm_norm("Cij_0", this->Cij, 1.0e-5); - // ZEROS(en, NBANDS); - -// cout << " ParaA.nlocal=" << ParaA.nlocal << endl; -// cout << " ParaO.nrow=" << ParaO.nrow << endl; - - double *precon = new double[ParaA.nlocal]; - assert(ParaA.nlocal == ParaO.nrow); - CG_precon::select_precondition(DIAGO_CG_PREC, precon); - - - bool reorder = true; - //bool reorder = false; - if(ATOM_DISTRIBUTION) - { - // 'c' is the wave functions after parallized. - // because c is adapted to grid integration, - // and used to generate density matrix, - // however, ccg is here is divided by atoms and adapted - // to the CG algorithm. - double** ccg = new double*[NBANDS]; - for(int ib=0; ib=0) - { - buffer[iw] = c[ib][nu]; - } - } - Parallel_Reduce::reduce_double_all(buffer,NLOCAL); - - // collect the trace_lo; - ZEROS(countb, NLOCAL); - for(int iw=0; iw=0) - { - countb[iw]=1; - } - } - // collect countb - Parallel_Reduce::reduce_int_all(countb, NLOCAL); - // and then get the correct final wave functions - for(int iw=0; iw0); - buffer[iw] /= (double)countb[iw]; - } - - // transfer wave functions from 'c' to ccg - for(int iw=0; iw=0 ) - { - ccg[ib][mu] = buffer[iw]; - } - } - } - delete[] countb; - - CG_LCAO CGL; - CGL.diag( ccg, wf.ekb[ik], ParaA.nlocal, NBANDS, precon, ETHR, DIAGO_CG_MAXITER, reorder, notconv, cg_iter); - - for(int ib=0; ib= 0 ) - { - buffer[iw] = ccg[ib][mu]; - } - } - // reduce the wave functions. - Parallel_Reduce::reduce_double_all(buffer, NLOCAL); - - // put the wave functions back to LOWF.WFC_GAMMA - for(int iw=0; iw= 0) - { - c[ib][mu] = buffer[iw]; - } - - - const int mu2 = LOWF.trace_aug[iw]; - if(GAMMA_ONLY_LOCAL) - { - if(mu2 >= 0) - { - LOWF.WFC_GAMMA_aug[CURRENT_SPIN][ib][mu2] = buffer[iw]; - } - } - else - { - WARNING_QUIT("using_CG","how to update augmented wave functions."); - } - } - } - - delete[] buffer; - - for(int ib=0; ibCij, 1.0e-5); - // out.printr1_d("en",en,NBANDS); - - timer::tick("Diago_LCAO_Matrix","using_CG",'i'); - return; -} -*/ diff --git a/ABACUS.develop/source/src_lcao/LCAO_matrix.cpp b/ABACUS.develop/source/src_lcao/LCAO_matrix.cpp index 34b406f2c5..bbba7fd10b 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_matrix.cpp @@ -39,55 +39,40 @@ void LCAO_Matrix::divide_HS_in_frag(void) ofs_running << "\n SETUP THE DIVISION OF H/S MATRIX" << endl; // (1) calculate nrow, ncol, nloc. - if (KS_SOLVER=="genelpa" || KS_SOLVER=="hpseps" || KS_SOLVER=="scalpack" || KS_SOLVER=="selinv" || KS_SOLVER=="scalapack_gvx") //xiaohui add 2013-09-02 + if (KS_SOLVER=="genelpa" || KS_SOLVER=="hpseps" || KS_SOLVER=="scalpack" + || KS_SOLVER=="selinv" || KS_SOLVER=="scalapack_gvx") //xiaohui add 2013-09-02 { ofs_running << " divide the H&S matrix using 2D block algorithms." << endl; #ifdef __MPI ParaO.divide_HS_2d(DIAG_WORLD); #else - WARNING_QUIT("LCAO_Matrix::init","diago_type = 'HPSEPS' is not available for series version.\n You can use 'LAPACK' instead."); + WARNING_QUIT("LCAO_Matrix::init","diago method is not ready."); #endif } - else if(KS_SOLVER == "canonical" - || KS_SOLVER == "trace_resetting" - || KS_SOLVER == "trace_correcting") - { - //------------------------------------------------------------------------------------- - // This part is intended for linear-scaling solver for KS matrix utilizing - // the sparse matrices. The developments of these parts need to have efficient - // algorithms to design, distribute (parallel), and operate sprase Hamiltionian - // matrix (H), sparse density matrix (DM), and sparse overlap matrix (S),etc. - // in localized basis sets -- mohan 2021-01-31 - //------------------------------------------------------------------------------------- - ofs_running << " divide the H&S matrix according to atoms." << endl; - // done nothing. - // the nloc is calculated in "ParaA.set_trace" - } else { // the full matrix ParaO.nloc = NLOCAL * NLOCAL; } - // (2) set the trace, then we can calculate the nnr. // for 2d: calculate ParaO.nloc first, then trace_loc_row and trace_loc_col // for O(N): calculate the three together. ParaO.set_trace(); - - // (3) allocate matrix. if(GAMMA_ONLY_LOCAL) { + // allocate for S, H_fixed, H, and S_diag allocate_HS_gamma(ParaO.nloc); } else { + // allocate for S, H_fixed, H, and S_diag + // for version 2 allocate_HS_k(ParaO.nloc); } - return; } @@ -495,6 +480,7 @@ void LCAO_Matrix::print_HSgamma(const char &mtype, ostream &os) ofs_running << " nrow=" << ParaO.nrow << endl; ofs_running << " ncol=" << ParaO.ncol << endl; ofs_running << " element number = " << ParaO.ncol << endl; + if (mtype=='S') { os << setprecision(8); @@ -515,99 +501,9 @@ void LCAO_Matrix::print_HSgamma(const char &mtype, ostream &os) }//end j os << endl; }//end i - - /* - ofs_running << " " << setw(10) << "LocalRow" << setw(10) << "LocalCol" - << setw(10) << "GlobalRow" << setw(10) << "GloablCol" - << setw(10) << "Sloc" << endl; - for (int i=0; inrow; i++) - { - for (int j=0; jncol; j++) - { - if ( abs(Sloc[i * this->ncol + j]) > 1.0e-5 ) - ofs_running << " " << setw(10) << i << setw(10) << j - << setw(10) << MatrixInfo.row_set[i] << setw(10) << MatrixInfo.col_set[j] - << setw(10) << Sloc[i * this->ncol + j] << endl; - } - } - os << "\n Smatrix" << endl; - //ofs_running << setprecision(5) << endl; - - for(int i=0; i 1.0e-3 ) - { - // ofs_running << setw(5) << i+1 << setw(5) << j+1 << setw(12) << h << setw(12) << s << endl; - } - - - if( abs(s) > 1.0e-5 ) - { - ofs_running << setw(10) << s; - // ofs_running << setw(5) << i << setw(5) << j << setw(15) << s << endl; - - } - else - { - ofs_running << setw(10) << "0"; - } - } - ofs_running << endl; - } - */ } if (mtype=='T') { - - - /* - ofs_running << " " << setw(10) << "LocalRow" << setw(10) << "LocalCol" - << setw(10) << "GlobalRow" << setw(10) << "GloablCol" - << setw(10) << "Hloc_fixed" << endl; - for (int i=0; i 1.0e-5 ) - { - ofs_running << " " << setw(10) << i+1 << setw(10) << j+1; - - //mohan fix bug 2012-02-22 - if(ATOM_DISTRIBUTION!=1) - { - ofs_running << setw(10) << ParaO.MatrixInfo.row_set[i] << setw(10) << ParaO.MatrixInfo.col_set[j]; - } - else - { - ofs_running << setw(10) << "0" << setw(10) << "0"; - } - ofs_running << setw(10) << Hloc_fixed[i * ParaO.ncol + j] << endl; - } - } - } - for(int i=0; i 1.0e-5 ) - { - ofs_running << setw(15) << v; - } - else - { - ofs_running << setw(15) << "0"; - } - } - ofs_running << endl; - } - */ - os << " print Hloc_fixed" << endl; for(int i=0; i 1.0e-5 ) - { - // ofs_running << " " << setw(10) << i << setw(10) << j - // << setw(10) << ParaO.MatrixInfo.row_set[i] << setw(10) << ParaO.MatrixInfo.col_set[j] - // << setw(10) << a << endl; - - // - ofs_running << setw(15) << a; - //ofs_running << setw(5) << i << setw(5) << j << setw(15) << a << endl; - - } - else - { - // - ofs_running << setw(15) << "0"; - } - } - // - ofs_running << endl; - } - */ } return; diff --git a/ABACUS.develop/source/src_lcao/global_fp.cpp b/ABACUS.develop/source/src_lcao/global_fp.cpp index c5f2bb6a74..30445aa85e 100644 --- a/ABACUS.develop/source/src_lcao/global_fp.cpp +++ b/ABACUS.develop/source/src_lcao/global_fp.cpp @@ -2,7 +2,6 @@ #include "src_pw/global.h" Grid_Driver GridD; -Parallel_Atoms ParaA; Parallel_Orbitals ParaO; Local_Orbital_Charge LOC; Local_Orbital_wfc LOWF; diff --git a/ABACUS.develop/source/src_lcao/global_fp.h b/ABACUS.develop/source/src_lcao/global_fp.h index fd12dc1c1a..4bb7f4cf50 100644 --- a/ABACUS.develop/source/src_lcao/global_fp.h +++ b/ABACUS.develop/source/src_lcao/global_fp.h @@ -3,7 +3,6 @@ #include "src_global/sltk_grid_driver.h" #include "src_lcao/grid_technique.h" -#include "src_parallel/parallel_atoms.h" #include "src_parallel/parallel_orbitals.h" #include "src_lcao/local_orbital_wfc.h" #include "src_lcao/local_orbital_charge.h" @@ -16,7 +15,6 @@ #include "src_ri/exx_lcao.h" extern Grid_Driver GridD; -extern Parallel_Atoms ParaA; extern Parallel_Orbitals ParaO; extern Local_Orbital_wfc LOWF; extern Local_Orbital_Charge LOC; diff --git a/ABACUS.develop/source/src_lcao/local_orbital_charge.h b/ABACUS.develop/source/src_lcao/local_orbital_charge.h index 921be38a85..bf40f268df 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_charge.h +++ b/ABACUS.develop/source/src_lcao/local_orbital_charge.h @@ -8,8 +8,8 @@ class Local_Orbital_Charge { -public: - friend class Trace_Rho_HS; + + public: Local_Orbital_Charge(); ~Local_Orbital_Charge(); diff --git a/ABACUS.develop/source/src_parallel/parallel_atoms.cpp b/ABACUS.develop/source/src_parallel/parallel_atoms.cpp deleted file mode 100644 index a502c7535d..0000000000 --- a/ABACUS.develop/source/src_parallel/parallel_atoms.cpp +++ /dev/null @@ -1,143 +0,0 @@ -#include "parallel_atoms.h" -#include "../src_pw/global.h" - -Parallel_Atoms::Parallel_Atoms() -{ - keep_this_atom = new bool[1]; - nat = 0; -} - -Parallel_Atoms::~Parallel_Atoms() -{ - delete[] keep_this_atom; -} - - -void Parallel_Atoms::cut_atoms(void) -{ - TITLE("Parallel_Atoms","cut_atoms"); - OUT(ofs_running,"TotalAtomNumber",ucell.nat); - OUT(ofs_running,"AtomDistribution",ATOM_DISTRIBUTION); - - delete[] keep_this_atom; - keep_this_atom = new bool[ucell.nat]; - for(int i=0; inat = 0; - this->nlocal = 0; - ofs_running << " Atom index in this processor." << endl; - for(int iat=0; iatkeep_this_atom[iat] ) - { - const int start = ucell.itiaiw2iwt(it, ia, 0); - for(int iw=0; iw=0 && trace_loc_col[j]>=0) - { - ofs_running << setw(8) << i+1 << setw(8) << j+1 - << setw(8) << trace_loc_row[i] << setw(8) << trace_loc_col[j] << endl; - } - } - } - */ - - return; -} diff --git a/ABACUS.develop/source/src_parallel/parallel_atoms.h b/ABACUS.develop/source/src_parallel/parallel_atoms.h deleted file mode 100644 index 84e2858257..0000000000 --- a/ABACUS.develop/source/src_parallel/parallel_atoms.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef PARALLEL_ATOMS_H -#define PARALLEL_ATOMS_H - -#include "../src_pw/tools.h" - -class Parallel_Atoms -{ - public: - - Parallel_Atoms(); - ~Parallel_Atoms(); - - bool* keep_this_atom; - int nat; // how many atoms on this processor. - int nlocal; // how many orbitals on this processor. - void cut_atoms(void); - void set_trace(int *trace_loc_row, int *trace_loc_col, int &nrow, int &ncol); - - private: - - -}; - -#endif diff --git a/ABACUS.develop/source/src_parallel/parallel_kpoints.cpp b/ABACUS.develop/source/src_parallel/parallel_kpoints.cpp index 8ec3401296..45a1f2ac12 100644 --- a/ABACUS.develop/source/src_parallel/parallel_kpoints.cpp +++ b/ABACUS.develop/source/src_parallel/parallel_kpoints.cpp @@ -15,7 +15,7 @@ Parallel_Kpoints::~Parallel_Kpoints() delete[] whichpool; } -void Parallel_Kpoints::init(void) +void Parallel_Kpoints::init_pools(void) { #ifdef __MPI //---------------------------------------------------------- diff --git a/ABACUS.develop/source/src_parallel/parallel_kpoints.h b/ABACUS.develop/source/src_parallel/parallel_kpoints.h index 9dbdfe3d44..2095ce0444 100644 --- a/ABACUS.develop/source/src_parallel/parallel_kpoints.h +++ b/ABACUS.develop/source/src_parallel/parallel_kpoints.h @@ -10,7 +10,8 @@ class Parallel_Kpoints Parallel_Kpoints(); ~Parallel_Kpoints(); - void init(); + void init_pools(); + void kinfo(int &nkstot); // collect value from each pool to wk. diff --git a/ABACUS.develop/source/src_parallel/parallel_orbitals.cpp b/ABACUS.develop/source/src_parallel/parallel_orbitals.cpp index 9a2854ff86..c1c1419797 100644 --- a/ABACUS.develop/source/src_parallel/parallel_orbitals.cpp +++ b/ABACUS.develop/source/src_parallel/parallel_orbitals.cpp @@ -1,7 +1,4 @@ #include "parallel_orbitals.h" -#include "parallel_atoms.h" - -extern Parallel_Atoms ParaA; Parallel_Orbitals::Parallel_Orbitals() { @@ -70,82 +67,46 @@ void Parallel_Orbitals::set_trace(void) Memory::record("Parallel_Orbitals","trace_loc_row",NLOCAL,"int"); Memory::record("Parallel_Orbitals","trace_loc_col",NLOCAL,"int"); - - - //if (DIAGO_TYPE=="lapack" - // || DIAGO_TYPE=="cg" - // || DIAGO_TYPE=="david") xiaohui modify 2013-09-02 //delete selinv here 2012-04-23 if(KS_SOLVER=="lapack" || KS_SOLVER=="cg" || KS_SOLVER=="dav") //xiaohui add 2013-09-02 - { - // mohan add special case for cg, 2012-02-15 - //if(DIAGO_TYPE=="cg" && LOCAL_BASIS==4 - // && LINEAR_SCALING==1 && ATOM_DISTRIBUTION==1) xiaohui modify 2013-09-02 - if(KS_SOLVER=="cg" && BASIS_TYPE=="lcao" && ATOM_DISTRIBUTION==1) //xiaohui add 2013-09-02 - { - ParaA.cut_atoms(); - ParaA.set_trace(this->trace_loc_row, this->trace_loc_col, - this->nrow, this->ncol); - this->nloc = nrow * ncol; - - cout << " ATOM TRACE ! " << endl; - } - else - { - cout << " common cg setting " << endl; - for (int i=0; inrow = NLOCAL; - this->ncol = NLOCAL; - } - } - //else if (DIAGO_TYPE == "canonical" - // || DIAGO_TYPE == "trace_resetting" - // || DIAGO_TYPE == "trace_correcting") xiaohui modify 2013-09-02 - else if(KS_SOLVER == "canonical" - || KS_SOLVER == "trace_resetting" - || KS_SOLVER =="trace_correcting") //xiaohui add 2013-09-02 - { - // mohan add 2011-04-07 - ParaA.cut_atoms(); - ParaA.set_trace(this->trace_loc_row, this->trace_loc_col, - this->nrow, this->ncol); - this->nloc = nrow * ncol; - } + { + cout << " common settings for trace_loc_row and dtraace_loc_col " << endl; + for (int i=0; inrow = NLOCAL; + this->ncol = NLOCAL; + } #ifdef __MPI - //else if (DIAGO_TYPE=="scalpack" - // || DIAGO_TYPE=="hpseps" || DIAGO_TYPE=="selinv") xiaohui modify 2013-09-02 - else if(KS_SOLVER=="scalpack" || KS_SOLVER=="genelpa" || KS_SOLVER=="hpseps" || KS_SOLVER=="selinv" || KS_SOLVER=="scalapack_gvx") //xiaohui add 2013-09-02 + else if(KS_SOLVER=="scalpack" || KS_SOLVER=="genelpa" || KS_SOLVER=="hpseps" + || KS_SOLVER=="selinv" || KS_SOLVER=="scalapack_gvx") //xiaohui add 2013-09-02 { - // set the row index. - //ofs_running << " nrow=" << nrow << endl; + // ofs_running << " nrow=" << nrow << endl; for (int irow=0; irow< this->nrow; irow++) { int global_row = MatrixInfo.row_set[irow]; trace_loc_row[global_row] = irow; -// ofs_running << " global_row=" << global_row << " trace_loc_row=" << trace_loc_row[global_row] << endl; + // ofs_running << " global_row=" << global_row + // << " trace_loc_row=" << trace_loc_row[global_row] << endl; } - //ofs_running << " ncol=" << ncol << endl; + // ofs_running << " ncol=" << ncol << endl; for (int icol=0; icol< this->ncol; icol++) { int global_col = MatrixInfo.col_set[icol]; trace_loc_col[global_col] = icol; -// ofs_running << " global_col=" << global_col << " trace_loc_col=" << trace_loc_col[global_col] << endl; + // ofs_running << " global_col=" << global_col + // << " trace_loc_col=" << trace_loc_col[global_col] << endl; } - } #endif else { - //cout << " Parallel Orbial, DIAGO_TYPE = " << DIAGO_TYPE << endl; xiaohui modify 2013-09-02 - cout << " Parallel Orbial, DIAGO_TYPE = " << KS_SOLVER << endl; //xiaohui add 2013-09-02 - //WARNING_QUIT("Parallel_Orbitals::set_trace","Check diago_type."); xiaohui modify 2013-09-02 - WARNING_QUIT("Parallel_Orbitals::set_trace","Check KS_SOLVER."); //xiaohui add 2013-09-02 + cout << " Parallel Orbial, DIAGO_TYPE = " << KS_SOLVER << endl; + WARNING_QUIT("Parallel_Orbitals::set_trace","Check KS_SOLVER."); } //--------------------------- diff --git a/ABACUS.develop/source/src_parallel/parallel_orbitals.h b/ABACUS.develop/source/src_parallel/parallel_orbitals.h index 9199008db3..73b4aab628 100644 --- a/ABACUS.develop/source/src_parallel/parallel_orbitals.h +++ b/ABACUS.develop/source/src_parallel/parallel_orbitals.h @@ -7,6 +7,7 @@ class Parallel_Orbitals : public Pdiag_Double { public: + Parallel_Orbitals(); ~Parallel_Orbitals(); diff --git a/ABACUS.develop/source/src_parallel/subgrid_oper.cpp b/ABACUS.develop/source/src_parallel/subgrid_oper.cpp index 93aa3a8497..936cc78508 100644 --- a/ABACUS.develop/source/src_parallel/subgrid_oper.cpp +++ b/ABACUS.develop/source/src_parallel/subgrid_oper.cpp @@ -113,15 +113,7 @@ void SubGrid_oper::cal_totwfc() // reduce occupy and get the full occupations. #ifdef __MPI // mohan 2012-02-23 - if(ATOM_DISTRIBUTION==1) - { - ofs_running << " Because of the atom distribution." << endl; - ofs_running << " Don't reduce the trace_lo_tot here." << endl; - } - else - { - Parallel_Reduce::reduce_int_grid(occupy, NLOCAL); - } + Parallel_Reduce::reduce_int_grid(occupy, NLOCAL); #endif /* From 96302b22e7c3e9a7ce566f5c7ae83cddf524e6d8 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 17 Feb 2021 15:03:46 +0800 Subject: [PATCH 127/233] move src_pdiag out from src_external --- ABACUS.develop/source/Makefile | 10 +++++----- ABACUS.develop/source/src_lcao/LCAO_diago.cpp | 2 +- ABACUS.develop/source/src_lcao/LCAO_evolve.cpp | 2 +- ABACUS.develop/source/src_lcao/ORB_control.h | 2 +- ABACUS.develop/source/src_lcao/local_orbital_ions.cpp | 6 +++--- ABACUS.develop/source/src_lcao/mulliken_charge.h | 5 ++--- ABACUS.develop/source/src_parallel/parallel_orbitals.h | 4 ++-- .../source/{src_external => }/src_pdiag/Cblacs.h | 0 .../source/{src_external => }/src_pdiag/GenELPA.cpp | 0 .../source/{src_external => }/src_pdiag/GenELPA.h | 0 .../source/{src_external => }/src_pdiag/MRRR/dcopy.cpp | 0 .../source/{src_external => }/src_pdiag/MRRR/dlae2.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlaebz.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlaev2.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlaneg.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlanst.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlar1v.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlarnv.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlarra.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlarrb.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlarrc.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlarrd.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlarre.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlarrf.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlarrj.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlarrk.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlarrr.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlarrv.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlaruv.cpp | 0 .../source/{src_external => }/src_pdiag/MRRR/dlas2.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlascl.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlaset.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlasq2.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlasq3.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlasq4.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlasq5.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlasq6.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlasrt.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dlassq.cpp | 0 .../source/{src_external => }/src_pdiag/MRRR/dscal.cpp | 0 .../{src_external => }/src_pdiag/MRRR/dstemr_mpi.cpp | 0 .../source/{src_external => }/src_pdiag/MRRR/dswap.cpp | 0 .../{src_external => }/src_pdiag/MRRR/i_nint.cpp | 0 .../{src_external => }/src_pdiag/MRRR/ieeeck.cpp | 0 .../{src_external => }/src_pdiag/MRRR/ilaenv.cpp | 0 .../{src_external => }/src_pdiag/MRRR/iparmq.cpp | 0 .../source/{src_external => }/src_pdiag/MRRR/lsame.cpp | 0 .../{src_external => }/src_pdiag/MRRR/mr_interface.h | 0 .../source/{src_external => }/src_pdiag/MRRR/mrrr.h | 0 .../{src_external => }/src_pdiag/MRRR/psort_w.cpp | 0 .../source/{src_external => }/src_pdiag/MRRR/s_cmp.cpp | 0 .../{src_external => }/src_pdiag/MRRR/s_copy.cpp | 0 .../{src_external => }/src_pdiag/MRRR/xerbla.cpp | 0 .../source/{src_external => }/src_pdiag/my_elpa.h | 0 .../source/{src_external => }/src_pdiag/pdgseps.cpp | 4 +--- .../source/{src_external => }/src_pdiag/pdgseps.h | 2 +- .../{src_external => }/src_pdiag/pdiag_basic.cpp | 6 +++--- .../source/{src_external => }/src_pdiag/pdiag_basic.h | 2 +- .../{src_external => }/src_pdiag/pdiag_common.cpp | 0 .../source/{src_external => }/src_pdiag/pdiag_common.h | 2 +- .../{src_external => }/src_pdiag/pdiag_double.cpp | 4 ++-- .../source/{src_external => }/src_pdiag/pdiag_double.h | 2 +- .../source/{src_external => }/src_pdiag/pdst2g.cpp | 0 .../source/{src_external => }/src_pdiag/pdst2g.h | 2 +- .../source/{src_external => }/src_pdiag/pdstebz.cpp | 0 .../source/{src_external => }/src_pdiag/pdstebz.h | 2 +- .../source/{src_external => }/src_pdiag/pdsteiz.cpp | 0 .../source/{src_external => }/src_pdiag/pdsteiz.h | 2 +- .../source/{src_external => }/src_pdiag/pdsyg2st.cpp | 0 .../source/{src_external => }/src_pdiag/pdsyg2st.h | 2 +- .../source/{src_external => }/src_pdiag/pdsytrd.cpp | 0 .../source/{src_external => }/src_pdiag/pdsytrd.h | 2 +- .../source/{src_external => }/src_pdiag/pdt2s.cpp | 0 .../source/{src_external => }/src_pdiag/pdt2s.h | 2 +- .../source/{src_external => }/src_pdiag/pdtrsm.cpp | 0 .../source/{src_external => }/src_pdiag/pdtrsm.h | 2 +- .../source/{src_external => }/src_pdiag/pzgseps.cpp | 2 +- .../source/{src_external => }/src_pdiag/pzgseps.h | 2 +- .../source/{src_external => }/src_pdiag/pzheg2st.cpp | 0 .../source/{src_external => }/src_pdiag/pzheg2st.h | 2 +- .../source/{src_external => }/src_pdiag/pzhetrd.cpp | 0 .../source/{src_external => }/src_pdiag/pzhetrd.h | 2 +- .../source/{src_external => }/src_pdiag/pzhtrsm.cpp | 0 .../source/{src_external => }/src_pdiag/pzhtrsm.h | 2 +- .../source/{src_external => }/src_pdiag/pzst2g.cpp | 0 .../source/{src_external => }/src_pdiag/pzst2g.h | 2 +- .../source/{src_external => }/src_pdiag/pzsteiz.cpp | 0 .../source/{src_external => }/src_pdiag/pzsteiz.h | 2 +- .../source/{src_external => }/src_pdiag/pzt2s.cpp | 0 .../source/{src_external => }/src_pdiag/pzt2s.h | 2 +- .../source/{src_external => }/src_pdiag/saveMatrix.hpp | 0 91 files changed, 40 insertions(+), 43 deletions(-) rename ABACUS.develop/source/{src_external => }/src_pdiag/Cblacs.h (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/GenELPA.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/GenELPA.h (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dcopy.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlae2.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlaebz.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlaev2.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlaneg.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlanst.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlar1v.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlarnv.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlarra.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlarrb.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlarrc.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlarrd.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlarre.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlarrf.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlarrj.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlarrk.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlarrr.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlarrv.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlaruv.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlas2.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlascl.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlaset.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlasq2.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlasq3.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlasq4.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlasq5.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlasq6.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlasrt.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dlassq.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dscal.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dstemr_mpi.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/dswap.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/i_nint.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/ieeeck.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/ilaenv.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/iparmq.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/lsame.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/mr_interface.h (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/mrrr.h (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/psort_w.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/s_cmp.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/s_copy.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/MRRR/xerbla.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/my_elpa.h (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdgseps.cpp (98%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdgseps.h (88%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdiag_basic.cpp (99%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdiag_basic.h (97%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdiag_common.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdiag_common.h (89%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdiag_double.cpp (99%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdiag_double.h (96%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdst2g.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdst2g.h (85%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdstebz.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdstebz.h (81%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdsteiz.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdsteiz.h (81%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdsyg2st.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdsyg2st.h (86%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdsytrd.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdsytrd.h (87%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdt2s.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdt2s.h (85%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdtrsm.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pdtrsm.h (86%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pzgseps.cpp (98%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pzgseps.h (90%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pzheg2st.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pzheg2st.h (87%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pzhetrd.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pzhetrd.h (88%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pzhtrsm.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pzhtrsm.h (87%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pzst2g.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pzst2g.h (86%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pzsteiz.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pzsteiz.h (82%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pzt2s.cpp (100%) rename ABACUS.develop/source/{src_external => }/src_pdiag/pzt2s.h (87%) rename ABACUS.develop/source/{src_external => }/src_pdiag/saveMatrix.hpp (100%) diff --git a/ABACUS.develop/source/Makefile b/ABACUS.develop/source/Makefile index fde4962b7f..a95386b1b8 100644 --- a/ABACUS.develop/source/Makefile +++ b/ABACUS.develop/source/Makefile @@ -4,14 +4,14 @@ include Makefile.system include Makefile.Objects VPATH=./src_global\ -:./src_parallel\ -:./src_external/src_pdiag\ :./src_pw\ :./src_lcao\ -:./src_ri\ -:./src_io\ :./src_ions\ -:./src_external/src_pdiag/MRRR\ +:./src_io\ +:./src_parallel\ +:./src_pdiag\ +:./src_pdiag/MRRR\ +:./src_ri\ :./\ #========================== diff --git a/ABACUS.develop/source/src_lcao/LCAO_diago.cpp b/ABACUS.develop/source/src_lcao/LCAO_diago.cpp index 1c8fa0028f..768b631036 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_diago.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_diago.cpp @@ -1,7 +1,7 @@ #include "LCAO_diago.h" #include "../src_pw/algorithms.h" #include "../src_pw/global.h" -#include "../src_external/src_pdiag/pdiag_double.h" +#include "../src_pdiag/pdiag_double.h" #include "../src_io/hs_matrix.h" //xiaohui modified 2013-03-23 //#include "../src_develop/src_siao/selinv.h" diff --git a/ABACUS.develop/source/src_lcao/LCAO_evolve.cpp b/ABACUS.develop/source/src_lcao/LCAO_evolve.cpp index a9714c7e38..b533f6667e 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_evolve.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_evolve.cpp @@ -1,7 +1,7 @@ #include "LCAO_evolve.h" #include "../src_pw/algorithms.h" #include "../src_pw/global.h" -#include "../src_external/src_pdiag/pdiag_double.h" +#include "../src_pdiag/pdiag_double.h" #include "../src_io/hs_matrix.h" #include"../input.h" #include diff --git a/ABACUS.develop/source/src_lcao/ORB_control.h b/ABACUS.develop/source/src_lcao/ORB_control.h index afe17979fe..089960f2be 100644 --- a/ABACUS.develop/source/src_lcao/ORB_control.h +++ b/ABACUS.develop/source/src_lcao/ORB_control.h @@ -9,7 +9,7 @@ #include "../src_pw/algorithms.h" #include "ORB_gen_tables.h" -#include "../src_external/src_pdiag/pdiag_double.h" +#include "../src_pdiag/pdiag_double.h" class ORB_control { diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index 35c9acc4d9..5aa346fa6c 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -1,14 +1,14 @@ #include "local_orbital_ions.h" #include "src_pw/global.h" #include "src_parallel/parallel_orbitals.h" -#include "src_external/src_pdiag/pdiag_double.h" +#include "src_pdiag/pdiag_double.h" #include "LCAO_nnr.h" #include "force_lcao.h" #include "stress_lcao.h" #include "src_global/global_function.h" -#include "../src_io/hs_matrix.h" +#include "src_io/hs_matrix.h" #include "src_lcao/cal_r_overlap_R.h" -#include "../src_ions/variable_cell.h" // mohan add 2021-02-01 +#include "src_ions/variable_cell.h" // mohan add 2021-02-01 #include "src_ri/exx_abfs.h" #include "src_ri/exx_opt_orb.h" #include "ELEC_scf.h" diff --git a/ABACUS.develop/source/src_lcao/mulliken_charge.h b/ABACUS.develop/source/src_lcao/mulliken_charge.h index fea1d3887d..2406d918aa 100644 --- a/ABACUS.develop/source/src_lcao/mulliken_charge.h +++ b/ABACUS.develop/source/src_lcao/mulliken_charge.h @@ -14,9 +14,8 @@ #include "../src_global/matrix.h" #include "../src_global/complexmatrix.h" #include -#include "../src_external/src_pdiag/pdiag_double.h" -#include "../src_external/src_pdiag/GenELPA.h" - +#include "../src_pdiag/pdiag_double.h" +#include "../src_pdiag/GenELPA.h" class Mulliken_Charge { diff --git a/ABACUS.develop/source/src_parallel/parallel_orbitals.h b/ABACUS.develop/source/src_parallel/parallel_orbitals.h index 73b4aab628..aa65d65844 100644 --- a/ABACUS.develop/source/src_parallel/parallel_orbitals.h +++ b/ABACUS.develop/source/src_parallel/parallel_orbitals.h @@ -1,8 +1,8 @@ #ifndef PARALLEL_ORBITALS_H #define PARALLEL_ORBITALS_H -#include "../src_pw/tools.h" -#include "../src_external/src_pdiag/pdiag_double.h" +#include "src_pw/tools.h" +#include "src_pdiag/pdiag_double.h" class Parallel_Orbitals : public Pdiag_Double { diff --git a/ABACUS.develop/source/src_external/src_pdiag/Cblacs.h b/ABACUS.develop/source/src_pdiag/Cblacs.h similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/Cblacs.h rename to ABACUS.develop/source/src_pdiag/Cblacs.h diff --git a/ABACUS.develop/source/src_external/src_pdiag/GenELPA.cpp b/ABACUS.develop/source/src_pdiag/GenELPA.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/GenELPA.cpp rename to ABACUS.develop/source/src_pdiag/GenELPA.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/GenELPA.h b/ABACUS.develop/source/src_pdiag/GenELPA.h similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/GenELPA.h rename to ABACUS.develop/source/src_pdiag/GenELPA.h diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dcopy.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dcopy.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dcopy.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dcopy.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlae2.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlae2.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlae2.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlae2.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlaebz.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlaebz.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlaebz.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlaebz.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlaev2.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlaev2.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlaev2.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlaev2.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlaneg.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlaneg.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlaneg.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlaneg.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlanst.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlanst.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlanst.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlanst.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlar1v.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlar1v.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlar1v.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlar1v.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarnv.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlarnv.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarnv.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlarnv.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarra.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlarra.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarra.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlarra.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarrb.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlarrb.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarrb.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlarrb.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarrc.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlarrc.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarrc.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlarrc.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarrd.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlarrd.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarrd.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlarrd.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarre.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlarre.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarre.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlarre.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarrf.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlarrf.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarrf.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlarrf.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarrj.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlarrj.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarrj.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlarrj.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarrk.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlarrk.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarrk.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlarrk.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarrr.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlarrr.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarrr.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlarrr.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarrv.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlarrv.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlarrv.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlarrv.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlaruv.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlaruv.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlaruv.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlaruv.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlas2.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlas2.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlas2.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlas2.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlascl.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlascl.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlascl.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlascl.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlaset.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlaset.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlaset.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlaset.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlasq2.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlasq2.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlasq2.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlasq2.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlasq3.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlasq3.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlasq3.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlasq3.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlasq4.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlasq4.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlasq4.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlasq4.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlasq5.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlasq5.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlasq5.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlasq5.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlasq6.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlasq6.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlasq6.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlasq6.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlasrt.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlasrt.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlasrt.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlasrt.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dlassq.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dlassq.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dlassq.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dlassq.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dscal.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dscal.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dscal.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dscal.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dstemr_mpi.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dstemr_mpi.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dstemr_mpi.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dstemr_mpi.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/dswap.cpp b/ABACUS.develop/source/src_pdiag/MRRR/dswap.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/dswap.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/dswap.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/i_nint.cpp b/ABACUS.develop/source/src_pdiag/MRRR/i_nint.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/i_nint.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/i_nint.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/ieeeck.cpp b/ABACUS.develop/source/src_pdiag/MRRR/ieeeck.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/ieeeck.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/ieeeck.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/ilaenv.cpp b/ABACUS.develop/source/src_pdiag/MRRR/ilaenv.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/ilaenv.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/ilaenv.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/iparmq.cpp b/ABACUS.develop/source/src_pdiag/MRRR/iparmq.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/iparmq.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/iparmq.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/lsame.cpp b/ABACUS.develop/source/src_pdiag/MRRR/lsame.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/lsame.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/lsame.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/mr_interface.h b/ABACUS.develop/source/src_pdiag/MRRR/mr_interface.h similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/mr_interface.h rename to ABACUS.develop/source/src_pdiag/MRRR/mr_interface.h diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/mrrr.h b/ABACUS.develop/source/src_pdiag/MRRR/mrrr.h similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/mrrr.h rename to ABACUS.develop/source/src_pdiag/MRRR/mrrr.h diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/psort_w.cpp b/ABACUS.develop/source/src_pdiag/MRRR/psort_w.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/psort_w.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/psort_w.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/s_cmp.cpp b/ABACUS.develop/source/src_pdiag/MRRR/s_cmp.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/s_cmp.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/s_cmp.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/s_copy.cpp b/ABACUS.develop/source/src_pdiag/MRRR/s_copy.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/s_copy.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/s_copy.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/MRRR/xerbla.cpp b/ABACUS.develop/source/src_pdiag/MRRR/xerbla.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/MRRR/xerbla.cpp rename to ABACUS.develop/source/src_pdiag/MRRR/xerbla.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/my_elpa.h b/ABACUS.develop/source/src_pdiag/my_elpa.h similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/my_elpa.h rename to ABACUS.develop/source/src_pdiag/my_elpa.h diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdgseps.cpp b/ABACUS.develop/source/src_pdiag/pdgseps.cpp similarity index 98% rename from ABACUS.develop/source/src_external/src_pdiag/pdgseps.cpp rename to ABACUS.develop/source/src_pdiag/pdgseps.cpp index 097594cab3..9af506ac5a 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdgseps.cpp +++ b/ABACUS.develop/source/src_pdiag/pdgseps.cpp @@ -1,9 +1,7 @@ //column-circle decomposition #include"./MRRR/mr_interface.h" #include "pdgseps.h" - -#include "../../src_parallel/parallel_reduce.h" - +#include "src_parallel/parallel_reduce.h" #include "pdsyg2st.h" #include "pdsytrd.h" #include "pdt2s.h" diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdgseps.h b/ABACUS.develop/source/src_pdiag/pdgseps.h similarity index 88% rename from ABACUS.develop/source/src_external/src_pdiag/pdgseps.h rename to ABACUS.develop/source/src_pdiag/pdgseps.h index 2b72590864..cc23bcf5e2 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdgseps.h +++ b/ABACUS.develop/source/src_pdiag/pdgseps.h @@ -1,7 +1,7 @@ #ifndef PDGSEPS_H #define PDGSEPS_H -#include "../../src_pw/tools.h" +#include "src_pw/tools.h" #include "pdiag_common.h" void pdgseps( diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.cpp b/ABACUS.develop/source/src_pdiag/pdiag_basic.cpp similarity index 99% rename from ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.cpp rename to ABACUS.develop/source/src_pdiag/pdiag_basic.cpp index 437576aae3..08e6cbbbcf 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.cpp +++ b/ABACUS.develop/source/src_pdiag/pdiag_basic.cpp @@ -1,7 +1,7 @@ #include "pdiag_basic.h" -#include "../../src_parallel/parallel_common.h" -#include "../../src_pw/global.h" -#include "../../src_io/wf_local.h" +#include "src_parallel/parallel_common.h" +#include "src_pw/global.h" +#include "src_io/wf_local.h" #include "src_global/lapack_connector.h" Pdiag_Basic::Pdiag_Basic() diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.h b/ABACUS.develop/source/src_pdiag/pdiag_basic.h similarity index 97% rename from ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.h rename to ABACUS.develop/source/src_pdiag/pdiag_basic.h index 996d4d65af..eb3afaa717 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdiag_basic.h +++ b/ABACUS.develop/source/src_pdiag/pdiag_basic.h @@ -1,7 +1,7 @@ #ifndef PDIAG_BASIC_H #define PDIAG_BASIC_H -#include "../../src_pw/tools.h" +#include "src_pw/tools.h" #include "pdiag_common.h" class Pdiag_Basic diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdiag_common.cpp b/ABACUS.develop/source/src_pdiag/pdiag_common.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/pdiag_common.cpp rename to ABACUS.develop/source/src_pdiag/pdiag_common.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdiag_common.h b/ABACUS.develop/source/src_pdiag/pdiag_common.h similarity index 89% rename from ABACUS.develop/source/src_external/src_pdiag/pdiag_common.h rename to ABACUS.develop/source/src_pdiag/pdiag_common.h index 55cd8466fb..d5eaef7f7e 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdiag_common.h +++ b/ABACUS.develop/source/src_pdiag/pdiag_common.h @@ -5,7 +5,7 @@ #include "mpi.h" #endif #include "src_global/blas_connector.h" -#include "../../src_global/lapack_connector.h" // Peize Lin add 2016-08-04 +#include "src_global/lapack_connector.h" // Peize Lin add 2016-08-04 struct LocalMatrix { diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp b/ABACUS.develop/source/src_pdiag/pdiag_double.cpp similarity index 99% rename from ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp rename to ABACUS.develop/source/src_pdiag/pdiag_double.cpp index 92015b0f41..c604e34f71 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.cpp +++ b/ABACUS.develop/source/src_pdiag/pdiag_double.cpp @@ -3,10 +3,10 @@ #include "src_global/lapack_connector.h" #include "src_pw/occupy.h" #include "src_pw/global.h" -//#include "../src_pw/global.h" -//xiaohui add 2014-06-20 #include "src_lcao/local_orbital_charge.h" #include "src_io/wf_local.h" + + #ifdef __MPI extern "C" { diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.h b/ABACUS.develop/source/src_pdiag/pdiag_double.h similarity index 96% rename from ABACUS.develop/source/src_external/src_pdiag/pdiag_double.h rename to ABACUS.develop/source/src_pdiag/pdiag_double.h index b7f084e7ab..a58e0e914d 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdiag_double.h +++ b/ABACUS.develop/source/src_pdiag/pdiag_double.h @@ -1,7 +1,7 @@ #ifndef PDIAG_DOUBLE_H #define PDIAG_DOUBLE_H -#include "../../src_pw/tools.h" +#include "src_pw/tools.h" #include "pdiag_basic.h" class Pdiag_Double : public Pdiag_Basic diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdst2g.cpp b/ABACUS.develop/source/src_pdiag/pdst2g.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/pdst2g.cpp rename to ABACUS.develop/source/src_pdiag/pdst2g.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdst2g.h b/ABACUS.develop/source/src_pdiag/pdst2g.h similarity index 85% rename from ABACUS.develop/source/src_external/src_pdiag/pdst2g.h rename to ABACUS.develop/source/src_pdiag/pdst2g.h index 5165a472bd..5370f75294 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdst2g.h +++ b/ABACUS.develop/source/src_pdiag/pdst2g.h @@ -1,7 +1,7 @@ #ifndef PDST2G_H #define PDST2G_H -#include "../../src_pw/tools.h" +#include "src_pw/tools.h" #include "pdiag_common.h" void pdst2g(MPI_Comm comm_2D,int NB,int N_A,double *A,double *B, diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdstebz.cpp b/ABACUS.develop/source/src_pdiag/pdstebz.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/pdstebz.cpp rename to ABACUS.develop/source/src_pdiag/pdstebz.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdstebz.h b/ABACUS.develop/source/src_pdiag/pdstebz.h similarity index 81% rename from ABACUS.develop/source/src_external/src_pdiag/pdstebz.h rename to ABACUS.develop/source/src_pdiag/pdstebz.h index 290d1fab28..de2dd53f9a 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdstebz.h +++ b/ABACUS.develop/source/src_pdiag/pdstebz.h @@ -1,7 +1,7 @@ #ifndef PDSTEBZ_H #define PDSTEBZ_H -#include "../../src_pw/tools.h" +#include "src_pw/tools.h" #include "pdiag_common.h" void pdstebz(MPI_Comm comm_2D, double *D,double *E,double *eigen,int N); diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdsteiz.cpp b/ABACUS.develop/source/src_pdiag/pdsteiz.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/pdsteiz.cpp rename to ABACUS.develop/source/src_pdiag/pdsteiz.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdsteiz.h b/ABACUS.develop/source/src_pdiag/pdsteiz.h similarity index 81% rename from ABACUS.develop/source/src_external/src_pdiag/pdsteiz.h rename to ABACUS.develop/source/src_pdiag/pdsteiz.h index a5ac34e831..66301e0e45 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdsteiz.h +++ b/ABACUS.develop/source/src_pdiag/pdsteiz.h @@ -1,7 +1,7 @@ #ifndef PDSTEIZ_H #define PDSTEIZ_H -#include "../../src_pw/tools.h" +#include "src_pw/tools.h" #include "pdiag_common.h" void pdsteiz(int n,double *a,double *b,double *w,double *Z,int m); diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdsyg2st.cpp b/ABACUS.develop/source/src_pdiag/pdsyg2st.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/pdsyg2st.cpp rename to ABACUS.develop/source/src_pdiag/pdsyg2st.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdsyg2st.h b/ABACUS.develop/source/src_pdiag/pdsyg2st.h similarity index 86% rename from ABACUS.develop/source/src_external/src_pdiag/pdsyg2st.h rename to ABACUS.develop/source/src_pdiag/pdsyg2st.h index c16bb5ac0b..bfa5429b0b 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdsyg2st.h +++ b/ABACUS.develop/source/src_pdiag/pdsyg2st.h @@ -1,7 +1,7 @@ #ifndef PDSYG2ST_H #define PDSYG2ST_H -#include "../../src_pw/tools.h" +#include "src_pw/tools.h" #include "pdiag_common.h" void pdsyg2st( diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdsytrd.cpp b/ABACUS.develop/source/src_pdiag/pdsytrd.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/pdsytrd.cpp rename to ABACUS.develop/source/src_pdiag/pdsytrd.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdsytrd.h b/ABACUS.develop/source/src_pdiag/pdsytrd.h similarity index 87% rename from ABACUS.develop/source/src_external/src_pdiag/pdsytrd.h rename to ABACUS.develop/source/src_pdiag/pdsytrd.h index e2bb4ab1ef..b427e9a310 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdsytrd.h +++ b/ABACUS.develop/source/src_pdiag/pdsytrd.h @@ -1,7 +1,7 @@ #ifndef PDSYTRD_H #define PDSYTRD_H -#include "../../src_pw/tools.h" +#include "src_pw/tools.h" #include "pdiag_common.h" #include "pdsytrd.h" diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdt2s.cpp b/ABACUS.develop/source/src_pdiag/pdt2s.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/pdt2s.cpp rename to ABACUS.develop/source/src_pdiag/pdt2s.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdt2s.h b/ABACUS.develop/source/src_pdiag/pdt2s.h similarity index 85% rename from ABACUS.develop/source/src_external/src_pdiag/pdt2s.h rename to ABACUS.develop/source/src_pdiag/pdt2s.h index d006d11edc..a3075d7adb 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdt2s.h +++ b/ABACUS.develop/source/src_pdiag/pdt2s.h @@ -1,7 +1,7 @@ #ifndef PDT2S_H #define PDT2S_H -#include "../../src_pw/tools.h" +#include "src_pw/tools.h" #include "pdiag_common.h" void pdt2s(MPI_Comm comm2D,int N_A,int NB,double *A,double *X, diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdtrsm.cpp b/ABACUS.develop/source/src_pdiag/pdtrsm.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/pdtrsm.cpp rename to ABACUS.develop/source/src_pdiag/pdtrsm.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/pdtrsm.h b/ABACUS.develop/source/src_pdiag/pdtrsm.h similarity index 86% rename from ABACUS.develop/source/src_external/src_pdiag/pdtrsm.h rename to ABACUS.develop/source/src_pdiag/pdtrsm.h index 12370d18c2..8194780e5c 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pdtrsm.h +++ b/ABACUS.develop/source/src_pdiag/pdtrsm.h @@ -1,7 +1,7 @@ #ifndef PDTRSM_H #define PDTRSM_H -#include "../../src_pw/tools.h" +#include "src_pw/tools.h" #include "pdiag_common.h" void pdtrsm(char isuplo,int b_n,MPI_Comm comm_2D,int NB,int N_A, diff --git a/ABACUS.develop/source/src_external/src_pdiag/pzgseps.cpp b/ABACUS.develop/source/src_pdiag/pzgseps.cpp similarity index 98% rename from ABACUS.develop/source/src_external/src_pdiag/pzgseps.cpp rename to ABACUS.develop/source/src_pdiag/pzgseps.cpp index 96d9d69ec6..727db9c853 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pzgseps.cpp +++ b/ABACUS.develop/source/src_pdiag/pzgseps.cpp @@ -1,6 +1,6 @@ //column-circle decomposition #include "pzgseps.h" -#include "../../src_parallel/parallel_reduce.h" +#include "src_parallel/parallel_reduce.h" #include "src_global/lapack_connector.h" #include "pzheg2st.h" diff --git a/ABACUS.develop/source/src_external/src_pdiag/pzgseps.h b/ABACUS.develop/source/src_pdiag/pzgseps.h similarity index 90% rename from ABACUS.develop/source/src_external/src_pdiag/pzgseps.h rename to ABACUS.develop/source/src_pdiag/pzgseps.h index 7986936d57..3ad2309278 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pzgseps.h +++ b/ABACUS.develop/source/src_pdiag/pzgseps.h @@ -1,7 +1,7 @@ #ifndef PZGSEPS_H #define PZGSEPS_H -#include "../../src_pw/tools.h" +#include "src_pw/tools.h" #include "pdiag_common.h" void pzgseps( diff --git a/ABACUS.develop/source/src_external/src_pdiag/pzheg2st.cpp b/ABACUS.develop/source/src_pdiag/pzheg2st.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/pzheg2st.cpp rename to ABACUS.develop/source/src_pdiag/pzheg2st.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/pzheg2st.h b/ABACUS.develop/source/src_pdiag/pzheg2st.h similarity index 87% rename from ABACUS.develop/source/src_external/src_pdiag/pzheg2st.h rename to ABACUS.develop/source/src_pdiag/pzheg2st.h index f16d9fd659..15fca54b07 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pzheg2st.h +++ b/ABACUS.develop/source/src_pdiag/pzheg2st.h @@ -1,7 +1,7 @@ #ifndef PZHEG2ST_H #define PZHEG2ST_H -#include "../../src_pw/tools.h" +#include "src_pw/tools.h" #include "pdiag_common.h" void pzheg2st( diff --git a/ABACUS.develop/source/src_external/src_pdiag/pzhetrd.cpp b/ABACUS.develop/source/src_pdiag/pzhetrd.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/pzhetrd.cpp rename to ABACUS.develop/source/src_pdiag/pzhetrd.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/pzhetrd.h b/ABACUS.develop/source/src_pdiag/pzhetrd.h similarity index 88% rename from ABACUS.develop/source/src_external/src_pdiag/pzhetrd.h rename to ABACUS.develop/source/src_pdiag/pzhetrd.h index aed4926688..921859a308 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pzhetrd.h +++ b/ABACUS.develop/source/src_pdiag/pzhetrd.h @@ -1,7 +1,7 @@ #ifndef PZHETRD_H #define PZHETRD_H -#include "../../src_pw/tools.h" +#include "src_pw/tools.h" #include "pdiag_common.h" #include "pzhetrd.h" diff --git a/ABACUS.develop/source/src_external/src_pdiag/pzhtrsm.cpp b/ABACUS.develop/source/src_pdiag/pzhtrsm.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/pzhtrsm.cpp rename to ABACUS.develop/source/src_pdiag/pzhtrsm.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/pzhtrsm.h b/ABACUS.develop/source/src_pdiag/pzhtrsm.h similarity index 87% rename from ABACUS.develop/source/src_external/src_pdiag/pzhtrsm.h rename to ABACUS.develop/source/src_pdiag/pzhtrsm.h index b70e19ac6e..d36bb96f92 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pzhtrsm.h +++ b/ABACUS.develop/source/src_pdiag/pzhtrsm.h @@ -1,7 +1,7 @@ #ifndef PZHTRSM_H #define PZHTRSM_H -#include "../../src_pw/tools.h" +#include "src_pw/tools.h" #include "pdiag_common.h" void pzhtrsm(char isuplo,int b_n,MPI_Comm comm_2D,int NB,int N_A, diff --git a/ABACUS.develop/source/src_external/src_pdiag/pzst2g.cpp b/ABACUS.develop/source/src_pdiag/pzst2g.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/pzst2g.cpp rename to ABACUS.develop/source/src_pdiag/pzst2g.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/pzst2g.h b/ABACUS.develop/source/src_pdiag/pzst2g.h similarity index 86% rename from ABACUS.develop/source/src_external/src_pdiag/pzst2g.h rename to ABACUS.develop/source/src_pdiag/pzst2g.h index b870c96cf8..fe7e36206a 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pzst2g.h +++ b/ABACUS.develop/source/src_pdiag/pzst2g.h @@ -1,7 +1,7 @@ #ifndef PZST2G_H #define PZST2G_H -#include "../../src_pw/tools.h" +#include "src_pw/tools.h" #include "pdiag_common.h" void pzst2g(MPI_Comm comm_2D,int NB,int N_A,complex *A,complex *B, diff --git a/ABACUS.develop/source/src_external/src_pdiag/pzsteiz.cpp b/ABACUS.develop/source/src_pdiag/pzsteiz.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/pzsteiz.cpp rename to ABACUS.develop/source/src_pdiag/pzsteiz.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/pzsteiz.h b/ABACUS.develop/source/src_pdiag/pzsteiz.h similarity index 82% rename from ABACUS.develop/source/src_external/src_pdiag/pzsteiz.h rename to ABACUS.develop/source/src_pdiag/pzsteiz.h index 179adb166d..93d0f0e478 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pzsteiz.h +++ b/ABACUS.develop/source/src_pdiag/pzsteiz.h @@ -1,7 +1,7 @@ #ifndef PZSTEIZ_H #define PZSTEIZ_H -#include "../../src_pw/tools.h" +#include "src_pw/tools.h" #include "pdiag_common.h" void pzsteiz(int n,double *a,double *b,double *w,complex *Z,int m); diff --git a/ABACUS.develop/source/src_external/src_pdiag/pzt2s.cpp b/ABACUS.develop/source/src_pdiag/pzt2s.cpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/pzt2s.cpp rename to ABACUS.develop/source/src_pdiag/pzt2s.cpp diff --git a/ABACUS.develop/source/src_external/src_pdiag/pzt2s.h b/ABACUS.develop/source/src_pdiag/pzt2s.h similarity index 87% rename from ABACUS.develop/source/src_external/src_pdiag/pzt2s.h rename to ABACUS.develop/source/src_pdiag/pzt2s.h index 32edaab7ff..e2e85111a8 100644 --- a/ABACUS.develop/source/src_external/src_pdiag/pzt2s.h +++ b/ABACUS.develop/source/src_pdiag/pzt2s.h @@ -1,7 +1,7 @@ #ifndef PZT2S_H #define PZT2S_H -#include "../../src_pw/tools.h" +#include "src_pw/tools.h" #include "pdiag_common.h" void pzt2s(MPI_Comm comm2D,int N_A,int NB,complex *A,complex *X, diff --git a/ABACUS.develop/source/src_external/src_pdiag/saveMatrix.hpp b/ABACUS.develop/source/src_pdiag/saveMatrix.hpp similarity index 100% rename from ABACUS.develop/source/src_external/src_pdiag/saveMatrix.hpp rename to ABACUS.develop/source/src_pdiag/saveMatrix.hpp From 39aff8a91bca7773183f9bc4df810680ae67ef25 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 17 Feb 2021 15:25:41 +0800 Subject: [PATCH 128/233] delete grid_integral, which is useless because it uses sparsematrix. delete sparsematrix.h and .cpp, which is useless for now. --- ABACUS.develop/source/Makefile.Objects | 2 - ABACUS.develop/source/README | 3 + ABACUS.develop/source/input.cpp | 180 ++-------- ABACUS.develop/source/input.h | 4 - ABACUS.develop/source/input_conv.cpp | 7 +- .../source/src_global/sparsematrix.cpp | 215 ------------ .../source/src_global/sparsematrix.h | 85 ----- ABACUS.develop/source/src_lcao/LCAO_hamilt.h | 1 - .../source/src_lcao/ORB_control.cpp | 1 - ABACUS.develop/source/src_lcao/grid_base.cpp | 3 +- ABACUS.develop/source/src_lcao/grid_base.h | 1 - .../source/src_lcao/grid_base_beta.cpp | 1 - .../source/src_lcao/grid_integral.cpp | 313 ------------------ .../source/src_lcao/grid_integral.h | 49 --- ABACUS.develop/source/src_pw/electrons.cpp | 4 - ABACUS.develop/source/src_pw/tools.h | 1 - 16 files changed, 43 insertions(+), 827 deletions(-) delete mode 100644 ABACUS.develop/source/src_global/sparsematrix.cpp delete mode 100644 ABACUS.develop/source/src_global/sparsematrix.h delete mode 100644 ABACUS.develop/source/src_lcao/grid_integral.cpp delete mode 100644 ABACUS.develop/source/src_lcao/grid_integral.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 890b5b6957..ce981518c0 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -67,7 +67,6 @@ realarray.o \ intarray.o\ matrix.o \ matrix3.o\ -sparsematrix.o\ export.o\ timer.o\ memory.o\ @@ -100,7 +99,6 @@ grid_meshk.o\ grid_meshcell.o\ grid_bigcell.o\ grid_meshball.o\ -grid_integral.o\ gint_gamma.o\ gint_gamma_fvl.o\ gint_gamma_vl.o\ diff --git a/ABACUS.develop/source/README b/ABACUS.develop/source/README index f6c80e1a9b..d06f242a80 100644 --- a/ABACUS.develop/source/README +++ b/ABACUS.develop/source/README @@ -21,4 +21,7 @@ but the NQX is computed in ./src_pw/pseudopot_cell_vnl.cpp Ask Peize: explain exx_lip.h +Ask Yuyang Ji: what's 'ocp' in input.cpp, what are the options +about 'ocp' in input_conv.cpp? + diff --git a/ABACUS.develop/source/input.cpp b/ABACUS.develop/source/input.cpp index 1e4e686df3..73ca181228 100644 --- a/ABACUS.develop/source/input.cpp +++ b/ABACUS.develop/source/input.cpp @@ -159,11 +159,8 @@ void Input::Default(void) ks_solver = "default"; //xiaohui add 2013-09-01 search_radius=-1.0; // unit: a.u. -1.0 has no meaning. search_pbc=true; - sparse_matrix=false; symmetry=false; mlwf_flag=false; - vna = 0; - grid_speed=1; //mohan add 2012-03-29 force=0; force_set=false; force_thr=1.0e-3; @@ -691,10 +688,6 @@ bool Input::Read(const string &fn) { read_value(ifs, search_pbc); } - else if (strcmp("sparse_matrix", word) == 0) - { - read_value(ifs, sparse_matrix); - } else if (strcmp("symmetry", word) == 0) { read_value(ifs, symmetry); @@ -703,14 +696,6 @@ bool Input::Read(const string &fn) { read_value(ifs, mlwf_flag); } - else if (strcmp("vna", word) == 0) - { - read_value(ifs, vna); - } - else if (strcmp("grid_speed", word) == 0)//mohan 2012-03-29 - { - read_value(ifs, grid_speed); - } else if (strcmp("force", word) == 0) { read_value(ifs, force); @@ -1984,18 +1969,13 @@ void Input::Bcast() Parallel_Common::bcast_double( tot_magnetization ); - //Parallel_Common::bcast_int( local_basis ); xiaohui modify 2013-09-01 Parallel_Common::bcast_string( basis_type ); //xiaohui add 2013-09-01 - //Parallel_Common::bcast_int ( linear_scaling ); xiaohui modify 2013-09-01 Parallel_Common::bcast_string( ks_solver ); //xiaohui add 2013-09-01 Parallel_Common::bcast_double( search_radius ); Parallel_Common::bcast_bool( search_pbc ); - Parallel_Common::bcast_bool ( sparse_matrix ); Parallel_Common::bcast_double( search_radius ); Parallel_Common::bcast_bool( symmetry ); Parallel_Common::bcast_bool( mlwf_flag ); - Parallel_Common::bcast_int( vna ); - Parallel_Common::bcast_int( grid_speed );//mohan add 2012-03-29 Parallel_Common::bcast_int( force ); Parallel_Common::bcast_bool( force_set ); Parallel_Common::bcast_double( force_thr); @@ -2016,7 +1996,6 @@ void Input::Bcast() Parallel_Common::bcast_double( trust_radius_min); Parallel_Common::bcast_double( trust_radius_ini); - //Parallel_Common::bcast_bool( gamma_only ); Parallel_Common::bcast_bool( gamma_only ); Parallel_Common::bcast_bool( gamma_only_local ); Parallel_Common::bcast_double( ecutwfc ); @@ -2031,7 +2010,6 @@ void Input::Bcast() Parallel_Common::bcast_int( by ); Parallel_Common::bcast_int( bz ); - //Parallel_Common::bcast_string( diago_type ); xiaohui modify 2013-09-01 Parallel_Common::bcast_int( diago_proc ); //mohan add 2012-01-03 Parallel_Common::bcast_int( diago_cg_maxiter ); Parallel_Common::bcast_int( diago_cg_prec ); @@ -2589,15 +2567,11 @@ void Input::Check(void) } - //if(local_basis==0) xiaohui modify 2013-09-01 if(basis_type=="pw") //xiaohui add 2013-09-01 { - //if(diago_type=="default") xiaohui modify 2013-09-01 if(ks_solver=="default") //xiaohui add 2013-09-01 { - //diago_type = "cg"; ks_solver = "cg"; - //AUTO_SET("diago_type","cg"); AUTO_SET("ks_solver","cg"); } else if(ks_solver=="cg") @@ -2608,7 +2582,6 @@ void Input::Check(void) { ofs_warning << " It's ok to use dav." << endl; } - //if(diago_type=="hpseps") xiaohui modify 2013-09-01 else if(ks_solver=="genelpa") //yshen add 2016-07-20 { WARNING_QUIT("Input","genelpa can not be used with plane wave basis."); @@ -2617,57 +2590,34 @@ void Input::Check(void) { WARNING_QUIT("Input","scalapack_gvx can not be used with plane wave basis."); } - else if(ks_solver=="hpseps") //xiaohui add 2013-09-01 + else if(ks_solver=="hpseps") { - //ofs_warning << " hpseps can't be used with plane wave basis." << endl; xiaohui modify 2013-09-04 - //diago_type = "cg"; - //ks_solver = "cg"; xiaohui modify 2013-09-04 - //AUTO_SET("diago_type","cg"); - //AUTO_SET("ks_solver","cg"); xiaohui modify 2013-09-04 WARNING_QUIT("Input","hpseps can not be used with plane wave basis."); //xiaohui add 2013-09-04 } - //else if(diago_type=="selinv") xiaohui modify 2013-09-01 - else if(ks_solver=="selinv") //xiaohui add 2013-09-01 + else if(ks_solver=="selinv") { - //ofs_warning << " selinv can't be used with plane wave basis." << endl; xiaohui modify 2013-09-04 - //diago_type = "cg"; - //ks_solver = "cg"; xiaohui modify 2013-09-04 - //AUTO_SET("diago_type","cg"); - //AUTO_SET("ks_solver","cg"); xiaohui modify 2013-09-04 WARNING_QUIT("Input","selinv can not be used with plane wave basis."); //xiaohui add 2013-09-04 } - //xiaohui add 2013-09-04 else if(ks_solver=="lapack") { - //ofs_warning << " lapack can't be used with plane wave basis." << endl; xiaohui modify 2013-09-04 WARNING_QUIT("Input","lapack can not be used with plane wave basis."); - }//xiaohui add 2013-09-04 - else //xiaohui add 2013-09-04 + } + else { WARNING_QUIT("Input","please check the ks_solver parameter!"); - } //xiaohui add 2013-09-04 + } } - //else if(local_basis==4) xiaohui modify 2013-09-01 - else if(basis_type=="lcao") //xiaohui add 2013-09-01 + else if(basis_type=="lcao") { - //if(linear_scaling == 1) xiaohui modify 2013-09-01 - //{ - //if(diago_type == "default") if(ks_solver == "default") { - //diago_type = "hpseps"; - //ks_solver = "hpseps"; ks_solver = "genelpa"; - //AUTO_SET("diago_type","hpseps"); - //AUTO_SET("ks_solver","hpseps"); AUTO_SET("ks_solver","genelpa"); } - //else if(diago_type == "cg" ) else if (ks_solver == "cg") { WARNING_QUIT("Input","not ready for cg method in lcao ."); //xiaohui add 2013-09-04 } - //else if( diago_type == "hpseps" ) else if (ks_solver == "genelpa") { #ifdef __MPI @@ -2692,82 +2642,45 @@ void Input::Check(void) WARNING_QUIT("Input","hpseps can not be used for series version."); #endif } - //else if( diago_type == "lapack" ) else if (ks_solver == "lapack") { #ifdef __MPI - //WARNING_QUIT("Input","diago_type=lapack is not an option for parallel version of MESIA (try hpseps)."); - //xiaohui modify 2015-03-25 - //WARNING_QUIT("Input","ks_solver=lapack is not an option for parallel version of MESIA (try hpseps)."); WARNING_QUIT("Input","ks_solver=lapack is not an option for parallel version of ABACUS (try hpseps)."); #else ofs_warning << " It's ok to use lapack." << endl; #endif } - //else if( diago_type == "selinv") else if (ks_solver == "selinv") { - WARNING_QUIT("Input","not ready for selinv method in lcao ."); //xiaohui add 2013-09-04 + WARNING_QUIT("Input","not ready for selinv method in lcao ."); } - //xiaohui add 2013-09-04 else if(ks_solver == "linear_scaling") { WARNING_QUIT("Input","not ready for linear_scaling method in lcao ."); - } //xiaohui add 2013-09-04 + } else { - //WARNING_QUIT("Input","please check the diago_type parameter!"); WARNING_QUIT("Input","please check the ks_solver parameter!"); } - //}xiaohui modify 2013-09-01 - //else if(linear_scaling == 2) xiaohui modify 2013-09-01. Attention! Maybe there is some problem. - //{ - //if(diago_type != "canonical" && diago_type != "trace_correcting" && diago_type != "trace_resetting") - //{ - // diago_type = "canonical"; - // AUTO_SET("diago_type","canonical"); - //} - //} - //else xiaohui modify 2013-09-01, move this part to "lcao in pw" - //{ - //if( diago_type != "lapack" ) - //{ - //ofs_warning << " LCAO in plane wave can only done with lapack." << endl; - //diago_type = "lapack"; - //AUTO_SET("diago_type","lapack"); - //} - //} } - else if(basis_type=="lcao_in_pw") //xiaohui add 2013-09-01 + else if(basis_type=="lcao_in_pw") { if( ks_solver != "lapack" ) { - //ofs_warning << " LCAO in plane wave can only done with lapack." << endl; xiaohui modify 2013-09-04 - //ks_solver = "lapack"; xiaohui modify 2013-09-04 - //AUTO_SET("ks_solver","lapack"); xiaohui modify 2013-09-04 WARNING_QUIT("Input","LCAO in plane wave can only done with lapack."); } } - else //xiaohui add 2013-09-01 + else { WARNING_QUIT("Input","please check the basis_type parameter!"); } - //if(local_basis==0 && linear_scaling>0) xiaohui modify 2013-09-01. Attention! Maybe there is some problem. - //{ - // WARNING_QUIT("Input","linear scaling method can not used for plane wave basis!"); - //} - - // add 2010-09-04 - //if(local_basis==0 && gamma_only) xiaohui modify 2013-09-01 - if(basis_type=="pw" && gamma_only) //xiaohui add 2013-09-01 + if(basis_type=="pw" && gamma_only) { WARNING_QUIT("Input","gamma_only not implemented for plane wave now."); } - // add 2010-09-06 - //if(local_basis==0 || (local_basis==4 && !linear_scaling) ) xiaohui modify 2013-09-01 - if(basis_type=="pw" || basis_type=="lcao_in_pw") //xiaohui add 2013-09-01 + if(basis_type=="pw" || basis_type=="lcao_in_pw") { if(gamma_only_local) { @@ -2777,7 +2690,6 @@ void Input::Check(void) } } - //if( (local_basis>0 && linear_scaling) && !gamma_only_local) xiaohui modify 2013-09-01 if(basis_type=="lcao" && !gamma_only_local) //xiaohui add 2013-09-01. Attention! Maybe there is some problem. { WARNING("Input","gamma_only_local algorithm is not used."); @@ -2795,7 +2707,6 @@ void Input::Check(void) } } - //if(NPROC>1 && diago_type=="lapack") xiaohui modify 2013-09-01 if(NPROC>1 && ks_solver=="lapack") //xiaohui add 2013-09-01 { //if(local_basis ==4 && linear_scaling==0) xiaohui modify 2013-09-01 @@ -2809,7 +2720,8 @@ void Input::Check(void) } } - if(ion_dynamics!= "sd" && ion_dynamics!="cg" && ion_dynamics!="bfgs" && ion_dynamics!="cg_bfgs") // pengfei add 13-8-10 a new method cg to bfgs + // pengfei add 13-8-10 a new method cg to bfgs + if(ion_dynamics!= "sd" && ion_dynamics!="cg" && ion_dynamics!="bfgs" && ion_dynamics!="cg_bfgs") { WARNING_QUIT("Input","ion_dynamics can only be sd, cg, bfgs or cg_bfgs."); } @@ -2819,8 +2731,7 @@ void Input::Check(void) WARNING_QUIT("Input","please Input the opt_nbands for optical properties calculations"); } - //if(local_basis==0) xiaohui modify 2013-09-01 - if(basis_type=="pw") //xiaohui add 2013-09-01 + if(basis_type=="pw") { bx=1; by=1; @@ -2848,36 +2759,9 @@ void Input::Check(void) } } -/* - if(vdwD2) //Peize Lin add 2-14-04-05, update 2015-09-30 - { - if( (vdwD2_C6_unit!="Jnm6/mol") && (vdwD2_C6_unit!="eVA6") ) - { - WARNING_QUIT("Input","vdwD2_C6_unit must be Jnm6/mol or eVA6"); - } - if( (vdwD2_R0_unit!="A") && (vdwD2_R0_unit!="Bohr") ) - { - WARNING_QUIT("Input","vdwD2_R0_unit must be A or Bohr"); - } - if( (vdwD2_model!="radius") && (vdwD2_model!="period") ) - { - WARNING_QUIT("Input","vdwD2_model must be radius or period"); - } - if( (vdwD2_period.x<=0) || (vdwD2_period.y<=0) || (vdwD2_period.z<=0) ) - { - WARNING_QUIT("Input","vdwD2_period <= 0 is not allowd"); - } - if( vdwD2_radius<=0 ) - { - WARNING_QUIT("Input","vdwD2_radius <= 0 is not allowd"); - } - if( (vdwD2_radius_unit!="A") && (vdwD2_radius_unit!="Bohr") ) - { - WARNING_QUIT("Input","vdwD2_radius_unit must be A or Bohr"); - } - } */ - if(vdw_method=="d2" || vdw_method=="d3_0" || vdw_method=="d3_bj") //jiyy add 2019-08-04 + // jiyy add 2019-08-04 + if(vdw_method=="d2" || vdw_method=="d3_0" || vdw_method=="d3_bj") { if( (vdw_C6_unit!="Jnm6/mol") && (vdw_C6_unit!="eVA6") ) { @@ -2918,7 +2802,8 @@ void Input::Check(void) WARNING_QUIT("INPUT","spectral_type must be eels or absorption !"); } - if(spectral_type!="None") // pengfei 2016-12-14 + // pengfei 2016-12-14 + if(spectral_type!="None") { if( system!="bulk" && system!="surface") { @@ -2946,10 +2831,15 @@ void Input::Check(void) // } } - if(exx_hybrid_type!="no" && exx_hybrid_type!="hf" && exx_hybrid_type!="pbe0" && exx_hybrid_type!="hse" && exx_hybrid_type!="opt_orb") + if(exx_hybrid_type!="no" && + exx_hybrid_type!="hf" && + exx_hybrid_type!="pbe0" && + exx_hybrid_type!="hse" && + exx_hybrid_type!="opt_orb") { WARNING_QUIT("INPUT","exx_hybrid_type must be no or hf or pbe0 or hse or opt_orb"); } + if(exx_hybrid_type=="hf" || exx_hybrid_type=="pbe0" || exx_hybrid_type=="hse") { if(exx_hybrid_alpha<0 || exx_hybrid_alpha>1) @@ -2964,7 +2854,10 @@ void Input::Check(void) { WARNING_QUIT("INPUT","must exx_ccp_rmesh_times >= 1"); } - if(exx_distribute_type!="htime" && exx_distribute_type!="kmeans2" && exx_distribute_type!="kmeans1" && exx_distribute_type!="order") + if(exx_distribute_type!="htime" + && exx_distribute_type!="kmeans2" + && exx_distribute_type!="kmeans1" + && exx_distribute_type!="order") { WARNING_QUIT("INPUT","exx_distribute_type must be htime or kmeans2 or kmeans1"); } @@ -2984,12 +2877,12 @@ void Input::Check(void) WARNING_QUIT("INPUT","exx_opt_orb_tolerence must >=0"); } } - -//2015-06-15, xiaohui - if(mixing_mode == "pulay" && mixing_gg0 > 0.0) - { - WARNING("Input","To use pulay-kerker mixing method, please set mixing_type=pulay-kerker"); - } + + //2015-06-15, xiaohui + if(mixing_mode == "pulay" && mixing_gg0 > 0.0) + { + WARNING("Input","To use pulay-kerker mixing method, please set mixing_type=pulay-kerker"); + } if(berry_phase) { @@ -3110,8 +3003,6 @@ void Input::Print(const string &fn)const //OUTP(ofs,"diago_type",DIAGO_TYPE,"cg; david; lapack; hpseps;"); xiaohui modify 2013-09-01 OUTP(ofs,"ks_solver",KS_SOLVER,"cg; david; lapack; genelpa; hpseps; scalapack_gvx"); OUTP(ofs,"niter",niter,"#number of electron iterations"); - OUTP(ofs,"vna",vna,"use the vna or not"); - OUTP(ofs,"grid_speed",grid_speed,"1:normal 2:fast");//mohan add 2012-03-29 //OUTP(ofs,"force",force,"calculate the force or not"); OUTP(ofs,"force_set",force_set,"output the force_set or not"); OUTP(ofs,"nstep",nstep,"number of ion iteration steps"); @@ -3181,7 +3072,6 @@ void Input::Print(const string &fn)const OUTP(ofs,"diago_proc",DIAGO_PROC,"number of proc used to diago");//mohan add 2012-01-13 //OUTP(ofs,"gamma_only_pw",gamma_only,"gamma only in pw"); OUTP(ofs,"npool",npool,"number of pools for k points, pw only"); - OUTP(ofs,"sparse_matrix",sparse_matrix,"use sparse matrix, in DMM"); OUTP(ofs,"mem_saver",mem_saver,"memory saver for many k points used"); OUTP(ofs,"printe",printe,"print band energy for selectively ionic steps"); diff --git a/ABACUS.develop/source/input.h b/ABACUS.develop/source/input.h index 1a25760ab1..5a22e4d542 100644 --- a/ABACUS.develop/source/input.h +++ b/ABACUS.develop/source/input.h @@ -89,10 +89,6 @@ class Input //========================================================== string basis_type; //xiaohui add 2013-09-01, for structural adjustment string ks_solver; //xiaohui add 2013-09-01 - bool sparse_matrix; - - int vna; //control the vna term. - int grid_speed; //1:normal 2:fast, mohan add 2012-03-29 //========================================================== // Forces diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index 6eaa24b5fa..c88a82caee 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -133,7 +133,6 @@ void Input_Conv::Convert(void) KS_SOLVER = INPUT.ks_solver; SEARCH_RADIUS = INPUT.search_radius; SEARCH_PBC = INPUT.search_pbc; - SPARSE_MATRIX = INPUT.sparse_matrix; //---------------------------------------------------------- // planewave (8/8) @@ -416,11 +415,13 @@ void Input_Conv::Convert(void) val_elec_03 = INPUT.val_elec_03; vext = INPUT.vext; vext_dire = INPUT.vext_dire; - + + + // jiyy add 2020.10.11 ocp = INPUT.ocp; //ocp_n = INPUT.ocp_n; ocp_set = INPUT.ocp_set; - if(ocp == 1) // jiyy add 2020.10.11 + if(ocp == 1) { int count = 0; string pattern("([0-9]+\\*[0-9.]+|[0-9,.]+)"); diff --git a/ABACUS.develop/source/src_global/sparsematrix.cpp b/ABACUS.develop/source/src_global/sparsematrix.cpp deleted file mode 100644 index 80de48f97e..0000000000 --- a/ABACUS.develop/source/src_global/sparsematrix.cpp +++ /dev/null @@ -1,215 +0,0 @@ -#include "sparsematrix.h" -#include -#include -#include -using namespace std; - -double SparseMatrix::zero = 0.0; - -SparseMatrix::SparseMatrix(const int row_num, const int col_num) -{ - this->init(row_num, col_num); -} -SparseMatrix::~SparseMatrix() -{ - delete[] this->RowSet; -} - -void SparseMatrix::init(const int row_num, const int col_num) -{ - /*Set Size of the Matrix*/ - assert(row_num >= 0); - assert(col_num >= 0); - - this->row = row_num; - this->col = col_num; - this->size = row_num * col_num; - this->size_sparse = 0; - - /*Allocate Space for the Matrix*/ - this->RowSet = new Row[row]; - for(int i=0;i= 0); - assert(col_num >= 0); - delete[] this->RowSet; - this->init(row_num, col_num); - return; -} - -// Set a member -void SparseMatrix::set(const int row_wanted,const int column_wanted,const double &value) -{ - this->RowSet[row_wanted].member.push_back(value); - this->RowSet[row_wanted].j_col.push_back(column_wanted); - this->RowSet[row_wanted].n_col++; - this->size_sparse++; - -// cout<<"\n set()"<<" row="<row); - assert(row_wanted >= 0 ); - assert(column_wanted < this->col); - assert(column_wanted >= 0); - - for(int ic=0; icRowSet[ row_wanted].j_col[ic] == column_wanted) - { - this->RowSet[row_wanted].member[ic] += value; - return; - } - } - - this->set(row_wanted, column_wanted, value); - return; -} - -SparseMatrix& SparseMatrix::operator=(const SparseMatrix &m) -{ - if(m.row!=this->row || m.col!=this->col) - { - cout << "\n row/col number can't match in ComplexMatrix '=' operator\n"; - cout << " this row = " << this->row; - cout << " this col = " << this->col; - cout << " in row = " << m.row; - cout << " in col = " << m.col; - exit(0); - } - else { - this->create(m.row, m.col); - this->size_sparse=0; - } - - for(int ir=0; ir SparseMatrix::convert_to_matrix"; - matrix cm(this->row, this->col); -// cout << "\n row = " << this->row << " col = " << this->col; - for(int i=0;irow;i++) - { - for(int j=0;jRowSet[i].n_col;j++) - { - // cout<<"\n i="<RowSet[i].member[j]; - cm(i, this->RowSet[i].j_col[j]) = this->RowSet[i].member[j]; - } - } - return cm; -} - -void SparseMatrix::multiply_vector( - const double* psi, // - double* h_psi)const -{ - for(int i=0;irow;i++) - { - h_psi[i] = 0.0; - } - - for(int i=0;irow;i++) - { - for(int j=0;jRowSet[i].n_col;j++) - { - -// if( abs( this->RowSet[i].member[j].real() ) > 1.0e-5) -// cout<<"\n i="<RowSet[i].member[j].real() -// <<" "<RowSet[i].j_col[j] ].real(); - - h_psi[i] += this->RowSet[i].member[j] * psi[ this->RowSet[i].j_col[j] ]; - } -// cout<<"\n result ==> "<< h_psi[i]; - } - return; -} - -double SparseMatrix::rate(void) const -{ - assert(size!=0); -// cout << "\n size_sparse = " << size_sparse; - const double occupy_rate = static_cast(size_sparse)/ - static_cast(size); - return occupy_rate; -} diff --git a/ABACUS.develop/source/src_global/sparsematrix.h b/ABACUS.develop/source/src_global/sparsematrix.h deleted file mode 100644 index f3fd78acb3..0000000000 --- a/ABACUS.develop/source/src_global/sparsematrix.h +++ /dev/null @@ -1,85 +0,0 @@ -//========================================================== -// Author: ywcui ,mohan -// Last Upstae : 2009-3-8 -//========================================================== -#ifndef SPARSEMATRIX_H -#define SPARSEMATRIX_H - -#include -#include -#include -#include "matrix.h" - -using namespace std; - -// define a row in the matrix -struct Row -{ - Row():n_col(0){}; - ~Row(){}; - - vector< double > member; - vector j_col;//column number j of a member - int n_col;//non_zero member number in a row - // Constructors and destructor -}; - - -class SparseMatrix -{ -public: - // default constructor - SparseMatrix(const int row_num=0, const int col_num=0); - ~SparseMatrix(); - - // matrix size - int row; //row number - int col; //column number - - // rows in the matrix - Row * RowSet; - - //allocate new space for a sparse matrix - void create (const int row_num, const int col_num); - - //add an new element - void set( - const int row_wanted, - const int column_wanted, - const double &value); - - void set_add( - const int row_wanted, - const int column_wanted, - const double &value); - - void reset( - const int row_wanted, - const int column_wanted, - const double &value); - - // An important function - void multiply_vector( - const double* psi, - double* h_psi - )const; - - //operators - double &operator()(const int row,const int column); - const double &operator()(const int row,const int column)const ; - SparseMatrix& operator=(const SparseMatrix &m); - - const matrix convert_to_matrix(void)const; - - double rate(void) const; - -private: - void init(const int row_num, const int col_num); - int size_sparse; - int size; - - static double zero; - -}; - -#endif diff --git a/ABACUS.develop/source/src_lcao/LCAO_hamilt.h b/ABACUS.develop/source/src_lcao/LCAO_hamilt.h index 1c98757418..9679253313 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_hamilt.h +++ b/ABACUS.develop/source/src_lcao/LCAO_hamilt.h @@ -5,7 +5,6 @@ #include "LCAO_gen_fixedH.h" #include "gint_gamma.h" #include "gint_k.h" -#include "grid_integral.h" class Use_Hamilt_Matrix { diff --git a/ABACUS.develop/source/src_lcao/ORB_control.cpp b/ABACUS.develop/source/src_lcao/ORB_control.cpp index 020e84ebb6..7206eed0e8 100644 --- a/ABACUS.develop/source/src_lcao/ORB_control.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_control.cpp @@ -3,7 +3,6 @@ #include "ORB_control.h" #include "src_global/sltk_atom_arrange.h" #include "ORB_gen_tables.h" -#include "grid_integral.h" #include "build_st_pw.h" ORB_control::ORB_control() diff --git a/ABACUS.develop/source/src_lcao/grid_base.cpp b/ABACUS.develop/source/src_lcao/grid_base.cpp index 072abb9d8d..09644971a7 100644 --- a/ABACUS.develop/source/src_lcao/grid_base.cpp +++ b/ABACUS.develop/source/src_lcao/grid_base.cpp @@ -1,8 +1,7 @@ -#include "grid_integral.h" #include "../src_pw/global.h" #include "ylm.h" #include "ORB_read.h" - +#include "grid_base.h" #include "global_fp.h" // mohan add 2021-01-30 Grid_Base::Grid_Base() diff --git a/ABACUS.develop/source/src_lcao/grid_base.h b/ABACUS.develop/source/src_lcao/grid_base.h index a968b551a9..dd81eb1266 100644 --- a/ABACUS.develop/source/src_lcao/grid_base.h +++ b/ABACUS.develop/source/src_lcao/grid_base.h @@ -29,7 +29,6 @@ class Grid_Base // MEMBER FUNCTION : //=========================================================== // define pointer - SparseMatrix* SM; // about vlocal const double* vlocal; void get_rcut_max(void); diff --git a/ABACUS.develop/source/src_lcao/grid_base_beta.cpp b/ABACUS.develop/source/src_lcao/grid_base_beta.cpp index a7acc0a3e0..fef5d98700 100644 --- a/ABACUS.develop/source/src_lcao/grid_base_beta.cpp +++ b/ABACUS.develop/source/src_lcao/grid_base_beta.cpp @@ -1,4 +1,3 @@ -#include "grid_integral.h" #include "../src_pw/global.h" #include "ylm.h" diff --git a/ABACUS.develop/source/src_lcao/grid_integral.cpp b/ABACUS.develop/source/src_lcao/grid_integral.cpp deleted file mode 100644 index 5f9529a0ee..0000000000 --- a/ABACUS.develop/source/src_lcao/grid_integral.cpp +++ /dev/null @@ -1,313 +0,0 @@ -#include "grid_integral.h" -#include "../src_pw/global.h" -#include "ylm.h" -#include "ORB_read.h" - -#include "global_fp.h" // mohan add 2021-01-30 - - -// use density kernel(density matrix) to calcualte the density -// on real space grid. -void Grid_Integral::cal_rho(void) -{ - if(test>0)TITLE("Grid_Integral","cal_rho"); - timer::tick("Grid_Integral","cal_rho"); - - // there are two job available: cal_charge or cal_local. - this->job = cal_charge; - - //========================================= - // calculte chrge density from local basis - //========================================= - this->deal_region_atoms(); - - timer::tick("Grid_Integral","cal_rho"); - return; -} - -void Grid_Integral::cal_vlocal( - const double* vlocal_in, - SparseMatrix &SM_in) -{ - if(test>0)TITLE("Grid_Integral","cal_vlocal"); - timer::tick("Grid_Integral","cal_vlocal"); - this->test = 0; - this->job = cal_local; - - // a pointer point to the sparse matrix. - this->SM = &SM_in; - - // a pointer point to the real space grid vlocal. - this->vlocal = vlocal_in; - - //================================================= - // calculte vlocal grid integral from local basis - //================================================= - this->deal_region_atoms(); - timer::tick("Grid_Integral","cal_vlocal"); - return; -} - -// be called by : Grid_Integral::cal_rho & Grid_Integral::cal_vlocal -// this program is in the core of the whole LCAO program. -// it's very important to make this part efficient. -void Grid_Integral::deal_region_atoms(void) -{ -// if(test>0)TITLE("Grid_Integral","cal_region_alpha"); - for(int T1=0; T11)!"); - } - - if( min_direct_coordinate.z > max_direct_coordinate.z ) - { - ofs_warning << "\n min_direct_z=" << min_direct_coordinate.z; - ofs_warning << "\n max_direct_z=" << max_direct_coordinate.z; - WARNING_QUIT("Grid_Base::constrain_grid","min_direct_coordinate.z > max_direct_coordinate.z"); - } - - this->lmax1 = ucell.atoms[T1].nwl + 1; - this->lmax2 = ucell.atoms[T2].nwl + 1; - this->n1 = lmax1 * lmax1; - this->n2 = lmax2 * lmax2; - - // (4) 8 Edge Points In Which Includes the Two Orbitals in Direct Coordinates - this->edge_grid_points( R1*this->lat0, R2*this->lat0, max_direct_coordinate, min_direct_coordinate ); - this->iw1_all = ucell.itiaiw2iwt(T1, I1, 0); - - //cout << "\n T1=" << T1 << " I1=" << I1 << " T2=" << T2 << " I2=" << I2; - this->deal_region_orbitals( - R1, //atomic position of the first atom - T1, - I1, - R2, //atomic position of the second atom - T2, - I2); - } - } - } - } - return; -} - -// be called by cal_region_atoms -// FUNCTION : deal things happen between two atoms. -void Grid_Integral::deal_region_orbitals -( - const Vector3 &R1, //atomic position of the first atom - const int &T1, - const int &I1, - const Vector3 &R2, //atomic position of the second atom - const int &T2, - const int &I2 -) -{ - this->Rcut1 = ORB.Phi[T1].getRcut(); - this->Rcut2 = ORB.Phi[T2].getRcut(); - for (int L1 = 0; L1 < ucell.atoms[T1].nwl + 1; L1++) - { - for (int N1 = 0; N1 < ucell.atoms[T1].l_nchi[L1]; N1++) - { - for (int m1 = 0; m1 < 2*L1 + 1; m1++) - { - // calculate iw2_all and index1 - this->iw2_all = ucell.itiaiw2iwt(T2, I2, 0); - this->index1 = L1*L1+m1; - - for (int L2 = 0; L2 < ucell.atoms[T2].nwl+1; L2++) - { - for (int N2 = 0; N2 < ucell.atoms[T2].l_nchi[L2]; N2++) - { - for (int m2 = 0; m2 < 2*L2 + 1; m2++) - { - - if( iw1_all > iw2_all) - { - ++iw2_all; - continue; - } - - this->index2 = L2*L2+m2; - this->pointer1 = &ORB.Phi[T1].PhiLN(L1, N1); - this->pointer2 = &ORB.Phi[T2].PhiLN(L2, N2); - - switch( job ) - { - case cal_local: - this->vlocal_in_small_box(); - break; - - case cal_charge: - this->rho_in_small_box(); - break; - - default: - WARNING_QUIT("Grid_Integral::cal_region","check job!"); - } - ++iw2_all; - }// m2 - }// N2 - }// L2 - ++iw1_all; - }// m1 - }// N1 - }// L1 - return; -} - - -void Grid_Integral::rho_in_small_box(void) -{ - int count = 0; - - double factor; - if(iw1_all == iw2_all) factor=1; - else factor = 2; - - double* yy1_lm = this->yy1[index1]; - double* yy2_lm = this->yy2[index2]; - double dk = LOC.DM[0][iw1_all][iw2_all]; - -// double sum = 0.0; - for (int i = this->edge_min.x; i < this->edge_max.x; i++) - { - for (int j = this->edge_min.y; j < this->edge_max.y; j++) - { - for (int k = this->edge_min.z; k < this->edge_max.z; k++) - { - if ( this->norm1[count] < this->Rcut1 && this->norm2[count] < this->Rcut2) - { - CHR.rho[0][ ijk_index[count] ] += factor * - Mathzone::Polynomial_Interpolation( - pointer1->getPsiuniform(), // Peize Lin update 2016-05-14 - pointer1->getNruniform(), - pointer1->getDruniform(), - norm1[count]) - * - Mathzone::Polynomial_Interpolation( - pointer2->getPsiuniform(), // Peize Lin update 2016-05-14 - pointer2->getNruniform(), - pointer2->getDruniform(), - norm2[count]) - * - yy1_lm[count] - * - yy2_lm[count] - * - dk; - -// sum += psi1 * yy1( this->index1, count)* psi2 * yy2( this->index2, count); - } - count++; - - } - } - } -// if( sum > 1.0e-5 ) -// cout << "\n" << " iw1_all = " << iw1_all << " iw2_all = " << iw2_all << " sum = " << sum * pw.omega / pw.ncxyz; - return; -} - -void Grid_Integral::vlocal_in_small_box(void) -{ - double v = 0.0; - int count=0; - - double* yy1_lm = this->yy1[index1]; - double* yy2_lm = this->yy2[index2]; - - for (int i = this->edge_min.x; i < this->edge_max.x; i++) - { - for (int j = this->edge_min.y; j < this->edge_max.y; j++) - { - for (int k = this->edge_min.z; k < this->edge_max.z; k++) - { - //timer::tick("Grid_Integral","interpo"); - - if ( this->norm1[count] < this->Rcut1 && this->norm2[count] < this->Rcut2) - { - - v += Mathzone::Polynomial_Interpolation( - pointer1->getPsiuniform(), // Peize Lin update 2016-05-14 - pointer1->getNruniform(), - pointer1->getDruniform(), - norm1[count]) - * - Mathzone::Polynomial_Interpolation( - pointer2->getPsiuniform(), // Peize Lin update 2016-05-14 - pointer2->getNruniform(), - pointer2->getDruniform(), - norm2[count]) - * - yy1_lm[count] - * - yy2_lm[count] - * - this->vlocal[ ijk_index[count] ]; - } - count++; - } - } - } - // unit : (a.u.) - SM->set_add(iw1_all, iw2_all, v * latvec0.Det() / nxyz ); - - if(iw1_all!=iw2_all) - { - SM->reset( iw2_all, iw1_all, SM[0](iw1_all,iw2_all) ); - } - - return; -} - - - diff --git a/ABACUS.develop/source/src_lcao/grid_integral.h b/ABACUS.develop/source/src_lcao/grid_integral.h deleted file mode 100644 index 58964b89dd..0000000000 --- a/ABACUS.develop/source/src_lcao/grid_integral.h +++ /dev/null @@ -1,49 +0,0 @@ -//========================================================= -//AUTHOR : liaochen, mohan -//DATE : 2008-03-28 -//========================================================= -#ifndef GRID_INTEGRAL_H -#define GRID_INTEGRAL_H - -#include "../src_pw/tools.h" -#include "grid_base.h" -//========================================================= -//CLASS Grid_Integral -//Note : Integral On 3D Grids -//Feature : Matrix Elements Of Local Potential For -//Numerical Orbitals -//========================================================= - -class Grid_Integral : public Grid_Base -{ -public: - - Grid_Integral(){}; - ~Grid_Integral(){}; - - void cal_rho(void); - - void cal_vlocal( const double* vlocal_in, - SparseMatrix &SM_in); - -private: - - void deal_region_atoms(void); - - void deal_region_orbitals - ( - const Vector3 &R1, //atomic position of the first atom - const int &T1, - const int &I1, - const Vector3 &R2, //atomic position of the second atom - const int &T2, - const int &I2 - ); - - void vlocal_in_small_box(void); - void rho_in_small_box(void); - - -}; - -#endif diff --git a/ABACUS.develop/source/src_pw/electrons.cpp b/ABACUS.develop/source/src_pw/electrons.cpp index b38c77513c..ddc6cb1a3c 100644 --- a/ABACUS.develop/source/src_pw/electrons.cpp +++ b/ABACUS.develop/source/src_pw/electrons.cpp @@ -496,10 +496,6 @@ void Electrons::c_bands(const int &istep) // // In localized orbital presented in plane wave case, // only using cinitcgg. - // - // In linear scaling method, using sparse matrix and - // adjacent searching code and cg method to calculate the - // eigenstates. //============================================================= double avg_iter_k = 0.0; hm.diago(istep, this->iter, ik, h_diag, avg_iter_k); diff --git a/ABACUS.develop/source/src_pw/tools.h b/ABACUS.develop/source/src_pw/tools.h index 630431c96f..8a25c54f08 100644 --- a/ABACUS.develop/source/src_pw/tools.h +++ b/ABACUS.develop/source/src_pw/tools.h @@ -25,7 +25,6 @@ using namespace std; #include "../src_global/intarray.h" #include "../src_global/complexarray.h" #include "../src_global/complexmatrix.h" -#include "../src_global/sparsematrix.h" #include "../src_global/memory.h" #include "../src_global/timer.h" From d2005457a25dd548a7bbc9472b12b81cfb7cd5f2 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 17 Feb 2021 21:15:18 +0800 Subject: [PATCH 129/233] delete nbxx_start in pw_basis.cpp because it is useless, update comments in pw_basis.h and .cpp --- ABACUS.develop/source/README | 5 +- .../source/src_lcao/local_orbital_elec.cpp | 3 - .../source/src_parallel/parallel_pw.h | 1 + ABACUS.develop/source/src_pw/electrons.cpp | 1 - ABACUS.develop/source/src_pw/pw_basis.cpp | 9 +- ABACUS.develop/source/src_pw/pw_basis.h | 146 ++++++++++-------- 6 files changed, 92 insertions(+), 73 deletions(-) diff --git a/ABACUS.develop/source/README b/ABACUS.develop/source/README index d06f242a80..4c52573e49 100644 --- a/ABACUS.develop/source/README +++ b/ABACUS.develop/source/README @@ -5,7 +5,8 @@ implementing new functions, and adding more autotests. URGENT: -Ask Xiaohui Liu: all functions named with 'after_vc' should be reconstructed +Ask Xiaohui Liu: all functions named with 'after_vc' should be reconstructed. +The 'FINAL_SCF' global varialble should be removed. (condition: need to reconstruct these codes within a given time) Ask Fuxiang He: we need to remove all TDDFT-related global variables @@ -24,4 +25,6 @@ Ask Peize: explain exx_lip.h Ask Yuyang Ji: what's 'ocp' in input.cpp, what are the options about 'ocp' in input_conv.cpp? +QUESTION: +* in pw_basis.cpp, why ggwfc2=ggwfc if gamma_only is used? diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp index 10104846d7..7b272c9f5f 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp @@ -46,9 +46,6 @@ void Local_Orbital_Elec::set_matrix_grid_index(void) //DONE(ofs_running,"SEARCH ADJACENT ATOMS"); // (3) Periodic condition search for each grid. - // here 0 means GridT is not used for Vna. - // mohan add Vna 2012-06-13 - // because it must be consistent with gtf in lcao_vna. GridT.set_pbc_grid( pw.ncx, pw.ncy, pw.ncz, pw.bx, pw.by, pw.bz, diff --git a/ABACUS.develop/source/src_parallel/parallel_pw.h b/ABACUS.develop/source/src_parallel/parallel_pw.h index 05ae4bdb9a..88c72a83b8 100644 --- a/ABACUS.develop/source/src_parallel/parallel_pw.h +++ b/ABACUS.develop/source/src_parallel/parallel_pw.h @@ -60,6 +60,7 @@ class Parallel_PW//: public PW_Basis int rank_use; private: + double gcut; int *ig_l2g; int ngm_i; diff --git a/ABACUS.develop/source/src_pw/electrons.cpp b/ABACUS.develop/source/src_pw/electrons.cpp index ddc6cb1a3c..74a5e8ae3e 100644 --- a/ABACUS.develop/source/src_pw/electrons.cpp +++ b/ABACUS.develop/source/src_pw/electrons.cpp @@ -347,7 +347,6 @@ void Electrons::self_consistent(const int &istep) pot.set_vrs_tddft(istep); } - //pot.set_vrs(pw.doublegrid); //print_eigenvalue(ofs_running); en.calculate_etot(); diff --git a/ABACUS.develop/source/src_pw/pw_basis.cpp b/ABACUS.develop/source/src_pw/pw_basis.cpp index 41b482472d..0b43032793 100644 --- a/ABACUS.develop/source/src_pw/pw_basis.cpp +++ b/ABACUS.develop/source/src_pw/pw_basis.cpp @@ -35,7 +35,7 @@ PW_Basis::PW_Basis() this->nczp_start = 0; gg_global0 = nullptr; //LiuXh 20180515 - cutgg_num_table = nullptr; //LiuXh 20180515 + cutgg_num_table = nullptr; //LiuXh 0180515 ggchg_time_global = 0; //LiuXh 20180515 } @@ -185,7 +185,7 @@ void PW_Basis::gen_pw(ofstream &runlog, const UnitCell &Ucell_in, const kvect &K // mohan update 2011-09-21 this->nbzp=nbz; //nbz shoud equal nz for single proc. this->nczp=nbzp*bz; - this->nbxx=nbz*ncx*ncy; + this->nbxx=nbz*nbx*nby; //mohan fix 2021-02-17 this->nbzp_start=0; bool cutgg_flag = false; #endif @@ -380,14 +380,10 @@ void PW_Basis::setup_gg(void) // Ry*a0^2/(2*PI)^2 //================================= - //================================= // FFT cut off for wave function - //================================= this->ggwfc = 4 * this->ggpsi; - //================================== // FFT cut off for charge/potential - //================================== this->ggchg = wfac * this->ggpsi; this->ggwfc2 = 0; @@ -519,7 +515,6 @@ void PW_Basis::divide_fft_grid(void) OUT(ofs_running,"nbxx",nbxx); OUT(ofs_running,"nrxx",nrxx); if(test_pw)OUT(ofs_running,"nrxx_start",nrxx_start); - if(test_pw)OUT(ofs_running,"nbxx_start",nbxx_start); //===================================== // generate nst,st_i,st_j,st_k,npps diff --git a/ABACUS.develop/source/src_pw/pw_basis.h b/ABACUS.develop/source/src_pw/pw_basis.h index 4fa4c788cf..65ea9cb067 100644 --- a/ABACUS.develop/source/src_pw/pw_basis.h +++ b/ABACUS.develop/source/src_pw/pw_basis.h @@ -19,17 +19,10 @@ class PW_Basis PW_Basis(); ~PW_Basis(); - // pointer for UnitCell - const UnitCell *Ucell; - - // pointer for K-point list - const kvect *Klist; - - // FFT grid for charge density - FFT FFT_chg; - - // FFT grid for wave functions - FFT FFT_wfc; + const UnitCell *Ucell; // pointer for UnitCell + const kvect *Klist; // pointer for K-point list + FFT FFT_chg; // FFT operations for charge density + FFT FFT_wfc; // FFT operations for wave functions void set ( @@ -47,56 +40,88 @@ class PW_Basis const int &bz_in ); - //====================== - // Part1:Energy cutoff - //====================== - bool gamma_only; // only half G are used. - double wfac; // weighting factor - double ecutwfc; // Energy cutoff for wavefunctions. - double ecutrho; // Energy cutoff for charge/potential. + //=============================================== + // Part 1: Kinetic energy cutoff for plane waves + //=============================================== + bool gamma_only; // only half G are used. + double ecutwfc; // Energy cutoff for wavefunctions. + double ecutrho; // Energy cutoff for charge/potential. // ggpsi=2*Ecut*(lat0*lat0)/(4.0*PI*PI); - // in NCPP, ggchg=ggfft - // in USPP (double grids), ggchg=4*ggfft - double ggpsi; // planewave cut off for the wavefunctions, unit (2*PI/lat0)^2 - double ggwfc; // ggwav;(=G2max);/ G^2 cutoff for wave function FFT box, unit (2*PI/a0)^2, - double ggwfc2; // ggwav=wfact*ggpsi, default value: wfact=4.0 - double ggchg; // G^2 cutoff for supporting charge density, - - //=============== - // FFT_dimension - //=============== - int bx, by, bz, bxyz; // subset of each grid of FFT box, for example 2 2 2 - int nbx, nby, nbz, nbxyz; // - int nbzp, nbzp_start; // start ncz in each process, mohan add 2009-11-09 - int nbxx, nbxx_start; - - int nx, ny, nz, nxyz; // fft dimensions for wave functions. - int ncx, ncy, ncz, ncxyz; // fft dimensions for charge/potential. - int nczp, nczp_start; // start ncz in each process, mohan add 2009-11-09 - - ComplexMatrix strucFac; // StrucFac (ntype,ngmax) - - //========================================= - // Part2: Wave function(G vectors,FFT box) - //========================================= - int ngmw; //(= ngmax) / num. of G vectors within ggfft - /*** mohan add 2008-3-25 ***/ - int *ig2fftw; //(=*ind_FFT) /1D G vector -> for wave function FFT + // in NCPP, ggchg=ggfft; in USPP (double grids), ggchg=4*ggfft + double ggpsi; // planewave cut off for the wavefunctions, unit (2*PI/lat0)^2 + double ggwfc; // cutoff for wave function, ggwfc=4*ggpsi + double ggwfc2; // ggwav=wfact*ggpsi, default value: wfact=4.0 + double wfac; // weighting factor from ggpsi to ggwfc2 + double ggchg; // G^2 cutoff for supporting charge density, + + //=============================================== + // Part 2: FFT dimensions in real space + //=============================================== + + //----------------------------------------------- + // FFT dimensions for wave functions. + int nx, ny, nz, nxyz; + // FFT dimensions for charge/potential. + int ncx, ncy, ncz, ncxyz; + // nczp: number of x-y planes in each processor + // nczp_start: starting nczp index in each processor + int nczp, nczp_start; + // nrxx: for parallel,local FFT grid dimension + int nrxx; + // nrxx_start: starting nrxx in each processor + int nrxx_start; + + //----------------------------------------------- + // used in LCAO algorithm: grid integrals + // combine [bx,by,bz] FFT grids into a big one + // typical values are bx=2, by=2, bz=2 + // bxyz = bx*by*bz, typical value is 8 + int bx, by, bz, bxyz; + // nbx=ncx/bx, nby=ncy/by, nbz=ncz/bz, + // nbxyz=nbx*nby*nbz + int nbx, nby, nbz, nbxyz; + // nbzp: number of x-y planes in each processor + // nbzp_start: starting nbzp index in each processor + int nbzp, nbzp_start; + // nbxx is local dimension of nbxyz + // nbxx=nbx*nby*nbzp + int nbxx; + + + //=============================================== + // Part 3: G vectors in reciprocal FFT box + //=============================================== + + // structure factor (ntype, ngmax) + ComplexMatrix strucFac; + + // (= ngmax) / num. of G vectors within ggfft + int ngmw; + + // mohan add 2008-3-25 + // (=*ind_FFT) /1D G vector -> for wave function FFT + int *ig2fftw; //ig2fftw= new int [ngmw] for wave functions //ig2fftw[ng] -> the coordinates in FFT box //=============================================== - // Part3: Charge & Potential (G vectors,FFT box) + // Part 4: Charge & Potential (G vectors,FFT box) //=============================================== + // G vectors, FFT box related to charge density and potentials etc. - // fft grid for charge density, potentials etc. + // FFT grid for charge density, potentials etc. // this grid equal to the wave function grid - int nrxx; //for parallel,local FFT grid dimension - int nrxx_start; //for parallel,local FFT grid dimension - int ngmc; // new, num. of G vectors within ggchg, - int ngmc_g; // mohan add 2008-4-2 - int *ig2fftc; //(=*ind_FFT) //1D G vector -> charge/potential FFT + + + // new, num. of G vectors within ggchg + int ngmc; + + // mohan add 2008-4-2 + int ngmc_g; + + // mohan add 2008-4-2 + int *ig2fftc; //ig2fftc= new int [ngmc] for wave functions //ig2fftc[ng] -> the coordinates in FFT box @@ -120,6 +145,7 @@ class PW_Basis // void set_nggm() //================== int nggm; // =ngl(another dft code); + // number of |G| shells (i.e., how many different |G|s) double *ggs; // store the |G|^2 for each shell int *ig2ngg; //=*igtong1 (another dft code) @@ -140,30 +166,28 @@ class PW_Basis int *cutgg_num_table; //LiuXh add 20180515 int ggchg_time_global; //LiuXh add 20180515 - bool doublegrid; // .TRUE. if we use a double grid; (for USPP) - // .FALSE., if NCPP. void gen_pw(ofstream &log, const UnitCell &Ucell_in, const kvect &Klist_in); - void setup_structure_factor(); // Calculate structur factors + void setup_structure_factor(void); // Calculate structur factors void update_gvectors(ofstream &log, const UnitCell &Ucell_in); //LiuXh add 20180515 private: - void setup_gg(); + void setup_gg(void); - void setup_FFT_dimension(); // set up FFT dimensions + void setup_FFT_dimension(void); // set up FFT dimensions #ifdef __MPI - void divide_fft_grid(); + void divide_fft_grid(void); - void get_MPI_GVectors(); + void get_MPI_GVectors(void); - void columns_and_pw_distribution_2(); + void columns_and_pw_distribution_2(void); #else - void get_GVectors(); + void get_GVectors(void); #endif From af459f8e53ea6693892bd5c34d09063184f6ff97 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 17 Feb 2021 22:04:54 +0800 Subject: [PATCH 130/233] update pw_basis variables and functions --- ABACUS.develop/source/src_pw/pw_basis.cpp | 19 +-- ABACUS.develop/source/src_pw/pw_basis.h | 184 ++++++++++++---------- 2 files changed, 102 insertions(+), 101 deletions(-) diff --git a/ABACUS.develop/source/src_pw/pw_basis.cpp b/ABACUS.develop/source/src_pw/pw_basis.cpp index 0b43032793..412b968637 100644 --- a/ABACUS.develop/source/src_pw/pw_basis.cpp +++ b/ABACUS.develop/source/src_pw/pw_basis.cpp @@ -4,7 +4,6 @@ // 3. delete condition justification in pw_and_columns distributins 2 #include "tools.h" -//#include "algorithms.h" #include "pw_basis.h" #include "../src_pw/pw_complement.h" @@ -121,7 +120,6 @@ void PW_Basis::set } -//#include "../src_develop/src_wannier/winput.h" // initialize of plane wave basis. void PW_Basis::gen_pw(ofstream &runlog, const UnitCell &Ucell_in, const kvect &Klist_in) { @@ -160,7 +158,7 @@ void PW_Basis::gen_pw(ofstream &runlog, const UnitCell &Ucell_in, const kvect &K // if calculation is 'test', we don't need // to allocate the arrays, claculate the // structure factors, etc. - // we just return here. + // just return here. //---------------------------------------- if(CALCULATION=="test") { @@ -201,11 +199,11 @@ void PW_Basis::gen_pw(ofstream &runlog, const UnitCell &Ucell_in, const kvect &K double cutgg_pieces = 10; -// OUT(ofs_running,"cutgg_pieces",cutgg_pieces); + // OUT(ofs_running,"cutgg_pieces",cutgg_pieces); const double cutgg_delta = ggchg / std::pow( (double)cutgg_pieces, 2.0/3.0 ); // get cutgg_delta from input. -// OUT(ofs_running,"cutgg_delta",cutgg_delta); + // OUT(ofs_running,"cutgg_delta",cutgg_delta); //int cutgg_num_start = 0; double ggchg_start = 0.0; @@ -466,11 +464,6 @@ void PW_Basis::setup_FFT_dimension(void) #ifdef __MPI -// FUNCTION: -// set nbzp: how many planes in this processor -// set nczp -// set nbxx -// set nrxx void PW_Basis::divide_fft_grid(void) { TITLE("PW_Basis","divide_fft_grid"); @@ -559,7 +552,7 @@ void PW_Basis::divide_fft_grid(void) ////////////////////////////////// EXPLAIN ////////////////////////////////// -// M. Gong has made mistakes during calculating the effective structure factor +// M. Gong has made mistakes during calculating the effective structure factor // ig1[i], ig2[i], ig3[i] store the $G$ points using Cartesian coordinate, // where -ncx <= ig1[] <= ncx, -ncy <= ig2[] <= ncy and -ncz <= ig3[] <= ncz // ngmc > ngmw. ig1, ig2 and ig3 is a mapping between (k+G) <-> G @@ -698,9 +691,7 @@ void PW_Basis::get_nggm(const int ngmc_local) //******************************** - // - // number of different |G| shells - // + // number of different |G| values // ******************************* this->nggm = ng; diff --git a/ABACUS.develop/source/src_pw/pw_basis.h b/ABACUS.develop/source/src_pw/pw_basis.h index 65ea9cb067..e83cc74125 100644 --- a/ABACUS.develop/source/src_pw/pw_basis.h +++ b/ABACUS.develop/source/src_pw/pw_basis.h @@ -14,15 +14,12 @@ using namespace std; class PW_Basis { - public: +public: PW_Basis(); ~PW_Basis(); - const UnitCell *Ucell; // pointer for UnitCell - const kvect *Klist; // pointer for K-point list - FFT FFT_chg; // FFT operations for charge density - FFT FFT_wfc; // FFT operations for wave functions + void gen_pw(ofstream &log, const UnitCell &Ucell_in, const kvect &Klist_in); void set ( @@ -40,9 +37,18 @@ class PW_Basis const int &bz_in ); - //=============================================== - // Part 1: Kinetic energy cutoff for plane waves - //=============================================== + const UnitCell *Ucell; // pointer for UnitCell + const kvect *Klist; // pointer for K-point list + + FFT FFT_chg; // FFT operations for charge density + FFT FFT_wfc; // FFT operations for wave functions + + + +//=============================================== +// Part 1: Kinetic energy cutoff for plane waves +//=============================================== +public: bool gamma_only; // only half G are used. double ecutwfc; // Energy cutoff for wavefunctions. double ecutrho; // Energy cutoff for charge/potential. @@ -55,11 +61,16 @@ class PW_Basis double wfac; // weighting factor from ggpsi to ggwfc2 double ggchg; // G^2 cutoff for supporting charge density, - //=============================================== - // Part 2: FFT dimensions in real space - //=============================================== +private: + // setup for ggpsi, ggwfc, ggwfc2, ggchg + void setup_gg(void); + - //----------------------------------------------- + +//=============================================== +// Part 2: FFT dimensions in real space +//=============================================== +public: // FFT dimensions for wave functions. int nx, ny, nz, nxyz; // FFT dimensions for charge/potential. @@ -72,8 +83,16 @@ class PW_Basis // nrxx_start: starting nrxx in each processor int nrxx_start; - //----------------------------------------------- - // used in LCAO algorithm: grid integrals +private: + void setup_FFT_dimension(void); // set up FFT dimensions + + + +//=============================================== +// Part 3: FFT dimensions in real space +// used in LCAO algorithm: grid integrals +//=============================================== +public: // combine [bx,by,bz] FFT grids into a big one // typical values are bx=2, by=2, bz=2 // bxyz = bx*by*bz, typical value is 8 @@ -89,46 +108,45 @@ class PW_Basis int nbxx; - //=============================================== - // Part 3: G vectors in reciprocal FFT box - //=============================================== - - // structure factor (ntype, ngmax) - ComplexMatrix strucFac; - - // (= ngmax) / num. of G vectors within ggfft - int ngmw; - - // mohan add 2008-3-25 - // (=*ind_FFT) /1D G vector -> for wave function FFT - int *ig2fftw; - //ig2fftw= new int [ngmw] for wave functions - //ig2fftw[ng] -> the coordinates in FFT box - //=============================================== - // Part 4: Charge & Potential (G vectors,FFT box) - //=============================================== +//=============================================== +// Part 4: G vectors in reciprocal FFT box +//=============================================== +public: + // mohan add 2008-4-2 + int ngmc_g; // global ngmc (total number of G vectors) + int ngmc; // num. of G vectors within ggchg in each proc. + // map: 1D G vector -> charge in FFT grid + int *ig2fftc; // dimension: [ngmc] - // G vectors, FFT box related to charge density and potentials etc. - // FFT grid for charge density, potentials etc. - // this grid equal to the wave function grid + // PW_complement::get_ngmw(ngmc, ggwfc2, gg_global, ngmw); + int ngmw; // num. of G vectors within ggwfc2 in each proc. + // map: 1D G vector -> wave function in FFT grid + int *ig2fftw; // dimension: [ngmw] + // structure factor (ntype, ngmc) + ComplexMatrix strucFac; + void setup_structure_factor(void); // Calculate structur factors - // new, num. of G vectors within ggchg - int ngmc; +private: +#ifdef __MPI + void divide_fft_grid(void); + void get_MPI_GVectors(void); + void columns_and_pw_distribution_2(void); +#else + void get_GVectors(void); +#endif - // mohan add 2008-4-2 - int ngmc_g; - // mohan add 2008-4-2 - int *ig2fftc; - //ig2fftc= new int [ngmc] for wave functions - //ig2fftc[ng] -> the coordinates in FFT box +//=============================================== +// Part 5: G vectors, |G|^2, G index [ngmc] +//=============================================== +public: Vector3 *gdirect; //(= *G1d) ; // ig = new Vector igc[ngmc], Vector3 *gdirect_global; //(= *G1d) ; // ig = new Vector igc[ngmc], // store the 3D G vector coordinates for charge density grid; - //ig.x, ig.y, ig.z should be integers !!! + // ig.x, ig.y, ig.z should be integers !!! // G vectors are in order of increasing G^2 // can be shared by charge density/potential and wave functions. @@ -137,61 +155,53 @@ class PW_Basis //g=ig*G ?? HLX (05-26-06): need to check if this is ok! //tau is also defined in Cartesian coordintes unit lat0 - double *gg; // modulus (G^2) of G vectors - double *gg_global; // modulus (G^2) of G vectors + double *gg; // modulus (G^2) of G vectors [ngmc] + double *gg_global; // modulus (G^2) of G vectors [ngmc_g] //gg[ng]=ig[ng]*GGT*ig[ng]/(lat0*lat0)=g[ng]*g[ng] (/lat0*lat0) + // gg_global dimension: [cutgg_num_now] (save memory skill is used) - //================== - // void set_nggm() - //================== - int nggm; // =ngl(another dft code); - - // number of |G| shells (i.e., how many different |G|s) - double *ggs; // store the |G|^2 for each shell - int *ig2ngg; //=*igtong1 (another dft code) - // G -> correspondence shells of G - // end charge grids - - int gstart; // first nonzero g vector - - ComplexMatrix eigts1; // - ComplexMatrix eigts2; //the phases e^{-iG*tau_s} - ComplexMatrix eigts3; // - - int *ig1; // - int *ig2; // the indices of G components - int *ig3; // - - double *gg_global0; //LiuXh add 20180515 - int *cutgg_num_table; //LiuXh add 20180515 - int ggchg_time_global; //LiuXh add 20180515 - - - void gen_pw(ofstream &log, const UnitCell &Ucell_in, const kvect &Klist_in); - - void setup_structure_factor(void); // Calculate structur factors + // index of cartesian coordinates [ngmc] + int *ig1; // + int *ig2; // the indices of G components + int *ig3; // - void update_gvectors(ofstream &log, const UnitCell &Ucell_in); //LiuXh add 20180515 - private: - void setup_gg(void); +//=============================================== +// Part 6: |G|^2 [nggm] +//=============================================== +public: + // number of |G| shells (i.e., how many different |G|s) + int nggm; + double *ggs; // store |G|^2 for each shell + int *ig2ngg; // dimension [ngmc], index from ngmc to nggm + int gstart; // first nonzero g vector - void setup_FFT_dimension(void); // set up FFT dimensions +private: + void get_nggm(const int ngmc_local); -#ifdef __MPI - void divide_fft_grid(void); - void get_MPI_GVectors(void); - void columns_and_pw_distribution_2(void); -#else +//=============================================== +// Part 7: phase of e^{-iG*tau_s} +//=============================================== +public: + // phase of e^{-iG*tau_s} + ComplexMatrix eigts1; // dimension: [Ucell->nat, 2*this->ncx + 1] + ComplexMatrix eigts2; // dimension: [Ucell->nat, 2*this->ncy + 1] + ComplexMatrix eigts3; // dimension: [Ucell->nat, 2*this->ncz + 1] - void get_GVectors(void); -#endif - void get_nggm(const int ngmc_local); +//=============================================== +// Part 8: update_gvectors +// LiuXh add 20180515 +//=============================================== +public: + double *gg_global0; + int *cutgg_num_table; + int ggchg_time_global; + void update_gvectors(ofstream &log, const UnitCell &Ucell_in); }; #endif //PlaneWave class From 396a9ad1aa52f1966de32cb5af740bd0e40ad33a Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 17 Feb 2021 22:11:57 +0800 Subject: [PATCH 131/233] delete pseudopot_cell_us.h and .cpp because ultrasoft pseudopotential is not used --- ABACUS.develop/source/Makefile.Objects | 1 - ABACUS.develop/source/run_lcao.cpp | 1 - ABACUS.develop/source/run_pw.cpp | 1 - .../source/src_pw/pseudopot_cell_us.cpp | 610 ------------------ .../source/src_pw/pseudopot_cell_us.h | 75 --- 5 files changed, 688 deletions(-) delete mode 100644 ABACUS.develop/source/src_pw/pseudopot_cell_us.cpp delete mode 100644 ABACUS.develop/source/src_pw/pseudopot_cell_us.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index ce981518c0..9feced6e88 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -36,7 +36,6 @@ pseudo_nc.o \ pseudo_us.o \ pseudopot_cell_vl.o \ pseudopot_cell_vnl.o \ -pseudopot_cell_us.o\ atom_pseudo.o\ unitcell_pseudo.o\ threshold_elec.o\ diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index 0c98ae9134..83e7c93175 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -6,7 +6,6 @@ #include "src_pw/global.h" #include "input.h" #include "src_pw/algorithms.h" -#include "src_pw/pseudopot_cell_us.h" #include "src_io/optical.h" #include "src_io/cal_test.h" #include "src_lcao/dftu.h" //Quxin add for DFT+U on 20201029 diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp index d456e50ee2..56114ee303 100644 --- a/ABACUS.develop/source/run_pw.cpp +++ b/ABACUS.develop/source/run_pw.cpp @@ -2,7 +2,6 @@ #include "src_pw/global.h" #include "input.h" #include "src_pw/algorithms.h" -#include "src_pw/pseudopot_cell_us.h" #include "src_io/optical.h" #include "src_io/cal_test.h" #include "src_io/winput.h" diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_us.cpp b/ABACUS.develop/source/src_pw/pseudopot_cell_us.cpp deleted file mode 100644 index 61fb08a7c6..0000000000 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_us.cpp +++ /dev/null @@ -1,610 +0,0 @@ -#include "global.h" -#include "pseudopot_cell_us.h" -#include "tools.h" - -pseudopot_cell_us::pseudopot_cell_us(void) -{ -} - -pseudopot_cell_us::~pseudopot_cell_us(void) -{ -} - -/*************************************************************** -//void start_clock (char *); -//void stop_clock (char *); -//void reduce ( int , ::real *qq ); -void divide (int nqxq, int startq, int lastq); // ? -void setqf(::real , ::real , ::real r, int nqf,int , int ilast); // ? -// void invmat(int llx, matrix ylm, matrix mly, ::real dum); ? - -template -void copyarr(T *orig, T *dest, int len); - -pseudopot_cell_us::pseudopot_cell_us(void) -{ - - nlx = (lmaxx+1) * (lmaxx+1); - // maximum number of combined angular momentum - mx = 2*lqmax-1; // maximum magnetic angular momentum of Q - lpx = matrix(nlx, nlx); // (nlx,nlx); for each pair of combined momenta lm(1),lm(2): - // maximum combined angular momentum LM - lpl = realArray (mx,nlx,nlx); //(nlx,nlx,mx) list of combined angular momenta LM - - ap = realArray(nlx,nlx,lqmax*lqmax); //(lqmax*lqmax,nlx,nlx) - // Clebsch-Gordan coefficients for spherical harmonics -// qq = realArray(ntyp,nhm,nhm); //(:,:,:), the q functions in the solid -// qrad = realArray(nbeta*(nbeta+1),nbrx,nbrx); //(:,:,:,:), radial FT of Q functions - -// int nkbus; // as above, for US-PP only - -// realArray deeq; //(:,:,:,:), the integral of V_eff and Q_{nm} -// realArray becsum; //(:,:,:), \sum_i f(i) -// realArray beta; //(:,:,:), beta functions for CP (without struct.factor) //not sure! - - // from spin_orb - lspinorb = true; - domag = true; // if .TRUE. this is a spin-robit calculation - // from us - okvan = false;; // if .TRUE. at least one pseudo is Vanderbilt - rot_ylm = ComplexMatrix(2*lmaxx+1,2*lmaxx+1); - //(2*lmaxx+1,2*lmaxx+1), transform real - // spherical harmonics into complex ones -// fcoef = ComplexArray(ntyp,nhm,nhm,2,2); // (:,:,:,:,:), function needed to - // account for spinors. - - // from uspp -// dvan_so = ComplexArray(ntyp,nhm,nhm,4); // (:,:,:,:), D_{nm} -// qq_so = ComplexArray(ntyp,nhm,nhm,4); // (:,:,:,:), Q_{nm} -} - -pseudopot_cell_us::~pseudopot_cell_us(void) -{ -} - -//---------------------------------------------------------------------- -// from init_us_1.f90 -void pseudopot_cell_us::init_us_1(PW_Basis pw) -{ - //------------------------------------------------------------------ - // This routine performs the following tasks: - // a) For each non vanderbilt pseudopotential it computes the D and - // the betar in the same form of the Vanderbilt pseudopotential. - // b) It computes the indices indv which establish the correspondence - // nh <-> beta in the atom - // c) It computes the indices nhtol which establish the correspondence - // nh <-> angular momentum of the beta function - // d) It computes the indices nhtolm which establish the correspondence - // nh <-> combined (l,m) index for the beta function. - // e) It computes the coefficients c_{LM}^{nm} which relates the - // spherical harmonics in the Q expansion - // f) It computes the radial fourier transform of the Q function on - // all the g vectors - // g) It computes the q terms which define the S matrix. - // h) It fills the interpolation table for the beta functions - - // USE parameters, ONLY : lmaxx, nbrx, lqmax - // USE constants, ONLY : fpi - // USE atom, ONLY : r, rab - // USE ions_base, ONLY : ntyp => nsp - // USE cell_base, ONLY : omega, tpiba - // USE gvect, ONLY : g, gg - // USE pseud, ONLY : lloc, lmax - // USE lsda_mod, ONLY : nspin - // USE us, ONLY : okvan, nqxq, dq, nqx, tab, qrad - // USE uspp, ONLY : nhtol, nhtoj, nhtolm, dvan, qq, indv, ap, aainit, - // qq_so, dvan_so - // USE uspp_param, ONLY : lmaxq, dion, betar, qfunc, qfcoef, rinner, nbeta, - // kkbeta, nqf, nqlc, lll, jjj, lmaxkb, nh, tvanp, nhm - // USE spin_orb, ONLY : lspinorb, rot_ylm, fcoef - - // here a few local variables - int nt, ih, jh, nb, mb, nmb, l, m, ir, iq, is, startq, - lastq, ilast, ndm; - // various counters - - ::real *aux , *aux1 , *besr ; - realArray qtot ; // (:,:,:) - // various work space - - ::real prefr, pref, q, qi; - // the prefactor of the q functions - // the prefactor of the beta functions - // the modulus of g for each shell - // q-point grid for interpolation - - matrix ylmk0; - // the spherical harmonics - - ::real *vll; // (0:lmaxx), - ::real vqint, sqrt2, j; - // the denominator in KB case - // interpolated value - - int n1, m0, m1, n, li, mi, vi, vj, ijs, is1, is2, - lk, mk, vk, kh, lh; - realArray sph_ind; - complex <::real> coeff, qgm; //(1);? - realArray spinor; - ::real ji, jk; - - ::real x; - complex <::real> cx; - complex <::real> c0,c10; - c0 = complex <::real>(0,0); - c10 = complex <::real>(1,0); - - int ntyp,nbeta,kkbeta; - int nh; - ::real omega; - int *lll; - omega = pw.omega; - ntyp = pw.ntype; -// start_clock ("init_us_1"); - // Initialization of the variables - - // ndm = MAXVAL (kkbeta),(1:ntyp)); - ndm = 0; - for(n=0;n kkbeta)?ndm:kkbeta; - } - // allocate - aux = new real[ndm]; - aux1 = new real[ndm]; - besr = new real [ndm]; - qtot = realArray(nbrx, nbrx, ndm); - ylmk0 = matrix( lmaxq , lmaxq); - ap.zero_out(); // (:,:,:) = 0.0; - if (lmaxq > 0) - qrad.zero_out(); //(:,:,:,:)= 0.0; - prefr = fpi / omega; - if (lspinorb){ - // In the spin-orbit case we need the unitary matrix u which - // rotates the real spherical harmonics and yields the complex ones. - - sqrt2=1.0/sqrt(2.0); // dsqrt() - rot_ylm.zero_out(); //(0.0,0.0) - l=lmaxx; - rot_ylm(l+1,1)=c10; //(1.0,0.0); - for(n1=2;n1<2*l+1;n1+=2){ // do n1=2,2*l+1,2 - m=n1/2; - n=l+1-m; - rot_ylm(n,n1)=std::complex (pow(-1.0, m)*sqrt2,0.0); - rot_ylm(n,n1+1)=std::complex (0.0,pow(-(-1.0),m)*sqrt2); - n=l+1+m; - rot_ylm(n,n1)=std::complex (sqrt2,0.0); - rot_ylm(n,n1+1)=std::complex (0.0, sqrt2); - } // enddo - fcoef.zero_out(); - dvan_so.zero_out(); - qq_so.zero_out(); - }else{ - qq.zero_out(); // (:,:,:) = 0.d0 - dvan.zero_out(); - } // endif - // For each pseudopotential we initialize the indices nhtol, nhtolm, - // nhtoj, indv, and if the pseudopotential is of KB type we initialize - // the atomic D terms - for(nt=0;nt= fabs (lll [nb] - lll [mb]) ) && - (l <= lll [nb] + lll [mb]) && - (((int)(l + lll [nb] + lll [mb]) % 2) == 0) ){ - // mod (l + lll [nb] + lll [mb], 2) - for(ir=0;ir= - pw.atoms[nt].ppus.rinner [l + 1]){ - qtot.assign (nb, mb, ir, - pw.atoms[nt].ppus.qfunc.valueof (ir, nb, mb)); - }else{ - ilast = ir; - } // endif - } // enddo - if (pw.atoms[nt].ppus.rinner [l + 1] > 0.0) - setqf(pw.atoms[nt].ppus.qfcoef.valueof (1, l+1, nb, mb), - qtot.valueof(nb,mb,1), pw.atoms[nt].r[1], - pw.atoms[nt].ppus.nqf,l,ilast); - } // endif - } // enddo - } // enddo - // here we compute the spherical bessel function for each |g| - for(iq=startq;iq= fabs (lll [nb] - lll [mb]) ) && - (l <= lll [nb] + lll [mb]) && - (((int)(l + lll[nb] + lll[mb]) % 2) == 0) ){ - // mod (l + lll[nb] + lll[mb], 2) - for(ir=0;ir 1.0e-8) -//? goto 100; -#endif - ylmr2 (lmaxq * lmaxq, 1, pw.g, pw.gg, ylmk0); - for(nt=0;nt *r; //(:,:), - ::real *rr; //(:), - matrix ylm; //(:,:), - matrix mly; //(:,:) - // an array of random vectors: r(3,llx) - // the norm of r: rr(llx) - // the real spherical harmonics for array r: ylm(llx,llx) - // the inverse of ylm considered as a matrix: mly(llx,llx) - ::real dum; - int lli2; - lli2 = lli * lli; - - if (lli < 0) - cout << "\n error,aainit,lli not allowed," - << lli; - - if (lli2 > nlx) - cout << "\n error, aainit, nlx is too small," - << lli2; - - llx = (2*lli-1); - llx *= llx; - if (2*lli-1 > lqmax) - cout << "\n error, aainit, ap leading dimension is too small," - << llx; - - rr = new ::real[ llx ]; - r = new Vector3 <::real>[llx]; - ylm = matrix( llx, llx ); - mly = matrix( llx, llx ); - -// r.zero_out(); - ylm.zero_out(); - mly.zero_out(); - ap.zero_out(); //(:,:,:)= 0.d0 - - // - generate an array of random vectors (uniform deviate on unitary sphere) - gen_rndm_r(llx,r,rr); - - // - generate the real spherical harmonics for the array: ylm(ir,lm) - ylmr2(llx,llx,r,rr,ylm); - - //- store the inverse of ylm(ir,lm) in mly(lm,ir) - // invmat(llx, ylm, mly, dum); - mly = ylm.Inverse(); //? dum - - ::real x; - //- for each li,lj compute ap(l,li,lj) and the indices, lpx and lpl - for(li=0;li 1.e-3){ - lpx(li,lj) = lpx(li,lj) + 1; - if (lpx(li,lj) > mx) - cout << "\n error, aainit, mx dimension too small," - << lpx(li,lj); - lpl.assign(li,lj,lpx(li,lj),l); - } // end if - } // end do - } // end do - } // end do - - //deallocate(mly) - //deallocate(ylm) - //deallocate(rr) - //deallocate(r) - return; -} // end subroutine aainit - -// ----------------------------------------------------------------------- -// from uspp.f90 -void gen_rndm_r(int llx,Vector3 <::real> *r,::real *rr) // Vector3 *r ? -{ - //----------------------------------------------------------------------- - // - generate an array of random vectors (uniform deviate on unitary sphere) - // - // USE constants, ONLY: tpi - - // first the I/O variables - // int llx; // input: the dimension of r and rr - // matrix r(3,llx), // output: an array of random vectors - // real *rr(llx) // output: the norm of r - - // here the local variables - int ir; - ::real costheta, sintheta, phi; - - for(ir=0;ir -void copyarr(T *orig, T *dest, int len) -{ - for(int i=0;i - realArray beta; //(:,:,:), beta functions for CP (without struct.factor) //not sure! - - // from spin_orb -// bool lspinorb, -// domag; // if .TRUE. this is a spin-robit calculation - // from us -// ComplexMatrix rot_ylm; //(2*lmaxx+1,2*lmaxx+1), transform real - // spherical harmonics into complex ones -// ComplexArray fcoef; // (:,:,:,:,:), function needed to - // account for spinors. - - // from uspp -// ComplexArray dvan_so, // (:,:,:,:), D_{nm} -// qq_so; // (:,:,:,:), Q_{nm} - - //MODULE us - //. These parameters are needed with the US pseudopotentials - -// ::real dq = 0.01; // space between points in the pseudopotential tab. - // moved to constants.h - -// realArray qrad; //(:,:,:,:),radial FT of Q functions - - // END MODULE us - - pseudopot_cell_us(); - ~pseudopot_cell_us(); - /* - // member functions: - // void init_us_1(); // generate qrad(:,:,:,:) ? - void init_us_1(PW_Basis pw); // generate tab(:,:,:), indv, nhtol, nhtolm - void aainit(int); //Clebsch-Gordan coefficients "ap" - ::real compute_ap(int l,int li,int lj,int llx,matrix ylm,matrix mly); - void gen_rndm_r(int llx, Vector3 <::real> *r, ::real *rr); - // void gen_rndm_r(int llx,Vector3 *r,::real *rr); - void qvan2 (int, int ih, int jh, int nt, ::real *gg, - complex<::real> qgm, matrix ylmk0); - // void newd(); //computes the fourier transform of the Q function, qq - - void printus(ofstream &ofs); - - // template - // void copyarr(T *, T *, int len); - // void copyarr(::real *, ::real *, int ); - - */ -}; - -#endif // PSEUDOPOT_CELL_US_H From 16c2ebb58c6e554a9d98cad1f48cc5124a37edb7 Mon Sep 17 00:00:00 2001 From: mohan Date: Thu, 18 Feb 2021 09:56:37 +0800 Subject: [PATCH 132/233] move energy_dos and mulliken_charge to src_io --- .../source/{src_pw => src_io}/energy_dos.cpp | 39 +++++++++--------- .../{src_lcao => src_io}/mulliken_charge.cpp | 29 ++++++------- .../source/src_io/mulliken_charge.h | 40 ++++++++++++++++++ .../source/src_lcao/mulliken_charge.h | 41 ------------------- ABACUS.develop/source/src_pw/pw_basis.cpp | 1 + ABACUS.develop/source/src_pw/pw_basis.h | 5 ++- 6 files changed, 76 insertions(+), 79 deletions(-) rename ABACUS.develop/source/{src_pw => src_io}/energy_dos.cpp (96%) rename ABACUS.develop/source/{src_lcao => src_io}/mulliken_charge.cpp (95%) create mode 100644 ABACUS.develop/source/src_io/mulliken_charge.h delete mode 100644 ABACUS.develop/source/src_lcao/mulliken_charge.h diff --git a/ABACUS.develop/source/src_pw/energy_dos.cpp b/ABACUS.develop/source/src_io/energy_dos.cpp similarity index 96% rename from ABACUS.develop/source/src_pw/energy_dos.cpp rename to ABACUS.develop/source/src_io/energy_dos.cpp index 8ee0eb6d90..2e8246111c 100644 --- a/ABACUS.develop/source/src_pw/energy_dos.cpp +++ b/ABACUS.develop/source/src_io/energy_dos.cpp @@ -1,25 +1,24 @@ -#include "tools.h" -#include "global.h" -#include "energy.h" -#include "algorithms.h" -#include "../src_lcao/mulliken_charge.h" -#include "../src_lcao/LCAO_nnr.h" -#include "../src_lcao/LCAO_gen_fixedH.h" -#include "../src_global/sltk_atom_arrange.h"//qifeng-2019-01-21 -#include "../src_lcao/local_orbital_charge.h" -#include "../src_pw/global.h" -#include "../src_pw/wavefunc.h" -#include "../src_lcao/LCAO_matrix.h" -#include "../src_lcao/global_fp.h" -#include "../src_lcao/wfc_dm_2d.h" -#include "../src_global/lapack_connector.h" -#include "../src_global/scalapack_connector.h" -#include "../src_global/matrix.h" -#include "../src_global/complexmatrix.h" +#include "src_pw/tools.h" +#include "src_pw/global.h" +#include "src_pw/energy.h" +#include "src_pw/algorithms.h" +#include "src_io/mulliken_charge.h" +#include "src_lcao/LCAO_nnr.h" +#include "src_lcao/LCAO_gen_fixedH.h" +#include "src_global/sltk_atom_arrange.h"//qifeng-2019-01-21 +#include "src_lcao/local_orbital_charge.h" +#include "src_pw/global.h" +#include "src_pw/wavefunc.h" +#include "src_lcao/LCAO_matrix.h" +#include "src_lcao/global_fp.h" +#include "src_lcao/wfc_dm_2d.h" +#include "src_global/lapack_connector.h" +#include "src_global/scalapack_connector.h" +#include "src_global/matrix.h" +#include "src_global/complexmatrix.h" #include #include -#include -#include "../src_pw/tools.h" +#include void energy::perform_dos(void) diff --git a/ABACUS.develop/source/src_lcao/mulliken_charge.cpp b/ABACUS.develop/source/src_io/mulliken_charge.cpp similarity index 95% rename from ABACUS.develop/source/src_lcao/mulliken_charge.cpp rename to ABACUS.develop/source/src_io/mulliken_charge.cpp index e2feb43261..ea8e56ffda 100644 --- a/ABACUS.develop/source/src_lcao/mulliken_charge.cpp +++ b/ABACUS.develop/source/src_io/mulliken_charge.cpp @@ -10,24 +10,21 @@ ***********************************************************************/ #include "mulliken_charge.h" -#include "../src_lcao/local_orbital_charge.h" -#include "LCAO_gen_fixedH.h" -#include "../src_pw/global.h" -#include "../src_pw/wavefunc.h" -#include "global_fp.h" -#include "LCAO_matrix.h" -#include "../src_lcao/global_fp.h" -#include "../src_lcao/wfc_dm_2d.h" -#include "../src_global/lapack_connector.h" -#include "../src_global/scalapack_connector.h" -#include "../src_global/matrix.h" -#include "../src_global/complexmatrix.h" +#include "src_lcao/local_orbital_charge.h" +#include "src_lcao/LCAO_gen_fixedH.h" +#include "src_pw/global.h" +#include "src_pw/wavefunc.h" +#include "src_lcao/LCAO_matrix.h" +#include "src_lcao/global_fp.h" +#include "src_lcao/wfc_dm_2d.h" +#include "src_global/lapack_connector.h" +#include "src_global/scalapack_connector.h" +#include "src_global/matrix.h" +#include "src_global/complexmatrix.h" #include #include -#include "../src_global/sltk_atom_arrange.h" -#include "../src_lcao/LCAO_nnr.h" - - +#include "src_global/sltk_atom_arrange.h" +#include "src_lcao/LCAO_nnr.h" Mulliken_Charge::Mulliken_Charge() diff --git a/ABACUS.develop/source/src_io/mulliken_charge.h b/ABACUS.develop/source/src_io/mulliken_charge.h new file mode 100644 index 0000000000..8ba490d6b2 --- /dev/null +++ b/ABACUS.develop/source/src_io/mulliken_charge.h @@ -0,0 +1,40 @@ +#ifndef MULLIKEN_CHARGE_H +#define MULLIKEN_CHARGE_H + +#include "src_pw/tools.h" +#include "src_lcao/ORB_gen_tables.h" +#include "src_global/sltk_grid_driver.h" +#include "src_lcao/LCAO_matrix.h" +#include "src_lcao/global_fp.h" +#include "src_lcao/wfc_dm_2d.h" +#include "src_global/lapack_connector.h" +#include "src_global/scalapack_connector.h" +#include "src_global/matrix.h" +#include "src_global/complexmatrix.h" +#include "src_pdiag/pdiag_double.h" +#include "src_pdiag/GenELPA.h" +#include + +// by qifeng +class Mulliken_Charge +{ + public: + + Mulliken_Charge(); + ~Mulliken_Charge(); + + double** DecMulP ; + double** MecMulP ; + double*** ADecMulP ; + Wfc_Dm_2d M; + + complex *mug; + + void cal_mulliken(void); + + void stdout_mulliken(void); + + private: + +}; +#endif diff --git a/ABACUS.develop/source/src_lcao/mulliken_charge.h b/ABACUS.develop/source/src_lcao/mulliken_charge.h deleted file mode 100644 index 2406d918aa..0000000000 --- a/ABACUS.develop/source/src_lcao/mulliken_charge.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef MULLIKEN_CHARGE_H -#define MULLIKEN_CHARGE_H - -//#include "../src_pw/tools.h" -#include "../src_pw/tools.h" -#include "ORB_gen_tables.h" -#include "../src_global/sltk_grid_driver.h" -#include "LCAO_matrix.h" -#include "LCAO_matrix.h" -#include "../src_lcao/global_fp.h" -#include "../src_lcao/wfc_dm_2d.h" -#include "../src_global/lapack_connector.h" -#include "../src_global/scalapack_connector.h" -#include "../src_global/matrix.h" -#include "../src_global/complexmatrix.h" -#include -#include "../src_pdiag/pdiag_double.h" -#include "../src_pdiag/GenELPA.h" - -class Mulliken_Charge -{ - public: - - Mulliken_Charge(); - ~Mulliken_Charge(); - - double** DecMulP ; - double** MecMulP ; - double*** ADecMulP ; - Wfc_Dm_2d M; - - complex *mug; - - void cal_mulliken(void); - - void stdout_mulliken(void); - - private: - -}; -#endif diff --git a/ABACUS.develop/source/src_pw/pw_basis.cpp b/ABACUS.develop/source/src_pw/pw_basis.cpp index 412b968637..9ac5f866ee 100644 --- a/ABACUS.develop/source/src_pw/pw_basis.cpp +++ b/ABACUS.develop/source/src_pw/pw_basis.cpp @@ -151,6 +151,7 @@ void PW_Basis::gen_pw(ofstream &runlog, const UnitCell &Ucell_in, const kvect &K this->Klist = &Klist_in; //mohan modify 2008-3-25 + // setup for ggpsi, ggwfc, ggwfc2, ggchg this->setup_gg(); this->setup_FFT_dimension(); diff --git a/ABACUS.develop/source/src_pw/pw_basis.h b/ABACUS.develop/source/src_pw/pw_basis.h index e83cc74125..7d9236fbc5 100644 --- a/ABACUS.develop/source/src_pw/pw_basis.h +++ b/ABACUS.develop/source/src_pw/pw_basis.h @@ -5,11 +5,12 @@ #ifndef PLANEWAVE_H #define PLANEWAVE_H -#include "../src_global/complexmatrix.h" -#include "../src_global/vector3.h" #include "unitcell.h" #include "klist.h" +#include "../src_global/complexmatrix.h" +#include "../src_global/vector3.h" #include "../src_parallel/ft.h" + using namespace std; class PW_Basis From 926a7bbe5418ddba6958962ae30156463552d9a4 Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 19 Feb 2021 09:40:01 +0800 Subject: [PATCH 133/233] move a judgement between NLCOAL and NBANDS from driver.cpp to unitcell_pseudo.cpp --- ABACUS.develop/source/driver.cpp | 22 +---- ABACUS.develop/source/input.cpp | 94 +++++++------------ .../source/src_io/mulliken_charge.cpp | 9 -- ABACUS.develop/source/src_pw/klist.cpp | 27 +++--- .../source/src_pw/unitcell_pseudo.cpp | 76 +++++++++------ 5 files changed, 95 insertions(+), 133 deletions(-) diff --git a/ABACUS.develop/source/driver.cpp b/ABACUS.develop/source/driver.cpp index a9f198f57b..57c38f12b9 100644 --- a/ABACUS.develop/source/driver.cpp +++ b/ABACUS.develop/source/driver.cpp @@ -71,6 +71,7 @@ void Driver::reading(void) // (7) Setup the unitcell. ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running); + //ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running, NLOCAL, NBANDS); DONE(ofs_running, "SETUP UNITCELL"); // (8) symmetry analysize. @@ -84,26 +85,9 @@ void Driver::reading(void) kv.set( symm, global_kpoint_card, NSPIN, ucell.G, ucell.latvec ); DONE(ofs_running,"INIT K-POINTS"); - // (10) check the number of basis, the warning should be moved to - // other places -- mohan 2021-01-30 - // mohan add 2011-01-5 - if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") - { - if( NLOCAL < NBANDS ) - { - WARNING_QUIT("UnitCell_pseudo::cal_nwfc","NLOCAL < NBANDS"); - } - else - { - //OUT(ofs_running,"NLOCAL",NLOCAL); - OUT(ofs_running,"NBASE",NLOCAL); - OUT(ofs_running,"NBANDS",NBANDS); - } - } - //--------------------------------------------------------------------------------- - // (11) for LCAO basis, reading the orbitals and construct + // (10) for LCAO basis, reading the orbitals and construct // the interpolation tables. // this part should be moved somewher else -- mohan 2021-01-30 if(BASIS_TYPE=="lcao") //xiaohui add 2013-09-01 @@ -121,7 +105,7 @@ void Driver::reading(void) LM.divide_HS_in_frag(); } - // (12) print information + // (11) print information // mohan add 2021-01-30 Print_Info PI; PI.screen_output(); diff --git a/ABACUS.develop/source/input.cpp b/ABACUS.develop/source/input.cpp index 73ca181228..a3f1b3f239 100644 --- a/ABACUS.develop/source/input.cpp +++ b/ABACUS.develop/source/input.cpp @@ -3004,16 +3004,16 @@ void Input::Print(const string &fn)const OUTP(ofs,"ks_solver",KS_SOLVER,"cg; david; lapack; genelpa; hpseps; scalapack_gvx"); OUTP(ofs,"niter",niter,"#number of electron iterations"); //OUTP(ofs,"force",force,"calculate the force or not"); - OUTP(ofs,"force_set",force_set,"output the force_set or not"); + OUTP(ofs,"force_set",force_set,"output the force_set or not"); OUTP(ofs,"nstep",nstep,"number of ion iteration steps"); OUTP(ofs,"out_stru",out_stru,"output the structure files after each ion step"); OUTP(ofs,"force_thr",force_thr,"force threshold, unit: Ry/Bohr"); OUTP(ofs,"force_thr_ev",force_thr*13.6058/0.529177,"force threshold, unit: eV/Angstrom"); OUTP(ofs,"force_thr_ev2",force_thr_ev2,"force invalid threshold, unit: eV/Angstrom"); - OUTP(ofs,"stress_thr",stress_thr,"stress threshold"); //LiuXh add 20180515 - OUTP(ofs,"press1",press1,"target pressure, unit: KBar"); - OUTP(ofs,"press2",press2,"target pressure, unit: KBar"); - OUTP(ofs,"press3",press3,"target pressure, unit: KBar"); + OUTP(ofs,"stress_thr",stress_thr,"stress threshold"); //LiuXh add 20180515 + OUTP(ofs,"press1",press1,"target pressure, unit: KBar"); + OUTP(ofs,"press2",press2,"target pressure, unit: KBar"); + OUTP(ofs,"press3",press3,"target pressure, unit: KBar"); OUTP(ofs,"bfgs_w1",bfgs_w1,"wolfe condition 1 for bfgs"); OUTP(ofs,"bfgs_w2",bfgs_w2,"wolfe condition 2 for bfgs"); OUTP(ofs,"trust_radius_max", trust_radius_max,"maximal trust radius, unit: Bohr"); @@ -3024,8 +3024,9 @@ void Input::Print(const string &fn)const OUTP(ofs,"move_method",ion_dynamics,"bfgs; sd; cg; cg_bfgs;"); //pengfei add 2013-08-15 OUTP(ofs,"out_level",out_level,"ie(for electrons); i(for ions);"); OUTP(ofs,"out_dm",out_dm,">0 output density matrix"); - OUTP(ofs,"out_descriptor",out_descriptor,">0 compute descriptor for deepks");//caoyu added 2020-11-24, mohan added 2021-01-03 - OUTP(ofs,"lmax_descriptor",lmax_descriptor,">0 lmax used in descriptor for deepks");//caoyu added 2020-11-24, mohan added 2021-01-03 + + OUTP(ofs,"out_descriptor",out_descriptor,">0 compute descriptor for deepks");//caoyu add 2020-11-24, mohan added 2021-01-03 + OUTP(ofs,"lmax_descriptor",lmax_descriptor,">0 lmax used in descriptor for deepks");//caoyu add 2020-11-24, mohan added 2021-01-03 ofs << "\n#Parameters (4.LCAO)" << endl; //OUTP(ofs,"local_basis",local_basis,"0:PW; 1:LO in pw; 4:LCAO"); xiaohui modify 2013-09-01 @@ -3054,8 +3055,7 @@ void Input::Print(const string &fn)const OUTP(ofs,"sigma",degauss,"energy range for smearing"); ofs << "\n#Parameters (6.Charge Mixing)" << endl; -//2015-06-15 - OUTP(ofs,"mixing_type",mixing_mode,"plain; kerker; pulay; pulay-kerker"); + OUTP(ofs,"mixing_type",mixing_mode,"plain; kerker; pulay; pulay-kerker"); OUTP(ofs,"mixing_beta",mixing_beta,"mixing parameter: 0 means no new charge"); OUTP(ofs,"mixing_ndim",mixing_ndim,"mixing dimension in pulay"); OUTP(ofs,"mixing_gg0",mixing_gg0,"mixing parameter in kerker"); @@ -3064,21 +3064,15 @@ void Input::Print(const string &fn)const OUTP(ofs,"dos_emin_ev",dos_emin_ev,"minimal range for dos"); OUTP(ofs,"dos_emax_ev",dos_emax_ev,"maximal range for dos"); OUTP(ofs,"dos_edelta_ev",dos_edelta_ev,"delta energy for dos"); - OUTP(ofs,"dos_sigma",b_coef,"gauss b coefficeinet(default=0.07)"); - + OUTP(ofs,"dos_sigma",b_coef,"gauss b coefficeinet(default=0.07)"); + ofs << "\n#Parameters (8.Technique)" << endl; - OUTP(ofs,"gamma_only",gamma_only,"gamma only"); - //OUTP(ofs,"gamma_only_local",gamma_only_local,"gamma only in LCAO (important)"); + OUTP(ofs,"gamma_only",gamma_only,"gamma only"); OUTP(ofs,"diago_proc",DIAGO_PROC,"number of proc used to diago");//mohan add 2012-01-13 - //OUTP(ofs,"gamma_only_pw",gamma_only,"gamma only in pw"); OUTP(ofs,"npool",npool,"number of pools for k points, pw only"); OUTP(ofs,"mem_saver",mem_saver,"memory saver for many k points used"); OUTP(ofs,"printe",printe,"print band energy for selectively ionic steps"); -// ofs << "\n#Parameters (11.Divide&Conqure)" << endl; -// OUTP(ofs,"DC_nx",dc_nx,"division of atoms along x"); -// OUTP(ofs,"DC_ny",dc_ny,"division of atoms along y"); -// OUTP(ofs,"DC_nz",dc_nz,"division of atoms along z"); ofs << "\n#Parameters (9.SIAO)" << endl; OUTP(ofs,"selinv_npole",selinv_npole,"number of selected poles"); @@ -3090,36 +3084,27 @@ void Input::Print(const string &fn)const OUTP(ofs,"selinv_niter",selinv_niter,"max number of steps to update mu"); ofs << "\n#Parameters (10.Molecular dynamics)" << endl; -/* - OUTP(ofs,"md_dt",md_dt,"time step for molecular dynamics"); - OUTP(ofs,"md_restart",md_restart,"restart molecular dynamics from previous steps."); - OUTP(ofs,"md_thermostat",md_thermostat,"ionic temperature: various md_thermostat"); - OUTP(ofs,"md_temp0",md_temp0,"start temperature"); - OUTP(ofs,"md_tolv",md_tolv,"tolerence for velocity scaling"); - OUTP(ofs,"md_tstep",md_tstep,"the temperature will reduce every md_tstep"); - OUTP(ofs,"md_delt",md_delt,"the reduce amount of temperature"); -*/ -//added by zheng daye - OUTP(ofs,"md_mdtype",md_mdtype,"choose ensemble"); + //added by zheng daye + OUTP(ofs,"md_mdtype",md_mdtype,"choose ensemble"); //OUTP(ofs,"md_tauthermo",md_tauthermo,); - //OUTP(ofs,"md_taubaro",md_taubaro,); - OUTP(ofs,"md_dt",md_dt,"time step"); - OUTP(ofs,"md_nresn",md_nresn,"parameter during integrater"); - OUTP(ofs,"md_nyosh",md_nyosh,"parameter during integrater"); - OUTP(ofs,"md_qmass",md_qmass,"mass of thermostat"); - OUTP(ofs,"md_tfirst",md_tfirst,"temperature first"); - OUTP(ofs,"md_tlast",md_tlast,"temperature last"); - OUTP(ofs,"md_dumpmdfred",md_dumpmdfred,"The period to dump MD information for monitoring and restarting MD"); - OUTP(ofs,"md_mdoutpath",md_mdoutpath,"output path of md"); - OUTP(ofs,"md_domsd",md_domsd,"whether compute "); - OUTP(ofs,"md_domsdatom",md_domsdatom,"whether compute msd for each atom"); - OUTP(ofs,"md_rstmd",md_rstmd,"whether restart"); - //OUTP(ofs,"md_outputstressperiod",md_outputstressperiod,"period to output stress"); - OUTP(ofs,"md_fixtemperature",md_fixtemperature,"period to change temperature"); - OUTP(ofs,"md_ediff",md_ediff,"parameter for constraining total energy change"); - OUTP(ofs,"md_ediffg",md_ediffg,"parameter for constraining max force change"); - OUTP(ofs,"md_msdstarttime",md_msdstartTime,"choose which step that msd be calculated"); -//end of zheng daye's adding + //OUTP(ofs,"md_taubaro",md_taubaro,); + OUTP(ofs,"md_dt",md_dt,"time step"); + OUTP(ofs,"md_nresn",md_nresn,"parameter during integrater"); + OUTP(ofs,"md_nyosh",md_nyosh,"parameter during integrater"); + OUTP(ofs,"md_qmass",md_qmass,"mass of thermostat"); + OUTP(ofs,"md_tfirst",md_tfirst,"temperature first"); + OUTP(ofs,"md_tlast",md_tlast,"temperature last"); + OUTP(ofs,"md_dumpmdfred",md_dumpmdfred,"The period to dump MD information for monitoring and restarting MD"); + OUTP(ofs,"md_mdoutpath",md_mdoutpath,"output path of md"); + OUTP(ofs,"md_domsd",md_domsd,"whether compute "); + OUTP(ofs,"md_domsdatom",md_domsdatom,"whether compute msd for each atom"); + OUTP(ofs,"md_rstmd",md_rstmd,"whether restart"); + //OUTP(ofs,"md_outputstressperiod",md_outputstressperiod,"period to output stress"); + OUTP(ofs,"md_fixtemperature",md_fixtemperature,"period to change temperature"); + OUTP(ofs,"md_ediff",md_ediff,"parameter for constraining total energy change"); + OUTP(ofs,"md_ediffg",md_ediffg,"parameter for constraining max force change"); + OUTP(ofs,"md_msdstarttime",md_msdstartTime,"choose which step that msd be calculated"); + //end of zheng daye's adding ofs << "\n#Parameters (11.Efield)" << endl; OUTP(ofs,"efield",efield,"add electric field"); @@ -3144,23 +3129,10 @@ void Input::Print(const string &fn)const OUTP(ofs,"mlwf_flag",mlwf_flag,"turn MLWF on or off"); OUTP(ofs,"opt_epsilon2",opt_epsilon2,"calculate the dielectic function"); OUTP(ofs,"opt_nbands",opt_nbands,"number of bands for optical calculation"); -// OUTP(ofs,"berry_phase",berry_phase); -// OUTP(ofs,"lda_plus_u",lda_plus_u); -/* ofs << "\n#Parameters (15.vdw-D2)" << endl; //Peize Lin add 2014-04-05, update 2015-09-30 - OUTP(ofs,"vdwD2",vdwD2,"calculate vdw-D2 or not"); - OUTP(ofs,"vdwD2_scaling",vdwD2_scaling,"scaling of vdw-D2"); - OUTP(ofs,"vdwD2_d",vdwD2_d,"damping parameter"); - OUTP(ofs,"vdwD2_C6_file",vdwD2_C6_file,"filename of C6"); - OUTP(ofs,"vdwD2_C6_unit",vdwD2_C6_unit,"unit of C6, Jnm6/mol or eVA6"); - OUTP(ofs,"vdwD2_R0_file",vdwD2_R0_file,"filename of R0"); - OUTP(ofs,"vdwD2_R0_unit",vdwD2_R0_unit,"unit of R0, A or Bohr"); - OUTP(ofs,"vdwD2_model",vdwD2_model,"expression model of periodic structure, radius or period"); - OUTP(ofs,"vdwD2_radius",vdwD2_radius,"radius cutoff for periodic structure"); - OUTP(ofs,"vdwD2_radius_unit",vdwD2_radius_unit,"unit of radius cutoff for periodic structure"); - ofs << setw(20) << "vdwD2_period" << vdwD2_period.x << " " << vdwD2_period.y << " " << vdwD2_period.z<< " #periods of periodic structure" << endl; */ ofs << "\n#Parameters (14.VdW Correction)" << endl; + //jiyy add 2019-08-04 OUTP(ofs,"vdw_method",vdw_method,"the method of calculating vdw (none ; d2 ; d3_0 ; d3_bj"); OUTP(ofs,"vdw_s6",vdw_s6,"scale parameter of d2/d3_0/d3_bj"); diff --git a/ABACUS.develop/source/src_io/mulliken_charge.cpp b/ABACUS.develop/source/src_io/mulliken_charge.cpp index ea8e56ffda..a2b3fd15bf 100644 --- a/ABACUS.develop/source/src_io/mulliken_charge.cpp +++ b/ABACUS.develop/source/src_io/mulliken_charge.cpp @@ -174,22 +174,13 @@ void Mulliken_Charge::cal_mulliken(void) for(int ik=0;ik>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl; - ofs_running << " | |" << endl; - ofs_running << " | Setup K-points |" << endl; - ofs_running << " | We setup the k-points according to input parameters. |" << endl; - ofs_running << " | The reduced k-points are set according to symmetry operations. |" << endl; - ofs_running << " | We treat the spin as another set of k-points. |" << endl; - ofs_running << " | |" << endl; - ofs_running << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << endl; - ofs_running << "\n\n\n\n"; - - + ofs_running << "\n\n\n\n"; + ofs_running << " >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << endl; + ofs_running << " | |" << endl; + ofs_running << " | Setup K-points |" << endl; + ofs_running << " | We setup the k-points according to input parameters. |" << endl; + ofs_running << " | The reduced k-points are set according to symmetry operations. |" << endl; + ofs_running << " | We treat the spin as another set of k-points. |" << endl; + ofs_running << " | |" << endl; + ofs_running << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << endl; + ofs_running << "\n\n\n\n"; ofs_running << "\n SETUP K-POINTS" << endl; // (1) set nspin, read kpoints. this->nspin = nspin_in; OUT(ofs_running,"nspin",nspin); - if(this->nspin==4) this->nspin = 1;//zhengdy-soc + if(this->nspin==4) + { + this->nspin = 1;//zhengdy-soc + } bool read_succesfully = this->read_kpoints(k_file_name); #ifdef __MPI diff --git a/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp b/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp index ba49b71e0c..c57e140a3b 100644 --- a/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp +++ b/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp @@ -72,8 +72,6 @@ void UnitCell_pseudo::setup_cell( ofs_running << " <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << endl; ofs_running << "\n\n\n\n"; - - ofs_running << " READING UNITCELL INFORMATION" << endl; //======================== // call read_atom_species @@ -136,12 +134,13 @@ void UnitCell_pseudo::setup_cell( //========================================================== // Calculate recip. lattice vectors and dot products - // latvec has the unit of lat0, but G has the unit 2Pi/lat0 + // latvec have the unit of lat0, but G has the unit 2Pi/lat0 //========================================================== this->GT = latvec.Inverse(); this->G = GT.Transpose(); this->GGT = G * GT; this->invGGT = GGT.Inverse(); + //LiuXh add 20180515 this->GT0 = latvec.Inverse(); this->G0 = GT.Transpose(); @@ -275,10 +274,15 @@ void UnitCell_pseudo::setup_cell( xcf.which_dft(atoms[it].dft); } - //this->cal_nelec(); + // setup the total number of PAOs this->cal_natomwfc(); + + // setup NLOCAL this->cal_nwfc(); + + // setup NBANDS this->cal_nelec(); + this->cal_meshx(); // stringstream ss; @@ -1207,7 +1211,7 @@ void UnitCell_pseudo::read_pseudopot(const string &pp_dir) #include "occupy.h" void UnitCell_pseudo::cal_nelec(void) { - if(test_pseudo_cell) TITLE("UnitCell_pseudo","cal_nelec"); + TITLE("UnitCell_pseudo","cal_nelec"); //======================================================= // calculate the total number of electrons in the system // if nelec <>0; use input number (setup.f90) @@ -1230,7 +1234,7 @@ void UnitCell_pseudo::cal_nelec(void) } } -// OUT(ofs_running,"Total nelec",nelec); + //OUT(ofs_running,"Total nelec",nelec); //======================================= // calculate number of bands (setup.f90) @@ -1245,12 +1249,12 @@ void UnitCell_pseudo::cal_nelec(void) OUT(ofs_running,"occupied bands",occupied_bands); // mohan add 2010-09-04 - //cout << "nbands(ucell) = " < num. of occupied bands"); } } @@ -1269,10 +1273,6 @@ void UnitCell_pseudo::cal_nelec(void) int nbands4 = 1.2 * nelec; NBANDS = max(nbands3, nbands4); } - if (NBANDS > NLOCAL) - { - NBANDS = NLOCAL; - } AUTO_SET("NBANDS",NBANDS); } //else if ( CALCULATION=="scf" || CALCULATION=="md" || CALCULATION=="relax") //pengfei 2014-10-13 @@ -1288,12 +1288,23 @@ void UnitCell_pseudo::cal_nelec(void) { WARNING_QUIT("unitcell","Too few spin down bands!"); } - if (NBANDS > NLOCAL) - { - WARNING_QUIT("unitcell","Too many bands! NBANDS > NBASIS."); - } } + // mohan update 2021-02-19 + // mohan add 2011-01-5 + if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") + { + if( NBANDS > NLOCAL ) + { + WARNING_QUIT("UnitCell_pseudo::cal_nwfc","NLOCAL < NBANDS"); + } + else + { + OUT(ofs_running,"NLOCAL",NLOCAL); + OUT(ofs_running,"NBANDS",NBANDS); + } + } + OUT(ofs_running,"NBANDS",NBANDS); return; } @@ -1304,9 +1315,9 @@ void UnitCell_pseudo::cal_nelec(void) // atoms[].stapos_wf // NBANDS //=========================================== -void UnitCell_pseudo::cal_nwfc() +void UnitCell_pseudo::cal_nwfc(void) { - if(test_pseudo_cell) TITLE("UnitCell_pseudo","cal_nwfc"); + TITLE("UnitCell_pseudo","cal_nwfc"); assert(ntype>0); assert(nat>0); @@ -1329,8 +1340,9 @@ void UnitCell_pseudo::cal_nwfc() this->nwmax = std::max( atoms[it].nw, nwmax ); } assert(namax>0); -// OUT(ofs_running,"max input atom number",namax); -// OUT(ofs_running,"max wave function number",nwmax); +// for tests +// OUT(ofs_running,"max input atom number",namax); +// OUT(ofs_running,"max wave function number",nwmax); //=========================== // (3) set nwfc and stapos_wf @@ -1340,16 +1352,22 @@ void UnitCell_pseudo::cal_nwfc() { atoms[it].stapos_wf = NLOCAL; const int nlocal_it = atoms[it].nw * atoms[it].na; - if(NSPIN!=4) NLOCAL += nlocal_it; - else NLOCAL += nlocal_it * 2;//zhengdy-soc -// stringstream ss1; -// ss1 << "number of local orbitals for species " << it; -// if(LOCAL_BASIS)OUT(ofs_running,ss1.str(),nlocal_it); + if(NSPIN!=4) + { + NLOCAL += nlocal_it; + } + else + { + NLOCAL += nlocal_it * 2;//zhengdy-soc + } + +// for tests +// OUT(ofs_running,ss1.str(),nlocal_it); // OUT(ofs_running,"start position of local orbitals",atoms[it].stapos_wf); } //OUT(ofs_running,"NLOCAL",NLOCAL); - ofs_running << " " << setw(40) << "NLOCAL" << " = " << NLOCAL <natomwfc = 0; for (int it = 0;it < ntype;it++) { From dffb252c7e34834739f3a8e32d7ec6061ef68af8 Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 19 Feb 2021 17:40:39 +0800 Subject: [PATCH 134/233] delete algorithms.h in src_pw --- ABACUS.develop/source/input.cpp | 14 +- ABACUS.develop/source/run_lcao.cpp | 1 - ABACUS.develop/source/run_pw.cpp | 3 +- ABACUS.develop/source/src_io/chi0_hilbert.cpp | 1 - .../source/src_io/chi0_standard.cpp | 1 - ABACUS.develop/source/src_io/energy_dos.cpp | 2 +- .../source/src_io/epsilon0_pwscf.cpp | 1 - .../source/src_io/epsilon0_vasp.cpp | 1 - ABACUS.develop/source/src_lcao/LCAO_diago.cpp | 1 - .../source/src_lcao/LCAO_evolve.cpp | 1 - ABACUS.develop/source/src_lcao/ORB_control.h | 1 - .../source/src_lcao/local_orbital_wfc.cpp | 1 - .../source/src_lcao/stress_lcao.cpp | 142 +++++++++--------- ABACUS.develop/source/src_pw/1 | 136 ----------------- ABACUS.develop/source/src_pw/algorithms.h | 13 -- ABACUS.develop/source/src_pw/electrons.cpp | 2 - ABACUS.develop/source/src_pw/energy.cpp | 3 +- ABACUS.develop/source/src_pw/hamilt.cpp | 3 +- ABACUS.develop/source/src_pw/hamilt_pw.cpp | 2 +- ABACUS.develop/source/src_pw/ions.cpp | 2 - ABACUS.develop/source/src_pw/myfunc.h | 19 --- ABACUS.develop/source/src_pw/occupy.cpp | 1 - ABACUS.develop/source/src_pw/sto_elec.cpp | 1 - ABACUS.develop/source/src_pw/stress.cpp | 1 + ABACUS.develop/source/src_pw/wavefunc.cpp | 2 - 25 files changed, 87 insertions(+), 268 deletions(-) delete mode 100644 ABACUS.develop/source/src_pw/1 delete mode 100644 ABACUS.develop/source/src_pw/algorithms.h diff --git a/ABACUS.develop/source/input.cpp b/ABACUS.develop/source/input.cpp index a3f1b3f239..aa39c038c9 100644 --- a/ABACUS.develop/source/input.cpp +++ b/ABACUS.develop/source/input.cpp @@ -451,14 +451,14 @@ void Input::Default(void) ocp_set = "none"; // for(int i=0; i<10000; i++) // { - // ocp_kb[i] = 0.0; + // ocp_kb[i] = 0.0; // } - - cell_factor = 1.2; //LiuXh add 20180619 - - newDM=0; // Shen Yu add 2019/5/9 - mulliken=0;// qi feng add 2019/9/10 - + + cell_factor = 1.2; //LiuXh add 20180619 + + newDM=0; // Shen Yu add 2019/5/9 + mulliken=0;// qi feng add 2019/9/10 + //---------------------------------------------------------- //Peize Lin add 2020-04-04 // restart //---------------------------------------------------------- diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index 83e7c93175..a381a18622 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -5,7 +5,6 @@ #include "run_lcao.h" #include "src_pw/global.h" #include "input.h" -#include "src_pw/algorithms.h" #include "src_io/optical.h" #include "src_io/cal_test.h" #include "src_lcao/dftu.h" //Quxin add for DFT+U on 20201029 diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp index 56114ee303..fea5a4d949 100644 --- a/ABACUS.develop/source/run_pw.cpp +++ b/ABACUS.develop/source/run_pw.cpp @@ -1,10 +1,11 @@ #include "run_pw.h" #include "src_pw/global.h" #include "input.h" -#include "src_pw/algorithms.h" #include "src_io/optical.h" #include "src_io/cal_test.h" #include "src_io/winput.h" +#include "src_io/numerical_basis.h" +#include "src_io/numerical_descriptor.h" Run_pw::Run_pw(){} Run_pw::~Run_pw(){} diff --git a/ABACUS.develop/source/src_io/chi0_hilbert.cpp b/ABACUS.develop/source/src_io/chi0_hilbert.cpp index 8608f515e9..e9f183d295 100644 --- a/ABACUS.develop/source/src_io/chi0_hilbert.cpp +++ b/ABACUS.develop/source/src_io/chi0_hilbert.cpp @@ -9,7 +9,6 @@ //------------------------------------------------------------------------------- #include "src_pw/global.h" #include "chi0_hilbert.h" -#include "src_pw/algorithms.h" #include "src_pw/hamilt_pw.h" #include "src_pw/wavefunc_in_pw.h" #include "../src_io/optical.h" diff --git a/ABACUS.develop/source/src_io/chi0_standard.cpp b/ABACUS.develop/source/src_io/chi0_standard.cpp index db72ad591b..ec0eb6457e 100644 --- a/ABACUS.develop/source/src_io/chi0_standard.cpp +++ b/ABACUS.develop/source/src_io/chi0_standard.cpp @@ -9,7 +9,6 @@ #include "src_pw/global.h" #include "chi0_standard.h" -#include "src_pw/algorithms.h" #include "src_pw/hamilt_pw.h" #include "src_pw/wavefunc_in_pw.h" #include "src_io/optical.h" diff --git a/ABACUS.develop/source/src_io/energy_dos.cpp b/ABACUS.develop/source/src_io/energy_dos.cpp index 2e8246111c..3579108f46 100644 --- a/ABACUS.develop/source/src_io/energy_dos.cpp +++ b/ABACUS.develop/source/src_io/energy_dos.cpp @@ -1,7 +1,6 @@ #include "src_pw/tools.h" #include "src_pw/global.h" #include "src_pw/energy.h" -#include "src_pw/algorithms.h" #include "src_io/mulliken_charge.h" #include "src_lcao/LCAO_nnr.h" #include "src_lcao/LCAO_gen_fixedH.h" @@ -16,6 +15,7 @@ #include "src_global/scalapack_connector.h" #include "src_global/matrix.h" #include "src_global/complexmatrix.h" +#include "src_io/dos.h" #include #include #include diff --git a/ABACUS.develop/source/src_io/epsilon0_pwscf.cpp b/ABACUS.develop/source/src_io/epsilon0_pwscf.cpp index 3293d27439..8d65f715dd 100644 --- a/ABACUS.develop/source/src_io/epsilon0_pwscf.cpp +++ b/ABACUS.develop/source/src_io/epsilon0_pwscf.cpp @@ -7,7 +7,6 @@ //response theory . //------------------------------------------------------------------------------- #include "src_pw/global.h" -#include "src_pw/algorithms.h" #include "src_pw/hamilt_pw.h" #include "../src_pw/wavefunc_in_pw.h" #include "src_io/optical.h" diff --git a/ABACUS.develop/source/src_io/epsilon0_vasp.cpp b/ABACUS.develop/source/src_io/epsilon0_vasp.cpp index 4d31cd86c5..9fdd5e8786 100644 --- a/ABACUS.develop/source/src_io/epsilon0_vasp.cpp +++ b/ABACUS.develop/source/src_io/epsilon0_vasp.cpp @@ -7,7 +7,6 @@ //response theory . //------------------------------------------------------------------------------- #include "src_pw/global.h" -#include "src_pw/algorithms.h" #include "src_pw/hamilt_pw.h" #include "../src_pw/wavefunc_in_pw.h" #include "./src_io/optical.h" diff --git a/ABACUS.develop/source/src_lcao/LCAO_diago.cpp b/ABACUS.develop/source/src_lcao/LCAO_diago.cpp index 768b631036..f360707ac9 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_diago.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_diago.cpp @@ -1,5 +1,4 @@ #include "LCAO_diago.h" -#include "../src_pw/algorithms.h" #include "../src_pw/global.h" #include "../src_pdiag/pdiag_double.h" #include "../src_io/hs_matrix.h" diff --git a/ABACUS.develop/source/src_lcao/LCAO_evolve.cpp b/ABACUS.develop/source/src_lcao/LCAO_evolve.cpp index b533f6667e..13fb0b14aa 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_evolve.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_evolve.cpp @@ -1,5 +1,4 @@ #include "LCAO_evolve.h" -#include "../src_pw/algorithms.h" #include "../src_pw/global.h" #include "../src_pdiag/pdiag_double.h" #include "../src_io/hs_matrix.h" diff --git a/ABACUS.develop/source/src_lcao/ORB_control.h b/ABACUS.develop/source/src_lcao/ORB_control.h index 089960f2be..c69397bc1d 100644 --- a/ABACUS.develop/source/src_lcao/ORB_control.h +++ b/ABACUS.develop/source/src_lcao/ORB_control.h @@ -6,7 +6,6 @@ #define ORB_CONTROL_H #include "../src_pw/tools.h" -#include "../src_pw/algorithms.h" #include "ORB_gen_tables.h" #include "../src_pdiag/pdiag_double.h" diff --git a/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp b/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp index 8e03b98d4a..5cb397f1d8 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp @@ -1,6 +1,5 @@ #include "local_orbital_wfc.h" #include "../src_pw/global.h" -#include "../src_pw/algorithms.h" #include "../src_io/wf_local.h" #include "global_fp.h" // mohan add 2021-01-30 diff --git a/ABACUS.develop/source/src_lcao/stress_lcao.cpp b/ABACUS.develop/source/src_lcao/stress_lcao.cpp index b66ba76a17..c8f4d46bd1 100644 --- a/ABACUS.develop/source/src_lcao/stress_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/stress_lcao.cpp @@ -2,6 +2,7 @@ #include "../src_pw/global.h" #include "../src_pw/xc_functional.h" #include "../src_pw/xc_gga_pw.h" +#include "src_pw/myfunc.h" double Stress_LCAO::stress_invalid_threshold_ev = 0.00; @@ -754,7 +755,7 @@ void Stress_LCAO::cal_stress_cc(void) return; } -void Stress_LCAO::cal_stress_har() +void Stress_LCAO::cal_stress_har(void) { double shart,g2; const double eps=1e-8; @@ -776,73 +777,72 @@ void Stress_LCAO::cal_stress_har() //============================= pw.FFT_chg.FFT3D(Porter, -1); - complex *psic = new complex [pw.nrxx]; - double *psic0 = new double[pw.nrxx]; - ZEROS( psic0, pw.nrxx); - for(int is=0; is(psic0[ir], 0.0); - } - } - - pw.FFT_chg.FFT3D(psic, -1) ; - + complex *psic = new complex [pw.nrxx]; + double *psic0 = new double[pw.nrxx]; + ZEROS( psic0, pw.nrxx); + for(int is=0; is(psic0[ir], 0.0); + } + } - double charge; - if (pw.gstart == 1) - { - charge = ucell.omega * Porter[pw.ig2fftc[0]].real(); - } + pw.FFT_chg.FFT3D(psic, -1) ; - complex *vh_g = new complex[pw.ngmc]; - ZEROS(vh_g, pw.ngmc); + double charge; + if (pw.gstart == 1) + { + charge = ucell.omega * Porter[pw.ig2fftc[0]].real(); + } - double g[3]; -//test - // int i=pw.gstart; - // cout<< "gstart " < *vh_g = new complex[pw.ngmc]; + ZEROS(vh_g, pw.ngmc); - ehart += ( conj( Porter[j] ) * Porter[j] ).real() * fac; -// vh_g[ig] = fac * Porter[j]; - shart= ( conj( Porter[j] ) * Porter[j] ).real()/(ucell.tpiba2 * pw.gg [ig]); - g[0]=pw.gcar[ig].x; - g[1]=pw.gcar[ig].y; - g[2]=pw.gcar[ig].z; - //test + double g[3]; + //test + // int i=pw.gstart; + // cout<< "gstart " < #include #include #include "../src_pw/tools.h" #include "../src_lcao/dftu.h" //Quxin adds for DFT+U on 20201029 +#include "src_pw/myfunc.h" + int energy::mxr = 50; energy::energy() diff --git a/ABACUS.develop/source/src_pw/hamilt.cpp b/ABACUS.develop/source/src_pw/hamilt.cpp index 15101cf7e3..c276da9b06 100644 --- a/ABACUS.develop/source/src_pw/hamilt.cpp +++ b/ABACUS.develop/source/src_pw/hamilt.cpp @@ -1,6 +1,7 @@ #include "global.h" #include "hamilt.h" -#include "algorithms.h" +#include "diago_cg.h" +#include "diago_david.h" Hamilt::Hamilt() {} Hamilt::~Hamilt() diff --git a/ABACUS.develop/source/src_pw/hamilt_pw.cpp b/ABACUS.develop/source/src_pw/hamilt_pw.cpp index 7efe9e0f4c..fa9798c2fc 100644 --- a/ABACUS.develop/source/src_pw/hamilt_pw.cpp +++ b/ABACUS.develop/source/src_pw/hamilt_pw.cpp @@ -1,10 +1,10 @@ /* hermit.cpp file */ #include "tools.h" #include "global.h" -#include "algorithms.h" #include "hamilt_pw.h" #include "src_global/blas_connector.h" #include "../src_io/optical.h" // only get judgement to calculate optical matrix or not. +#include "src_pw/myfunc.h" int Hamilt_PW::moved = 0; diff --git a/ABACUS.develop/source/src_pw/ions.cpp b/ABACUS.develop/source/src_pw/ions.cpp index e16124b4fb..08f1c5eb34 100644 --- a/ABACUS.develop/source/src_pw/ions.cpp +++ b/ABACUS.develop/source/src_pw/ions.cpp @@ -2,11 +2,9 @@ #include "ions.h" #include "forces.h" #include "stress.h" -#include "algorithms.h" #include "../src_pw/global.h" // use chr. #include "vdwd2.h" #include "vdwd3.h" - #include "../src_pw/pw_complement.h" #include "../src_pw/pw_basis.h" #include "../src_ions/variable_cell.h" // mohan add 2021-02-01 diff --git a/ABACUS.develop/source/src_pw/myfunc.h b/ABACUS.develop/source/src_pw/myfunc.h index 6ac87174bd..f29665c5b4 100644 --- a/ABACUS.develop/source/src_pw/myfunc.h +++ b/ABACUS.develop/source/src_pw/myfunc.h @@ -42,25 +42,6 @@ void grad_dot(int ncx, int ncy, int ncz, int ncxyz, Vector3 < double> *a, int ng Vector3 < double> *g, int *ig2fftc, double lat0, double *da); -// myfunc4.cpp -/* -void wsinit(double *rws0, Vector3 < double> *rws, int nrwsx, int nrws, - Matrix3 atw); -void ccalbec(int nkb, - int npwx, - int npw, - int nbnd, - ComplexMatrix &bec, - const ComplexMatrix &vkb, - const ComplexMatrix &psi); - -void pw_gemm(char sum_over_nodes, int na, int nb, int n, ComplexMatrix a, - int lda, ComplexMatrix b, int ldb, ComplexMatrix c, int ldc); - -void interpolate(double *v, double *vs, int iflag); -void cinterpolate(complex < double> *v, complex < double> *vs, int iflag); -*/ - // myfunc5.cpp (from LPACK) // compute y = alpha * y where alpha is a scalar and y is an n-vector void dscal(const int n, const double &alpha, double *y, const int incy); diff --git a/ABACUS.develop/source/src_pw/occupy.cpp b/ABACUS.develop/source/src_pw/occupy.cpp index 8e25bb2fa0..5cdf7f88e1 100644 --- a/ABACUS.develop/source/src_pw/occupy.cpp +++ b/ABACUS.develop/source/src_pw/occupy.cpp @@ -1,6 +1,5 @@ #include "global.h" #include "occupy.h" -#include "algorithms.h" #include "src_global/mymath.h" Occupy::Occupy(){} diff --git a/ABACUS.develop/source/src_pw/sto_elec.cpp b/ABACUS.develop/source/src_pw/sto_elec.cpp index 2d6499caa1..51f99a0c82 100644 --- a/ABACUS.develop/source/src_pw/sto_elec.cpp +++ b/ABACUS.develop/source/src_pw/sto_elec.cpp @@ -1,7 +1,6 @@ #include "tools.h" #include "global.h" #include "sto_elec.h" -#include "algorithms.h" #include "occupy.h" #include "symmetry_rho.h" #include "../src_io/wf_io.h" diff --git a/ABACUS.develop/source/src_pw/stress.cpp b/ABACUS.develop/source/src_pw/stress.cpp index fc1458d0f9..7c74ebeac6 100644 --- a/ABACUS.develop/source/src_pw/stress.cpp +++ b/ABACUS.develop/source/src_pw/stress.cpp @@ -4,6 +4,7 @@ #include "xc_functional.h" #include "xc_gga_pw.h" #include "efield.h" +#include "myfunc.h" void Stress::cal_stress() { diff --git a/ABACUS.develop/source/src_pw/wavefunc.cpp b/ABACUS.develop/source/src_pw/wavefunc.cpp index 2f95bdf936..162ad9d6fd 100644 --- a/ABACUS.develop/source/src_pw/wavefunc.cpp +++ b/ABACUS.develop/source/src_pw/wavefunc.cpp @@ -1,8 +1,6 @@ #include "wavefunc.h" #include "global.h" -#include "algorithms.h" #include "../src_pw/wavefunc_in_pw.h" -//xiaohui add 2013 -08-01 #include "src_io/winput.h" #include "src_io/chi0_hilbert.h" From fe791f12e370b8f4a2422acf3b6cdf05ac277101 Mon Sep 17 00:00:00 2001 From: mohan Date: Sat, 20 Feb 2021 09:07:53 +0800 Subject: [PATCH 135/233] move reading orbitals, generations of plane wave basis, parallel_grid::init from driver.cpp into run_pw.cpp and run_lcao.cpp --- ABACUS.develop/source/README | 5 +- ABACUS.develop/source/driver.cpp | 50 +----------------- ABACUS.develop/source/run_lcao.cpp | 43 +++++++++++++++- ABACUS.develop/source/run_pw.cpp | 22 ++++++++ ABACUS.develop/source/src_io/print_info.cpp | 56 +++++++-------------- ABACUS.develop/source/src_io/print_info.h | 3 +- 6 files changed, 87 insertions(+), 92 deletions(-) diff --git a/ABACUS.develop/source/README b/ABACUS.develop/source/README index 4c52573e49..f61de08fff 100644 --- a/ABACUS.develop/source/README +++ b/ABACUS.develop/source/README @@ -20,10 +20,7 @@ NEED TO DO: Ask Xiaohui: we need to remove DQ and NQX in global_variable.h, but the NQX is computed in ./src_pw/pseudopot_cell_vnl.cpp -Ask Peize: explain exx_lip.h - -Ask Yuyang Ji: what's 'ocp' in input.cpp, what are the options -about 'ocp' in input_conv.cpp? +Ask Peize: exx_lip.h and related Exx codes QUESTION: diff --git a/ABACUS.develop/source/driver.cpp b/ABACUS.develop/source/driver.cpp index 57c38f12b9..134c1365f8 100644 --- a/ABACUS.develop/source/driver.cpp +++ b/ABACUS.develop/source/driver.cpp @@ -85,55 +85,10 @@ void Driver::reading(void) kv.set( symm, global_kpoint_card, NSPIN, ucell.G, ucell.latvec ); DONE(ofs_running,"INIT K-POINTS"); -//--------------------------------------------------------------------------------- - - // (10) for LCAO basis, reading the orbitals and construct - // the interpolation tables. - // this part should be moved somewher else -- mohan 2021-01-30 - if(BASIS_TYPE=="lcao") //xiaohui add 2013-09-01 - { - // read orbital information. - // init overlap matrix table, which is 'S Table' - // init kinetical matrix element table, which is 'T Table' - // init non-local pseudopotential matrix element table, which is 'NL Table' - hm.orb_con.set_orb_tables(); - - // xiaohui add 2015-09-06 - // (1) divide the H and S matrix into each CPU, count the dimensions - // (2) set the 'trace' between local H/S and global H/S - // (2) allocate the needed H and S memory - LM.divide_HS_in_frag(); - } - - // (11) print information + // (10) print information // mohan add 2021-01-30 Print_Info PI; - PI.screen_output(); - -//--------------------------------------------------------------------------------- - - - // (12) Initalize the plane wave basis set - pw.gen_pw(ofs_running, ucell, kv); - DONE(ofs_running,"INIT PLANEWAVE"); - cout << " UNIFORM GRID DIM : " << pw.nx <<" * " << pw.ny <<" * "<< pw.nz << endl; - cout << " UNIFORM GRID DIM(BIG): " << pw.nbx <<" * " << pw.nby <<" * "<< pw.nbz << endl; - - - // (13) mohan add 2010-10-10, just to test the symmetry of a variety - // of systems. - if(CALCULATION == "test") - { - Cal_Test::test_memory(); - QUIT(); - } - - // (14) mohan add 2010-09-13 - // initialize the real-space uniform grid for FFT and parallel - // distribution of plane waves - Pgrid.init(pw.ncx, pw.ncy, pw.ncz, pw.nczp, - pw.nrxx, pw.nbz, pw.bz); // mohan add 2010-07-22, update 2011-05-04 - + PI.setup_parameters(); timer::tick("Driver","reading",'A'); return; @@ -147,7 +102,6 @@ void Driver::atomic_world(void) TITLE("Driver","atomic_world"); timer::tick("Driver","atomic_world",'A'); - //-------------------------------------------------- // choose basis sets: // pw: plane wave basis set diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index a381a18622..15806a73d9 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -20,7 +20,48 @@ void Run_lcao::lcao_line(void) { TITLE("Run_lcao","lcao_line"); timer::tick("Run_lcao","lcao_line",'B'); - + + // for LCAO basis, reading the orbitals and construct + // the interpolation tables. + // this part should be moved somewher else -- mohan 2021-01-30 + if(BASIS_TYPE=="lcao") //xiaohui add 2013-09-01 + { + // read orbital information. + // init overlap matrix table, which is 'S Table' + // init kinetical matrix element table, which is 'T Table' + // init non-local pseudopotential matrix element table, which is 'NL Table' + hm.orb_con.set_orb_tables(); + + // xiaohui add 2015-09-06 + // (1) divide the H and S matrix into each CPU, count the dimensions + // (2) set the 'trace' between local H/S and global H/S + // (2) allocate the needed H and S memory + LM.divide_HS_in_frag(); + } + + + // Initalize the plane wave basis set + pw.gen_pw(ofs_running, ucell, kv); + DONE(ofs_running,"INIT PLANEWAVE"); + cout << " UNIFORM GRID DIM : " << pw.nx <<" * " << pw.ny <<" * "<< pw.nz << endl; + cout << " UNIFORM GRID DIM(BIG): " << pw.nbx <<" * " << pw.nby <<" * "<< pw.nbz << endl; + + + // mohan add 2010-10-10, just to test the symmetry of a variety + // of systems. + if(CALCULATION == "test") + { + Cal_Test::test_memory(); + QUIT(); + } + + // mohan add 2010-09-13 + // initialize the real-space uniform grid for FFT and parallel + // distribution of plane waves + Pgrid.init(pw.ncx, pw.ncy, pw.ncz, pw.nczp, + pw.nrxx, pw.nbz, pw.bz); // mohan add 2010-07-22, update 2011-05-04 + + // (1) Inititlize the charge density. CHR.init(); DONE(ofs_running,"INIT CHARGE"); diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp index fea5a4d949..b393fec1d0 100644 --- a/ABACUS.develop/source/run_pw.cpp +++ b/ABACUS.develop/source/run_pw.cpp @@ -15,6 +15,28 @@ void Run_pw::plane_wave_line(void) TITLE("Run_pw","plane_wave_line"); timer::tick("Run_pw","plane_wave_line",'B'); + // Initalize the plane wave basis set + pw.gen_pw(ofs_running, ucell, kv); + DONE(ofs_running,"INIT PLANEWAVE"); + cout << " UNIFORM GRID DIM : " << pw.nx <<" * " << pw.ny <<" * "<< pw.nz << endl; + cout << " UNIFORM GRID DIM(BIG): " << pw.nbx <<" * " << pw.nby <<" * "<< pw.nbz << endl; + + + // mohan add 2010-10-10, just to test the symmetry of a variety + // of systems. + if(CALCULATION == "test") + { + Cal_Test::test_memory(); + QUIT(); + } + + // mohan add 2010-09-13 + // initialize the real-space uniform grid for FFT and parallel + // distribution of plane waves + Pgrid.init(pw.ncx, pw.ncy, pw.ncz, pw.nczp, + pw.nrxx, pw.nbz, pw.bz); // mohan add 2010-07-22, update 2011-05-04 + + //---------------------------------------------------------- // 1 read in initial data: // a lattice structure:atom_species,atom_positions,lattice vector diff --git a/ABACUS.develop/source/src_io/print_info.cpp b/ABACUS.develop/source/src_io/print_info.cpp index 86bbf57640..515cca97db 100644 --- a/ABACUS.develop/source/src_io/print_info.cpp +++ b/ABACUS.develop/source/src_io/print_info.cpp @@ -7,38 +7,34 @@ Print_Info::Print_Info(){} Print_Info::~Print_Info(){} -void Print_Info::screen_output(void) +void Print_Info::setup_parameters(void) { + TITLE("Print_Info","setup_parameters"); - // the following printing information should be moved to somewhere else -- mohan 2021-01-30 if(CALCULATION=="scf" || CALCULATION=="relax" || CALCULATION=="cell-relax" || CALCULATION=="nscf" - || CALCULATION=="istate" || CALCULATION=="ienvelope" - || CALCULATION=="md") //pengfei add 2014-10-13 + || CALCULATION=="istate" || CALCULATION=="ienvelope" || CALCULATION=="md") { - //LM.divide_HS_in_frag(); //move it above 2015-09-06, xiaohui cout << " ---------------------------------------------------------" << endl; if(CALCULATION=="scf") { - cout << " This calculation is self-consistent" << endl; + cout << " Self-consistent calculations for electrons" << endl; } else if(CALCULATION=="test") { - cout << " This calculation is for test" << endl; + cout << " Test run" << endl; } - if(CALCULATION=="relax") //add 4 lines 2015-09-06, xiaohui + if(CALCULATION=="relax") { - //cout << " This calculation is structure relaxation" << endl; - cout << " This calculation is ion relaxation" << endl; + cout << " Ion relaxation calculations" << endl; } if(CALCULATION=="cell-relax") { - cout << " This calculation is cell relaxation" << endl; + cout << " Cell relaxation calculations" << endl; } - if(CALCULATION=="md") //add 4 lines 2015-09-06, xiaohui + if(CALCULATION=="md") { - cout << " This calculation is molecular dynamics" << endl; + cout << " Molecular Dynamics simulations" << endl; - //xiaohui add 2015-09-15 cout << " ---------------------------------------------------------" << endl; if(INPUT.md_mdtype ==1 || INPUT.md_mdtype==2) @@ -55,23 +51,19 @@ void Print_Info::screen_output(void) cout << " ---------------------------------------------------------" << endl; - // TITLE cout << " " << setw(8) << "SPIN" << setw(16) << "KPOINTS" << setw(12) << "PROCESSORS"; - //if(LOCAL_BASIS==4) xiaohui modify 2013-09-01 - if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-01 + if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") { cout << setw(12) << "NBASE"; - cout << setw(12) << "VNA"; } cout << endl; - // data cout << " " << setw(8) << NSPIN; if(GAMMA_ONLY_LOCAL) @@ -103,12 +95,9 @@ void Print_Info::screen_output(void) cout << setw(12) << NPROC; - //if(LOCAL_BASIS==4) xiaohui modify 2013-09-01 - if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-01 + if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") { cout << setw(12) << NLOCAL; - // print VNA: no, should delete in future -- mohan 2021-02-09 - cout << setw(12) << "No"; } cout << endl; @@ -117,8 +106,7 @@ void Print_Info::screen_output(void) cout << " ---------------------------------------------------------" << endl; - //if(LOCAL_BASIS==4 && LINEAR_SCALING==1) xiaohui modify 2013-09-01 - if(BASIS_TYPE=="lcao") //xiaohui add 2013-09-01 + if(BASIS_TYPE=="lcao") { if(COLOUR && MY_RANK==0) { @@ -131,14 +119,11 @@ void Print_Info::screen_output(void) cout << " Use Systematically Improvable Atomic bases" << endl; } } - //else if(LOCAL_BASIS==4 && LINEAR_SCALING==0) xiaohui modify 2013-09-01 - else if(BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-01 + else if(BASIS_TYPE=="lcao_in_pw") { - //cout << " Expand Systematically Improvable Atomic bases into plane waves" << endl; cout << " Expand Atomic bases into plane waves" << endl; } - //else if(LOCAL_BASIS==0 && LINEAR_SCALING==0) xiaohui modify 2013-09-01 - else if(BASIS_TYPE=="pw") //xiaohui add 2013-09-01 + else if(BASIS_TYPE=="pw") { cout << " Use plane wave basis" << endl; } @@ -152,14 +137,12 @@ void Print_Info::screen_output(void) cout << " " << setw(8) << "ELEMENT"; - //if(LOCAL_BASIS==4) xiaohui modify 2013-09-01 - if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-01 + if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") { cout << setw(16) << "ORBITALS"; cout << setw(12) << "NBASE"; - //cout << setw(12) << "NATOM"; //move it below 2015-09-06, xiaohui } - cout << setw(12) << "NATOM"; //add 2015-09-06, xiaohui + cout << setw(12) << "NATOM"; cout << setw(12) << "XC"; cout << endl; @@ -170,7 +153,6 @@ void Print_Info::screen_output(void) { if(COLOUR && MY_RANK==0) { - //printf( " \e[36m%-8s\e[0m", ucell.atoms[it].label.c_str()); printf( " [36m%-8s[0m", ucell.atoms[it].label.c_str()); } else @@ -178,8 +160,7 @@ void Print_Info::screen_output(void) cout << " " << setw(8) << ucell.atoms[it].label; } - //if(LOCAL_BASIS==4) xiaohui modify 2013-09-01 - if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-01 + if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") { stringstream orb; @@ -249,7 +230,6 @@ void Print_Info::screen_output(void) cout << " Initial plane wave basis and FFT box" << endl; cout << " ---------------------------------------------------------" << endl; -// cout << " GRID_SPEED : " << GRID_SPEED << endl; } return; diff --git a/ABACUS.develop/source/src_io/print_info.h b/ABACUS.develop/source/src_io/print_info.h index a11472f897..f688461ec3 100644 --- a/ABACUS.develop/source/src_io/print_info.h +++ b/ABACUS.develop/source/src_io/print_info.h @@ -12,7 +12,8 @@ class Print_Info Print_Info(); ~Print_Info(); - void screen_output(); + // print out to screen about the readin parameters + void setup_parameters(); }; From eadecf0f63a4a35888c208830d78ab73596c43c9 Mon Sep 17 00:00:00 2001 From: mohan Date: Sat, 20 Feb 2021 09:26:52 +0800 Subject: [PATCH 136/233] update the input parameters of charge.init --- ABACUS.develop/source/README | 4 +- ABACUS.develop/source/driver.cpp | 5 +- ABACUS.develop/source/run_lcao.cpp | 34 +++++++------- ABACUS.develop/source/run_pw.cpp | 2 +- ABACUS.develop/source/src_pw/charge.cpp | 58 +++++++++++++----------- ABACUS.develop/source/src_pw/charge.h | 12 ++++- ABACUS.develop/source/src_pw/potential.h | 6 +-- 7 files changed, 72 insertions(+), 49 deletions(-) diff --git a/ABACUS.develop/source/README b/ABACUS.develop/source/README index f61de08fff..191291c344 100644 --- a/ABACUS.develop/source/README +++ b/ABACUS.develop/source/README @@ -9,8 +9,10 @@ Ask Xiaohui Liu: all functions named with 'after_vc' should be reconstructed. The 'FINAL_SCF' global varialble should be removed. (condition: need to reconstruct these codes within a given time) +Ask Xiaohui Liu and Daye Zheng: We need test examples. + Ask Fuxiang He: we need to remove all TDDFT-related global variables -in global_variable.h +in global_variable.h, we need TDDFT examples. (condition: need to reconstruct these codes within a given time) Ask Daye Zheng: MD, force, stress modules need reconstruction diff --git a/ABACUS.develop/source/driver.cpp b/ABACUS.develop/source/driver.cpp index 134c1365f8..cf18c645a5 100644 --- a/ABACUS.develop/source/driver.cpp +++ b/ABACUS.develop/source/driver.cpp @@ -70,11 +70,14 @@ void Driver::reading(void) //DONE(ofs_running,"READING CARDS"); // (7) Setup the unitcell. + // improvement: a) separating the first reading of the atom_card and subsequent + // cell relaxation. b) put NLOCAL and NBANDS as input parameters ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running); //ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running, NLOCAL, NBANDS); DONE(ofs_running, "SETUP UNITCELL"); - // (8) symmetry analysize. + // (8) Symmetry analysis. + // symmetry analysis should be performed every time the cell is changed if (SYMMETRY) { symm.analy_sys(); diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index 15806a73d9..f94469896a 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -23,21 +23,23 @@ void Run_lcao::lcao_line(void) // for LCAO basis, reading the orbitals and construct // the interpolation tables. - // this part should be moved somewher else -- mohan 2021-01-30 - if(BASIS_TYPE=="lcao") //xiaohui add 2013-09-01 - { - // read orbital information. - // init overlap matrix table, which is 'S Table' - // init kinetical matrix element table, which is 'T Table' - // init non-local pseudopotential matrix element table, which is 'NL Table' - hm.orb_con.set_orb_tables(); - - // xiaohui add 2015-09-06 - // (1) divide the H and S matrix into each CPU, count the dimensions - // (2) set the 'trace' between local H/S and global H/S - // (2) allocate the needed H and S memory - LM.divide_HS_in_frag(); - } + + // read orbital information. + // init overlap matrix table, which is 'S Table' + // init kinetical matrix element table, which is 'T Table' + // init non-local pseudopotential matrix element table, which is 'NL Table' + hm.orb_con.set_orb_tables(); + + // xiaohui add 2015-09-06 + // (1) divide the H and S matrix into each CPU, count the dimensions + // (2) set the 'trace' between local H/S and global H/S + // (2) allocate the needed H and S memory + LM.divide_HS_in_frag(); + + +//-------------------------------------- +// cell relaxation should begin here +//-------------------------------------- // Initalize the plane wave basis set @@ -63,7 +65,7 @@ void Run_lcao::lcao_line(void) // (1) Inititlize the charge density. - CHR.init(); + CHR.init(NSPIN, pw.nrxx, pw.ngmc); DONE(ofs_running,"INIT CHARGE"); // (2) Initializee the potential. diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp index b393fec1d0..a829b39293 100644 --- a/ABACUS.develop/source/run_pw.cpp +++ b/ABACUS.develop/source/run_pw.cpp @@ -50,7 +50,7 @@ void Run_pw::plane_wave_line(void) //===================== // init potential //===================== - CHR.init(); + CHR.init(NSPIN, pw.nrxx, pw.ngmc); pot.init(pw.nrxx); //===================== diff --git a/ABACUS.develop/source/src_pw/charge.cpp b/ABACUS.develop/source/src_pw/charge.cpp index c3766b1002..fad155dee7 100644 --- a/ABACUS.develop/source/src_pw/charge.cpp +++ b/ABACUS.develop/source/src_pw/charge.cpp @@ -53,49 +53,55 @@ Charge::~Charge() } } -void Charge::init() +void Charge::init(const int &nspin_in, const int &nrxx_in, const int &ngmc_in) { if (test_charge) TITLE("Charge","init"); assert(allocate_rho == false); + // mohan add 2021-02-20 + this->nspin = nspin_in; + this->nrxx = nrxx_in; + this->ngmc = ngmc_in; + if (test_charge > 1) { - cout << "\n spin_number = " << NSPIN - << " real_point_number = " << pw.nrxx; + cout << "\n spin_number = " << nspin + << " real_point_number = " << nrxx; } + // allocate memory - rho = new double*[NSPIN]; - rhog = new complex*[NSPIN]; - rho_save = new double*[NSPIN]; - rhog_save = new complex*[NSPIN]; + rho = new double*[nspin]; + rhog = new complex*[nspin]; + rho_save = new double*[nspin]; + rhog_save = new complex*[nspin]; - for(int is=0; is[pw.ngmc]; - rho_save[is] = new double[pw.nrxx]; - rhog_save[is] = new complex[pw.ngmc]; - ZEROS(rho[is], pw.nrxx); - ZEROS(rhog[is], pw.ngmc); - ZEROS(rho_save[is], pw.nrxx); - ZEROS(rhog_save[is], pw.ngmc); + rho[is] = new double[nrxx]; + rhog[is] = new complex[ngmc]; + rho_save[is] = new double[nrxx]; + rhog_save[is] = new complex[ngmc]; + ZEROS(rho[is], nrxx); + ZEROS(rhog[is], ngmc); + ZEROS(rho_save[is], nrxx); + ZEROS(rhog_save[is], ngmc); } - Memory::record("Charge","rho",NSPIN*pw.nrxx,"double"); - Memory::record("Charge","rho_save",NSPIN*pw.nrxx,"double"); - Memory::record("Charge","rhog",NSPIN*pw.ngmc,"double"); - Memory::record("Charge","rhog_save",NSPIN*pw.ngmc,"double"); + Memory::record("Charge","rho",nspin*nrxx,"double"); + Memory::record("Charge","rho_save",nspin*nrxx,"double"); + Memory::record("Charge","rhog",nspin*ngmc,"double"); + Memory::record("Charge","rhog_save",nspin*ngmc,"double"); - this->rho_core = new double[pw.nrxx]; // core charge in real space - ZEROS( rho_core, pw.nrxx); + this->rho_core = new double[nrxx]; // core charge in real space + ZEROS( rho_core, nrxx); - this->rhog_core = new complex[pw.ngmc]; // reciprocal core charge - ZEROS( rhog_core, pw.ngmc); + this->rhog_core = new complex[ngmc]; // reciprocal core charge + ZEROS( rhog_core, ngmc); - Memory::record("Charge","rho_core",pw.nrxx,"double"); - Memory::record("Charge","rhog_core",pw.ngmc,"double"); + Memory::record("Charge","rho_core",nrxx,"double"); + Memory::record("Charge","rhog_core",ngmc,"double"); this->allocate_rho = true; return; diff --git a/ABACUS.develop/source/src_pw/charge.h b/ABACUS.develop/source/src_pw/charge.h index 355cf2984d..b446a3f73d 100644 --- a/ABACUS.develop/source/src_pw/charge.h +++ b/ABACUS.develop/source/src_pw/charge.h @@ -14,9 +14,15 @@ class Charge { + public: + Charge(); ~Charge(); + + // mohan update 2021-02-20 + void init(const int &nspin_in, const int &nrxx_in, const int &ngmc_in); + //========================================================== // MEMBER VARIABLES : // NAME : rho (nspin,ncxyz), the charge density in real space @@ -43,7 +49,6 @@ class Charge double *start_mag_type; double *start_mag_atom; - void init(); void atomic_rho(const int spin_number_need, double **rho_in)const; @@ -79,6 +84,11 @@ class Charge private: + // mohan add 2021-02-20 + int nrxx; // number of r vectors in this processor + int ngmc; // number of g vectors in this processor + int nspin; // number of spins + void sum_band_k(); void rho_mpi(void); diff --git a/ABACUS.develop/source/src_pw/potential.h b/ABACUS.develop/source/src_pw/potential.h index 2bbaf0f6f3..e5e91fd639 100644 --- a/ABACUS.develop/source/src_pw/potential.h +++ b/ABACUS.develop/source/src_pw/potential.h @@ -22,9 +22,8 @@ class potential matrix vrs; matrix vnew; double *vrs1; // mohan add 2007-11-12 - double *vext; // fuxiang add 2017-05 - double *vextold; //fuxiang add 2018-01-15 - + double *vext; // fuxiang add 2017-05 + double *vextold; //fuxiang add 2018-01-15 // member functions void init(const int nrxx); @@ -37,6 +36,7 @@ class potential // V(rho_atom) is calclated, // V(xc) is not calculated. void init_pot(const int &istep, const bool delta_vh=false, const bool vna=false); + void newd(void); void v_of_rho( double** rho_in, double &ehart, double &etxc, From 56a26f1a32870219fb6cd85e1f6b2f678c7623d6 Mon Sep 17 00:00:00 2001 From: qianrui <1962242031@qq.com> Date: Sat, 20 Feb 2021 12:54:57 +0800 Subject: [PATCH 137/233] finish iteration for mu --- ABACUS.develop/source/src_pw/sto_che.cpp | 85 +++++++- ABACUS.develop/source/src_pw/sto_che.h | 65 +++++- ABACUS.develop/source/src_pw/sto_hchi.cpp | 230 ++++++++++++++++++---- ABACUS.develop/source/src_pw/sto_hchi.h | 33 ++-- ABACUS.develop/source/src_pw/sto_iter.cpp | 199 ++++++++++++++++++- ABACUS.develop/source/src_pw/sto_iter.h | 29 ++- ABACUS.develop/source/src_pw/sto_wf.cpp | 10 +- ABACUS.develop/source/src_pw/sto_wf.h | 3 +- 8 files changed, 580 insertions(+), 74 deletions(-) diff --git a/ABACUS.develop/source/src_pw/sto_che.cpp b/ABACUS.develop/source/src_pw/sto_che.cpp index 748111bf25..5af2212e11 100644 --- a/ABACUS.develop/source/src_pw/sto_che.cpp +++ b/ABACUS.develop/source/src_pw/sto_che.cpp @@ -6,9 +6,12 @@ Stochastic_Chebychev::Stochastic_Chebychev() { initplan = false; initcoef = false; - norder = 0; + getcoef = false; + getpolyval = false; + norder = 10; ccoef = new complex [1]; coef = new double [1]; + polyvalue = new complex [1]; } Stochastic_Chebychev::~Stochastic_Chebychev() @@ -19,16 +22,22 @@ Stochastic_Chebychev::~Stochastic_Chebychev() } delete [] coef; delete [] ccoef; + delete [] polyvalue; } void Stochastic_Chebychev:: init() { + norder = STO_WF.nche_sto; + assert(norder > 10); if(norder != 0) { norder2 = 2 * norder; delete[] coef; delete[] ccoef; + delete[] polyvalue; ccoef = new complex [norder2]; coef = new double [norder]; + polyvalue = new complex [norder]; + ZEROS(polyvalue, norder); initcoef = true; } else @@ -62,6 +71,7 @@ void Stochastic_Chebychev:: calcoef(double fun(double)) coef[i]/=ccoef[i].real()/norder; } } + getcoef = true; } void Stochastic_Chebychev:: recurs(double&tnp1, double& tn, double& tn_1, double &t) @@ -69,3 +79,76 @@ void Stochastic_Chebychev:: recurs(double&tnp1, double& tn, double& tn_1, double tnp1 = 2*t*tn-tn_1; } +complex Stochastic_Chebychev:: calresult() +{ + if(!getcoef||!getpolyval) WARNING_QUIT("Stochastic_Chebychev", "Please calculate coef or polyval first!"); + complex result = 0; + for(int ior = 0; ior < norder; ++ior) + { + result += coef[ior] * polyvalue[ior]; + } + return result; +} + +void Stochastic_Chebychev:: calresult(double &t, double& result) +{ + if(!getcoef) WARNING_QUIT("Stochastic_Chebychev", "Please calculate coef first!"); + double tnp1, tn, tn_1; + tn_1 = 1; + tn = tn_1 * t; + //0- & 1-st order + result = coef[0] * tn_1 + coef[1] * tn; + + //more than 1-st orders + for(int ior = 2; ior < norder; ++ior) + { + recurs(tnp1, tn, tn_1, t); + result += coef[ior] * tnp1; + tn_1 = tn; + tn = tnp1; + } + return; +} + +void Stochastic_Chebychev:: calpolyval(void tfun(complex *in, complex *out), int& ndim, complex *wavein) +{ + if(!getcoef) WARNING_QUIT("Stochastic_Chebychev", "Please calculate coef first!"); + + complex *arraynp1, *arrayn, *arrayn_1; + arraynp1 = new complex [ndim]; + arrayn = new complex [ndim]; + arrayn_1 = new complex [ndim]; + + for(int i = 0; i < ndim; ++i) + { + arrayn_1[i] = wavein[i]; + } + tfun(arrayn_1, arrayn); + + //0- & 1-st order + polyvalue[0] = ndim; // 0-th order : = ndim + for(int i = 0; i < ndim; ++i) // 1-st order : + { + polyvalue[1] += conj(wavein[i]) * arrayn_1[i]; + } + + //more than 1-st orders + for(int ior = 2; ior < norder; ++ior) + { + recurs(arraynp1, arrayn, arrayn_1, tfun, ndim); + for(int i = 0; i < ndim; ++i) // n-th order : + { + polyvalue[ior] += conj(wavein[i]) * arraynp1[i]; + } + complex* tem = arrayn_1; + arrayn_1 = arrayn; + arrayn = arraynp1; + arraynp1 = tem; + } + + delete [] arraynp1; + delete [] arrayn; + delete [] arrayn_1; + getpolyval = true; + return; +} diff --git a/ABACUS.develop/source/src_pw/sto_che.h b/ABACUS.develop/source/src_pw/sto_che.h index 0c6fbc745f..53c6200dea 100644 --- a/ABACUS.develop/source/src_pw/sto_che.h +++ b/ABACUS.develop/source/src_pw/sto_che.h @@ -16,19 +16,29 @@ class Stochastic_Chebychev Stochastic_Chebychev(); ~Stochastic_Chebychev(); void init(); + void calcoef(double fun(double)); - void recurs(double&tnp1, double &tn, double &tn_1, double& t); //tnp1: T_(n+1), tn: T_n, tn_1: T_(n-1) + complex calresult(); + void calresult(double &t, double &result); + template - void recurs(T *arraynp1, T* arrayn, T *arrayn_1, void fun(T *in,T *out), int& ndim); + void calresult(void fun(T *in, T *out), int& ndim, T *wavein, T *waveout); + + + void calpolyval(void fun(complex *in, complex *out), int& ndim, complex *wavein); + int norder; int norder2; // 2 * norder double* coef; //[norder] expansion coefficient of each order, - complex *ccoef; //[norder2] temporary complex expansion coefficient of each order, only first norder coefficient is usefull. + complex *ccoef; //[norder2] temporary complex expansion coefficient of each order, only first norder coefficient are usefull. + complex *polyvalue; // fftw_plan plancoef; - bool initplan, initcoef; + bool initplan, initcoef, getcoef, getpolyval; private: - + void recurs(double&tnp1, double &tn, double &tn_1, double& t); //tnp1: T_(n+1), tn: T_n, tn_1: T_(n-1) + template + void recurs(T *arraynp1, T* arrayn, T *arrayn_1, void fun(T *in,T *out), int& ndim); }; @@ -36,11 +46,54 @@ class Stochastic_Chebychev template void Stochastic_Chebychev:: recurs(T *arraynp1, T* arrayn, T *arrayn_1, void fun(T *in,T *out), int& ndim) { - fun(arrayn,arraynp1,ndim); + fun(arrayn,arraynp1); for(int i = 0; i < ndim; ++i) { arraynp1[i]=2*arraynp1[i]-arrayn_1[i]; } } +template +void Stochastic_Chebychev:: calresult(void tfun(T *in, T *out), int &ndim, T *wavein, T *waveout) +{ + if(!getcoef) WARNING_QUIT("Stochastic_Chebychev", "Please calculate coef first!"); + + T *arraynp1, *arrayn, *arrayn_1; + arraynp1 = new T [ndim]; + arrayn = new T [ndim]; + arrayn_1 = new T [ndim]; + for(int i = 0; i < ndim; ++i) + { + arrayn_1[i] = wavein[i]; + } + tfun(arrayn_1, arrayn); + //0- & 1-st order + for(int i = 0; i < ndim; ++i) + { + waveout[i] = coef[0] * arrayn_1[i] + coef[1] * arrayn[i]; + } + + //more than 1-st orders + for(int ior = 2; ior <= norder; ++ior) + { + recurs(arraynp1, arrayn, arrayn_1, tfun, ndim); + for(int i = 0; i < ndim; ++i) + { + waveout[i] += coef[ior] * arraynp1[i]; + } + T * tem = arrayn_1; + arrayn_1 = arrayn; + arrayn = arraynp1; + arraynp1 = tem; + } + delete [] arraynp1; + delete [] arrayn; + delete [] arrayn_1; + return; +} + + + + + #endif// Eelectrons_Chebychev diff --git a/ABACUS.develop/source/src_pw/sto_hchi.cpp b/ABACUS.develop/source/src_pw/sto_hchi.cpp index 6c178b5e98..3bd73da7eb 100644 --- a/ABACUS.develop/source/src_pw/sto_hchi.cpp +++ b/ABACUS.develop/source/src_pw/sto_hchi.cpp @@ -2,84 +2,159 @@ #include "global.h" #include "sto_hchi.h" +int Stochastic_hchi:: nrxx; +int Stochastic_hchi:: nx,Stochastic_hchi::ny,Stochastic_hchi::nz; +fftw_plan Stochastic_hchi:: pf, Stochastic_hchi::pb; +double Stochastic_hchi:: Emin, Stochastic_hchi:: Emax; +bool Stochastic_hchi:: initplan, Stochastic_hchi::ortho; +complex* Stochastic_hchi:: rp_chi, * Stochastic_hchi::tmpchi2, * Stochastic_hchi::chig; -Stochastic_Hchi::Stochastic_Hchi() + +Stochastic_hchi::Stochastic_hchi() { initplan = false; - initchi = false; + ortho = false; nrxx = 0; - tmpchi1 = new complex [1]; + rp_chi = new complex [1]; tmpchi2 = new complex [1]; + chig = new complex [1]; } -Stochastic_Hchi::~Stochastic_Hchi() +Stochastic_hchi::~Stochastic_hchi() { if(initplan) { fftw_destroy_plan(pf); + fftw_destroy_plan(pb); } - delete[] tmpchi1; + delete[] rp_chi; delete[] tmpchi2; } -void Stochastic_Hchi:: init() +void Stochastic_hchi:: init() { + //wait for init-------------------------------------- + //nrxx + //--------------------------------------------------- if(nrxx != 0) { - delete[] tmpchi1; + delete[] rp_chi; delete[] tmpchi2; - tmpchi1 = new complex [nrxx]; + rp_chi = new complex [nrxx]; tmpchi2 = new complex [nrxx]; - initchi = true; + pb=fftw_plan_dft_3d(nx,ny,nz,(fftw_complex *)rp_chi,(fftw_complex *)rp_chi, FFTW_BACKWARD, FFTW_MEASURE); + pf=fftw_plan_dft_3d(nx,ny,nz,(fftw_complex *)tmpchi2,(fftw_complex *)tmpchi2, FFTW_FORWARD, FFTW_MEASURE); + initplan = true; } else { - WARNING_QUIT("Stochastic_Hchi", "Number of grids should be at least one!"); + WARNING_QUIT("Stochastic_hchi", "Number of grids should be at least one!"); } } -void Stochastic_Hchi:: Hchi(complex*wfin, complex *wfout) +void Stochastic_hchi::orthogonal_to_psi(complex *wfin, complex *wfgortho) { - //wait for init-------------------------------------- - double dk1=1,dk2=1,dk3=1; double*vr; - - //--------------------------------------------------- - if(!initchi) WARNING_QUIT("Stochastic_Hchi", "Please init Hchi first!"); - if(!initplan) + //wait for init + int * GR_INDEX; + double * v; + + TITLE("Stochastic_hchi","orthogonal_to_psi0"); + if(!initplan) WARNING_QUIT("Stochastic_hchi", "Please init hchi first!"); + + for( int ir = 0; ir < nrxx; ++ir) + { + rp_chi[ir] = wfin[ir]; + } + ZEROS(wfgortho,nrxx); + fftw_execute(pb); + + delete []chig; + chig = new complex [wf.npw]; + for(int ig = 0; ig < wf.npw; ++ig) { - initplan=true; - pf=fftw_plan_dft_3d(nx,ny,nz,(fftw_complex *)tmpchi1,(fftw_complex *)tmpchi2, FFTW_FORWARD, FFTW_MEASURE); + chig[ig] = rp_chi[GR_INDEX[ig]]; } - complex ui(0,1); - for(int ix = 0, i = 0; ix < nx; ++ix) + + //orthogonal part + complex sum; + for(int iksb = 0; iksb < NBANDS; ++iksb) { - for(int iy = 0; iy < ny; ++iy) + complex *kswf; // kswf is normalized + sum=0; + for(int ig = 0; ig < pw.ngmw; ++ig) { - for(int iz = 0; iz < nz; ++iz) - { - tmpchi1[i] = wfin[i]*exp(PI*(double(nx)/(nx-1)*ix+double(ny)/(ny-1)*iy+double(nz)/(nz-1)*iz)*ui); - ++i; - } + sum += conj(kswf[ig]) * chig[ig]; } + for(int ig = 0; ig < pw.ngmw; ++ig) + { + chig[ig] -= sum*kswf[ig]; + } + } + + for(int ig = 0; ig < wf.npw; ++ig) + { + rp_chi[GR_INDEX[ig]] = chig[ig]; + } + for(int ir = 0; ir < nrxx; ++ir) + { + wfgortho[ir] = rp_chi[ir]; + } + ortho = true; + return; +} + + + + +void Stochastic_hchi:: hchi(complex*wfgortho, complex *wfout) +{ + //wait for init-------------------------------------- + double dk1=1,dk2=1,dk3=1; double*vr;//vr= pot.vrs1 temporarily use cutoff vr. + int * GR_INDEX; + //--------------------------------------------------- + if(!initplan||!ortho) WARNING_QUIT("Stochastic_hchi", "Please init hchi first!"); + + + //------------------------------------ + //(1) the local potential. + //------------------------------------ + if(VL_IN_H) + { + for(int ir = 0; ir < nrxx; ++ir) + { + tmpchi2[ir] = wfgortho[ir]; + } + fftw_execute(pf); + for(int ir = 0; ir < nrxx; ++ir) + { + wfout[ir] += tmpchi2[ir] * vr[ir]; + } } + //------------------------------------ - //(1) the kinetical energy. + //(2) the kinetical energy. //------------------------------------ if(T_IN_H) { - fftw_execute(pf); Vector3 gg; + int gx,gy,gz; for(int ig1 = 0, i = 0; ig1 < nx; ++ig1) { for(int ig2 = 0; ig2 < ny; ++ig2) { for(int ig3 = 0; ig3 < nz; ++ig3) { - gg.set((ig1-double(nx-1)/2)*dk1, (ig2-double(ny-1)/2)*dk2, (ig3-double(nz-1)/2)*dk3); - tmpchi2[i] *= -gg.norm2(); + gx = ig1; + gy = ig2; + gz = ig3; + if(ig1 > nx/2) gx -= nx; + if(ig2 > ny/2) gy -= ny; + if(ig3 > nz/2) gz -= nz; + gg.set((gx-double(nx-1)/2)*dk1, (gy-double(ny-1)/2)*dk2, (gz-double(nz-1)/2)*dk3); + tmpchi2[i] = -gg.norm2()*wfgortho[i]; ++i; } } @@ -87,26 +162,97 @@ void Stochastic_Hchi:: Hchi(complex*wfin, complex *wfout) } } + + //------------------------------------ - //(2) the local potential. + // (3) the nonlocal pseudopotential. //------------------------------------ - if(VL_IN_H) + if(VNL_IN_H) { - for(int ir = 0; ir < nrxx; ++ir) + if ( ppcell.nkb > 0) { - tmpchi1[ir]*=vr[ir]; + complex *becp = new complex[ ppcell.nkb * NPOL ]; + ZEROS(becp,ppcell.nkb * NPOL); + + for (int i=0;i< ppcell.nkb;++i) + { + const complex* p = &ppcell.vkb(i,0); + const complex* const p_end = p + wf.npw; + for (int ig=0; ig< wf.npw; ++ig) + { + if(NSPIN!=4) becp[i] += chig[ig] * conj( p[ig] ); + else + { + //We didnot consider it temporarily. + } + } + } + + //Parallel_Reduce::reduce_complex_double_pool( becp, ppcell.nkb * NPOL); + complex * Ps; + ZEROS( Ps, ppcell.nkb * NPOL ); + int sum = 0; + int iat = 0; + // this function sum up each non-local pseudopotential located in each atom, + // all we need to do is put the right Dij coefficient to each becp, which + // is calculated before. + for (int it=0; it* p = &ppcell.vkb(i,0); + for(int ig=0; ig< wf.npw; ++ig) + { + chig[ig] = Ps[i] * p[ig]; + } + } + delete[] becp; } } + //------------------------------------ - // (3) the nonlocal pseudopotential. + // (4) Conver (2) & (3) in Reciprocal space to Real one //------------------------------------ -} - -void Stochastic_Hchi::orthogonal_to_psi() -{ - TITLE("Stochastic_Hchi","orthogonal_to_psi0"); - + for(int ig = 0; ig < wf.npw; ++ig) + { + tmpchi2[GR_INDEX[ig]] += chig[ig]; + } + fftw_execute(pf); + for(int i = 0; i *tmpchi1,*tmpchi2; - void Hchi(complex* chiin, complex *chiout); + Stochastic_hchi(); + ~Stochastic_hchi(); + static void init(); + static int nrxx; + static int nx,ny,nz; + static fftw_plan pf,pb; + static double Emin, Emax; + static bool initplan,ortho; + static complex *rp_chi,*tmpchi2; + static complex *chig; + static void orthogonal_to_psi(complex* wfin, complex *wfgortho); + static void hchi(complex *chigortho, complex *wfout); @@ -35,9 +38,9 @@ class Stochastic_Hchi // chi should be orthogonal to psi (generated by diaganolization methods, // such as CG) - void orthogonal_to_psi(); + }; -#endif// Eelectrons_Hchi +#endif// Eelectrons_hchi diff --git a/ABACUS.develop/source/src_pw/sto_iter.cpp b/ABACUS.develop/source/src_pw/sto_iter.cpp index 6cb3f891bf..21a82ac606 100644 --- a/ABACUS.develop/source/src_pw/sto_iter.cpp +++ b/ABACUS.develop/source/src_pw/sto_iter.cpp @@ -1,11 +1,208 @@ #include "global.h" -#include "sto_iter.h" +#include "sto_iter.h" +#include "occupy.h" +double Stochastic_Iter:: mu; +double Stochastic_Iter:: Emin; +double Stochastic_Iter:: Emax; Stochastic_Iter::Stochastic_Iter() { + mu = 0; + spolyv = new double [1]; } Stochastic_Iter::~Stochastic_Iter() { } +void Stochastic_Iter:: init() +{ + nchip = STO_WF.nchip; + //wait for init + targetne = 0; + stoche.init(); + stohchi.init(); + delete [] spolyv; + int norder = stoche.norder; + spolyv = new double [norder]; + ZEROS(spolyv,norder); + +} + +void Stochastic_Iter:: itermu() +{ + //orthogonal part + int nkk=1;// We temporarily use gamma k point. + for(int ik = 0; ik < nkk; ++ik) + { + for(int ichi = 0; ichi < nchip; ++ichi) + { + complex * p0 = &STO_WF.chi0[ik](ichi,0); + complex * pg = &STO_WF.chig[ik](ichi,0); + stohchi.orthogonal_to_psi(p0,pg); + } + } + + sumpolyval(); + double dnedmu = caldnedmu(); + double ne1 = calne(); + double mu1 = mu; + double mu2 = (targetne - ne1) / dnedmu; + double Dne=abs(targetne - ne1); + double ne2; + double mu3; + while(Dne > th_ne) + { + mu = mu2; + ne2 = calne(); + mu3 = mu2; + mu2 = (targetne - ne1) * (mu2 - mu1) / (ne2 - ne1) + mu1; + mu1 = mu3; + ne1 = ne2; + Dne = abs(targetne - ne2); + } + + //wait for init + double *rho; + mu = mu1; + calrho(rho); +} + +void Stochastic_Iter:: sumpolyval() +{ + int norder = stoche.norder; + //wait for init + int nkk; + int nrxx = stohchi.nrxx; + + for(int ik = 0; ik < nkk; ++ik) + { + for(int ichi = 0; ichi < nchip; ++ichi) + { + complex * pg = &STO_WF.chig[ik](ichi,0); + stoche.calpolyval(stohchi.hchi, nrxx, pg); + for(int ior = 0; ior < norder; ++ior) + { + spolyv[ior] += stoche.polyvalue[ior].real(); + } + } + } + return; +} + +double Stochastic_Iter:: caldnedmu() +{ + stoche.calcoef(this->dfddmu); + int norder = stoche.norder; + double dnedmu = 0; + for(int ior = 0; ior < norder; ++ior) + { + dnedmu += stoche.coef[ior] * spolyv[ior]; + } + + //wait for init + double *en; + + //number of electrons in KS orbitals + for(int iksb = 0; iksb < NBANDS; ++iksb) + { + dnedmu += fd(en[iksb]); + } + + dnedmu *= 2; + return dnedmu; +} + +double Stochastic_Iter::calne() +{ + stoche.calcoef(this->nfd); + double ne = 0; + int norder = stoche.norder; + for(int ior = 0; ior < norder; ++ior) + { + ne += stoche.coef[ior] * spolyv[ior]; + } + + + //wait for init + double *en; + + //number of electrons in KS orbitals + for(int iksb = 0; iksb < NBANDS; ++iksb) + { + ne += fd(en[iksb]); + } + + ne *= 2; + return ne; +} + +void Stochastic_Iter::calrho( double * rho) +{ + stoche.calcoef(this->nroot_fd); + int nkk=1;// We temporarily use gamma k point. + int nrxx = stohchi.nrxx; + double ne = 0; + complex * out = new complex [nrxx]; + for(int ik = 0; ik < nkk; ++ik) + { + for(int ichi = 0; ichi < nchip; ++ichi) + { + complex * pg = &STO_WF.chig[ik](ichi,0); + stoche.calresult(Stochastic_hchi::hchi, nrxx, pg, out); + for(int ir = 0; ir < nrxx; ++ir) + { + rho[ir] += norm(out[ir]); + } + } + } + + //wait for init + double *rhoks; + + //number of electrons in KS orbitals + for(int ir = 0 ; ir < nrxx; ++ir) + { + rho[ir] += rhoks [ir]; + } + delete [] out; + return; +} + +double Stochastic_Iter:: dfddmu(double e) +{ + double expc = exp((e - mu) / (Occupy::gaussian_parameter * Ry_to_eV)); + return expc / pow(1 + expc, 2) / (Occupy::gaussian_parameter * Ry_to_eV); +} + +double Stochastic_Iter:: ndfddmu(double e) +{ + double Ebar = (Emin + Emax)/2; + double DeltaE = (Emax - Emin)/2; + double expc = exp((e * DeltaE + Ebar - mu) / (Occupy::gaussian_parameter * Ry_to_eV)); + return expc / pow(1 + expc, 2) / (Occupy::gaussian_parameter * Ry_to_eV); +} + +double Stochastic_Iter:: root_fd(double e) +{ + return sqrt(1 / (1 + exp((e - mu) / (Occupy::gaussian_parameter * Ry_to_eV)))); +} + +double Stochastic_Iter:: nroot_fd(double e) +{ + double Ebar = (Emin + Emax)/2; + double DeltaE = (Emax - Emin)/2; + return sqrt(1 / (1 + exp((e * DeltaE + Ebar - mu) / (Occupy::gaussian_parameter * Ry_to_eV)))); +} + +double Stochastic_Iter:: fd(double e) +{ + return 1 / (1 + exp((e - mu) / (Occupy::gaussian_parameter * Ry_to_eV))); +} + +double Stochastic_Iter:: nfd(double e) +{ + double Ebar = (Emin + Emax)/2; + double DeltaE = (Emax - Emin)/2; + return 1 / (1 + exp((e * DeltaE + Ebar - mu) / (Occupy::gaussian_parameter * Ry_to_eV))); +} diff --git a/ABACUS.develop/source/src_pw/sto_iter.h b/ABACUS.develop/source/src_pw/sto_iter.h index 6b3be8d327..d310bc7445 100644 --- a/ABACUS.develop/source/src_pw/sto_iter.h +++ b/ABACUS.develop/source/src_pw/sto_iter.h @@ -2,6 +2,8 @@ #define INCLUDE_STO_ITER_H #include "tools.h" +#include "sto_che.h" +#include "sto_hchi.h" //---------------------------------------------- // Solve for the new electron density and iterate @@ -18,12 +20,35 @@ class Stochastic_Iter // constructor and deconstructor Stochastic_Iter(); - ~Stochastic_Iter(); - double mu; // chemical potential + void init(); + + void calrho(double *); + double calne(); + double caldnedmu(); + void itermu(); + void sumpolyval(); + Stochastic_Chebychev stoche; + Stochastic_hchi stohchi; + + + static double mu; // chemical potential + static double Emin, Emax; + double targetne; + double * spolyv; private: + + double nchip; + double th_ne; + + static double root_fd(double e); + static double dfddmu(double e); + static double fd(double e); + static double nroot_fd(double e); + static double ndfddmu(double e); + static double nfd(double e); }; diff --git a/ABACUS.develop/source/src_pw/sto_wf.cpp b/ABACUS.develop/source/src_pw/sto_wf.cpp index 7e494f7ea4..cee03e832d 100644 --- a/ABACUS.develop/source/src_pw/sto_wf.cpp +++ b/ABACUS.develop/source/src_pw/sto_wf.cpp @@ -4,13 +4,13 @@ Stochastic_WF::Stochastic_WF() { - chi = new ComplexMatrix[1]; + chig = new ComplexMatrix[1]; chi0 = new ComplexMatrix[1]; } Stochastic_WF::~Stochastic_WF() { - delete[] chi; + delete[] chig; delete[] chi0; } @@ -37,11 +37,11 @@ void Stochastic_WF::init() chi0[0].c[i]=exp(2*PI*rand()*ui); } - delete[] chi; + delete[] chig; int nkk = 1; // We temporarily use gamma k point. - chi = new ComplexMatrix[nkk]; + chig = new ComplexMatrix[1]; + chig[0].create(nchip,nrxx,0); return; } - diff --git a/ABACUS.develop/source/src_pw/sto_wf.h b/ABACUS.develop/source/src_pw/sto_wf.h index 8f73faeeb3..3f0b5d7c66 100644 --- a/ABACUS.develop/source/src_pw/sto_wf.h +++ b/ABACUS.develop/source/src_pw/sto_wf.h @@ -21,10 +21,9 @@ class Stochastic_WF void init(); void calculate_chi(); - // ComplexMatrix may not be a best filetype to store the electronic wave functions ComplexMatrix* chi0; // origin stochastic wavefunctions in real space - ComplexMatrix* chi; // stochastic wavefunctions after orthogonalized with KS wavefunctions + ComplexMatrix* chig; // stochastic wavefunctions after in reciprocal space orthogonalized with KS wavefunctions Stochastic_Chebychev sto_che; int nchi; // Total number of stochatic obitals int nchip; // The number of stochatic obitals in current process From e9c420d7cc9ac00dd052b3530ef50dd86d18f0a0 Mon Sep 17 00:00:00 2001 From: mohan Date: Sat, 20 Feb 2021 17:13:33 +0800 Subject: [PATCH 138/233] update pw lcao line, prepare for cell relaxation --- ABACUS.develop/source/driver.cpp | 24 ---------------- ABACUS.develop/source/run_lcao.cpp | 28 +++++++++++++++++++ ABACUS.develop/source/run_pw.cpp | 28 +++++++++++++++++++ .../source/src_pw/unitcell_pseudo.cpp | 7 +++-- 4 files changed, 61 insertions(+), 26 deletions(-) diff --git a/ABACUS.develop/source/driver.cpp b/ABACUS.develop/source/driver.cpp index cf18c645a5..5819ef1228 100644 --- a/ABACUS.develop/source/driver.cpp +++ b/ABACUS.develop/source/driver.cpp @@ -5,7 +5,6 @@ #include "input_conv.h" #include "src_lcao/global_fp.h" #include "src_pw/global.h" -#include "src_io/print_info.h" #include "src_io/cal_test.h" #include "src_io/winput.h" @@ -69,29 +68,6 @@ void Driver::reading(void) INPUT.Print( ss1.str() ); //DONE(ofs_running,"READING CARDS"); - // (7) Setup the unitcell. - // improvement: a) separating the first reading of the atom_card and subsequent - // cell relaxation. b) put NLOCAL and NBANDS as input parameters - ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running); - //ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running, NLOCAL, NBANDS); - DONE(ofs_running, "SETUP UNITCELL"); - - // (8) Symmetry analysis. - // symmetry analysis should be performed every time the cell is changed - if (SYMMETRY) - { - symm.analy_sys(); - DONE(ofs_running, "SYMMETRY"); - } - - // (9) Setup the k points according to symmetry. - kv.set( symm, global_kpoint_card, NSPIN, ucell.G, ucell.latvec ); - DONE(ofs_running,"INIT K-POINTS"); - - // (10) print information - // mohan add 2021-01-30 - Print_Info PI; - PI.setup_parameters(); timer::tick("Driver","reading",'A'); return; diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index f94469896a..24faf66089 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -11,6 +11,7 @@ #include "src_io/winput.h" #include "src_global/sltk_atom_arrange.h" #include "src_lcao/local_orbital_ions.h" +#include "src_io/print_info.h" Run_lcao::Run_lcao(){} Run_lcao::~Run_lcao(){} @@ -21,6 +22,33 @@ void Run_lcao::lcao_line(void) TITLE("Run_lcao","lcao_line"); timer::tick("Run_lcao","lcao_line",'B'); + + // Setup the unitcell. + // improvement: a) separating the first reading of the atom_card and subsequent + // cell relaxation. b) put NLOCAL and NBANDS as input parameters + ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running); + //ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running, NLOCAL, NBANDS); + DONE(ofs_running, "SETUP UNITCELL"); + + // Symmetry analysis. + // symmetry analysis should be performed every time the cell is changed + if (SYMMETRY) + { + symm.analy_sys(); + DONE(ofs_running, "SYMMETRY"); + } + + // Setup the k points according to symmetry. + kv.set( symm, global_kpoint_card, NSPIN, ucell.G, ucell.latvec ); + DONE(ofs_running,"INIT K-POINTS"); + + // print information + // mohan add 2021-01-30 + Print_Info PI; + PI.setup_parameters(); + + + // for LCAO basis, reading the orbitals and construct // the interpolation tables. diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp index a829b39293..3294145441 100644 --- a/ABACUS.develop/source/run_pw.cpp +++ b/ABACUS.develop/source/run_pw.cpp @@ -6,6 +6,7 @@ #include "src_io/winput.h" #include "src_io/numerical_basis.h" #include "src_io/numerical_descriptor.h" +#include "src_io/print_info.h" Run_pw::Run_pw(){} Run_pw::~Run_pw(){} @@ -15,6 +16,33 @@ void Run_pw::plane_wave_line(void) TITLE("Run_pw","plane_wave_line"); timer::tick("Run_pw","plane_wave_line",'B'); + + // Setup the unitcell. + // improvement: a) separating the first reading of the atom_card and subsequent + // cell relaxation. b) put NLOCAL and NBANDS as input parameters + ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running); + //ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running, NLOCAL, NBANDS); + DONE(ofs_running, "SETUP UNITCELL"); + + // Symmetry analysis. + // symmetry analysis should be performed every time the cell is changed + if (SYMMETRY) + { + symm.analy_sys(); + DONE(ofs_running, "SYMMETRY"); + } + + // Setup the k points according to symmetry. + kv.set( symm, global_kpoint_card, NSPIN, ucell.G, ucell.latvec ); + DONE(ofs_running,"INIT K-POINTS"); + + // print information + // mohan add 2021-01-30 + Print_Info PI; + PI.setup_parameters(); + + + // Initalize the plane wave basis set pw.gen_pw(ofs_running, ucell, kv); DONE(ofs_running,"INIT PLANEWAVE"); diff --git a/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp b/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp index c57e140a3b..c74fedd0b1 100644 --- a/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp +++ b/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp @@ -95,8 +95,11 @@ void UnitCell_pseudo::setup_cell( #ifdef __MPI Parallel_Common::bcast_bool(ok); Parallel_Common::bcast_bool(ok2); - if(NSPIN==4) Parallel_Common::bcast_bool(DOMAG); - if(NSPIN==4) Parallel_Common::bcast_bool(DOMAG_Z); + if(NSPIN==4) + { + Parallel_Common::bcast_bool(DOMAG); + Parallel_Common::bcast_bool(DOMAG_Z); + } #endif if(!ok) { From 2a3eb1444a4333282172cfae7cf63ab2f6263a19 Mon Sep 17 00:00:00 2001 From: mohan Date: Sun, 21 Feb 2021 14:54:53 +0800 Subject: [PATCH 139/233] delete the global variable SYMMETRY, use new Symmetry::symm_flag variable --- ABACUS.develop/source/driver.cpp | 11 - ABACUS.develop/source/input_conv.cpp | 3 +- ABACUS.develop/source/run_lcao.cpp | 4 +- ABACUS.develop/source/run_pw.cpp | 9 +- .../source/src_global/global_variable.cpp | 1 - .../source/src_global/global_variable.h | 1 - .../source/src_ions/variable_cell.cpp | 4 +- ABACUS.develop/source/src_lcao/ELEC_nscf.cpp | 2 +- ABACUS.develop/source/src_lcao/force_lcao.cpp | 2 +- .../source/src_lcao/stress_lcao.cpp | 2 +- ABACUS.develop/source/src_pw/electrons.cpp | 2 +- ABACUS.develop/source/src_pw/forces.cpp | 5 +- ABACUS.develop/source/src_pw/klist.cpp | 7 +- ABACUS.develop/source/src_pw/stress.cpp | 9 +- ABACUS.develop/source/src_pw/symmetry.cpp | 4 + ABACUS.develop/source/src_pw/symmetry.h | 3 + ABACUS.develop/source/src_pw/symmetry_rho.cpp | 2 +- ABACUS.develop/source/src_pw/vdwd3.h | 211 +++++++++--------- 18 files changed, 138 insertions(+), 144 deletions(-) diff --git a/ABACUS.develop/source/driver.cpp b/ABACUS.develop/source/driver.cpp index 5819ef1228..0264b2e65b 100644 --- a/ABACUS.develop/source/driver.cpp +++ b/ABACUS.develop/source/driver.cpp @@ -21,11 +21,9 @@ void Driver::init() // (1) read the input parameters. this->reading(); - // (2) welcome to the atomic world! this->atomic_world(); - // (3) close all of the running logs INPUT.close_log(); @@ -37,8 +35,6 @@ void Driver::reading(void) { timer::tick("Driver","reading",'A'); -//--------------------------------------------------------------------------------- - // (1) read INPUT INPUT.Init( global_in_card ); @@ -68,14 +64,10 @@ void Driver::reading(void) INPUT.Print( ss1.str() ); //DONE(ofs_running,"READING CARDS"); - timer::tick("Driver","reading",'A'); return; } - - - void Driver::atomic_world(void) { TITLE("Driver","atomic_world"); @@ -103,6 +95,3 @@ void Driver::atomic_world(void) return; } - - - diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index c88a82caee..730ec5a386 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -19,6 +19,7 @@ #include "src_ri/exx_abfs-jle.h" #include "src_pw/occupy.h" #include "src_io/berryphase.h" +#include "src_pw/symmetry.h" void Input_Conv::Convert(void) { @@ -128,7 +129,7 @@ void Input_Conv::Convert(void) OUT_LEVEL = INPUT.out_level; Ions_Move_CG::CG_THRESHOLD = INPUT.cg_threshold; // pengfei add 2013-09-09 - SYMMETRY = INPUT.symmetry; // 9 + Symmetry::symm_flag = INPUT.symmetry; // 9 BASIS_TYPE = INPUT.basis_type; KS_SOLVER = INPUT.ks_solver; SEARCH_RADIUS = INPUT.search_radius; diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index 24faf66089..7af07bcb34 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -12,6 +12,7 @@ #include "src_global/sltk_atom_arrange.h" #include "src_lcao/local_orbital_ions.h" #include "src_io/print_info.h" +#include "src_pw/symmetry.h" Run_lcao::Run_lcao(){} Run_lcao::~Run_lcao(){} @@ -30,9 +31,8 @@ void Run_lcao::lcao_line(void) //ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running, NLOCAL, NBANDS); DONE(ofs_running, "SETUP UNITCELL"); - // Symmetry analysis. // symmetry analysis should be performed every time the cell is changed - if (SYMMETRY) + if (Symmetry::symm_flag) { symm.analy_sys(); DONE(ofs_running, "SYMMETRY"); diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp index 3294145441..ed37834159 100644 --- a/ABACUS.develop/source/run_pw.cpp +++ b/ABACUS.develop/source/run_pw.cpp @@ -7,6 +7,7 @@ #include "src_io/numerical_basis.h" #include "src_io/numerical_descriptor.h" #include "src_io/print_info.h" +#include "src_pw/symmetry.h" Run_pw::Run_pw(){} Run_pw::~Run_pw(){} @@ -16,7 +17,6 @@ void Run_pw::plane_wave_line(void) TITLE("Run_pw","plane_wave_line"); timer::tick("Run_pw","plane_wave_line",'B'); - // Setup the unitcell. // improvement: a) separating the first reading of the atom_card and subsequent // cell relaxation. b) put NLOCAL and NBANDS as input parameters @@ -24,9 +24,8 @@ void Run_pw::plane_wave_line(void) //ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running, NLOCAL, NBANDS); DONE(ofs_running, "SETUP UNITCELL"); - // Symmetry analysis. // symmetry analysis should be performed every time the cell is changed - if (SYMMETRY) + if (Symmetry::symm_flag) { symm.analy_sys(); DONE(ofs_running, "SYMMETRY"); @@ -41,15 +40,12 @@ void Run_pw::plane_wave_line(void) Print_Info PI; PI.setup_parameters(); - - // Initalize the plane wave basis set pw.gen_pw(ofs_running, ucell, kv); DONE(ofs_running,"INIT PLANEWAVE"); cout << " UNIFORM GRID DIM : " << pw.nx <<" * " << pw.ny <<" * "<< pw.nz << endl; cout << " UNIFORM GRID DIM(BIG): " << pw.nbx <<" * " << pw.nby <<" * "<< pw.nbz << endl; - // mohan add 2010-10-10, just to test the symmetry of a variety // of systems. if(CALCULATION == "test") @@ -64,7 +60,6 @@ void Run_pw::plane_wave_line(void) Pgrid.init(pw.ncx, pw.ncy, pw.ncz, pw.nczp, pw.nrxx, pw.nbz, pw.bz); // mohan add 2010-07-22, update 2011-05-04 - //---------------------------------------------------------- // 1 read in initial data: // a lattice structure:atom_species,atom_positions,lattice vector diff --git a/ABACUS.develop/source/src_global/global_variable.cpp b/ABACUS.develop/source/src_global/global_variable.cpp index e689d1bd7c..e7d0a7c5de 100644 --- a/ABACUS.develop/source/src_global/global_variable.cpp +++ b/ABACUS.develop/source/src_global/global_variable.cpp @@ -41,7 +41,6 @@ string OUT_LEVEL = "ie"; int NSTEP = 20; int NITER = 50; -bool SYMMETRY = false; string BASIS_TYPE = "pw"; //xiaohui add 2013-09-01 string KS_SOLVER = "cg"; //xiaohui add 2013-09-01 double SEARCH_RADIUS = -1.0; diff --git a/ABACUS.develop/source/src_global/global_variable.h b/ABACUS.develop/source/src_global/global_variable.h index 7dcef7b269..b8b0b2a3e1 100644 --- a/ABACUS.develop/source/src_global/global_variable.h +++ b/ABACUS.develop/source/src_global/global_variable.h @@ -44,7 +44,6 @@ extern string OUT_LEVEL; extern int NSTEP; // 8.3 extern int NITER; // 8.4 -extern bool SYMMETRY; // 9 extern string BASIS_TYPE; //xiaohui add 2013-09-01 extern string KS_SOLVER; //xiaohui add 2013-09-01 extern double SEARCH_RADIUS; // 11.1 // mohan add 2011-03-10 diff --git a/ABACUS.develop/source/src_ions/variable_cell.cpp b/ABACUS.develop/source/src_ions/variable_cell.cpp index 9b4a6d39d6..b9635660f0 100644 --- a/ABACUS.develop/source/src_ions/variable_cell.cpp +++ b/ABACUS.develop/source/src_ions/variable_cell.cpp @@ -24,7 +24,7 @@ void Variable_Cell::init_after_vc(void) ucell.setup_cell_after_vc(global_pseudo_dir, global_atom_card, ofs_running); DONE(ofs_running, "SETUP UNITCELL"); - if(SYMMETRY) + if(Symmetry::symm_flag) { symm.analy_sys(); DONE(ofs_running, "SYMMETRY"); @@ -98,7 +98,7 @@ void Variable_Cell::final_calculation_after_vc(void) DONE(ofs_running, "SETUP UNITCELL"); // (6) symmetry analysize. - if (SYMMETRY) + if(Symmetry::symm_flag) { symm.analy_sys(); DONE(ofs_running, "SYMMETRY"); diff --git a/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp b/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp index cbf90cb96c..4e0baba9b5 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp @@ -85,7 +85,7 @@ void ELEC_nscf::nscf(Use_Hamilt_Matrix &uhm) } // add by jingan - if (berryphase::berry_phase_flag && SYMMETRY == 0) + if (berryphase::berry_phase_flag && Symmetry::symm_flag == 0) { berryphase bp; bp.Macroscopic_polarization(); diff --git a/ABACUS.develop/source/src_lcao/force_lcao.cpp b/ABACUS.develop/source/src_lcao/force_lcao.cpp index 34d9c9e912..d224f7d042 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/force_lcao.cpp @@ -255,7 +255,7 @@ void Force_LCAO::start_force(void) // pengfei 2016-12-20 - if(SYMMETRY) + if(Symmetry::symm_flag) { double *pos; double d1,d2,d3; diff --git a/ABACUS.develop/source/src_lcao/stress_lcao.cpp b/ABACUS.develop/source/src_lcao/stress_lcao.cpp index c8f4d46bd1..532a24521c 100644 --- a/ABACUS.develop/source/src_lcao/stress_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/stress_lcao.cpp @@ -234,7 +234,7 @@ void Stress_LCAO::start_stress(double overlap[][3],double tvnl_dphi[][3],double } } - if(SYMMETRY) + if(Symmetry::symm_flag) { symm.stress_symmetry(scs); }//end symmetry diff --git a/ABACUS.develop/source/src_pw/electrons.cpp b/ABACUS.develop/source/src_pw/electrons.cpp index 8f77c377f3..9859c4c642 100644 --- a/ABACUS.develop/source/src_pw/electrons.cpp +++ b/ABACUS.develop/source/src_pw/electrons.cpp @@ -69,7 +69,7 @@ void Electrons::non_self_consistent(const int &istep) // Do a Berry phase polarization calculation if required //======================================================= - if (berryphase::berry_phase_flag && SYMMETRY == 0) + if (berryphase::berry_phase_flag && Symmetry::symm_flag == 0) { berryphase bp; bp.Macroscopic_polarization(); diff --git a/ABACUS.develop/source/src_pw/forces.cpp b/ABACUS.develop/source/src_pw/forces.cpp index 0bb6c6f4ac..f7bd746ff2 100644 --- a/ABACUS.develop/source/src_pw/forces.cpp +++ b/ABACUS.develop/source/src_pw/forces.cpp @@ -2,6 +2,7 @@ #include "global.h" #include "vdwd2.h" #include "vdwd3.h" +#include "symmetry.h" double Forces::output_acc = 1.0e-8; // (Ryd/angstrom). @@ -28,7 +29,7 @@ void Forces::init() { vdwd2.force(stress_vdw_pw, STRESS); } - if(vdwd3.vdwD3) //jiyy add 2019-05-18 + else if(vdwd3.vdwD3) //jiyy add 2019-05-18 { vdwd3.force(stress_vdw_pw, STRESS); } @@ -96,7 +97,7 @@ void Forces::init() } } - if(SYMMETRY) // pengfei 2016-12-20 + if(Symmetry::symm_flag) { double *pos; double d1,d2,d3; diff --git a/ABACUS.develop/source/src_pw/klist.cpp b/ABACUS.develop/source/src_pw/klist.cpp index 57913dfce8..062451a75f 100644 --- a/ABACUS.develop/source/src_pw/klist.cpp +++ b/ABACUS.develop/source/src_pw/klist.cpp @@ -1,6 +1,7 @@ #include "global.h" #include "klist.h" #include "../src_parallel/parallel_global.h" +#include "symmetry.h" kvect::kvect() { @@ -95,7 +96,7 @@ void kvect::set( } // (2) - if (SYMMETRY) + if(Symmetry::symm_flag) { this->ibz_kpoint(symm); this->update_use_ibz(); @@ -280,7 +281,7 @@ bool kvect::read_kpoints(const string &fn) else if (kword == "Line_Cartesian" ) { //cout << " kword = " << kword << endl; - if(SYMMETRY) + if(Symmetry::symm_flag) { WARNING("kvect::read_kpoints","Line mode of k-points is open, please set symmetry to 0."); return 0; @@ -368,7 +369,7 @@ bool kvect::read_kpoints(const string &fn) else if (kword == "Line_Direct" || kword == "L" || kword == "Line" ) { //cout << " kword = " << kword << endl; - if(SYMMETRY) + if(Symmetry::symm_flag) { WARNING("kvect::read_kpoints","Line mode of k-points is open, please set symmetry to 0."); return 0; diff --git a/ABACUS.develop/source/src_pw/stress.cpp b/ABACUS.develop/source/src_pw/stress.cpp index 7c74ebeac6..2c8f0bc4dd 100644 --- a/ABACUS.develop/source/src_pw/stress.cpp +++ b/ABACUS.develop/source/src_pw/stress.cpp @@ -5,6 +5,7 @@ #include "xc_gga_pw.h" #include "efield.h" #include "myfunc.h" +#include "symmetry.h" void Stress::cal_stress() { @@ -27,10 +28,12 @@ void Stress::cal_stress() } //kinetic contribution stres_knl(); - if(SYMMETRY) + + if(Symmetry::symm_flag) { symm.stress_symmetry(sigmakin); }//end symmetry + //hartree contribution stres_har(); @@ -52,7 +55,7 @@ void Stress::cal_stress() //nonlocal stres_nl(); - if(SYMMETRY) + if(Symmetry::symm_flag) { symm.stress_symmetry(sigmanlc); }//end symmetry @@ -67,7 +70,7 @@ void Stress::cal_stress() } } - if(SYMMETRY) + if(Symmetry::symm_flag) { symm.stress_symmetry(sigmatot); } diff --git a/ABACUS.develop/source/src_pw/symmetry.cpp b/ABACUS.develop/source/src_pw/symmetry.cpp index 2cd4600577..60907d3c95 100644 --- a/ABACUS.develop/source/src_pw/symmetry.cpp +++ b/ABACUS.develop/source/src_pw/symmetry.cpp @@ -19,6 +19,10 @@ Symmetry::~Symmetry() } + +bool Symmetry::symm_flag=false; + + void Symmetry::analy_sys(void) { if (available == false) return; diff --git a/ABACUS.develop/source/src_pw/symmetry.h b/ABACUS.develop/source/src_pw/symmetry.h index fd9619cc56..874d48db64 100644 --- a/ABACUS.develop/source/src_pw/symmetry.h +++ b/ABACUS.develop/source/src_pw/symmetry.h @@ -15,6 +15,9 @@ class Symmetry : public Symmetry_Basic Symmetry(); ~Symmetry(); + // mohan add 2021-02-21 + static bool symm_flag; + void analy_sys(); bool available; diff --git a/ABACUS.develop/source/src_pw/symmetry_rho.cpp b/ABACUS.develop/source/src_pw/symmetry_rho.cpp index cd86e17a94..f91202ce61 100644 --- a/ABACUS.develop/source/src_pw/symmetry_rho.cpp +++ b/ABACUS.develop/source/src_pw/symmetry_rho.cpp @@ -15,7 +15,7 @@ void Symmetry_rho::begin(const int &spin_now) const { assert(spin_now < 4);//added by zhengdy-soc - if(!SYMMETRY) return; + if(!Symmetry::symm_flag) return; #ifdef __MPI // parallel version psymm(CHR.rho[spin_now]); diff --git a/ABACUS.develop/source/src_pw/vdwd3.h b/ABACUS.develop/source/src_pw/vdwd3.h index 7447420e46..575ff7f563 100644 --- a/ABACUS.develop/source/src_pw/vdwd3.h +++ b/ABACUS.develop/source/src_pw/vdwd3.h @@ -12,25 +12,25 @@ #ifdef __cplusplus extern "C"{ #endif - void setr0ab_(const int *max_elem,const double *autoang, - double (*r0ab)[94]); - void set_criteria_(double *rthr2,double (*lat)[3],double *tau_max); - void pbcedisp_(const int *max_elem,const int *maxc,const int *n, - double (*xyz)[3],int *iz,double (*c6ab)[5][5][94][94], - int *mxc,double *r2r4,double (*r0ab)[94], - double *rcov,double *rs6,double *rs8, - double *rs10,double *alp6,double *alp8,double *alp10, - int *version,bool *noabc, double *e6,double *e8,double *e10, - double *e12,double *e63,double (*lat)[3],double *rthr2, - int *rep_vdw,double *cn_thr2,int *rep_cn); - void pbcgdisp_(const int *max_elem,const int *maxc,const int *n, - double (*xyz)[3],int *iz,double (*c6ab)[5][5][94][94], - int *mxc,double *r2r4,double (*r0ab)[94], - double *rcov,double *s6,double *s18,double *rs6, - double *rs8,double *rs10,double *alp6,double *alp8, - double *alp10,bool *noabc,int *version,double (*g)[3],double *disp, - double (*stress)[3],double (*sigma)[3],double (*lat)[3],int *rep_v, - int *rep_cn,double *crit_vdw,double *crit_cn); +void setr0ab_(const int *max_elem,const double *autoang, + double (*r0ab)[94]); +void set_criteria_(double *rthr2,double (*lat)[3],double *tau_max); +void pbcedisp_(const int *max_elem,const int *maxc,const int *n, + double (*xyz)[3],int *iz,double (*c6ab)[5][5][94][94], + int *mxc,double *r2r4,double (*r0ab)[94], + double *rcov,double *rs6,double *rs8, + double *rs10,double *alp6,double *alp8,double *alp10, + int *version,bool *noabc, double *e6,double *e8,double *e10, + double *e12,double *e63,double (*lat)[3],double *rthr2, + int *rep_vdw,double *cn_thr2,int *rep_cn); +void pbcgdisp_(const int *max_elem,const int *maxc,const int *n, + double (*xyz)[3],int *iz,double (*c6ab)[5][5][94][94], + int *mxc,double *r2r4,double (*r0ab)[94], + double *rcov,double *s6,double *s18,double *rs6, + double *rs8,double *rs10,double *alp6,double *alp8, + double *alp10,bool *noabc,int *version,double (*g)[3],double *disp, + double (*stress)[3],double (*sigma)[3],double (*lat)[3],int *rep_v, + int *rep_cn,double *crit_vdw,double *crit_cn); #ifdef __cplusplus } #endif @@ -38,96 +38,95 @@ extern "C"{ class Vdwd3 { public: - Vdwd3( const UnitCell_pseudo &unitcell); + Vdwd3( const UnitCell_pseudo &unitcell); - bool vdwD3; - - double energy_result; - double energy(); - - vector< vector > force_result; - vector< vector > force(matrix &stress_result, const bool stress_for_vdw); + bool vdwD3; + + double energy_result; + double energy(); + + vector< vector > force_result; + vector< vector > force(matrix &stress_result, const bool stress_for_vdw); private: - //third-order term? - bool abc; - bool noabc; - //R^2 distance neglect threshold (important for speed in case of large systems) (a.u.) - double rthr2; - //R^2 distance to cutoff for CN_calculation (a.u.) - double cn_thr2; - - string model; - - double s6; - double rs6; - double s18; - double alp; - double rs18; - - //energies - double e6; - double e8; - double e10; - double e12; - //3_th energy - double e63; - - - const int max_elem; - //maximum coordination number references per element - const int maxc; - const int nline; - - const UnitCell_pseudo &ucell; - vector atom_kind; - void atomkind(const UnitCell_pseudo &unitcell); - - void XYZ(const UnitCell_pseudo &unitcell,double (*xyz)[3],int *iz); - - //C6 for all element pairs - vector C6_tmp; - void init_C6_tmp(); - double c6ab[3][5][5][94][94]; - //how many different C6 for one element - int mxc[94]; - void init_mxc(); - int limit(int &i); - void loadc6(); - - //lattice in au - double lat[3][3]; - void setlat( const UnitCell_pseudo &unitcell); - - int version; - //void setfuncpar(int &ver); - - //atomic / values - vector r2r4; - void init_r2r4(); - double* add_r2r4; - //covalent radii - vector rcov; - void init_rcov(); - double* add_rcov; - - //cut-off radii for all element pairs - double r0ab[94][94]; - double tau_max[3]; - //repetitions of the unitcell to match the rthr and c_thr - int rep_vdw[3]; - int rep_cn[3]; - - bool init_set; - void initset(); - - //force and stress - double stress[3][3]; - double sigma[3][3]; - double disp; - - friend void Input_Conv::Convert(); + //third-order term? + bool abc; + bool noabc; + //R^2 distance neglect threshold (important for speed in case of large systems) (a.u.) + double rthr2; + //R^2 distance to cutoff for CN_calculation (a.u.) + double cn_thr2; + + string model; + + double s6; + double rs6; + double s18; + double alp; + double rs18; + + //energies + double e6; + double e8; + double e10; + double e12; + //3_th energy + double e63; + + + const int max_elem; + //maximum coordination number references per element + const int maxc; + const int nline; + + const UnitCell_pseudo &ucell; + vector atom_kind; + void atomkind(const UnitCell_pseudo &unitcell); + + void XYZ(const UnitCell_pseudo &unitcell,double (*xyz)[3],int *iz); + + //C6 for all element pairs + vector C6_tmp; + void init_C6_tmp(); + double c6ab[3][5][5][94][94]; + //how many different C6 for one element + int mxc[94]; + void init_mxc(); + int limit(int &i); + void loadc6(); + + //lattice in au + double lat[3][3]; + void setlat( const UnitCell_pseudo &unitcell); + + int version; + //void setfuncpar(int &ver); + + //atomic / values + vector r2r4; + void init_r2r4(); + double* add_r2r4; + //covalent radii + vector rcov; + void init_rcov(); + double* add_rcov; + + //cut-off radii for all element pairs + double r0ab[94][94]; + double tau_max[3]; + //repetitions of the unitcell to match the rthr and c_thr + int rep_vdw[3]; + int rep_cn[3]; + + bool init_set; + void initset(); + + //force and stress + double stress[3][3]; + double sigma[3][3]; + double disp; + + friend void Input_Conv::Convert(); }; #endif - From 0eba6fa17e0c0acac727276624f8344b88164674 Mon Sep 17 00:00:00 2001 From: mohan Date: Mon, 22 Feb 2021 14:09:39 +0800 Subject: [PATCH 140/233] delete hm.init, use hm.hpw.init instead --- ABACUS.develop/source/run_lcao.cpp | 14 +++++--------- ABACUS.develop/source/run_pw.cpp | 3 +-- ABACUS.develop/source/run_pw.h | 2 +- .../source/src_ions/variable_cell.cpp | 2 +- ABACUS.develop/source/src_pw/hamilt.cpp | 10 ---------- ABACUS.develop/source/src_pw/hamilt.h | 2 -- ABACUS.develop/source/src_pw/hamilt_pw.cpp | 19 +++++++++---------- ABACUS.develop/source/src_pw/hamilt_pw.h | 3 ++- ABACUS.develop/source/src_pw/wavefunc.cpp | 2 +- ABACUS.develop/source/src_pw/wavefunc.h | 5 ++++- 10 files changed, 24 insertions(+), 38 deletions(-) diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index 7af07bcb34..29021e04d3 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -120,24 +120,20 @@ void Run_lcao::lcao_line(void) switch (uoc) { case ALL_LO: - // (4) Init the local wave functions. + // Init the local wave functions. wf.init_local(); - // (5) Init the FFT. + // Init the FFT. UFFT.allocate(); - // (6) Init the hamiltonian. - // first0 stands for nkb, but no used. - // second0 stands for no use hpw.init() - hm.init(0); - // (7) Init the local part of NC pseudopotential. + // Init the local part of NC pseudopotential. ppcell.init_vloc(); - // (8) Init the potential. + // Init the potential. pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs break; case SOME_PW: wf.init(kv.nks); UFFT.allocate(); ppcell.init(ucell.ntype); - hm.init(); + hm.hpw.init(wf.npwx, NPOL, ppcell.nkb, pw.nrxx); ppcell.init_vloc(); ppcell.init_vnl(); pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp index ed37834159..9b3466b837 100644 --- a/ABACUS.develop/source/run_pw.cpp +++ b/ABACUS.develop/source/run_pw.cpp @@ -90,8 +90,7 @@ void Run_pw::plane_wave_line(void) //===================== // init hamiltonian //===================== - hm.init(); -// DONE(ofs_running,"CHARGE, POTENTIAL, WAVE FUNCTINOS ALLOCATION"); + hm.hpw.init(wf.npwx, NPOL, ppcell.nkb, pw.nrxx); //================================= // initalize local pseudopotential diff --git a/ABACUS.develop/source/run_pw.h b/ABACUS.develop/source/run_pw.h index 7a9a3325aa..880c66923c 100644 --- a/ABACUS.develop/source/run_pw.h +++ b/ABACUS.develop/source/run_pw.h @@ -11,7 +11,7 @@ class Run_pw { -public: + public: Run_pw(); ~Run_pw(); diff --git a/ABACUS.develop/source/src_ions/variable_cell.cpp b/ABACUS.develop/source/src_ions/variable_cell.cpp index b9635660f0..8b6aa1297f 100644 --- a/ABACUS.develop/source/src_ions/variable_cell.cpp +++ b/ABACUS.develop/source/src_ions/variable_cell.cpp @@ -144,7 +144,7 @@ void Variable_Cell::final_calculation_after_vc(void) //===================== // init hamiltonian //===================== - hm.init(); + hm.hpw.init(wf.npwx, NPOL, ppcell.nkb, pw.nrxx); //================================= // initalize local pseudopotential diff --git a/ABACUS.develop/source/src_pw/hamilt.cpp b/ABACUS.develop/source/src_pw/hamilt.cpp index c276da9b06..f8f772711b 100644 --- a/ABACUS.develop/source/src_pw/hamilt.cpp +++ b/ABACUS.develop/source/src_pw/hamilt.cpp @@ -12,16 +12,6 @@ Hamilt::~Hamilt() } } -void Hamilt::init(const bool use_pw) -{ - TITLE("Hamilt","init"); -// ofs_running << " use_pw=" << use_pw << endl; - if (use_pw) - { - this->hpw.init(); - } - return; -} void Hamilt::init_k(const int ik) { diff --git a/ABACUS.develop/source/src_pw/hamilt.h b/ABACUS.develop/source/src_pw/hamilt.h index 1a084f24f0..96ebb413ac 100644 --- a/ABACUS.develop/source/src_pw/hamilt.h +++ b/ABACUS.develop/source/src_pw/hamilt.h @@ -12,8 +12,6 @@ class Hamilt Hamilt(); ~Hamilt(); - void init(const bool use_pw = true); - void init_k(const int ik); void init_before_ions(void); diff --git a/ABACUS.develop/source/src_pw/hamilt_pw.cpp b/ABACUS.develop/source/src_pw/hamilt_pw.cpp index fa9798c2fc..de356df88e 100644 --- a/ABACUS.develop/source/src_pw/hamilt_pw.cpp +++ b/ABACUS.develop/source/src_pw/hamilt_pw.cpp @@ -1,4 +1,3 @@ -/* hermit.cpp file */ #include "tools.h" #include "global.h" #include "hamilt_pw.h" @@ -31,7 +30,7 @@ Hamilt_PW::~Hamilt_PW() } -void Hamilt_PW::init(void) +void Hamilt_PW::init(const int &npwx, const int &npol, const int &nkb, const int &nrxx) { TITLE("Hamilt_PW","init"); @@ -41,15 +40,15 @@ void Hamilt_PW::init(void) delete[] Bec; delete[] Ps; - this->hpsi = new complex [wf.npwx * NPOL]; - this->spsi = new complex [wf.npwx * NPOL]; - this->GR_index = new int[pw.nrxx]; - this->Bec = new complex [ppcell.nkb]; - this->Ps = new complex [ppcell.nkb * NPOL]; + this->hpsi = new complex [npwx * npol]; + this->spsi = new complex [npwx * npol]; + this->GR_index = new int[nrxx]; + this->Bec = new complex [nkb]; + this->Ps = new complex [nkb * npol]; - ZEROS(this->hpsi,wf.npwx * NPOL); - ZEROS(this->spsi,wf.npwx * NPOL); - ZEROS(this->GR_index, pw.nrxx); + ZEROS(this->hpsi, npwx * npol); + ZEROS(this->spsi, npwx * npol); + ZEROS(this->GR_index, nrxx); // ofs_running << "\n Hamiltonian allocate done."<npwx, NPOL, ppcell.nkb, pw.nrxx); hm.init_k(ik); //hm.cinitcgg(ik ,NLOCAL, NBANDS, wvf, wvf, ekb[ik]); diff --git a/ABACUS.develop/source/src_pw/wavefunc.h b/ABACUS.develop/source/src_pw/wavefunc.h index d129335811..ba8c56df99 100644 --- a/ABACUS.develop/source/src_pw/wavefunc.h +++ b/ABACUS.develop/source/src_pw/wavefunc.h @@ -39,16 +39,19 @@ class wavefunc : public WF_atomic // wanf2: save given localized orbitals. void LCAO_in_pw_k(const int &ik, ComplexMatrix &wvf); - void LCAO_in_pw_k_q(const int &ik, ComplexMatrix &wvf, Vector3 q); // pengfei 2016-11-23 + void LCAO_in_pw_k_q(const int &ik, ComplexMatrix &wvf, Vector3 q); // pengfei 2016-11-23 // evc: get the initial wave functions from diagnalized the PAO // orbitals first. void diago_PAO_in_pw_k(const int &ik, ComplexMatrix &wvf); + // used if k dependent staff is ready. void prepare_k(void); + void diago_PAO_in_pw_k2(const int &ik, ComplexMatrix &wvf); int get_R(int ix, int iy, int iz); // pengfei 2016-11-23 + int iw2it( int iw); int iw2ia( int iw); void init_after_vc(const int nks); //LiuXh 20180515 From 3cb628a8b0c9c930f871cece301d2d4a3227f5c7 Mon Sep 17 00:00:00 2001 From: mohan Date: Mon, 22 Feb 2021 17:49:35 +0800 Subject: [PATCH 141/233] delete some variables in src_global/constants.h --- ABACUS.develop/source/input.cpp | 6 ++-- ABACUS.develop/source/src_global/constants.h | 34 ------------------- ABACUS.develop/source/src_pw/klist.cpp | 4 ++- ABACUS.develop/source/src_pw/pseudo_h.cpp | 5 ++- .../source/src_pw/pseudopot_cell_vl.cpp | 30 ++-------------- .../source/src_pw/pseudopot_cell_vnl.cpp | 5 ++- 6 files changed, 17 insertions(+), 67 deletions(-) diff --git a/ABACUS.develop/source/input.cpp b/ABACUS.develop/source/input.cpp index aa39c038c9..89d6e0cf51 100644 --- a/ABACUS.develop/source/input.cpp +++ b/ABACUS.develop/source/input.cpp @@ -2553,15 +2553,15 @@ void Input::Check(void) WARNING_QUIT("Input","wrong start_wfc, please use 'atomic' or 'random' or 'file' "); } - if (nbands > nbndxx) + if (nbands > 100000) { - WARNING_QUIT("Input","nbnd out of range, increase nbndxx!"); + WARNING_QUIT("Input","nbnd >100000, out of range"); } if ( nelec > 0 && nbands > 0 && nelec > 2*nbands ) { WARNING_QUIT("Input","nelec > 2*nbnd , bands not enough!"); } - if (nspin < 1 || nspin > nspinx) + if (nspin < 1 || nspin > 4) { WARNING_QUIT("Input","nspin out of range!"); } diff --git a/ABACUS.develop/source/src_global/constants.h b/ABACUS.develop/source/src_global/constants.h index c4e9fc1947..9b39291dca 100644 --- a/ABACUS.develop/source/src_global/constants.h +++ b/ABACUS.develop/source/src_global/constants.h @@ -101,38 +101,4 @@ const double eps32 = 1.0e-32; const double epsr = 1.0e-6; const double epsg = 1.0e-10; -//========================================================== -// EXPLAIN : max constants we limit.(x stands for max) -// NAME : nspinx( max number of sionors ) -// NAME : ntypx( max number of different types of atom) -// NAME : npsx( max number of different PPs) -// NAME : natx( maximum number of atoms ) -// NAME : nbndxx( maximum number of electronic states ) -// NAME : MAX_KPOINTS( max number of k-points) -// NAME : nchix( max number of atomic wavefunctions per atom) -// NAME : ndmx( max number of points in the atomic radial mesh) -//========================================================== -const int nspinx= 4; -const int ntypx = 50; -const int npsx = ntypx; -const int natx = 1000000; -const int nbndxx= 4000000; -const int MAX_KPOINTS = 40000;// npk -const int nchix = 10; -const int nchix_nc = 20; -const int ndmx = 2000; - -//========================================================== -// NAME : lmaxx( max non-local angular momentum) -// NAME : nbrx( max number of beta functions ) -// NAME : lqmax( max number of angular momenta of Q) -// NAME : nqfx( max number of coefficients in Q smoothing) -//========================================================== -#ifndef __EPM -const int lmaxx = 3; -const int nbrx = 10; -const int nbrx_nc = 20; -const int lqmax = 2*lmaxx + 1; -const int nqfx = 8; -#endif #endif diff --git a/ABACUS.develop/source/src_pw/klist.cpp b/ABACUS.develop/source/src_pw/klist.cpp index 062451a75f..0cb42d25ba 100644 --- a/ABACUS.develop/source/src_pw/klist.cpp +++ b/ABACUS.develop/source/src_pw/klist.cpp @@ -225,7 +225,9 @@ bool kvect::read_kpoints(const string &fn) this->k_kword = kword; //LiuXh add 20180619 - if (nkstot > MAX_KPOINTS) + // mohan update 2021-02-22 + int max_kpoints = 100000; + if (nkstot > 100000) { ofs_warning << " nkstot > MAX_KPOINTS" << endl; return 0; diff --git a/ABACUS.develop/source/src_pw/pseudo_h.cpp b/ABACUS.develop/source/src_pw/pseudo_h.cpp index 5cdb66b4e2..885c063829 100644 --- a/ABACUS.develop/source/src_pw/pseudo_h.cpp +++ b/ABACUS.develop/source/src_pw/pseudo_h.cpp @@ -55,7 +55,10 @@ void pseudo_h::set_pseudo_h(const Pseudopot_upf &upf) this->lmax = upf.lmax; this->mesh = upf.mesh; - + + // mohan update 2021-02-22 + // max number of points in the atomic radial mesh + int ndmx = 2000; if (this->mesh > ndmx) { cout << "\n set_pseudo_h, too many grid points,"; diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_vl.cpp b/ABACUS.develop/source/src_pw/pseudopot_cell_vl.cpp index d8100ac852..407a131759 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_vl.cpp +++ b/ABACUS.develop/source/src_pw/pseudopot_cell_vl.cpp @@ -81,38 +81,14 @@ void pseudopot_cell_vl::allocate(void) for (int it = 0; it < ucell.ntype; it++) { this->numeric[it] = true; } + // mohan change global variable 'npsx' to local variable, + // 2021-02-22 + int npsx = 50; delete[] zp; this->zp = new double[npsx]; ZEROS(zp, npsx); // npsx( max number of different PPs) - /* - cc.create(npsx, 2); - alpc.create(npsx, 2); - aps.create(npsx, 4, 6); - alps.create(npsx, 4, 3); - - a_nlcc = new double[npsx]; - ZEROS(a_nlcc, npsx); - - b_nlcc = new double[npsx]; - ZEROS(b_nlcc, npsx); - - alpha_nlcc = new double[npsx]; - ZEROS(alpha_nlcc, npsx); - - nlc = new int[npsx]; - ZEROS(nlc, npsx); - - nnl = new int[npsx]; - ZEROS(nnl, npsx); - - lmax = new int[npsx]; - ZEROS(lmax, npsx); - - lloc = new int[npsx]; - ZEROS(lloc, npsx); - */ return; } diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.cpp b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.cpp index ebc6cc56f3..8d6501aec1 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.cpp +++ b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.cpp @@ -104,7 +104,10 @@ void pseudopot_cell_vnl::init(const int ntype, const bool allocate_vkb) if(NSPIN!=4) this->tab.create(ntype, nbrx, NQX); else this->tab.create(ntype, nbrx_nc, NQX); - // nchix is defined in constant.h + + // mohan update 2021-02-22 + int nchix = 10; + int nchix_nc = 20; // nchix : max number of atomic wavefunctions per atom if(NSPIN!=4) this->tab_at.create(ntype, nchix, NQX); else this->tab_at.create(ntype, nchix_nc, NQX); From 7500825555a1255b5ceb13af0837a1308b6a386a Mon Sep 17 00:00:00 2001 From: mohan Date: Mon, 22 Feb 2021 20:02:40 +0800 Subject: [PATCH 142/233] delete eps as global variables in constants.h --- ABACUS.develop/source/src_global/constants.h | 6 -- ABACUS.develop/source/src_io/to_wannier90.cpp | 64 ++++++++++++------- .../source/src_ions/lattice_change_basic.cpp | 2 +- .../source/src_lcao/ORB_nonlocal.cpp | 6 +- ABACUS.develop/source/src_lcao/force_lcao.cpp | 19 ++++-- .../source/src_lcao/stress_lcao.cpp | 2 +- ABACUS.develop/source/src_pw/ions.cpp | 6 +- ABACUS.develop/source/src_pw/mdNVE.cpp | 2 +- ABACUS.develop/source/src_pw/mdNVT.cpp | 2 +- .../source/src_pw/pseudopot_cell_vnl.cpp | 11 +++- ABACUS.develop/source/src_pw/pw_basis.cpp | 2 +- ABACUS.develop/source/src_pw/stress.cpp | 6 +- 12 files changed, 79 insertions(+), 49 deletions(-) diff --git a/ABACUS.develop/source/src_global/constants.h b/ABACUS.develop/source/src_global/constants.h index 9b39291dca..89bc47ae3f 100644 --- a/ABACUS.develop/source/src_global/constants.h +++ b/ABACUS.develop/source/src_global/constants.h @@ -11,7 +11,6 @@ using namespace std; // GLOBAL CONSTANTS //========================================================== - //========================================================== // EXPLAIN : constants // NAME : pi @@ -93,11 +92,6 @@ const double AMCONV = 1.660538782e-27 / 9.10938215e-31 * 0.50; // mass conversio const double uakbar = 147105.0; // pressure conversion from Ry/(a.u)^3 to K // zero up to a given accuracy -const double eps4 = 1.0e-4; -const double eps8 = 1.0e-8; -const double eps9 = 1.0e-9; -const double eps16 = 1.0e-16; -const double eps32 = 1.0e-32; const double epsr = 1.0e-6; const double epsg = 1.0e-10; diff --git a/ABACUS.develop/source/src_io/to_wannier90.cpp b/ABACUS.develop/source/src_io/to_wannier90.cpp index 14759a31a6..6601106b13 100644 --- a/ABACUS.develop/source/src_io/to_wannier90.cpp +++ b/ABACUS.develop/source/src_io/to_wannier90.cpp @@ -97,15 +97,24 @@ void toWannier90::read_nnkp() real_lattice_nnkp = real_lattice_nnkp / ucell.lat0_angstrom; - if(abs(real_lattice_nnkp.e11 - ucell.latvec.e11) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error real_lattice in *.nnkp file"); - if(abs(real_lattice_nnkp.e12 - ucell.latvec.e12) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error real_lattice in *.nnkp file"); - if(abs(real_lattice_nnkp.e13 - ucell.latvec.e13) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error real_lattice in *.nnkp file"); - if(abs(real_lattice_nnkp.e21 - ucell.latvec.e21) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error real_lattice in *.nnkp file"); - if(abs(real_lattice_nnkp.e22 - ucell.latvec.e22) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error real_lattice in *.nnkp file"); - if(abs(real_lattice_nnkp.e23 - ucell.latvec.e23) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error real_lattice in *.nnkp file"); - if(abs(real_lattice_nnkp.e31 - ucell.latvec.e31) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error real_lattice in *.nnkp file"); - if(abs(real_lattice_nnkp.e32 - ucell.latvec.e32) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error real_lattice in *.nnkp file"); - if(abs(real_lattice_nnkp.e33 - ucell.latvec.e33) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error real_lattice in *.nnkp file"); + if(abs(real_lattice_nnkp.e11 - ucell.latvec.e11) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error real_lattice in *.nnkp file"); + if(abs(real_lattice_nnkp.e12 - ucell.latvec.e12) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error real_lattice in *.nnkp file"); + if(abs(real_lattice_nnkp.e13 - ucell.latvec.e13) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error real_lattice in *.nnkp file"); + if(abs(real_lattice_nnkp.e21 - ucell.latvec.e21) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error real_lattice in *.nnkp file"); + if(abs(real_lattice_nnkp.e22 - ucell.latvec.e22) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error real_lattice in *.nnkp file"); + if(abs(real_lattice_nnkp.e23 - ucell.latvec.e23) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error real_lattice in *.nnkp file"); + if(abs(real_lattice_nnkp.e31 - ucell.latvec.e31) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error real_lattice in *.nnkp file"); + if(abs(real_lattice_nnkp.e32 - ucell.latvec.e32) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error real_lattice in *.nnkp file"); + if(abs(real_lattice_nnkp.e33 - ucell.latvec.e33) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error real_lattice in *.nnkp file"); } @@ -119,16 +128,24 @@ void toWannier90::read_nnkp() const double tpiba_angstrom = TWO_PI / ucell.lat0_angstrom; recip_lattice_nnkp = recip_lattice_nnkp / tpiba_angstrom; - if(abs(recip_lattice_nnkp.e11 - ucell.G.e11) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error recip_lattice in *.nnkp file"); - if(abs(recip_lattice_nnkp.e12 - ucell.G.e12) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error recip_lattice in *.nnkp file"); - if(abs(recip_lattice_nnkp.e13 - ucell.G.e13) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error recip_lattice in *.nnkp file"); - if(abs(recip_lattice_nnkp.e21 - ucell.G.e21) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error recip_lattice in *.nnkp file"); - if(abs(recip_lattice_nnkp.e22 - ucell.G.e22) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error recip_lattice in *.nnkp file"); - if(abs(recip_lattice_nnkp.e23 - ucell.G.e23) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error recip_lattice in *.nnkp file"); - if(abs(recip_lattice_nnkp.e31 - ucell.G.e31) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error recip_lattice in *.nnkp file"); - if(abs(recip_lattice_nnkp.e32 - ucell.G.e32) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error recip_lattice in *.nnkp file"); - if(abs(recip_lattice_nnkp.e33 - ucell.G.e33) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error recip_lattice in *.nnkp file"); - + if(abs(recip_lattice_nnkp.e11 - ucell.G.e11) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error recip_lattice in *.nnkp file"); + if(abs(recip_lattice_nnkp.e12 - ucell.G.e12) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error recip_lattice in *.nnkp file"); + if(abs(recip_lattice_nnkp.e13 - ucell.G.e13) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error recip_lattice in *.nnkp file"); + if(abs(recip_lattice_nnkp.e21 - ucell.G.e21) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error recip_lattice in *.nnkp file"); + if(abs(recip_lattice_nnkp.e22 - ucell.G.e22) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error recip_lattice in *.nnkp file"); + if(abs(recip_lattice_nnkp.e23 - ucell.G.e23) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error recip_lattice in *.nnkp file"); + if(abs(recip_lattice_nnkp.e31 - ucell.G.e31) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error recip_lattice in *.nnkp file"); + if(abs(recip_lattice_nnkp.e32 - ucell.G.e32) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error recip_lattice in *.nnkp file"); + if(abs(recip_lattice_nnkp.e33 - ucell.G.e33) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error recip_lattice in *.nnkp file"); } if( SCAN_BEGIN(nnkp_read,"kpoints") ) @@ -142,9 +159,12 @@ void toWannier90::read_nnkp() for(int ik = 0; ik < numkpt_nnkp; ik++) { nnkp_read >> kpoints_direct_nnkp[ik].x >> kpoints_direct_nnkp[ik].y >> kpoints_direct_nnkp[ik].z; - if(abs(kpoints_direct_nnkp[ik].x - kv.kvec_d[ik].x) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error kpoints in *.nnkp file"); - if(abs(kpoints_direct_nnkp[ik].y - kv.kvec_d[ik].y) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error kpoints in *.nnkp file"); - if(abs(kpoints_direct_nnkp[ik].z - kv.kvec_d[ik].z) > eps4) WARNING_QUIT("toWannier90::read_nnkp","Error kpoints in *.nnkp file"); + if(abs(kpoints_direct_nnkp[ik].x - kv.kvec_d[ik].x) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error kpoints in *.nnkp file"); + if(abs(kpoints_direct_nnkp[ik].y - kv.kvec_d[ik].y) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error kpoints in *.nnkp file"); + if(abs(kpoints_direct_nnkp[ik].z - kv.kvec_d[ik].z) > 1.0e-4) + WARNING_QUIT("toWannier90::read_nnkp","Error kpoints in *.nnkp file"); } delete[] kpoints_direct_nnkp; diff --git a/ABACUS.develop/source/src_ions/lattice_change_basic.cpp b/ABACUS.develop/source/src_ions/lattice_change_basic.cpp index c5bad64064..0482db57e0 100644 --- a/ABACUS.develop/source/src_ions/lattice_change_basic.cpp +++ b/ABACUS.develop/source/src_ions/lattice_change_basic.cpp @@ -175,7 +175,7 @@ void Lattice_Change_Basic::check_converged(matrix &stress, double *grad) } double unit_transform = 0.0; - unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * eps8; + unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * 1.0e-8; Lattice_Change_Basic::largest_grad = Lattice_Change_Basic::largest_grad * unit_transform; stress_ii_max = stress_ii_max * unit_transform; diff --git a/ABACUS.develop/source/src_lcao/ORB_nonlocal.cpp b/ABACUS.develop/source/src_lcao/ORB_nonlocal.cpp index 7d8f912ac8..bf60401f0e 100644 --- a/ABACUS.develop/source/src_lcao/ORB_nonlocal.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_nonlocal.cpp @@ -124,7 +124,8 @@ void Numerical_Nonlocal::set_type_info for (int L2 = 0; L2 < nproj_soc; L2++) { this->Coefficient_D_so(is, L1, L2) = Coefficient_D_in_so(L1 + nproj_soc*is1, L2 + nproj_soc*is2); - if(fabs(this->Coefficient_D_so(is, L1, L2).real())>eps8 || fabs(this->Coefficient_D_so(is, L1, L2).imag())>eps8) + if(fabs(this->Coefficient_D_so(is, L1, L2).real())>1.0e-8 || + fabs(this->Coefficient_D_so(is, L1, L2).imag())>1.0e-8 ) { this->index1_soc[is][non_zero_count_soc[is]] = L1; this->index2_soc[is][non_zero_count_soc[is]] = L2; @@ -150,7 +151,8 @@ void Numerical_Nonlocal::set_type_info { if(is==1||is==2) this->Coefficient_D_so(is, L1, L2) = ZERO; else this->Coefficient_D_so(is, L1, L2) = Coefficient_D_in_so(L1 + nproj_soc*is1, L2 + nproj_soc*is2); - if(abs(this->Coefficient_D_so(is, L1, L2).real())>eps8 || abs(this->Coefficient_D_so(is, L1, L2).imag())>eps8) + if(abs(this->Coefficient_D_so(is, L1, L2).real())>1.0e-8 + || abs(this->Coefficient_D_so(is, L1, L2).imag())>1.0e-8) { this->index1_soc[is][non_zero_count_soc[is]] = L1; this->index2_soc[is][non_zero_count_soc[is]] = L2; diff --git a/ABACUS.develop/source/src_lcao/force_lcao.cpp b/ABACUS.develop/source/src_lcao/force_lcao.cpp index d224f7d042..f7a17cd088 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/force_lcao.cpp @@ -926,13 +926,15 @@ void Force_LCAO::cal_force_scc(void) void Force_LCAO::cal_stress(matrix &stress) { - Stress_LCAO SS; - SS.allocate(); - SS.start_stress(this->soverlap, this->stvnl_dphi, this->svnl_dbeta, this->svl_dphi, this->stress_vdw); + TITLE("Force_LCAO","cal_stress"); - double unit_transform = 0.0; - unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * eps8; - double external_stress[3] = {PRESS1,PRESS2,PRESS3}; + Stress_LCAO SS; + SS.allocate(); + SS.start_stress(this->soverlap, this->stvnl_dphi, this->svnl_dbeta, this->svl_dphi, this->stress_vdw); + + double unit_transform = 0.0; + unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * 1.0e-8; + double external_stress[3] = {PRESS1,PRESS2,PRESS3}; for(int i=0;i<3;i++) { @@ -949,7 +951,10 @@ void Force_LCAO::cal_stress(matrix &stress) } PRESSURE = (SS.scs[0][0]+SS.scs[1][1]+SS.scs[2][2])/3; - if(INPUT.dft_plus_u) PRESSURE += (dftu.stress_dftu.at(0).at(0) + dftu.stress_dftu.at(1).at(1) + dftu.stress_dftu.at(2).at(2))/3.0; + if(INPUT.dft_plus_u) + { + PRESSURE += (dftu.stress_dftu.at(0).at(0) + dftu.stress_dftu.at(1).at(1) + dftu.stress_dftu.at(2).at(2))/3.0; + } return; } diff --git a/ABACUS.develop/source/src_lcao/stress_lcao.cpp b/ABACUS.develop/source/src_lcao/stress_lcao.cpp index 532a24521c..cd01ba876f 100644 --- a/ABACUS.develop/source/src_lcao/stress_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/stress_lcao.cpp @@ -360,7 +360,7 @@ void Stress_LCAO::printstress_total(bool ry) if(!ry) { - unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * eps8; + unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * 1.0e-8; } // cout.setf(ios::fixed); diff --git a/ABACUS.develop/source/src_pw/ions.cpp b/ABACUS.develop/source/src_pw/ions.cpp index 08f1c5eb34..c15bebecb9 100644 --- a/ABACUS.develop/source/src_pw/ions.cpp +++ b/ABACUS.develop/source/src_pw/ions.cpp @@ -312,7 +312,7 @@ bool Ions::force_stress(const int &istep, int &force_step, int &stress_step) // stress.create(3,3); double unit_transform = 0.0; - unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * eps8; + unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * 1.0e-8; double external_stress[3] = {PRESS1,PRESS2,PRESS3}; for(int i=0;i<3;i++) { @@ -373,7 +373,7 @@ bool Ions::force_stress(const int &istep, int &force_step, int &stress_step) // stress.create(3,3); double unit_transform = 0.0; - unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * eps8; + unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * 1.0e-8; double external_stress[3] = {PRESS1,PRESS2,PRESS3}; for(int i=0;i<3;i++) { @@ -447,7 +447,7 @@ bool Ions::force_stress(const int &istep, int &force_step, int &stress_step) // stress.create(3,3); double unit_transform = 0.0; - unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * eps8; + unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * 1.0e-8; double external_stress[3] = {PRESS1,PRESS2,PRESS3}; for(int i=0;i<3;i++) { diff --git a/ABACUS.develop/source/src_pw/mdNVE.cpp b/ABACUS.develop/source/src_pw/mdNVE.cpp index b34e3fb03d..ffb3a199f5 100644 --- a/ABACUS.develop/source/src_pw/mdNVE.cpp +++ b/ABACUS.develop/source/src_pw/mdNVE.cpp @@ -127,7 +127,7 @@ void mdNVE::runNVE(int step1){ for(int i=0;i<3;i++) press += stress_lcao(i,i)/3; press += twiceKE/3/ucell.omega; //output virtual press = 2/3*Ek/V + sum(sigma[i][i])/3 - double unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * eps8 ; + double unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * 1.0e-8 ; cout<<"Virtual Pressure is "<calculate_nqx(pw.ecutwfc,DQ) * cell_factor; //LiuXh add 20180619 // nqx = (sqrt(ecutwfc)/dq+4)*cell_factor; // - // nbrx is defined in constant.h + + + // mohan update 2021-02-22 + const int nbrx = 10; + const int nbrx_nc = 20; // max number of beta functions if(NSPIN!=4) this->tab.create(ntype, nbrx, NQX); else this->tab.create(ntype, nbrx_nc, NQX); @@ -570,6 +574,11 @@ void pseudopot_cell_vnl::init_vnl_alpha(void) // pengfei Li 2018-3-23 } } } + + + // max number of beta functions + const int nbrx = 10; + const double pref = FOUR_PI / sqrt(ucell.omega); this->tab_alpha.create(ucell.ntype, nbrx, lmaxkb+2, NQX); this->tab_alpha.zero_out(); diff --git a/ABACUS.develop/source/src_pw/pw_basis.cpp b/ABACUS.develop/source/src_pw/pw_basis.cpp index 9ac5f866ee..900ee567fc 100644 --- a/ABACUS.develop/source/src_pw/pw_basis.cpp +++ b/ABACUS.develop/source/src_pw/pw_basis.cpp @@ -681,7 +681,7 @@ void PW_Basis::get_nggm(const int ngmc_local) for (int ig = 1; ig < ngmc_local; ig++) { - if (abs(this->gg[ig] - tmp[ng]) > eps8) + if (abs(this->gg[ig] - tmp[ng]) > 1.0e-8) { ng++; tmp[ng] = this->gg[ig]; diff --git a/ABACUS.develop/source/src_pw/stress.cpp b/ABACUS.develop/source/src_pw/stress.cpp index 2c8f0bc4dd..12e955b006 100644 --- a/ABACUS.develop/source/src_pw/stress.cpp +++ b/ABACUS.develop/source/src_pw/stress.cpp @@ -164,12 +164,12 @@ void Stress::printstress_total (bool ry) if(!ry) { - unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * eps8; + unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * 1.0e-8; } -// cout.setf(ios::fixed); + // cout.setf(ios::fixed); - //ofs_running << setiosflags(ios::right); + //ofs_running << setiosflags(ios::right); ofs_running << setprecision(8) << setiosflags(ios::showpos) << setiosflags(ios::fixed) << endl; NEW_PART("TOTAL-STRESS (KBAR)");//Ryd/(a.u.)^3 From e0b996b40f96da62dc33c07f0a1277fffad4260e Mon Sep 17 00:00:00 2001 From: mohan Date: Mon, 22 Feb 2021 20:29:11 +0800 Subject: [PATCH 143/233] delete some useless codes in pseudopote_cell_vl and vnl and potential --- ABACUS.develop/source/src_pw/potential.cpp | 312 +++--------------- ABACUS.develop/source/src_pw/potential.h | 2 - .../source/src_pw/pseudopot_cell_vl.cpp | 19 +- .../source/src_pw/pseudopot_cell_vl.h | 15 +- .../source/src_pw/pseudopot_cell_vnl.h | 26 +- 5 files changed, 75 insertions(+), 299 deletions(-) diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index b20c611e71..fb05dbcd02 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -9,7 +9,6 @@ potential::potential() { - this->test = 0; vltot = new double[1]; vrs1 = new double[1]; this->out_potential = 0; @@ -953,7 +952,7 @@ void potential::set_vrs(void) } //end subroutine set_vrs // ---------------------------------------------------------------------- -void potential::newd() +void potential::newd(void) { if (test_potential) TITLE("potential","newd"); @@ -966,83 +965,58 @@ void potential::newd() // This routine computes the integral of the effective potential with // the Q function and adds it to the bare ionic D term which is used // to compute the non-local term in the US scheme. - if (!ppcell.okvan) - { - // no ultrasoft potentials: use bare coefficients for projectors - // if( spin_orbital) .... - // else if(noncolin) .... - for (int iat=0; iat(0.0 , 0.0); - ppcell.deeq_nc(is, iat, jh, ih) = complex(0.0 , 0.0); - } - else if(is==2) - { - ppcell.deeq_nc(is, iat, ih, jh) = complex(0.0 , 0.0); - ppcell.deeq_nc(is, iat, jh, ih) = complex(0.0 , 0.0); - } - else if(is==3) - { - ppcell.deeq_nc(is, iat, ih, jh) = ppcell.dvan(it, ih, jh); - ppcell.deeq_nc(is, iat, jh, ih) = ppcell.dvan(it, ih, jh); - } - } - else{ - ppcell.deeq(is, iat, ih, jh) = ppcell.dvan(it, ih, jh); - ppcell.deeq(is, iat, jh, ih) = ppcell.dvan(it, ih, jh); - } - } - } - } - } - return; - } - - //==================== - // if use PAW method - //==================== - /* if (okpaw) then - ! Add paw contributions to deeq (computed in paw_potential) - do na=1,nat - nt = ityp(na) - IF (.not.upf(nt)%tpawp) cycle - ijh=0 - do ih=1,nh(nt) - do jh=ih,nh(nt) - ijh=ijh+1 - deeq(ih,jh,na,1:nspin) = deeq(ih,jh,na,1:nspin) & - + ddd_paw(ijh,na,1:nspin) - deeq(jh,ih,na,1:nspin) = deeq(ih,jh,na,1:nspin) - end do - end do - end do - end IF - */ - return; + // no ultrasoft potentials: use bare coefficients for projectors + // if( spin_orbital) .... + // else if(noncolin) .... + for (int iat=0; iat(0.0 , 0.0); + ppcell.deeq_nc(is, iat, jh, ih) = complex(0.0 , 0.0); + } + else if(is==2) + { + ppcell.deeq_nc(is, iat, ih, jh) = complex(0.0 , 0.0); + ppcell.deeq_nc(is, iat, jh, ih) = complex(0.0 , 0.0); + } + else if(is==3) + { + ppcell.deeq_nc(is, iat, ih, jh) = ppcell.dvan(it, ih, jh); + ppcell.deeq_nc(is, iat, jh, ih) = ppcell.dvan(it, ih, jh); + } + } + else{ + ppcell.deeq(is, iat, ih, jh) = ppcell.dvan(it, ih, jh); + ppcell.deeq(is, iat, jh, ih) = ppcell.dvan(it, ih, jh); + } + } + } + } + } + return; } // end subroutine newd void potential::print_pot(ofstream &ofs)const @@ -1057,185 +1031,7 @@ void potential::print_pot(ofstream &ofs)const } -/* -// from mix_potential.f90 -//----------------------------------------------------------------------- -void potential::mix_potential (int ndim, double *vout, double *vin, double alphamix, - double &dr2, double tr2, int iter, int n_iter, string filename, - bool &conv) -{ - cout << "\n ==== mix_potential() ==== "; - //----------------------------------------------------------------------- - // - // Modified Broyden"s method for potential/charge density mixing - // D.D.Johnson, PRB 38, 12807 (1988) - // On input : - // ndim dimension of arrays vout, vin - // vout output potential/rho at current iteration - // vin potential/rho at previous iteration - // alphamix mixing factor (0 < alphamix <= 1) - // tr2 threshold for selfconsistency - // iter current iteration number - // n_iter number of iterations used in the mixing - // filename if present save previous iterations on file "filename" - // otherwise keep everything in memory - // On output: - // dr2 [(vout-vin)/ndim]^2 - // vin mixed potential - // vout vout-vin - // conv true if dr2 <= tr2 - - // First the dummy variables - // character (len=42) :: filename - // integer :: ndim, iter, n_iter - // real(kind=DP) :: vout (ndim), vin (ndim), alphamix, dr2, tr2 - // logical :: conv - - // Here the local variables - - // max number of iterations used in mixing: n_iter must be .le. maxter - // parameter : - int maxter = 8; - - int n, i, j, *iwork, info, iter_used, - ipos, inext, ndimtot; - iwork = new int[maxter]; - assert(iwork != 0); - // work space containing info from previous iterations: - // must be kept in memory and saved between calls if filename=' ' - - // allocatable, save :: - matrix df, dv ; - double *vinsave, *ework; - ework = new double[maxter]; - assert(ework != 0); - matrix beta (maxter, maxter); - double gamma, norm; - - // adjustable parameters as suggested in the original paper - double *w, w0; - w = new double[maxter]; - // data : - w0 = 0.010 ; - // w / maxter * 1.0 / ? - - double *work; - work = new double[maxter];//? - assert(work != 0); - start_clock ("mix_pot"); - - if (iter < 1) - cout << "\n mix_potential, iter is wrong"; - if (nmix > maxter) - cout << "\n mix_potential, nmix too big"; - if (ndim <= 0) - cout << "\n mix_potential, ndim <= 0"; - - for(n=0;n n_iter - iter_used = (iter - 1 < nmix)?(iter-1):nmix; // min - // ipos is the position in which results from the present iteraction - // are stored. ipos=iter-1 until ipos=n_iter, then back to 1,2,... - - ipos = iter - 1 - ( (iter - 2) / nmix) * nmix; - if (iter > 1){ - for(n=0;n 0) TITLE("pseudopot_cell_vl","init_vloc"); @@ -30,13 +32,9 @@ void pseudopot_cell_vl::init_vloc(void) for (int it = 0; it < ucell.ntype; it++) { - // ofs_running << " it=" << it << endl; - // ofs_running << " numeric[it]=" << numeric[it] << endl; - const Atom* atom = &ucell.atoms[it]; ZEROS(vloc1d, pw.nggm); - //HLX(05-24-06): add zp[it]=ucell.atoms[it].zv; read zp[it] from atoms this->zp[it] = atom->zv; @@ -56,17 +54,17 @@ void pseudopot_cell_vl::init_vloc(void) WARNING_QUIT("init_vloc","not available now."); } - dcopy(vloc1d, this->vloc,it); //HLX(05-23-06): dcopy might have problems, check later! + dcopy(vloc1d, this->vloc,it); } - delete [] vloc1d; + delete[] vloc1d; this->print_vloc(); timer::tick("ppcell_vl","init_vloc",'C'); return; -} // end subroutine init_vloc +} void pseudopot_cell_vl::allocate(void) @@ -82,12 +80,12 @@ void pseudopot_cell_vl::allocate(void) { this->numeric[it] = true; } // mohan change global variable 'npsx' to local variable, + // npsx( max number of different PPs) // 2021-02-22 int npsx = 50; delete[] zp; this->zp = new double[npsx]; ZEROS(zp, npsx); - // npsx( max number of different PPs) return; } @@ -99,7 +97,7 @@ void pseudopot_cell_vl::allocate(void) ! !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/ -// from vloc_of_g.f90 + // Here we always have numeric form, i.e. numeric=ture void pseudopot_cell_vl::vloc_of_g( const int& msh, @@ -200,6 +198,7 @@ void pseudopot_cell_vl::vloc_of_g( return; } // end subroutine vloc_of_g + void pseudopot_cell_vl::print_vloc(void)const { if(MY_RANK!=0) return; //mohan fix bug 2011-10-13 diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_vl.h b/ABACUS.develop/source/src_pw/pseudopot_cell_vl.h index 18469bedce..3a266c7e59 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_vl.h +++ b/ABACUS.develop/source/src_pw/pseudopot_cell_vl.h @@ -14,24 +14,15 @@ class pseudopot_cell_vl pseudopot_cell_vl(); ~pseudopot_cell_vl(); - matrix vloc;//(ntype,ngl),the local potential for each atom type(ntype,ngl) - bool *numeric;//[ntype], =true - void init_vloc(void); + matrix vloc; //(ntype,ngl),the local potential for each atom type(ntype,ngl) + bool *numeric; //[ntype], =true + private: double *zp; // (npsx),the charge of the pseudopotential -// double *a_nlcc; // (npsx), nonlinear core correction coefficients: -// double *b_nlcc; // (npsx), rho_c(r) = (a_c + b_c*r^2) exp(-alpha_c*r^2) -// double *alpha_nlcc; // (npsx) - -// int *nlc; //(npsx), number of erf functions -// int *nnl; //(npsx), number of the gaussian functions -// int *lmax; //(npsx), maximum angular momentum of the pseudopot -// int *lloc; //(npsx), angular momentum of the part taken as local - void allocate(void); // generate vloc for a particular atom type. diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h index 2b0af115d4..5a865bfc48 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h +++ b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h @@ -10,35 +10,33 @@ #include "../src_lcao/ORB_gen_tables.h" //========================================================== -// CLASS : -// NAME : pseudopot_cell_vnl -// (Calculate the non-local pseudopotential in reciprocal -// space. -// Using plane wave as basis set.) +// Calculate the non-local pseudopotential in reciprocal +// space using plane wave as basis set. //========================================================== class pseudopot_cell_vnl: public pseudopot_cell_vl { public: + pseudopot_cell_vnl(); + ~pseudopot_cell_vnl(); + //========================================================== // MEMBER VARIABLES : -// NAME : dq(space between points in the pseudopotential tab) // NAME : nkb(total number of beta functions, with struct.fact.) -// NAME : nqxq(size of interpolation table) // NAME : nqx(number of interpolation points) +// NAME : nqxq(size of interpolation table) // NAME : nhm(max number of different beta functions per atom) // NAME : lmaxkb(max angular momentum,(see pseudo_h)) -// NAME : lmaxq(new added) +// NAME : lmaxq +// NAME : dq(space between points in the pseudopotential tab) //========================================================== int nkb; + int calculate_nqx(const double &ecutwfc,const double &dq); int nhm; int lmaxkb; int lmaxq; -// int nbetam; // max number of different projectors per atom ? -// int nchim; // max number of different wavefunctions per atom -// int lllm; // max number of matrix indv; // indes linking atomic beta's to beta's in the solid matrix nhtol; // correspondence n <-> angular momentum l @@ -53,17 +51,11 @@ class pseudopot_cell_vnl: public pseudopot_cell_vl realArray deeq; //(:,:,:,:), the integral of V_eff and Q_{nm} ComplexArray deeq_nc; //(:,:,:,:), the spin-orbit case realArray becsum; //(:,:,:,:), \sum_i f(i) //used in charge -// realArray qq; //(:,:,:), the q functions in the solid ComplexMatrix vkb; // all beta functions in reciprocal space complex ***vkb1_alpha; complex ***vkb_alpha; - bool okvan; // if .TRUE. at least one pseudo is Vanderbilt - - pseudopot_cell_vnl(); - ~pseudopot_cell_vnl(); - double cell_factor; //LiuXh add 20180619 public: From 943a3a2104cf490f69f0c78d4bea082c34d375f7 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 23 Feb 2021 09:37:36 +0800 Subject: [PATCH 144/233] the writtinng of potentials has been moved from potential.cpp to src_io/write_pot.cpp --- ABACUS.develop/source/Makefile.Objects | 1 + ABACUS.develop/source/src_io/write_pot.cpp | 483 +++++++++++++++++++++ ABACUS.develop/source/src_pw/potential.cpp | 480 -------------------- ABACUS.develop/source/src_pw/potential.h | 1 + 4 files changed, 485 insertions(+), 480 deletions(-) create mode 100644 ABACUS.develop/source/src_io/write_pot.cpp diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 9feced6e88..5c3312a08d 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -210,6 +210,7 @@ charge_broyden.o \ charge_extra.o \ xc_gga_pw.o \ potential.o \ +write_pot.o\ potential_libxc.o \ efield.o \ magnetism.o\ diff --git a/ABACUS.develop/source/src_io/write_pot.cpp b/ABACUS.develop/source/src_io/write_pot.cpp new file mode 100644 index 0000000000..22d2098394 --- /dev/null +++ b/ABACUS.develop/source/src_io/write_pot.cpp @@ -0,0 +1,483 @@ +#include "../src_pw/potential.h" +#include "../src_pw/global.h" + +// translate from write_rho in charge.cpp. +void potential::write_potential(const int &is, const int &iter, const string &fn, +const matrix &v, const int &precision, const int &hartree)const +{ + TITLE("potential","write_potential"); + + if(out_potential==0) + { + return; + } + else if(out_potential<0) + { + if(hartree==0) return; + } + else if(iter % out_potential != 0) + { + return; + } + timer::tick("potential","write_potential"); + + ofstream ofs; + + if(MY_RANK==0) + { + ofs.open( fn.c_str() ); + + ofs << ucell.latName << endl;//1 + ofs << " " << ucell.lat0 * 0.529177 << endl; + ofs << " " << ucell.latvec.e11 << " " << ucell.latvec.e12 << " " << ucell.latvec.e13 << endl; + ofs << " " << ucell.latvec.e21 << " " << ucell.latvec.e22 << " " << ucell.latvec.e23 << endl; + ofs << " " << ucell.latvec.e31 << " " << ucell.latvec.e32 << " " << ucell.latvec.e33 << endl; + + for(int it=0; it=start_z[NPROC_IN_POOL-1]) + { + which_ip[iz] = NPROC_IN_POOL-1; + break; + } + else if(iz>=start_z[ip] && iz *Porter = UFFT.porter; + ZEROS( Porter, pw.nrxx ); + + int nspin0 = 1; + if(NSPIN==2) nspin0 = NSPIN; + for(int is=0; is( CHR.rho[is][ir], 0.0 ); + } + } + + //============================= + // bring rho (aux) to G space + //============================= + pw.FFT_chg.FFT3D(Porter, -1); + + //======================================================= + // calculate hartree potential in G-space (NB: V(G=0)=0 ) + //======================================================= + complex *vh_g = new complex[pw.ngmc]; + ZEROS(vh_g, pw.ngmc); + + for(int ig = pw.gstart; ig= 1.0e-12) //LiuXh 20180410 + { + const double fac = e2 * FOUR_PI / (ucell.tpiba2 * pw.gg [ig]); + vh_g[ig] = fac * Porter[j]; + } + } + + ZEROS(Porter, pw.nrxx); + + for (int ig = 0;ig < pw.ngmc;ig++) + { + Porter[pw.ig2fftc[ig]] = vh_g[ig]; + } + + //========================================== + //transform hartree potential to real space + //========================================== + pw.FFT_chg.FFT3D(Porter, 1); + //========================================== + //Add hartree potential and local pseudopot + //========================================== + for (int ir = 0;ir < pw.nrxx;ir++) + { + v_elecstat[ir] = Porter[ir].real() + this->vltot[ir]; + } + + //------------------------------------------- + // output the electrostatic potential into a file. + //------------------------------------------- + ofstream ofs; + ofstream ofs_ave; + + if(MY_RANK==0) + { + ofs.open( fn.c_str() ); + ofs_ave.open( fn_ave.c_str() ); + + ofs << ucell.latName << endl;//1 + ofs << " " << ucell.lat0 * 0.529177 << endl; + ofs << " " << ucell.latvec.e11 << " " << ucell.latvec.e12 << " " << ucell.latvec.e13 << endl; + ofs << " " << ucell.latvec.e21 << " " << ucell.latvec.e22 << " " << ucell.latvec.e23 << endl; + ofs << " " << ucell.latvec.e31 << " " << ucell.latvec.e32 << " " << ucell.latvec.e33 << endl; + + ofs_ave << ucell.latName << endl;//1 + ofs_ave << " " << ucell.lat0 * 0.529177 << endl; + ofs_ave << " " << ucell.latvec.e11 << " " << ucell.latvec.e12 << " " << ucell.latvec.e13 << endl; + ofs_ave << " " << ucell.latvec.e21 << " " << ucell.latvec.e22 << " " << ucell.latvec.e23 << endl; + ofs_ave << " " << ucell.latvec.e31 << " " << ucell.latvec.e32 << " " << ucell.latvec.e33 << endl; + + for(int it=0; it=start_z[NPROC_IN_POOL-1]) + { + which_ip[iz] = NPROC_IN_POOL-1; + break; + } + else if(iz>=start_z[ip] && iz=start_z[NPROC_IN_POOL-1]) - { - which_ip[iz] = NPROC_IN_POOL-1; - break; - } - else if(iz>=start_z[ip] && iz *Porter = UFFT.porter; - ZEROS( Porter, pw.nrxx ); - - int nspin0 = 1; - if(NSPIN==2) nspin0 = NSPIN; - for(int is=0; is( CHR.rho[is][ir], 0.0 ); - } - } - - //============================= - // bring rho (aux) to G space - //============================= - pw.FFT_chg.FFT3D(Porter, -1); - - //======================================================= - // calculate hartree potential in G-space (NB: V(G=0)=0 ) - //======================================================= - complex *vh_g = new complex[pw.ngmc]; - ZEROS(vh_g, pw.ngmc); - - for(int ig = pw.gstart; ig= 1.0e-12) //LiuXh 20180410 - { - const double fac = e2 * FOUR_PI / (ucell.tpiba2 * pw.gg [ig]); - vh_g[ig] = fac * Porter[j]; - } - } - - ZEROS(Porter, pw.nrxx); - - for (int ig = 0;ig < pw.ngmc;ig++) - { - Porter[pw.ig2fftc[ig]] = vh_g[ig]; - } - - //========================================== - //transform hartree potential to real space - //========================================== - pw.FFT_chg.FFT3D(Porter, 1); - //========================================== - //Add hartree potential and local pseudopot - //========================================== - for (int ir = 0;ir < pw.nrxx;ir++) - { - v_elecstat[ir] = Porter[ir].real() + this->vltot[ir]; - } - - //------------------------------------------- - // output the electrostatic potential into a file. - //------------------------------------------- - ofstream ofs; - ofstream ofs_ave; - - if(MY_RANK==0) - { - ofs.open( fn.c_str() ); - ofs_ave.open( fn_ave.c_str() ); - - ofs << ucell.latName << endl;//1 - ofs << " " << ucell.lat0 * 0.529177 << endl; - ofs << " " << ucell.latvec.e11 << " " << ucell.latvec.e12 << " " << ucell.latvec.e13 << endl; - ofs << " " << ucell.latvec.e21 << " " << ucell.latvec.e22 << " " << ucell.latvec.e23 << endl; - ofs << " " << ucell.latvec.e31 << " " << ucell.latvec.e32 << " " << ucell.latvec.e33 << endl; - - ofs_ave << ucell.latName << endl;//1 - ofs_ave << " " << ucell.lat0 * 0.529177 << endl; - ofs_ave << " " << ucell.latvec.e11 << " " << ucell.latvec.e12 << " " << ucell.latvec.e13 << endl; - ofs_ave << " " << ucell.latvec.e21 << " " << ucell.latvec.e22 << " " << ucell.latvec.e23 << endl; - ofs_ave << " " << ucell.latvec.e31 << " " << ucell.latvec.e32 << " " << ucell.latvec.e33 << endl; - - for(int it=0; it=start_z[NPROC_IN_POOL-1]) - { - which_ip[iz] = NPROC_IN_POOL-1; - break; - } - else if(iz>=start_z[ip] && iz Date: Wed, 24 Feb 2021 17:42:48 +0800 Subject: [PATCH 145/233] add comments in pseudopot_cell_vnl.h and pseudopot_cell_vnl.cpp --- ABACUS.develop/source/src_pw/diago_cg.cpp | 4 +- ABACUS.develop/source/src_pw/diago_cg.h | 7 +- ABACUS.develop/source/src_pw/hamilt_pw.cpp | 8 +- .../source/src_pw/pseudopot_cell_vnl.cpp | 88 +++++++++++-------- .../source/src_pw/pseudopot_cell_vnl.h | 49 +++++++---- 5 files changed, 100 insertions(+), 56 deletions(-) diff --git a/ABACUS.develop/source/src_pw/diago_cg.cpp b/ABACUS.develop/source/src_pw/diago_cg.cpp index 90c44e6592..2638e000f8 100644 --- a/ABACUS.develop/source/src_pw/diago_cg.cpp +++ b/ABACUS.develop/source/src_pw/diago_cg.cpp @@ -3,13 +3,14 @@ int Diago_CG::moved = 0; + Diago_CG::Diago_CG() { test_cg=0; } Diago_CG::~Diago_CG() {} -// from ccgdiagg.f90 + void Diago_CG::diag ( ComplexMatrix &phi, @@ -37,6 +38,7 @@ void Diago_CG::diag // Band-by-band algorithm with minimal use of memory // Calls h_1phi and s_1phi to calculate H|phi> and S|phi> // Works for generalized eigenvalue problem (US pseudopotentials) as well + //------------------------------------------------------------------- complex *sphi = new complex[dim](); complex *scg = new complex[dim](); complex *hphi = new complex[dim](); diff --git a/ABACUS.develop/source/src_pw/diago_cg.h b/ABACUS.develop/source/src_pw/diago_cg.h index b471291c6e..7998894645 100644 --- a/ABACUS.develop/source/src_pw/diago_cg.h +++ b/ABACUS.develop/source/src_pw/diago_cg.h @@ -17,10 +17,13 @@ class Diago_CG { -public: + public: + Diago_CG(); ~Diago_CG(); + static int moved; + static double ddot_real( const int & dim, const complex* psi_L, @@ -64,7 +67,7 @@ class Diago_CG complex *psi_m ); -private: + private: int test_cg; diff --git a/ABACUS.develop/source/src_pw/hamilt_pw.cpp b/ABACUS.develop/source/src_pw/hamilt_pw.cpp index de356df88e..b4509b81d5 100644 --- a/ABACUS.develop/source/src_pw/hamilt_pw.cpp +++ b/ABACUS.develop/source/src_pw/hamilt_pw.cpp @@ -49,7 +49,8 @@ void Hamilt_PW::init(const int &npwx, const int &npol, const int &nkb, const int ZEROS(this->hpsi, npwx * npol); ZEROS(this->spsi, npwx * npol); ZEROS(this->GR_index, nrxx); -// ofs_running << "\n Hamiltonian allocate done."< 0 && !LINEAR_SCALING) xiaohui modify 2013-09-02 if(ppcell.nkb > 0 && (BASIS_TYPE=="pw" || BASIS_TYPE=="lcao_in_pw")) //xiaohui add 2013-09-02. Attention... { ppcell.getvnl(ik); } + // (5) The number of wave functions. wf.npw = kv.ngk[ik]; + // (6) The index of plane waves. for (int ig = 0;ig < wf.npw;ig++) { diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.cpp b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.cpp index 68a744e917..49f6b10980 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.cpp +++ b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.cpp @@ -2,8 +2,7 @@ // AUTHOR : Lixin He, mohan // DATE : 2008-11-08 //========================================================== -#include "global.h" // only out - +#include "global.h" #include "pseudopot_cell_vnl.h" #include "tools.h" #include "wavefunc.h" @@ -17,9 +16,10 @@ pseudopot_cell_vnl::~pseudopot_cell_vnl() { } -//========================================================== -// see allocate_nlpot.f90 -//========================================================== +//----------------------------------- +// setup lmaxkb, nhm, nkb, lmaxq +// allocate vkb, NQX, tab, tab_at +//----------------------------------- void pseudopot_cell_vnl::init(const int ntype, const bool allocate_vkb) { TITLE("pseudopot_cell_vnl", "init"); @@ -73,7 +73,6 @@ void pseudopot_cell_vnl::init(const int ntype, const bool allocate_vkb) nhtoj.create(ntype, this->nhm); deeq.create(NSPIN, ucell.nat, this->nhm, this->nhm); deeq_nc.create(NSPIN, ucell.nat, this->nhm, this->nhm); - // qq.create(ntype, this->nhm, this->nhm); dvan.create(ntype, this->nhm, this->nhm); dvan_so.create(NSPIN, ntype, this->nhm, this->nhm); becsum.create(NSPIN, ucell.nat, this->nhm * (this->nhm + 1) / 2); @@ -98,23 +97,34 @@ void pseudopot_cell_vnl::init(const int ntype, const bool allocate_vkb) //NQX = this->calculate_nqx(pw.ecutwfc,DQ) * 10; //LiuXh add 20180515 NQX = this->calculate_nqx(pw.ecutwfc,DQ) * cell_factor; //LiuXh add 20180619 // nqx = (sqrt(ecutwfc)/dq+4)*cell_factor; - // // mohan update 2021-02-22 const int nbrx = 10; const int nbrx_nc = 20; // max number of beta functions - if(NSPIN!=4) this->tab.create(ntype, nbrx, NQX); - else this->tab.create(ntype, nbrx_nc, NQX); + if(NSPIN!=4) + { + this->tab.create(ntype, nbrx, NQX); + } + else + { + this->tab.create(ntype, nbrx_nc, NQX); + } // mohan update 2021-02-22 int nchix = 10; int nchix_nc = 20; // nchix : max number of atomic wavefunctions per atom - if(NSPIN!=4) this->tab_at.create(ntype, nchix, NQX); - else this->tab_at.create(ntype, nchix_nc, NQX); + if(NSPIN!=4) + { + this->tab_at.create(ntype, nchix, NQX); + } + else + { + this->tab_at.create(ntype, nchix_nc, NQX); + } if(test_pp > 1) { @@ -132,12 +142,11 @@ void pseudopot_cell_vnl::init(const int ntype, const bool allocate_vkb) return; } + + //---------------------------------------------------------- -// MEMBER FUNCTION NAME : -// NAME : pseudopot_cell_vnl -// Calculates beta functions (Kleinman-Bylander projectors), with -// structure factor, for all atoms, in reciprocal space -// from init_us_2.f90 +// Calculates beta functions (Kleinman-Bylander projectors), +// with structure factor, for all atoms, in reciprocal space //---------------------------------------------------------- void pseudopot_cell_vnl::getvnl(const int &ik) { @@ -162,13 +171,11 @@ void pseudopot_cell_vnl::getvnl(const int &ik) gk[ig] = wf.get_1qvec_cartesian(ik, ig); } - Mathzone::Ylm_Real(x1, npw, gk, ylm); int jkb = 0; for(int it = 0;it < ucell.ntype;it++) { - if(test_pp>1) OUT("it",it); // calculate beta in G-space using an interpolation table const int nbeta = ucell.atoms[it].nbeta; const int nh = ucell.atoms[it].nh; @@ -182,17 +189,9 @@ void pseudopot_cell_vnl::getvnl(const int &ik) { const double gnorm = gk[ig].norm() * ucell.tpiba; -// cout << "\n gk[ig] = " << gk[ig].x << " " << gk[ig].y << " " << gk[ig].z; -// cout << "\n gk.norm = " << gnorm; - -//if(ik==0){ -//cout<<"ik: "<tab, it, nb, NQX, DQ, gnorm ); - } // enddo + } // add spherical harmonic part for (ih = 0;ih < nh;ih++) @@ -228,13 +227,17 @@ void pseudopot_cell_vnl::getvnl(const int &ik) delete [] gk; delete [] vq; + timer::tick("pp_cell_vnl","getvnl"); + return; } // end subroutine getvnl + + void pseudopot_cell_vnl::init_vnl(void) { - if(test_pp) TITLE("pseudopot_cell_vnl","init_vnl"); + TITLE("pseudopot_cell_vnl","init_vnl"); timer::tick("ppcell_vnl","init_vnl"); //from init_us_1 @@ -247,9 +250,10 @@ void pseudopot_cell_vnl::init_vnl(void) // d) It computes the indices nhtolm which establish the correspondence // nh <-> combined (l,m) index for the beta function. - // For each pseudopotential we initialize the indices nhtol, nhtolm, - // nhtoj, indv, and if the pseudopotential is of KB type we initialize + // For each pseudopotential we initialize the indices nhtol, nhtolm, + // nhtoj, indv, and if the pseudopotential is of KB type we initialize // the atomic D terms + this->dvan.zero_out(); this->dvan_so.zero_out();//added by zhengdy-soc soc.rot_ylm(this->lmaxkb); @@ -313,13 +317,17 @@ void pseudopot_cell_vnl::init_vnl(void) // // and calculate the bare coefficients // - for(int ip = 0;ip( indv(it, ip ) ); - for(int ip2=0; ip2( indv(it, ip2) ); int ijs =0; - for(int is1=0;is1<2;++is1){ - for(int is2=0;is2<2;++is2){ + for(int is1=0;is1<2;++is1) + { + for(int is2=0;is2<2;++is2) + { this->dvan_so(ijs,it,ip,ip2) = ucell.atoms[it].dion(ir, is) * soc.fcoef(it,is1,is2,ip,ip2); ++ijs; if(ir != is) soc.fcoef(it,is1,is2,ip,ip2) = complex(0.0,0.0); @@ -338,11 +346,13 @@ void pseudopot_cell_vnl::init_vnl(void) { const int ir = static_cast( indv(it, ip ) ); const int is = static_cast( indv(it, ip2) ); - if(LSPINORB){ + if(LSPINORB) + { this->dvan_so(0,it,ip,ip2) = ucell.atoms[it].dion(ir, is); this->dvan_so(3,it,ip,ip2) = ucell.atoms[it].dion(ir, is); } - else{ + else + { this->dvan(it, ip, ip2) = ucell.atoms[it].dion(ir, is); } } @@ -350,7 +360,7 @@ void pseudopot_cell_vnl::init_vnl(void) } } - // h) It fills the interpolation table for the beta functions + // h) It fills the interpolation table for the beta functions /********************************************************** // He Lixin: this block is used for non-local potential // fill the interpolation table tab @@ -400,6 +410,7 @@ void pseudopot_cell_vnl::init_vnl(void) return; } + complex pseudopot_cell_vnl::Cal_C(int alpha, int lu, int mu, int L, int M) // pengfei Li 2018-3-23 { complex cf; @@ -627,11 +638,14 @@ void pseudopot_cell_vnl::init_vnl_alpha(void) // pengfei Li 2018-3-23 } + void pseudopot_cell_vnl::print_vnl(ofstream &ofs) { out.printr3_d(ofs, " tab : ", tab); } + + int pseudopot_cell_vnl::calculate_nqx(const double &ecutwfc,const double &dq) { int points_of_table = static_cast( sqrt(ecutwfc)/dq + 4 ) ;//* cell_factor; diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h index 5a865bfc48..4f04c19aff 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h +++ b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h @@ -8,6 +8,7 @@ #include "tools.h" #include "pseudopot_cell_vl.h" #include "../src_lcao/ORB_gen_tables.h" +#include "wavefunc_in_pw.h" //========================================================== // Calculate the non-local pseudopotential in reciprocal @@ -15,27 +16,52 @@ //========================================================== class pseudopot_cell_vnl: public pseudopot_cell_vl { + public: pseudopot_cell_vnl(); ~pseudopot_cell_vnl(); -//========================================================== -// MEMBER VARIABLES : + friend class Stress; + friend class Forces; + friend class Epsilon0_vasp; + friend class potential; + friend class Hamilt_PW; + friend class WF_atomic; + friend class wavefunc; + + void init(const int ntype, const bool allocate_vkb=1); + + double cell_factor; //LiuXh add 20180619 + // NAME : nkb(total number of beta functions, with struct.fact.) + int nkb; // be called in hm.hpw.init + +// NAME : lmaxkb(max angular momentum,(see pseudo_h)) + int lmaxkb; + + void init_vnl(void); + +private: + + void getvnl(const int &ik); + + void getvnl_alpha(const int &ik); + + void init_vnl_alpha(void); + +//=============================================================== +// MEMBER VARIABLES : // NAME : nqx(number of interpolation points) // NAME : nqxq(size of interpolation table) // NAME : nhm(max number of different beta functions per atom) -// NAME : lmaxkb(max angular momentum,(see pseudo_h)) // NAME : lmaxq // NAME : dq(space between points in the pseudopotential tab) -//========================================================== - int nkb; +//=============================================================== int calculate_nqx(const double &ecutwfc,const double &dq); int nhm; - int lmaxkb; int lmaxq; matrix indv; // indes linking atomic beta's to beta's in the solid @@ -45,9 +71,11 @@ class pseudopot_cell_vnl: public pseudopot_cell_vl realArray dvan; //(:,:,:), the D functions of the solid ComplexArray dvan_so; //(:,:,:), spin-orbit case, added by zhengdy-soc + realArray tab; //(:,:,:), interpolation table for PPs realArray tab_alpha; realArray tab_at; //(:,:,:), interpolation table for atomic wfc + realArray deeq; //(:,:,:,:), the integral of V_eff and Q_{nm} ComplexArray deeq_nc; //(:,:,:,:), the spin-orbit case realArray becsum; //(:,:,:,:), \sum_i f(i) //used in charge @@ -56,16 +84,7 @@ class pseudopot_cell_vnl: public pseudopot_cell_vl complex ***vkb1_alpha; complex ***vkb_alpha; - double cell_factor; //LiuXh add 20180619 -public: - void init(const int ntype, const bool allocate_vkb=1); - void init_vnl(void); - void getvnl(const int &ik); - void getvnl_alpha(const int &ik); - void init_vnl_alpha(void); - -private: complex Cal_C(int alpha, int lu, int mu, int L, int M); double CG(int l1, int m1, int l2, int m2, int L, int M); void print_vnl(ofstream &ofs); From eee6fa6dc158ef2da057aa2d25f73c5591729220 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 24 Feb 2021 20:46:44 +0800 Subject: [PATCH 146/233] organize potential.h and .cpp --- ABACUS.develop/source/src_pw/potential.cpp | 17 ------ ABACUS.develop/source/src_pw/potential.h | 63 +++++++++++----------- ABACUS.develop/source/src_pw/wavefunc.cpp | 3 +- 3 files changed, 34 insertions(+), 49 deletions(-) diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index 00cf26b951..61c18716b8 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -840,23 +840,6 @@ void potential::print_pot(ofstream &ofs)const // ofs << "\n charge = " << charge; out.printr1_d(ofs, " vltot : ", vltot, pw.nrxx); out.printrm(ofs, " vrs : ", vrs); - -} - - - -double potential::vr_ave(const int n,const int size,const double *p) -{ - // return the average of potential here - // [sum_i v(i)^n] / size of the array - double ave = 0.0; - if (size < 0) - { - cout << "\n The size of the array should > = 1, error"; - exit(0); - } - for (int i =0; i< size; i++) ave += pow(p[i], n); - return ( ave / static_cast(size) ) ; } diff --git a/ABACUS.develop/source/src_pw/potential.h b/ABACUS.develop/source/src_pw/potential.h index cc0bd7b83c..dd947eda64 100644 --- a/ABACUS.develop/source/src_pw/potential.h +++ b/ABACUS.develop/source/src_pw/potential.h @@ -6,63 +6,57 @@ class potential { public: + friend class Hamilt_PW; + friend class Electrons; + friend class ELEC_scf; + // constructor and deconstructor potential(); ~potential(); - //================================================================== + //========================================================== // start_pot : "atomic" or "file" - // vr(nspin,ncxyz) : The Hartree + xc potential in real space - // vrs(nspin,ncxyz): The total potential in real space(smooth grid) - // vnew(nspin,ncxyz) : V_out - V_in , needed in scf - //================================================================== + // extra_pot : extrapolation methods for potential + // vr(nspin,ncxyz) : Hartree + xc potentials in real space + // vrs(nspin,ncxyz) : total potential in real space + // vnew(nspin,ncxyz) : V_out - V_in, needed in scf + // vltot: the local potential in real space + // out_potential: options to print out potentials + //========================================================== string start_pot; - string extra_pot; //mohan add 2011-03-13, xiaohui modify 2015-02-01 + string extra_pot; matrix vr; matrix vrs; matrix vnew; - double *vrs1; // mohan add 2007-11-12 - double *vext; // fuxiang add 2017-05 - double *vextold; //fuxiang add 2018-01-15 + double *vrs1; + double *vltot; + int out_potential; // mohan add 2011-02-28 // member functions void init(const int nrxx); - + + //------------------------------------------------ // if delta_vh==true, vl_pseudo not calculated, // V(rho-rho_atom) is calculated, // V(xc) is calculated. - // if vna==true, vl_pseudo is calculated, // V(rho_atom) is calclated, // V(xc) is not calculated. + //------------------------------------------------ void init_pot(const int &istep, const bool delta_vh=false, const bool vna=false); - void newd(void); - void v_of_rho( double** rho_in, double &ehart, double &etxc, double &vtxc, matrix &v, const bool delta_vh=false, const bool vna=false); - // mix input and output potentials. - // void mix_potential (int ndim, double *vout, double *vin, double alphamix, - // double &dr2,double tr2,int iter,int n_iter,string filename,bool &conv); + void newd(void); - // vrs = vr + vltotK - // vr : Hartree potential + V_xc potential . - // vltot : From pseudopotential . void set_vrs(void); - // I guess this is done by Fuxiang He, -- mohan 2021-02-01 - void set_vrs_tddft(const int istep); - - void print_pot(ofstream &ofs)const; - - double vr_ave(const int, const int, const double *) ; - void v_xc(double** rho_in, double &etxc, double &vtxc, matrix &v); - double *vltot; // = new [ncxyz],the local potential in real space + public: - int out_potential; // mohan add 2011-02-28 + void print_pot(ofstream &ofs)const; // mohan add 2011-02-28 // here vh is complex because the array is got after complex FFT. @@ -73,11 +67,20 @@ class potential private: - // use fft to set vltot. - // do once in demo.cpp void set_local(double *vl_pseudo)const; void v_h( int nspin, double &ehart, matrix &v, double** rho); + + + private: + + // TDDFT related, fuxiang add + double *vext; + + double *vextold; + + void set_vrs_tddft(const int istep); + }; #endif // POTENTIAL_H diff --git a/ABACUS.develop/source/src_pw/wavefunc.cpp b/ABACUS.develop/source/src_pw/wavefunc.cpp index db034687e1..8d32127240 100644 --- a/ABACUS.develop/source/src_pw/wavefunc.cpp +++ b/ABACUS.develop/source/src_pw/wavefunc.cpp @@ -246,8 +246,7 @@ void wavefunc::LCAO_in_pw_k(const int &ik, ComplexMatrix &wvf) TITLE("wavefunc","LCAO_in_pw_k"); timer::tick("wavefunc","LCAO_in_pw_k",'G'); - //assert(LOCAL_BASIS==4); xiaohui modify 2013-09-01 - assert(BASIS_TYPE=="lcao_in_pw"); //xiaohui add 2013-09-01. Attention! How about "BASIS_TYPE=="lcao""??? + assert(BASIS_TYPE=="lcao_in_pw"); static bool ltable = false; if(!ltable) From 4db1fb63d3a5dc632374e1da0c8a1c2d794211d3 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 24 Feb 2021 21:38:45 +0800 Subject: [PATCH 147/233] update hamilt and hamilt_pw, delete useless codes --- ABACUS.develop/source/src_pw/diago_cg.cpp | 10 +- ABACUS.develop/source/src_pw/diago_david.cpp | 8 +- ABACUS.develop/source/src_pw/exx_lip.h | 3 +- ABACUS.develop/source/src_pw/hamilt.cpp | 141 +------------------ ABACUS.develop/source/src_pw/hamilt.h | 8 -- ABACUS.develop/source/src_pw/hamilt_pw.cpp | 86 ++++++----- ABACUS.develop/source/src_pw/hamilt_pw.h | 35 +++-- 7 files changed, 85 insertions(+), 206 deletions(-) diff --git a/ABACUS.develop/source/src_pw/diago_cg.cpp b/ABACUS.develop/source/src_pw/diago_cg.cpp index 2638e000f8..9e8015561b 100644 --- a/ABACUS.develop/source/src_pw/diago_cg.cpp +++ b/ABACUS.develop/source/src_pw/diago_cg.cpp @@ -63,13 +63,13 @@ void Diago_CG::diag if (test_cg>2) ofs_running << "Diagonal Band : " << m << endl; for (int i=0; i + hm.hpw.s_1psi(dim, phi_m, sphi); // sphi = S|psi(m)> this->schmit_orth(dim, m, phi, sphi, phi_m); // cout<<"\n before h_1psi sphi"; // for(int i=0; iddot_real(dim, phi_m, hphi ); // cout<<"\n\n m="<ddot_real(dim, cg, scg) ); if (cg_norm < 1.0e-10 ) return 1; @@ -458,7 +458,7 @@ void Diago_CG::schmit_orth { psi_m[ig] /= psi_norm; } - hm.s_1psi(dim, psi_m, sphi); // sphi = S|psi(m)> + hm.hpw.s_1psi(dim, psi_m, sphi); // sphi = S|psi(m)> delete [] lagrange ; //timer::tick("Diago_CG","schmit_orth"); diff --git a/ABACUS.develop/source/src_pw/diago_david.cpp b/ABACUS.develop/source/src_pw/diago_david.cpp index 5096095038..cf3c9248fc 100644 --- a/ABACUS.develop/source/src_pw/diago_david.cpp +++ b/ABACUS.develop/source/src_pw/diago_david.cpp @@ -78,7 +78,7 @@ void Diago_David::diag this->SchmitOrth(npw, nband, m, basis, psi_m, spsi); - hm.h_1psi(npw, psi_m, hpsi, spsi); + hm.hpw.h_1psi(npw, psi_m, hpsi, spsi); // basis(m) = psi_m, hp(m) = H |psi_m>, sp(m) = S |psi_m> for ( int ig = 0; ig < npw; ig++ ) @@ -239,7 +239,7 @@ void Diago_David::cal_grad */ this->SchmitOrth(npw, nbase+notconv, nbase+m, basis, ppsi, spsi); - hm.h_1psi(npw, ppsi, hpsi, spsi); + hm.hpw.h_1psi(npw, ppsi, hpsi, spsi); for ( int ig = 0; ig < npw; ig++ ) { @@ -515,7 +515,7 @@ void Diago_David::SchmitOrth assert(m >= 0); assert(m < n_band); - hm.s_1psi(npw, psi_m, spsi); + hm.hpw.s_1psi(npw, psi_m, spsi); complex* lagrange = new complex[m+1]; ZEROS( lagrange, m+1 ); @@ -565,7 +565,7 @@ void Diago_David::SchmitOrth } } - hm.s_1psi(npw, psi_m, spsi); + hm.hpw.s_1psi(npw, psi_m, spsi); delete[] lagrange; timer::tick("Diago_David","SchmitOrth"); diff --git a/ABACUS.develop/source/src_pw/exx_lip.h b/ABACUS.develop/source/src_pw/exx_lip.h index 8494f3de4b..8dd382f6b0 100644 --- a/ABACUS.develop/source/src_pw/exx_lip.h +++ b/ABACUS.develop/source/src_pw/exx_lip.h @@ -80,7 +80,8 @@ class Exx_Lip void sum_all(int ik); void exx_energy_cal(); void read_q_pack(); - + +// mohan comment out 2021-02-24 friend void Hamilt_PW::cinitcgg(const int ik,const int nstart,const int n_band,const ComplexMatrix &psi,ComplexMatrix &evc,double *en); public: diff --git a/ABACUS.develop/source/src_pw/hamilt.cpp b/ABACUS.develop/source/src_pw/hamilt.cpp index f8f772711b..5d58291005 100644 --- a/ABACUS.develop/source/src_pw/hamilt.cpp +++ b/ABACUS.develop/source/src_pw/hamilt.cpp @@ -190,160 +190,23 @@ void Hamilt::cinitcgg( ComplexMatrix &evc, double *en) { - // 1 : Local basis or not. - // yes : using cinitcgg - // no : using cinitcgg, then cg method - // - // 2 : Linear scaling or not. - // yes : using - // - // 3 : Lapack using or cg method. - // - // - // 4 : Sparse matrix or not. - // (Default setting : yes for LINEAR SCALING) - // - // LINEAR SCALING: yes( consider set it or not ), no (never do it) - // LOCAL BASIS : yes( consider set it or not), no(never do it) - // - // belong to STORE hamiltonian and overlap. - // Can used for LAPACK for check. - // Formally used for CG method. - // - // In LINEAR SCALING case, - // there are some difference between - // S|psi and H|psi - // - // 5 : belong to CONSTRUCT hamiltonian and overlap. - // only for Local basis = 1 or 2. - // not for Local basis = 0 - // can used for both cg or lapack - // can used for both sparsematrix or complexmatrix - // - // - // Using overlap from SIESTA method - // Using kinetic from SISTA method - // Using non-local from SISTA method - // Local part from SISTA method - // - // Overlap, kinetic and non-local can only do once. - // Local part built up in each iteration - if(nstart < n_band) { WARNING_QUIT("cinitcgg","nstart < n_band!"); } - //if (LINEAR_SCALING && LOCAL_BASIS) xiaohui modify 2013-09-02 - if(BASIS_TYPE=="lcao") //xiaohui add 2013-09-02 - { - WARNING_QUIT("cinitcgg","Diago not doing here."); - } - //else if (!LINEAR_SCALING) xiaohui modify 2013-09-02 - else if(BASIS_TYPE=="pw" || BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-02 + if(BASIS_TYPE=="pw" || BASIS_TYPE=="lcao_in_pw") { this->hpw.cinitcgg(ik, nstart, n_band, psi, evc, en); } else { - //WARNING_QUIT("cinitcgg","Check parameters: LINEAR_SCALING and LOCAL_BASIS. "); xiaohui modify 2013-09-02 - WARNING_QUIT("cinitcgg","Check parameters: BASIS_TYPE. "); //xiaohui add 2013-09-02 - } - return; -} - - -void Hamilt::h_1psi(const int dim,const complex *psi,complex *hpsi,complex *spsi) -{ - //if (LINEAR_SCALING) xiaohui modify 2013-09-02 - if(BASIS_TYPE=="lcao") //xiaohui add 2013-09-02. Attention! Maybe this change is not reasonable. - { - timer::tick("Hamilt","Sparse_SH"); - double *psi_real = new double[dim]; - double *hpsi_real = new double[dim]; - double *spsi_real = new double[dim]; - - for (int i=0; ihon.UHM.Sparse_H.multiply_vector(psi_real, hpsi_real); -// this->hon.UOM.Sparse_S.multiply_vector(psi_real, spsi_real); - - for (int i=0; i( spsi_real[i], 0.0 ); - for (int i=0; i( hpsi_real[i], 0.0 ); - - delete[] psi_real; - delete[] hpsi_real; - delete[] spsi_real; - timer::tick("Hamilt","Sparse_SH"); - } - else - { - this->hpw.h_1psi(dim, psi, hpsi, spsi); + WARNING_QUIT("cinitcgg","Check parameters: BASIS_TYPE. "); } return; } -void Hamilt::s_1psi(const int dim, const complex *psi, complex *spsi) -{ - //if (LINEAR_SCALING) xiaohui modify 2013-09-02 - if(BASIS_TYPE=="lcao") //xiaohui add 2013-09-02. Attention! Maybe this change is not reasonable. - { - timer::tick("Hamilt","Sparse_S"); - double *psi_real = new double[dim]; - double *spsi_real = new double[dim]; - - for (int i=0; ihon.UOM.Sparse_S.multiply_vector(psi_real, spsi_real); - - for (int i=0; i( spsi_real[i] , 0.0 ); - } - delete[] psi_real; - delete[] spsi_real; - timer::tick("Hamilt","Sparse_S"); - } - else - { - this->hpw.s_1psi(dim, psi, spsi); - } - return; -} - -void Hamilt::h_psi( const int dim, const complex *psi, complex *hpsi) -{ - //if (LINEAR_SCALING) xiaohui modify 2013-09-02 - if(BASIS_TYPE=="lcao") //xiaohui add 2013-09-02. Attention! Maybe this change is not reasonable. - { - timer::tick("Hamilt","Sparse_H"); - double *psi_real = new double[dim]; - double *hpsi_real = new double[dim]; - - for (int i=0; ihon.UHM.Sparse_H.multiply_vector(psi_real, hpsi_real); - - for (int i=0; i( hpsi[i].real(), 0.0 ); - - delete[] psi_real; - delete[] hpsi_real; - timer::tick("Hamilt","Sparse_H"); - } - else - { - this->hpw.h_psi( psi, hpsi); - } - return; -} void Hamilt::cdiaghg( const int nstart, diff --git a/ABACUS.develop/source/src_pw/hamilt.h b/ABACUS.develop/source/src_pw/hamilt.h index 96ebb413ac..264bdbcec4 100644 --- a/ABACUS.develop/source/src_pw/hamilt.h +++ b/ABACUS.develop/source/src_pw/hamilt.h @@ -29,14 +29,6 @@ class Hamilt void cdiaghg(const int n,const int m,const ComplexMatrix &hc,const ComplexMatrix &sc, const int ldh,double *e,ComplexMatrix &hvec); - void h_1psi(const int dim,const complex *psi,complex *hpsi,complex *spi); - void s_1psi(const int dim,const complex *psi,complex *spsi); - - void h_1psi_real(const int dim,const double *psi,double *hpsi,double *spi); - void s_1psi_real(const int dim,const double *psi, double *spsi); - - void h_psi( const int dim, const complex *psi,complex *hpsi); - Hamilt_PW hpw; // mohan update 2021-02-10 diff --git a/ABACUS.develop/source/src_pw/hamilt_pw.cpp b/ABACUS.develop/source/src_pw/hamilt_pw.cpp index b4509b81d5..b71903b41f 100644 --- a/ABACUS.develop/source/src_pw/hamilt_pw.cpp +++ b/ABACUS.develop/source/src_pw/hamilt_pw.cpp @@ -91,10 +91,11 @@ void Hamilt_PW::init_k(const int ik) } -// from cinitcgg.f90 +//---------------------------------------------------------------------- // Hamiltonian diagonalization in the subspace spanned // by nstart states psi (atomic or random wavefunctions). // Produces on output n_band eigenvectors (n_band <= nstart) in evc. +//---------------------------------------------------------------------- void Hamilt_PW::cinitcgg( const int ik, const int nstart, @@ -117,9 +118,13 @@ void Hamilt_PW::cinitcgg( for(int i=0; i[wf.npwx*NPOL]; + } else + { p[i] = new complex[wf.npwx]; + } } for(int i=0; ijust_ddot(dmin, p[j], hpsi); sc(j,m) = this->just_ddot(dmin, p[j], spsi); hc(m, j) = conj(hc(j, m)); sc(m, j) = conj(sc(j, m)); - } // enddo - // timer::tick("Hamilt_PW","zdotc"); + } } - } // enddo + } // Peize Lin add 2019-03-09 if("lcao_in_pw"==BASIS_TYPE) @@ -184,29 +186,36 @@ void Hamilt_PW::cinitcgg( auto add_Hexx = [&](const double alpha) { for (int m=0; m1) { Parallel_Reduce::reduce_complex_double_pool( hc.c, nstart*nstart ); Parallel_Reduce::reduce_complex_double_pool( sc.c, nstart*nstart ); } -// timer::tick("Hamilt_PW","reduce"); for(int i=0; ihvec_array[ik] = hvec; break; } + } - //cout << "\n <2> pw.gcar[0] = " << " " << pw.gcar[0].x << " " << pw.gcar[0].y << " " << pw.gcar[0].z << endl; //======================= //diagonize the H-matrix //======================= +// for tests /* cout << setprecision(3); out.printV3(ofs_running,kv.kvec_c[ik]); @@ -240,9 +253,6 @@ void Hamilt_PW::cinitcgg( cout << endl; */ -// cout << " ----------------------------- ik=" << ik << endl; -// out.printV3( kv.kvec_c[ik] ); -// cout << " cinitcgg" << endl; cout << setprecision(5); //-------------------------- @@ -283,17 +293,15 @@ void Hamilt_PW::cinitcgg( // KEEP THIS BLOCK FOR TESTS //-------------------------- -// cout << "OUTPUT Overlap Matrix = " << setprecision(6); - //if(LOCAL_BASIS==4 && CALCULATION=="nscf" && !Optical::opt_epsilon2) xiaohui modify 2013-09-02 - if((BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") && CALCULATION=="nscf" && !Optical::opt_epsilon2) //xiaohui add 2013-09-02. Attention! + if((BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") && CALCULATION=="nscf" && !Optical::opt_epsilon2) { ofs_running << " Not do zgemm to get evc." << endl; } - //else if(LOCAL_BASIS==4 && ( CALCULATION == "scf" || CALCULATION == "md") ) xiaohui modify 2013-09-02 - else if((BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") && ( CALCULATION == "scf" || CALCULATION == "md" || CALCULATION == "relax")) //pengfei 2014-10-13 + else if((BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") + && ( CALCULATION == "scf" || CALCULATION == "md" || CALCULATION == "relax")) //pengfei 2014-10-13 { - // because psi and evc is different here, + // because psi and evc are different here, // I think if psi and evc is the same, // there may be problems, mohan 2011-01-01 char transa = 'N'; @@ -314,8 +322,8 @@ void Hamilt_PW::cinitcgg( } else { - /* As the evc and psi may refer to the same matrix, we first - * create a temporary matrix to story the result. (by wangjp) */ + // As the evc and psi may refer to the same matrix, we first + // create a temporary matrix to story the result. (by wangjp) ComplexMatrix evctmp(n_band, dmax); for(int ib=0; ib pw.gcar[0] = " << " " << pw.gcar[0].x << " " << pw.gcar[0].y << " " << pw.gcar[0].z << endl; return; -} //end subroutine cinitcgg +} void Hamilt_PW::h_1psi( const int npw_in, const complex < double> *psi, @@ -429,7 +437,8 @@ void Hamilt_PW::h_psi(const complex *psi_in, complex *hpsi) hpsi[ig] = wf.g2kin[ig] * psi_in[ig]; } //added by zhengdy-soc - if(NSPIN==4){ + if(NSPIN==4) + { for (ig = wf.npwx;ig < wf.npw + wf.npwx;ig++) { hpsi[ig] = wf.g2kin[ig - wf.npwx] * psi_in[ig]; @@ -442,7 +451,8 @@ void Hamilt_PW::h_psi(const complex *psi_in, complex *hpsi) //------------------------------------ if(VL_IN_H) { - if(NSPIN!=4){ + if(NSPIN!=4) + { ZEROS( UFFT.porter, pw.nrxx); UFFT.RoundTrip( psi_in, pot.vrs1, GR_index, UFFT.porter ); @@ -870,7 +880,7 @@ complex Hamilt_PW::ddot( Parallel_Reduce::reduce_complex_double_pool( result ); } return result; -} // end of ddot +} complex Hamilt_PW::just_ddot( const int & dim, @@ -879,8 +889,7 @@ complex Hamilt_PW::just_ddot( )const { complex result = ZERO; - //const int incx = 1; - //const int incy = 1; + // mohan add 2010-10-11 // zdotc_(&result, &dim, psi_L, &incx, psi_R, &incy); @@ -896,8 +905,9 @@ complex Hamilt_PW::just_ddot( { result += conj(psi_L[i])*psi_R[i]; } + return result; -} // end of ddot +} diff --git a/ABACUS.develop/source/src_pw/hamilt_pw.h b/ABACUS.develop/source/src_pw/hamilt_pw.h index 831ab99cce..3e2e28af9b 100644 --- a/ABACUS.develop/source/src_pw/hamilt_pw.h +++ b/ABACUS.develop/source/src_pw/hamilt_pw.h @@ -16,15 +16,6 @@ class Hamilt_PW // mohan updated 2021-02-22 void init(const int &npwx, const int &npol, const int &nkb, const int &nrxx); - void diag_zheev - ( - const int& npw, - ComplexMatrix& psi, - const int& nband, - double *em, - double *err - ) ; - void cal_err ( const int &npw, @@ -36,6 +27,13 @@ class Hamilt_PW void init_k(const int ik); + private: + + friend class Diago_David; + friend class Diago_CG; + friend class Exx_Lip; + friend class Hamilt; + void cinitcgg(const int ik, const int nstart, const int nbnd, @@ -56,8 +54,7 @@ class Hamilt_PW const complex < double> *psi, complex < double> *spsi); - int test; - double ddot_real( const int& npw, const complex* psi_L, const complex* psi_R)const; + private: int *GR_index; @@ -72,6 +69,10 @@ class Hamilt_PW void add_vuspsi(complex *hpsi, const complex *becp); + private: + + double ddot_real( const int& npw, const complex* psi_L, const complex* psi_R)const; + complex ddot( const int& npw, const complex * psi_L, @@ -85,6 +86,18 @@ class Hamilt_PW const ComplexMatrix &psi, const int & m, const complex *psik )const ; + + private: + + void diag_zheev + ( + const int& npw, + ComplexMatrix& psi, + const int& nband, + double *em, + double *err + ) ; + }; #endif From c55ad2e5faf68d16c7d6e4b07f8a81fe999d079b Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 24 Feb 2021 22:02:58 +0800 Subject: [PATCH 148/233] update hamilt and wavefunc, delete some useless comments --- ABACUS.develop/source/src_pw/electrons.cpp | 2 +- ABACUS.develop/source/src_pw/hamilt.cpp | 54 +++----- ABACUS.develop/source/src_pw/hamilt.h | 2 - ABACUS.develop/source/src_pw/sto_elec.cpp | 2 +- ABACUS.develop/source/src_pw/wavefunc.cpp | 141 ++++++++++++--------- ABACUS.develop/source/src_pw/wavefunc.h | 5 +- 6 files changed, 100 insertions(+), 106 deletions(-) diff --git a/ABACUS.develop/source/src_pw/electrons.cpp b/ABACUS.develop/source/src_pw/electrons.cpp index 9859c4c642..e695bef7b7 100644 --- a/ABACUS.develop/source/src_pw/electrons.cpp +++ b/ABACUS.develop/source/src_pw/electrons.cpp @@ -451,7 +451,7 @@ void Electrons::c_bands(const int &istep) ofs_running << setprecision(6) << setiosflags(ios::fixed) << setiosflags(ios::showpoint); for (int ik = 0;ik < kv.nks;ik++) { - hm.init_k(ik); + hm.hpw.init_k(ik); //=========================================== // Conjugate-Gradient diagonalization diff --git a/ABACUS.develop/source/src_pw/hamilt.cpp b/ABACUS.develop/source/src_pw/hamilt.cpp index 5d58291005..d26b190acd 100644 --- a/ABACUS.develop/source/src_pw/hamilt.cpp +++ b/ABACUS.develop/source/src_pw/hamilt.cpp @@ -13,12 +13,6 @@ Hamilt::~Hamilt() } -void Hamilt::init_k(const int ik) -{ - this->hpw.init_k(ik); -} - - void Hamilt::diago( const int &istep, const int &iter, @@ -28,7 +22,6 @@ void Hamilt::diago( { TITLE("Hamilt","diago"); timer::tick("Hamilt","diago",'F'); -// timer::tick("Hamilt","diago"); double avg = 0.0; // set ik0 because of mem_saver. @@ -36,34 +29,29 @@ void Hamilt::diago( // but if mem_saver is used, ik0=0. int ik0 = ik; - // mohan add 2010-09-07 - // mohan update 2010-09-14, about wanf2 if(CALCULATION=="nscf" && wf.mem_saver==1) { - //if(LOCAL_BASIS==0) xiaohui modify 2013-09-02 - if(BASIS_TYPE=="pw") //xiaohui add 2013-09-02 + if(BASIS_TYPE=="pw") { // generate PAOs first, then diagonalize to get // inital wavefunctions. wf.diago_PAO_in_pw_k2(ik, wf.evc[0]); } - //else if(LOCAL_BASIS==4) xiaohui modify 2013-09-02 - else if(BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-02. Attention! Maybe "BASIS_TYPE==lcao_in_pw" is just ok. + else if(BASIS_TYPE=="lcao_in_pw") { wf.LCAO_in_pw_k(ik, wf.wanf2[0]); } ik0 = 0; } - //if (LOCAL_BASIS) xiaohui modify 2013-09-02 - if(BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-02. Attention... + if(BASIS_TYPE=="lcao_in_pw") { - //if(DIAGO_TYPE=="lapack") xiaohui modify 2013-09-02 - if(KS_SOLVER=="lapack") //xiaohui add 2013-09-02 + if(KS_SOLVER=="lapack") { assert(NLOCAL >= NBANDS); this->cinitcgg(ik, NLOCAL, NBANDS, wf.wanf2[ik0], wf.evc[ik0], wf.ekb[ik]); - + + // for tests /* cout << " Check evc unit of ik = " << ik0 << endl; for(int ib=0; ib 0 || istep > 0 || ntry > 0) { @@ -126,14 +102,17 @@ void Hamilt::diago( // if cinitcgg has not been called, // we need to reorder the eigenvectors. } - //else if ( DIAGO_TYPE=="dav" ) xiaohui modify 2013-09-02 - else if(KS_SOLVER=="dav") //xiaohui add 2013-09-02 + else if(KS_SOLVER=="dav") { Diago_David david; - if(NPOL==1) david.diag(wf.evc[ik0], wf.ekb[ik], kv.ngk[ik], + if(NPOL==1) + { + david.diag(wf.evc[ik0], wf.ekb[ik], kv.ngk[ik], NBANDS, precondition, DIAGO_DAVID_NDIM, - ETHR, DIAGO_CG_MAXITER, notconv, avg); - else{ + ETHR, DIAGO_CG_MAXITER, notconv, avg); + } + else + { david.diag(wf.evc[ik0], wf.ekb[ik], wf.npwx*NPOL, NBANDS, precondition, DIAGO_DAVID_NDIM, ETHR, DIAGO_CG_MAXITER, notconv, avg); @@ -141,8 +120,7 @@ void Hamilt::diago( } else { - //WARNING_QUIT("calculate_bands","Check DIAGO_TYPE !"); xiaohui modify 2013-09-02 - WARNING_QUIT("calculate_bands","Check KS_SOLVER !"); //xiaohui add 2013-09-02 + WARNING_QUIT("calculate_bands","Check KS_SOLVER !"); } avg_iter += avg; ++ntry; diff --git a/ABACUS.develop/source/src_pw/hamilt.h b/ABACUS.develop/source/src_pw/hamilt.h index 264bdbcec4..8b96f4f8fc 100644 --- a/ABACUS.develop/source/src_pw/hamilt.h +++ b/ABACUS.develop/source/src_pw/hamilt.h @@ -12,8 +12,6 @@ class Hamilt Hamilt(); ~Hamilt(); - void init_k(const int ik); - void init_before_ions(void); void init_before_electrons(void); diff --git a/ABACUS.develop/source/src_pw/sto_elec.cpp b/ABACUS.develop/source/src_pw/sto_elec.cpp index 51f99a0c82..4403bdb6c0 100644 --- a/ABACUS.develop/source/src_pw/sto_elec.cpp +++ b/ABACUS.develop/source/src_pw/sto_elec.cpp @@ -318,7 +318,7 @@ void Stochastic_Elec::c_bands(const int &istep) for (int ik = 0;ik < kv.nks;ik++) { - hm.init_k(ik); + hm.hpw.init_k(ik); //=========================================== // Conjugate-Gradient diagonalization diff --git a/ABACUS.develop/source/src_pw/wavefunc.cpp b/ABACUS.develop/source/src_pw/wavefunc.cpp index 8d32127240..6b51084715 100644 --- a/ABACUS.develop/source/src_pw/wavefunc.cpp +++ b/ABACUS.develop/source/src_pw/wavefunc.cpp @@ -104,13 +104,12 @@ LiuXh modify 20180619*/ if(CALCULATION=="nscf" && wf.mem_saver==1) { // mohan add 2010-09-07 - // only available for first principle now. this->evc = new ComplexMatrix[1]; this->wanf2 = new ComplexMatrix[1]; evc[0].create(NBANDS, npwx * NPOL);//added by zhengdy-soc - //if(LOCAL_BASIS && LINEAR_SCALING==0) xiaohui modify 2013-09-02 - if(BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-02 + + if(BASIS_TYPE=="lcao_in_pw") { wanf2[0].create(NLOCAL, npwx * NPOL); cout << " Memory for wanf2 (MB): " << @@ -129,9 +128,7 @@ LiuXh modify 20180619*/ this->evc[ik].create(NBANDS, npwx * NPOL);//added by zhengdy-soc //Mohan add 2010-1-10 - //xiaohui add 2013 -08-01 - //if (LOCAL_BASIS || winput::out_spillage==2) xiaohui modify 2013-09-02 - if((BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") || winput::out_spillage==2) //xiaohui add 2013-09-02 + if((BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") || winput::out_spillage==2) { this->wanf2[ik].create(NLOCAL, npwx * NPOL);//added by zhengdy-soc } @@ -164,7 +161,6 @@ void wavefunc::wfcinit(void) TITLE("wavefunc","wfcinit"); timer::tick("wavefunc","wfcinit",'C'); - //this->init_at_1(); this->wfcinit_k(); @@ -173,8 +169,7 @@ void wavefunc::wfcinit(void) //================================ // Occupations are computed here //================================ - //if(LOCAL_BASIS == 0 && LINEAR_SCALING == 0) xiaohui modify 2013-09-02 - if(BASIS_TYPE=="pw") //xiaohui add 2013-09-02 + if(BASIS_TYPE=="pw") { // mohan fix bug 2011-02-25, // in nscf, occupations is not needed, @@ -231,15 +226,11 @@ int wavefunc::get_starting_nw(void)const -// not full test. -void wavefunc::PAO_in_pw_k(const int &ik, ComplexMatrix &wvf) -{ - TITLE("wavefunc","PAO_in_pw_k"); - //assert(LINEAR_SCALING==0); xiaohui modify 2013-09-02 - //assert(LOCAL_BASIS==2); xiaohui modify 2013-09-02. Attention! Here why assert LOCAL_BASIS=2 ??? - - this->atomic_wfc(ik, this->npw, ucell.lmax_ppwf, wvf, ppcell.tab_at, NQX, DQ); -} +//void wavefunc::PAO_in_pw_k(const int &ik, ComplexMatrix &wvf) +//{ +// TITLE("wavefunc","PAO_in_pw_k"); +// this->atomic_wfc(ik, this->npw, ucell.lmax_ppwf, wvf, ppcell.tab_at, NQX, DQ); +//} void wavefunc::LCAO_in_pw_k(const int &ik, ComplexMatrix &wvf) { @@ -262,7 +253,7 @@ void wavefunc::LCAO_in_pw_k(const int &ik, ComplexMatrix &wvf) // (2) diago to get wf.ekb, then the weights can be calculated. //------------------------------------------------------------- hm.hpw.init(this->npwx, NPOL, ppcell.nkb, pw.nrxx); - hm.init_k(ik); + hm.hpw.init_k(ik); //hm.cinitcgg(ik ,NLOCAL, NBANDS, wvf, wvf, ekb[ik]); // for(int ib=0; ib q) // pengfei 2016-11-23 { - TITLE("wavefunc","LCAO_in_pw_k_q"); - timer::tick("wavefunc","LCAO_in_pw_k_q",'G'); - //assert(LOCAL_BASIS==4); xiaohui modify 2013-09-01 - assert(BASIS_TYPE=="lcao_in_pw"); //xiaohui add 2013-09-01. Attention! How about "BASIS_TYPE=="lcao""??? + TITLE("wavefunc","LCAO_in_pw_k_q"); + timer::tick("wavefunc","LCAO_in_pw_k_q",'G'); + //assert(LOCAL_BASIS==4); xiaohui modify 2013-09-01 + assert(BASIS_TYPE=="lcao_in_pw"); //xiaohui add 2013-09-01. Attention! How about "BASIS_TYPE=="lcao""??? - Wavefunc_in_pw::produce_local_basis_q_in_pw(ik, wvf, this->table_local, q); + Wavefunc_in_pw::produce_local_basis_q_in_pw(ik, wvf, this->table_local, q); - timer::tick("wavefunc","LCAO_in_pw_k_q",'G'); - return; + timer::tick("wavefunc","LCAO_in_pw_k_q",'G'); + return; } @@ -295,7 +286,7 @@ void wavefunc::diago_PAO_in_pw_k(const int &ik, ComplexMatrix &wvf) { TITLE("wavefunc","diago_PAO_in_pw_k"); - hm.init_k(ik); + hm.hpw.init_k(ik); this->diago_PAO_in_pw_k2(ik, wvf); return; @@ -367,35 +358,13 @@ void wavefunc::wfcinit_k(void) for(int ik=0; ikLCAO_in_pw_k(ik, wf.wanf2[ik]); } - //else if(LOCAL_BASIS==3) xiaohui modify 2013-09-02. - //{ - // // prepare for Jlq, gauss, slater-type - // // which is anylatic basis. - // WARNING_QUIT("wavefunc::wfcinit_k","not ready for local_basis=3"); - //} xiaohui modify 2013-09-02. Attention... - - //else if(LOCAL_BASIS==2) xiaohui modify 2013-09-02 - //{ - // // prepare for using PAO directly. - // this->PAO_in_pw_k(ik, wf.wanf2[ik]); - // WARNING_QUIT("wavefunc::wfcinit_k","not ready for local_basis=2"); - //} xiaohui modify 2013-09-02. Attention... - - //else if(LOCAL_BASIS==1) xiaohui modify 2013-09-02 - //{ - // // prepare for wannier functions. - // WARNING_QUIT("wavefunc::wfcinit_k","not ready for local_basis=1"); - //} xiaohui modify 2013-09-02. Attention... - - //else if(LOCAL_BASIS==0) xiaohui modify 2013-09-02 - else if (BASIS_TYPE=="pw") //xiaohui add 2013-09-02 + else if (BASIS_TYPE=="pw") { // get the wave functions // by first diagolize PAO @@ -428,7 +397,8 @@ void wavefunc::wfcinit_k(void) cout <<"lcao_box3 = "< gkqg, Rcar[NLOCAL][NLOCAL][NR]; // k+G+qg, Rcartesian for(int iw1=0;iw1 phase; + double arg; + complex phase; for(int iq=0; iqLCAO_in_pw_k_q(ik, Mat, qg); for(int iw=0; iw( cos(arg), -sin(arg) ); - overlap_aux[iw1][iw2][g][ir] += conj(wf.wanf2[ik](iw1,ig)) * wanf2_q[ik][iw2][ig] * phase/static_cast(kv.nks); // Peize Lin add static_cast 2018-07-14 + overlap_aux[iw1][iw2][g][ir] += conj(wf.wanf2[ik](iw1,ig)) + * wanf2_q[ik][iw2][ig] * phase/static_cast(kv.nks); + // Peize Lin add static_cast 2018-07-14 } } - + } } + } } for(int g=0; g( overlap_R[iw1][iw2][g][ir], overlap_I[iw1][iw2][g][ir]); + overlap[iw1][iw2][g][ir] = complex( overlap_R[iw1][iw2][g][ir], + overlap_I[iw1][iw2][g][ir]); } + } + } + } //------------------------------ // store the overlap in q_(iq) @@ -598,6 +614,7 @@ void wavefunc::wfcinit_k(void) for(int g=0; g ***R; int ** Rmax; - - }; #endif //wavefunc From 7904e281ebe95bac18bc1b87c09f7131e65b63c5 Mon Sep 17 00:00:00 2001 From: linpz Date: Thu, 25 Feb 2021 13:02:00 +0800 Subject: [PATCH 149/233] 1. add scalapack_gvx in Pdiag_Double::diago_complex_begin() --- .../source/src_global/scalapack_connector.h | 5 + .../source/src_pdiag/pdiag_double.cpp | 118 ++++++++++++++++++ 2 files changed, 123 insertions(+) diff --git a/ABACUS.develop/source/src_global/scalapack_connector.h b/ABACUS.develop/source/src_global/scalapack_connector.h index a4d8c84b7f..541cbd80fa 100644 --- a/ABACUS.develop/source/src_global/scalapack_connector.h +++ b/ABACUS.develop/source/src_global/scalapack_connector.h @@ -76,6 +76,11 @@ extern "C" const double* vl, const double* vu, const int* il, const int* iu, const double* abstol, int* m, int* nz, double* w, const double*orfac, double* Z, const int* iz, const int* jz, const int*descz, double* work, int* lwork, int*iwork, int*liwork, int* ifail, int*iclustr, double*gap, int* info); + void pzhegvx_(const int* itype, const char* jobz, const char* range, const char* uplo, + const int* n, std::complex* A, const int* ia, const int* ja, const int*desca, std::complex* B, const int* ib, const int* jb, const int*descb, + const double* vl, const double* vu, const int* il, const int* iu, + const double* abstol, int* m, int* nz, double* w, const double*orfac, std::complex* Z, const int* iz, const int* jz, const int*descz, + std::complex* work, int* lwork, double* rwork, int* lrwork, int*iwork, int*liwork, int* ifail, int*iclustr, double*gap, int* info); } /* diff --git a/ABACUS.develop/source/src_pdiag/pdiag_double.cpp b/ABACUS.develop/source/src_pdiag/pdiag_double.cpp index c604e34f71..df466f5e1a 100644 --- a/ABACUS.develop/source/src_pdiag/pdiag_double.cpp +++ b/ABACUS.develop/source/src_pdiag/pdiag_double.cpp @@ -953,6 +953,124 @@ void Pdiag_Double::diago_complex_begin(const int &ik, complex **wfc, Com delete[] work; timer::tick("Diago_LCAO_Matrix","gath_eig_complex",'G'); } // GenELPA method + else if(KS_SOLVER=="scalapack_gvx") + { + ComplexMatrix h_tmp(this->ncol, this->nrow, false); + memcpy( h_tmp.c, ch_mat, sizeof(complex)*this->ncol*this->nrow ); + ComplexMatrix s_tmp(this->ncol, this->nrow, false); + memcpy( s_tmp.c, cs_mat, sizeof(complex)*this->ncol*this->nrow ); + wfc_2d.create(this->ncol, this->nrow, false); + + const char jobz='V', range='I', uplo='U'; + const int itype=1, il=1, iu=NBANDS, one=1; + int M=0, NZ=0, lwork=-1, lrwork=-1, liwork=-1, info=0; + const double abstol=0, orfac=-1; + vector> work(1,0); + vector rwork(1,0); + vector iwork(1,0); + vector ifail(NLOCAL,0); + vector iclustr(2*DSIZE); + vector gap(DSIZE); + + pzhegvx_(&itype, &jobz, &range, &uplo, + &NLOCAL, h_tmp.c, &one, &one, desc, s_tmp.c, &one, &one, desc, + NULL, NULL, &il, &iu, &abstol, + &M, &NZ, ekb, &orfac, wfc_2d.c, &one, &one, desc, + work.data(), &lwork, rwork.data(), &lrwork, iwork.data(), &liwork, ifail.data(), iclustr.data(), gap.data(), &info); + ofs_running<<"lwork="< *work=new complex[maxnloc]; // work/buffer matrix + + int naroc[2]; // maximum number of row or column + for(int iprow=0; iprowout_lowf) + { + complex **ctot; + if(myid==0) + { + ctot = new complex*[NBANDS]; + for (int i=0; i[NLOCAL]; + ZEROS(ctot[i], NLOCAL); + } + Memory::record("Pdiag_Basic","ctot",NBANDS*NLOCAL,"cdouble"); + } + // mohan update 2021-02-12, delete BFIELD option + info=q2WFC_WFCAUG_CTOT_complex(myid, naroc, nb, + dim0, dim1, iprow, ipcol, + work, wfc, LOWF.WFC_K_aug[ik], ctot); + stringstream ss; + ss << global_out_dir << "LOWF_K_" << ik+1 << ".dat"; + // mohan add 2012-04-03, because we need the occupations for the + // first iteration. + WF_Local::write_lowf_complex( ss.str(), ctot, ik );//mohan add 2010-09-09 + if(myid==0) + { + for (int i=0; i Date: Thu, 25 Feb 2021 14:22:35 +0800 Subject: [PATCH 150/233] change wf.init to wf.allocate, change pot.init to pot.allocate --- ABACUS.develop/source/run_lcao.cpp | 6 ++-- ABACUS.develop/source/run_pw.cpp | 16 ++++----- .../source/src_ions/variable_cell.cpp | 4 +-- ABACUS.develop/source/src_pw/charge.cpp | 4 +-- ABACUS.develop/source/src_pw/charge.h | 2 +- ABACUS.develop/source/src_pw/exx_lip.cpp | 2 +- ABACUS.develop/source/src_pw/potential.cpp | 15 ++------ ABACUS.develop/source/src_pw/potential.h | 10 +++--- ABACUS.develop/source/src_pw/wavefunc.cpp | 36 +++++-------------- ABACUS.develop/source/src_pw/wavefunc.h | 2 +- 10 files changed, 30 insertions(+), 67 deletions(-) diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index 29021e04d3..a2d1fdc0c8 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -93,11 +93,11 @@ void Run_lcao::lcao_line(void) // (1) Inititlize the charge density. - CHR.init(NSPIN, pw.nrxx, pw.ngmc); + CHR.allocate(NSPIN, pw.nrxx, pw.ngmc); DONE(ofs_running,"INIT CHARGE"); // (2) Initializee the potential. - pot.init(pw.nrxx); + pot.allocate(pw.nrxx); DONE(ofs_running,"INIT POTENTIAL"); // declration @@ -130,7 +130,7 @@ void Run_lcao::lcao_line(void) pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs break; case SOME_PW: - wf.init(kv.nks); + wf.allocate(kv.nks); UFFT.allocate(); ppcell.init(ucell.ntype); hm.hpw.init(wf.npwx, NPOL, ppcell.nkb, pw.nrxx); diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp index 9b3466b837..2eaee9b228 100644 --- a/ABACUS.develop/source/run_pw.cpp +++ b/ABACUS.develop/source/run_pw.cpp @@ -70,16 +70,12 @@ void Run_pw::plane_wave_line(void) // 4 initialize charge desity and warefunctios in G_space //---------------------------------------------------------- - //===================== - // init potential - //===================== - CHR.init(NSPIN, pw.nrxx, pw.ngmc); - pot.init(pw.nrxx); - - //===================== - // init wave functions - //===================== - wf.init(kv.nks); + //===================================== + // init charge/potential/wave functions + //===================================== + CHR.allocate(NSPIN, pw.nrxx, pw.ngmc); + pot.allocate(pw.nrxx); + wf.allocate(kv.nks); UFFT.allocate(); //======================= diff --git a/ABACUS.develop/source/src_ions/variable_cell.cpp b/ABACUS.develop/source/src_ions/variable_cell.cpp index 8b6aa1297f..b524477951 100644 --- a/ABACUS.develop/source/src_ions/variable_cell.cpp +++ b/ABACUS.develop/source/src_ions/variable_cell.cpp @@ -123,13 +123,13 @@ void Variable_Cell::final_calculation_after_vc(void) // init potential //===================== CHR.init_final_scf(); - pot.init(pw.nrxx); + pot.allocate(pw.nrxx); //===================== // init wave functions //===================== if(BASIS_TYPE=="pw") { - wf.init(kv.nks); + wf.allocate(kv.nks); } else { diff --git a/ABACUS.develop/source/src_pw/charge.cpp b/ABACUS.develop/source/src_pw/charge.cpp index fad155dee7..15cb7801ef 100644 --- a/ABACUS.develop/source/src_pw/charge.cpp +++ b/ABACUS.develop/source/src_pw/charge.cpp @@ -53,9 +53,9 @@ Charge::~Charge() } } -void Charge::init(const int &nspin_in, const int &nrxx_in, const int &ngmc_in) +void Charge::allocate(const int &nspin_in, const int &nrxx_in, const int &ngmc_in) { - if (test_charge) TITLE("Charge","init"); + TITLE("Charge","allocate"); assert(allocate_rho == false); diff --git a/ABACUS.develop/source/src_pw/charge.h b/ABACUS.develop/source/src_pw/charge.h index b446a3f73d..06b48e6f49 100644 --- a/ABACUS.develop/source/src_pw/charge.h +++ b/ABACUS.develop/source/src_pw/charge.h @@ -21,7 +21,7 @@ class Charge ~Charge(); // mohan update 2021-02-20 - void init(const int &nspin_in, const int &nrxx_in, const int &ngmc_in); + void allocate(const int &nspin_in, const int &nrxx_in, const int &ngmc_in); //========================================================== // MEMBER VARIABLES : diff --git a/ABACUS.develop/source/src_pw/exx_lip.cpp b/ABACUS.develop/source/src_pw/exx_lip.cpp index 928e69416a..d7ab7c6719 100644 --- a/ABACUS.develop/source/src_pw/exx_lip.cpp +++ b/ABACUS.develop/source/src_pw/exx_lip.cpp @@ -678,7 +678,7 @@ void Exx_Lip::read_q_pack() q_pack->wf_ptr = new wavefunc(); - q_pack->wf_ptr->init(q_pack->kv_ptr->nks); + q_pack->wf_ptr->allocate(q_pack->kv_ptr->nks); // mohan update 2021-02-25 // q_pack->wf_ptr->init(q_pack->kv_ptr->nks,q_pack->kv_ptr,ucell_ptr,pw_ptr,&ppcell,&ORB,&hm,&Pkpoints); q_pack->wf_ptr->table_local.create(ucell.ntype, ucell.nmax_total, NQX); // q_pack->wf_ptr->table_local.create(q_pack->wf_ptr->ucell_ptr->ntype, q_pack->wf_ptr->ucell_ptr->nmax_total, NQX); diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index 61c18716b8..4a6dd27920 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -20,9 +20,9 @@ potential::~potential() delete[] vrs1; } -void potential::init(const int nrxx) +void potential::allocate(const int nrxx) { - if (test_potential) TITLE("potential","init"); + TITLE("potential","allocate"); assert(nrxx>0); delete[] this->vltot; @@ -831,17 +831,6 @@ void potential::newd(void) return; } // end subroutine newd -void potential::print_pot(ofstream &ofs)const -{ - // ofs << "\n potinit() : "; - ofs << "\n vtxc = " << en.vtxc; - ofs << "\n etxc = " << en.etxc; - ofs << "\n ehart = " << en.ehart; - // ofs << "\n charge = " << charge; - out.printr1_d(ofs, " vltot : ", vltot, pw.nrxx); - out.printrm(ofs, " vrs : ", vrs); -} - //========================================================== // this function aims to add external time-dependent potential diff --git a/ABACUS.develop/source/src_pw/potential.h b/ABACUS.develop/source/src_pw/potential.h index dd947eda64..d6fb6070c5 100644 --- a/ABACUS.develop/source/src_pw/potential.h +++ b/ABACUS.develop/source/src_pw/potential.h @@ -32,13 +32,13 @@ class potential double *vltot; int out_potential; // mohan add 2011-02-28 - // member functions - void init(const int nrxx); + void allocate(const int nrxx); //------------------------------------------------ // if delta_vh==true, vl_pseudo not calculated, // V(rho-rho_atom) is calculated, // V(xc) is calculated. + //------------------------------------------------ // if vna==true, vl_pseudo is calculated, // V(rho_atom) is calclated, // V(xc) is not calculated. @@ -48,15 +48,13 @@ class potential void v_of_rho( double** rho_in, double &ehart, double &etxc, double &vtxc, matrix &v, const bool delta_vh=false, const bool vna=false); - void newd(void); - void set_vrs(void); void v_xc(double** rho_in, double &etxc, double &vtxc, matrix &v); - public: + void newd(void); - void print_pot(ofstream &ofs)const; + public: // mohan add 2011-02-28 // here vh is complex because the array is got after complex FFT. diff --git a/ABACUS.develop/source/src_pw/wavefunc.cpp b/ABACUS.develop/source/src_pw/wavefunc.cpp index 6b51084715..ef44b3ddac 100644 --- a/ABACUS.develop/source/src_pw/wavefunc.cpp +++ b/ABACUS.develop/source/src_pw/wavefunc.cpp @@ -50,21 +50,10 @@ void wavefunc::init_local(void) return; } -void wavefunc::init(const int nks) +void wavefunc::allocate(const int nks) { -/*LiuXh modify 20180619 - static bool done_once = false; - if(done_once) - { - return; - } - else - { - done_once = true; - } -LiuXh modify 20180619*/ + TITLE("wavefunc","allocate"); - TITLE("wavefunc","init"); this->npwx = this->setupIndGk(pw, nks); OUT(ofs_running,"npwx",npwx); @@ -72,11 +61,11 @@ LiuXh modify 20180619*/ assert(nks > 0); assert(NBANDS > 0); + // allocate for kinetic energy delete[] g2kin; - this->g2kin = new double[npwx]; // [npw],kinetic energy + this->g2kin = new double[npwx]; ZEROS(g2kin, npwx); Memory::record("wavefunc","g2kin",npwx,"double"); - if(test_wf)OUT(ofs_running,"g2kin allocation","Done"); // if use spin orbital, do not double nks but double allocate evc and wanf2. int prefactor = 1; @@ -90,11 +79,10 @@ LiuXh modify 20180619*/ } this->allocate_ekb = true; - this->wg.create(nks, NBANDS); // the weight of each k point and band + // the weight of each k point and band + this->wg.create(nks, NBANDS); Memory::record("wavefunc","et",nks*NBANDS,"double"); Memory::record("wavefunc","wg",nks*NBANDS,"double"); - if(test_wf)OUT(ofs_running, "et allocation","Done"); - if(test_wf)OUT(ofs_running, "wg allocation","Done"); delete[] evc; delete[] wanf2; @@ -107,7 +95,8 @@ LiuXh modify 20180619*/ this->evc = new ComplexMatrix[1]; this->wanf2 = new ComplexMatrix[1]; - evc[0].create(NBANDS, npwx * NPOL);//added by zhengdy-soc + // //added by zhengdy-soc + evc[0].create(NBANDS, npwx * NPOL); if(BASIS_TYPE=="lcao_in_pw") { @@ -138,15 +127,6 @@ LiuXh modify 20180619*/ Memory::record("wavefunc","evc",nks2*NBANDS*(prefactor*npwx),"complexmatrix") << endl; } - if(test_wf) - { - OUT(ofs_running,"evc allocation","Done"); - //if(LOCAL_BASIS) xiaohui modify 2013-09-02 - if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-02 - { - OUT(ofs_running,"wanf2 allocation","Done"); - } - } //showMemStats(); return; } diff --git a/ABACUS.develop/source/src_pw/wavefunc.h b/ABACUS.develop/source/src_pw/wavefunc.h index c85b3a0344..51945fba24 100644 --- a/ABACUS.develop/source/src_pw/wavefunc.h +++ b/ABACUS.develop/source/src_pw/wavefunc.h @@ -17,7 +17,7 @@ class wavefunc : public WF_atomic ~wavefunc(); // allocate memory - void init(const int nks); + void allocate(const int nks); void init_local(void); int out_wf; //qianrui modify 2020-10-19 From 8c0727e9a61396f85bdd42803f236d833b9dbf79 Mon Sep 17 00:00:00 2001 From: mohan Date: Thu, 25 Feb 2021 15:48:06 +0800 Subject: [PATCH 151/233] add H_Ewald_pw.h and .cpp, which is used for the ewald term --- ABACUS.develop/source/Makefile.Objects | 1 + ABACUS.develop/source/src_io/eximport.cpp | 3 +- ABACUS.develop/source/src_lcao/ELEC_scf.cpp | 5 +- ABACUS.develop/source/src_lcao/force_lcao.cpp | 14 +- .../source/src_lcao/stress_lcao.cpp | 3 +- ABACUS.develop/source/src_pw/H_Ewald_pw.cpp | 359 +++++++++++++++++ ABACUS.develop/source/src_pw/H_Ewald_pw.h | 46 +++ ABACUS.develop/source/src_pw/H_Hartree_pw.cpp | 114 ++++++ ABACUS.develop/source/src_pw/H_XC_pw.cpp | 178 +++++++++ ABACUS.develop/source/src_pw/electrons.cpp | 6 +- ABACUS.develop/source/src_pw/energy.cpp | 375 +----------------- ABACUS.develop/source/src_pw/energy.h | 13 - ABACUS.develop/source/src_pw/forces.cpp | 6 +- ABACUS.develop/source/src_pw/potential.cpp | 14 +- ABACUS.develop/source/src_pw/sto_elec.cpp | 5 +- ABACUS.develop/source/src_pw/stress.cpp | 4 +- 16 files changed, 747 insertions(+), 399 deletions(-) create mode 100644 ABACUS.develop/source/src_pw/H_Ewald_pw.cpp create mode 100644 ABACUS.develop/source/src_pw/H_Ewald_pw.h create mode 100644 ABACUS.develop/source/src_pw/H_Hartree_pw.cpp create mode 100644 ABACUS.develop/source/src_pw/H_XC_pw.cpp diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 5c3312a08d..d40a7e696f 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -210,6 +210,7 @@ charge_broyden.o \ charge_extra.o \ xc_gga_pw.o \ potential.o \ +H_Ewald_pw.o\ write_pot.o\ potential_libxc.o \ efield.o \ diff --git a/ABACUS.develop/source/src_io/eximport.cpp b/ABACUS.develop/source/src_io/eximport.cpp index cc1f19b938..da7c9cdf49 100644 --- a/ABACUS.develop/source/src_io/eximport.cpp +++ b/ABACUS.develop/source/src_io/eximport.cpp @@ -699,6 +699,7 @@ void eximport::in_evc(ifstream &in) //=========== // energy //=========== +#include "src_pw/H_Ewald_pw.h" void eximport::out_energy(ofstream &out_data) { //cout << "\n ==> out_energy" << endl; @@ -709,7 +710,7 @@ void eximport::out_energy(ofstream &out_data) out_data << setw(20) << en.eband + en.deband << endl; //6.5 out_data << setw(20) << en.ehart << endl; //6.6 out_data << setw(20) << en.etxc - en.etxcc << endl; //6.7 - out_data << setw(20) << en.ewld << endl; //6.8 + out_data << setw(20) << H_Ewald_pw::ewald_energy << endl; //6.8 } void eximport::in_energy(ifstream &in) diff --git a/ABACUS.develop/source/src_lcao/ELEC_scf.cpp b/ABACUS.develop/source/src_lcao/ELEC_scf.cpp index 8cc556eff9..f5baa782b4 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_scf.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_scf.cpp @@ -9,6 +9,8 @@ #include "ELEC_evolve.h" #include "input_update.h" #include "src_pw/occupy.h" +//new +#include "src_pw/H_Ewald_pw.h" ELEC_scf::ELEC_scf(){} ELEC_scf::~ELEC_scf(){} @@ -21,7 +23,8 @@ void ELEC_scf::scf(const int &istep) timer::tick("ELEC_scf","scf",'D'); // (1) calculate ewald energy. - en.ewld = en.ewald(); + // mohan update 2021-02-25 + H_Ewald_pw::compute_ewald(ucell,pw); // mohan add 2012-02-08 set_ethr(); diff --git a/ABACUS.develop/source/src_lcao/force_lcao.cpp b/ABACUS.develop/source/src_lcao/force_lcao.cpp index f7a17cd088..0d8ec4c63c 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/force_lcao.cpp @@ -586,6 +586,7 @@ void Force_LCAO::cal_force_loc(void) } +#include "src_pw/H_Ewald_pw.h" void Force_LCAO::cal_force_ew(void) { timer::tick("Force_lo","cal_force_ew",'E'); @@ -608,7 +609,7 @@ void Force_LCAO::cal_force_ew(void) for (int ig = gstart; ig < pw.ngmc; ig++) { - aux[ig] *= exp(-1.0 * pw.gg[ig] * ucell.tpiba2 / en.alpha / 4.0) / (pw.gg[ig] * ucell.tpiba2); + aux[ig] *= exp(-1.0 * pw.gg[ig] * ucell.tpiba2 / H_Ewald_pw::alpha / 4.0) / (pw.gg[ig] * ucell.tpiba2); } int iat = 0; @@ -643,7 +644,7 @@ void Force_LCAO::cal_force_ew(void) // means that the processor contains G=0 term. if (gstart == 1) { - double rmax = 5.0 / (sqrt(en.alpha) * ucell.lat0); + double rmax = 5.0 / (sqrt(H_Ewald_pw::alpha) * ucell.lat0); int nrm = 0; //output of rgen: the number of vectors in the sphere @@ -669,18 +670,19 @@ void Force_LCAO::cal_force_ew(void) if (iat1 != iat2) { Vector3 d_tau = ucell.atoms[it1].tau[ia1] - ucell.atoms[it2].tau[ia2]; - en.rgen(d_tau, rmax, irr, ucell.latvec, ucell.G, r, r2, nrm); + H_Ewald_pw::rgen(d_tau, rmax, irr, ucell.latvec, ucell.G, r, r2, nrm); // return r2[n], r(n, ipol) // cout << "nrm = " << nrm << endl; for (int n = 0; n < nrm; n++) { - assert (en.alpha >= 0.0); + assert (H_Ewald_pw::alpha >= 0.0); const double rr = sqrt(r2[n]) * ucell.lat0; double factor = ucell.atoms[it1].zv * ucell.atoms[it2].zv * e2 / (rr * rr) - * (erfc(sqrt(en.alpha) * rr) / rr - + sqrt(8.0 * en.alpha / TWO_PI) * exp(-1.0 * en.alpha * rr * rr)) * ucell.lat0; + * (erfc(sqrt(H_Ewald_pw::alpha) * rr) / rr + + sqrt(8.0 * H_Ewald_pw::alpha / TWO_PI) + * exp(-1.0 * H_Ewald_pw::alpha * rr * rr)) * ucell.lat0; //remian problem //fix bug iat -> iat1 diff --git a/ABACUS.develop/source/src_lcao/stress_lcao.cpp b/ABACUS.develop/source/src_lcao/stress_lcao.cpp index cd01ba876f..b44d421700 100644 --- a/ABACUS.develop/source/src_lcao/stress_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/stress_lcao.cpp @@ -510,6 +510,7 @@ void Stress_LCAO::cal_stress_loc(void) } +#include "src_pw/H_Ewald_pw.h" void Stress_LCAO::cal_stress_ew(void) { timer::tick("Stress_lo","cal_stress_ew",'E'); @@ -615,7 +616,7 @@ void Stress_LCAO::cal_stress_ew(void) //calculate tau[na]-tau[nb] d_tau = ucell.atoms[it].tau[i] - ucell.atoms[jt].tau[j]; //generates nearest-neighbors shells - en.rgen(d_tau, rmax, irr, ucell.latvec, ucell.G, r, r2, nrm); + H_Ewald_pw::rgen(d_tau, rmax, irr, ucell.latvec, ucell.G, r, r2, nrm); for(int nr=0 ; nr dtau ; + Vector3 *r; + double *r2; + double rmax=0.0; + double rr=0.0; + double upperbound=0.0; + double fact=0; + // total ionic charge in the cell + // ewald energy computed in reciprocal space + // ewald energy computed in real space + // the difference tau_s - tau_s' + // alpha term in ewald sum + // input of the rgen routine ( not used here ) + // the square modulus of R_j-tau_s-tau_s' + // the maximum radius to consider real space sum + // buffer variable + // used to optimize alpha + + if(test_energy)OUT(ofs_running,"mxr",mxr); + r = new Vector3[mxr]; + r2 = new double[mxr]; + int* irr = new int[mxr]; + + // (1) calculate total ionic charge + double charge = 0.0; + for (int it = 0;it < cell.ntype;it++) + { + charge += cell.atoms[it].na * cell.atoms[it].zv;//mohan modify 2007-11-7 + } + if(test_energy)OUT(ofs_running,"Total ionic charge",charge); + + // (2) calculate the converged value: alpha + H_Ewald_pw::alpha = 2.90; + do + { + alpha -= 0.10; + // choose alpha in order to have convergence in the sum over G + // upperbound is a safe upper bound for the error in the sum over G + + if (alpha <= 0.0) + { + WARNING_QUIT("ewald","Can't find optimal alpha."); + } + upperbound = 2.0 * charge * charge * sqrt(2.0 * alpha / TWO_PI) * + erfc(sqrt(cell.tpiba2 * pwb.ggchg / 4.0 / alpha)); + } + while (upperbound > 1.0e-7); + if(test_energy)OUT(ofs_running,"alpha",alpha); + if(test_energy)OUT(ofs_running,"Upper bound",upperbound); + + // G-space sum here. + // Determine if this processor contains G=0 and set the constant term + if (pwb.gstart == 1) + { + ewaldg = - charge * charge / alpha / 4.0; + } + else + { + ewaldg = 0.0; + } + + // in plane wave basis, only use k=0 point is not + // called "gamma_only", only if the wave functions + // are stored as double type, the gamma_only = true. + // I don't know why "gamma_only" in plane wave + // makes the fact below is 2, that's a little complicated + // to understand. I think that may because only half + // the G vectors are used. Unfortunately implement the + // function hasn't in my plan list yet. + // + // but that's not the term "gamma_only" I want to use in LCAO, + fact = 1.0; + + //ofs_running << "\n pwb.gstart = " << pwb.gstart << endl; + + for (int ig=pwb.gstart; ig rhon = ZERO; + for (int it=0; it( cell.atoms[it].zv ) * conj( pwb.strucFac(it, ig)); + } + if(pwb.gg[ig] >= 1.0e-12) //LiuXh 20180515 + { + ewaldg += fact * abs(rhon) * abs(rhon) + * exp(- pwb.gg[ig] * cell.tpiba2 / alpha / 4.0 ) / pwb.gg[ig] / cell.tpiba2; + } + } + + ewaldg = FOUR_PI / cell.omega * ewaldg; + +// cout << "\n ewaldg = " << ewaldg; + + // Here add the other constant term + if(pwb.gstart == 1) + { + for (int it = 0; it < cell.ntype;it++) + { + ewaldg = ewaldg - cell.atoms[it].na * cell.atoms[it].zv * cell.atoms[it].zv * sqrt(8.0 / TWO_PI * alpha); + } + }//mohan modify 2007-11-7, 2010-07-26 + + // R-space sum here (only done for the processor that contains G=0) + ewaldr = 0.0; + if (pwb.gstart == 1) + { + rmax = 4.0 / sqrt(alpha) / cell.lat0; + if(test_energy)OUT(ofs_running,"rmax(unit lat0)",rmax); + // with this choice terms up to ZiZj*erfc(4) are counted (erfc(4)=2x10^-8 + int nt1=0; + int nt2=0; + + for (nt1 = 0; nt1 < cell.ntype; nt1++) + { + for (nt2 = 0; nt2 < cell.ntype; nt2++) + { + for (na = 0; na < cell.atoms[nt1].na; na++) + { + for (nb = 0; nb < cell.atoms[nt2].na; nb++) + { + //calculate tau[na]-tau[nb] + dtau = cell.atoms[nt1].tau[na] - cell.atoms[nt2].tau[nb]; + //generates nearest-neighbors shells + H_Ewald_pw::rgen(dtau, rmax, irr, cell.latvec, cell.G, r, r2, nrm); + // at-->cell.latvec, bg-->G + // and sum to the real space part + + if (test_energy>1) + { + OUT("dtau.x",dtau.x); + OUT("dtau.y",dtau.y); + OUT("dtau.z",dtau.z); + OUT("nrm",nrm); + } + for (nr = 0;nr < nrm;nr++) + { + rr = sqrt(r2 [nr]) * cell.lat0; + ewaldr = ewaldr + cell.atoms[nt1].zv * cell.atoms[nt2].zv * + erfc(sqrt(alpha) * rr) / rr; + + } // enddo + if (test_energy>1) OUT("ewaldr",ewaldr); + } // enddo + } // enddo + } // nt2 + }//nt1 + } // endif + + ewalds = 0.50 * e2 * (ewaldg + ewaldr); + + // mohan fix bug 2010-07-26 + Parallel_Reduce::reduce_double_pool( ewalds ); + + if (test_energy>1) + { + OUT("ewaldg",ewaldg); + OUT("ewaldr",ewaldr); + OUT("ewalds",ewalds); + } + + delete[] irr; + delete[] r; + delete[] r2; + + // set the Ewald energy, mohan add 2021-02-25 + H_Ewald_pw::ewald_energy = ewalds; + + timer::tick("H_Ewald_pw","compute_ewald"); + return; +} // end function ewald + + +void H_Ewald_pw::rgen( + const Vector3 &dtau, + const double &rmax, + int *irr, + const Matrix3 &latvec, + const Matrix3 &G, + Vector3 *r, + double *r2, + int &nrm) +{ + //------------------------------------------------------------------- + // generates neighbours shells (in units of alat) with length + // less than rmax,and returns them in order of increasing length. + // r=i*a1+j*a2+k*a3-dtau, + // where a1,a2,a3 are the vectors defining the lattice + + // first the dummy variables + // int nrm, mxr; + // output: the number of vectors in the spher + // input: the maximum number of vectors + + // real r (3, mxr), r2 (mxr), at (3, 3), bg (3, 3), dtau (3),rmax; + // output: coordinates of vectors R+tau_s-tau + // output: square modulus of vectors R+tau_s- + // input: direct lattice vectors + // input: reciprocal lattice vectors + // input: the vector tau_s-tau_s' + // input: the radius of the sphere in real sp + // and here the local variables + + int nm1=0; + int nm2=0; + int nm3=0; + int i=0; + int j=0; + int k=0; + // index on R vectors for order + // maximum values for trial vectors + // counters on trial vectors + // counter on polarizations + // counter on R vectors + // index of swapping + // used for swapping + + Vector3 t; + Vector3 t1; + double tt=0.0; + double bg1[3]={0,0,0}; + // buffer contains the actual r + // buffer cotains the modulus of actual r + // used for swapping + // function to find the norm of a vector + // external dnrm2, see myfunc + + nrm = 0; + + if (rmax == 0.0) + { + return; + } + + bg1[0] = G.e11; + bg1[1] = G.e12; + bg1[2] = G.e13; + + nm1 = (int)(dnrm2(3, bg1, 1) * rmax + 2); + + bg1[0] = G.e21; + bg1[1] = G.e22; + bg1[2] = G.e23; + + nm2 = (int)(dnrm2(3, bg1, 1) * rmax + 2); + + bg1[0] = G.e31; + bg1[1] = G.e32; + bg1[2] = G.e33; + + nm3 = (int)(dnrm2(3, bg1, 1) * rmax + 2); + + if (test_energy>1) + { + OUT("nm1",nm1); + OUT("nm2",nm2); + OUT("nm3",nm3); + } + + for (i = -nm1; i <= nm1; i++) // mohan fix bug, add '='. 2009-02-27 + { + for (j = -nm2; j <= nm2; j++) + { + for (k = -nm3; k <= nm3; k++) + { + Vector3 t1(i,j,k); +// out.printV3(t1); + t = t1 * latvec; // bug ! first '*latvec', second '-dtau'. + t = t - dtau; // bug ! t = t - dtau, not t1 = t1 -tau; + +// out.printV3(t); // mohan fix 2bugs here, 2009-2-27 +// out.printM3("latvec",latvec); + + tt = t.x * t.x + t.y * t.y + t.z * t.z; + + if (tt <= rmax * rmax && abs(tt) > 1.e-10) + { + if (nrm > mxr) + { + cerr << "\n rgen, too many r-vectors," << nrm; + } + r[nrm] = t; + r2[nrm] = tt; + nrm++; + } // endif + } // enddo + } // enddo + } // enddo + + // reorder the vectors in order of increasing magnitude + // initialize the index inside sorting routine + irr[0] = 0; + if (nrm > 1) + { + heapsort(nrm, r2, irr); + } + + // mohan fix bug 2011-06-07 + for(int i=0; i &dtau, + const double &rmax, + int *irr, + const Matrix3 &at, + const Matrix3 &bg, + Vector3 *r, + double *r2, + int &nrm + ); + + // the coefficient of ewald method + static double alpha; + static int mxr; + +}; + +#endif //ewald energy diff --git a/ABACUS.develop/source/src_pw/H_Hartree_pw.cpp b/ABACUS.develop/source/src_pw/H_Hartree_pw.cpp new file mode 100644 index 0000000000..9a49f0dc04 --- /dev/null +++ b/ABACUS.develop/source/src_pw/H_Hartree_pw.cpp @@ -0,0 +1,114 @@ +//-------------------------------------------------------------------- +// Transform charge density to hartree potential. +//-------------------------------------------------------------------- +void potential::v_h(int NSPIN,double &ehart, matrix &v, double** rho) +{ + TITLE("potential","v_h"); + timer::tick("potential","v_hartree"); + + complex *Porter = UFFT.porter; + + // Hartree potential VH(r) from n(r) + ZEROS( Porter, pw.nrxx ); + int nspin0 = 1; + if(NSPIN==2)nspin0 = NSPIN; + for(int is=0; is( rho[is][ir], 0.0 ); + } + } + + //============================= + // bring rho (aux) to G space + //============================= + pw.FFT_chg.FFT3D(Porter, -1); + + //double charge; + //if (pw.gstart == 1) + //{ + // charge = ucell.omega * Porter[pw.ig2fftc[0]].real(); + //} + //OUT(ofs_running, "v_h charge", charge); + + //======================================================= + // calculate hartree potential in G-space (NB: V(G=0)=0 ) + //======================================================= + ehart = 0.0; + + complex *vh_g = new complex[pw.ngmc]; + ZEROS(vh_g, pw.ngmc); + + for (int ig = pw.gstart; ig= 1.0e-12) //LiuXh 20180410 + { + const double fac = e2 * FOUR_PI / (ucell.tpiba2 * pw.gg [ig]); + + ehart += ( conj( Porter[j] ) * Porter[j] ).real() * fac; + vh_g[ig] = fac * Porter[j]; + } + } + + Parallel_Reduce::reduce_double_pool( ehart ); + ehart *= 0.5 * ucell.omega; + + //cout << " ehart=" << ehart << endl; + + ZEROS(Porter, pw.nrxx); + + for (int ig = 0;ig < pw.ngmc;ig++) + { + Porter[pw.ig2fftc[ig]] = vh_g[ig]; + } + + //========================================== + //transform hartree potential to real space + //========================================== + pw.FFT_chg.FFT3D(Porter, 1); + //========================================== + //Add hartree potential to the xc potential + //========================================== + + if(NSPIN==4) + for (int ir = 0;ir < pw.nrxx;ir++) + { + v(0, ir) += Porter[ir].real(); + } + else + for (int is = 0;is < NSPIN;is++) + { + for (int ir = 0;ir < pw.nrxx;ir++) + { + v(is, ir) += Porter[ir].real(); + } + } + + //------------------------------------------- + // output the Hartree potential into a file. + //------------------------------------------- + if(out_potential==-2) + { + cout << " output VH" << endl; + int is = 0; + int iter = 0; + int precision = 3; + string fn = "VH.dat"; + stringstream ss; + ss << global_out_dir << fn; + matrix v; + v.create(1,pw.nrxx); + for(int ir=0; irwrite_potential( is, iter, ss.str(), v, precision, 1 ); + } + + timer::tick("potential","v_hartree"); + delete[] vh_g; + return; +} // end subroutine v_h + diff --git a/ABACUS.develop/source/src_pw/H_XC_pw.cpp b/ABACUS.develop/source/src_pw/H_XC_pw.cpp new file mode 100644 index 0000000000..4b49787de3 --- /dev/null +++ b/ABACUS.develop/source/src_pw/H_XC_pw.cpp @@ -0,0 +1,178 @@ +void potential::v_xc +( + double **rho_in, + double &etxc, + double &vtxc, + matrix &v) +{ + TITLE("potential","v_xc"); + timer::tick("potential","v_xc"); + //Exchange-Correlation potential Vxc(r) from n(r) + etxc = 0.0; + vtxc = 0.0; + + // the square of the e charge + // in Rydeberg unit, so * 2.0. + double e2 = 2.0; + + double rhox = 0.0; + double arhox = 0.0; + double zeta = 0.0; + double ex = 0.0; + double ec = 0.0; + double vx[2]; + double vc[2]; + + int ir, is; + int neg [3]; + + double vanishing_charge = 1.0e-10; + if (NSPIN == 1 || ( NSPIN ==4 && !DOMAG && !DOMAG_Z)) + { + // spin-unpolarized case + // for parallel : ncxyz change ==> nrxx + // 2008-06-01 mohan + for (int ir = 0;ir < pw.nrxx;ir++) + { + rhox = rho_in[0][ir] + CHR.rho_core[ir]; + arhox = abs(rhox); + if (arhox > vanishing_charge) + { + // call + XC_Functional::xc(arhox, ex, ec, vx[0], vc[0]); + //if(ir<10) + //{ + // cout << "\n ir = " << ir << " ex = " << ex << " ec = " << ec; + //} + v(0,ir) = e2 * (vx[0] + vc[0]); + etxc += e2 * (ex + ec) * rhox; + vtxc += v(0, ir) * rho_in[0][ir]; + } // endif + } //enddo + } + else if(NSPIN ==2) + { + // spin-polarized case + neg [0] = 0; + neg [1] = 0; + neg [2] = 0; + + // 2008-06-01 mohan + if (test_potential>0) cout<<"\n Begin calculate Exc(r) and Vxc(r)"; + for (ir = 0;ir < pw.nrxx;ir++) + { + rhox = rho_in[0][ir] + rho_in[1][ir] + CHR.rho_core[ir]; //HLX(05-29-06): bug fixed + arhox = abs(rhox); + + if (arhox > vanishing_charge) + { + zeta = (rho_in[0][ir] - rho_in[1][ir]) / arhox; //HLX(05-29-06): bug fixed + + if (abs(zeta) > 1.0) + { + ++neg[2]; + zeta = (zeta > 0.0) ? 1.0 : (-1.0); + } + + if (rho_in[0][ir] < 0.0) + { + ++neg[0]; + } + + if (rho_in[1][ir] < 0.0) + { + ++neg[1]; + } + + // call + XC_Functional::xc_spin(arhox, zeta, ex, ec, vx[0], vx[1], vc[0], vc[1]); + + //if(ir<10) + //{ + // cout << "\n ir = " << ir << " ex = " << ex << " ec = " << ec; + //} + + for (is = 0;is < NSPIN;is++) + { + v(is, ir) = e2 * (vx[is] + vc[is]); + } + + etxc += e2 * (ex + ec) * rhox; + + vtxc += v(0, ir) * rho_in[0][ir] + v(1, ir) * rho_in[1][ir]; + } // endif + } // enddo + if (test_potential>0) cout<<"\n End calculate Exc(r) and Vxc(r) with SPIN == 2"; + + } // nspin 2 + else if(NSPIN == 4)//noncollinear case added by zhengdy + { + for( ir = 0;ir vanishing_charge ) + { + zeta = amag / arhox; + + if ( abs( zeta ) > 1.0 ) + { + neg[1] += 1.0 / ucell.omega; + + zeta = (zeta > 0.0) ? 1.0 : (-1.0); + }//end if + + XC_Functional::xc_spin( arhox, zeta, ex, ec, vx[0], vx[1], vc[0], vc[1] ); + + etxc += e2 * ( ex + ec ) * rhox; + + v(0, ir) = e2*( 0.5 * ( vx[0] + vc[0] + vx[1] + vc[1] ) ); + vtxc += v(0,ir) * rho_in[0][ir]; + + double vs = 0.5 * ( vx[0] + vc[0] - vx[1] - vc[1] ); + if ( amag > vanishing_charge ) + { + for(int ipol = 1;ipol< 4;ipol++) + { + v(ipol, ir) = e2 * vs * rho_in[ipol][ir] / amag; + vtxc += v(ipol,ir) * rho_in[ipol][ir]; + }//end do + }//end if + }//end if + }//end do + }//end if + // energy terms, local-density contributions + + // add gradient corrections (if any) + // mohan modify 2009-12-15 + GGA_PW::gradcorr(etxc, vtxc, v); + + // parallel code : collect vtxc,etxc + // mohan add 2008-06-01 + Parallel_Reduce::reduce_double_pool( etxc ); + Parallel_Reduce::reduce_double_pool( vtxc ); + + etxc *= ucell.omega / pw.ncxyz; + vtxc *= ucell.omega / pw.ncxyz; + if (test_potential > 1) + { + OUT(ofs_running,"etxc",etxc); + OUT(ofs_running,"vtxc",vtxc); + } + + if (test_potential >0 ) cout<<"\n End calculate gradient"; + + if (test_potential > 2) + { + cout<<"\n After gradcorr : vtxc = "<etot = 0; // the total energy of the solid @@ -31,7 +31,6 @@ energy::energy() this->etxcc = 0; // the nlcc exchange and correlation this->exx = 0; // the exact exchange energy. - this->ewld = 0; // the ewald energy this->demet = 0; // correction for metals this->ef = 0; // the fermi energy } @@ -52,7 +51,8 @@ void energy::calculate_harris(const int &flag) } else if(flag==2) { - this->etot_harris = eband + deband_harris + (etxc - etxcc) + ewld + this->etot_harris = eband + deband_harris + (etxc - etxcc) + + H_Ewald_pw::ewald_energy + ehart + demet + exx + Efield::etotefield; if(INPUT.dft_plus_u) @@ -68,8 +68,9 @@ void energy::calculate_etot(void) { TITLE("energy","calculate_etot"); //cout << "\n demet in etot = " << demet << endl; - this->etot = eband + deband + (etxc - etxcc) + ewld + - ehart + demet + descf + exx + Efield::etotefield; + this->etot = eband + deband + (etxc - etxcc) + + H_Ewald_pw::ewald_energy + + ehart + demet + descf + exx + Efield::etotefield; // Peize Lin add 2014-04-03, update 2019-04-26 if(vdwd2.vdwD2) @@ -87,20 +88,7 @@ void energy::calculate_etot(void) { this->etot += dftu.EU; } - -/* - cout << resetiosflags(ios::scientific) << endl; - cout << setprecision(6) << endl; - cout << " eband=" << eband << endl; - cout << " deband=" << deband << endl; - cout << " etxc-etxcc=" << etxc-etxcc << endl; - cout << " ewld=" << ewld << endl; - cout << " ehart=" << ehart << endl; - cout << " demet=" << demet << endl; - cout << " descf=" << descf << endl; - cout << " exx=" << exx << endl; - cout << " efiled=" << Efield::etotefield << endl; - */ + return; } void energy::print_etot(const bool converged, const int &istep, const int &iter_in, @@ -129,7 +117,7 @@ bool print) this->print_format("E_one_elec",eband+deband); this->print_format("E_Hartree",ehart); this->print_format("E_xc",etxc-etxcc); - this->print_format("E_Ewald",ewld); + this->print_format("E_Ewald",H_Ewald_pw::ewald_energy); this->print_format("E_demet",demet); //mohan add 2011-12-02 this->print_format("E_descf",descf); this->print_format("E_efield",Efield::etotefield); @@ -412,351 +400,6 @@ void energy::print_format(const string &name, const double &value) return; } -// from ewald.f90 -double energy::ewald(void) -{ - TITLE("energy","ewald"); - timer::tick("energy","ewald"); - -//---------------------------------------------------------- -// Calculates Ewald energy with both G- and R-space terms. -// Determines optimal alpha. Should hopefully work for any structure. -//---------------------------------------------------------- - //int ng=0; - int nr=0; - int na=0; - int nb=0; - //int nt=0; - int nrm=0; - - double ewaldg=0.0; - double ewaldr=0.0; - double ewalds=0.0; - - Vector3 dtau ; - Vector3 *r; - double *r2; - double rmax=0.0; - double rr=0.0; - double upperbound=0.0; - double fact=0; - // total ionic charge in the cell - // ewald energy computed in reciprocal space - // ewald energy computed in real space - // the difference tau_s - tau_s' - // alpha term in ewald sum - // input of the rgen routine ( not used here ) - // the square modulus of R_j-tau_s-tau_s' - // the maximum radius to consider real space sum - // buffer variable - // used to optimize alpha - - if(test_energy)OUT(ofs_running,"mxr",mxr); - r = new Vector3[mxr]; - r2 = new double[mxr]; - int* irr = new int[mxr]; - - // (1) calculate total ionic charge - double charge = 0.0; - for (int it = 0;it < ucell.ntype;it++) - { - charge += ucell.atoms[it].na * ucell.atoms[it].zv;//mohan modify 2007-11-7 - } - if(test_energy)OUT(ofs_running,"Total ionic charge",charge); - - // (2) calculate the converged value: alpha - this->alpha = 2.90; - do - { - alpha -= 0.10; - // choose alpha in order to have convergence in the sum over G - // upperbound is a safe upper bound for the error in the sum over G - - if (alpha <= 0.0) - { - WARNING_QUIT("ewald","Can't find optimal alpha."); - } - upperbound = 2.0 * charge * charge * sqrt(2.0 * alpha / TWO_PI) * - erfc(sqrt(ucell.tpiba2 * pw.ggchg / 4.0 / alpha)); - } - while (upperbound > 1.0e-7); - if(test_energy)OUT(ofs_running,"alpha",alpha); - if(test_energy)OUT(ofs_running,"Upper bound",upperbound); - - // G-space sum here. - // Determine if this processor contains G=0 and set the constant term - if (pw.gstart == 1) - { - ewaldg = - charge * charge / alpha / 4.0; - } - else - { - ewaldg = 0.0; - } - - // in plane wave basis, only use k=0 point is not - // called "gamma_only", only if the wave functions - // are stored as double type, the gamma_only = true. - // I don't know why "gamma_only" in plane wave - // makes the fact below is 2, that's a little complicated - // to understand. I think that may because only half - // the G vectors are used. Unfortunately implement the - // function hasn't in my plan list yet. - // - // but that's not the term "gamma_only" I want to use in LCAO, - fact = 1.0; - - //ofs_running << "\n pw.gstart = " << pw.gstart << endl; - - for (int ig=pw.gstart; ig rhon = ZERO; - for (int it=0; it( ucell.atoms[it].zv ) * conj( pw.strucFac(it, ig)); - } - if(pw.gg[ig] >= 1.0e-12) //LiuXh 20180515 - { - ewaldg += fact * abs(rhon) * abs(rhon) - * exp(- pw.gg[ig] * ucell.tpiba2 / alpha / 4.0 ) / pw.gg[ig] / ucell.tpiba2; - } - } - - ewaldg = FOUR_PI / ucell.omega * ewaldg; - -// cout << "\n ewaldg = " << ewaldg; - - // Here add the other constant term - if(pw.gstart == 1) - { - for (int it = 0; it < ucell.ntype;it++) - { - ewaldg = ewaldg - ucell.atoms[it].na * ucell.atoms[it].zv * ucell.atoms[it].zv * sqrt(8.0 / TWO_PI * alpha); - } - }//mohan modify 2007-11-7, 2010-07-26 - - // R-space sum here (only done for the processor that contains G=0) - ewaldr = 0.0; - if (pw.gstart == 1) - { - rmax = 4.0 / sqrt(alpha) / ucell.lat0; - if(test_energy)OUT(ofs_running,"rmax(unit lat0)",rmax); - // with this choice terms up to ZiZj*erfc(4) are counted (erfc(4)=2x10^-8 - int nt1=0; - int nt2=0; - - for (nt1 = 0; nt1 < ucell.ntype; nt1++) - { - for (nt2 = 0; nt2 < ucell.ntype; nt2++) - { - for (na = 0; na < ucell.atoms[nt1].na; na++) - { - for (nb = 0; nb < ucell.atoms[nt2].na; nb++) - { - //calculate tau[na]-tau[nb] - dtau = ucell.atoms[nt1].tau[na] - ucell.atoms[nt2].tau[nb]; - //generates nearest-neighbors shells - this->rgen(dtau, rmax, irr, ucell.latvec, ucell.G, r, r2, nrm); - //pw.at-->ucell.latvec, pw.bg-->pw.G - // and sum to the real space part - - if (test_energy>1) - { - OUT("dtau.x",dtau.x); - OUT("dtau.y",dtau.y); - OUT("dtau.z",dtau.z); - OUT("nrm",nrm); - } - for (nr = 0;nr < nrm;nr++) - { - rr = sqrt(r2 [nr]) * ucell.lat0; - ewaldr = ewaldr + ucell.atoms[nt1].zv * ucell.atoms[nt2].zv * - erfc(sqrt(alpha) * rr) / rr; - - } // enddo - if (test_energy>1) OUT("ewaldr",ewaldr); - } // enddo - } // enddo - } // nt2 - }//nt1 - } // endif - - ewalds = 0.50 * e2 * (ewaldg + ewaldr); - - // mohan fix bug 2010-07-26 - Parallel_Reduce::reduce_double_pool( ewalds ); - - if (test_energy>1) - { - OUT("ewaldg",ewaldg); - OUT("ewaldr",ewaldr); - OUT("ewalds",ewalds); - } - - delete[] irr; - delete[] r; - delete[] r2; - timer::tick("energy","ewald"); - return ewalds; -} // end function ewald - -//----------------------------------------------------------------------- -void energy::rgen( - const Vector3 &dtau, - const double &rmax, - int *irr, - const Matrix3 &latvec, - const Matrix3 &G, - Vector3 *r, - double *r2, - int &nrm) const -{ - //------------------------------------------------------------------- - // generates neighbours shells (in units of alat) with length - // less than rmax,and returns them in order of increasing length. - // r=i*a1+j*a2+k*a3-dtau, - // where a1,a2,a3 are the vectors defining the lattice - - // first the dummy variables - // int nrm, mxr; - // output: the number of vectors in the spher - // input: the maximum number of vectors - - // real r (3, mxr), r2 (mxr), at (3, 3), bg (3, 3), dtau (3),rmax; - // output: coordinates of vectors R+tau_s-tau - // output: square modulus of vectors R+tau_s- - // input: direct lattice vectors - // input: reciprocal lattice vectors - // input: the vector tau_s-tau_s' - // input: the radius of the sphere in real sp - // and here the local variables - - int nm1=0; - int nm2=0; - int nm3=0; - int i=0; - int j=0; - int k=0; - // index on R vectors for order - // maximum values for trial vectors - // counters on trial vectors - // counter on polarizations - // counter on R vectors - // index of swapping - // used for swapping - - Vector3 t; - Vector3 t1; - double tt=0.0; - double bg1[3]={0,0,0}; - // buffer contains the actual r - // buffer cotains the modulus of actual r - // used for swapping - // function to find the norm of a vector - // external dnrm2, see myfunc - - nrm = 0; - - if (rmax == 0.0) - { - return; - } - - bg1[0] = G.e11; - bg1[1] = G.e12; - bg1[2] = G.e13; - - nm1 = (int)(dnrm2(3, bg1, 1) * rmax + 2); - - bg1[0] = G.e21; - bg1[1] = G.e22; - bg1[2] = G.e23; - - nm2 = (int)(dnrm2(3, bg1, 1) * rmax + 2); - - bg1[0] = G.e31; - bg1[1] = G.e32; - bg1[2] = G.e33; - - nm3 = (int)(dnrm2(3, bg1, 1) * rmax + 2); - - if (test_energy>1) - { - OUT("nm1",nm1); - OUT("nm2",nm2); - OUT("nm3",nm3); - } - - for (i = -nm1; i <= nm1; i++) // mohan fix bug, add '='. 2009-02-27 - { - for (j = -nm2; j <= nm2; j++) - { - for (k = -nm3; k <= nm3; k++) - { - Vector3 t1(i,j,k); -// out.printV3(t1); - t = t1 * latvec; // bug ! first '*latvec', second '-dtau'. - t = t - dtau; // bug ! t = t - dtau, not t1 = t1 -tau; - -// out.printV3(t); // mohan fix 2bugs here, 2009-2-27 -// out.printM3("latvec",latvec); - - tt = t.x * t.x + t.y * t.y + t.z * t.z; - - if (tt <= rmax * rmax && abs(tt) > 1.e-10) - { - if (nrm > mxr) - { - cerr << "\n rgen, too many r-vectors," << nrm; - } - r[nrm] = t; - r2[nrm] = tt; - nrm++; - } // endif - } // enddo - } // enddo - } // enddo - - // reorder the vectors in order of increasing magnitude - // initialize the index inside sorting routine - irr[0] = 0; - if (nrm > 1) - { - heapsort(nrm, r2, irr); - } - - // mohan fix bug 2011-06-07 - for(int i=0; i &dtau, - const double &rmax, - int *irr, - const Matrix3 &at, - const Matrix3 &bg, - Vector3 *r, - double *r2, - int &nrm - ) const; void set_exx(); // Peize Lin add 2016-12-03 - static int mxr; }; #endif //energy diff --git a/ABACUS.develop/source/src_pw/forces.cpp b/ABACUS.develop/source/src_pw/forces.cpp index f7bd746ff2..a518c901cb 100644 --- a/ABACUS.develop/source/src_pw/forces.cpp +++ b/ABACUS.develop/source/src_pw/forces.cpp @@ -377,7 +377,7 @@ void Forces::cal_force_loc(void) return; } - +#include "H_Ewald_pw.h" void Forces::cal_force_ew(void) { timer::tick("Forces","cal_force_ew"); @@ -489,9 +489,7 @@ void Forces::cal_force_ew(void) if (iat1 != iat2) { Vector3 d_tau = ucell.atoms[T1].tau[I1] - ucell.atoms[T2].tau[I2]; - en.rgen(d_tau, rmax, irr, ucell.latvec, ucell.G, r, r2, nrm); - - + H_Ewald_pw::rgen(d_tau, rmax, irr, ucell.latvec, ucell.G, r, r2, nrm); for (int n = 0;n < nrm;n++) { diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index 4a6dd27920..40f2af3bde 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -35,7 +35,7 @@ void potential::allocate(const int nrxx) Memory::record("potential","vrs",NSPIN*nrxx,"double"); delete[] this->vrs1; - this->vrs1 = new double[nrxx];//mohan add 2007-11-12 + this->vrs1 = new double[nrxx]; Memory::record("potential","vrs1",nrxx,"double"); this->vnew.create(NSPIN,nrxx); @@ -141,7 +141,9 @@ void potential::init_pot(const int &istep, const bool delta_vh, const bool vna) {//read only up+down , others set to zero. ofs_running << " Didn't read in the charge density but autoset it for spin " <0) + { for (int i = 0;i < pw.nrxx;i++) { this->vrs(is, i) = this->vr(is, i); } + } else + { for (int i = 0;i < pw.nrxx;i++) { this->vrs(is, i) = this->vltot[i] + this->vr(is, i); // cout <<"i: "<< i <<" "<< "vrs: " << vrs(is,i) < Date: Thu, 25 Feb 2021 21:53:30 +0800 Subject: [PATCH 152/233] add H_Hartree_pw.h and .cpp, move Hartree related codes into this class --- ABACUS.develop/source/Makefile.Objects | 1 + ABACUS.develop/source/run_lcao.cpp | 1 + ABACUS.develop/source/src_io/eximport.cpp | 3 +- ABACUS.develop/source/src_lcao/ELEC_scf.cpp | 10 +- .../source/src_lcao/stress_lcao.cpp | 88 +++--- ABACUS.develop/source/src_parallel/ft.h | 1 + ABACUS.develop/source/src_pw/H_Hartree_pw.cpp | 98 ++++--- ABACUS.develop/source/src_pw/H_Hartree_pw.h | 33 +++ ABACUS.develop/source/src_pw/electrons.cpp | 6 +- ABACUS.develop/source/src_pw/energy.cpp | 14 +- ABACUS.develop/source/src_pw/energy.h | 1 - ABACUS.develop/source/src_pw/potential.cpp | 265 ++---------------- ABACUS.develop/source/src_pw/potential.h | 17 +- ABACUS.develop/source/src_pw/sto_elec.cpp | 4 +- ABACUS.develop/source/src_pw/stress.cpp | 7 +- 15 files changed, 204 insertions(+), 345 deletions(-) create mode 100644 ABACUS.develop/source/src_pw/H_Hartree_pw.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index d40a7e696f..b60980387c 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -211,6 +211,7 @@ charge_extra.o \ xc_gga_pw.o \ potential.o \ H_Ewald_pw.o\ +H_Hartree_pw.o\ write_pot.o\ potential_libxc.o \ efield.o \ diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index a2d1fdc0c8..f6c82fed2c 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -129,6 +129,7 @@ void Run_lcao::lcao_line(void) // Init the potential. pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs break; + case SOME_PW: wf.allocate(kv.nks); UFFT.allocate(); diff --git a/ABACUS.develop/source/src_io/eximport.cpp b/ABACUS.develop/source/src_io/eximport.cpp index da7c9cdf49..543fea3aa7 100644 --- a/ABACUS.develop/source/src_io/eximport.cpp +++ b/ABACUS.develop/source/src_io/eximport.cpp @@ -700,6 +700,7 @@ void eximport::in_evc(ifstream &in) // energy //=========== #include "src_pw/H_Ewald_pw.h" +#include "src_pw/H_Hartree_pw.h" void eximport::out_energy(ofstream &out_data) { //cout << "\n ==> out_energy" << endl; @@ -708,7 +709,7 @@ void eximport::out_energy(ofstream &out_data) //out_data << setw(20) << elec.dE << endl; //6.3 out_data << setw(20) << en.eband << endl; //6.4 out_data << setw(20) << en.eband + en.deband << endl; //6.5 - out_data << setw(20) << en.ehart << endl; //6.6 + out_data << setw(20) << H_Hartree_pw::hartree_energy << endl; out_data << setw(20) << en.etxc - en.etxcc << endl; //6.7 out_data << setw(20) << H_Ewald_pw::ewald_energy << endl; //6.8 } diff --git a/ABACUS.develop/source/src_lcao/ELEC_scf.cpp b/ABACUS.develop/source/src_lcao/ELEC_scf.cpp index f5baa782b4..b3b7b8f53f 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_scf.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_scf.cpp @@ -189,7 +189,7 @@ void ELEC_scf::scf(const int &istep) // so be careful here, make sure // rho1 and rho2 are the same rho. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - pot.v_of_rho(CHR.rho, en.ehart, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho, en.etxc, en.vtxc, pot.vr); en.delta_escf(); if (vext == 0) { @@ -417,7 +417,7 @@ void ELEC_scf::scf(const int &istep) if(!conv_elec) { // option 1 - pot.v_of_rho(CHR.rho, en.ehart, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho, en.etxc, en.vtxc, pot.vr); en.delta_escf(); // option 2 @@ -426,16 +426,16 @@ void ELEC_scf::scf(const int &istep) // use real E_tot functional. //------------------------------ /* - pot.v_of_rho(CHR.rho_save, en.ehart, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho_save, en.etxc, en.vtxc, pot.vr); en.calculate_etot(); en.print_etot(conv_elec, istep, iter, dr2, 0.0, ETHR, avg_iter,0); - pot.v_of_rho(CHR.rho, en.ehart, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho, en.etxc, en.vtxc, pot.vr); en.delta_escf(); */ } else { - pot.v_of_rho(CHR.rho, en.ehart, en.etxc, en.vtxc, pot.vnew); + pot.v_of_rho(CHR.rho, en.etxc, en.vtxc, pot.vnew); //(used later for scf correction to the forces ) pot.vnew -= pot.vr; en.descf = 0.0; diff --git a/ABACUS.develop/source/src_lcao/stress_lcao.cpp b/ABACUS.develop/source/src_lcao/stress_lcao.cpp index b44d421700..1c5ad212ce 100644 --- a/ABACUS.develop/source/src_lcao/stress_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/stress_lcao.cpp @@ -3,6 +3,8 @@ #include "../src_pw/xc_functional.h" #include "../src_pw/xc_gga_pw.h" #include "src_pw/myfunc.h" +// new +#include "src_pw/H_Hartree_pw.h" double Stress_LCAO::stress_invalid_threshold_ev = 0.00; @@ -758,25 +760,27 @@ void Stress_LCAO::cal_stress_cc(void) void Stress_LCAO::cal_stress_har(void) { - double shart,g2; - const double eps=1e-8; - int is,ig,l,m,nspin0; + TITLE("Stress_LCAO","cal_stress_har"); - complex *Porter = UFFT.porter; + double shart,g2; + const double eps=1e-8; + int is,ig,l,m,nspin0; - // Hartree potential VH(r) from n(r) - ZEROS( Porter, pw.nrxx ); - for(int is=0; is( CHR.rho[is][ir], 0.0 ); - } - } - //============================= - // bring rho (aux) to G space - //============================= - pw.FFT_chg.FFT3D(Porter, -1); + complex *Porter = UFFT.porter; + + // Hartree potential VH(r) from n(r) + ZEROS( Porter, pw.nrxx ); + for(int is=0; is( CHR.rho[is][ir], 0.0 ); + } + } + //============================= + // bring rho (aux) to G space + //============================= + pw.FFT_chg.FFT3D(Porter, -1); complex *psic = new complex [pw.nrxx]; double *psic0 = new double[pw.nrxx]; @@ -802,9 +806,11 @@ void Stress_LCAO::cal_stress_har(void) ZEROS(vh_g, pw.ngmc); double g[3]; - //test - // int i=pw.gstart; - // cout<< "gstart " < *psi,const int sign); // void FFT3D(double *psi, const int sign); // void FFT3D(matrix &psi, const int sign); // just for now diff --git a/ABACUS.develop/source/src_pw/H_Hartree_pw.cpp b/ABACUS.develop/source/src_pw/H_Hartree_pw.cpp index 9a49f0dc04..84175bccf4 100644 --- a/ABACUS.develop/source/src_pw/H_Hartree_pw.cpp +++ b/ABACUS.develop/source/src_pw/H_Hartree_pw.cpp @@ -1,20 +1,30 @@ +#include "H_Hartree_pw.h" + +double H_Hartree_pw::hartree_energy=0.0; + //-------------------------------------------------------------------- // Transform charge density to hartree potential. //-------------------------------------------------------------------- -void potential::v_h(int NSPIN,double &ehart, matrix &v, double** rho) +void H_Hartree_pw::v_hartree( + const UnitCell &cell, + PW_Basis &pwb, + const Use_FFT &ufft, + const int &nspin, + matrix &v, + double** rho) { - TITLE("potential","v_h"); - timer::tick("potential","v_hartree"); + TITLE("H_Hartree_pw","v_hartree"); + timer::tick("H_Hartree_pw","v_hartree"); - complex *Porter = UFFT.porter; + complex *Porter = ufft.porter; // Hartree potential VH(r) from n(r) - ZEROS( Porter, pw.nrxx ); + ZEROS( Porter, pwb.nrxx ); int nspin0 = 1; - if(NSPIN==2)nspin0 = NSPIN; + if(nspin==2) nspin0 = nspin; for(int is=0; is( rho[is][ir], 0.0 ); } @@ -23,29 +33,30 @@ void potential::v_h(int NSPIN,double &ehart, matrix &v, double** rho) //============================= // bring rho (aux) to G space //============================= - pw.FFT_chg.FFT3D(Porter, -1); + pwb.FFT_chg.FFT3D(Porter, -1); //double charge; - //if (pw.gstart == 1) + //if (pwb.gstart == 1) //{ - // charge = ucell.omega * Porter[pw.ig2fftc[0]].real(); + // charge = cell.omega * Porter[pwb.ig2fftc[0]].real(); //} //OUT(ofs_running, "v_h charge", charge); //======================================================= // calculate hartree potential in G-space (NB: V(G=0)=0 ) //======================================================= - ehart = 0.0; - complex *vh_g = new complex[pw.ngmc]; - ZEROS(vh_g, pw.ngmc); + double ehart = 0.0; + + complex *vh_g = new complex[pwb.ngmc]; + ZEROS(vh_g, pwb.ngmc); - for (int ig = pw.gstart; ig= 1.0e-12) //LiuXh 20180410 + const int j = pwb.ig2fftc[ig]; + if(pwb.gg[ig] >= 1.0e-12) //LiuXh 20180410 { - const double fac = e2 * FOUR_PI / (ucell.tpiba2 * pw.gg [ig]); + const double fac = e2 * FOUR_PI / (cell.tpiba2 * pwb.gg [ig]); ehart += ( conj( Porter[j] ) * Porter[j] ).real() * fac; vh_g[ig] = fac * Porter[j]; @@ -53,42 +64,57 @@ void potential::v_h(int NSPIN,double &ehart, matrix &v, double** rho) } Parallel_Reduce::reduce_double_pool( ehart ); - ehart *= 0.5 * ucell.omega; + ehart *= 0.5 * cell.omega; //cout << " ehart=" << ehart << endl; - ZEROS(Porter, pw.nrxx); + H_Hartree_pw::hartree_energy = ehart; + + - for (int ig = 0;ig < pw.ngmc;ig++) + ZEROS(Porter, pwb.nrxx); + + for (int ig = 0;ig < pwb.ngmc;ig++) { - Porter[pw.ig2fftc[ig]] = vh_g[ig]; + Porter[pwb.ig2fftc[ig]] = vh_g[ig]; } //========================================== //transform hartree potential to real space //========================================== - pw.FFT_chg.FFT3D(Porter, 1); + pwb.FFT_chg.FFT3D(Porter, 1); //========================================== //Add hartree potential to the xc potential //========================================== - if(NSPIN==4) - for (int ir = 0;ir < pw.nrxx;ir++) + if(nspin==4) + { + for (int ir = 0;ir < pwb.nrxx;ir++) { v(0, ir) += Porter[ir].real(); } + } else - for (int is = 0;is < NSPIN;is++) - { - for (int ir = 0;ir < pw.nrxx;ir++) - { - v(is, ir) += Porter[ir].real(); - } - } + { + for (int is = 0;is < nspin;is++) + { + for (int ir = 0;ir < pwb.nrxx;ir++) + { + v(is, ir) += Porter[ir].real(); + } + } + } + + +//----------------------------------------------------------- +// we need to add this out_potential funciton back +// in near future, 2021-02-25 +//----------------------------------------------------------- //------------------------------------------- // output the Hartree potential into a file. //------------------------------------------- +/* if(out_potential==-2) { cout << " output VH" << endl; @@ -99,16 +125,18 @@ void potential::v_h(int NSPIN,double &ehart, matrix &v, double** rho) stringstream ss; ss << global_out_dir << fn; matrix v; - v.create(1,pw.nrxx); - for(int ir=0; irwrite_potential( is, iter, ss.str(), v, precision, 1 ); } +*/ + + timer::tick("H_Hartree_pw","v_hartree"); - timer::tick("potential","v_hartree"); delete[] vh_g; + return; } // end subroutine v_h - diff --git a/ABACUS.develop/source/src_pw/H_Hartree_pw.h b/ABACUS.develop/source/src_pw/H_Hartree_pw.h new file mode 100644 index 0000000000..c5e31f13a6 --- /dev/null +++ b/ABACUS.develop/source/src_pw/H_Hartree_pw.h @@ -0,0 +1,33 @@ +#ifndef H_HARTREE_PW_H +#define H_HARTREE_PW_H + +#include "tools.h" +#include "unitcell.h" +#include "pw_basis.h" +#include "use_fft.h" + +class H_Hartree_pw +{ + public: + + H_Hartree_pw(); + ~H_Hartree_pw(); + + // the Hartree energy + static double hartree_energy; + + // compute the Hartree energy + static void v_hartree( + const UnitCell &cell, + PW_Basis &pwb, + const Use_FFT &ufft, + const int &nspin, + matrix &v, + double** rho); + + private: + + +}; + +#endif //Hartree energy diff --git a/ABACUS.develop/source/src_pw/electrons.cpp b/ABACUS.develop/source/src_pw/electrons.cpp index efb5d438de..e5c75b52a7 100644 --- a/ABACUS.develop/source/src_pw/electrons.cpp +++ b/ABACUS.develop/source/src_pw/electrons.cpp @@ -287,11 +287,11 @@ void Electrons::self_consistent(const int &istep) if (!conv_elec) { // not converged yet, calculate new potential from mixed charge density - pot.v_of_rho(CHR.rho, en.ehart, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho, en.etxc, en.vtxc, pot.vr); // because = are calculated after sum // band, using output charge density. - // but E_Hartree(en.ehart) and Exc(en.etxc) are calculated in v_of_rho above, + // but E_Hartree and Exc(en.etxc) are calculated in v_of_rho above, // using the mixed charge density. // so delta_escf corrects for this difference at first order. en.delta_escf(); @@ -309,7 +309,7 @@ void Electrons::self_consistent(const int &istep) // mohan fix bug 2012-06-05, // the new potential V(PL)+V(H)+V(xc) - pot.v_of_rho(CHR.rho, en.ehart, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho, en.etxc, en.vtxc, pot.vr); //cout<<"Exc = "<eband = 0; // the band energy this->deband = 0; // correction for variational energy this->deband_harris = 0; // harris energy - this->ehart = 0; // the hartree energy this->etxc = 0; // the exchange and correlation energy this->vtxc = 0; // another exchange-correlation energy this->etxcc = 0; // the nlcc exchange and correlation @@ -53,7 +53,8 @@ void energy::calculate_harris(const int &flag) { this->etot_harris = eband + deband_harris + (etxc - etxcc) + H_Ewald_pw::ewald_energy - + ehart + demet + exx + Efield::etotefield; + + H_Hartree_pw::hartree_energy + + demet + exx + Efield::etotefield; if(INPUT.dft_plus_u) { @@ -70,7 +71,8 @@ void energy::calculate_etot(void) //cout << "\n demet in etot = " << demet << endl; this->etot = eband + deband + (etxc - etxcc) + H_Ewald_pw::ewald_energy - + ehart + demet + descf + exx + Efield::etotefield; + + H_Hartree_pw::hartree_energy + + demet + descf + exx + Efield::etotefield; // Peize Lin add 2014-04-03, update 2019-04-26 if(vdwd2.vdwD2) @@ -115,7 +117,7 @@ bool print) this->print_format("E_Harris",etot_harris); this->print_format("E_band",eband); this->print_format("E_one_elec",eband+deband); - this->print_format("E_Hartree",ehart); + this->print_format("E_Hartree",H_Hartree_pw::hartree_energy); this->print_format("E_xc",etxc-etxcc); this->print_format("E_Ewald",H_Ewald_pw::ewald_energy); this->print_format("E_demet",demet); //mohan add 2011-12-02 @@ -289,7 +291,7 @@ bool print) printf( "[36m%-15f[0m", en.etot*Ry_to_eV); cout << setprecision(3); // cout << setw(11) << en.eband; - // cout << setw(11) << en.ehart; + // cout << setw(11) << H_Hartree_pw::hartree_energy; // cout << setw(11) << en.etxc - en.etxcc; cout << resetiosflags(ios::scientific); //if(DIAGO_TYPE=="cg") xiaohui modify 2013-09-02 @@ -324,7 +326,7 @@ bool print) cout << setw(11) << dr2; cout << setprecision(3); // cout << setw(11) << en.eband; - // cout << setw(11) << en.ehart; + // cout << setw(11) << H_Hartree_pw::hartree_energy; // cout << setw(11) << en.etxc - en.etxcc; //if(DIAGO_TYPE=="cg") xiaohui modify 2013-09-02 if(KS_SOLVER=="cg") //xiaohui add 2013-09-02 diff --git a/ABACUS.develop/source/src_pw/energy.h b/ABACUS.develop/source/src_pw/energy.h index 2e2d36cfc1..bc5c564876 100644 --- a/ABACUS.develop/source/src_pw/energy.h +++ b/ABACUS.develop/source/src_pw/energy.h @@ -49,7 +49,6 @@ class energy double deband_harris; double descf; - double ehart; // the hartree energy double etxc; // the exchange and correlation energy double vtxc; // another exchange-correlation energy double etxcc; // the nlcc exchange and correlation diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index 40f2af3bde..8aa272254d 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -6,6 +6,8 @@ #include "efield.h" #include "math.h" #include "potential_libxc.h" +// new +#include "H_Hartree_pw.h" potential::potential() { @@ -45,14 +47,9 @@ void potential::allocate(const int nrxx) } //---------------------------------------------------------- -// EXPLAIN : -// Initializes the self consistent potential in the array vr -// if 'delta_vh=0' & 'vna=1', then -// the final potential: atom Hartree + Local pp = Vna -// else if 'delta_vh=1' & 'vna=0', then -// the final potential: the remaining Hartree potential. +// Initializes the self consistent potential //---------------------------------------------------------- -void potential::init_pot(const int &istep, const bool delta_vh, const bool vna) +void potential::init_pot(const int &istep) { TITLE("potential","init_pot"); timer::tick("potential","init_pot"); @@ -67,48 +64,26 @@ void potential::init_pot(const int &istep, const bool delta_vh, const bool vna) // the vltot should and must be zero here. ZEROS(this->vltot, pw.nrxx); - // vna use this line to get delta_vh and V_Efield to do grid integration. - // if detal_vh is set to 1, then local pseudopotential is not added. - if(delta_vh) - { - if(EFIELD && !DIPOLE) - { - Efield EFID; - // in fact, CHR.rho is not used here. - // if charge correction due to Efield is considered, - // the structure here need to be updated. + // (1) local part of pseudopotentials. + // set vltot + this->set_local(this->vltot); - static bool first = true; - if(first) - { - cout << " ADD THE EFIELD (V/A) : " << Efield::eamp*51.44 << endl; - first = false; - } - EFID.add_efield(CHR.rho[0], this->vltot); - } - } - else - { - // (1) local part of pseudopotentials. - // set vltot - this->set_local(this->vltot); - - // mohan fix bug 2011-07-07 - // set pseudopotentials. - int nspin0=NSPIN;//zhengdy-soc, pauli matrix, just index 0 has vlocal term. - if(NSPIN==4) nspin0=1; - for(int is=0; isvrs(is,ir) = this->vltot[ir]; - } - } - // (2) core correction potential. - CHR.set_rho_core( pw.strucFac ); + // mohan fix bug 2011-07-07 + // set pseudopotentials. + int nspin0=NSPIN;//zhengdy-soc, pauli matrix, just index 0 has vlocal term. - //if(vna==1)return; // tmp by mohan - } + if(NSPIN==4) nspin0=1; + + for(int is=0; isvrs(is,ir) = this->vltot[ir]; + } + } + + // (2) core correction potential. + CHR.set_rho_core( pw.strucFac ); // before ion relaxation // need reconstruction -- mohan add 2021-02-09 @@ -201,16 +176,7 @@ void potential::init_pot(const int &istep, const bool delta_vh, const bool vna) CHR.renormalize_rho(); - //------------------------------------------------------- - // Here we computer the potential which correspond - // to the charge density - // if(vna=1) - // get the Hartree potential from atomic charge density. - // else - // delta_vh = 1: get the delta Hartree potential. - // delta_vh = 0: get the full Hartree potential. - //-------------------------------------------------------- - this->v_of_rho( CHR.rho, en.ehart, en.etxc, en.vtxc, vr, delta_vh, vna); + this->v_of_rho(CHR.rho, en.etxc, en.vtxc, vr); //---------------------------------------------------------- // Define the total local potential (external+scf) in DFT @@ -286,41 +252,14 @@ void potential::set_local(double* vl_pseudo)const void potential::v_of_rho ( double **rho_in, - double &ehart, double &etxc, double &vtxc, - matrix &v_in, - const bool delta_vh, - const bool vna + matrix &v_in ) { TITLE("potential","v_of_rho"); v_in.zero_out(); - if(vna) - { - timer::tick("potential","vna_h"); - double** rho_atom = new double*[NSPIN]; - for(int is=0; isv_h(NSPIN, ehart, v_in, rho_atom); - - for(int is=0; isv_h(NSPIN, ehart, v_in, rho_atom); - - for(int is=0; isv_h(NSPIN, ehart, v_in, rho_in); - } + H_Hartree_pw::v_hartree(ucell, pw, UFFT, NSPIN, v_in, rho_in); // mohan add 2011-06-20 if(EFIELD && DIPOLE) @@ -572,120 +471,6 @@ void potential::v_xc return; } -//-------------------------------------------------------------------- -// Transform charge density to hartree potential. -//-------------------------------------------------------------------- -void potential::v_h(int NSPIN,double &ehart, matrix &v, double** rho) -{ - TITLE("potential","v_h"); - timer::tick("potential","v_hartree"); - - complex *Porter = UFFT.porter; - - // Hartree potential VH(r) from n(r) - ZEROS( Porter, pw.nrxx ); - int nspin0 = 1; - if(NSPIN==2)nspin0 = NSPIN; - for(int is=0; is( rho[is][ir], 0.0 ); - } - } - - //============================= - // bring rho (aux) to G space - //============================= - pw.FFT_chg.FFT3D(Porter, -1); - - //double charge; - //if (pw.gstart == 1) - //{ - // charge = ucell.omega * Porter[pw.ig2fftc[0]].real(); - //} - //OUT(ofs_running, "v_h charge", charge); - - //======================================================= - // calculate hartree potential in G-space (NB: V(G=0)=0 ) - //======================================================= - ehart = 0.0; - - complex *vh_g = new complex[pw.ngmc]; - ZEROS(vh_g, pw.ngmc); - - for (int ig = pw.gstart; ig= 1.0e-12) //LiuXh 20180410 - { - const double fac = e2 * FOUR_PI / (ucell.tpiba2 * pw.gg [ig]); - - ehart += ( conj( Porter[j] ) * Porter[j] ).real() * fac; - vh_g[ig] = fac * Porter[j]; - } - } - - Parallel_Reduce::reduce_double_pool( ehart ); - ehart *= 0.5 * ucell.omega; - - //cout << " ehart=" << ehart << endl; - - ZEROS(Porter, pw.nrxx); - - for (int ig = 0;ig < pw.ngmc;ig++) - { - Porter[pw.ig2fftc[ig]] = vh_g[ig]; - } - - //========================================== - //transform hartree potential to real space - //========================================== - pw.FFT_chg.FFT3D(Porter, 1); - //========================================== - //Add hartree potential to the xc potential - //========================================== - - if(NSPIN==4) - for (int ir = 0;ir < pw.nrxx;ir++) - { - v(0, ir) += Porter[ir].real(); - } - else - for (int is = 0;is < NSPIN;is++) - { - for (int ir = 0;ir < pw.nrxx;ir++) - { - v(is, ir) += Porter[ir].real(); - } - } - - //------------------------------------------- - // output the Hartree potential into a file. - //------------------------------------------- - if(out_potential==-2) - { - cout << " output VH" << endl; - int is = 0; - int iter = 0; - int precision = 3; - string fn = "VH.dat"; - stringstream ss; - ss << global_out_dir << fn; - matrix v; - v.create(1,pw.nrxx); - for(int ir=0; irwrite_potential( is, iter, ss.str(), v, precision, 1 ); - } - - timer::tick("potential","v_hartree"); - delete[] vh_g; - return; -} // end subroutine v_h - //========================================================== // set the total local potential vrs on the smooth mesh to diff --git a/ABACUS.develop/source/src_pw/potential.h b/ABACUS.develop/source/src_pw/potential.h index d6fb6070c5..895da38391 100644 --- a/ABACUS.develop/source/src_pw/potential.h +++ b/ABACUS.develop/source/src_pw/potential.h @@ -34,19 +34,9 @@ class potential void allocate(const int nrxx); - //------------------------------------------------ - // if delta_vh==true, vl_pseudo not calculated, - // V(rho-rho_atom) is calculated, - // V(xc) is calculated. - //------------------------------------------------ - // if vna==true, vl_pseudo is calculated, - // V(rho_atom) is calclated, - // V(xc) is not calculated. - //------------------------------------------------ - void init_pot(const int &istep, const bool delta_vh=false, const bool vna=false); - - void v_of_rho( double** rho_in, double &ehart, double &etxc, - double &vtxc, matrix &v, const bool delta_vh=false, const bool vna=false); + void init_pot(const int &istep); + + void v_of_rho(double** rho_in, double &etxc, double &vtxc, matrix &v); void set_vrs(void); @@ -67,7 +57,6 @@ class potential void set_local(double *vl_pseudo)const; - void v_h( int nspin, double &ehart, matrix &v, double** rho); private: diff --git a/ABACUS.develop/source/src_pw/sto_elec.cpp b/ABACUS.develop/source/src_pw/sto_elec.cpp index cef4b787cf..c3be81e830 100644 --- a/ABACUS.develop/source/src_pw/sto_elec.cpp +++ b/ABACUS.develop/source/src_pw/sto_elec.cpp @@ -191,7 +191,7 @@ void Stochastic_Elec::scf_stochastic(const int &istep) if (!conv_elec) { // not converged yet, calculate new potential from mixed charge density - pot.v_of_rho(CHR.rho, en.ehart, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho, en.etxc, en.vtxc, pot.vr); // because = are calculated after sum // band, using output charge density. @@ -211,7 +211,7 @@ void Stochastic_Elec::scf_stochastic(const int &istep) } // the new potential V(PL)+V(H)+V(xc) - pot.v_of_rho(CHR.rho, en.ehart, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho, en.etxc, en.vtxc, pot.vr); //( vnew used later for scf correction to the forces ) pot.vnew = pot.vr - pot.vnew; diff --git a/ABACUS.develop/source/src_pw/stress.cpp b/ABACUS.develop/source/src_pw/stress.cpp index ccfb830270..28f75baea2 100644 --- a/ABACUS.develop/source/src_pw/stress.cpp +++ b/ABACUS.develop/source/src_pw/stress.cpp @@ -8,6 +8,7 @@ #include "symmetry.h" // new #include "H_Ewald_pw.h" +#include "H_Hartree_pw.h" void Stress::cal_stress() { @@ -505,8 +506,10 @@ void Stress::stres_har(){ } } } - for(l=0;l<3;l++) - sigmahar[l][l] -= en.ehart /ucell.omega; + for(l=0;l<3;l++) + { + sigmahar[l][l] -= H_Hartree_pw::hartree_energy /ucell.omega; + } for(l=0;l<3;l++){ for(m=0;m Date: Fri, 26 Feb 2021 12:34:21 +0800 Subject: [PATCH 153/233] move v_xc, etxc, vtxc from energy.h and .cpp to H_XC_pw.h and .cpp --- ABACUS.develop/source/Makefile.Objects | 1 + ABACUS.develop/source/src_io/eximport.cpp | 3 +- ABACUS.develop/source/src_lcao/ELEC_scf.cpp | 10 +- ABACUS.develop/source/src_lcao/force_lcao.cpp | 4 +- .../source/src_lcao/stress_lcao.cpp | 5 +- ABACUS.develop/source/src_pw/H_XC_pw.cpp | 77 +++---- ABACUS.develop/source/src_pw/H_XC_pw.h | 38 ++++ ABACUS.develop/source/src_pw/electrons.cpp | 4 +- ABACUS.develop/source/src_pw/energy.cpp | 11 +- ABACUS.develop/source/src_pw/energy.h | 2 - ABACUS.develop/source/src_pw/forces.cpp | 4 +- ABACUS.develop/source/src_pw/potential.cpp | 189 +----------------- ABACUS.develop/source/src_pw/potential.h | 3 +- ABACUS.develop/source/src_pw/sto_elec.cpp | 4 +- ABACUS.develop/source/src_pw/stress.cpp | 8 +- 15 files changed, 107 insertions(+), 256 deletions(-) create mode 100644 ABACUS.develop/source/src_pw/H_XC_pw.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index b60980387c..08f7500277 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -212,6 +212,7 @@ xc_gga_pw.o \ potential.o \ H_Ewald_pw.o\ H_Hartree_pw.o\ +H_XC_pw.o \ write_pot.o\ potential_libxc.o \ efield.o \ diff --git a/ABACUS.develop/source/src_io/eximport.cpp b/ABACUS.develop/source/src_io/eximport.cpp index 543fea3aa7..569952cdf2 100644 --- a/ABACUS.develop/source/src_io/eximport.cpp +++ b/ABACUS.develop/source/src_io/eximport.cpp @@ -701,6 +701,7 @@ void eximport::in_evc(ifstream &in) //=========== #include "src_pw/H_Ewald_pw.h" #include "src_pw/H_Hartree_pw.h" +#include "src_pw/H_XC_pw.h" void eximport::out_energy(ofstream &out_data) { //cout << "\n ==> out_energy" << endl; @@ -710,7 +711,7 @@ void eximport::out_energy(ofstream &out_data) out_data << setw(20) << en.eband << endl; //6.4 out_data << setw(20) << en.eband + en.deband << endl; //6.5 out_data << setw(20) << H_Hartree_pw::hartree_energy << endl; - out_data << setw(20) << en.etxc - en.etxcc << endl; //6.7 + out_data << setw(20) << H_XC_pw::etxc - en.etxcc << endl; //6.7 out_data << setw(20) << H_Ewald_pw::ewald_energy << endl; //6.8 } diff --git a/ABACUS.develop/source/src_lcao/ELEC_scf.cpp b/ABACUS.develop/source/src_lcao/ELEC_scf.cpp index b3b7b8f53f..6318cd72de 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_scf.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_scf.cpp @@ -189,7 +189,7 @@ void ELEC_scf::scf(const int &istep) // so be careful here, make sure // rho1 and rho2 are the same rho. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - pot.v_of_rho(CHR.rho, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho, pot.vr); en.delta_escf(); if (vext == 0) { @@ -417,7 +417,7 @@ void ELEC_scf::scf(const int &istep) if(!conv_elec) { // option 1 - pot.v_of_rho(CHR.rho, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho, pot.vr); en.delta_escf(); // option 2 @@ -426,16 +426,16 @@ void ELEC_scf::scf(const int &istep) // use real E_tot functional. //------------------------------ /* - pot.v_of_rho(CHR.rho_save, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho_save, pot.vr); en.calculate_etot(); en.print_etot(conv_elec, istep, iter, dr2, 0.0, ETHR, avg_iter,0); - pot.v_of_rho(CHR.rho, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho, pot.vr); en.delta_escf(); */ } else { - pot.v_of_rho(CHR.rho, en.etxc, en.vtxc, pot.vnew); + pot.v_of_rho(CHR.rho, pot.vnew); //(used later for scf correction to the forces ) pot.vnew -= pot.vr; en.descf = 0.0; diff --git a/ABACUS.develop/source/src_lcao/force_lcao.cpp b/ABACUS.develop/source/src_lcao/force_lcao.cpp index 0d8ec4c63c..7a366c52bf 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/force_lcao.cpp @@ -2,6 +2,8 @@ #include "src_pw/global.h" #include "src_pw/potential_libxc.h" #include "dftu.h" //Quxin add for DFT+U on 20201029 +// new +#include "src_pw/H_XC_pw.h" double Force_LCAO::force_invalid_threshold_ev = 0.00; @@ -727,7 +729,7 @@ void Force_LCAO::cal_force_cc(void) #ifdef TEST_LIBXC Potential_Libxc::v_xc(CHR.rho, en.etxc, en.vtxc, vxc); #else - pot.v_xc(CHR.rho, en.etxc, en.vtxc, vxc); + H_XC_pw::v_xc(pw.nrxx, pw.ncxyz, ucell.omega, CHR.rho, CHR.rho_core, vxc); #endif complex * psiv = new complex [pw.nrxx]; diff --git a/ABACUS.develop/source/src_lcao/stress_lcao.cpp b/ABACUS.develop/source/src_lcao/stress_lcao.cpp index 1c5ad212ce..242fd92734 100644 --- a/ABACUS.develop/source/src_lcao/stress_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/stress_lcao.cpp @@ -5,6 +5,7 @@ #include "src_pw/myfunc.h" // new #include "src_pw/H_Hartree_pw.h" +#include "src_pw/H_XC_pw.h" double Stress_LCAO::stress_invalid_threshold_ev = 0.00; @@ -93,7 +94,7 @@ void Stress_LCAO::start_stress(double overlap[][3],double tvnl_dphi[][3],double for(int i=0;i<3;i++) { // sigmaxc[i][i] = - (en.etxc-en.vtxc) / ucell.omega; - sigmaxc[i][i] = -(en.etxc) / ucell.omega; + sigmaxc[i][i] = -(H_XC_pw::etxc) / ucell.omega; // sigmahar[i][i] = en.ehart /ucell.omega; @@ -676,7 +677,7 @@ void Stress_LCAO::cal_stress_cc(void) //recalculate the exchange-correlation potential matrix vxc(NSPIN, pw.nrxx); - pot.v_xc(CHR.rho, en.etxc, en.vtxc, vxc); + H_XC_pw::v_xc(pw.nrxx, pw.ncxyz, ucell.omega, CHR.rho, CHR.rho_core, vxc); complex * psic = new complex [pw.nrxx]; diff --git a/ABACUS.develop/source/src_pw/H_XC_pw.cpp b/ABACUS.develop/source/src_pw/H_XC_pw.cpp index 4b49787de3..04a06ce90f 100644 --- a/ABACUS.develop/source/src_pw/H_XC_pw.cpp +++ b/ABACUS.develop/source/src_pw/H_XC_pw.cpp @@ -1,12 +1,22 @@ -void potential::v_xc +#include "H_XC_pw.h" +#include "xc_functional.h" +#include "xc_gga_pw.h" + +double H_XC_pw::etxc; +double H_XC_pw::vtxc; + +void H_XC_pw::v_xc ( + const int &nrxx, // number of real-space grid + const int &ncxyz, // total number of charge grid + const double &omega, // volume of cell double **rho_in, - double &etxc, - double &vtxc, + double *rho_core, // core charge density matrix &v) { - TITLE("potential","v_xc"); - timer::tick("potential","v_xc"); + TITLE("H_XC_pw","v_xc"); + timer::tick("H_XC_pw","v_xc"); + //Exchange-Correlation potential Vxc(r) from n(r) etxc = 0.0; vtxc = 0.0; @@ -27,25 +37,22 @@ void potential::v_xc int neg [3]; double vanishing_charge = 1.0e-10; + if (NSPIN == 1 || ( NSPIN ==4 && !DOMAG && !DOMAG_Z)) { // spin-unpolarized case - // for parallel : ncxyz change ==> nrxx - // 2008-06-01 mohan - for (int ir = 0;ir < pw.nrxx;ir++) + for (int ir = 0;ir < nrxx;ir++) { - rhox = rho_in[0][ir] + CHR.rho_core[ir]; + // total electron charge density + rhox = rho_in[0][ir] + rho_core[ir]; arhox = abs(rhox); if (arhox > vanishing_charge) { - // call XC_Functional::xc(arhox, ex, ec, vx[0], vc[0]); - //if(ir<10) - //{ - // cout << "\n ir = " << ir << " ex = " << ex << " ec = " << ec; - //} v(0,ir) = e2 * (vx[0] + vc[0]); + // consider the total charge density etxc += e2 * (ex + ec) * rhox; + // only consider rho_in vtxc += v(0, ir) * rho_in[0][ir]; } // endif } //enddo @@ -57,11 +64,9 @@ void potential::v_xc neg [1] = 0; neg [2] = 0; - // 2008-06-01 mohan - if (test_potential>0) cout<<"\n Begin calculate Exc(r) and Vxc(r)"; - for (ir = 0;ir < pw.nrxx;ir++) + for (ir = 0;ir < nrxx;ir++) { - rhox = rho_in[0][ir] + rho_in[1][ir] + CHR.rho_core[ir]; //HLX(05-29-06): bug fixed + rhox = rho_in[0][ir] + rho_in[1][ir] + rho_core[ir]; //HLX(05-29-06): bug fixed arhox = abs(rhox); if (arhox > vanishing_charge) @@ -87,11 +92,6 @@ void potential::v_xc // call XC_Functional::xc_spin(arhox, zeta, ex, ec, vx[0], vx[1], vc[0], vc[1]); - //if(ir<10) - //{ - // cout << "\n ir = " << ir << " ex = " << ex << " ec = " << ec; - //} - for (is = 0;is < NSPIN;is++) { v(is, ir) = e2 * (vx[is] + vc[is]); @@ -100,18 +100,17 @@ void potential::v_xc etxc += e2 * (ex + ec) * rhox; vtxc += v(0, ir) * rho_in[0][ir] + v(1, ir) * rho_in[1][ir]; - } // endif - } // enddo - if (test_potential>0) cout<<"\n End calculate Exc(r) and Vxc(r) with SPIN == 2"; + } + } - } // nspin 2 + } else if(NSPIN == 4)//noncollinear case added by zhengdy { - for( ir = 0;ir 1.0 ) { - neg[1] += 1.0 / ucell.omega; + neg[1] += 1.0 / omega; zeta = (zeta > 0.0) ? 1.0 : (-1.0); }//end if @@ -158,21 +157,9 @@ void potential::v_xc Parallel_Reduce::reduce_double_pool( etxc ); Parallel_Reduce::reduce_double_pool( vtxc ); - etxc *= ucell.omega / pw.ncxyz; - vtxc *= ucell.omega / pw.ncxyz; - if (test_potential > 1) - { - OUT(ofs_running,"etxc",etxc); - OUT(ofs_running,"vtxc",vtxc); - } - - if (test_potential >0 ) cout<<"\n End calculate gradient"; + etxc *= omega / ncxyz; + vtxc *= omega / ncxyz; - if (test_potential > 2) - { - cout<<"\n After gradcorr : vtxc = "< = are calculated after sum // band, using output charge density. @@ -309,7 +309,7 @@ void Electrons::self_consistent(const int &istep) // mohan fix bug 2012-06-05, // the new potential V(PL)+V(H)+V(xc) - pot.v_of_rho(CHR.rho, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho, pot.vr); //cout<<"Exc = "<eband = 0; // the band energy this->deband = 0; // correction for variational energy this->deband_harris = 0; // harris energy - this->etxc = 0; // the exchange and correlation energy - this->vtxc = 0; // another exchange-correlation energy this->etxcc = 0; // the nlcc exchange and correlation this->exx = 0; // the exact exchange energy. @@ -51,7 +50,8 @@ void energy::calculate_harris(const int &flag) } else if(flag==2) { - this->etot_harris = eband + deband_harris + (etxc - etxcc) + this->etot_harris = eband + deband_harris + + (H_XC_pw::etxc - etxcc) + H_Ewald_pw::ewald_energy + H_Hartree_pw::hartree_energy + demet + exx + Efield::etotefield; @@ -69,7 +69,8 @@ void energy::calculate_etot(void) { TITLE("energy","calculate_etot"); //cout << "\n demet in etot = " << demet << endl; - this->etot = eband + deband + (etxc - etxcc) + this->etot = eband + deband + + (H_XC_pw::etxc - etxcc) + H_Ewald_pw::ewald_energy + H_Hartree_pw::hartree_energy + demet + descf + exx + Efield::etotefield; @@ -118,7 +119,7 @@ bool print) this->print_format("E_band",eband); this->print_format("E_one_elec",eband+deband); this->print_format("E_Hartree",H_Hartree_pw::hartree_energy); - this->print_format("E_xc",etxc-etxcc); + this->print_format("E_xc",H_XC_pw::etxc-etxcc); this->print_format("E_Ewald",H_Ewald_pw::ewald_energy); this->print_format("E_demet",demet); //mohan add 2011-12-02 this->print_format("E_descf",descf); diff --git a/ABACUS.develop/source/src_pw/energy.h b/ABACUS.develop/source/src_pw/energy.h index bc5c564876..f49e59efdf 100644 --- a/ABACUS.develop/source/src_pw/energy.h +++ b/ABACUS.develop/source/src_pw/energy.h @@ -49,8 +49,6 @@ class energy double deband_harris; double descf; - double etxc; // the exchange and correlation energy - double vtxc; // another exchange-correlation energy double etxcc; // the nlcc exchange and correlation double exx; // the exact exchange energy. diff --git a/ABACUS.develop/source/src_pw/forces.cpp b/ABACUS.develop/source/src_pw/forces.cpp index a518c901cb..cebaeb180d 100644 --- a/ABACUS.develop/source/src_pw/forces.cpp +++ b/ABACUS.develop/source/src_pw/forces.cpp @@ -3,6 +3,8 @@ #include "vdwd2.h" #include "vdwd3.h" #include "symmetry.h" +// new +#include "H_XC_pw.h" double Forces::output_acc = 1.0e-8; // (Ryd/angstrom). @@ -538,7 +540,7 @@ void Forces::cal_force_cc(void) // recalculate the exchange-correlation potential. matrix vxc(NSPIN, pw.nrxx); - pot.v_xc(CHR.rho, en.etxc, en.vtxc, vxc); + H_XC_pw::v_xc(pw.nrxx, pw.ncxyz, ucell.omega, CHR.rho, CHR.rho_core, vxc); complex * psiv = new complex [pw.nrxx]; ZEROS(psiv, pw.nrxx); diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index 8aa272254d..a5be825d38 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -8,6 +8,7 @@ #include "potential_libxc.h" // new #include "H_Hartree_pw.h" +#include "H_XC_pw.h" potential::potential() { @@ -176,7 +177,7 @@ void potential::init_pot(const int &istep) CHR.renormalize_rho(); - this->v_of_rho(CHR.rho, en.etxc, en.vtxc, vr); + this->v_of_rho(CHR.rho, vr); //---------------------------------------------------------- // Define the total local potential (external+scf) in DFT @@ -252,8 +253,6 @@ void potential::set_local(double* vl_pseudo)const void potential::v_of_rho ( double **rho_in, - double &etxc, - double &vtxc, matrix &v_in ) { @@ -267,9 +266,9 @@ void potential::v_of_rho //---------------------------------------------------------- #ifdef TEST_LIBXC - Potential_Libxc::v_xc(rho_in, etxc, vtxc, v_in); + Potential_Libxc::v_xc(rho_in, en.etxc, en.vtxc, v_in); #else - this->v_xc(rho_in, etxc, vtxc, v_in); + H_XC_pw::v_xc(pw.nrxx, pw.ncxyz, ucell.omega, rho_in, CHR.rho_core, v_in); #endif //---------------------------------------------------------- @@ -291,186 +290,6 @@ void potential::v_of_rho } //end subroutine v_of_rho -//-------------------------------------------------------------------- -void potential::v_xc -( - double **rho_in, - double &etxc, - double &vtxc, - matrix &v) -{ - TITLE("potential","v_xc"); - timer::tick("potential","v_xc"); - //Exchange-Correlation potential Vxc(r) from n(r) - etxc = 0.0; - vtxc = 0.0; - - // the square of the e charge - // in Rydeberg unit, so * 2.0. - double e2 = 2.0; - - double rhox = 0.0; - double arhox = 0.0; - double zeta = 0.0; - double ex = 0.0; - double ec = 0.0; - double vx[2]; - double vc[2]; - - int ir, is; - int neg [3]; - - double vanishing_charge = 1.0e-10; - if (NSPIN == 1 || ( NSPIN ==4 && !DOMAG && !DOMAG_Z)) - { - // spin-unpolarized case - // for parallel : ncxyz change ==> nrxx - // 2008-06-01 mohan - for (int ir = 0;ir < pw.nrxx;ir++) - { - rhox = rho_in[0][ir] + CHR.rho_core[ir]; - arhox = abs(rhox); - if (arhox > vanishing_charge) - { - // call - XC_Functional::xc(arhox, ex, ec, vx[0], vc[0]); - //if(ir<10) - //{ - // cout << "\n ir = " << ir << " ex = " << ex << " ec = " << ec; - //} - v(0,ir) = e2 * (vx[0] + vc[0]); - etxc += e2 * (ex + ec) * rhox; - vtxc += v(0, ir) * rho_in[0][ir]; - } // endif - } //enddo - } - else if(NSPIN ==2) - { - // spin-polarized case - neg [0] = 0; - neg [1] = 0; - neg [2] = 0; - - // 2008-06-01 mohan - if (test_potential>0) cout<<"\n Begin calculate Exc(r) and Vxc(r)"; - for (ir = 0;ir < pw.nrxx;ir++) - { - rhox = rho_in[0][ir] + rho_in[1][ir] + CHR.rho_core[ir]; //HLX(05-29-06): bug fixed - arhox = abs(rhox); - - if (arhox > vanishing_charge) - { - zeta = (rho_in[0][ir] - rho_in[1][ir]) / arhox; //HLX(05-29-06): bug fixed - - if (abs(zeta) > 1.0) - { - ++neg[2]; - zeta = (zeta > 0.0) ? 1.0 : (-1.0); - } - - if (rho_in[0][ir] < 0.0) - { - ++neg[0]; - } - - if (rho_in[1][ir] < 0.0) - { - ++neg[1]; - } - - // call - XC_Functional::xc_spin(arhox, zeta, ex, ec, vx[0], vx[1], vc[0], vc[1]); - - //if(ir<10) - //{ - // cout << "\n ir = " << ir << " ex = " << ex << " ec = " << ec; - //} - - for (is = 0;is < NSPIN;is++) - { - v(is, ir) = e2 * (vx[is] + vc[is]); - } - - etxc += e2 * (ex + ec) * rhox; - - vtxc += v(0, ir) * rho_in[0][ir] + v(1, ir) * rho_in[1][ir]; - } // endif - } // enddo - if (test_potential>0) cout<<"\n End calculate Exc(r) and Vxc(r) with SPIN == 2"; - - } // nspin 2 - else if(NSPIN == 4)//noncollinear case added by zhengdy - { - for( ir = 0;ir vanishing_charge ) - { - zeta = amag / arhox; - - if ( abs( zeta ) > 1.0 ) - { - neg[1] += 1.0 / ucell.omega; - - zeta = (zeta > 0.0) ? 1.0 : (-1.0); - }//end if - - XC_Functional::xc_spin( arhox, zeta, ex, ec, vx[0], vx[1], vc[0], vc[1] ); - - etxc += e2 * ( ex + ec ) * rhox; - - v(0, ir) = e2*( 0.5 * ( vx[0] + vc[0] + vx[1] + vc[1] ) ); - vtxc += v(0,ir) * rho_in[0][ir]; - - double vs = 0.5 * ( vx[0] + vc[0] - vx[1] - vc[1] ); - if ( amag > vanishing_charge ) - { - for(int ipol = 1;ipol< 4;ipol++) - { - v(ipol, ir) = e2 * vs * rho_in[ipol][ir] / amag; - vtxc += v(ipol,ir) * rho_in[ipol][ir]; - }//end do - }//end if - }//end if - }//end do - }//end if - // energy terms, local-density contributions - - // add gradient corrections (if any) - // mohan modify 2009-12-15 - GGA_PW::gradcorr(etxc, vtxc, v); - - // parallel code : collect vtxc,etxc - // mohan add 2008-06-01 - Parallel_Reduce::reduce_double_pool( etxc ); - Parallel_Reduce::reduce_double_pool( vtxc ); - - etxc *= ucell.omega / pw.ncxyz; - vtxc *= ucell.omega / pw.ncxyz; - if (test_potential > 1) - { - OUT(ofs_running,"etxc",etxc); - OUT(ofs_running,"vtxc",vtxc); - } - - if (test_potential >0 ) cout<<"\n End calculate gradient"; - - if (test_potential > 2) - { - cout<<"\n After gradcorr : vtxc = "< = are calculated after sum // band, using output charge density. @@ -211,7 +211,7 @@ void Stochastic_Elec::scf_stochastic(const int &istep) } // the new potential V(PL)+V(H)+V(xc) - pot.v_of_rho(CHR.rho, en.etxc, en.vtxc, pot.vr); + pot.v_of_rho(CHR.rho, pot.vr); //( vnew used later for scf correction to the forces ) pot.vnew = pot.vr - pot.vnew; diff --git a/ABACUS.develop/source/src_pw/stress.cpp b/ABACUS.develop/source/src_pw/stress.cpp index 28f75baea2..95ee408595 100644 --- a/ABACUS.develop/source/src_pw/stress.cpp +++ b/ABACUS.develop/source/src_pw/stress.cpp @@ -9,6 +9,7 @@ // new #include "H_Ewald_pw.h" #include "H_Hartree_pw.h" +#include "H_XC_pw.h" void Stress::cal_stress() { @@ -44,8 +45,9 @@ void Stress::cal_stress() stres_ewa(); //xc contribution: add gradient corrections(non diagonal) - for(int i=0;i<3;i++){ - sigmaxc[i][i] = - (en.etxc-en.vtxc) / ucell.omega; + for(int i=0;i<3;i++) + { + sigmaxc[i][i] = - (H_XC_pw::etxc - H_XC_pw::vtxc) / ucell.omega; } stres_gradcorr(); @@ -1686,7 +1688,7 @@ void Stress::stres_cc() //recalculate the exchange-correlation potential matrix vxc(NSPIN, pw.nrxx); - pot.v_xc(CHR.rho, en.etxc, en.vtxc, vxc); + H_XC_pw::v_xc(pw.nrxx, pw.ncxyz, ucell.omega, CHR.rho, CHR.rho_core, vxc); complex * psic = new complex [pw.nrxx]; ZEROS(psic, pw.nrxx); From 2765857754edcf554b91ddafed82571c91260ef2 Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 26 Feb 2021 17:29:33 +0800 Subject: [PATCH 154/233] move write_rho_dipole function in charge.cpp to src_io/write_rho_dipole.cpp --- ABACUS.develop/source/Makefile.Objects | 1 + .../source/src_io/write_rho_dipole.cpp | 371 ++++++++++++++++++ ABACUS.develop/source/src_pw/charge.cpp | 370 ----------------- ABACUS.develop/source/src_pw/charge.h | 8 +- ABACUS.develop/source/src_pw/potential.h | 6 +- ABACUS.develop/source/src_pw/wavefunc.h | 5 - ABACUS.develop/source/src_pw/wf_igk.cpp | 1 - ABACUS.develop/source/src_pw/wf_igk.h | 2 + 8 files changed, 376 insertions(+), 388 deletions(-) create mode 100644 ABACUS.develop/source/src_io/write_rho_dipole.cpp diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 08f7500277..b282e9f023 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -214,6 +214,7 @@ H_Ewald_pw.o\ H_Hartree_pw.o\ H_XC_pw.o \ write_pot.o\ +write_rho_dipole.o\ potential_libxc.o \ efield.o \ magnetism.o\ diff --git a/ABACUS.develop/source/src_io/write_rho_dipole.cpp b/ABACUS.develop/source/src_io/write_rho_dipole.cpp new file mode 100644 index 0000000000..bb0559e840 --- /dev/null +++ b/ABACUS.develop/source/src_io/write_rho_dipole.cpp @@ -0,0 +1,371 @@ +#include "src_pw/charge.h" +#include "src_pw/energy.h" +#include "src_pw/global.h" + +//fuxiang add 2017-03-15 +void Charge::write_rho_dipole(const int &is, const int &iter, const string &fn, const int &precision, const bool for_plot) +{ + TITLE("Charge","write_rho_dipole"); + if (out_charge==0) + { + return; + } + else if(iter % out_charge != 0) + { + return; // mohan add 2010-05-22 + } + + time_t start, end; + ofstream ofs; + + if(MY_RANK==0) + { + start = time(NULL); + + ofs.open(fn.c_str()); + if (!ofs) + { + WARNING("Charge::write_rho","Can't create Charge File!"); + } + + //ofs_running << "\n Output charge file." << endl; + + ofs << ucell.latName << endl;//1 + ofs << " " << ucell.lat0 * 0.529177 << endl; + ofs << " " << ucell.latvec.e11 << " " << ucell.latvec.e12 << " " << ucell.latvec.e13 << endl; + ofs << " " << ucell.latvec.e21 << " " << ucell.latvec.e22 << " " << ucell.latvec.e23 << endl; + ofs << " " << ucell.latvec.e31 << " " << ucell.latvec.e32 << " " << ucell.latvec.e33 << endl; + for(int it=0; it( pw.ncxyz ); + dipole_elec_y *= ucell.omega / static_cast( pw.ncxyz ); + dipole_elec_z *= ucell.omega / static_cast( pw.ncxyz ); + Parallel_Reduce::reduce_double_pool( dipole_elec_x ); + Parallel_Reduce::reduce_double_pool( dipole_elec_y ); + Parallel_Reduce::reduce_double_pool( dipole_elec_z ); + + //cout << "dipole_elec_x: " << dipole_elec_x <( pw.ncxyz ); - dipole_elec_y *= ucell.omega / static_cast( pw.ncxyz ); - dipole_elec_z *= ucell.omega / static_cast( pw.ncxyz ); - Parallel_Reduce::reduce_double_pool( dipole_elec_x ); - Parallel_Reduce::reduce_double_pool( dipole_elec_y ); - Parallel_Reduce::reduce_double_pool( dipole_elec_z ); - - //cout << "dipole_elec_x: " << dipole_elec_x <** rhog_save; double *rho_core; - complex *rhog_core; // mohan add 2009-12-15 + complex *rhog_core; int out_charge; // output charge if out_charge > 0, and output every "out_charge" elec step. double *start_mag_type; double *start_mag_atom; - void atomic_rho(const int spin_number_need, double **rho_in)const; void set_rho_core(const ComplexMatrix &structure_factor); diff --git a/ABACUS.develop/source/src_pw/potential.h b/ABACUS.develop/source/src_pw/potential.h index b877384fbc..d8af34e7c3 100644 --- a/ABACUS.develop/source/src_pw/potential.h +++ b/ABACUS.develop/source/src_pw/potential.h @@ -1,5 +1,6 @@ #ifndef POTENTIAL_H #define POTENTIAL_H + #include "tools.h" class potential @@ -40,7 +41,6 @@ class potential void set_vrs(void); - void newd(void); public: @@ -56,10 +56,6 @@ class potential void set_local(double *vl_pseudo)const; - - - private: - // TDDFT related, fuxiang add double *vext; diff --git a/ABACUS.develop/source/src_pw/wavefunc.h b/ABACUS.develop/source/src_pw/wavefunc.h index 51945fba24..b5731cf683 100644 --- a/ABACUS.develop/source/src_pw/wavefunc.h +++ b/ABACUS.develop/source/src_pw/wavefunc.h @@ -1,8 +1,3 @@ -//========================================================== -// AUTHOR : Lixin He, Mohan Chen -// DATE : 2008-11-13 -// LAST UPDATE : 2009-03-17 add out_wf -//========================================================== #ifndef WAVEFUNC_H #define WAVEFUNC_H diff --git a/ABACUS.develop/source/src_pw/wf_igk.cpp b/ABACUS.develop/source/src_pw/wf_igk.cpp index 6669680892..ce53c5d349 100644 --- a/ABACUS.develop/source/src_pw/wf_igk.cpp +++ b/ABACUS.develop/source/src_pw/wf_igk.cpp @@ -23,7 +23,6 @@ WF_igk::~WF_igk() // set npwx // set igk //======================================================== -//similar to n_plane_waves.f90 int WF_igk::setupIndGk(const PW_Basis &pwb,const int nks) { TITLE("WF_igk","setupIndGk"); diff --git a/ABACUS.develop/source/src_pw/wf_igk.h b/ABACUS.develop/source/src_pw/wf_igk.h index 1857dfc203..02f556e8be 100644 --- a/ABACUS.develop/source/src_pw/wf_igk.h +++ b/ABACUS.develop/source/src_pw/wf_igk.h @@ -15,7 +15,9 @@ class WF_igk int setupIndGk(const PW_Basis &pwb,const int nks); int npwx; + int npw; + IntArray igk; // g2kin : [npw],kinetic energy for current k point From c790adf2ac57a17b193fd9057faed5e87ae57f67 Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 26 Feb 2021 20:25:29 +0800 Subject: [PATCH 155/233] add read_rho and write_rho in src_io/ --- ABACUS.develop/source/Makefile.Objects | 2 + ABACUS.develop/source/src_io/read_rho.cpp | 120 ++++++ ABACUS.develop/source/src_io/write_rho.cpp | 225 +++++++++++ ABACUS.develop/source/src_pw/charge.cpp | 445 ++------------------- ABACUS.develop/source/src_pw/charge.h | 39 +- ABACUS.develop/source/src_pw/energy.cpp | 101 +---- ABACUS.develop/source/src_pw/potential.cpp | 1 - 7 files changed, 409 insertions(+), 524 deletions(-) create mode 100644 ABACUS.develop/source/src_io/read_rho.cpp create mode 100644 ABACUS.develop/source/src_io/write_rho.cpp diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index b282e9f023..5fd256db2b 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -213,7 +213,9 @@ potential.o \ H_Ewald_pw.o\ H_Hartree_pw.o\ H_XC_pw.o \ +read_rho.o\ write_pot.o\ +write_rho.o\ write_rho_dipole.o\ potential_libxc.o \ efield.o \ diff --git a/ABACUS.develop/source/src_io/read_rho.cpp b/ABACUS.develop/source/src_io/read_rho.cpp new file mode 100644 index 0000000000..f673017e97 --- /dev/null +++ b/ABACUS.develop/source/src_io/read_rho.cpp @@ -0,0 +1,120 @@ +#include "src_pw/charge.h" +#include "src_pw/global.h" + +bool Charge::read_rho(const int &is, const string &fn) //add by dwan +{ + TITLE("Charge","read_rho"); + ifstream ifs(fn.c_str()); + if (!ifs) + { + ofs_running << " !!! Couldn't find the charge file !!!" << endl; + return false; + } + else + { + ofs_running << " Find the file, try to read charge from file." << endl; + } + + bool quit=false; + + string name; + ifs >> name; + + // check lattice constant, unit is Angstrom + CHECK_DOUBLE(ifs,ucell.lat0 * 0.529177,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e11,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e12,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e13,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e21,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e22,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e23,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e31,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e32,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e33,quit); + + for(int it=0; it> coordinate; + + for(int it=0; it> rho[is][i*pw.ncy*pw.ncz + j*pw.ncz +k]; + } + } + } +#else + + const int nxy = pw.ncx * pw.ncy; + double *zpiece = new double[nxy]; + for(int iz=0; iz0); double *rho1d = new double[ucell.meshx]; @@ -196,6 +192,7 @@ void Charge::atomic_rho(const int spin_number_need, double** rho_in)const } } } + if(NSPIN==4) startmag_type = 1;//zhengdy-soc, type 2 is still wrong. OUT(ofs_warning,"startmag_type",startmag_type); @@ -204,12 +201,9 @@ void Charge::atomic_rho(const int spin_number_need, double** rho_in)const { Atom* atom = &ucell.atoms[it]; - if (test_charge>0) cout<<" To get charge in G for atom type : " << it <msh; - - //---------------------------------------------------------- // Here we check the electron number //---------------------------------------------------------- @@ -219,9 +213,9 @@ void Charge::atomic_rho(const int spin_number_need, double** rho_in)const double r2=atom->r[ir]*atom->r[ir]; rhoatm[ir]=atom->rho_at[ir]/FOUR_PI/r2; } - rhoatm[0] = pow( (rhoatm[2]/rhoatm[1]), 1./(atom->r[2]-atom->r[1]) );//{zws add + rhoatm[0] = pow( (rhoatm[2]/rhoatm[1]), 1./(atom->r[2]-atom->r[1]) );//zws add rhoatm[0] = pow(rhoatm[0], atom->r[1]); - rhoatm[0] = rhoatm[1] / rhoatm[0]; //} + rhoatm[0] = rhoatm[1] / rhoatm[0]; double charge = 0.0; Mathzone::Simpson_Integral(atom->msh,atom->rho_at,atom->rab,charge); @@ -244,12 +238,11 @@ void Charge::atomic_rho(const int spin_number_need, double** rho_in)const //---------------------------------------------------------- // Here we compute the G=0 term //---------------------------------------------------------- - if (pw.gstart == 1) { for (int ir = 0;ir < mesh;ir++) { -// rho1d [ir] = atom->rho_at[ir]; +// rho1d [ir] = atom->rho_at[ir]; rho1d[ir] = rhoatm[ir]; } Mathzone::Simpson_Integral(mesh, rho1d, atom->rab , rho_lgl[0]); @@ -282,19 +275,9 @@ void Charge::atomic_rho(const int spin_number_need, double** rho_in)const } Mathzone::Simpson_Integral(mesh , rho1d, atom->rab , rho_lgl [ig]); } - - delete[] rhoatm; - - - - - - - - if (test_charge>0) cout<<" |G|>0 term done." < swap = pw.strucFac(it, ig)* rho_lgl[pw.ig2ngg[ig]]; //rho_g3d(0, ig) += swap * mag.nelup_percent(it); //rho_g3d(1, ig) += swap * mag.neldw_percent(it); - const double up = 0.5 * ( 1 + mag.start_magnetization[it] / atom->zv ); - const double dw = 0.5 * ( 1 - mag.start_magnetization[it] / atom->zv ); - rho_g3d(0, ig) += swap * up; - rho_g3d(1, ig) += swap * dw; + const double up = 0.5 * ( 1 + mag.start_magnetization[it] / atom->zv ); + const double dw = 0.5 * ( 1 - mag.start_magnetization[it] / atom->zv ); + rho_g3d(0, ig) += swap * up; + rho_g3d(1, ig) += swap * dw; } } // mohan add 2011-06-14 @@ -370,12 +352,12 @@ void Charge::atomic_rho(const int spin_number_need, double** rho_in)const rho_g3d(0, ig) += swap ; if(DOMAG) { - //rho_g3d(1, ig) += swap * mag.start_magnetization[it] * sin(soc.angle1[it]) * cos(soc.angle2[it]); - //rho_g3d(2, ig) += swap * mag.start_magnetization[it] * sin(soc.angle1[it]) * sin(soc.angle2[it]); - //rho_g3d(3, ig) += swap * mag.start_magnetization[it] * cos(soc.angle1[it]); - rho_g3d(1, ig) += swap * (mag.start_magnetization[it] / atom->zv) * sin(soc.angle1[it]) * cos(soc.angle2[it]); - rho_g3d(2, ig) += swap * (mag.start_magnetization[it] / atom->zv) * sin(soc.angle1[it]) * sin(soc.angle2[it]); - rho_g3d(3, ig) += swap * (mag.start_magnetization[it] / atom->zv) * cos(soc.angle1[it]); + rho_g3d(1, ig) += swap * (mag.start_magnetization[it] / atom->zv) + * sin(soc.angle1[it]) * cos(soc.angle2[it]); + rho_g3d(2, ig) += swap * (mag.start_magnetization[it] / atom->zv) + * sin(soc.angle1[it]) * sin(soc.angle2[it]); + rho_g3d(3, ig) += swap * (mag.start_magnetization[it] / atom->zv) + * cos(soc.angle1[it]); } else if(DOMAG_Z) { @@ -402,16 +384,15 @@ void Charge::atomic_rho(const int spin_number_need, double** rho_in)const rho_g3d(0, ig) += swap; if(DOMAG) { - //rho_g3d(1, ig) += swap * atom->mag[ia] * sin(soc.angle1[it]) * cos(soc.angle2[it]); - //rho_g3d(2, ig) += swap * atom->mag[ia] * sin(soc.angle1[it]) * sin(soc.angle2[it]); - //rho_g3d(3, ig) += swap * atom->mag[ia] * cos(soc.angle1[it]); - rho_g3d(1, ig) += swap * (atom->mag[ia] / atom->zv) * sin(soc.angle1[it]) * cos(soc.angle2[it]); - rho_g3d(2, ig) += swap * (atom->mag[ia] / atom->zv) * sin(soc.angle1[it]) * sin(soc.angle2[it]); - rho_g3d(3, ig) += swap * (atom->mag[ia] / atom->zv) * cos(soc.angle1[it]); + rho_g3d(1, ig) += swap * (atom->mag[ia] / atom->zv) + * sin(soc.angle1[it]) * cos(soc.angle2[it]); + rho_g3d(2, ig) += swap * (atom->mag[ia] / atom->zv) + * sin(soc.angle1[it]) * sin(soc.angle2[it]); + rho_g3d(3, ig) += swap * (atom->mag[ia] / atom->zv) + * cos(soc.angle1[it]); } else if(DOMAG_Z) { - //rho_g3d(3, ig) += swap * atom->mag[ia]; rho_g3d(3, ig) += swap * (atom->mag[ia] / atom->zv); } } @@ -427,7 +408,6 @@ void Charge::atomic_rho(const int spin_number_need, double** rho_in)const delete [] rho_lgl; delete [] rho1d;; - if (test_charge>0) cout<<"\n Charge in G space is done."< 0 ); double* ne = new double[spin_number_need]; @@ -504,8 +484,6 @@ void Charge::atomic_rho(const int spin_number_need, double** rho_in)const } } - - // if TWO_EFEMI, // the total magnetism will affect the calculation of // occupations. @@ -519,11 +497,9 @@ void Charge::atomic_rho(const int spin_number_need, double** rho_in)const return; } + //========================================================== -// MEMBER FUNCTION : -// set_rhoc : computes the core charge on the real space -// 3D mesh. -// from set_rhoc.f90 +// computes the core charge on the real space 3D mesh. //========================================================== void Charge::set_rho_core( const ComplexMatrix &structure_factor @@ -531,6 +507,7 @@ void Charge::set_rho_core( { TITLE("Charge","set_rho_core"); timer::tick("Charge","set_rho_core"); + //double eps = 1.e-10; en.etxcc = 0.0; //---------------------------------------------------------- @@ -546,10 +523,6 @@ void Charge::set_rho_core( bool bl = false; for (int it = 0; it> name; - - // check lattice constant, unit is Angstrom - CHECK_DOUBLE(ifs,ucell.lat0 * 0.529177,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e11,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e12,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e13,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e21,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e22,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e23,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e31,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e32,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e33,quit); - - for(int it=0; it> coordinate; - - for(int it=0; it> rho[is][i*pw.ncy*pw.ncz + j*pw.ncz +k]; - } - } - } -#else - - const int nxy = pw.ncx * pw.ncy; - double *zpiece = new double[nxy]; - for(int iz=0; iz 0, and output every "out_charge" elec step. + int out_charge; double *start_mag_type; double *start_mag_atom; + // mohan update 2021-02-20 + void allocate(const int &nspin_in, const int &nrxx_in, const int &ngmc_in); + void atomic_rho(const int spin_number_need, double **rho_in)const; void set_rho_core(const ComplexMatrix &structure_factor); - void write_rho(const int &is, const int &iter, const string &fn, - const int &precision = 11, const bool for_plot = false);//mohan add 2007-10-17 - - void write_rho_dipole(const int &is, const int &iter, const string &fn, - const int &precision = 11, const bool for_plot = false);//fuxiang add 2017-3-15 - - bool read_rho(const int &is, const string &fn);//mohan add 2007-10-17 - void sum_band(void); void renormalize_rho(void); void save_rho_before_sum_band(void); - void non_linear_core_correction// drhoc + // for non-linear core correction + void non_linear_core_correction ( const bool &numeric, const int mesh, @@ -76,6 +68,17 @@ class Charge void init_final_scf(); //LiuXh add 20180619 + public: + + void write_rho(const int &is, const int &iter, const string &fn, + const int &precision = 11, const bool for_plot = false);//mohan add 2007-10-17 + + void write_rho_dipole(const int &is, const int &iter, const string &fn, + const int &precision = 11, const bool for_plot = false);//fuxiang add 2017-3-15 + + bool read_rho(const int &is, const string &fn);//mohan add 2007-10-17 + + private: // mohan add 2021-02-20 diff --git a/ABACUS.develop/source/src_pw/energy.cpp b/ABACUS.develop/source/src_pw/energy.cpp index d384813184..baa0b85cd2 100644 --- a/ABACUS.develop/source/src_pw/energy.cpp +++ b/ABACUS.develop/source/src_pw/energy.cpp @@ -157,68 +157,8 @@ bool print) this->etot_old = this->etot; } - // for test, output eigenvalues. - /* - for(int ik=0; iketot_old = this->etot; + this->etot_old = this->etot; return; } diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index a5be825d38..23297c82d5 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -200,7 +200,6 @@ void potential::init_pot(const int &istep) //========================================================== // This routine computes the local potential in real space -// vltot(ir) //========================================================== void potential::set_local(double* vl_pseudo)const { From 92179c1b53b61f5a49303da1101167194e436fcf Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 26 Feb 2021 22:04:19 +0800 Subject: [PATCH 156/233] change the class name of Use_Hamilt_Matrix to LCAO_Hamilt --- ABACUS.develop/source/driver.cpp | 2 - ABACUS.develop/source/run_lcao.cpp | 4 +- .../source/src_lcao/ELEC_cbands_gamma.cpp | 6 +-- .../source/src_lcao/ELEC_cbands_gamma.h | 2 +- .../source/src_lcao/ELEC_cbands_k.cpp | 2 +- .../source/src_lcao/ELEC_cbands_k.h | 2 +- .../source/src_lcao/ELEC_evolve.cpp | 2 +- ABACUS.develop/source/src_lcao/ELEC_evolve.h | 2 +- ABACUS.develop/source/src_lcao/ELEC_nscf.cpp | 2 +- ABACUS.develop/source/src_lcao/ELEC_nscf.h | 2 +- .../source/src_lcao/LCAO_gen_fixedH.cpp | 5 +-- .../source/src_lcao/LCAO_hamilt.cpp | 45 ++++++++++--------- ABACUS.develop/source/src_lcao/LCAO_hamilt.h | 13 +++--- ABACUS.develop/source/src_lcao/LCAO_nnr.cpp | 2 +- .../source/src_lcao/build_st_pw.cpp | 2 +- ABACUS.develop/source/src_lcao/global_fp.cpp | 2 +- ABACUS.develop/source/src_lcao/global_fp.h | 2 +- .../source/src_lcao/local_orbital_elec.cpp | 19 +++++--- .../source/src_lcao/local_orbital_elec.h | 4 +- .../source/src_lcao/local_orbital_ions.cpp | 8 ++-- 20 files changed, 67 insertions(+), 61 deletions(-) diff --git a/ABACUS.develop/source/driver.cpp b/ABACUS.develop/source/driver.cpp index 0264b2e65b..15763bbff7 100644 --- a/ABACUS.develop/source/driver.cpp +++ b/ABACUS.develop/source/driver.cpp @@ -71,7 +71,6 @@ void Driver::reading(void) void Driver::atomic_world(void) { TITLE("Driver","atomic_world"); - timer::tick("Driver","atomic_world",'A'); //-------------------------------------------------- // choose basis sets: @@ -88,7 +87,6 @@ void Driver::atomic_world(void) Run_lcao::lcao_line(); } - timer::tick("Driver","atomic_world",'A'); timer::finish( ofs_running ); Memory::print_all( ofs_running ) ; diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index f6c82fed2c..f129bd95e6 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -21,7 +21,7 @@ Run_lcao::~Run_lcao(){} void Run_lcao::lcao_line(void) { TITLE("Run_lcao","lcao_line"); - timer::tick("Run_lcao","lcao_line",'B'); + timer::tick("Run_lcao","lcao_line",'A'); // Setup the unitcell. @@ -173,6 +173,6 @@ void Run_lcao::lcao_line(void) ions.opt_ions(); en.perform_dos(); - timer::tick("Run_lcao","lcao_line",'B'); + timer::tick("Run_lcao","lcao_line",'A'); return; } diff --git a/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp b/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp index 838cd7a2f9..3ee1cb589d 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp @@ -11,7 +11,7 @@ ELEC_cbands_gamma::ELEC_cbands_gamma(){}; ELEC_cbands_gamma::~ELEC_cbands_gamma(){}; -void ELEC_cbands_gamma::cal_bands(const int &istep, Use_Hamilt_Matrix &uhm) +void ELEC_cbands_gamma::cal_bands(const int &istep, LCAO_Hamilt &uhm) { TITLE("ELEC_cbands_gamma","cal_bands"); timer::tick("ELEC_cband_gamma","cal_bands",'E'); @@ -35,7 +35,7 @@ void ELEC_cbands_gamma::cal_bands(const int &istep, Use_Hamilt_Matrix &uhm) pot.vrs1[ir] = pot.vrs( CURRENT_SPIN, ir); } - if(!UHM.init_s) + if(!uhm.init_s) { WARNING_QUIT("Hamilt_Linear::solve_using_cg","Need init S matrix firstly"); } @@ -46,7 +46,7 @@ void ELEC_cbands_gamma::cal_bands(const int &istep, Use_Hamilt_Matrix &uhm) //-------------------------------------------- // Peize Lin add ik 2016-12-03 - UHM.calculate_Hgamma(ik); + uhm.calculate_Hgamma(ik); // Effective potential of DFT+U is added to total Hamiltonian here; Quxin adds on 20201029 if(INPUT.dft_plus_u) diff --git a/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.h b/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.h index 55d6d50178..8268288616 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.h +++ b/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.h @@ -26,7 +26,7 @@ class ELEC_cbands_gamma private: - static void cal_bands(const int &istep, Use_Hamilt_Matrix &uhm); + static void cal_bands(const int &istep, LCAO_Hamilt &uhm); }; diff --git a/ABACUS.develop/source/src_lcao/ELEC_cbands_k.cpp b/ABACUS.develop/source/src_lcao/ELEC_cbands_k.cpp index 89446d35ba..17db6c76a2 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_cbands_k.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_cbands_k.cpp @@ -10,7 +10,7 @@ ELEC_cbands_k::ELEC_cbands_k(){}; ELEC_cbands_k::~ELEC_cbands_k(){}; -void ELEC_cbands_k::cal_bands(const int &istep, Use_Hamilt_Matrix &uhm) +void ELEC_cbands_k::cal_bands(const int &istep, LCAO_Hamilt &uhm) { TITLE("ELEC_cbands_k","cal_bands"); timer::tick("ELEC_cbands_k","cal_bands",'E'); diff --git a/ABACUS.develop/source/src_lcao/ELEC_cbands_k.h b/ABACUS.develop/source/src_lcao/ELEC_cbands_k.h index c3d8d01b26..cafbab38e7 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_cbands_k.h +++ b/ABACUS.develop/source/src_lcao/ELEC_cbands_k.h @@ -26,7 +26,7 @@ class ELEC_cbands_k private: - static void cal_bands(const int &istep, Use_Hamilt_Matrix &uhm); + static void cal_bands(const int &istep, LCAO_Hamilt &uhm); }; diff --git a/ABACUS.develop/source/src_lcao/ELEC_evolve.cpp b/ABACUS.develop/source/src_lcao/ELEC_evolve.cpp index 2f316f9057..b853c3cba0 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_evolve.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_evolve.cpp @@ -10,7 +10,7 @@ ELEC_evolve::ELEC_evolve(){}; ELEC_evolve::~ELEC_evolve(){}; // this routine only serves for TDDFT using LCAO basis set -void ELEC_evolve::evolve_psi(const int &istep, Use_Hamilt_Matrix &uhm, complex ***wfc) +void ELEC_evolve::evolve_psi(const int &istep, LCAO_Hamilt &uhm, complex ***wfc) { TITLE("ELEC_evolve","eveolve_psi"); timer::tick("ELEC_evolve","evolve_psi",'E'); diff --git a/ABACUS.develop/source/src_lcao/ELEC_evolve.h b/ABACUS.develop/source/src_lcao/ELEC_evolve.h index 39691d1b1b..05043833fe 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_evolve.h +++ b/ABACUS.develop/source/src_lcao/ELEC_evolve.h @@ -23,7 +23,7 @@ class ELEC_evolve private: - static void evolve_psi(const int &istep, Use_Hamilt_Matrix &uhm, complex*** wfc); + static void evolve_psi(const int &istep, LCAO_Hamilt &uhm, complex*** wfc); }; diff --git a/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp b/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp index 4e0baba9b5..e60852891a 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp @@ -11,7 +11,7 @@ ELEC_nscf::ELEC_nscf(){} ELEC_nscf::~ELEC_nscf(){} -void ELEC_nscf::nscf(Use_Hamilt_Matrix &uhm) +void ELEC_nscf::nscf(LCAO_Hamilt &uhm) { TITLE("ELEC_nscf","nscf"); diff --git a/ABACUS.develop/source/src_lcao/ELEC_nscf.h b/ABACUS.develop/source/src_lcao/ELEC_nscf.h index 84f9426dce..324205739b 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_nscf.h +++ b/ABACUS.develop/source/src_lcao/ELEC_nscf.h @@ -24,7 +24,7 @@ class ELEC_nscf private: - static void nscf(Use_Hamilt_Matrix &uhm); + static void nscf(LCAO_Hamilt &uhm); }; diff --git a/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.cpp b/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.cpp index 41fec2bf1c..3457a8a11c 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.cpp @@ -416,7 +416,6 @@ void LCAO_gen_fixedH::build_Nonlocal_mu(const bool &calc_deri) // RA.for_2d(); // psi1 -// double sum = 0.0; for (int T1 = 0; T1 < ucell.ntype; ++T1) { const Atom* atom1 = &ucell.atoms[T1]; @@ -548,7 +547,8 @@ void LCAO_gen_fixedH::build_Nonlocal_mu(const bool &calc_deri) // mohan add 2010-12-20 if( nlm[0]!=0.0 ) { - //ofs_running << setw(10) << iw1_all << setw(10) << iw2_all << setw(20) << nlm[0] << endl; + // ofs_running << setw(10) << iw1_all << setw(10) + // << iw2_all << setw(20) << nlm[0] << endl; LM.set_HSgamma(iw1_all,iw2_all,nlm[0],'N');//N stands for nonlocal. } } @@ -621,7 +621,6 @@ void LCAO_gen_fixedH::build_Nonlocal_mu(const bool &calc_deri) } // I1 } // T1 -// cout << " sum from build_Nonlocal_mu = " << sum << endl; if(!GAMMA_ONLY_LOCAL) { diff --git a/ABACUS.develop/source/src_lcao/LCAO_hamilt.cpp b/ABACUS.develop/source/src_lcao/LCAO_hamilt.cpp index 824a0e5d20..aa3d70048c 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_hamilt.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_hamilt.cpp @@ -4,27 +4,28 @@ #include "../src_global/sltk_atom_arrange.h" #include "global_fp.h" // mohan add 2021-01-30 -Use_Hamilt_Matrix::Use_Hamilt_Matrix() +LCAO_Hamilt::LCAO_Hamilt() { init_s = false; } -Use_Hamilt_Matrix::~Use_Hamilt_Matrix() +LCAO_Hamilt::~LCAO_Hamilt() { if(test_deconstructor) { - cout << " ~Use_Hamilt_Matrix()" << endl; + cout << " ~LCAO_Hamilt()" << endl; } } //-------------------------------------------- -// In set_ion, the 'calculate_STNR_gamma' or +// 'calculate_STNR_gamma' or // 'calculate_STNR_k' functions are called //-------------------------------------------- -void Use_Hamilt_Matrix::set_ion(void) +void LCAO_Hamilt::set_lcao_matrices(void) { - TITLE("Use_Hamilt_Matrix","set_ion"); - timer::tick("Use_Hamilt_Matrix","set_ion",'D'); + TITLE("LCAO_Hamilt","set_lcao_matrices"); + timer::tick("LCAO_Hamilt","set_lcao_matrices",'E'); + if(GAMMA_ONLY_LOCAL) { // mohan add 2012-03-29 @@ -50,14 +51,14 @@ void Use_Hamilt_Matrix::set_ion(void) //cout << " init_s=" << init_s << endl; //delete 2015-09-06, xiaohui // OUT(ofs_running,"init_s",init_s); - timer::tick("Use_Hamilt_Matrix","set_ion",'D'); + timer::tick("LCAO_Hamilt","set_lcao_matrices",'E'); return; } -void Use_Hamilt_Matrix::calculate_Hgamma( const int &ik ) // Peize Lin add ik 2016-12-03 +void LCAO_Hamilt::calculate_Hgamma( const int &ik ) // Peize Lin add ik 2016-12-03 { - TITLE("Use_Hamilt_Matrix","calculate_Hgamma"); - timer::tick("Use_Hamilt_Matrix","cal_Hgamma",'F'); + TITLE("LCAO_Hamilt","calculate_Hgamma"); + timer::tick("LCAO_Hamilt","cal_Hgamma",'F'); // Set the matrix 'H' to zero. LM.zeros_HSgamma('H'); // 3 stands for Hloc. @@ -110,20 +111,20 @@ void Use_Hamilt_Matrix::calculate_Hgamma( const int &ik ) // Peize Lin add ik LM.print_HSgamma('S'); // S LM.print_HSgamma('T'); LM.print_HSgamma('H'); - // WARNING_QUIT("Use_Hamilt_Matrix::calculate_Hgamma","print the H,S matrix"); + // WARNING_QUIT("LCAO_Hamilt::calculate_Hgamma","print the H,S matrix"); // QUIT(); } - timer::tick("Use_Hamilt_Matrix","cal_Hgamma",'F'); + timer::tick("LCAO_Hamilt","cal_Hgamma",'F'); return; } -void Use_Hamilt_Matrix::calculate_STNR_gamma(void) +void LCAO_Hamilt::calculate_STNR_gamma(void) { - TITLE("Use_Hamilt_Matrix","calculate_fixed"); + TITLE("LCAO_Hamilt","calculate_fixed"); OUT(ofs_running,"gamma_only_local",GAMMA_ONLY_LOCAL); @@ -181,10 +182,10 @@ void Use_Hamilt_Matrix::calculate_STNR_gamma(void) #include "LCAO_nnr.h" // be called in Local_Orbital_Elec::cal_bands(). -void Use_Hamilt_Matrix::calculate_Hk(const int &ik) +void LCAO_Hamilt::calculate_Hk(const int &ik) { - TITLE("Use_Hamilt_Matrix","calculate_Hk"); - timer::tick("Use_Hamilt_Matrix","calculate_Hk",'F'); + TITLE("LCAO_Hamilt","calculate_Hk"); + timer::tick("LCAO_Hamilt","calculate_Hk",'F'); // whether you want to calculate the local potential // or not, you need to set this matrix to 0. @@ -256,13 +257,13 @@ void Use_Hamilt_Matrix::calculate_Hk(const int &ik) } */ - timer::tick("Use_Hamilt_Matrix","calculate_Hk",'F'); + timer::tick("LCAO_Hamilt","calculate_Hk",'F'); return; } // only need to do the first time. // available for all k points. -void Use_Hamilt_Matrix::calculate_STNR_k(void) +void LCAO_Hamilt::calculate_STNR_k(void) { TITLE("Hamilt_Linear","calculate_STBR_k"); @@ -363,9 +364,9 @@ void Use_Hamilt_Matrix::calculate_STNR_k(void) } -void Use_Hamilt_Matrix::calculate_STN_R(void) +void LCAO_Hamilt::calculate_STN_R(void) { - TITLE("Use_Hamilt_Matrix","calculate_STN_R"); + TITLE("LCAO_Hamilt","calculate_STN_R"); //int iat = 0; int index = 0; diff --git a/ABACUS.develop/source/src_lcao/LCAO_hamilt.h b/ABACUS.develop/source/src_lcao/LCAO_hamilt.h index 9679253313..ca7c694f68 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_hamilt.h +++ b/ABACUS.develop/source/src_lcao/LCAO_hamilt.h @@ -1,18 +1,19 @@ -#ifndef USE_HAMILT_MATRIX_H -#define USE_HAMILT_MATRIX_H +#ifndef LCAO_HAMILT_H +#define LCAO_HAMILT_H #include "../src_pw/tools.h" #include "LCAO_gen_fixedH.h" #include "gint_gamma.h" #include "gint_k.h" -class Use_Hamilt_Matrix +class LCAO_Hamilt { public: - Use_Hamilt_Matrix(); - ~Use_Hamilt_Matrix(); - void set_ion(void); + LCAO_Hamilt(); + ~LCAO_Hamilt(); + + void set_lcao_matrices(void); // used fro k-dependent Hamiltonian matrix. void calculate_Hk( const int &ik); diff --git a/ABACUS.develop/source/src_lcao/LCAO_nnr.cpp b/ABACUS.develop/source/src_lcao/LCAO_nnr.cpp index ea43f86367..e62f0aa77d 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_nnr.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_nnr.cpp @@ -554,7 +554,7 @@ int LCAO_nnr::cal_RindexAtom(const int &u1, const int &u2, const int &u3, const } -// be called in Use_Hamilt_Matrix::calculate_Hk. +// be called in LCAO_Hamilt::calculate_Hk. void LCAO_nnr::folding_fixedH(const int &ik) { TITLE("LCAO_nnr","folding_fixedH"); diff --git a/ABACUS.develop/source/src_lcao/build_st_pw.cpp b/ABACUS.develop/source/src_lcao/build_st_pw.cpp index b30b3fb246..f10ee28974 100644 --- a/ABACUS.develop/source/src_lcao/build_st_pw.cpp +++ b/ABACUS.develop/source/src_lcao/build_st_pw.cpp @@ -13,7 +13,7 @@ Build_ST_pw::~Build_ST_pw() } -// be called in Use_Hamilt_Matrix::calculate_STNR_k() +// be called in LCAO_Hamilt::calculate_STNR_k() // FUNCTION: calculate the overlap and kinetic matrix // in localized basis (expanded in plane wave basis). void Build_ST_pw::set_ST(const int &ik, const char& dtype) diff --git a/ABACUS.develop/source/src_lcao/global_fp.cpp b/ABACUS.develop/source/src_lcao/global_fp.cpp index 30445aa85e..e7ec361e30 100644 --- a/ABACUS.develop/source/src_lcao/global_fp.cpp +++ b/ABACUS.develop/source/src_lcao/global_fp.cpp @@ -6,6 +6,6 @@ Parallel_Orbitals ParaO; Local_Orbital_Charge LOC; Local_Orbital_wfc LOWF; LCAO_Matrix LM; -Use_Hamilt_Matrix UHM; +LCAO_Hamilt UHM; SubGrid_oper SGO; //mohan add 2012-01-12 Exx_Lcao exx_lcao(exx_global.info); // Peize Lin add 2016-12-03 diff --git a/ABACUS.develop/source/src_lcao/global_fp.h b/ABACUS.develop/source/src_lcao/global_fp.h index 4bb7f4cf50..be401c8551 100644 --- a/ABACUS.develop/source/src_lcao/global_fp.h +++ b/ABACUS.develop/source/src_lcao/global_fp.h @@ -19,7 +19,7 @@ extern Parallel_Orbitals ParaO; extern Local_Orbital_wfc LOWF; extern Local_Orbital_Charge LOC; extern LCAO_Matrix LM; -extern Use_Hamilt_Matrix UHM; +extern LCAO_Hamilt UHM; extern SubGrid_oper SGO; //mohan add 2012-01-12 extern Exx_Lcao exx_lcao; // Peize Lin add 2016-12-03 #endif diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp index 7b272c9f5f..302a6e1cca 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp @@ -24,21 +24,24 @@ void Local_Orbital_Elec::solve_elec_stru(const int &istep) { TITLE("Local_Orbital_Elec","solve_elec_stru"); + timer::tick("Local_Orbital_Elec","solve_elec_stru",'C'); // prepare HS matrices, prepare grid integral - this->set_matrix_grid_index(); + this->set_matrix_grid(); // density matrix extrapolation and prepare S,T,VNL matrices this->before_solver(istep); // do self-interaction calculations / nscf/ tddft, etc. this->solver(istep); + timer::tick("Local_Orbital_Elec","solve_elec_stru",'C'); return; } -void Local_Orbital_Elec::set_matrix_grid_index(void) +void Local_Orbital_Elec::set_matrix_grid(void) { - TITLE("Local_Orbital_Elec","set_matrix_grid_index"); + TITLE("Local_Orbital_Elec","set_matrix_grid"); + timer::tick("Local_Orbital_Elec","set_matrix_grid",'D'); // (1) Find adjacent atoms for each atom. atom_arrange::set_sr_NL(); @@ -65,6 +68,7 @@ void Local_Orbital_Elec::set_matrix_grid_index(void) LNNR.cal_nnrg(GridT); } + timer::tick("Local_Orbital_Elec","set_matrix_grid",'D'); return; } @@ -72,6 +76,7 @@ void Local_Orbital_Elec::set_matrix_grid_index(void) void Local_Orbital_Elec::before_solver(const int &istep) { TITLE("Local_Orbital_Elec","before_solver"); + timer::tick("Local_Orbital_Elec","before_solver",'D'); // set the augmented orbitals index. // after ParaO and GridT, @@ -123,15 +128,16 @@ void Local_Orbital_Elec::before_solver(const int &istep) // (9) compute S, T, Vnl, Vna matrix. - UHM.set_ion(); + UHM.set_lcao_matrices(); + timer::tick("Local_Orbital_Elec","before_solver",'D'); return; } void Local_Orbital_Elec::solver(const int &istep) { - TITLE("Local_Orbital_Elec","solver"); + timer::tick("Local_Orbital_Elec","solver",'D'); // Peize Lin add 2014-04-04, update 2019-04-26 if(vdwd2.vdwD2) @@ -219,9 +225,10 @@ void Local_Orbital_Elec::solver(const int &istep) } else { - WARNING_QUIT("Local_Orbital_Ions::opt_ions","What's the CALCULATION."); + WARNING_QUIT("Local_Orbital_Ions::solver","CALCULATION type not supported"); } + timer::tick("Local_Orbital_Elec","solver",'D'); return; } diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.h b/ABACUS.develop/source/src_lcao/local_orbital_elec.h index cc4b662ff3..b349df288a 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.h +++ b/ABACUS.develop/source/src_lcao/local_orbital_elec.h @@ -15,8 +15,8 @@ class Local_Orbital_Elec private: - // set matrix index and grid integral - void set_matrix_grid_index(void); + // set matrix and grid integral + void set_matrix_grid(void); void before_solver(const int &istep); diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index 5aa346fa6c..1d466cae5b 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -23,7 +23,7 @@ Local_Orbital_Ions::~Local_Orbital_Ions() void Local_Orbital_Ions::opt_ions(void) { TITLE("Local_Orbital_Ions","opt_ions"); - timer::tick("Local_Orbital_Ions","opt_ions",'C'); + timer::tick("Local_Orbital_Ions","opt_ions",'B'); if(OUT_LEVEL=="i") { @@ -311,7 +311,7 @@ void Local_Orbital_Ions::opt_ions(void) // mohan update 2021-02-10 hm.orb_con.clear_after_ions(); - timer::tick("Local_Orbital_Ions","opt_ions",'C'); + timer::tick("Local_Orbital_Ions","opt_ions",'B'); return; } @@ -586,13 +586,13 @@ void Local_Orbital_Ions::final_scf(void) LOC.allocate_DM_k(); } - UHM.set_ion(); + UHM.set_lcao_matrices(); if(vdwd2.vdwD2) //Peize Lin add 2014-04-04, update 2019-04-26 { vdwd2.energy(); } - if(vdwd3.vdwD3) //jiyy add 2019-05-18 + else if(vdwd3.vdwD3) //jiyy add 2019-05-18 { vdwd3.energy(); } From b066f81fbd677357252a3386c3c216da4e2f83f6 Mon Sep 17 00:00:00 2001 From: mohan Date: Sat, 27 Feb 2021 09:34:45 +0800 Subject: [PATCH 157/233] update potential, the 'restart' modula needs reconstruction in near future --- ABACUS.develop/source/src_pw/potential.cpp | 72 ++++++---------------- ABACUS.develop/source/src_pw/potential.h | 1 + 2 files changed, 19 insertions(+), 54 deletions(-) diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index 23297c82d5..f474a351a8 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -57,16 +57,15 @@ void potential::init_pot(const int &istep) assert(istep>=0); - //ofs_running << " istep=" << istep << " delta_vh=" << delta_vh << " vna=" << vna << endl; - vrs.zero_out(); // mohan fix bug 2011-07-08 // the vltot should and must be zero here. ZEROS(this->vltot, pw.nrxx); - // (1) local part of pseudopotentials. - // set vltot + //------------------------------------------------------------------- + // put the local pseudopotential + electric field (if any) in vltot + //------------------------------------------------------------------- this->set_local(this->vltot); // mohan fix bug 2011-07-07 @@ -75,6 +74,10 @@ void potential::init_pot(const int &istep) if(NSPIN==4) nspin0=1; + //------------------------------------------------------------------- + // put the local pseudopotential + electric field (if any) in vltot + // vrs saves the total potential. + //------------------------------------------------------------------- for(int is=0; is0 && NSPIN==4) { + // read only spin (up+down) if(PRENSPIN == 1) - {//read only up+down , others set to zero. + { ofs_running << " Didn't read in the charge density but autoset it for spin " <v_of_rho(CHR.rho, vr); @@ -291,8 +299,8 @@ void potential::v_of_rho //========================================================== -// set the total local potential vrs on the smooth mesh to -// be used in h_psi, adding the (spin dependent) scf (H+xc) +// set the total local potential vrs on the real space grid +// used in h_psi, adding the (spin dependent) scf (H+xc) // part and the sum of all the local pseudopotential // contributions. //========================================================== @@ -318,52 +326,8 @@ void potential::set_vrs(void) for (int i = 0;i < pw.nrxx;i++) { this->vrs(is, i) = this->vltot[i] + this->vr(is, i); - // cout <<"i: "<< i <<" "<< "vrs: " << vrs(is,i) <= 0) - { - for (int i = 0;i < pw.nrxx;i++) - { - this->vrs(is, i) = this->vltot[i] + this->vr(is, i); - } - } - else - { - this->vext = new double[pw.nrxx]; - const int yz = pw.ncy*pw.nczp; - int index, i, j, k; - - for(int ir=0; irvext[ir] = -0.4*k/pw.ncx+0.05; - //else if (k>=pw.ncx*0.1 && kvext[ir] = 0.1*k/pw.ncx; - //else if (k>=pw.ncx*0.9) this->vext[ir] = -0.4*(1.0*k/pw.ncx-1)+0.05; - - if (kvext[ir] = (0.019447*k/pw.ncx-0.001069585)*ucell.lat0; - else if (k>=pw.ncx*0.05 && kvext[ir] = -0.0019447*k/pw.ncx*ucell.lat0; - else if (k>=pw.ncx*0.95) this->vext[ir] = (0.019447*(1.0*k/pw.ncx-1)-0.001069585)*ucell.lat0; - - this->vrs(is,ir) = this->vltot[ir] + this->vr(is, ir) + this->vext[ir]; - - //cout << "x: " << k <<" " << "y: " << j <<" "<< "z: "<< i <<" "<< "ir: " << ir << endl; - //cout << "vext: " << this->vext[ir] << endl; - //cout << "vrs: " << vrs(is,ir) < Date: Sat, 27 Feb 2021 19:16:38 +0800 Subject: [PATCH 158/233] initially compelete stochasticDFT module part --- ABACUS.develop/source/input.cpp | 8 + ABACUS.develop/source/run_pw.cpp | 19 +- .../source/src_global/global_function.h | 2 +- ABACUS.develop/source/src_pw/energy.cpp | 6 +- ABACUS.develop/source/src_pw/sto_che.cpp | 35 +- ABACUS.develop/source/src_pw/sto_che.h | 16 +- ABACUS.develop/source/src_pw/sto_elec.cpp | 73 +-- ABACUS.develop/source/src_pw/sto_elec.h | 3 +- ABACUS.develop/source/src_pw/sto_hchi.cpp | 210 +++++--- ABACUS.develop/source/src_pw/sto_hchi.h | 13 +- ABACUS.develop/source/src_pw/sto_iter.cpp | 462 ++++++++++++++---- ABACUS.develop/source/src_pw/sto_iter.h | 10 +- ABACUS.develop/source/src_pw/sto_wf.cpp | 24 +- ABACUS.develop/source/src_pw/sto_wf.h | 5 +- .../source/src_pw/threshold_elec.cpp | 2 +- .../source/src_pw/unitcell_pseudo.cpp | 70 +-- 16 files changed, 690 insertions(+), 268 deletions(-) diff --git a/ABACUS.develop/source/input.cpp b/ABACUS.develop/source/input.cpp index e5f96b7e9a..18456fd77e 100644 --- a/ABACUS.develop/source/input.cpp +++ b/ABACUS.develop/source/input.cpp @@ -2281,6 +2281,14 @@ void Input::Check(void) */ nstep = 1; + } + else if (calculation == "scf-sto") // qianrui 2021-2-20 + { + if(mem_saver == 1) + { + mem_saver = 0; + AUTO_SET("mem_savre","0"); + } } else if (calculation == "relax") // pengfei 2014-10-13 { diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp index 8b3a4b8883..ba32fad8fa 100644 --- a/ABACUS.develop/source/run_pw.cpp +++ b/ABACUS.develop/source/run_pw.cpp @@ -34,8 +34,16 @@ void Run_pw::plane_wave_line(void) //===================== // init wave functions //===================== - wf.init(kv.nks); - UFFT.allocate(); + if ( NBANDS != 0 || (CALCULATION!="scf-sto" && CALCULATION!="relax-sto" && CALCULATION!="md-sto") )//qianrui add + { + wf.init(kv.nks); + } + else + { + wf.npwx = wf.setupIndGk(pw, kv.nks); + } + UFFT.allocate(); + //======================= // init pseudopotential @@ -76,7 +84,12 @@ void Run_pw::plane_wave_line(void) //================================ // Initial start wave functions //================================ - wf.wfcinit(); + if ( NBANDS != 0 || (CALCULATION!="scf-sto" && CALCULATION!="relax-sto" && CALCULATION!="md-sto") )//qianrui add + { + wf.wfcinit(); + } + + DONE(ofs_running,"INIT BASIS"); diff --git a/ABACUS.develop/source/src_global/global_function.h b/ABACUS.develop/source/src_global/global_function.h index 00a2b30004..353963e154 100644 --- a/ABACUS.develop/source/src_global/global_function.h +++ b/ABACUS.develop/source/src_global/global_function.h @@ -183,7 +183,7 @@ void SCAN_END(ifstream &ifs, const string &TargetName); template static inline void DCOPY( const T &a, T &b, const int &dim) { - for (int i=0; ietot += dftu.EU; -/* - cout << resetiosflags(ios::scientific) << endl; + + /*cout << resetiosflags(ios::scientific) << endl; cout << setprecision(6) << endl; cout << " eband=" << eband << endl; cout << " deband=" << deband << endl; @@ -108,7 +108,7 @@ void energy::calculate_etot(void) cout << " demet=" << demet << endl; cout << " descf=" << descf << endl; cout << " efiled=" << Efield::etotefield << endl; - */ + cout << " fermienergy= "< [1]; coef = new double [1]; polyvalue = new complex [1]; @@ -27,17 +28,17 @@ Stochastic_Chebychev::~Stochastic_Chebychev() void Stochastic_Chebychev:: init() { norder = STO_WF.nche_sto; - assert(norder > 10); + assert(norder > 5); + assert(extend >= 1); if(norder != 0) { - norder2 = 2 * norder; + norder2 = 2 * norder * extend; delete[] coef; delete[] ccoef; delete[] polyvalue; ccoef = new complex [norder2]; - coef = new double [norder]; + coef = new double [norder2]; polyvalue = new complex [norder]; - ZEROS(polyvalue, norder); initcoef = true; } else @@ -52,23 +53,24 @@ void Stochastic_Chebychev:: calcoef(double fun(double)) if(!initcoef) WARNING_QUIT("Stochastic_Chebychev", "Please init coef first!"); for(int i = 0; i < norder2; ++i) { - ccoef[i]=complex(fun(cos((i+0.5)*PI/norder))); + coef[i]=fun(cos((i+0.5)*TWO_PI/norder2)); } if(!initplan) { initplan = true; - plancoef = fftw_plan_dft_1d(norder2, (fftw_complex *) ccoef, (fftw_complex *) ccoef, FFTW_FORWARD, FFTW_MEASURE); + plancoef = fftw_plan_dft_r2c_1d(norder2, coef, (fftw_complex *) ccoef, FFTW_MEASURE); } fftw_execute(plancoef); + complex ui(0,1); for(int i = 0; i *in, complex *out), int& ndim, complex *wavein) { - if(!getcoef) WARNING_QUIT("Stochastic_Chebychev", "Please calculate coef first!"); complex *arraynp1, *arrayn, *arrayn_1; arraynp1 = new complex [ndim]; arrayn = new complex [ndim]; arrayn_1 = new complex [ndim]; - for(int i = 0; i < ndim; ++i) - { - arrayn_1[i] = wavein[i]; - } + DCOPY(wavein, arrayn_1, ndim); tfun(arrayn_1, arrayn); + ZEROS(polyvalue,norder); //0- & 1-st order - polyvalue[0] = ndim; // 0-th order : = ndim - for(int i = 0; i < ndim; ++i) // 1-st order : + for(int i = 0; i < ndim; ++i) { - polyvalue[1] += conj(wavein[i]) * arrayn_1[i]; + polyvalue[0] += conj(wavein[i]) * wavein[i];// 0-th order : = ndim + polyvalue[1] += conj(wavein[i]) * arrayn[i];// 1-st order : } //more than 1-st orders @@ -140,6 +140,7 @@ void Stochastic_Chebychev:: calpolyval(void tfun(complex *in, complex* tem = arrayn_1; arrayn_1 = arrayn; arrayn = arraynp1; diff --git a/ABACUS.develop/source/src_pw/sto_che.h b/ABACUS.develop/source/src_pw/sto_che.h index 53c6200dea..951967ebaa 100644 --- a/ABACUS.develop/source/src_pw/sto_che.h +++ b/ABACUS.develop/source/src_pw/sto_che.h @@ -25,12 +25,14 @@ class Stochastic_Chebychev void calresult(void fun(T *in, T *out), int& ndim, T *wavein, T *waveout); + void calpolyval(void fun(complex *in, complex *out), int& ndim, complex *wavein); int norder; + int extend; int norder2; // 2 * norder - double* coef; //[norder] expansion coefficient of each order, - complex *ccoef; //[norder2] temporary complex expansion coefficient of each order, only first norder coefficient are usefull. + double* coef; //[norder2] expansion coefficient of each order, only first norder coefficients are usefull + complex *ccoef; //[norder2] temporary complex expansion coefficient of each order, only first norder coefficients are usefull. complex *polyvalue; // fftw_plan plancoef; bool initplan, initcoef, getcoef, getpolyval; @@ -62,19 +64,19 @@ void Stochastic_Chebychev:: calresult(void tfun(T *in, T *out), int &ndim, T *wa arraynp1 = new T [ndim]; arrayn = new T [ndim]; arrayn_1 = new T [ndim]; - for(int i = 0; i < ndim; ++i) - { - arrayn_1[i] = wavein[i]; - } + DCOPY(wavein, arrayn_1, ndim); tfun(arrayn_1, arrayn); + //0- & 1-st order for(int i = 0; i < ndim; ++i) { waveout[i] = coef[0] * arrayn_1[i] + coef[1] * arrayn[i]; } + + //more than 1-st orders - for(int ior = 2; ior <= norder; ++ior) + for(int ior = 2; ior < norder; ++ior) { recurs(arraynp1, arrayn, arrayn_1, tfun, ndim); for(int i = 0; i < ndim; ++i) diff --git a/ABACUS.develop/source/src_pw/sto_elec.cpp b/ABACUS.develop/source/src_pw/sto_elec.cpp index a1b7a55f54..28cf73e294 100644 --- a/ABACUS.develop/source/src_pw/sto_elec.cpp +++ b/ABACUS.develop/source/src_pw/sto_elec.cpp @@ -19,7 +19,7 @@ Stochastic_Elec::~Stochastic_Elec() void Stochastic_Elec::scf_stochastic(const int &istep) { timer::tick("Elec_Stochastic","scf_stochastic",'D'); - en.ewld = en.ewald(); + en.ewld = en.ewald(); set_ethr(); @@ -56,8 +56,9 @@ void Stochastic_Elec::scf_stochastic(const int &istep) clock_t start,finish; double duration = 0.0; - - for (this->iter = 1;iter <= NITER;iter++) + //for (this->iter = 1;iter <= NITER;iter++) + STO_WF.init(); + for (this->iter = 1;iter <= 20;iter++) { ofs_running << "\n PW-STOCHASTIC ALGO --------- ION=" << setw(4) << istep + 1 @@ -72,7 +73,7 @@ void Stochastic_Elec::scf_stochastic(const int &istep) { CHR.new_e_iteration = false; } - + // record the start time. start=std::clock(); @@ -81,7 +82,8 @@ void Stochastic_Elec::scf_stochastic(const int &istep) //this->update_ethr(iter); if(FINAL_SCF && iter==1) { - ETHR = 1.0e-2; + ETHR = 1.0e-12; // only for test + //ETHR = 1.0e-2; } else { @@ -103,8 +105,12 @@ void Stochastic_Elec::scf_stochastic(const int &istep) //(2) calculate band energy using cg or davidson method. // output the new eigenvalues and wave functions. - this->c_bands(istep); + if(NBANDS > 0) + { + this->c_bands(istep+1); + } + if (check_stop_now()) return; en.eband = 0.0; @@ -112,19 +118,37 @@ void Stochastic_Elec::scf_stochastic(const int &istep) en.ef = 0.0; en.ef_up = 0.0; en.ef_dw = 0.0; - - //(3) calculate weights of each band. - Occupy::calculate_weights(); - //(4) save change density as previous charge, + //(3) save change density as previous charge, // prepared fox mixing. CHR.save_rho_before_sum_band(); - //(5) calculate new charge density according to - // new wave functions. + //(4) calculate fermi energy. + stoiter.init(); + stoiter.test(); + stoiter.itermu(); - // calculate the new eband here. - CHR.sum_band(); + + //(5) calculate new charge density + // calculate KS rho. + if(NBANDS > 0) + { + CHR.sum_band(); + } + else + { + for(int is=0; is= 0 ) CHR.rho = CHR.rho_save; //ofs_running << "\n start next iterate for idum "; + } - + timer::tick("Elec_Stochastic","scf_stochastic",'D'); return; } // end electrons diff --git a/ABACUS.develop/source/src_pw/sto_elec.h b/ABACUS.develop/source/src_pw/sto_elec.h index 4f09f53876..eb15a7e46b 100644 --- a/ABACUS.develop/source/src_pw/sto_elec.h +++ b/ABACUS.develop/source/src_pw/sto_elec.h @@ -4,6 +4,7 @@ #include "tools.h" #include "threshold_elec.h" #include "sto_wf.h" +#include "sto_iter.h" //---------------------------------------------- // methods based on stochastic wave functions @@ -25,7 +26,7 @@ class Stochastic_Elec: private Threshold_Elec void scf_stochastic(const int &istep); private: - Stochastic_WF swf; + Stochastic_Iter stoiter; void c_bands(const int &istep); diff --git a/ABACUS.develop/source/src_pw/sto_hchi.cpp b/ABACUS.develop/source/src_pw/sto_hchi.cpp index 3bd73da7eb..f3ee168e98 100644 --- a/ABACUS.develop/source/src_pw/sto_hchi.cpp +++ b/ABACUS.develop/source/src_pw/sto_hchi.cpp @@ -4,10 +4,11 @@ int Stochastic_hchi:: nrxx; int Stochastic_hchi:: nx,Stochastic_hchi::ny,Stochastic_hchi::nz; -fftw_plan Stochastic_hchi:: pf, Stochastic_hchi::pb; +fftw_plan Stochastic_hchi:: pb, Stochastic_hchi::pf; double Stochastic_hchi:: Emin, Stochastic_hchi:: Emax; bool Stochastic_hchi:: initplan, Stochastic_hchi::ortho; -complex* Stochastic_hchi:: rp_chi, * Stochastic_hchi::tmpchi2, * Stochastic_hchi::chig; +complex* Stochastic_hchi:: rp_chi, * Stochastic_hchi::rl_chi; +int * Stochastic_hchi:: GRA_index; Stochastic_hchi::Stochastic_hchi() @@ -16,19 +17,19 @@ Stochastic_hchi::Stochastic_hchi() ortho = false; nrxx = 0; rp_chi = new complex [1]; - tmpchi2 = new complex [1]; - chig = new complex [1]; + rl_chi = new complex [1]; + GRA_index = new int [1]; } Stochastic_hchi::~Stochastic_hchi() { if(initplan) { - fftw_destroy_plan(pf); fftw_destroy_plan(pb); + fftw_destroy_plan(pf); } delete[] rp_chi; - delete[] tmpchi2; + delete[] rl_chi; } void Stochastic_hchi:: init() @@ -36,14 +37,20 @@ void Stochastic_hchi:: init() //wait for init-------------------------------------- //nrxx //--------------------------------------------------- + nrxx = pw.nrxx; + nx = pw.nx; + ny = pw.ny; + nz = pw.nz; if(nrxx != 0) { delete[] rp_chi; - delete[] tmpchi2; + delete[] rl_chi; + delete[] GRA_index; rp_chi = new complex [nrxx]; - tmpchi2 = new complex [nrxx]; - pb=fftw_plan_dft_3d(nx,ny,nz,(fftw_complex *)rp_chi,(fftw_complex *)rp_chi, FFTW_BACKWARD, FFTW_MEASURE); - pf=fftw_plan_dft_3d(nx,ny,nz,(fftw_complex *)tmpchi2,(fftw_complex *)tmpchi2, FFTW_FORWARD, FFTW_MEASURE); + rl_chi = new complex [nrxx]; + GRA_index = new int [wf.npw]; + pf=fftw_plan_dft_3d(nx,ny,nz,(fftw_complex *)rp_chi,(fftw_complex *)rp_chi, FFTW_FORWARD, FFTW_MEASURE); + pb=fftw_plan_dft_3d(nx,ny,nz,(fftw_complex *)rl_chi,(fftw_complex *)rl_chi, FFTW_BACKWARD, FFTW_MEASURE); initplan = true; } else @@ -53,85 +60,154 @@ void Stochastic_hchi:: init() } -void Stochastic_hchi::orthogonal_to_psi(complex *wfin, complex *wfgortho) +void Stochastic_hchi::get_GRA_index() +{ + int ix,iy,iz; + int ir; + ZEROS(GRA_index,wf.npw); + for(int ig = 0 ; ig < wf.npw; ++ig) + { + ix = floor(pw.gcar[wf.igk(0, ig)].x+0.1); + iy = floor(pw.gcar[wf.igk(0, ig)].y+0.1); + iz = floor(pw.gcar[wf.igk(0, ig)].z+0.1); + if(ix < 0) ix += nx; + if(iy < 0) iy += ny; + if(iz < 0) iz += nz; + ir = ix * ny * nz + iy * nz + iz; + GRA_index[ig] = ir; + } +} + +void Stochastic_hchi::orthogonal_to_psi_real(complex *wfin, complex *wfout, int &ikk) { - //wait for init - int * GR_INDEX; - double * v; TITLE("Stochastic_hchi","orthogonal_to_psi0"); if(!initplan) WARNING_QUIT("Stochastic_hchi", "Please init hchi first!"); - for( int ir = 0; ir < nrxx; ++ir) - { - rp_chi[ir] = wfin[ir]; - } - ZEROS(wfgortho,nrxx); - fftw_execute(pb); + DCOPY(wfin,rp_chi,nrxx); + fftw_execute(pf); - delete []chig; - chig = new complex [wf.npw]; + complex * chig = new complex [wf.npw]; for(int ig = 0; ig < wf.npw; ++ig) { - chig[ig] = rp_chi[GR_INDEX[ig]]; + chig[ig] = rp_chi[GRA_index[ig]]; } //orthogonal part complex sum; for(int iksb = 0; iksb < NBANDS; ++iksb) { - complex *kswf; // kswf is normalized + complex *kswf = &wf.evc[ikk](iksb,0); sum=0; - for(int ig = 0; ig < pw.ngmw; ++ig) + for(int ig = 0; ig < wf.npw; ++ig) { sum += conj(kswf[ig]) * chig[ig]; } - for(int ig = 0; ig < pw.ngmw; ++ig) + for(int ig = 0; ig < wf.npw; ++ig) { chig[ig] -= sum*kswf[ig]; } } + //test orthogonal in reciprocal space + //complex overlap; + //for(int iksb = 0; iksb < NBANDS; ++iksb) + //{ + // complex *kswf = &wf.evc[ikk](iksb,0); + // overlap=0; + // for(int ig = 0; ig < wf.npw; ++ig) + // { + // overlap += conj(kswf[ig]) * chig[ig]; + // } + // cout<<"OVERLAP "< overlap; + complex * kswf = new complex [nrxx]; + fftw_plan pp=fftw_plan_dft_3d(pw.nx,pw.ny,pw.nz,(fftw_complex *)kswf,(fftw_complex *)kswf, FFTW_BACKWARD, FFTW_ESTIMATE); + for(int iksb = 0; iksb < NBANDS; ++iksb) + { + ZEROS(kswf,nrxx); + for(int ig = 0 ; ig < wf.npw; ++ig) + { + kswf[GRA_index[ig]] = wf.evc[ikk](iksb,ig); + } + fftw_execute(pp); + overlap=0; + for(int ir = 0; ir < nrxx; ++ir) + { + overlap += conj(kswf[ir]) * wfout[ir]; + } + cout<<"OVERLAP "<*wfgortho, complex *wfout) +void Stochastic_hchi:: hchi_real(complex*chi_in, complex *hchi) { - //wait for init-------------------------------------- - double dk1=1,dk2=1,dk3=1; double*vr;//vr= pot.vrs1 temporarily use cutoff vr. - int * GR_INDEX; + + double*vr = pot.vrs1; //vr= pot.vrs1 temporarily use cutoff vr. + + //wait for init-------------------------------------- + double dk1,dk2,dk3; + dk1 = ucell.tpiba; + dk2 = ucell.tpiba; + dk3 = ucell.tpiba; //--------------------------------------------------- - if(!initplan||!ortho) WARNING_QUIT("Stochastic_hchi", "Please init hchi first!"); + if(!initplan) WARNING_QUIT("Stochastic_hchi", "Please init hchi first!"); + + ZEROS(hchi,nrxx); + DCOPY(chi_in, rp_chi, nrxx); + fftw_execute(pf); + + complex * chig = new complex [wf.npw]; + ZEROS(chig,wf.npw); + for(int ig = 0; ig < wf.npw; ++ig) + { + chig[ig] = rp_chi[GRA_index[ig]]; + } - //------------------------------------ //(1) the local potential. //------------------------------------ + if(VL_IN_H) { for(int ir = 0; ir < nrxx; ++ir) { - tmpchi2[ir] = wfgortho[ir]; + hchi[ir] += chi_in[ir] * vr[ir] ; } - fftw_execute(pf); - for(int ir = 0; ir < nrxx; ++ir) + + } + /*cout<<"HCHI-------------------------"<*wfgortho, complex *wfout) if(ig1 > nx/2) gx -= nx; if(ig2 > ny/2) gy -= ny; if(ig3 > nz/2) gz -= nz; - gg.set((gx-double(nx-1)/2)*dk1, (gy-double(ny-1)/2)*dk2, (gz-double(nz-1)/2)*dk3); - tmpchi2[i] = -gg.norm2()*wfgortho[i]; + gg.set(gx*dk1, gy*dk2, gz*dk3); + rl_chi[i] = gg.norm2()*rp_chi[i]; ++i; } } @@ -163,6 +239,7 @@ void Stochastic_hchi:: hchi(complex*wfgortho, complex *wfout) } + //------------------------------------ // (3) the nonlocal pseudopotential. @@ -173,11 +250,10 @@ void Stochastic_hchi:: hchi(complex*wfgortho, complex *wfout) { complex *becp = new complex[ ppcell.nkb * NPOL ]; ZEROS(becp,ppcell.nkb * NPOL); - + for (int i=0;i< ppcell.nkb;++i) { const complex* p = &ppcell.vkb(i,0); - const complex* const p_end = p + wf.npw; for (int ig=0; ig< wf.npw; ++ig) { if(NSPIN!=4) becp[i] += chig[ig] * conj( p[ig] ); @@ -189,7 +265,7 @@ void Stochastic_hchi:: hchi(complex*wfgortho, complex *wfout) } //Parallel_Reduce::reduce_complex_double_pool( becp, ppcell.nkb * NPOL); - complex * Ps; + complex * Ps = new complex [ppcell.nkb * NPOL]; ZEROS( Ps, ppcell.nkb * NPOL ); int sum = 0; int iat = 0; @@ -225,34 +301,56 @@ void Stochastic_hchi:: hchi(complex*wfgortho, complex *wfout) complex* p = &ppcell.vkb(i,0); for(int ig=0; ig< wf.npw; ++ig) { - chig[ig] = Ps[i] * p[ig]; + chig[ig] += Ps[i] * p[ig]; } } delete[] becp; + delete[] Ps; + } + for(int ig = 0; ig < wf.npw; ++ig) + { + rl_chi[GRA_index[ig]] += chig[ig]; } } - + //------------------------------------ // (4) Conver (2) & (3) in Reciprocal space to Real one //------------------------------------ - for(int ig = 0; ig < wf.npw; ++ig) + fftw_execute(pb); + for(int i = 0; i < nrxx; ++i) { - tmpchi2[GR_INDEX[ig]] += chig[ig]; + hchi[i] += rl_chi[i] / nrxx; } - fftw_execute(pf); - for(int i = 0; i sum=0; + //for(int i = 0 ; i < nrxx; ++i) + //{ + // sum+=conj(chi_in[i]) * hchi[i]; + //} + //cout< *rp_chi,*tmpchi2; - static complex *chig; - static void orthogonal_to_psi(complex* wfin, complex *wfgortho); - static void hchi(complex *chigortho, complex *wfout); + static complex *rp_chi,*rl_chi; + + static int * GRA_index; + static void get_GRA_index(); + + static void orthogonal_to_psi_real(complex* wfin, complex *wfout, int& ikk); //wfin & wfout are wavefunctions in real space + static void hchi_real(complex *wfin, complex *wfout); //wfin & wfout are wavefunctions in real space + static void orthogonal_to_psi_reciprocal(complex* wfin, complex *wfout, int& ikk); //wfin & wfout are wavefunctions in reciprocal space + static void hchi_reciprocal(complex *wfin, complex *wfout); //wfin & wfout are wavefunctions in reciprocal space private: diff --git a/ABACUS.develop/source/src_pw/sto_iter.cpp b/ABACUS.develop/source/src_pw/sto_iter.cpp index 21a82ac606..7c6a969328 100644 --- a/ABACUS.develop/source/src_pw/sto_iter.cpp +++ b/ABACUS.develop/source/src_pw/sto_iter.cpp @@ -1,14 +1,16 @@ +#include "tools.h" #include "global.h" #include "sto_iter.h" #include "occupy.h" double Stochastic_Iter:: mu; +double Stochastic_Iter:: mu0; double Stochastic_Iter:: Emin; double Stochastic_Iter:: Emax; Stochastic_Iter::Stochastic_Iter() { - mu = 0; + mu0 = 0; spolyv = new double [1]; } @@ -19,190 +21,462 @@ void Stochastic_Iter:: init() { nchip = STO_WF.nchip; //wait for init - targetne = 0; + targetne = ucell.nelec; stoche.init(); stohchi.init(); delete [] spolyv; int norder = stoche.norder; spolyv = new double [norder]; - ZEROS(spolyv,norder); } void Stochastic_Iter:: itermu() { - //orthogonal part + stohchi.get_GRA_index(); + int nkk=1;// We temporarily use gamma k point. - for(int ik = 0; ik < nkk; ++ik) + //orthogonal part + if(NBANDS > 0) { - for(int ichi = 0; ichi < nchip; ++ichi) + for(int ik = 0; ik < nkk; ++ik) { - complex * p0 = &STO_WF.chi0[ik](ichi,0); - complex * pg = &STO_WF.chig[ik](ichi,0); - stohchi.orthogonal_to_psi(p0,pg); + for(int ichi = 0; ichi < nchip; ++ichi) + { + complex * p0 = &STO_WF.chi0[ik](ichi,0); + complex * pchi = &STO_WF.chiortho[ik](ichi,0); + stohchi.orthogonal_to_psi_real(p0,pchi,ik); + } } } + //if(NBANDS > 0) + //{ + // Emin = wf.ekb[0][0];} + //Emax = pw.ecutwfc * 20-250; + Emax = 750; + Emin = -10; + Stochastic_hchi:: Emin = this->Emin; + Stochastic_hchi:: Emax = this->Emax; + sumpolyval(); - double dnedmu = caldnedmu(); + mu = mu0 - 2; double ne1 = calne(); double mu1 = mu; - double mu2 = (targetne - ne1) / dnedmu; - double Dne=abs(targetne - ne1); - double ne2; + mu = mu0 + 2; + double ne2 = calne(); + double mu2 = mu; + th_ne = 1e-6; + double Dne = th_ne + 1; + double ne3; double mu3; - while(Dne > th_ne) + + mu = 0; + ne1 = calne(); + //test the domin of mu + /*for(mu = -5; mu<5;mu+=0.2) + { + ne1 = calne(); + cout<<"mu: "< targetne) { + mu1 -= 2; + mu = mu1; + ne1 = calne(); + cout<<"Reset mu1 from "< th_ne) + { + mu3 = (mu2 + mu1) / 2; + mu = mu3; + ne3 = calne(); + if(ne3 < targetne) + { + ne1 = ne3; + mu1 = mu3; + } + else if(ne3 > targetne) + { + ne2 = ne3; + mu2 = mu3; + } + Dne = abs(targetne - ne3); + //cout< 100) + { + cout<<"Fermi energy cannot be converged."< 0) + { + for(int ikk = 0; ikk < nkk; ++ikk) + { + double *en=wf.ekb[ikk]; + for(int iksb = 0; iksb < NBANDS; ++iksb) + { + wf.wg(ikk,iksb) = fd(en[iksb])*kv.wk[ikk]; + } + } + } } void Stochastic_Iter:: sumpolyval() { int norder = stoche.norder; //wait for init - int nkk; + int nkk=1; + int nrxx = stohchi.nrxx; - + ZEROS(spolyv, norder); + + complex * pchi; for(int ik = 0; ik < nkk; ++ik) { for(int ichi = 0; ichi < nchip; ++ichi) { - complex * pg = &STO_WF.chig[ik](ichi,0); - stoche.calpolyval(stohchi.hchi, nrxx, pg); + if(NBANDS > 0) + { + pchi = &STO_WF.chiortho[ik](ichi,0); + } + else + { + pchi = &STO_WF.chi0[ik](ichi,0); + } + stoche.calpolyval(stohchi.hchi_real, nrxx, pchi); for(int ior = 0; ior < norder; ++ior) { spolyv[ior] += stoche.polyvalue[ior].real(); } } } + return; } -double Stochastic_Iter:: caldnedmu() -{ - stoche.calcoef(this->dfddmu); - int norder = stoche.norder; - double dnedmu = 0; - for(int ior = 0; ior < norder; ++ior) - { - dnedmu += stoche.coef[ior] * spolyv[ior]; - } - - //wait for init - double *en; - - //number of electrons in KS orbitals - for(int iksb = 0; iksb < NBANDS; ++iksb) - { - dnedmu += fd(en[iksb]); - } - - dnedmu *= 2; - return dnedmu; -} double Stochastic_Iter::calne() { + //wait for init + int nkk = 1; + stoche.calcoef(this->nfd); - double ne = 0; int norder = stoche.norder; - for(int ior = 0; ior < norder; ++ior) + double totne = 0; + KS_ne = 0; + for(int ikk = 0; ikk < nkk; ++ikk) { - ne += stoche.coef[ior] * spolyv[ior]; + for(int ior = 0; ior < norder; ++ior) + { + totne += stoche.coef[ior] * spolyv[ior] * kv.wk[ikk]; + } + //cout< 0) + { + double *en=wf.ekb[ikk]; + //number of electrons in KS orbitals + for(int iksb = 0; iksb < NBANDS; ++iksb) + { + KS_ne += fd(en[iksb]) * kv.wk[ikk]; + } + } + } + totne += KS_ne; - - //wait for init - double *en; - - //number of electrons in KS orbitals - for(int iksb = 0; iksb < NBANDS; ++iksb) - { - ne += fd(en[iksb]); - } - - ne *= 2; - return ne; + return totne; } -void Stochastic_Iter::calrho( double * rho) +void Stochastic_Iter::sum_stoband() { + //stoche.calcoef(this->nfd); stoche.calcoef(this->nroot_fd); + int nkk=1;// We temporarily use gamma k point. int nrxx = stohchi.nrxx; - double ne = 0; + complex * out = new complex [nrxx]; + complex * hout = new complex [nrxx]; + + double dr3 = nrxx / ucell.omega; + double Ebar = (Emin + Emax)/2; + double DeltaE = (Emax - Emin)/2; + + double out2, tmpne; + double sto_ne; + double sto_ekband=0; + cout<<"Eband 1 "< * pchi; for(int ik = 0; ik < nkk; ++ik) { + sto_ekband =0; + double *rho = CHR.rho[ik]; + tmpne = 0; for(int ichi = 0; ichi < nchip; ++ichi) { - complex * pg = &STO_WF.chig[ik](ichi,0); - stoche.calresult(Stochastic_hchi::hchi, nrxx, pg, out); + if(NBANDS > 0) + { + pchi = &STO_WF.chiortho[ik](ichi,0); + } + else + { + pchi = &STO_WF.chi0[ik](ichi,0); + } + stoche.calresult(stohchi.hchi_real, nrxx, pchi, out); + stohchi.hchi_real(out,hout); for(int ir = 0; ir < nrxx; ++ir) { - rho[ir] += norm(out[ir]); + out2 = norm(out[ir]); + tmpne = out2 * kv.wk[ik]; + sto_ekband += real(conj(out[ir]) * hout[ir]) * DeltaE + Ebar * out2; + rho[ir] += tmpne * dr3; + sto_ne += tmpne; + //rho[ir] += real(conj(pchi[ir]) * out[ir]) * kv.wk[ik] * nrxx / ucell.omega; } } + en.eband += sto_ekband * kv.wk[ik]; } - - //wait for init - double *rhoks; - - //number of electrons in KS orbitals - for(int ir = 0 ; ir < nrxx; ++ir) + cout<<"Eband 2 "< 200) + return 0; + else + return 1 / sqrt(1 + exp(e_mu)); } double Stochastic_Iter:: nroot_fd(double e) { double Ebar = (Emin + Emax)/2; double DeltaE = (Emax - Emin)/2; - return sqrt(1 / (1 + exp((e * DeltaE + Ebar - mu) / (Occupy::gaussian_parameter * Ry_to_eV)))); + double ne_mu = (e * DeltaE + Ebar - mu) / Occupy::gaussian_parameter ; + if(ne_mu > 200) + return 0; + else + return 1 / sqrt(1 + exp(ne_mu)); } double Stochastic_Iter:: fd(double e) { - return 1 / (1 + exp((e - mu) / (Occupy::gaussian_parameter * Ry_to_eV))); + double e_mu = (e - mu) / Occupy::gaussian_parameter ; + if(e_mu > 100) + return 0; + else + return 1 / (1 + exp(e_mu)); } double Stochastic_Iter:: nfd(double e) { double Ebar = (Emin + Emax)/2; double DeltaE = (Emax - Emin)/2; - return 1 / (1 + exp((e * DeltaE + Ebar - mu) / (Occupy::gaussian_parameter * Ry_to_eV))); + double ne_mu = (e * DeltaE + Ebar - mu) / Occupy::gaussian_parameter ; + if(ne_mu > 100) + return 0; + else + return 1 / (1 + exp(ne_mu)); } + void Stochastic_Iter:: test() + { + //=====================test============================ + /* + complex *in = new complex [pw.nrxx]; + + complex *chig1 = new complex [wf.npw]; + complex *chig2 = new complex [wf.npw]; + ZEROS(in,pw.nrxx); + ZEROS(in2,pw.nrxx); + stohchi.get_GRA_index();*/ + + //--------------------------------------------------- + /*//test hermit property of hchi matrix + Emin = -1; + Emax = 1; + Stochastic_hchi:: Emin = this -> Emin; + Stochastic_hchi:: Emax = this -> Emax; + complex *out = new complex [pw.nrxx]; + complex *in2 = new complex [pw.nrxx]; + cout<<"------------------------------------"< cij,cji; + double dc; + for(int i = 0 ; i < 300 ; ++i) + { + if( i % 10 == 0) + cout<<"We are testing "< 1e-6) + { + cout<<"(i,j) = ("< Emin; + Stochastic_hchi:: Emax = this -> Emax; + int * GRA_index = stohchi.GRA_index; + ZEROS(in,pw.nrxx); + complex *kswf = &wf.evc[0](0,0); + for ( int ig = 0 ; ig< wf.npw; ++ig) + { + in[GRA_index[ig]] = kswf [ig]; + } + fftw_plan pp=fftw_plan_dft_3d(pw.nx,pw.ny,pw.nz,(fftw_complex *)in,(fftw_complex *)in2, FFTW_BACKWARD, FFTW_ESTIMATE); + fftw_execute(pp); + stohchi.hchi_real(in2,out); + fftw_plan pp2=fftw_plan_dft_3d(pw.nx,pw.ny,pw.nz,(fftw_complex *)out,(fftw_complex *)out, FFTW_FORWARD, FFTW_ESTIMATE); + fftw_execute(pp2); + for(int i = 0; i *chigout = new complex [wf.npw]; + complex *wave = new complex [pw.nrxx]; + complex *waveout = new complex [pw.nrxx]; + Emax = 1000; + Emin = 0; + Stochastic_hchi:: Emin = this->Emin; + Stochastic_hchi:: Emax = this->Emax; + double Ebar = (Emax + Emin)/2; + double DeltaE = (Emax - Emin)/2; + fftw_plan pp=fftw_plan_dft_3d(pw.nx,pw.ny,pw.nz,(fftw_complex *)wave,(fftw_complex *)wave, FFTW_BACKWARD, FFTW_ESTIMATE); + for(int ib = 0 ; ib < NBANDS ; ++ib) + { + complex *kswf = &wf.evc[0](ib,0); + hm.hpw.h_psi( kswf , chigout); + double energy = 0; + double norm1 =0; + ZEROS(wave,pw.nrxx); + for(int ig = 0 ; ig < wf.npw ; ++ig) + { + energy += real(conj(kswf[ig]) * chigout[ig]); + norm1 += norm (kswf[ig]); + wave[GRA_index[ig]] = kswf[ig]; + } + fftw_execute(pp); + stohchi.hchi_real(wave,waveout); + double energy2 = 0; + double norm2 =0; + for(int ir = 0 ; ir < pw.nrxx ; ++ir) + { + energy2 += real(conj(wave[ir]) * waveout[ir]) * DeltaE + Ebar * norm(wave[ir]); + norm2 += norm(wave[ir]); + } + + + cout<<"BAND "< *wave = new complex [pw.nrxx]; + complex *waveout = new complex [pw.nrxx]; + Emax = 750; + Emin = -100; + Stochastic_hchi:: Emin = this->Emin; + Stochastic_hchi:: Emax = this->Emax; + mu = en.ef; + stoche.calcoef(this->nfd); + fftw_plan pp=fftw_plan_dft_3d(pw.nx,pw.ny,pw.nz,(fftw_complex *)wave,(fftw_complex *)wave, FFTW_BACKWARD, FFTW_ESTIMATE); + for(int ib = 0 ; ib < NBANDS ; ++ib) + { + ZEROS(wave,pw.nrxx); + complex *kswf = &wf.evc[0](ib,0); + for(int ig = 0 ; ig < wf.npw ; ++ig) + { + wave[GRA_index[ig]] = kswf[ig]; + } + fftw_execute(pp); + double ne =0; + double norm1 = 0; + stoche.calresult(stohchi.hchi_real, pw.nrxx, wave, waveout); + for(int ir = 0 ; ir < pw.nrxx ; ++ir) + { + ne += real(conj(wave[ir]) * waveout[ir]); + norm1 += norm(wave[ir]); + } + cout<<"Ne of Band "< 0) + { + chiortho[0].create(nchip,nrxx,false); + } return; } diff --git a/ABACUS.develop/source/src_pw/sto_wf.h b/ABACUS.develop/source/src_pw/sto_wf.h index 3f0b5d7c66..184478ef9d 100644 --- a/ABACUS.develop/source/src_pw/sto_wf.h +++ b/ABACUS.develop/source/src_pw/sto_wf.h @@ -19,13 +19,12 @@ class Stochastic_WF void init(); - void calculate_chi(); // ComplexMatrix may not be a best filetype to store the electronic wave functions ComplexMatrix* chi0; // origin stochastic wavefunctions in real space - ComplexMatrix* chig; // stochastic wavefunctions after in reciprocal space orthogonalized with KS wavefunctions + ComplexMatrix* chiortho; // stochastic wavefunctions after in reciprocal space orthogonalized with KS wavefunctions Stochastic_Chebychev sto_che; - int nchi; // Total number of stochatic obitals + int nchi; // Total number of stochatic obitals; unit in a_0^(3/2) int nchip; // The number of stochatic obitals in current process int nche_sto; // number of orders for Chebyshev expansion diff --git a/ABACUS.develop/source/src_pw/threshold_elec.cpp b/ABACUS.develop/source/src_pw/threshold_elec.cpp index 1051310e1b..5757e3a723 100644 --- a/ABACUS.develop/source/src_pw/threshold_elec.cpp +++ b/ABACUS.develop/source/src_pw/threshold_elec.cpp @@ -39,7 +39,7 @@ void Threshold_Elec::set_ethr(void) const //================ // self consistent //================ - else if(CALCULATION=="scf" || CALCULATION=="md" || CALCULATION=="relax") + else if(CALCULATION=="scf" || CALCULATION=="md" || CALCULATION=="relax" || CALCULATION=="scf-sto")//qianrui 2021-2-20 { if (ETHR == 0.0) { diff --git a/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp b/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp index 632e6e2505..53112380cb 100644 --- a/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp +++ b/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp @@ -1240,45 +1240,47 @@ void UnitCell_pseudo::cal_nelec(void) } } - - if(NBANDS == 0) + if ( CALCULATION!="scf-sto" && CALCULATION!="relax-sto" && CALCULATION!="md-sto" ) //qianrui 2021-2-20 { - if(NSPIN == 1) - { - int nbands1 = static_cast(occupied_bands) + 10; - int nbands2 = static_cast(1.2 * occupied_bands); - NBANDS = max(nbands1, nbands2); - } - else if (NSPIN ==2 || NSPIN == 4) - { - int nbands3 = nelec + 20; - int nbands4 = 1.2 * nelec; - NBANDS = max(nbands3, nbands4); - } - if (NBANDS > NLOCAL) - { - NBANDS = NLOCAL; - } - AUTO_SET("NBANDS",NBANDS); - } - //else if ( CALCULATION=="scf" || CALCULATION=="md" || CALCULATION=="relax") //pengfei 2014-10-13 - else - { - if(NBANDS < occupied_bands) WARNING_QUIT("unitcell","Too few bands!"); - if(NBANDS < mag.get_nelup() ) - { - OUT(ofs_running,"nelup",mag.get_nelup()); - WARNING_QUIT("unitcell","Too few spin up bands!"); - } - if(NBANDS < mag.get_neldw() ) + if(NBANDS == 0) { - WARNING_QUIT("unitcell","Too few spin down bands!"); + if(NSPIN == 1) + { + int nbands1 = static_cast(occupied_bands) + 10; + int nbands2 = static_cast(1.2 * occupied_bands); + NBANDS = max(nbands1, nbands2); + } + else if (NSPIN ==2 || NSPIN == 4) + { + int nbands3 = nelec + 20; + int nbands4 = 1.2 * nelec; + NBANDS = max(nbands3, nbands4); + } + if (NBANDS > NLOCAL) + { + NBANDS = NLOCAL; + } + AUTO_SET("NBANDS",NBANDS); } - if (NBANDS > NLOCAL) + //else if ( CALCULATION=="scf" || CALCULATION=="md" || CALCULATION=="relax") //pengfei 2014-10-13 + else { - WARNING_QUIT("unitcell","Too many bands! NBANDS > NBASIS."); + if(NBANDS < occupied_bands) WARNING_QUIT("unitcell","Too few bands!"); + if(NBANDS < mag.get_nelup() ) + { + OUT(ofs_running,"nelup",mag.get_nelup()); + WARNING_QUIT("unitcell","Too few spin up bands!"); + } + if(NBANDS < mag.get_neldw() ) + { + WARNING_QUIT("unitcell","Too few spin down bands!"); + } + if (NBANDS > NLOCAL) + { + WARNING_QUIT("unitcell","Too many bands! NBANDS > NBASIS."); + } } - } + } OUT(ofs_running,"NBANDS",NBANDS); return; From 83e9ab0a66fc27d1ba9d630318877efade1b7557 Mon Sep 17 00:00:00 2001 From: mohan Date: Sat, 27 Feb 2021 21:19:35 +0800 Subject: [PATCH 159/233] add some minor changes to potential_libxc --- ABACUS.develop/source/src_pw/energy.h | 1 - .../source/src_pw/potential_libxc.cpp | 114 +++++++++++++++--- .../source/src_pw/potential_libxc.h | 6 +- 3 files changed, 103 insertions(+), 18 deletions(-) diff --git a/ABACUS.develop/source/src_pw/energy.h b/ABACUS.develop/source/src_pw/energy.h index f49e59efdf..69eceede51 100644 --- a/ABACUS.develop/source/src_pw/energy.h +++ b/ABACUS.develop/source/src_pw/energy.h @@ -38,7 +38,6 @@ class energy int printe; // print energy every 'printe' electron iteration. int iter; - //private: //mohan change 2011-06-12 public: // The variables needed to compute the energies diff --git a/ABACUS.develop/source/src_pw/potential_libxc.cpp b/ABACUS.develop/source/src_pw/potential_libxc.cpp index f764fd5410..94cb9af5b0 100644 --- a/ABACUS.develop/source/src_pw/potential_libxc.cpp +++ b/ABACUS.develop/source/src_pw/potential_libxc.cpp @@ -34,20 +34,27 @@ void Potential_Libxc::v_xc( auto process_exc = [&](vector &sgn) { for( size_t is=0; is!=nspin0(); ++is ) + { for( size_t ir=0; ir!=pw.nrxx; ++ir ) + { etxc += e2 * exc[ir] * rho[ir*nspin0()+is] * sgn[ir*nspin0()+is]; + } + } }; + auto process_vrho = [&](vector &sgn) { if(nspin0()==1 || NSPIN==2) { for( size_t is=0; is!=nspin0(); ++is ) + { for( size_t ir=0; ir!=pw.nrxx; ++ir ) { const double v_tmp = e2 * vrho[ir*nspin0()+is] * sgn[ir*nspin0()+is]; v(is,ir) += v_tmp; vtxc += v_tmp * rho_in[is][ir]; } + } } else { @@ -58,9 +65,14 @@ void Potential_Libxc::v_xc( v_tmp[0] = e2 * (0.5 * (vrho[ir*2] + vrho[ir*2+1])); const double vs = 0.5 * (vrho[ir*2] - vrho[ir*2+1]); const double amag = sqrt( pow(rho_in[1][ir],2) + pow(rho_in[2][ir],2) + pow(rho_in[3][ir],2) ); + if(amag>vanishing_charge) + { for(int ipol=1; ipol<4; ++ipol) + { v_tmp[ipol] = e2 * vs * rho_in[ipol][ir] / amag; + } + } for(int ipol=0; ipol<4; ++ipol) { v(ipol, ir) += v_tmp[ipol]; @@ -76,28 +88,47 @@ void Potential_Libxc::v_xc( vector>> h( nspin0(), vector>(pw.nrxx) ); if( 1==nspin0() ) + { for( size_t ir=0; ir!=pw.nrxx; ++ir ) + { h[0][ir] = e2 * gdr[0][ir] * vsigma[ir] * 2.0 * sgn[ir]; + } + } else + { for( size_t ir=0; ir!=pw.nrxx; ++ir ) { - h[0][ir] = e2 * (gdr[0][ir] * vsigma[ir*3 ] * 2.0 * sgn[ir*2 ] + gdr[1][ir] * vsigma[ir*3+1] * sgn[ir*2] * sgn[ir*2+1]); - h[1][ir] = e2 * (gdr[1][ir] * vsigma[ir*3+2] * 2.0 * sgn[ir*2+1] + gdr[0][ir] * vsigma[ir*3+1] * sgn[ir*2] * sgn[ir*2+1]); + h[0][ir] = e2 * (gdr[0][ir] * vsigma[ir*3 ] * 2.0 + * sgn[ir*2 ] + gdr[1][ir] * vsigma[ir*3+1] * sgn[ir*2] * sgn[ir*2+1]); + h[1][ir] = e2 * (gdr[1][ir] * vsigma[ir*3+2] * 2.0 + * sgn[ir*2+1] + gdr[0][ir] * vsigma[ir*3+1] * sgn[ir*2] * sgn[ir*2+1]); } + } vector> dh(nspin0(), vector(pw.nrxx)); for( size_t is=0; is!=nspin0(); ++is ) + { GGA_PW::grad_dot( VECTOR_TO_PTR(h[is]), VECTOR_TO_PTR(dh[is]) ); + } + for( size_t is=0; is!=nspin0(); ++is ) + { for( size_t ir=0; ir!=pw.nrxx; ++ir ) + { vtxc -= dh[is][ir] * rho[ir*nspin0()+is]; + } + } if(nspin0()==1 || NSPIN==2) { for( size_t is=0; is!=nspin0(); ++is ) + { for( size_t ir=0; ir!=pw.nrxx; ++ir ) + { v(is,ir) -= dh[is][ir]; + } + } } else { @@ -106,43 +137,61 @@ void Potential_Libxc::v_xc( { v(0,ir) -= 0.5 * (dh[0][ir] + dh[1][ir]); const double amag = sqrt( pow(rho_in[1][ir],2) + pow(rho_in[2][ir],2) + pow(rho_in[3][ir],2) ); - const double neg = (soc.lsign && rho_in[1][ir]*soc.ux[0]+rho_in[2][ir]*soc.ux[1]+rho_in[3][ir]*soc.ux[2]<=0) ? -1 : 1; + const double neg = (soc.lsign && rho_in[1][ir]*soc.ux[0] + +rho_in[2][ir]*soc.ux[1]+rho_in[3][ir]*soc.ux[2]<=0) ? -1 : 1; if(amag > vanishing_charge) + { for(int i=1;i<4;i++) + { v(i,ir) -= neg * 0.5 * (dh[0][ir]-dh[1][ir]) * rho_in[i][ir] / amag; + } + } } } }; constexpr double rho_threshold = 1E-6; constexpr double grho_threshold = 1E-10; + xc_func_set_dens_threshold(&func, rho_threshold); + vector sgn( pw.nrxx * nspin0(), 1.0); + if(nspin0()==2 && func.info->family != XC_FAMILY_LDA && func.info->kind==XC_CORRELATION) + { for( size_t ir=0; ir!=pw.nrxx; ++ir ) { if ( rho[ir*2]family ) { case XC_FAMILY_LDA: - xc_lda_exc_vxc( &func, pw.nrxx,VECTOR_TO_PTR(rho), VECTOR_TO_PTR(exc), VECTOR_TO_PTR(vrho) ); + xc_lda_exc_vxc( &func, pw.nrxx, + VECTOR_TO_PTR(rho), VECTOR_TO_PTR(exc), VECTOR_TO_PTR(vrho) ); process_exc(sgn); process_vrho(sgn); break; case XC_FAMILY_GGA: case XC_FAMILY_HYB_GGA: - xc_gga_exc_vxc( &func, pw.nrxx, VECTOR_TO_PTR(rho), VECTOR_TO_PTR(sigma), VECTOR_TO_PTR(exc), VECTOR_TO_PTR(vrho), VECTOR_TO_PTR(vsigma) ); + xc_gga_exc_vxc( &func, pw.nrxx, + VECTOR_TO_PTR(rho), VECTOR_TO_PTR(sigma), VECTOR_TO_PTR(exc), + VECTOR_TO_PTR(vrho), VECTOR_TO_PTR(vsigma) ); process_exc(sgn); process_vrho(sgn); process_vsigma(sgn); break; default: - throw domain_error("func.info->family ="+TO_STRING(func.info->family)+" unfinished in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + throw domain_error("func.info->family ="+TO_STRING(func.info->family) + +" unfinished in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; } xc_func_end(&func); @@ -175,31 +224,49 @@ std::vector Potential_Libxc::init_func() if( 6==xcf.iexch_now && 8==xcf.igcx_now && 4==xcf.icorr_now && 4==xcf.igcc_now ) { add_func( XC_HYB_GGA_XC_PBEH ); - double parameter_hse[3] = { exx_global.info.hybrid_alpha, exx_global.info.hse_omega, exx_global.info.hse_omega }; + double parameter_hse[3] = { exx_global.info.hybrid_alpha, + exx_global.info.hse_omega, + exx_global.info.hse_omega }; xc_func_set_ext_params(&funcs.back(), parameter_hse); return funcs; } else if( 9==xcf.iexch_now && 12==xcf.igcx_now && 4==xcf.icorr_now && 4==xcf.igcc_now ) { add_func( XC_HYB_GGA_XC_HSE06 ); - double parameter_hse[3] = { exx_global.info.hybrid_alpha, exx_global.info.hse_omega, exx_global.info.hse_omega }; + double parameter_hse[3] = { exx_global.info.hybrid_alpha, + exx_global.info.hse_omega, + exx_global.info.hse_omega }; xc_func_set_ext_params(&funcs.back(), parameter_hse); return funcs; } if( 1==xcf.iexch_now && 0==xcf.igcx_now ) + { add_func( XC_LDA_X ); + } else if( 1==xcf.iexch_now && 3==xcf.igcx_now ) + { add_func( XC_GGA_X_PBE ); + } else - throw domain_error("iexch="+TO_STRING(xcf.iexch_now)+", igcx="+TO_STRING(xcf.igcx_now)+" unfinished in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + { + throw domain_error("iexch="+TO_STRING(xcf.iexch_now)+", igcx=" + +TO_STRING(xcf.igcx_now)+" unfinished in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + } if( 1==xcf.icorr_now && 0==xcf.igcc_now ) + { add_func( XC_LDA_C_PZ ); + } else if( 4==xcf.icorr_now && 4==xcf.igcc_now ) + { add_func( XC_GGA_C_PBE ); + } else - throw domain_error("icorr="+TO_STRING(xcf.icorr_now)+", igcc="+TO_STRING(xcf.igcc_now)+" unfinished in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + { + throw domain_error("icorr="+TO_STRING(xcf.icorr_now)+", igcc=" + +TO_STRING(xcf.igcc_now)+" unfinished in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + } return funcs; } @@ -230,17 +297,25 @@ Potential_Libxc::cal_input( if(nspin0()==1 || NSPIN==2) { for( size_t is=0; is!=nspin0(); ++is ) + { for( size_t ir=0; ir!=pw.nrxx; ++ir ) + { rho[ir*nspin0()+is] = rho_in[is][ir] + 1.0/nspin0()*CHR.rho_core[ir]; + } + } } else { if(xcf.igcx||xcf.igcc) + { soc.cal_ux(ucell.ntype); + } for( size_t ir=0; ir!=pw.nrxx; ++ir ) { const double amag = sqrt( pow(rho_in[1][ir],2) + pow(rho_in[2][ir],2) + pow(rho_in[3][ir],2) ); - const double neg = (soc.lsign && rho_in[1][ir]*soc.ux[0]+rho_in[2][ir]*soc.ux[1]+rho_in[3][ir]*soc.ux[2]<=0) ? -1 : 1; + const double neg = (soc.lsign && rho_in[1][ir]*soc.ux[0] + +rho_in[2][ir]*soc.ux[1] + +rho_in[3][ir]*soc.ux[2]<=0) ? -1 : 1; rho[ir*2] = 0.5 * (rho_in[0][ir] + neg * amag) + 0.5 * CHR.rho_core[ir]; rho[ir*2+1] = 0.5 * (rho_in[0][ir] - neg * amag) + 0.5 * CHR.rho_core[ir]; } @@ -258,7 +333,9 @@ Potential_Libxc::cal_input( { vector rhor(pw.nrxx); for(int ir=0; ir> rhog(pw.ngmc); CHR.set_rhog(rhor.data(), rhog.data()); @@ -276,16 +353,22 @@ Potential_Libxc::cal_input( sigma.resize( pw.nrxx * ((1==nspin0())?1:3) ); if( 1==nspin0() ) + { for( size_t ir=0; ir!=pw.nrxx; ++ir ) + { sigma[ir] = gdr[0][ir]*gdr[0][ir]; + } + } else + { for( size_t ir=0; ir!=pw.nrxx; ++ir ) { sigma[ir*3] = gdr[0][ir]*gdr[0][ir]; sigma[ir*3+1] = gdr[0][ir]*gdr[1][ir]; sigma[ir*3+2] = gdr[1][ir]*gdr[1][ir]; } - } + } + } finished_sigma = true; }; @@ -303,14 +386,13 @@ Potential_Libxc::cal_input( cal_sigma(); break; default: - throw domain_error("func.info->family ="+TO_STRING(func.info->family)+" unfinished in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + throw domain_error("func.info->family =" + +TO_STRING(func.info->family)+" unfinished in " + +TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; } } return std::make_tuple( rho, sigma, gdr ); } - - - #endif diff --git a/ABACUS.develop/source/src_pw/potential_libxc.h b/ABACUS.develop/source/src_pw/potential_libxc.h index 1bf1eceacf..04bda075e9 100644 --- a/ABACUS.develop/source/src_pw/potential_libxc.h +++ b/ABACUS.develop/source/src_pw/potential_libxc.h @@ -13,6 +13,7 @@ class Potential_Libxc { public: + static void v_xc( const double * const * const rho_in, double &etxc, @@ -24,7 +25,10 @@ class Potential_Libxc static std::vector init_func(); // [ rho, sigma, gdr ] - static std::tuple< std::vector, std::vector, std::vector>> > + static std::tuple< + std::vector, + std::vector, + std::vector>> > cal_input( const std::vector &funcs, const double * const * const rho_in ); From dd1624043586585932725209d7cbe60a1e09091b Mon Sep 17 00:00:00 2001 From: mohan Date: Sat, 27 Feb 2021 21:59:34 +0800 Subject: [PATCH 160/233] move read atoms and read pseudopotentials codes to src_io, add read_atoms and read_pseudopot files --- ABACUS.develop/source/Makefile.Objects | 2 + ABACUS.develop/source/src_io/read_atoms.cpp | 895 ++++++++++++++ .../source/src_io/read_pseudopot.cpp | 146 +++ ABACUS.develop/source/src_pw/pseudo_us.h | 2 + .../source/src_pw/unitcell_pseudo.cpp | 1027 ----------------- 5 files changed, 1045 insertions(+), 1027 deletions(-) create mode 100644 ABACUS.develop/source/src_io/read_atoms.cpp create mode 100644 ABACUS.develop/source/src_io/read_pseudopot.cpp diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 5fd256db2b..197b1f4cf0 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -214,6 +214,8 @@ H_Ewald_pw.o\ H_Hartree_pw.o\ H_XC_pw.o \ read_rho.o\ +read_atoms.o\ +read_pseudopot.o\ write_pot.o\ write_rho.o\ write_rho_dipole.o\ diff --git a/ABACUS.develop/source/src_io/read_atoms.cpp b/ABACUS.develop/source/src_io/read_atoms.cpp new file mode 100644 index 0000000000..3e8f51bf46 --- /dev/null +++ b/ABACUS.develop/source/src_io/read_atoms.cpp @@ -0,0 +1,895 @@ +#include "src_pw/unitcell_pseudo.h" +#include "src_lcao/ORB_read.h" // to use 'ORB' -- mohan 2021-01-30 +#include "src_pw/global.h" +#include // Peize Lin fix bug about strcmp 2016-08-02 + +void UnitCell_pseudo::read_atom_species(ifstream &ifa) +{ + TITLE("UnitCell_pseudo","read_atom_species"); + + this->atom_mass = new double[ntype]; //atom masses + this->atom_label = new string[ntype]; //atom labels + this->pseudo_fn = new string[ntype]; //file name of pseudopotential + + string word; + //========================================== + // read in information of each type of atom + //========================================== + if( SCAN_BEGIN(ifa, "ATOMIC_SPECIES") ) + { + OUT(ofs_running,"ntype",ntype); + for (int i = 0;i < ntype;i++) + { + ifa >> atom_label[i] >> atom_mass[i]; + + stringstream ss; + ss << "atom label for species " << i+1; + OUT(ofs_running,ss.str(),atom_label[i]); + READ_VALUE(ifa, pseudo_fn[i]); + if(test_pseudo_cell==2) + { + ofs_running << "\n" << setw(6) << atom_label[i] + << setw(12) << atom_mass[i] + << setw(18) << pseudo_fn[i]; + } + } + } + + if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") + { + if( SCAN_BEGIN(ifa, "NUMERICAL_ORBITAL") ) + { + ORB.read_in_flag = true; + for(int i=0; i> ofile; + //----------------------------------- + // Turn off the read in NONLOCAL file + // function since 2013-08-02 by mohan + //----------------------------------- + //READ_VALUE(ifa, nfile); + + ORB.orbital_file.push_back(ofile); + + //----------------------------------- + // Turn off the read in NONLOCAL file + // function since 2013-08-02 by mohan + //----------------------------------- + //ORB.nonlocal_file.push_back(nfile); + +// ofs_running << " For atom type " << i + 1 << endl; +// ofs_running << " Read in numerical orbitals from file " << ofile << endl; +// ofs_running << " Read in nonlocal projectors from file " << nfile << endl; + + } + } + } + + // Peize Lin add 2016-09-23 + if( Exx_Global::Hybrid_Type::HF == exx_lcao.info.hybrid_type || + Exx_Global::Hybrid_Type::PBE0 == exx_lcao.info.hybrid_type || + Exx_Global::Hybrid_Type::HSE == exx_lcao.info.hybrid_type ) + { + if( SCAN_BEGIN(ifa, "ABFS_ORBITAL") ) + { + for(int i=0; i> ofile; + exx_lcao.info.files_abfs.push_back(ofile); + } + } + } + + //========================== + // read in lattice constant + //========================== + if( SCAN_BEGIN(ifa, "LATTICE_CONSTANT") ) + { + READ_VALUE(ifa, lat0); + if(lat0<=0.0) + { + WARNING_QUIT("read_atom_species","lat0<=0.0"); + } + lat0_angstrom = lat0 * 0.529177 ; + OUT(ofs_running,"lattice constant (Bohr)",lat0); + OUT(ofs_running,"lattice constant (Angstrom)",lat0_angstrom); + this->tpiba = TWO_PI / lat0; + this->tpiba2 = tpiba * tpiba; + } + + //=========================== + // Read in latticies vector + //=========================== + if( SCAN_BEGIN(ifa, "LATTICE_VECTORS") ) + { + // Reading lattice vectors. notice + // here that only one cpu read these + // parameters. + ifa >> latvec.e11 >> latvec.e12; + READ_VALUE(ifa, latvec.e13); + ifa >> latvec.e21 >> latvec.e22; + READ_VALUE(ifa, latvec.e23); + ifa >> latvec.e31 >> latvec.e32; + READ_VALUE(ifa, latvec.e33); + + // lattice vectors in another form. + a1.x = latvec.e11; + a1.y = latvec.e12; + a1.z = latvec.e13; + + a2.x = latvec.e21; + a2.y = latvec.e22; + a2.z = latvec.e23; + + a3.x = latvec.e31; + a3.y = latvec.e32; + a3.z = latvec.e33; + + } + return; +} + +// Read atomic positions +// return 1: no problem. +// return 0: some problems. +bool UnitCell_pseudo::read_atom_positions(ifstream &ifpos) +{ + TITLE("UnitCell_pseudo","read_atom_positions"); + + bool use_xyz = false; + /* LiuXh 20171109 + if( SCAN_BEGIN(ifpos, "USE_XYZ") ) + { + use_xyz = true; + } + */ + + if( SCAN_BEGIN(ifpos, "ATOMIC_POSITIONS")) + { + READ_VALUE( ifpos, Coordinate); + if(Coordinate != "Cartesian" + && Coordinate != "Direct" + && Coordinate != "Cartesian_angstrom" + && Coordinate != "Cartesian_au" + && Coordinate != "Cartesian_angstrom_center_xy" + && Coordinate != "Cartesian_angstrom_center_xz" + && Coordinate != "Cartesian_angstrom_center_yz" + && Coordinate != "Cartesian_angstrom_center_xyz" + ) + { + WARNING("read_atom_position","Cartesian or Direct?"); + ofs_warning << " There are several options for you:" << endl; + ofs_warning << " Direct" << endl; + ofs_warning << " Cartesian_angstrom" << endl; + ofs_warning << " Cartesian_au" << endl; + ofs_warning << " Cartesian_angstrom_center_xy" << endl; + ofs_warning << " Cartesian_angstrom_center_xz" << endl; + ofs_warning << " Cartesian_angstrom_center_yz" << endl; + ofs_warning << " Cartesian_angstrom_center_xyz" << endl; + return 0; + } + + Vector3 v; + Vector3 mv; + int na = 0; + this->nat = 0; + + //====================================== + // calculate total number of atoms + // and adjust the order of atom species + //====================================== + assert(ntype>0); + for (int it = 0;it < ntype; it++) + { + ofs_running << "\n READING ATOM TYPE " << it+1 << endl; + + //======================================= + // (1) read in atom label + // start magnetization + //======================================= + READ_VALUE(ifpos, atoms[it].label); + bool found = false; + for(int it2=0; it2atoms[it].label == this->atom_label[it] ) + found = true; + } + if(!found) + { + ofs_warning << " Label read from ATOMIC_POSITIONS is " << this->atoms[it].label << endl; + ofs_warning << " Lable from ATOMIC_SPECIES is " << this->atom_label[it] << endl; + return 0; + } + READ_VALUE(ifpos, mag.start_magnetization[it] ); + + OUT(ofs_running, "atom label",atoms[it].label); + + if(NSPIN==4)//added by zhengdy-soc + { + if(NONCOLIN) + { + soc.m_loc[it].x = mag.start_magnetization[it] * + sin(soc.angle1[it]) * cos(soc.angle2[it]); + soc.m_loc[it].y = mag.start_magnetization[it] * + sin(soc.angle1[it]) * sin(soc.angle2[it]); + soc.m_loc[it].z = mag.start_magnetization[it] * + cos(soc.angle1[it]); + } + else + { + soc.m_loc[it].x = 0; + soc.m_loc[it].y = 0; + soc.m_loc[it].z = mag.start_magnetization[it]; + } + + OUT(ofs_running, "noncollinear magnetization_x",soc.m_loc[it].x); + OUT(ofs_running, "noncollinear magnetization_y",soc.m_loc[it].y); + OUT(ofs_running, "noncollinear magnetization_z",soc.m_loc[it].z); + + ZEROS(soc.ux ,3); + } + else if(NSPIN==2) + { + soc.m_loc[it].x = mag.start_magnetization[it]; + OUT(ofs_running, "start magnetization",mag.start_magnetization[it]); + } + else if(NSPIN==1) + { + OUT(ofs_running, "start magnetization","FALSE"); + } + + //=========================================== + // (2) read in numerical orbital information + // int atoms[it].nwl + // int* atoms[it].l_nchi; + //=========================================== + /*READ_VALUE(ifpos, this->atoms[it].nwl); + assert(this->atoms[it].nwl<10); + OUT(ofs_running,"L max for local orbitals",atoms[it].nwl); + + delete[] this->atoms[it].l_nchi; + this->atoms[it].l_nchi = new int[ this->atoms[it].nwl+1]; + this->atoms[it].nw = 0; + for(int L=0; Latoms[it].l_nchi[L]); + + // calculate the number of local basis(3D) + this->atoms[it].nw += (2*L + 1) * this->atoms[it].l_nchi[L]; + + stringstream ss; + ss << "L=" << L << ", number of zeta"; + OUT(ofs_running,ss.str(),atoms[it].l_nchi[L]); + }*/ + if (BASIS_TYPE == "lcao" || BASIS_TYPE == "lcao_in_pw") + { + ifstream ifs(ORB.orbital_file[it].c_str(), ios::in); // pengfei 2014-10-13 + if (!ifs) + { + cout << " Can't find the ORBITAL file." << endl; + } + + char word[80]; + delete[] this->atoms[it].l_nchi; + this->atoms[it].l_nchi = new int[ this->atoms[it].nwl+1]; + this->atoms[it].nw = 0; + int L =0; + + while (ifs.good()) + { + ifs >> word; + if (strcmp("Lmax", word) == 0) + { + READ_VALUE(ifs, this->atoms[it].nwl); + } + assert(this->atoms[it].nwl<10); + + if (strcmp("Cutoff(a.u.)", word) == 0) // pengfei Li 16-2-29 + { + READ_VALUE(ifs, this->atoms[it].Rcut); + } + + //cout << "atoms[it].nwl = "<", word) == 0) + { + READ_VALUE(ifs, this->atoms[it].l_nchi[L]); + this->atoms[it].nw += (2*L + 1) * this->atoms[it].l_nchi[L]; + stringstream ss; + ss << "L=" << L << ", number of zeta"; + OUT(ofs_running,ss.str(),atoms[it].l_nchi[L]); + L++; + } + if (strcmp("Porbital-->", word) == 0) + { + READ_VALUE(ifs, this->atoms[it].l_nchi[L]); + this->atoms[it].nw += (2*L + 1) * this->atoms[it].l_nchi[L]; + stringstream ss; + ss << "L=" << L << ", number of zeta"; + OUT(ofs_running,ss.str(),atoms[it].l_nchi[L]); + L++; + } + if (strcmp("Dorbital-->", word) == 0) + { + READ_VALUE(ifs, this->atoms[it].l_nchi[L]); + this->atoms[it].nw += (2*L + 1) * this->atoms[it].l_nchi[L]; + stringstream ss; + ss << "L=" << L << ", number of zeta"; + OUT(ofs_running,ss.str(),atoms[it].l_nchi[L]); + L++; + } + if (strcmp("Forbital-->", word) == 0) + { + READ_VALUE(ifs, this->atoms[it].l_nchi[L]); + this->atoms[it].nw += (2*L + 1) * this->atoms[it].l_nchi[L]; + stringstream ss; + ss << "L=" << L << ", number of zeta"; + OUT(ofs_running,ss.str(),atoms[it].l_nchi[L]); + L++; + } + if (strcmp("Gorbital-->", word) == 0) + { + READ_VALUE(ifs, this->atoms[it].l_nchi[L]); + this->atoms[it].nw += (2*L + 1) * this->atoms[it].l_nchi[L]; + stringstream ss; + ss << "L=" << L << ", number of zeta"; + OUT(ofs_running,ss.str(),atoms[it].l_nchi[L]); + L++; + } + //cout <<" atoms[it].nw = "<atoms[it].l_nchi; + this->atoms[it].l_nchi = new int[ this->atoms[it].nwl+1]; + this->atoms[it].nw = 0; + + this->atoms[it].nwl = 2; + //cout << INPUT.lmaxmax << endl; + if ( INPUT.lmaxmax != 2 ) + { + this->atoms[it].nwl = INPUT.lmaxmax; + } + for(int L=0; Latoms[it].l_nchi[L] = 1; + // calculate the number of local basis(3D) + this->atoms[it].nw += (2*L + 1) * this->atoms[it].l_nchi[L]; + + stringstream ss; + ss << "L=" << L << ", number of zeta"; + OUT(ofs_running,ss.str(),atoms[it].l_nchi[L]); + } + + /* this->atoms[it].l_nchi[0] = 1; + this->atoms[it].nw += (2*0 + 1) * this->atoms[it].l_nchi[0]; + // stringstream s0; + // s0 << "L=" << 0 << ", number of zeta"; + // OUT(ofs_running,s0.str(),atoms[it].l_nchi[0]); + + this->atoms[it].l_nchi[1] = 1; + this->atoms[it].nw += (2*1 + 1) * this->atoms[it].l_nchi[1]; + // stringstream s1; + // s1 << "L=" << 1 << ", number of zeta"; + // OUT(ofs_running,s1.str(),atoms[it].l_nchi[1]); + + this->atoms[it].l_nchi[2] = 1; + this->atoms[it].nw += (2*2 + 1) * this->atoms[it].l_nchi[2];*/ + // stringstream s2; + // s2 << "L=" << 2 << ", number of zeta"; + // OUT(ofs_running,s2.str(),atoms[it].l_nchi[2]);*/ + + } + + //OUT(ofs_running,"Total number of local orbitals",atoms[it].nw); + + //========================= + // (3) read in atom number + //========================= + READ_VALUE(ifpos, na); + this->atoms[it].na = na; + + OUT(ofs_running,"number of atom for this type",na); + + this->nat += na; + if (na <= 0) + { + WARNING("read_atom_positions"," atom number < 0."); + return 0; + } + if (na > 0) + { + delete[] atoms[it].tau; + delete[] atoms[it].taud; + delete[] atoms[it].mbl; + delete[] atoms[it].mag; + atoms[it].tau = new Vector3[na]; + atoms[it].taud = new Vector3[na]; + atoms[it].mbl = new Vector3[na]; + atoms[it].mag = new double[na]; + atoms[it].mass = this->atom_mass[it]; //mohan add 2011-11-07 + ZEROS(atoms[it].mag,na); + for (int ia = 0;ia < na; ia++) + { + if(use_xyz) + { + string tmpid; + ifpos >> tmpid; + if(tmpid != atoms[it].label) + { + WARNING("read_atom_positions","atom label not match"); + return 0; + } + else + { + ifpos >> v.x >> v.y >> v.z; + + mv.x = true; + mv.y = true; + mv.z = true; + + string mags; + std::getline( ifpos, mags ); + // change string to double. + //atoms[it].mag[ia] = std::atof(mags.c_str()); + atoms[it].mag[ia] = 0.0; + } + } + else + { + ifpos >> v.x >> v.y >> v.z + >> mv.x >> mv.y >> mv.z; + string mags; + std::getline( ifpos, mags ); + // change string to double. + //atoms[it].mag[ia] = std::atof(mags.c_str()); + atoms[it].mag[ia] = 0.0; + } + + if(Coordinate=="Direct") + { + // change v from direct to cartesian, + // the unit is pw.lat0 + atoms[it].taud[ia] = v; + atoms[it].tau[ia] = v * latvec; + } + else if(Coordinate=="Cartesian") + { + atoms[it].tau[ia] = v ;// in unit lat0 + //cout << " T=" << it << " I=" << ia << " tau=" << atoms[it].tau[ia].x << " " << + //atoms[it].tau[ia].y << " " << atoms[it].tau[ia].z << endl; + } + else if(Coordinate=="Cartesian_angstrom") + { + atoms[it].tau[ia] = v / 0.529177 / lat0; + } + else if(Coordinate=="Cartesian_angstrom_center_xy") + { + // calculate lattice center + latcenter.x = (latvec.e11 + latvec.e21 + latvec.e31)/2.0; + latcenter.y = (latvec.e12 + latvec.e22 + latvec.e32)/2.0; + latcenter.z = 0.0; + atoms[it].tau[ia] = v / 0.529177 / lat0 + latcenter; + } + else if(Coordinate=="Cartesian_angstrom_center_xz") + { + // calculate lattice center + latcenter.x = (latvec.e11 + latvec.e21 + latvec.e31)/2.0; + latcenter.y = 0.0; + latcenter.z = (latvec.e13 + latvec.e23 + latvec.e33)/2.0; + atoms[it].tau[ia] = v / 0.529177 / lat0 + latcenter; + } + else if(Coordinate=="Cartesian_angstrom_center_yz") + { + // calculate lattice center + latcenter.x = 0.0; + latcenter.y = (latvec.e12 + latvec.e22 + latvec.e32)/2.0; + latcenter.z = (latvec.e13 + latvec.e23 + latvec.e33)/2.0; + atoms[it].tau[ia] = v / 0.529177 / lat0 + latcenter; + } + else if(Coordinate=="Cartesian_angstrom_center_xyz") + { + // calculate lattice center + latcenter.x = (latvec.e11 + latvec.e21 + latvec.e31)/2.0; + latcenter.y = (latvec.e12 + latvec.e22 + latvec.e32)/2.0; + latcenter.z = (latvec.e13 + latvec.e23 + latvec.e33)/2.0; + atoms[it].tau[ia] = v / 0.529177 / lat0 + latcenter; + } + else if(Coordinate=="Cartesian_au") + { + atoms[it].tau[ia] = v / lat0; + } + + if(Coordinate=="Cartesian" || + Coordinate=="Cartesian_angstrom" || + Coordinate=="Cartesian_angstrom_center_xy" || + Coordinate=="Cartesian_angstrom_center_xz" || + Coordinate=="Cartesian_angstrom_center_yz" || + Coordinate=="Cartesian_angstrom_center_xyz" || + Coordinate=="Cartesian_au") + { + double dx,dy,dz; + Mathzone::Cartesian_to_Direct(atoms[it].tau[ia].x, atoms[it].tau[ia].y, atoms[it].tau[ia].z, + latvec.e11, latvec.e12, latvec.e13, + latvec.e21, latvec.e22, latvec.e23, + latvec.e31, latvec.e32, latvec.e33, + dx,dy,dz); + + atoms[it].taud[ia].x = dx; + atoms[it].taud[ia].y = dy; + atoms[it].taud[ia].z = dz; + + } + + atoms[it].mbl[ia] = mv; + }//endj + }// end na + }//end for ntype + }// end scan_begin + + + ofs_running << endl; + OUT(ofs_running,"TOTAL ATOM NUMBER",nat); + + // mohan add 2010-06-30 + //xiaohui modify 2015-03-15, cancel outputfile "STRU_READIN.xyz" + //this->print_cell_xyz("STRU_READIN.xyz"); + this->check_dtau(); + + if ( this->check_tau() ) + { + + } + else + { + return 0; + } + this->print_tau(); + //xiaohui modify 2015-03-15, cancel outputfile "STRU_READIN.xyz" + //this->print_cell_xyz("STRU_READIN_ADJUST.xyz"); + this->print_cell_cif("STRU_READIN_ADJUST.cif"); + + return 1; +}//end read_atom_positions + +bool UnitCell_pseudo::check_tau(void)const +{ + TITLE("UnitCell_pseudo","check_tau"); + timer::tick("UnitCell_pseudo","check_tau"); + + Vector3 diff = 0.0; + double norm = 0.0; + double tolerence_bohr = 1.0e-3; + + //ofs_running << "\n Output nearest atom not considering periodic boundary condition" << endl; + //ofs_running << " " << setw(5) << "TYPE" << setw(6) << "INDEX" + //<< setw(20) << "NEAREST(Bohr)" + //<< setw(20) << "NEAREST(Angstrom)" << endl; + for(int T1=0; T1< this->ntype; T1++) + { + for(int I1=0; I1< this->atoms[T1].na; I1++) + { + double shortest_norm = 10000.0; // a large number + //int nearest_atom_type = 0; + //int nearest_atom_index = 0; + for(int T2=0; T2ntype; T2++) + { + for(int I2=0; I2atoms[T2].na; I2++) + { + if(T1==T2 && I1==I2) + { + shortest_norm = 0.0; + //nearest_atom_type = T1; + //nearest_atom_index = I2; + // self atom + } + else + { + diff = atoms[T1].tau[I1] - atoms[T2].tau[I2]; + norm = diff.norm() * ucell.lat0; + if( shortest_norm > norm ) + { + shortest_norm = norm; + //nearest_atom_type = T2; + //nearest_atom_index = I2; + } + if( norm < tolerence_bohr ) // unit is Bohr + { + ofs_warning << " two atoms are too close!" << endl; + ofs_warning << " type:" << this->atoms[T1].label << " atom " << I1 + 1 << endl; + ofs_warning << " type:" << this->atoms[T2].label << " atom " << I2 + 1 << endl; + ofs_warning << " distance = " << norm << " Bohr" << endl; + return 0; + } + } + } + } + //ofs_running << " " << setw(5) << atoms[T1].label << setw(6) << I1+1 + //<< setw(20) << shortest_norm + //<< setw(20) << shortest_norm * BOHR_TO_A << endl; + } + } + + timer::tick("UnitCell_pseudo","check_tau"); + return 1; +} + +void UnitCell_pseudo::print_stru_file(const string &fn, const int &type)const +{ + TITLE("UnitCell_pseudo","print_stru_file"); + + if(MY_RANK!=0) return; + + ofstream ofs(fn.c_str()); + + ofs << "ATOMIC_SPECIES" << endl; + ofs << setprecision(12); + + for(int it=0; it0); + for(int it=0;ittaud[ia].x+10000) - int(atom1->taud[ia].x+10000); + double dy2 = (atom1->taud[ia].y+10000) - int(atom1->taud[ia].y+10000); + double dz2 = (atom1->taud[ia].z+10000) - int(atom1->taud[ia].z+10000); + + // mohan add 2011-04-07 + while(dx2 >= 1) + { + ofs_warning << " dx2 is >=1 " << endl; + dx2 -= 1.0; + } + while(dy2 >= 1) + { + ofs_warning << " dy2 is >=1 " << endl; + dy2 -= 1.0; + } + while(dz2 >= 1) + { + ofs_warning << " dz2 is >=1 " << endl; + dz2 -= 1.0; + } + // mohan add 2011-04-07 + while(dx2<0) + { + ofs_warning << " dx2 is <0 " << endl; + dx2 += 1.0; + } + while(dy2<0) + { + ofs_warning << " dy2 is <0 " << endl; + dy2 += 1.0; + } + while(dz2<0) + { + ofs_warning << " dz2 is <0 " << endl; + dz2 += 1.0; + } + + atom1->taud[ia].x = dx2; + atom1->taud[ia].y = dy2; + atom1->taud[ia].z = dz2; + + double cx2, cy2, cz2; + + Mathzone::Direct_to_Cartesian( + atom1->taud[ia].x, atom1->taud[ia].y, atom1->taud[ia].z, + latvec.e11, latvec.e12, latvec.e13, + latvec.e21, latvec.e22, latvec.e23, + latvec.e31, latvec.e32, latvec.e33, + cx2, cy2, cz2); + + atom1->tau[ia].x = cx2; + atom1->tau[ia].y = cy2; + atom1->tau[ia].z = cz2; + + // cout << setw(15) << dx2 << setw(15) << dy2 << setw(15) << dz2 + // << setw(15) << cx2 << setw(15) << cy2 << setw(15) << cz2 + // << endl; + + } + } + return; +} diff --git a/ABACUS.develop/source/src_io/read_pseudopot.cpp b/ABACUS.develop/source/src_io/read_pseudopot.cpp new file mode 100644 index 0000000000..99d3e4cbd1 --- /dev/null +++ b/ABACUS.develop/source/src_io/read_pseudopot.cpp @@ -0,0 +1,146 @@ +#include "src_pw/unitcell_pseudo.h" +#include "src_lcao/ORB_read.h" // to use 'ORB' -- mohan 2021-01-30 +#include "src_pw/global.h" +#include // Peize Lin fix bug about strcmp 2016-08-02 + + +//========================================================== +// Read pseudopotential according to the dir +//========================================================== +void UnitCell_pseudo::read_pseudopot(const string &pp_dir) +{ + if(test_pseudo_cell) TITLE("UnitCell_pseudo","read_pseudopot"); +//---------------------------------------------------------- +// EXPLAIN : setup reading log for pseudopot_upf +//---------------------------------------------------------- + stringstream ss; + ss << global_out_dir << "atom_pseudo.log"; + +// ofstream ofs; + +// if(MY_RANK==0) +// { +// ofs.open( ss.str().c_str(), ios::out); +// } + +//---------------------------------------------------------- +// EXPLAIN : Read in the atomic pseudo potential +//---------------------------------------------------------- + string pp_address; + for (int i = 0;i < ntype;i++) + { + Pseudopot_upf upf; + + // mohan update 2010-09-12 + int error = 0, error_ap = 0; + + if(MY_RANK==0) + { + pp_address = pp_dir + this->pseudo_fn[i]; + //error = upf.read_pseudo_upf( pp_address ); xiaohui modify 2013-06-23 + error = upf.init_pseudo_reader( pp_address ); //xiaohui add 2013-06-23 + //average pseudopotential if needed + error_ap = upf.average_p(); //added by zhengdy 2020-10-20 + } + +#ifdef __MPI + Parallel_Common::bcast_int(error); + Parallel_Common::bcast_int(error_ap); +#endif + + if(error_ap) WARNING_QUIT("UnitCell_pseudo::read_pseudopot","error when average the pseudopotential."); + + if(error==1) + { + cout << " Pseudopotential directory now is : " << pp_address << endl; + ofs_warning << " Pseudopotential directory now is : " << pp_address << endl; + WARNING_QUIT("UnitCell_pseudo::read_pseudopot","Couldn't find pseudopotential file."); + } + else if(error==2) + { + WARNING_QUIT("UnitCell_pseudo::read_pseudopot","Something in pseudopotential not match."); + } + else if(error==3) + { + WARNING_QUIT("UnitCell_pseudo::read_pseudopot","Please check the reference states in pseudopotential .vwr file.\n Also the norm of the read in pseudo wave functions\n explicitly please check S, P and D channels.\n If the norm of the wave function is \n unreasonable large (should be near 1.0), ABACUS would quit. \n The solution is to turn off the wave functions \n and the corresponding non-local projectors together\n in .vwr pseudopotential file."); + } +// OUT(ofs_running,"PP_ERRROR",error); + +//xiaohui add 2015-03-24 +#ifdef __MPI + Parallel_Common::bcast_bool(upf.functional_error); +#endif + //xiaohui add 2015-03-24 + if(upf.functional_error == 1) + { + WARNING_QUIT("Pseudopot_upf::read_pseudo_header","input xc functional does not match that in pseudopot file"); + } + + if(MY_RANK==0) + { +// upf.print_pseudo_upf( ofs ); + atoms[i].set_pseudo_us( upf ); + + ofs_running << "\n Read in pseudopotential file is " << pseudo_fn[i] << endl; + OUT(ofs_running,"pseudopotential type",atoms[i].pp_type); + OUT(ofs_running,"functional Ex", atoms[i].dft[0]); + OUT(ofs_running,"functional Ec", atoms[i].dft[1]); + OUT(ofs_running,"functional GCEx", atoms[i].dft[2]); + OUT(ofs_running,"functional GCEc", atoms[i].dft[3]); + OUT(ofs_running,"nonlocal core correction", atoms[i].nlcc); +// OUT(ofs_running,"spin orbital",atoms[i].has_so); + OUT(ofs_running,"valence electrons", atoms[i].zv); + OUT(ofs_running,"lmax", atoms[i].lmax); + OUT(ofs_running,"number of zeta", atoms[i].nchi); + OUT(ofs_running,"number of projectors", atoms[i].nbeta); + for(int ib=0; ibprint_cell(ofs); + for (int i = 0;i < ntype;i++) + { + atoms[i].print_Atom(ofs); + } + + ofs.close(); + return; +} + + +#ifdef __MPI +void UnitCell_pseudo::bcast_unitcell_pseudo(void) +{ + Parallel_Common::bcast_int( meshx ); + Parallel_Common::bcast_int( natomwfc ); + Parallel_Common::bcast_int( lmax ); + Parallel_Common::bcast_int( lmax_ppwf ); + Parallel_Common::bcast_double( nelec ); + + bcast_unitcell(); +} + +void UnitCell_pseudo::bcast_unitcell_pseudo2(void) +{ + bcast_unitcell2(); +} +#endif diff --git a/ABACUS.develop/source/src_pw/pseudo_us.h b/ABACUS.develop/source/src_pw/pseudo_us.h index 5a2897b2b5..3ee83b0d9d 100644 --- a/ABACUS.develop/source/src_pw/pseudo_us.h +++ b/ABACUS.develop/source/src_pw/pseudo_us.h @@ -14,6 +14,7 @@ class pseudo_us: public pseudo_nc // int nqf; + // double *rinner; // rinner(0:2*lmax) matrix qqq; // qqq(nbeta,nbeta) @@ -26,6 +27,7 @@ class pseudo_us: public pseudo_nc int nqlc; // number of angular momenta in Q void set_pseudo_us(const Pseudopot_upf &upf); + void print_pseudo_us(ofstream &ofs); }; diff --git a/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp b/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp index c74fedd0b1..7433b4e226 100644 --- a/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp +++ b/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp @@ -294,917 +294,7 @@ void UnitCell_pseudo::setup_cell( return; } -void UnitCell_pseudo::read_atom_species(ifstream &ifa) -{ - TITLE("UnitCell_pseudo","read_atom_species"); - - this->atom_mass = new double[ntype]; //atom masses - this->atom_label = new string[ntype]; //atom labels - this->pseudo_fn = new string[ntype]; //file name of pseudopotential - - string word; - //========================================== - // read in information of each type of atom - //========================================== - if( SCAN_BEGIN(ifa, "ATOMIC_SPECIES") ) - { - OUT(ofs_running,"ntype",ntype); - for (int i = 0;i < ntype;i++) - { - ifa >> atom_label[i] >> atom_mass[i]; - - stringstream ss; - ss << "atom label for species " << i+1; - OUT(ofs_running,ss.str(),atom_label[i]); - READ_VALUE(ifa, pseudo_fn[i]); - if(test_pseudo_cell==2) - { - ofs_running << "\n" << setw(6) << atom_label[i] - << setw(12) << atom_mass[i] - << setw(18) << pseudo_fn[i]; - } - } - } - - if(BASIS_TYPE=="lcao" || BASIS_TYPE=="lcao_in_pw") - { - if( SCAN_BEGIN(ifa, "NUMERICAL_ORBITAL") ) - { - ORB.read_in_flag = true; - for(int i=0; i> ofile; - //----------------------------------- - // Turn off the read in NONLOCAL file - // function since 2013-08-02 by mohan - //----------------------------------- - //READ_VALUE(ifa, nfile); - - ORB.orbital_file.push_back(ofile); - - //----------------------------------- - // Turn off the read in NONLOCAL file - // function since 2013-08-02 by mohan - //----------------------------------- - //ORB.nonlocal_file.push_back(nfile); - -// ofs_running << " For atom type " << i + 1 << endl; -// ofs_running << " Read in numerical orbitals from file " << ofile << endl; -// ofs_running << " Read in nonlocal projectors from file " << nfile << endl; - - } - } - } - - // Peize Lin add 2016-09-23 - if( Exx_Global::Hybrid_Type::HF == exx_lcao.info.hybrid_type || - Exx_Global::Hybrid_Type::PBE0 == exx_lcao.info.hybrid_type || - Exx_Global::Hybrid_Type::HSE == exx_lcao.info.hybrid_type ) - { - if( SCAN_BEGIN(ifa, "ABFS_ORBITAL") ) - { - for(int i=0; i> ofile; - exx_lcao.info.files_abfs.push_back(ofile); - } - } - } - - //========================== - // read in lattice constant - //========================== - if( SCAN_BEGIN(ifa, "LATTICE_CONSTANT") ) - { - READ_VALUE(ifa, lat0); - if(lat0<=0.0) - { - WARNING_QUIT("read_atom_species","lat0<=0.0"); - } - lat0_angstrom = lat0 * 0.529177 ; - OUT(ofs_running,"lattice constant (Bohr)",lat0); - OUT(ofs_running,"lattice constant (Angstrom)",lat0_angstrom); - this->tpiba = TWO_PI / lat0; - this->tpiba2 = tpiba * tpiba; - } - - //=========================== - // Read in latticies vector - //=========================== - if( SCAN_BEGIN(ifa, "LATTICE_VECTORS") ) - { - // Reading lattice vectors. notice - // here that only one cpu read these - // parameters. - ifa >> latvec.e11 >> latvec.e12; - READ_VALUE(ifa, latvec.e13); - ifa >> latvec.e21 >> latvec.e22; - READ_VALUE(ifa, latvec.e23); - ifa >> latvec.e31 >> latvec.e32; - READ_VALUE(ifa, latvec.e33); - - // lattice vectors in another form. - a1.x = latvec.e11; - a1.y = latvec.e12; - a1.z = latvec.e13; - - a2.x = latvec.e21; - a2.y = latvec.e22; - a2.z = latvec.e23; - - a3.x = latvec.e31; - a3.y = latvec.e32; - a3.z = latvec.e33; - - } - return; -} - -// Read atomic positions -// return 1: no problem. -// return 0: some problems. -bool UnitCell_pseudo::read_atom_positions(ifstream &ifpos) -{ - TITLE("UnitCell_pseudo","read_atom_positions"); - - bool use_xyz = false; - /* LiuXh 20171109 - if( SCAN_BEGIN(ifpos, "USE_XYZ") ) - { - use_xyz = true; - } - */ - - if( SCAN_BEGIN(ifpos, "ATOMIC_POSITIONS")) - { - READ_VALUE( ifpos, Coordinate); - if(Coordinate != "Cartesian" - && Coordinate != "Direct" - && Coordinate != "Cartesian_angstrom" - && Coordinate != "Cartesian_au" - && Coordinate != "Cartesian_angstrom_center_xy" - && Coordinate != "Cartesian_angstrom_center_xz" - && Coordinate != "Cartesian_angstrom_center_yz" - && Coordinate != "Cartesian_angstrom_center_xyz" - ) - { - WARNING("read_atom_position","Cartesian or Direct?"); - ofs_warning << " There are several options for you:" << endl; - ofs_warning << " Direct" << endl; - ofs_warning << " Cartesian_angstrom" << endl; - ofs_warning << " Cartesian_au" << endl; - ofs_warning << " Cartesian_angstrom_center_xy" << endl; - ofs_warning << " Cartesian_angstrom_center_xz" << endl; - ofs_warning << " Cartesian_angstrom_center_yz" << endl; - ofs_warning << " Cartesian_angstrom_center_xyz" << endl; - return 0; - } - - Vector3 v; - Vector3 mv; - int na = 0; - this->nat = 0; - - //====================================== - // calculate total number of atoms - // and adjust the order of atom species - //====================================== - assert(ntype>0); - for (int it = 0;it < ntype; it++) - { - ofs_running << "\n READING ATOM TYPE " << it+1 << endl; - - //======================================= - // (1) read in atom label - // start magnetization - //======================================= - READ_VALUE(ifpos, atoms[it].label); - bool found = false; - for(int it2=0; it2atoms[it].label == this->atom_label[it] ) - found = true; - } - if(!found) - { - ofs_warning << " Label read from ATOMIC_POSITIONS is " << this->atoms[it].label << endl; - ofs_warning << " Lable from ATOMIC_SPECIES is " << this->atom_label[it] << endl; - return 0; - } - READ_VALUE(ifpos, mag.start_magnetization[it] ); - - OUT(ofs_running, "atom label",atoms[it].label); - - if(NSPIN==4)//added by zhengdy-soc - { - if(NONCOLIN) - { - soc.m_loc[it].x = mag.start_magnetization[it] * - sin(soc.angle1[it]) * cos(soc.angle2[it]); - soc.m_loc[it].y = mag.start_magnetization[it] * - sin(soc.angle1[it]) * sin(soc.angle2[it]); - soc.m_loc[it].z = mag.start_magnetization[it] * - cos(soc.angle1[it]); - } - else - { - soc.m_loc[it].x = 0; - soc.m_loc[it].y = 0; - soc.m_loc[it].z = mag.start_magnetization[it]; - } - - OUT(ofs_running, "noncollinear magnetization_x",soc.m_loc[it].x); - OUT(ofs_running, "noncollinear magnetization_y",soc.m_loc[it].y); - OUT(ofs_running, "noncollinear magnetization_z",soc.m_loc[it].z); - - ZEROS(soc.ux ,3); - } - else if(NSPIN==2) - { - soc.m_loc[it].x = mag.start_magnetization[it]; - OUT(ofs_running, "start magnetization",mag.start_magnetization[it]); - } - else if(NSPIN==1) - { - OUT(ofs_running, "start magnetization","FALSE"); - } - - //=========================================== - // (2) read in numerical orbital information - // int atoms[it].nwl - // int* atoms[it].l_nchi; - //=========================================== - /*READ_VALUE(ifpos, this->atoms[it].nwl); - assert(this->atoms[it].nwl<10); - OUT(ofs_running,"L max for local orbitals",atoms[it].nwl); - - delete[] this->atoms[it].l_nchi; - this->atoms[it].l_nchi = new int[ this->atoms[it].nwl+1]; - this->atoms[it].nw = 0; - for(int L=0; Latoms[it].l_nchi[L]); - - // calculate the number of local basis(3D) - this->atoms[it].nw += (2*L + 1) * this->atoms[it].l_nchi[L]; - - stringstream ss; - ss << "L=" << L << ", number of zeta"; - OUT(ofs_running,ss.str(),atoms[it].l_nchi[L]); - }*/ - if (BASIS_TYPE == "lcao" || BASIS_TYPE == "lcao_in_pw") - { - ifstream ifs(ORB.orbital_file[it].c_str(), ios::in); // pengfei 2014-10-13 - if (!ifs) - { - cout << " Can't find the ORBITAL file." << endl; - } - - char word[80]; - delete[] this->atoms[it].l_nchi; - this->atoms[it].l_nchi = new int[ this->atoms[it].nwl+1]; - this->atoms[it].nw = 0; - int L =0; - - while (ifs.good()) - { - ifs >> word; - if (strcmp("Lmax", word) == 0) - { - READ_VALUE(ifs, this->atoms[it].nwl); - } - assert(this->atoms[it].nwl<10); - - if (strcmp("Cutoff(a.u.)", word) == 0) // pengfei Li 16-2-29 - { - READ_VALUE(ifs, this->atoms[it].Rcut); - } - - //cout << "atoms[it].nwl = "<", word) == 0) - { - READ_VALUE(ifs, this->atoms[it].l_nchi[L]); - this->atoms[it].nw += (2*L + 1) * this->atoms[it].l_nchi[L]; - stringstream ss; - ss << "L=" << L << ", number of zeta"; - OUT(ofs_running,ss.str(),atoms[it].l_nchi[L]); - L++; - } - if (strcmp("Porbital-->", word) == 0) - { - READ_VALUE(ifs, this->atoms[it].l_nchi[L]); - this->atoms[it].nw += (2*L + 1) * this->atoms[it].l_nchi[L]; - stringstream ss; - ss << "L=" << L << ", number of zeta"; - OUT(ofs_running,ss.str(),atoms[it].l_nchi[L]); - L++; - } - if (strcmp("Dorbital-->", word) == 0) - { - READ_VALUE(ifs, this->atoms[it].l_nchi[L]); - this->atoms[it].nw += (2*L + 1) * this->atoms[it].l_nchi[L]; - stringstream ss; - ss << "L=" << L << ", number of zeta"; - OUT(ofs_running,ss.str(),atoms[it].l_nchi[L]); - L++; - } - if (strcmp("Forbital-->", word) == 0) - { - READ_VALUE(ifs, this->atoms[it].l_nchi[L]); - this->atoms[it].nw += (2*L + 1) * this->atoms[it].l_nchi[L]; - stringstream ss; - ss << "L=" << L << ", number of zeta"; - OUT(ofs_running,ss.str(),atoms[it].l_nchi[L]); - L++; - } - if (strcmp("Gorbital-->", word) == 0) - { - READ_VALUE(ifs, this->atoms[it].l_nchi[L]); - this->atoms[it].nw += (2*L + 1) * this->atoms[it].l_nchi[L]; - stringstream ss; - ss << "L=" << L << ", number of zeta"; - OUT(ofs_running,ss.str(),atoms[it].l_nchi[L]); - L++; - } - //cout <<" atoms[it].nw = "<atoms[it].l_nchi; - this->atoms[it].l_nchi = new int[ this->atoms[it].nwl+1]; - this->atoms[it].nw = 0; - - this->atoms[it].nwl = 2; - //cout << INPUT.lmaxmax << endl; - if ( INPUT.lmaxmax != 2 ) - { - this->atoms[it].nwl = INPUT.lmaxmax; - } - for(int L=0; Latoms[it].l_nchi[L] = 1; - // calculate the number of local basis(3D) - this->atoms[it].nw += (2*L + 1) * this->atoms[it].l_nchi[L]; - - stringstream ss; - ss << "L=" << L << ", number of zeta"; - OUT(ofs_running,ss.str(),atoms[it].l_nchi[L]); - } - - /* this->atoms[it].l_nchi[0] = 1; - this->atoms[it].nw += (2*0 + 1) * this->atoms[it].l_nchi[0]; - // stringstream s0; - // s0 << "L=" << 0 << ", number of zeta"; - // OUT(ofs_running,s0.str(),atoms[it].l_nchi[0]); - - this->atoms[it].l_nchi[1] = 1; - this->atoms[it].nw += (2*1 + 1) * this->atoms[it].l_nchi[1]; - // stringstream s1; - // s1 << "L=" << 1 << ", number of zeta"; - // OUT(ofs_running,s1.str(),atoms[it].l_nchi[1]); - - this->atoms[it].l_nchi[2] = 1; - this->atoms[it].nw += (2*2 + 1) * this->atoms[it].l_nchi[2];*/ - // stringstream s2; - // s2 << "L=" << 2 << ", number of zeta"; - // OUT(ofs_running,s2.str(),atoms[it].l_nchi[2]);*/ - - } - - //OUT(ofs_running,"Total number of local orbitals",atoms[it].nw); - - //========================= - // (3) read in atom number - //========================= - READ_VALUE(ifpos, na); - this->atoms[it].na = na; - - OUT(ofs_running,"number of atom for this type",na); - - this->nat += na; - if (na <= 0) - { - WARNING("read_atom_positions"," atom number < 0."); - return 0; - } - if (na > 0) - { - delete[] atoms[it].tau; - delete[] atoms[it].taud; - delete[] atoms[it].mbl; - delete[] atoms[it].mag; - atoms[it].tau = new Vector3[na]; - atoms[it].taud = new Vector3[na]; - atoms[it].mbl = new Vector3[na]; - atoms[it].mag = new double[na]; - atoms[it].mass = this->atom_mass[it]; //mohan add 2011-11-07 - ZEROS(atoms[it].mag,na); - for (int ia = 0;ia < na; ia++) - { - if(use_xyz) - { - string tmpid; - ifpos >> tmpid; - if(tmpid != atoms[it].label) - { - WARNING("read_atom_positions","atom label not match"); - return 0; - } - else - { - ifpos >> v.x >> v.y >> v.z; - - mv.x = true; - mv.y = true; - mv.z = true; - - string mags; - std::getline( ifpos, mags ); - // change string to double. - //atoms[it].mag[ia] = std::atof(mags.c_str()); - atoms[it].mag[ia] = 0.0; - } - } - else - { - ifpos >> v.x >> v.y >> v.z - >> mv.x >> mv.y >> mv.z; - string mags; - std::getline( ifpos, mags ); - // change string to double. - //atoms[it].mag[ia] = std::atof(mags.c_str()); - atoms[it].mag[ia] = 0.0; - } - - if(Coordinate=="Direct") - { - // change v from direct to cartesian, - // the unit is pw.lat0 - atoms[it].taud[ia] = v; - atoms[it].tau[ia] = v * latvec; - } - else if(Coordinate=="Cartesian") - { - atoms[it].tau[ia] = v ;// in unit lat0 - //cout << " T=" << it << " I=" << ia << " tau=" << atoms[it].tau[ia].x << " " << - //atoms[it].tau[ia].y << " " << atoms[it].tau[ia].z << endl; - } - else if(Coordinate=="Cartesian_angstrom") - { - atoms[it].tau[ia] = v / 0.529177 / lat0; - } - else if(Coordinate=="Cartesian_angstrom_center_xy") - { - // calculate lattice center - latcenter.x = (latvec.e11 + latvec.e21 + latvec.e31)/2.0; - latcenter.y = (latvec.e12 + latvec.e22 + latvec.e32)/2.0; - latcenter.z = 0.0; - atoms[it].tau[ia] = v / 0.529177 / lat0 + latcenter; - } - else if(Coordinate=="Cartesian_angstrom_center_xz") - { - // calculate lattice center - latcenter.x = (latvec.e11 + latvec.e21 + latvec.e31)/2.0; - latcenter.y = 0.0; - latcenter.z = (latvec.e13 + latvec.e23 + latvec.e33)/2.0; - atoms[it].tau[ia] = v / 0.529177 / lat0 + latcenter; - } - else if(Coordinate=="Cartesian_angstrom_center_yz") - { - // calculate lattice center - latcenter.x = 0.0; - latcenter.y = (latvec.e12 + latvec.e22 + latvec.e32)/2.0; - latcenter.z = (latvec.e13 + latvec.e23 + latvec.e33)/2.0; - atoms[it].tau[ia] = v / 0.529177 / lat0 + latcenter; - } - else if(Coordinate=="Cartesian_angstrom_center_xyz") - { - // calculate lattice center - latcenter.x = (latvec.e11 + latvec.e21 + latvec.e31)/2.0; - latcenter.y = (latvec.e12 + latvec.e22 + latvec.e32)/2.0; - latcenter.z = (latvec.e13 + latvec.e23 + latvec.e33)/2.0; - atoms[it].tau[ia] = v / 0.529177 / lat0 + latcenter; - } - else if(Coordinate=="Cartesian_au") - { - atoms[it].tau[ia] = v / lat0; - } - - if(Coordinate=="Cartesian" || - Coordinate=="Cartesian_angstrom" || - Coordinate=="Cartesian_angstrom_center_xy" || - Coordinate=="Cartesian_angstrom_center_xz" || - Coordinate=="Cartesian_angstrom_center_yz" || - Coordinate=="Cartesian_angstrom_center_xyz" || - Coordinate=="Cartesian_au") - { - double dx,dy,dz; - Mathzone::Cartesian_to_Direct(atoms[it].tau[ia].x, atoms[it].tau[ia].y, atoms[it].tau[ia].z, - latvec.e11, latvec.e12, latvec.e13, - latvec.e21, latvec.e22, latvec.e23, - latvec.e31, latvec.e32, latvec.e33, - dx,dy,dz); - - atoms[it].taud[ia].x = dx; - atoms[it].taud[ia].y = dy; - atoms[it].taud[ia].z = dz; - - } - - atoms[it].mbl[ia] = mv; - }//endj - }// end na - }//end for ntype - }// end scan_begin - - - ofs_running << endl; - OUT(ofs_running,"TOTAL ATOM NUMBER",nat); - - // mohan add 2010-06-30 - //xiaohui modify 2015-03-15, cancel outputfile "STRU_READIN.xyz" - //this->print_cell_xyz("STRU_READIN.xyz"); - this->check_dtau(); - - if ( this->check_tau() ) - { - - } - else - { - return 0; - } - this->print_tau(); - //xiaohui modify 2015-03-15, cancel outputfile "STRU_READIN.xyz" - //this->print_cell_xyz("STRU_READIN_ADJUST.xyz"); - this->print_cell_cif("STRU_READIN_ADJUST.cif"); - - return 1; -}//end read_atom_positions - -bool UnitCell_pseudo::check_tau(void)const -{ - TITLE("UnitCell_pseudo","check_tau"); - timer::tick("UnitCell_pseudo","check_tau"); - - Vector3 diff = 0.0; - double norm = 0.0; - double tolerence_bohr = 1.0e-3; - - //ofs_running << "\n Output nearest atom not considering periodic boundary condition" << endl; - //ofs_running << " " << setw(5) << "TYPE" << setw(6) << "INDEX" - //<< setw(20) << "NEAREST(Bohr)" - //<< setw(20) << "NEAREST(Angstrom)" << endl; - for(int T1=0; T1< this->ntype; T1++) - { - for(int I1=0; I1< this->atoms[T1].na; I1++) - { - double shortest_norm = 10000.0; // a large number - //int nearest_atom_type = 0; - //int nearest_atom_index = 0; - for(int T2=0; T2ntype; T2++) - { - for(int I2=0; I2atoms[T2].na; I2++) - { - if(T1==T2 && I1==I2) - { - shortest_norm = 0.0; - //nearest_atom_type = T1; - //nearest_atom_index = I2; - // self atom - } - else - { - diff = atoms[T1].tau[I1] - atoms[T2].tau[I2]; - norm = diff.norm() * ucell.lat0; - if( shortest_norm > norm ) - { - shortest_norm = norm; - //nearest_atom_type = T2; - //nearest_atom_index = I2; - } - if( norm < tolerence_bohr ) // unit is Bohr - { - ofs_warning << " two atoms are too close!" << endl; - ofs_warning << " type:" << this->atoms[T1].label << " atom " << I1 + 1 << endl; - ofs_warning << " type:" << this->atoms[T2].label << " atom " << I2 + 1 << endl; - ofs_warning << " distance = " << norm << " Bohr" << endl; - return 0; - } - } - } - } - //ofs_running << " " << setw(5) << atoms[T1].label << setw(6) << I1+1 - //<< setw(20) << shortest_norm - //<< setw(20) << shortest_norm * BOHR_TO_A << endl; - } - } - - timer::tick("UnitCell_pseudo","check_tau"); - return 1; -} - -void UnitCell_pseudo::print_stru_file(const string &fn, const int &type)const -{ - TITLE("UnitCell_pseudo","print_stru_file"); - - if(MY_RANK!=0) return; - - ofstream ofs(fn.c_str()); - - ofs << "ATOMIC_SPECIES" << endl; - ofs << setprecision(12); - - for(int it=0; itpseudo_fn[i]; - //error = upf.read_pseudo_upf( pp_address ); xiaohui modify 2013-06-23 - error = upf.init_pseudo_reader( pp_address ); //xiaohui add 2013-06-23 - //average pseudopotential if needed - error_ap = upf.average_p(); //added by zhengdy 2020-10-20 - } -#ifdef __MPI - Parallel_Common::bcast_int(error); - Parallel_Common::bcast_int(error_ap); -#endif - - if(error_ap) WARNING_QUIT("UnitCell_pseudo::read_pseudopot","error when average the pseudopotential."); - - if(error==1) - { - cout << " Pseudopotential directory now is : " << pp_address << endl; - ofs_warning << " Pseudopotential directory now is : " << pp_address << endl; - WARNING_QUIT("UnitCell_pseudo::read_pseudopot","Couldn't find pseudopotential file."); - } - else if(error==2) - { - WARNING_QUIT("UnitCell_pseudo::read_pseudopot","Something in pseudopotential not match."); - } - else if(error==3) - { - //xiaohui modify 2015-03-25 - //WARNING_QUIT("UnitCell_pseudo::read_pseudopot","Please check the reference states in pseudopotential .vwr file.\n Also the norm of the read in pseudo wave functions\n explicitly please check S, P and D channels.\n If the norm of the wave function is \n unreasonable large (should be near 1.0), MESIA would quit. \n The solution is to turn off the wave functions \n and the corresponding non-local projectors together\n in .vwr pseudopotential file."); - WARNING_QUIT("UnitCell_pseudo::read_pseudopot","Please check the reference states in pseudopotential .vwr file.\n Also the norm of the read in pseudo wave functions\n explicitly please check S, P and D channels.\n If the norm of the wave function is \n unreasonable large (should be near 1.0), ABACUS would quit. \n The solution is to turn off the wave functions \n and the corresponding non-local projectors together\n in .vwr pseudopotential file."); - } -// OUT(ofs_running,"PP_ERRROR",error); - -//xiaohui add 2015-03-24 -#ifdef __MPI - Parallel_Common::bcast_bool(upf.functional_error); -#endif - //xiaohui add 2015-03-24 - if(upf.functional_error == 1) - { - WARNING_QUIT("Pseudopot_upf::read_pseudo_header","input xc functional does not match that in pseudopot file"); - } - - if(MY_RANK==0) - { -// upf.print_pseudo_upf( ofs ); - atoms[i].set_pseudo_us( upf ); - - ofs_running << "\n Read in pseudopotential file is " << pseudo_fn[i] << endl; - OUT(ofs_running,"pseudopotential type",atoms[i].pp_type); - OUT(ofs_running,"functional Ex", atoms[i].dft[0]); - OUT(ofs_running,"functional Ec", atoms[i].dft[1]); - OUT(ofs_running,"functional GCEx", atoms[i].dft[2]); - OUT(ofs_running,"functional GCEc", atoms[i].dft[3]); - OUT(ofs_running,"nonlocal core correction", atoms[i].nlcc); -// OUT(ofs_running,"spin orbital",atoms[i].has_so); - OUT(ofs_running,"valence electrons", atoms[i].zv); - OUT(ofs_running,"lmax", atoms[i].lmax); - OUT(ofs_running,"number of zeta", atoms[i].nchi); - OUT(ofs_running,"number of projectors", atoms[i].nbeta); - for(int ib=0; ibprint_cell(ofs); - for (int i = 0;i < ntype;i++) - { - atoms[i].print_Atom(ofs); - } - - ofs.close(); - return; -} - -int UnitCell_pseudo::find_type(const string &label) -{ - if(test_pseudo_cell) TITLE("UnitCell_pseudo","find_type"); - assert(ntype>0); - for(int it=0;ittaud[ia].x+10000) - int(atom1->taud[ia].x+10000); - double dy2 = (atom1->taud[ia].y+10000) - int(atom1->taud[ia].y+10000); - double dz2 = (atom1->taud[ia].z+10000) - int(atom1->taud[ia].z+10000); - - // mohan add 2011-04-07 - while(dx2 >= 1) - { - ofs_warning << " dx2 is >=1 " << endl; - dx2 -= 1.0; - } - while(dy2 >= 1) - { - ofs_warning << " dy2 is >=1 " << endl; - dy2 -= 1.0; - } - while(dz2 >= 1) - { - ofs_warning << " dz2 is >=1 " << endl; - dz2 -= 1.0; - } - // mohan add 2011-04-07 - while(dx2<0) - { - ofs_warning << " dx2 is <0 " << endl; - dx2 += 1.0; - } - while(dy2<0) - { - ofs_warning << " dy2 is <0 " << endl; - dy2 += 1.0; - } - while(dz2<0) - { - ofs_warning << " dz2 is <0 " << endl; - dz2 += 1.0; - } - - atom1->taud[ia].x = dx2; - atom1->taud[ia].y = dy2; - atom1->taud[ia].z = dz2; - - double cx2, cy2, cz2; - - Mathzone::Direct_to_Cartesian( - atom1->taud[ia].x, atom1->taud[ia].y, atom1->taud[ia].z, - latvec.e11, latvec.e12, latvec.e13, - latvec.e21, latvec.e22, latvec.e23, - latvec.e31, latvec.e32, latvec.e33, - cx2, cy2, cz2); - - atom1->tau[ia].x = cx2; - atom1->tau[ia].y = cy2; - atom1->tau[ia].z = cz2; - - // cout << setw(15) << dx2 << setw(15) << dy2 << setw(15) << dz2 - // << setw(15) << cx2 << setw(15) << cy2 << setw(15) << cz2 - // << endl; - - } - } - return; -} //LiuXh add a new function here, //20180515 From 400c26605055e1bca3f392ce37dd2d6250eec219 Mon Sep 17 00:00:00 2001 From: mohan Date: Sun, 28 Feb 2021 11:28:17 +0800 Subject: [PATCH 161/233] update formats in occupy.h and .cpp --- ABACUS.develop/see.txt | 17 ---- ABACUS.develop/source/src_pw/occupy.cpp | 124 +++++------------------- ABACUS.develop/source/src_pw/occupy.h | 40 +++++--- 3 files changed, 48 insertions(+), 133 deletions(-) delete mode 100644 ABACUS.develop/see.txt diff --git a/ABACUS.develop/see.txt b/ABACUS.develop/see.txt deleted file mode 100644 index d569f4508f..0000000000 --- a/ABACUS.develop/see.txt +++ /dev/null @@ -1,17 +0,0 @@ -diff -r source/src_pw/unitcell_pseudo.cpp /media/qianrui/work/LQR/test/abacus-develop/ABACUS.develop/source/src_pw/unitcell_pseudo.cpp -1264,1265c1264 -< if ( CALCULATION!="scf-sto" && CALCULATION!="relax-sto" && CALCULATION!="md-sto" ) //qianrui 2021-2-20 -< { ---- -> -1291,1295c1290,1293 -< if(NBANDS < mag.get_neldw() ) -< { -< WARNING_QUIT("unitcell","Too few spin down bands!"); -< } -< } ---- -> if(NBANDS < mag.get_neldw() ) -> { -> WARNING_QUIT("unitcell","Too few spin down bands!"); -> } diff --git a/ABACUS.develop/source/src_pw/occupy.cpp b/ABACUS.develop/source/src_pw/occupy.cpp index 5cdf7f88e1..2cc62ecef9 100644 --- a/ABACUS.develop/source/src_pw/occupy.cpp +++ b/ABACUS.develop/source/src_pw/occupy.cpp @@ -6,30 +6,30 @@ Occupy::Occupy(){} Occupy::~Occupy(){} //=========================================================== -// There are four smearing methods: -// (1) not do anything, +// Four smearing methods: +// (1) do nothing // (2) gaussian_broadening method (need 'degauss' value). // (3) tetrahedron method // (4) fixed_occupations //=========================================================== bool Occupy::use_gaussian_broadening = false; -int Occupy::gaussian_type ; +int Occupy::gaussian_type; double Occupy::gaussian_parameter; bool Occupy::use_tetrahedron_method = false; bool Occupy::fixed_occupations = false; + void Occupy::calculate_weights(void) { TITLE("Occupy","calculate_weights"); + // for test // cout << " gaussian_broadening = " << use_gaussian_broadening << endl; // cout << " tetrahedron_method = " << use_tetrahedron_method << endl; // cout << " fixed_occupations = " << fixed_occupations << endl; - // mohan add 2011/09/30 - //if(DIAGO_TYPE=="selinv") xiaohui modify 2013-09-02 - if(KS_SOLVER=="selinv") //xiaohui add 2013-09-02 + if(KS_SOLVER=="selinv") { ofs_running << " Could not calculate occupation." << endl; return; @@ -61,7 +61,6 @@ void Occupy::calculate_weights(void) } else if (use_gaussian_broadening) { - // mohan add 2011-04-02 if (TWO_EFERMI) { double demet_up = 0.0; @@ -80,7 +79,6 @@ void Occupy::calculate_weights(void) wf.ekb, en.ef, en.demet, wf.wg, -1, kv.isk); } - //cout << "en.demet = " <(ni) * h0 ; ni++; h1 = 2.00 * x * h0 - 2.00 * static_cast(ni) * h1 ; - - //cout << " a = " <(ni) * h0m1 ) * hp ; - // cout << " w1 == "< &r, Vector3 *rws,const int nrws) { //============================================================ @@ -1152,5 +1076,3 @@ void Occupy::piksort(const int n, double *a) } return; } //end subroutine piksort - - diff --git a/ABACUS.develop/source/src_pw/occupy.h b/ABACUS.develop/source/src_pw/occupy.h index 20c4c31e14..65a73cd380 100644 --- a/ABACUS.develop/source/src_pw/occupy.h +++ b/ABACUS.develop/source/src_pw/occupy.h @@ -1,5 +1,3 @@ -// AUTHOR : Mohan Chen -// UPDATE LAST TIME : 2010-1-9 #ifndef OCCUPY_H #define OCCUPY_H @@ -10,7 +8,8 @@ using namespace std; class Occupy { - friend class Chi0_hilbert; // pengfei 2016-11-23 + // pengfei 2016-11-23 + friend class Chi0_hilbert; public: @@ -21,13 +20,18 @@ class Occupy static void decision(const string &name,const string &smearing,const double °auss); - static const bool& gauss(void) { + static const bool& gauss(void) + { return use_gaussian_broadening; } - static const bool& tetra(void) { + + static const bool& tetra(void) + { return use_tetrahedron_method; } - static const bool& fix(void) { + + static const bool& fix(void) + { return fixed_occupations; } @@ -45,23 +49,30 @@ class Occupy static bool fixed_occupations; static void iweights(const int nks,const double *wk,const int nband, - const double &nelec, double **ekb, double &ef, matrix &wg, const int &is, const int *isk); + const double &nelec, double **ekb, double &ef, + matrix &wg, const int &is, const int *isk); - static void gweights(const int nks,const double *wk,const int nband,const double &nelec,const double °auss, - const int ngauss,double **ekb, double &ef, double &demet, matrix &wg, const int &is, const int *isk); + static void gweights(const int nks,const double *wk,const int nband, + const double &nelec,const double °auss, + const int ngauss,double **ekb, double &ef, + double &demet, matrix &wg, const int &is, const int *isk); - static void tweights(const int nks,const int nspin,const int nband,const double &nelec,const int ntetra, + static void tweights(const int nks,const int nspin,const int nband, + const double &nelec,const int ntetra, const matrix &tetra,double **ekb,double &ef,matrix &wg); static double wsweight(const Vector3 &r, Vector3 *rws,const int nrws); private: - static void efermig(double **ekb,const int nbnd,const int nks,const double &nelec,const double *wk, - const double °auss,const int ngauss,double &ef, const int &is, const int *isk); + static void efermig(double **ekb,const int nbnd,const int nks, + const double &nelec,const double *wk, + const double °auss,const int ngauss, + double &ef, const int &is, const int *isk); - static double sumkg(double **ekb,const int nband,const int nks,const double *wk,const double °auss, - const int ngauss,const double &e, const int &is, const int *isk); + static double sumkg(double **ekb,const int nband,const int nks, + const double *wk,const double °auss, const int ngauss, + const double &e, const int &is, const int *isk); static double wgauss(const double &x,const int n); @@ -79,7 +90,6 @@ class Occupy const matrix &tetra,const double &eup); static void piksort(const int n, double *a); - }; #endif From 1ceec3173a15e702b8823905102feed2c17ef73a Mon Sep 17 00:00:00 2001 From: linpz Date: Sun, 28 Feb 2021 16:30:52 +0800 Subject: [PATCH 162/233] 1. change macro TEST_LIBXC to USE_LIBXC 2. add comments in Potential_Libxc --- ABACUS.develop/source/Makefile | 4 +- ABACUS.develop/source/src_lcao/force_lcao.cpp | 2 +- ABACUS.develop/source/src_pw/potential.cpp | 2 +- .../source/src_pw/potential_libxc.cpp | 56 +++++++++++-------- .../source/src_pw/potential_libxc.h | 18 ++++-- 5 files changed, 51 insertions(+), 31 deletions(-) diff --git a/ABACUS.develop/source/Makefile b/ABACUS.develop/source/Makefile index a95386b1b8..f6f828d6f8 100644 --- a/ABACUS.develop/source/Makefile +++ b/ABACUS.develop/source/Makefile @@ -23,8 +23,8 @@ HONG_SER_SELINV = -D__FP ${HONG_FFTW} -D__SELINV HONG_GDB = -g -D__FP ${HONG_FFTW} #(2)mpi HONG_MPI = -D__FP ${HONG_FFTW} -D__MPI -# mohan comment out 2021-02-06, add -DTEST_LIBXC=0 if you want to use LIBXC -#HONG_MPI_SELINV = -D__FP ${HONG_FFTW} -D__MPI -D__SELINV -DMETIS -DMKL_ILP64 -DEXX_DM=3 -DEXX_H_COMM=2 -DTEST_LIBXC=0 -DTEST_EXX_LCAO=0 -DTEST_EXX_RADIAL=1 -DUSE_CEREAL_SERIALIZATION +# mohan comment out 2021-02-06, add -DUSE_LIBXC=0 if you want to use LIBXC +#HONG_MPI_SELINV = -D__FP ${HONG_FFTW} -D__MPI -D__SELINV -DMETIS -DMKL_ILP64 -DEXX_DM=3 -DEXX_H_COMM=2 -DUSE_LIBXC=0 -DTEST_EXX_LCAO=0 -DTEST_EXX_RADIAL=1 -DUSE_CEREAL_SERIALIZATION HONG_MPI_SELINV = -D__FP ${HONG_FFTW} -D__MPI -D__SELINV -DMETIS -DMKL_ILP64 -DEXX_DM=3 -DEXX_H_COMM=2 -DTEST_EXX_LCAO=0 -DTEST_EXX_RADIAL=1 -DUSE_CEREAL_SERIALIZATION #(3)memory HONG_MEM = ${HONG_FFTW} -D__FP -D_MCD_CHECK -DWIN32 -DMCD_VERBOSE diff --git a/ABACUS.develop/source/src_lcao/force_lcao.cpp b/ABACUS.develop/source/src_lcao/force_lcao.cpp index 7a366c52bf..39ecacab8a 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/force_lcao.cpp @@ -726,7 +726,7 @@ void Force_LCAO::cal_force_cc(void) timer::tick("Force_LCAO","cal_force_cc",'E'); // recalculate the exchange-correlation potential. matrix vxc(NSPIN, pw.nrxx); - #ifdef TEST_LIBXC + #ifdef USE_LIBXC Potential_Libxc::v_xc(CHR.rho, en.etxc, en.vtxc, vxc); #else H_XC_pw::v_xc(pw.nrxx, pw.ncxyz, ucell.omega, CHR.rho, CHR.rho_core, vxc); diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index f474a351a8..66b6301e2b 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -272,7 +272,7 @@ void potential::v_of_rho // calculate the exchange-correlation potential //---------------------------------------------------------- - #ifdef TEST_LIBXC + #ifdef USE_LIBXC Potential_Libxc::v_xc(rho_in, en.etxc, en.vtxc, v_in); #else H_XC_pw::v_xc(pw.nrxx, pw.ncxyz, ucell.omega, rho_in, CHR.rho_core, v_in); diff --git a/ABACUS.develop/source/src_pw/potential_libxc.cpp b/ABACUS.develop/source/src_pw/potential_libxc.cpp index 94cb9af5b0..955d23ae0e 100644 --- a/ABACUS.develop/source/src_pw/potential_libxc.cpp +++ b/ABACUS.develop/source/src_pw/potential_libxc.cpp @@ -1,4 +1,11 @@ -#ifdef TEST_LIBXC +//========================================================== +// AUTHOR : Peize Lin +// DATE : 2017-09-14 +// UPDATE : 2021-02-28 +//========================================================== + +#ifdef USE_LIBXC + #include "potential_libxc.h" #include "src_pw/global.h" #include "src_lcao/global_fp.h" @@ -7,7 +14,7 @@ #include "src_pw/gga_pw.h" void Potential_Libxc::v_xc( - const double * const * const rho_in, + const double * const * const rho_in, // 此输入å¯èƒ½è®©äººè¯¯ä»¥ä¸ºè¾“入仅有此rho_in,然而程åºä¸­è¿˜ç”¨äº†chr.rho_core。该写法仅为了匹é…potential::v_xc,é‡ä¼°æ—¶éœ€è¦ä¿®æ”¹ã€‚ double &etxc, double &vtxc, matrix &v) @@ -21,6 +28,7 @@ void Potential_Libxc::v_xc( vector funcs = init_func(); + // [rho, sigma, gdr] = cal_input( funcs, rho_in ); const auto input_tmp = cal_input( funcs, rho_in ); const vector &rho = std::get<0>(input_tmp); const vector &sigma = std::get<1>(input_tmp); @@ -31,6 +39,7 @@ void Potential_Libxc::v_xc( vector vrho ( pw.nrxx * nspin0() ); vector vsigma( pw.nrxx * ((1==nspin0())?1:3) ); + // cal etxc from rho, exc auto process_exc = [&](vector &sgn) { for( size_t is=0; is!=nspin0(); ++is ) @@ -42,6 +51,7 @@ void Potential_Libxc::v_xc( } }; + // cal vtx, v from rho_in, vrho auto process_vrho = [&](vector &sgn) { if(nspin0()==1 || NSPIN==2) @@ -56,7 +66,7 @@ void Potential_Libxc::v_xc( } } } - else + else // 修改了socåŽï¼Œè¿™é‡Œå¯èƒ½éœ€è¦ä¿®æ”¹ { constexpr double vanishing_charge = 1.0e-12; for( size_t ir=0; ir!=pw.nrxx; ++ir ) @@ -82,6 +92,8 @@ void Potential_Libxc::v_xc( } }; + + // cal vtxc, v from rho_in, rho, gdr, vsigma auto process_vsigma = [&](vector &sgn) { const std::vector>> &gdr = std::get<2>(input_tmp); @@ -99,9 +111,9 @@ void Potential_Libxc::v_xc( for( size_t ir=0; ir!=pw.nrxx; ++ir ) { h[0][ir] = e2 * (gdr[0][ir] * vsigma[ir*3 ] * 2.0 - * sgn[ir*2 ] + gdr[1][ir] * vsigma[ir*3+1] * sgn[ir*2] * sgn[ir*2+1]); + * sgn[ir*2 ] + gdr[1][ir] * vsigma[ir*3+1] * sgn[ir*2] * sgn[ir*2+1]); h[1][ir] = e2 * (gdr[1][ir] * vsigma[ir*3+2] * 2.0 - * sgn[ir*2+1] + gdr[0][ir] * vsigma[ir*3+1] * sgn[ir*2] * sgn[ir*2+1]); + * sgn[ir*2+1] + gdr[0][ir] * vsigma[ir*3+1] * sgn[ir*2] * sgn[ir*2+1]); } } @@ -130,15 +142,15 @@ void Potential_Libxc::v_xc( } } } - else + else // 修改了socåŽï¼Œè¿™é‡Œå¯èƒ½éœ€è¦ä¿®æ”¹ { constexpr double vanishing_charge = 1.0e-12; for( size_t ir=0; ir!=pw.nrxx; ++ir ) { v(0,ir) -= 0.5 * (dh[0][ir] + dh[1][ir]); const double amag = sqrt( pow(rho_in[1][ir],2) + pow(rho_in[2][ir],2) + pow(rho_in[3][ir],2) ); - const double neg = (soc.lsign && rho_in[1][ir]*soc.ux[0] - +rho_in[2][ir]*soc.ux[1]+rho_in[3][ir]*soc.ux[2]<=0) ? -1 : 1; + const double neg = (soc.lsign && rho_in[1][ir]*soc.ux[0]+rho_in[2][ir]*soc.ux[1]+rho_in[3][ir]*soc.ux[2]<=0) + ? -1 : 1; if(amag > vanishing_charge) { for(int i=1;i<4;i++) @@ -150,13 +162,11 @@ void Potential_Libxc::v_xc( } }; + // jiyy add for threshold constexpr double rho_threshold = 1E-6; constexpr double grho_threshold = 1E-10; - xc_func_set_dens_threshold(&func, rho_threshold); - vector sgn( pw.nrxx * nspin0(), 1.0); - if(nspin0()==2 && func.info->family != XC_FAMILY_LDA && func.info->kind==XC_CORRELATION) { for( size_t ir=0; ir!=pw.nrxx; ++ir ) @@ -208,7 +218,8 @@ void Potential_Libxc::v_xc( } - +// 未æ¥ä¸æ–­å¢žåŠ xc泛函时,åªéœ€è¦ä¿®æ”¹æ­¤å‡½æ•°å³å¯ +// abacus中对泛函的指代目å‰ä¸ºxcf中的iexchã€igcxã€icorrã€igcc,å¯èƒ½éœ€è¦æ”¹è¿›ã€‚如果未æ¥ç¡®å®šæ†ç»‘libxc,å¯ä»¥æ”¹ä¸ºç”¨libxcçš„å®å®šä¹‰æ¥æŒ‡ä»£ã€‚ std::vector Potential_Libxc::init_func() { std::vector funcs; @@ -273,6 +284,7 @@ std::vector Potential_Libxc::init_func() +// [rho, sigma, gdr] = cal_input( funcs, rho_in ) std::tuple< std::vector, std::vector, std::vector>> > Potential_Libxc::cal_input( const std::vector &funcs, @@ -280,15 +292,8 @@ Potential_Libxc::cal_input( { // ..., ↑_{i},↓_{i}, ↑_{i+1},↓_{i+1}, ... std::vector rho; - // ..., ↑↑_{i},↑↓_{i},↓↓_{i}, ↑↑_{i+1},↑↓_{i+1},↓↓_{i+1}, ... - std::vector sigma; - // [...,↑_{i},↑_{i+1},...], [...,↓_{i},↓_{i+1},...] - std::vector>> gdr; - bool finished_rho = false; - bool finished_gdr = false; - bool finished_sigma = false; - + // 这里å‡å®šCHR.rho_coreå‡åˆ†åˆ°è‡ªæ—‹ä¸Šã€‚å¯èƒ½æœ‰è¯¯ auto cal_rho = [&]() { if(!finished_rho) @@ -304,7 +309,7 @@ Potential_Libxc::cal_input( } } } - else + else // 修改了socåŽï¼Œè¿™é‡Œå¯èƒ½éœ€è¦ä¿®æ”¹ { if(xcf.igcx||xcf.igcc) { @@ -324,6 +329,9 @@ Potential_Libxc::cal_input( finished_rho = true; }; + // [...,↑_{i},↑_{i+1},...], [...,↓_{i},↓_{i+1},...] + std::vector>> gdr; + bool finished_gdr = false; auto cal_gdr = [&]() { if(!finished_gdr) @@ -346,6 +354,9 @@ Potential_Libxc::cal_input( finished_gdr = true; }; + // ..., ↑↑_{i},↑↓_{i},↓↓_{i}, ↑↑_{i+1},↑↓_{i+1},↓↓_{i+1}, ... + std::vector sigma; + bool finished_sigma = false; auto cal_sigma = [&]() { if(!finished_sigma) @@ -395,4 +406,5 @@ Potential_Libxc::cal_input( return std::make_tuple( rho, sigma, gdr ); } -#endif + +#endif //ifdef USE_LIBXC diff --git a/ABACUS.develop/source/src_pw/potential_libxc.h b/ABACUS.develop/source/src_pw/potential_libxc.h index 04bda075e9..f46e1ef3c8 100644 --- a/ABACUS.develop/source/src_pw/potential_libxc.h +++ b/ABACUS.develop/source/src_pw/potential_libxc.h @@ -1,4 +1,11 @@ -#ifdef TEST_LIBXC +//========================================================== +// AUTHOR : Peize Lin +// DATE : 2017-09-14 +// UPDATE : 2021-02-28 +//========================================================== + +#ifdef USE_LIBXC + #ifndef POTENTIAL_LIBXC_H #define POTENTIAL_LIBXC_H @@ -23,17 +30,17 @@ class Potential_Libxc private: static std::vector init_func(); - // [ rho, sigma, gdr ] + // [rho, sigma, gdr] = cal_input( funcs, rho_in ) static std::tuple< std::vector, std::vector, std::vector>> > - cal_input( + cal_input( const std::vector &funcs, const double * const * const rho_in ); - static int nspin0() + static int nspin0() // 修改了soc判æ®åŽï¼Œè¿™é‡Œå¯èƒ½éœ€è¦ä¿®æ”¹ { if (NSPIN==1 || (NSPIN==4 && (!DOMAG && !DOMAG_Z))) return 1; else if(NSPIN==2 || (NSPIN==4 && ( DOMAG || DOMAG_Z))) return 2; @@ -42,4 +49,5 @@ class Potential_Libxc }; #endif -#endif + +#endif // ifdef USE_LIBXC From e0f4e31de65569d534769ba2da3f788b5eda4b27 Mon Sep 17 00:00:00 2001 From: mohan Date: Sun, 28 Feb 2021 22:09:58 +0800 Subject: [PATCH 163/233] update potential_libxc --- .../source/src_pw/potential_libxc.cpp | 47 ++++++++++++++----- .../source/src_pw/potential_libxc.h | 2 +- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/ABACUS.develop/source/src_pw/potential_libxc.cpp b/ABACUS.develop/source/src_pw/potential_libxc.cpp index 955d23ae0e..72bec55a30 100644 --- a/ABACUS.develop/source/src_pw/potential_libxc.cpp +++ b/ABACUS.develop/source/src_pw/potential_libxc.cpp @@ -14,7 +14,7 @@ #include "src_pw/gga_pw.h" void Potential_Libxc::v_xc( - const double * const * const rho_in, // 此输入å¯èƒ½è®©äººè¯¯ä»¥ä¸ºè¾“入仅有此rho_in,然而程åºä¸­è¿˜ç”¨äº†chr.rho_core。该写法仅为了匹é…potential::v_xc,é‡ä¼°æ—¶éœ€è¦ä¿®æ”¹ã€‚ + const double * const * const rho_in, // CHR.rho_core may be needed in future double &etxc, double &vtxc, matrix &v) @@ -26,6 +26,12 @@ void Potential_Libxc::v_xc( vtxc = 0.0; v.zero_out(); + //---------------------------------------------------------- + // xc_func_type is defined in Libxc package + // to understand the usage of xc_func_type, + // use can check on website, for example: + // https://www.tddft.org/programs/libxc/manual/libxc-5.1.x/ + //---------------------------------------------------------- vector funcs = init_func(); // [rho, sigma, gdr] = cal_input( funcs, rho_in ); @@ -66,7 +72,7 @@ void Potential_Libxc::v_xc( } } } - else // 修改了socåŽï¼Œè¿™é‡Œå¯èƒ½éœ€è¦ä¿®æ”¹ + else // may need updates for SOC { constexpr double vanishing_charge = 1.0e-12; for( size_t ir=0; ir!=pw.nrxx; ++ir ) @@ -142,15 +148,15 @@ void Potential_Libxc::v_xc( } } } - else // 修改了socåŽï¼Œè¿™é‡Œå¯èƒ½éœ€è¦ä¿®æ”¹ + else // may need updates for SOC { constexpr double vanishing_charge = 1.0e-12; for( size_t ir=0; ir!=pw.nrxx; ++ir ) { v(0,ir) -= 0.5 * (dh[0][ir] + dh[1][ir]); const double amag = sqrt( pow(rho_in[1][ir],2) + pow(rho_in[2][ir],2) + pow(rho_in[3][ir],2) ); - const double neg = (soc.lsign && rho_in[1][ir]*soc.ux[0]+rho_in[2][ir]*soc.ux[1]+rho_in[3][ir]*soc.ux[2]<=0) - ? -1 : 1; + const double neg = (soc.lsign && rho_in[1][ir]*soc.ux[0] + +rho_in[2][ir]*soc.ux[1]+rho_in[3][ir]*soc.ux[2]<=0) ? -1 : 1; if(amag > vanishing_charge) { for(int i=1;i<4;i++) @@ -166,6 +172,8 @@ void Potential_Libxc::v_xc( constexpr double rho_threshold = 1E-6; constexpr double grho_threshold = 1E-10; xc_func_set_dens_threshold(&func, rho_threshold); + + // LPZ: Explain what is sgn vector sgn( pw.nrxx * nspin0(), 1.0); if(nspin0()==2 && func.info->family != XC_FAMILY_LDA && func.info->kind==XC_CORRELATION) { @@ -218,8 +226,8 @@ void Potential_Libxc::v_xc( } -// 未æ¥ä¸æ–­å¢žåŠ xc泛函时,åªéœ€è¦ä¿®æ”¹æ­¤å‡½æ•°å³å¯ -// abacus中对泛函的指代目å‰ä¸ºxcf中的iexchã€igcxã€icorrã€igcc,å¯èƒ½éœ€è¦æ”¹è¿›ã€‚如果未æ¥ç¡®å®šæ†ç»‘libxc,å¯ä»¥æ”¹ä¸ºç”¨libxcçš„å®å®šä¹‰æ¥æŒ‡ä»£ã€‚ +// for adding new xc functionals, only this function needs to be updated +// now we use iexch, igcx, icorr, igcc in xcf to characterize XC functionals std::vector Potential_Libxc::init_func() { std::vector funcs; @@ -285,7 +293,9 @@ std::vector Potential_Libxc::init_func() // [rho, sigma, gdr] = cal_input( funcs, rho_in ) -std::tuple< std::vector, std::vector, std::vector>> > +std::tuple< std::vector, + std::vector, + std::vector>> > Potential_Libxc::cal_input( const std::vector &funcs, const double * const * const rho_in ) @@ -293,7 +303,8 @@ Potential_Libxc::cal_input( // ..., ↑_{i},↓_{i}, ↑_{i+1},↓_{i+1}, ... std::vector rho; bool finished_rho = false; - // 这里å‡å®šCHR.rho_coreå‡åˆ†åˆ°è‡ªæ—‹ä¸Šã€‚å¯èƒ½æœ‰è¯¯ + + // here we assume CHR.rho_core equally exists in different spins, may need double check auto cal_rho = [&]() { if(!finished_rho) @@ -309,7 +320,7 @@ Potential_Libxc::cal_input( } } } - else // 修改了socåŽï¼Œè¿™é‡Œå¯èƒ½éœ€è¦ä¿®æ”¹ + else // may need updates for SOC { if(xcf.igcx||xcf.igcc) { @@ -331,7 +342,7 @@ Potential_Libxc::cal_input( // [...,↑_{i},↑_{i+1},...], [...,↓_{i},↓_{i+1},...] std::vector>> gdr; - bool finished_gdr = false; + bool finished_gdr = false; auto cal_gdr = [&]() { if(!finished_gdr) @@ -344,9 +355,23 @@ Potential_Libxc::cal_input( { rhor[ir] = rho[ir*nspin0()+is]; } + + //------------------------------------------ + // initialize the charge density arry in + // reciprocal space + //------------------------------------------ vector> rhog(pw.ngmc); + + //------------------------------------------- + // bring electron charge density from real + // space to reciprocal space + //------------------------------------------- CHR.set_rhog(rhor.data(), rhog.data()); + //------------------------------------------- + // compute the gradient of charge density and + // store the gradient in gdr[is] + //------------------------------------------- gdr[is].resize(pw.nrxx); GGA_PW::grad_rho(rhog.data(), gdr[is].data()); } diff --git a/ABACUS.develop/source/src_pw/potential_libxc.h b/ABACUS.develop/source/src_pw/potential_libxc.h index f46e1ef3c8..869e4c8713 100644 --- a/ABACUS.develop/source/src_pw/potential_libxc.h +++ b/ABACUS.develop/source/src_pw/potential_libxc.h @@ -40,7 +40,7 @@ class Potential_Libxc const std::vector &funcs, const double * const * const rho_in ); - static int nspin0() // 修改了soc判æ®åŽï¼Œè¿™é‡Œå¯èƒ½éœ€è¦ä¿®æ”¹ + static int nspin0() // may need updates from SOC { if (NSPIN==1 || (NSPIN==4 && (!DOMAG && !DOMAG_Z))) return 1; else if(NSPIN==2 || (NSPIN==4 && ( DOMAG || DOMAG_Z))) return 2; From d00cc203849d04e99e5526af032e0af23be4846d Mon Sep 17 00:00:00 2001 From: zdy Date: Sun, 28 Feb 2021 23:26:07 +0800 Subject: [PATCH 164/233] zhengdy refactor the STRESS calculation module --- ABACUS.develop/source/Makefile.Objects | 10 +- ABACUS.develop/source/src_lcao/force_lcao.cpp | 17 +- .../source/src_lcao/stress_lcao.cpp | 1297 +++-------------- ABACUS.develop/source/src_lcao/stress_lcao.h | 60 +- ABACUS.develop/source/src_pw/H_Ewald_pw.h | 3 +- ABACUS.develop/source/src_pw/H_XC_pw.h | 5 +- ABACUS.develop/source/src_pw/ions.cpp | 41 +- .../source/src_pw/pseudopot_cell_vnl.h | 2 +- ABACUS.develop/source/src_pw/stress_func.h | 127 ++ .../source/src_pw/stress_func_cc.cpp | 170 +++ .../source/src_pw/stress_func_ewa.cpp | 159 ++ .../source/src_pw/stress_func_gga.cpp | 235 +++ .../source/src_pw/stress_func_har.cpp | 143 ++ .../source/src_pw/stress_func_kin.cpp | 167 +++ .../source/src_pw/stress_func_loc.cpp | 227 +++ .../source/src_pw/stress_func_nl.cpp | 540 +++++++ .../source/src_pw/stress_func_print.cpp | 104 ++ ABACUS.develop/source/src_pw/stress_pw.cpp | 123 ++ ABACUS.develop/source/src_pw/stress_pw.h | 23 + ABACUS.develop/source/src_pw/symmetry.cpp | 14 +- ABACUS.develop/source/src_pw/symmetry.h | 2 +- 21 files changed, 2275 insertions(+), 1194 deletions(-) create mode 100644 ABACUS.develop/source/src_pw/stress_func.h create mode 100644 ABACUS.develop/source/src_pw/stress_func_cc.cpp create mode 100644 ABACUS.develop/source/src_pw/stress_func_ewa.cpp create mode 100644 ABACUS.develop/source/src_pw/stress_func_gga.cpp create mode 100644 ABACUS.develop/source/src_pw/stress_func_har.cpp create mode 100644 ABACUS.develop/source/src_pw/stress_func_kin.cpp create mode 100644 ABACUS.develop/source/src_pw/stress_func_loc.cpp create mode 100644 ABACUS.develop/source/src_pw/stress_func_nl.cpp create mode 100644 ABACUS.develop/source/src_pw/stress_func_print.cpp create mode 100644 ABACUS.develop/source/src_pw/stress_pw.cpp create mode 100644 ABACUS.develop/source/src_pw/stress_pw.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 197b1f4cf0..60a1235820 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -41,7 +41,15 @@ unitcell_pseudo.o\ threshold_elec.o\ electrons.o \ forces.o\ -stress.o\ +stress_pw.o\ +stress_func_cc.o\ +stress_func_gga.o\ +stress_func_kin.o\ +stress_func_nl.o\ +stress_func_ewa.o\ +stress_func_har.o\ +stress_func_loc.o\ +stress_func_print.o\ chi0_hilbert.o\ chi0_standard.o\ epsilon0_pwscf.o\ diff --git a/ABACUS.develop/source/src_lcao/force_lcao.cpp b/ABACUS.develop/source/src_lcao/force_lcao.cpp index 39ecacab8a..926e5f09bd 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/force_lcao.cpp @@ -726,7 +726,7 @@ void Force_LCAO::cal_force_cc(void) timer::tick("Force_LCAO","cal_force_cc",'E'); // recalculate the exchange-correlation potential. matrix vxc(NSPIN, pw.nrxx); - #ifdef USE_LIBXC + #ifdef TEST_LIBXC Potential_Libxc::v_xc(CHR.rho, en.etxc, en.vtxc, vxc); #else H_XC_pw::v_xc(pw.nrxx, pw.ncxyz, ucell.omega, CHR.rho, CHR.rho_core, vxc); @@ -933,8 +933,7 @@ void Force_LCAO::cal_stress(matrix &stress) TITLE("Force_LCAO","cal_stress"); Stress_LCAO SS; - SS.allocate(); - SS.start_stress(this->soverlap, this->stvnl_dphi, this->svnl_dbeta, this->svl_dphi, this->stress_vdw); + SS.start_stress(this->soverlap, this->stvnl_dphi, this->svnl_dbeta, this->svl_dphi, this->stress_vdw, stress); double unit_transform = 0.0; unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * 1.0e-8; @@ -944,21 +943,15 @@ void Force_LCAO::cal_stress(matrix &stress) { for(int j=0;j<3;j++) { - stress(i,j) = SS.scs[i][j]; //quxin added for DFT+U; stress contribution from DFT+U - if(INPUT.dft_plus_u) if(i!=j) stress(i,j) += dftu.stress_dftu.at(i).at(j); + if(INPUT.dft_plus_u) stress(i,j) += dftu.stress_dftu.at(i).at(j); } - stress(i,i) = SS.scs[i][i] - external_stress[i]/unit_transform; + stress(i,i) -= external_stress[i]/unit_transform; - if(INPUT.dft_plus_u) stress(i,i) += dftu.stress_dftu.at(i).at(i); } - PRESSURE = (SS.scs[0][0]+SS.scs[1][1]+SS.scs[2][2])/3; + PRESSURE = (stress(0,0)+stress(1,1)+stress(2,2))/3; - if(INPUT.dft_plus_u) - { - PRESSURE += (dftu.stress_dftu.at(0).at(0) + dftu.stress_dftu.at(1).at(1) + dftu.stress_dftu.at(2).at(2))/3.0; - } return; } diff --git a/ABACUS.develop/source/src_lcao/stress_lcao.cpp b/ABACUS.develop/source/src_lcao/stress_lcao.cpp index 242fd92734..64077a4e25 100644 --- a/ABACUS.develop/source/src_lcao/stress_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/stress_lcao.cpp @@ -1,1093 +1,204 @@ -#include "stress_lcao.h" -#include "../src_pw/global.h" -#include "../src_pw/xc_functional.h" -#include "../src_pw/xc_gga_pw.h" -#include "src_pw/myfunc.h" -// new -#include "src_pw/H_Hartree_pw.h" -#include "src_pw/H_XC_pw.h" - -double Stress_LCAO::stress_invalid_threshold_ev = 0.00; - -Stress_LCAO::Stress_LCAO () -{ - allocate_flag = false; - output_acc = 1.0e-8; -} - -Stress_LCAO::~Stress_LCAO () -{ - this->destroy(); -} - -void Stress_LCAO::destroy (void) -{ - if (allocate_flag) - { - - allocate_flag = false; - } -} - -void Stress_LCAO::allocate(void) -{ - TITLE("Stress_LCAO","init"); - - if (allocate_flag) - { - this->destroy(); - } - - allocate_flag = true; - return; -} - -#include "../src_pw/efield.h" -#include "../src_pw/stress.h" -// be called in : Local_Orbital_Ions::force_stress -void Stress_LCAO::start_stress(double overlap[][3],double tvnl_dphi[][3],double vnl_dbeta[][3],double vl_dphi[][3], const matrix& stress_vdw) -{ - TITLE("Stress_LCAO","start_stress"); - timer::tick("Stress_LCAO","start_stress",'E'); - - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - scs[i][j] = 0.0; - soverlap[i][j] = overlap[i][j]; - stvnl_dphi[i][j] = tvnl_dphi[i][j]; - svnl_dbeta[i][j] = vnl_dbeta[i][j]; - svl_dphi[i][j] = vl_dphi[i][j]; - sigmacc[i][j] = 0.0; - sigmadvl[i][j] = 0.0; - sigmaewa[i][j] = 0.0; - sigmaxc[i][j] = 0.0; - sigmahar[i][j] = 0.0; - } - } - //-------------------------------------------------------- - // local pseudopotential stress: - // use charge density; plane wave; local pseudopotential; - //-------------------------------------------------------- - this->cal_stress_loc (); - - //-------------------------------------------------------- - //hartree term - //-------------------------------------------------------- - this->cal_stress_har (); - - //-------------------------------------------------------- - // ewald stress: use plane wave only. - //-------------------------------------------------------- - this->cal_stress_ew (); //remain problem - - - //-------------------------------------------------------- - // stress due to core correlation. - //-------------------------------------------------------- - this->cal_stress_cc(); - - //-------------------------------------------------------- - // stress due to self-consistent charge. - //-------------------------------------------------------- - for(int i=0;i<3;i++) - { - // sigmaxc[i][i] = - (en.etxc-en.vtxc) / ucell.omega; - sigmaxc[i][i] = -(H_XC_pw::etxc) / ucell.omega; - - // sigmahar[i][i] = en.ehart /ucell.omega; - - } - //Exchange-correlation for PBE - cal_stress_gradcorr(); - - //-------------------------------------------------------- - // need to move atom positions here. - //-------------------------------------------------------- - if(GAMMA_ONLY_LOCAL) - { -// this->stable_gamma(); - } - else - { -// this->stable_k(); - } - -/* if(vdwd2.vdwD2) //Peize Lin add 2014-04-04, update 2019-04-26 - { - vdwd2.stress(); - } -*/ -/* if(vdwd3.vdwD3) //jiyy add 2019-05-18 - { - vdwd3.stress(); - } -*/ -/* matrix sefield; - if(EFIELD) - { - sefield.create(3, 3); - Efield::compute_stress(sefield); - }*/ - - for(int i=0; i<3; i++) - { - for (int j=0;j<3;j++) - { - scs[i][j] += soverlap[i][j] - + stvnl_dphi[i][j] - + svnl_dbeta[i][j] - + svl_dphi[i][j] - + sigmadvl[i][j] // derivative of local potential stress (pw) - + sigmaewa[i][j] // ewald stress (pw) - + sigmacc[i][j] //nonlinear core correction stress (pw) - + sigmaxc[i][j]//exchange corretion stress - + sigmahar[i][j];// hartree stress - - if(vdwd2.vdwD2) // Peize Lin update 2019-04-26 - { - scs[i][j] += stress_vdw(i , j); - } - if(vdwd3.vdwD3) // jiyy add 2019-05-18 - { - scs[i][j] += stress_vdw(i , j); - } - /* if(EFIELD) - { - scs(iat, i) = scs(iat, i) + sefield(iat, i); - } - */ - - } - - // if(OUT_LEVEL != "m") ofs_running << " correction stress for each atom along direction " - // << i+1 << " is " << sum/ucell.nat << endl; - } - -/*if(SYMMETRY) -{ - double *pos; - double d1,d2,d3; - pos = new double[ucell.nat*3]; - ZEROS(pos, ucell.nat*3); - int iat = 0; - for(int it = 0;it < ucell.ntype;it++) - { - //Atom* atom = &ucell.atoms[it]; - for(int ia =0;ia< ucell.atoms[it].na;ia++) - { - pos[3*iat ] = ucell.atoms[it].taud[ia].x ; - pos[3*iat+1] = ucell.atoms[it].taud[ia].y ; - pos[3*iat+2] = ucell.atoms[it].taud[ia].z; - for(int k=0; k<3; ++k) - { - symm.check_translation( pos[iat*3+k], -floor(pos[iat*3+k])); - symm.check_boundary( pos[iat*3+k] ); - } - iat++; - - } - } - - for(int iat=0; iatprint_stress("OVERLAP STRESS",soverlap,TEST_STRESS,ry); - //test - this->print_stress("T STRESS",stvnl_dphi,TEST_STRESS,ry); - this->print_stress("VNL STRESS",svnl_dbeta,TEST_STRESS,ry); - - this->print_stress("T_VNL STRESS",stvnl,TEST_STRESS,ry); - - this->print_stress("VL_dPHI STRESS",svl_dphi,TEST_STRESS,ry); - this->print_stress("VL_dVL STRESS",sigmadvl,TEST_STRESS,ry); - this->print_stress("HAR STRESS",sigmahar,TEST_STRESS,ry); - - this->print_stress("EWALD STRESS",sigmaewa,TEST_STRESS,ry); - this->print_stress("cc STRESS",sigmacc,TEST_STRESS,ry); - // this->print_stress("NLCC STRESS",sigmacc,TEST_STRESS,ry); - this->print_stress("XC STRESS",sigmaxc,TEST_STRESS,ry); - this->print_stress("TOTAL STRESS",scs,TEST_STRESS,ry); - } - - -/* if(EFIELD) - { - STRESS::print("EFIELD STRESS", sefield); - } -*/ - ofs_running << setiosflags(ios::left); - - this->printstress_total(ry); - - ofs_running << resetiosflags(ios::showpos); - - if(TEST_STRESS) - { - ofs_running << "\n STRESS INVALID TABLE." << endl; - // ofs_running << " " << setw(8) << "atom" << setw(5) << "x" << setw(5) << "y" << setw(5) << "z" << endl; - for(int i=0;i<3; i++) - { - for(int j=0; j<3; j++) - { - if( abs( scs[i][j]*Ry_to_eV/0.529177 ) < Stress_LCAO::stress_invalid_threshold_ev) - { - scs[i][j] = 0.0; - ofs_running << setw(5) << "1"; - } - else - { - ofs_running << setw(5) << "0"; - } - } - ofs_running << endl; - } - } - timer::tick("Stress_LCAO","start_stress",'E'); - return; -} - -void Stress_LCAO::print_stress(const string &name, double f[][3], const bool screen, bool ry)const -{ - ofs_running << " --------------------------- " << name << " ----------------------------" << endl; - - - double fac = 1.0; - - if(!ry) - { - // fac = Ry_to_eV / 0.529177; - } - - cout << setprecision(5); - cout << setiosflags(ios::showpos); - - if(screen) - { - cout << " ------------------- " << name << " --------------------" << endl; - - } - - for (int i=0;i<3;i++) - { - ofs_running << setw(15)<< " "; - if( abs(f[i][0]) >output_acc) ofs_running << setw(15) << f[i][0]*fac; - else ofs_running << setw(15) << "0"; - if( abs(f[i][1]) >output_acc) ofs_running << setw(15) << f[i][1]*fac; - else ofs_running << setw(15) << "0"; - if( abs(f[i][2]) >output_acc) ofs_running << setw(15) << f[i][2]*fac; - else ofs_running << setw(15) << "0"; - ofs_running << endl; - - if(screen) - { - if( abs(f[i][0]) >output_acc) cout << setw(15) << f[i][0]*fac; - else cout << setw(15) << "0"; - if( abs(f[i][1]) >output_acc) cout << setw(15) << f[i][1]*fac; - else cout << setw(15) << "0"; - if( abs(f[i][2]) >output_acc) cout << setw(15) << f[i][2]*fac; - else cout << setw(15) << "0"; - cout << endl; - } - } - - - cout << resetiosflags(ios::showpos); - - return; -} - -void Stress_LCAO::printstress_total(bool ry) -{ -// zhengdy update 2016-10-08 - double unit_transform = 1; - - if(!ry) - { - unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * 1.0e-8; - } -// cout.setf(ios::fixed); - - - //ofs_running << setiosflags(ios::right); - ofs_running << setprecision(6) << setiosflags(ios::showpos) << setiosflags(ios::fixed) << endl; - NEW_PART("TOTAL-STRESS (KBAR)");//Ryd/(a.u.)^3 - cout << " ><><><><><><><><><><><><><><><><><><><><><><" << endl; - cout << " TOTAL-STRESS (KBAR):" << endl; - cout << " ><><><><><><><><><><><><><><><><><><><><><><" << endl; - -// if(INPUT.stress_set == 1) -// int TEST_STRESS = 1; - - if(TEST_STRESS) - { - cout << setiosflags(ios::fixed) << setprecision(6); - cout << setiosflags(ios::showpos); - cout << " ------------------- TOTAL STRESS --------------------" << endl; - cout << " " << setw(8) << "STRESS" << endl; - ofs_running << " " << setw(12) << "STRESS" << endl; - } - - - for (int i=0; i<3; i++) - { - - //if(TEST_STRESS) - cout << " " << setw(15) << scs[i][0]*unit_transform << setw(15) - << scs[i][1]*unit_transform << setw(15) << scs[i][2]*unit_transform << endl; - - ofs_running << " " << setw(15) << scs[i][0]*unit_transform << setw(15) - << scs[i][1]*unit_transform << setw(15) << scs[i][2]*unit_transform << endl; - - - } - ofs_running << setiosflags(ios::left); - cout << resetiosflags(ios::showpos); - - return; -} - -void Stress_LCAO::cal_stress_loc(void) -{ - timer::tick("Stress_LCAO","cal_stress_loc",'F'); - - double *dvloc; - double evloc,fact=1.0; - int ng,nt,l,m,is; - - dvloc = new double[pw.ngmc]; - - for(l=0;l<3;l++) - { - for(m=0;m<3;m++) - { - sigmadvl[l][m]=0; - } - } - - complex *Porter = UFFT.porter; - - ZEROS( Porter, pw.nrxx ); - for(int is=0; is(CHR.rho[is][ir], 0.0 ); - } - } - pw.FFT_chg.FFT3D(Porter, -1); - -// if(INPUT.gamma_only==1) fact=2.0; -// else fact=1.0; - - evloc=0.0; - double g[3]={0,0,0}; - - - complex *vg = new complex[pw.ngmc]; - ZEROS( vg, pw.ngmc ); - for (int it=0; itzv, dvloc); - // - } - else{ - // - // normal case: dvloc contains dV_loc(G)/dG - // - str.dvloc_of_g ( atom->msh, atom->rab, atom->r, - atom->vloc_at, atom->zv, dvloc); - // - } - - for( ng = 0;ng< pw.ngmc;ng++) - { - const int j = pw.ig2fftc[ng]; - g[0]=pw.gcar[ng].x; - g[1]=pw.gcar[ng].y; - g[2]=pw.gcar[ng].z; - for (l = 0;l< 3;l++){ - for (m = 0; m1e-7); - - //G-space sum here - //Determine if this processor contains G=0 and set the constant term - double sdewald; - if(pw.gstart == 1){ - sdewald = (TWO_PI) * e2 / 4.0 / alpha * pow(charge/ucell.omega,2); - } - else { - sdewald = 0.0; - } - - //sdewald is the diagonal term - - double fact=1.0; -// if (INPUT.gamma_only) fact=2.0; -// else fact=1.0; - - double g2,g2a; - double arg; - complex rhostar; - double sewald; - for(int ng=pw.gstart;ng(ucell.atoms[it].zv * cos(arg),ucell.atoms[it].zv * sin(arg)); - } - } - rhostar /= ucell.omega; - sewald = fact* (TWO_PI) * e2 * exp(-g2a) / g2 * pow(abs(rhostar),2); - sdewald = sdewald - sewald; - g[0]=pw.gcar[ng].x; - g[1]=pw.gcar[ng].y; - g[2]=pw.gcar[ng].z; - for(l=0;l<3;l++){ - for(m=0;m *r; - double *r2; - r = new Vector3[mxr]; - r2 = new double[mxr]; - irr = new int[mxr]; - double rr; - Vector3 d_tau; - double r0[3]; - int rmax , nrm=0; - double fac; - if(pw.gstart==1){ - rmax = 4.0/sqrt(alpha)/ucell.lat0; - //with this choice terms up to ZiZj*erfc(5) are counted (erfc(5)=2*10^-1) - for(int it=0; it < ucell.ntype; it++){ - for(int i=0; iprint(ofs_running, "ewald stress", stression); - timer::tick("Force_lo","cal_stress_ew"); - - return; -} - -void Stress_LCAO::cal_stress_cc(void) -{ - timer::tick("Stress_LCAO","cal_stress_cc",'E'); - - int nt,ng,l,m,ir; - double fact=1.0; - complex sigmadiag; - double* rhocg; - double g[3]; - - - int judge=0; - for(nt=0;nt * psic = new complex [pw.nrxx]; - - ZEROS(psic, pw.nrxx); - - if(NSPIN==1||NSPIN==4){ - for(ir=0;ir(vxc(0, ir), 0.0); - } - } - else{ - for(ir=0;ir t = conj(psic[pw.ig2fftc[ng]] ) - * pw.strucFac (nt, ng) * rhocg [pw.ig2ngg[ng] ] * ucell.tpiba * - g [l] * g [m] / pw.gcar[ng].norm() * fact; - sigmacc [l][ m] += t.real(); - }//end m - }//end l - }//end ng - }//end if - }//end nt - for( l = 0;l< 3;l++){ - sigmacc [l][ l] += sigmadiag.real(); - } - for( l = 0;l< 3;l++){ - for (m = 0;m< 3;m++){ - Parallel_Reduce::reduce_double_pool( sigmacc[l][m] ); - } - } - - delete[] rhocg; - delete[] psic; - - timer::tick("Stress_LCAO","cal_stress_cc",'E'); - return; -} - -void Stress_LCAO::cal_stress_har(void) -{ - TITLE("Stress_LCAO","cal_stress_har"); - - double shart,g2; - const double eps=1e-8; - int is,ig,l,m,nspin0; - - complex *Porter = UFFT.porter; - - // Hartree potential VH(r) from n(r) - ZEROS( Porter, pw.nrxx ); - for(int is=0; is( CHR.rho[is][ir], 0.0 ); - } - } - //============================= - // bring rho (aux) to G space - //============================= - pw.FFT_chg.FFT3D(Porter, -1); - - complex *psic = new complex [pw.nrxx]; - double *psic0 = new double[pw.nrxx]; - ZEROS( psic0, pw.nrxx); - for(int is=0; is(psic0[ir], 0.0); - } - } - - pw.FFT_chg.FFT3D(psic, -1) ; - - double charge; - if (pw.gstart == 1) - { - charge = ucell.omega * Porter[pw.ig2fftc[0]].real(); - } - - complex *vh_g = new complex[pw.ngmc]; - ZEROS(vh_g, pw.ngmc); - - double g[3]; - - // test - // int i=pw.gstart; - // cout<< "gstart " <0); - const double fac = 1.0/ NSPIN; - - // doing FFT to get rho in G space: rhog1 - CHR.set_rhog(CHR.rho[0], CHR.rhog[0]); - if(NSPIN==2)//mohan fix bug 2012-05-28 - { - CHR.set_rhog(CHR.rho[1], CHR.rhog[1]); - } - CHR.set_rhog(CHR.rho_core, CHR.rhog_core); - - double* rhotmp1; - double* rhotmp2; - complex* rhogsum1; - complex* rhogsum2; - Vector3* gdr1; - Vector3* gdr2; - - rhotmp1 = new double[pw.nrxx]; - rhogsum1 = new complex[pw.ngmc]; - ZEROS(rhotmp1, pw.nrxx); - ZEROS(rhogsum1, pw.ngmc); - for(int ir=0; ir[pw.nrxx]; - ZEROS(gdr1, pw.nrxx); - - GGA_PW::grad_rho( rhogsum1 , gdr1 ); - - if(NSPIN==2) - { - rhotmp2 = new double[pw.nrxx]; - rhogsum2 = new complex[pw.ngmc]; - ZEROS(rhotmp2, pw.nrxx); - ZEROS(rhogsum2, pw.ngmc); - for(int ir=0; ir[pw.nrxx]; - ZEROS(gdr2, pw.nrxx); - - GGA_PW::grad_rho( rhogsum2 , gdr2 ); - } - - const double epsr = 1.0e-6; - const double epsg = 1.0e-10; - - double grho2a = 0.0; - double grho2b = 0.0; - double sx = 0.0; - double sc = 0.0; - double v1x = 0.0; - double v2x = 0.0; - double v1c = 0.0; - double v2c = 0.0; - double vtxcgc = 0.0; - double etxcgc = 0.0; - - if(NSPIN==1||NSPIN==4) - { - double segno; - for(int ir=0; ir epsr) - { - grho2a = gdr1[ir].norm2(); - if( grho2a > epsg ) - { - if( rhotmp1[ir] >= 0.0 ) segno = 1.0; - if( rhotmp1[ir] < 0.0 ) segno = -1.0; - - XC_Functional::gcxc( arho, grho2a, sx, sc, v1x, v2x, v1c, v2c); - double tt[3]; - tt[0] = gdr1[ir].x; - tt[1] = gdr1[ir].y; - tt[2] = gdr1[ir].z; - for(int l = 0;l< 3;l++){ - for(int m = 0;m< l+1;m++){ - sigma_gradcorr[l][m] += tt[l] * tt[m] * e2 * (v2x + v2c); - } - } - } - } - } - } - else if(NSPIN==2) - { - double v1cup = 0.0; - double v1cdw = 0.0; - double v2cup = 0.0; - double v2cdw = 0.0; - double v1xup = 0.0; - double v1xdw = 0.0; - double v2xup = 0.0; - double v2xdw = 0.0; - double v2cud = 0.0; - double v2c = 0.0; - for(int ir=0; ir epsr) - { - if(igcc_is_lyp) - { - WARNING_QUIT("stress","igcc_is_lyp is not available now."); - } - else - { - double zeta = ( rhotmp1[ir] - rhotmp2[ir] ) / rh; - double grh2 = (gdr1[ir]+gdr2[ir]).norm2(); - //XC_Functional::gcc_spin(rh, zeta, grh2, sc, v1cup, v1cdw, v2c); - gcc_spin(rh, zeta, grh2, sc, v1cup, v1cdw, v2c); - v2cup = v2c; - v2cdw = v2c; - v2cud = v2c; - } - } - else - { - sc = 0.0; - v1cup = 0.0; - v1cdw = 0.0; - v2c = 0.0; - v2cup = 0.0; - v2cdw = 0.0; - v2cud = 0.0; - } - double tt1[3],tt2[3]; - { - tt1[0] = gdr1[ir].x; - tt1[1] = gdr1[ir].y; - tt1[2] = gdr1[ir].z; - tt2[0] = gdr2[ir].x; - tt2[1] = gdr2[ir].y; - tt2[2] = gdr2[ir].z; - } - for(int l = 0;l< 3;l++){ - for(int m = 0;m< l+1;m++){ - // exchange - sigma_gradcorr [l][m] += tt1[l] * tt1[m] * e2 * v2xup + - tt2[l] * tt2[m] * e2 * v2xdw; - // correlation - sigma_gradcorr [l][m] += ( tt1[l] * tt1[m] * v2cup + - tt2[l] * tt2[m] * v2cdw + - (tt1[l] * tt2[m] + - tt2[l] * tt1[m] ) * v2cud ) * e2; - } - } - } - } - - for(int l = 0;l< 3;l++){ - for(int m = 0;m< l;m++){ - sigma_gradcorr[m][l] = sigma_gradcorr[l][m]; - } - } - for(int l = 0;l<3;l++){ - for(int m = 0;m<3;m++){ - Parallel_Reduce::reduce_double_pool( sigma_gradcorr[l][m] ); - } - } - p= &sigma_gradcorr[0][0]; - double* p1 = &sigmaxc[0][0]; - for(int i=0;i<9;i++){ - *p /= pw.ncxyz ; - *p1++ += *p++; - } - - delete[] rhotmp1; - delete[] rhogsum1; - delete[] gdr1; - if(NSPIN==2) - { - delete[] rhotmp2; - delete[] rhogsum2; - delete[] gdr2; - } - return; -} +#include"./stress_lcao.h" +#include "../src_pw/H_XC_pw.h" + +void Stress_LCAO::start_stress +( +const double overlap[][3], +const double tvnl_dphi[][3], +const double vnl_dbeta[][3], +const double vl_dphi[][3], +const matrix& stress_vdw, +matrix& scs +) +{ + TITLE("Stress_LCAO","start_stress"); + timer::tick("Stress_LCAO","start_stress",'E'); + + matrix soverlap; + soverlap.create(3,3); + matrix stvnl_dphi; + stvnl_dphi.create(3,3); + matrix svnl_dbeta; + svnl_dbeta.create(3,3); + matrix svl_dphi; + svl_dphi.create(3,3); + matrix sigmacc; + sigmacc.create(3,3); + matrix sigmadvl; + sigmadvl.create(3,3); + matrix sigmaewa; + sigmaewa.create(3,3); + matrix sigmaxc; + sigmaxc.create(3,3); + matrix sigmahar; + sigmahar.create(3,3); + + for(int i=0;i<3;i++) + { + for(int j=0;j<3;j++) + { + scs(i,j) = 0.0; + soverlap(i,j) = overlap[i][j]; + stvnl_dphi(i,j) = tvnl_dphi[i][j]; + svnl_dbeta(i,j) = vnl_dbeta[i][j]; + svl_dphi(i,j) = vl_dphi[i][j]; + sigmacc(i,j) = 0.0; + sigmadvl(i,j) = 0.0; + sigmaewa(i,j) = 0.0; + sigmaxc(i,j) = 0.0; + sigmahar(i,j) = 0.0; + } + } + //-------------------------------------------------------- + // local pseudopotential stress: + // use charge density; plane wave; local pseudopotential; + //-------------------------------------------------------- + this->stress_loc (sigmadvl, 0); + + //-------------------------------------------------------- + //hartree term + //-------------------------------------------------------- + this->stress_har (sigmahar, 0); + + //-------------------------------------------------------- + // ewald stress: use plane wave only. + //-------------------------------------------------------- + this->stress_ewa (sigmaewa, 0); //remain problem + + + //-------------------------------------------------------- + // stress due to core correlation. + //-------------------------------------------------------- + this->stress_cc(sigmacc, 0); + + //-------------------------------------------------------- + // stress due to self-consistent charge. + //-------------------------------------------------------- + for(int i=0;i<3;i++) + { + sigmaxc(i,i) = -(H_XC_pw::etxc) / ucell.omega; + } + //Exchange-correlation for PBE + stress_gga(sigmaxc); + +/* if(vdwd2.vdwD2) //Peize Lin add 2014-04-04, update 2019-04-26 + { + vdwd2.stress(); + } +*/ +/* if(vdwd3.vdwD3) //jiyy add 2019-05-18 + { + vdwd3.stress(); + } +*/ +/* matrix sefield; + if(EFIELD) + { + sefield.create(3, 3); + Efield::compute_stress(sefield); + }*/ + + for(int i=0; i<3; i++) + { + for (int j=0;j<3;j++) + { + scs(i,j) += soverlap(i,j) + + stvnl_dphi(i,j) + + svnl_dbeta(i,j) + + svl_dphi(i,j) + + sigmadvl(i,j) // derivative of local potential stress (pw) + + sigmaewa(i,j) // ewald stress (pw) + + sigmacc(i,j) //nonlinear core correction stress (pw) + + sigmaxc(i,j)//exchange corretion stress + + sigmahar(i,j);// hartree stress + + if(vdwd2.vdwD2) // Peize Lin update 2019-04-26 + { + scs(i,j) += stress_vdw(i , j); + } + if(vdwd3.vdwD3) // jiyy add 2019-05-18 + { + scs(i,j) += stress_vdw(i , j); + } + /* if(EFIELD) + { + scs(iat, i) = scs(iat, i) + sefield(iat, i); + } + */ + + } + + // if(OUT_LEVEL != "m") ofs_running << " correction stress for each atom along direction " + // << i+1 << " is " << sum/ucell.nat << endl; + } + + // test + matrix svlocal; + svlocal.create(3,3); + for (int i = 0; i<3; i++) + { + for(int j=0; j<3; j++) + { + svlocal(i,j) = 0.0; + svlocal(i,j) = svl_dphi(i,j) + sigmadvl(i,j); + } + } + + // test + matrix stvnl; + stvnl.create(3,3); + for (int i = 0; i < 3; i++) + { + for(int j=0; j<3; j++) + { + stvnl(i,j) = 0.0; + stvnl(i,j) = stvnl_dphi(i,j) + svnl_dbeta(i,j); + } + } + + if(Symmetry::symm_flag) + { + symm.stress_symmetry(scs); + }//end symmetry + + // print Rydberg stress or not + bool ry = false; + +// int TEST_STRESS = 1; + if(TEST_STRESS) + { + ofs_running << "\n PARTS OF STRESS: " << endl; + ofs_running << setiosflags(ios::showpos); + ofs_running << setiosflags(ios::fixed) << setprecision(8) << endl; + this->print_stress("OVERLAP STRESS",soverlap,TEST_STRESS,ry); + //test + this->print_stress("T STRESS",stvnl_dphi,TEST_STRESS,ry); + this->print_stress("VNL STRESS",svnl_dbeta,TEST_STRESS,ry); + + this->print_stress("T_VNL STRESS",stvnl,TEST_STRESS,ry); + + this->print_stress("VL_dPHI STRESS",svl_dphi,TEST_STRESS,ry); + this->print_stress("VL_dVL STRESS",sigmadvl,TEST_STRESS,ry); + this->print_stress("HAR STRESS",sigmahar,TEST_STRESS,ry); + + this->print_stress("EWALD STRESS",sigmaewa,TEST_STRESS,ry); + this->print_stress("cc STRESS",sigmacc,TEST_STRESS,ry); + // this->print_stress("NLCC STRESS",sigmacc,TEST_STRESS,ry); + this->print_stress("XC STRESS",sigmaxc,TEST_STRESS,ry); + this->print_stress("TOTAL STRESS",scs,TEST_STRESS,ry); + } + + +/* if(EFIELD) + { + STRESS::print("EFIELD STRESS", sefield); + } +*/ + ofs_running << setiosflags(ios::left); + + this->printstress_total(scs, ry); + + + timer::tick("Stress_LCAO","start_stress",'E'); + return; +} diff --git a/ABACUS.develop/source/src_lcao/stress_lcao.h b/ABACUS.develop/source/src_lcao/stress_lcao.h index 9e556d70b3..f002be6216 100644 --- a/ABACUS.develop/source/src_lcao/stress_lcao.h +++ b/ABACUS.develop/source/src_lcao/stress_lcao.h @@ -1,55 +1,21 @@ #ifndef STRESS_LCAO_H #define STRESS_LCAO_H +#include "./../src_pw/stress_func.h" -#include "../src_pw/tools.h" -#include "../src_pw/stress.h" //test - -class Stress_LCAO +class Stress_LCAO:public Stress_Func { public : - Stress_LCAO (); - ~Stress_LCAO (); - - void allocate (void); - void destroy (void); - - void cal_stress_loc (void); - void cal_stress_ew (void); - void cal_stress_scc (void); - void cal_stress_cc (void); - void cal_stress_har(void); - void cal_stress_gradcorr(void); - - void print_stress(const string &name, double f[][3], const bool screen, bool ry)const; - void printstress_total (bool ry); - - void start_stress(double overlap[][3], double tvnl_dphi[][3], - double vnl_dbeta[][3],double vl_dphi[][3], const matrix& stress_vdw); - - // total stress - double scs[3][3]; - - static double stress_invalid_threshold_ev; - - private: - - //each part of stress - double sigmadvl[3][3]; - double sigmaewa[3][3]; - double sigmacc[3][3]; - double sigmaxc[3][3]; - double sigmahar[3][3]; - //each part of stress - //only calculated in force_lcao part - double soverlap[3][3]; - double stvnl_dphi[3][3]; - double svnl_dbeta[3][3]; - double svl_dphi[3][3]; - - bool allocate_flag; - double output_acc; // control the accuracy - - Stress str; //test + Stress_LCAO (){}; + ~Stress_LCAO (){}; + + //calculate the stress in LCAO basis + void start_stress( + const double overlap[][3], + const double tvnl_dphi[][3], + const double vnl_dbeta[][3], + const double vl_dphi[][3], + const matrix& stress_vdw, + matrix& scs); }; #endif diff --git a/ABACUS.develop/source/src_pw/H_Ewald_pw.h b/ABACUS.develop/source/src_pw/H_Ewald_pw.h index 34426e558c..55d2f263bf 100644 --- a/ABACUS.develop/source/src_pw/H_Ewald_pw.h +++ b/ABACUS.develop/source/src_pw/H_Ewald_pw.h @@ -10,9 +10,8 @@ class H_Ewald_pw public: // need to be updated in near future 2021-02-25 - friend class Stress; // Ewald stress + friend class Stress_Func; // Ewald stress friend class Forces; // Ewald forces - friend class Stress_LCAO; // Ewald stress friend class Force_LCAO; // Ewald forces H_Ewald_pw(); diff --git a/ABACUS.develop/source/src_pw/H_XC_pw.h b/ABACUS.develop/source/src_pw/H_XC_pw.h index bb49b652d2..639ea5d44e 100644 --- a/ABACUS.develop/source/src_pw/H_XC_pw.h +++ b/ABACUS.develop/source/src_pw/H_XC_pw.h @@ -7,9 +7,10 @@ class H_XC_pw { public: - friend class Stress; - friend class Forces; + friend class Stress_Func; + friend class Stress_PW; friend class Stress_LCAO; + friend class Forces; friend class Force_LCAO; friend class potential; friend class energy; diff --git a/ABACUS.develop/source/src_pw/ions.cpp b/ABACUS.develop/source/src_pw/ions.cpp index c15bebecb9..1849d15b1f 100644 --- a/ABACUS.develop/source/src_pw/ions.cpp +++ b/ABACUS.develop/source/src_pw/ions.cpp @@ -1,7 +1,7 @@ #include "tools.h" #include "ions.h" #include "forces.h" -#include "stress.h" +#include "stress_pw.h" #include "../src_pw/global.h" // use chr. #include "vdwd2.h" #include "vdwd3.h" @@ -306,24 +306,19 @@ bool Ions::force_stress(const int &istep, int &force_step, int &stress_step) // if(!FORCE&&STRESS) { - Stress ss; - ss.cal_stress(); + Stress_PW ss; matrix stress; stress.create(3,3); + ss.cal_stress(stress); double unit_transform = 0.0; unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * 1.0e-8; double external_stress[3] = {PRESS1,PRESS2,PRESS3}; for(int i=0;i<3;i++) { - for(int j=0;j<3;j++) - { - stress(i,j) = ss.sigmatot[i][j]; - //OUT(ofs_running,"stress(i,j)", stress(i,j)); //LiuXh modify 20180619 - } - stress(i,i) = ss.sigmatot[i][i] - external_stress[i]/unit_transform; + stress(i,i) -= external_stress[i]/unit_transform; } - PRESSURE = (ss.sigmatot[0][0]+ss.sigmatot[1][1]+ss.sigmatot[2][2])/3; + PRESSURE = (stress(0,0)+stress(1,1)+stress(2,2))/3; if(CALCULATION=="cell-relax") { LCM.cal_lattice_change(stress_step, stress, en.etot); @@ -367,24 +362,19 @@ bool Ions::force_stress(const int &istep, int &force_step, int &stress_step) // { force_step = 1; - Stress ss; - ss.cal_stress(); matrix stress; stress.create(3,3); + Stress_PW ss; + ss.cal_stress(stress); double unit_transform = 0.0; unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * 1.0e-8; double external_stress[3] = {PRESS1,PRESS2,PRESS3}; for(int i=0;i<3;i++) { - for(int j=0;j<3;j++) - { - stress(i,j) = ss.sigmatot[i][j]; - //OUT(ofs_running,"stress(i,j)", stress(i,j)); //LiuXh modify 20180619 - } - stress(i,i) = ss.sigmatot[i][i] - external_stress[i]/unit_transform; + stress(i,i) -= external_stress[i]/unit_transform; } - PRESSURE = (ss.sigmatot[0][0]+ss.sigmatot[1][1]+ss.sigmatot[2][2])/3; + PRESSURE = (stress(0,0)+stress(1,1)+stress(2,2))/3; if(CALCULATION=="cell-relax") { @@ -441,24 +431,19 @@ bool Ions::force_stress(const int &istep, int &force_step, int &stress_step) // } else { - Stress ss; - ss.cal_stress(); matrix stress; stress.create(3,3); + Stress_PW ss; + ss.cal_stress(stress); double unit_transform = 0.0; unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * 1.0e-8; double external_stress[3] = {PRESS1,PRESS2,PRESS3}; for(int i=0;i<3;i++) { - for(int j=0;j<3;j++) - { - stress(i,j) = ss.sigmatot[i][j]; - //OUT(ofs_running,"stress(i,j)", stress(i,j)); //LiuXh modify 20180619 - } - stress(i,i) = ss.sigmatot[i][i] - external_stress[i]/unit_transform; + stress(i,i) -= external_stress[i]/unit_transform; } - PRESSURE = (ss.sigmatot[0][0]+ss.sigmatot[1][1]+ss.sigmatot[2][2])/3; + PRESSURE = (stress(0,0)+stress(1,1)+stress(2,2))/3; return 1; } } diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h index 20cc80db72..c691617553 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h +++ b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h @@ -22,7 +22,7 @@ class pseudopot_cell_vnl: public pseudopot_cell_vl pseudopot_cell_vnl(); ~pseudopot_cell_vnl(); - friend class Stress; + friend class Stress_Func; friend class Forces; friend class Epsilon0_vasp; friend class potential; diff --git a/ABACUS.develop/source/src_pw/stress_func.h b/ABACUS.develop/source/src_pw/stress_func.h new file mode 100644 index 0000000000..5d2c506946 --- /dev/null +++ b/ABACUS.develop/source/src_pw/stress_func.h @@ -0,0 +1,127 @@ +#ifndef STRESS_FUNC_H +#define STRESS_FUNC_H + +#include "tools.h" +#include "./global.h" + +//------------------------------------------------------------------- +// mohan reconstruction note: 2021-02-07 +// the stress code needs reconstructions (by Daye Zheng) +// 1) add explanations for each function, each variable, for +// main procedures, make the code readable +// 2) divide the stress class into several files, each file +// deals with only one part of the stress, it is convenient for +// the next-step reconstruction, for example, we want to make +// pw as an external variable instead of a global variable +// 3) for PW and LCAO, keeps only one copy of the code, for example +// the ewald term needs only one copy, it will reduce the +// time to maintain both copies of stress codes. +// 4) remain openning interfaces for others to contribute stress +// codes, for example, molecular dynamics will have an ionic stress +// term, +U? exx? may have other stress terms. +// 5) delete useless comments and tests, if you have a useless code, +// please explicitly explain why you want to keep the test +// 6) format should be beautiful! code should be readable like a +// note (let readers be comfortable) +//------------------------------------------------------------------- + +//---------------------------------------------------------------- +// compute the stress terms in terms of the plane wave basis set +// the stress terms include: +// 1) the stress from the electron kinetic energy +// 2) the stress from the local pseudopotentials +// 3) the stress from the non-local pseudopotentials +// 4) the stress from the Hartree term +// 5) the stress from the non-linear core correction (if any) +// 6) the strees from the exchange-correlation functional term +// 7) the stress from the ewald term (ion-ion intraction under +// periodic boundary conditions). +// 8) the stress from ionic contributions (for molecular dynamics) +//---------------------------------------------------------------- + +class Stress_Func +{ + public: + + Stress_Func(){}; + ~Stress_Func(){}; + +//stress functions +// 1) the stress from the electron kinetic energy + void stress_kin(matrix& sigma); //electron kinetic part in PW basis + +// 2) the stress from the Hartree term + void stress_har(matrix& sigma, const bool is_pw); //hartree part in PW or LCAO basis + +// 3) the stress from the ewald term (ion-ion intraction under +// periodic boundary conditions). + void stress_ewa(matrix& sigma, const bool is_pw); //ewald part in PW or LCAO basis + +// 4) the stress from the local pseudopotentials + void stress_loc(matrix& sigma, const bool is_pw); //local pseudopotential part in PW or LCAO + + void dvloc_of_g (const int& msh, + const double* rab, + const double* r, + const double* vloc_at, + const double& zp, + double* dvloc); //used in local pseudopotential stress + + void dvloc_coul (const double& zp, double* dvloc); //used in local pseudopotential stress + +// 5) the stress from the non-linear core correction (if any) + void stress_cc(matrix& sigma, const bool is_pw); //nonlinear core correction stress in PW or LCAO basis + + void deriv_drhoc ( + const bool &numeric, + const int mesh, + const double *r, + const double *rab, + const double *rhoc, + double *drhocg); //used in nonlinear core correction stress + +// 6) the stress from the exchange-correlation functional term + void stress_gga(matrix& sigma); //gga part in both PW and LCAO basis + +// 7) the stress from the non-local pseudopotentials + void stress_nl(matrix& sigma); //nonlocal part in PW basis + + + void get_dvnl1( + ComplexMatrix &vkb, + const int ik, + const int ipol); //used in nonlocal part in PW basis + void dylmr2 ( + const int nylm, + const int ngy, + Vector3 *gk, + matrix &dylm, + const int ipol); //used in get_dvnl1() + void get_dvnl2( + ComplexMatrix &vkb, + const int ik); //used in nonlocal part in PW basis + double Polynomial_Interpolation_nl( + const realArray &table, + const int &dim1, + const int &dim2, + const double &table_interval, + const double &x); //used in get_dvnl2() + + //functions for stress print + void print_stress(const string &name, const matrix& f, const bool screen, bool ry)const; + + void printstress_total (const matrix& scs, bool ry); + + static double stress_invalid_threshold_ev; + +}; + +#endif + + + + + + + + diff --git a/ABACUS.develop/source/src_pw/stress_func_cc.cpp b/ABACUS.develop/source/src_pw/stress_func_cc.cpp new file mode 100644 index 0000000000..a38d0b0701 --- /dev/null +++ b/ABACUS.develop/source/src_pw/stress_func_cc.cpp @@ -0,0 +1,170 @@ +#include "./stress_func.h" +#include "./H_XC_pw.h" + +//NLCC term, need to be test! +void Stress_Func::stress_cc(matrix& sigma, const bool is_pw) +{ + timer::tick("Stress_Func","stress_cc",'F'); + + int nt,ng,l,m,ir; + double fact=1.0; + if(is_pw&&INPUT.gamma_only) fact = 2.0; //is_pw:PW basis, gamma_only need to double. + complex sigmadiag; + double* rhocg; + double g[3]; + + + int judge=0; + for(nt=0;nt * psic = new complex [pw.nrxx]; + + ZEROS(psic, pw.nrxx); + + if(NSPIN==1||NSPIN==4){ + for(ir=0;ir(vxc(0, ir), 0.0); + } + } + else{ + for(ir=0;irderiv_drhoc ( + ppcell.numeric, + ucell.atoms[nt].msh, + ucell.atoms[nt].r, + ucell.atoms[nt].rab, + ucell.atoms[nt].rho_atc, + rhocg); + // non diagonal term (g=0 contribution missing) + for( ng = pw.gstart;ng< pw.ngmc;ng++) + { + g[0] = pw.gcar[ng].x; + g[1] = pw.gcar[ng].y; + g[2] = pw.gcar[ng].z; + for( l = 0;l< 3;l++) + { + for (m = 0;m< 3;m++) + { + const complex t = conj(psic[pw.ig2fftc[ng]] ) + * pw.strucFac (nt, ng) * rhocg [pw.ig2ngg[ng] ] * ucell.tpiba * + g [l] * g [m] / pw.gcar[ng].norm() * fact; +// sigmacc [l][ m] += t.real(); + sigma(l,m) += t.real(); + }//end m + }//end l + }//end ng + }//end if + }//end nt + for( l = 0;l< 3;l++) + { + sigma(l,l) += sigmadiag.real(); +// sigmacc [l][ l] += sigmadiag.real(); + } + for( l = 0;l< 3;l++) + { + for (m = 0;m< 3;m++) + { + Parallel_Reduce::reduce_double_pool( sigma(l,m) ); + } + } + + delete[] rhocg; + delete[] psic; + + timer::tick("Stress_Func","stress_cc"); + return; +} + + +void Stress_Func::deriv_drhoc +( + const bool &numeric, + const int mesh, + const double *r, + const double *rab, + const double *rhoc, + double *drhocg +) +{ + + double gx = 0, rhocg1 = 0; + // the modulus of g for a given shell + // the fourier transform + double *aux = new double[ mesh]; + // auxiliary memory for integration + + int igl0; + // counter on radial mesh points + // counter on g shells + // lower limit for loop on ngl + + // + // G=0 term + // + if (pw.ggs[0] < 1.0e-8){ + drhocg [0] = 0.0; + igl0 = 1; + } + else{ + igl0 = 0; + } + // + // G <> 0 term + // + + for(int igl = igl0;igl< pw.nggm;igl++) + { + gx = sqrt(pw.ggs [igl] * ucell.tpiba2); + for( int ir = 0;ir< mesh; ir++) + { + aux [ir] = r [ir] * rhoc [ir] * (r [ir] * cos (gx * r [ir] ) / gx - sin (gx * r [ir] ) / pow(gx,2)); + }//ir + Mathzone::Simpson_Integral(mesh, aux, rab, rhocg1); + drhocg [igl] = FOUR_PI / ucell.omega * rhocg1; + }//igl + + delete [] aux; + + return; +} diff --git a/ABACUS.develop/source/src_pw/stress_func_ewa.cpp b/ABACUS.develop/source/src_pw/stress_func_ewa.cpp new file mode 100644 index 0000000000..7c66d64fc2 --- /dev/null +++ b/ABACUS.develop/source/src_pw/stress_func_ewa.cpp @@ -0,0 +1,159 @@ +#include "./stress_func.h" +#include "./H_Ewald_pw.h" + +//calcualte the Ewald stress term in PW and LCAO +void Stress_Func::stress_ewa(matrix& sigma, const bool is_pw) +{ + timer::tick("Stress_Func","stress_ew",'F'); + + int i,j,l,m; + double g[3]; + + double charge=0; + for(int it=0; it < ucell.ntype; it++) + { + for(int i=0; i1e-7); + + //G-space sum here + //Determine if this processor contains G=0 and set the constant term + double sdewald; + if(pw.gstart == 1) + { + sdewald = (TWO_PI) * e2 / 4.0 / alpha * pow(charge/ucell.omega,2); + } + else + { + sdewald = 0.0; + } + + //sdewald is the diagonal term + + double fact=1.0; + if (INPUT.gamma_only && is_pw) fact=2.0; +// else fact=1.0; + + double g2,g2a; + double arg; + complex rhostar; + double sewald; + for(int ng=pw.gstart;ng(ucell.atoms[it].zv * cos(arg),ucell.atoms[it].zv * sin(arg)); + } + } + rhostar /= ucell.omega; + sewald = fact* (TWO_PI) * e2 * exp(-g2a) / g2 * pow(abs(rhostar),2); + sdewald = sdewald - sewald; + g[0]=pw.gcar[ng].x; + g[1]=pw.gcar[ng].y; + g[2]=pw.gcar[ng].z; + for(l=0;l<3;l++) + { + for(m=0;m *r; + double *r2; + r = new Vector3[mxr]; + r2 = new double[mxr]; + irr = new int[mxr]; + double rr; + Vector3 d_tau; + double r0[3]; + int rmax , nrm=0; + double fac; + if(pw.gstart==1) + { + rmax = 4.0/sqrt(alpha)/ucell.lat0; + //with this choice terms up to ZiZj*erfc(5) are counted (erfc(5)=2*10^-1) + for(int it=0; it < ucell.ntype; it++) + { + for(int i=0; iprint(ofs_running, "ewald stress", stression); + timer::tick("Force_Func","stress_ew"); + + return; +} diff --git a/ABACUS.develop/source/src_pw/stress_func_gga.cpp b/ABACUS.develop/source/src_pw/stress_func_gga.cpp new file mode 100644 index 0000000000..75c5af9941 --- /dev/null +++ b/ABACUS.develop/source/src_pw/stress_func_gga.cpp @@ -0,0 +1,235 @@ +#include "./stress_func.h" +#include "./xc_functional.h" +#include "./myfunc.h" +#include "./xc_gga_pw.h" + +//calculate the GGA stress correction in PW and LCAO +void Stress_Func::stress_gga(matrix& sigma) +{ + timer::tick("Stress_Func","stress_gga",'F'); + + if (xcf.igcx == 0 && xcf.igcc == 0) + { + return; + } + double sigma_gradcorr[3][3]; + double* p= &sigma_gradcorr[0][0]; + for(int i=0;i<9;i++) + *p++ = 0; + + bool igcc_is_lyp = false; + if( xcf.igcc == 3 || xcf.igcc == 7) + { + igcc_is_lyp = true; + } + + assert(NSPIN>0); + const double fac = 1.0/ NSPIN; + + // doing FFT to get rho in G space: rhog1 + CHR.set_rhog(CHR.rho[0], CHR.rhog[0]); + if(NSPIN==2)//mohan fix bug 2012-05-28 + { + CHR.set_rhog(CHR.rho[1], CHR.rhog[1]); + } + CHR.set_rhog(CHR.rho_core, CHR.rhog_core); + + double* rhotmp1; + double* rhotmp2; + complex* rhogsum1; + complex* rhogsum2; + Vector3* gdr1; + Vector3* gdr2; + + rhotmp1 = new double[pw.nrxx]; + rhogsum1 = new complex[pw.ngmc]; + ZEROS(rhotmp1, pw.nrxx); + ZEROS(rhogsum1, pw.ngmc); + for(int ir=0; ir[pw.nrxx]; + ZEROS(gdr1, pw.nrxx); + + GGA_PW::grad_rho( rhogsum1 , gdr1 ); + + if(NSPIN==2) + { + rhotmp2 = new double[pw.nrxx]; + rhogsum2 = new complex[pw.ngmc]; + ZEROS(rhotmp2, pw.nrxx); + ZEROS(rhogsum2, pw.ngmc); + for(int ir=0; ir[pw.nrxx]; + ZEROS(gdr2, pw.nrxx); + + GGA_PW::grad_rho( rhogsum2 , gdr2 ); + } + + const double epsr = 1.0e-6; + const double epsg = 1.0e-10; + + double grho2a = 0.0; + double grho2b = 0.0; + double sx = 0.0; + double sc = 0.0; + double v1x = 0.0; + double v2x = 0.0; + double v1c = 0.0; + double v2c = 0.0; + double vtxcgc = 0.0; + double etxcgc = 0.0; + + if(NSPIN==1||NSPIN==4) + { + double segno; + for(int ir=0; ir epsr) + { + grho2a = gdr1[ir].norm2(); + if( grho2a > epsg ) + { + if( rhotmp1[ir] >= 0.0 ) segno = 1.0; + if( rhotmp1[ir] < 0.0 ) segno = -1.0; + + XC_Functional::gcxc( arho, grho2a, sx, sc, v1x, v2x, v1c, v2c); + double tt[3]; + tt[0] = gdr1[ir].x; + tt[1] = gdr1[ir].y; + tt[2] = gdr1[ir].z; + for(int l = 0;l< 3;l++) + { + for(int m = 0;m< l+1;m++) + { + sigma_gradcorr[l][m] += tt[l] * tt[m] * e2 * (v2x + v2c); + } + } + } + } + } + } + else if(NSPIN==2) + { + double v1cup = 0.0; + double v1cdw = 0.0; + double v2cup = 0.0; + double v2cdw = 0.0; + double v1xup = 0.0; + double v1xdw = 0.0; + double v2xup = 0.0; + double v2xdw = 0.0; + double v2cud = 0.0; + double v2c = 0.0; + for(int ir=0; ir epsr) + { + if(igcc_is_lyp) + { + WARNING_QUIT("stress","igcc_is_lyp is not available now."); + } + else + { + double zeta = ( rhotmp1[ir] - rhotmp2[ir] ) / rh; + double grh2 = (gdr1[ir]+gdr2[ir]).norm2(); + //XC_Functional::gcc_spin(rh, zeta, grh2, sc, v1cup, v1cdw, v2c); + gcc_spin(rh, zeta, grh2, sc, v1cup, v1cdw, v2c); + v2cup = v2c; + v2cdw = v2c; + v2cud = v2c; + } + } + else + { + sc = 0.0; + v1cup = 0.0; + v1cdw = 0.0; + v2c = 0.0; + v2cup = 0.0; + v2cdw = 0.0; + v2cud = 0.0; + } + double tt1[3],tt2[3]; + { + tt1[0] = gdr1[ir].x; + tt1[1] = gdr1[ir].y; + tt1[2] = gdr1[ir].z; + tt2[0] = gdr2[ir].x; + tt2[1] = gdr2[ir].y; + tt2[2] = gdr2[ir].z; + } + for(int l = 0;l< 3;l++) + { + for(int m = 0;m< l+1;m++) + { + // exchange + sigma_gradcorr [l][m] += tt1[l] * tt1[m] * e2 * v2xup + + tt2[l] * tt2[m] * e2 * v2xdw; + // correlation + sigma_gradcorr [l][m] += ( tt1[l] * tt1[m] * v2cup + + tt2[l] * tt2[m] * v2cdw + + (tt1[l] * tt2[m] + + tt2[l] * tt1[m] ) * v2cud ) * e2; + } + } + } + } + + for(int l = 0;l< 3;l++) + { + for(int m = 0;m< l;m++) + { + sigma_gradcorr[m][l] = sigma_gradcorr[l][m]; + } + } + for(int l = 0;l<3;l++) + { + for(int m = 0;m<3;m++) + { + Parallel_Reduce::reduce_double_pool( sigma_gradcorr[l][m] ); + } + } + +/* p= &sigma_gradcorr[0][0]; + double* p1 = &sigmaxc[0][0]; + for(int i=0;i<9;i++){ + *p /= pw.ncxyz ; + *p1++ += *p++; + }*/ + + for(int i=0;i<3;i++) + { + for(int j=0;j<3;j++) + { + sigma(i,j) += sigma_gradcorr[i][j]; + } + } + + delete[] rhotmp1; + delete[] rhogsum1; + delete[] gdr1; + if(NSPIN==2) + { + delete[] rhotmp2; + delete[] rhogsum2; + delete[] gdr2; + } + timer::tick("Stress_Func","stress_gga"); + return; +} diff --git a/ABACUS.develop/source/src_pw/stress_func_har.cpp b/ABACUS.develop/source/src_pw/stress_func_har.cpp new file mode 100644 index 0000000000..433698b974 --- /dev/null +++ b/ABACUS.develop/source/src_pw/stress_func_har.cpp @@ -0,0 +1,143 @@ +#include "./stress_func.h" +#include "./myfunc.h" +#include "./H_Hartree_pw.h" + +//calculate the Hartree part in PW or LCAO base +void Stress_Func::stress_har(matrix& sigma, const bool is_pw) +{ + timer::tick("Stress_Func","stress_har",'F'); + double shart,g2; + const double eps=1e-8; + int l,m,nspin0; + + complex *Porter = UFFT.porter; + + // Hartree potential VH(r) from n(r) + ZEROS( Porter, pw.nrxx ); + for(int is=0; is( CHR.rho[is][ir], 0.0 ); + } + } + //============================= + // bring rho (aux) to G space + //============================= + pw.FFT_chg.FFT3D(Porter, -1); + + complex *psic = new complex [pw.nrxx]; + double *psic0 = new double[pw.nrxx]; + ZEROS( psic0, pw.nrxx); + for(int is=0; is(psic0[ir], 0.0); + } + } + + pw.FFT_chg.FFT3D(psic, -1) ; + + + double charge; + if (pw.gstart == 1) + { + charge = ucell.omega * Porter[pw.ig2fftc[0]].real(); + } + + complex *vh_g = new complex[pw.ngmc]; + ZEROS(vh_g, pw.ngmc); + + double g[3]; +//test + // int i=pw.gstart; + // cout<< "gstart " <1){ + // iunigh.clear(); + // iunigh.seekg(0,ios::beg); + // }//go back to the beginning of file + + for(ik=0;ik1){ + // iunigk>>igk; + // get_buffer(evc,nwordwfc,iunwfc,ik); + // } + for(i=0;i0){ + // gk2=pow(gk[i].x,2)+pow(gk[i].y,2)+pow(gk[i].z,2); + // arg=pow((gk2-ecfixed)/q2sigma,2); + // kfac[i]=1+qcutz/q2sigma*tbsp*exp(-arg); + // } + } + + //kinetic contribution + + for(l=0;l<3;l++) + { + for(m=0;m *Porter = UFFT.porter; + + ZEROS( Porter, pw.nrxx ); + for(int is=0; is(CHR.rho[is][ir], 0.0 ); + } + } + pw.FFT_chg.FFT3D(Porter, -1); + +// if(INPUT.gamma_only==1) fact=2.0; +// else fact=1.0; + + evloc=0.0; + double g[3]={0,0,0}; + + + complex *vg = new complex[pw.ngmc]; + ZEROS( vg, pw.ngmc ); + for (int it=0; itdvloc_coul (atom->zv, dvloc); + // + } + else + { + // + // normal case: dvloc contains dV_loc(G)/dG + // + this->dvloc_of_g ( atom->msh, atom->rab, atom->r, + atom->vloc_at, atom->zv, dvloc); + // + } + + for( ng = 0;ng< pw.ngmc;ng++) + { + const int j = pw.ig2fftc[ng]; + g[0]=pw.gcar[ng].x; + g[1]=pw.gcar[ng].y; + g[2]=pw.gcar[ng].z; + for (l = 0;l< 3;l++) + { + for (m = 0; m ) + ComplexMatrix dbecp( nkb, NBANDS); + ComplexMatrix becp( nkb, NBANDS); + + // vkb1: |Beta(nkb,npw)> + ComplexMatrix vkb1( nkb, wf.npwx ); + ComplexMatrix vkb0[3]; + for(int i=0;i<3;i++){ + vkb0[i].create(nkb, wf.npwx); + } + ComplexMatrix vkb2( nkb, wf.npwx ); + for (int ik = 0;ik < kv.nks;ik++) + { + for(int i=0;i<3;i++){ + vkb0[i].zero_out(); + } + vkb2.zero_out(); + + if (NSPIN==2) CURRENT_SPIN = kv.isk[ik]; + wf.npw = kv.ngk[ik]; + // generate vkb + if (ppcell.nkb > 0) + { + ppcell.getvnl(ik); + } + + // get becp according to wave functions and vkb + // important here ! becp must set zero!! + // vkb: Beta(nkb,npw) + // becp(nkb,nbnd): + becp.zero_out(); + for (int ib=0; ib qvec; + double qvec0[3]; + + for (int ipol = 0; ipol<3; ipol++) + { + for(int jpol = 0; jpol < ipol+1; jpol++) + { + dbecp.zero_out(); + vkb1.zero_out(); + for (int i = 0;i < nkb;i++) + { + for (int ig=0; ig 1e-8) qm1 = 1.0 / qvec.norm(); + else qm1 = 0; + dbecp(i,ib) += -2.0 * wf.evc[ik](ib,ig) * conj(vkb2(i,ig)) * qvec0[ipol] * qvec0[jpol] * qm1 * ucell.tpiba; + }//end ig + }//end i + }//end ib + +// don't need to reduce here, keep dbecp different in each processor, +// and at last sum up all the forces. +// Parallel_Reduce::reduce_complex_double_pool( dbecp.ptr, dbecp.ndata); + +// double *cf = new double[ucell.nat*3]; +// ZEROS(cf, ucell.nat); + for (int ib=0; ib *gk = new Vector3[npw]; + for (ig = 0;ig < npw;ig++) + { + gk[ig] = wf.get_1qvec_cartesian(ik, ig); + } + + dylmr2(x1, npw, gk, dylm, ipol); + + int jkb = 0; + for(int it = 0;it < ucell.ntype;it++) + { + if(test_pp>1) OUT("it",it); + // calculate beta in G-space using an interpolation table + const int nbeta = ucell.atoms[it].nbeta; + const int nh = ucell.atoms[it].nh; + + if(test_pp>1) OUT("nbeta",nbeta); + + for (nb = 0;nb < nbeta;nb++) + { + if(test_pp>1) OUT("ib",nb); + for (ig = 0;ig < npw;ig++) + { + const double gnorm = gk[ig].norm() * ucell.tpiba; + + //cout << "\n gk[ig] = " << gk[ig].x << " " << gk[ig].y << " " << gk[ig].z; + //cout << "\n gk.norm = " << gnorm; + + vq [ig] = Mathzone::Polynomial_Interpolation( + ppcell.tab, it, nb, NQX, DQ, gnorm ); + + } // enddo + + // add spherical harmonic part + for (ih = 0;ih < nh;ih++) + { + if (nb == ppcell.indv(it, ih)) + { + const int lm = static_cast( ppcell.nhtolm(it, ih) ); + for (ig = 0;ig < npw;ig++) + { + vkb1(ih, ig) = dylm(lm, ig) * vq [ig]; + } + + } + + } // end ih + + } // end nbeta + + // vkb1 contains all betas including angular part for type nt + // now add the structure factor and factor (-i)^l + for (ia=0; ia *sk = wf.get_sk(ik, it, ia); + for (ih = 0;ih < nh;ih++) + { + complex pref = pow( NEG_IMAG_UNIT, ppcell.nhtol(it, ih)); //? + for (ig = 0;ig < npw;ig++) + { + vkb(jkb, ig) = vkb1(ih, ig) * sk [ig] * pref; + } + ++jkb; + } // end ih + delete [] sk; + } // end ia + } // enddo + delete [] gk; + delete [] vq; + return; +}//end get_dvnl1 + +void Stress_Func::get_dvnl2(ComplexMatrix &vkb, + const int ik) +{ + if(test_pp) TITLE("Stress","get_dvnl2"); +// timer::tick("Stress","get_dvnl2"); + + const int lmaxkb = ppcell.lmaxkb; + if(lmaxkb < 0) + { + return; + } + + const int npw = kv.ngk[ik]; + const int nhm = ppcell.nhm; + int ig, ia, nb, ih; + matrix vkb1(nhm, npw); + double *vq = new double[npw]; + const int x1= (lmaxkb + 1)*(lmaxkb + 1); + + matrix ylm(x1, npw); + Vector3 *gk = new Vector3[npw]; + for (ig = 0;ig < npw;ig++) + { + gk[ig] = wf.get_1qvec_cartesian(ik, ig); + } + Mathzone::Ylm_Real(x1, npw, gk, ylm); + + int jkb = 0; + for(int it = 0;it < ucell.ntype;it++) + { + if(test_pp>1) OUT("it",it); + // calculate beta in G-space using an interpolation table + const int nbeta = ucell.atoms[it].nbeta; + const int nh = ucell.atoms[it].nh; + + if(test_pp>1) OUT("nbeta",nbeta); + + for (nb = 0;nb < nbeta;nb++) + { + if(test_pp>1) OUT("ib",nb); + for (ig = 0;ig < npw;ig++) + { + const double gnorm = gk[ig].norm() * ucell.tpiba; + //cout << "\n gk[ig] = " << gk[ig].x << " " << gk[ig].y << " " << gk[ig].z; + //cout << "\n gk.norm = " << gnorm; + vq [ig] = Polynomial_Interpolation_nl( + ppcell.tab, it, nb, DQ, gnorm ); + + } // enddo + + // add spherical harmonic part + for (ih = 0;ih < nh;ih++) + { + if (nb == ppcell.indv(it, ih)) + { + const int lm = static_cast( ppcell.nhtolm(it, ih) ); + for (ig = 0;ig < npw;ig++) + { + vkb1(ih, ig) = ylm(lm, ig) * vq [ig]; + } + } + } // end ih + } // end nbeta + + // vkb1 contains all betas including angular part for type nt + // now add the structure factor and factor (-i)^l + for (ia=0; ia *sk = wf.get_sk(ik, it, ia); + for (ih = 0;ih < nh;ih++) + { + complex pref = pow( NEG_IMAG_UNIT, ppcell.nhtol(it, ih)); //? + for (ig = 0;ig < npw;ig++) + { + vkb(jkb, ig) = vkb1(ih, ig) * sk [ig] * pref; + } + ++jkb; + } // end ih + delete [] sk; + } // end ia + } // enddo + + delete [] gk; + delete [] vq; +// timer::tick("Stress","get_dvnl2"); + + return; +} + + + + +double Stress_Func::Polynomial_Interpolation_nl +( + const realArray &table, + const int &dim1, + const int &dim2, + const double &table_interval, + const double &x // input value +) +{ +// timer::tick("Mathzone","Poly_Interpo_2"); + assert(table_interval>0.0); + const double position = x / table_interval; + const int iq = static_cast(position); + + const double x0 = position - static_cast(iq); + const double x1 = 1.0 - x0; + const double x2 = 2.0 - x0; + const double x3 = 3.0 - x0; + const double y= + ( table(dim1, dim2, iq) * (-x2*x3-x1*x3-x1*x2) / 6.0 + + table(dim1, dim2, iq+1) * (+x2*x3-x0*x3-x0*x2) / 2.0 - + table(dim1, dim2, iq+2) * (+x1*x3-x0*x3-x0*x1) / 2.0 + + table(dim1, dim2, iq+3) * (+x1*x2-x0*x2-x0*x1) / 6.0 )/table_interval ; + +// timer::tick("Mathzone","Poly_Interpo_2"); + return y; +} + +void Stress_Func::dylmr2 ( + const int nylm, + const int ngy, + Vector3 *gk, + matrix &dylm, + const int ipol) +{ + //----------------------------------------------------------------------- + // + // compute \partial Y_lm(G) \over \partial (G)_ipol + // using simple numerical derivation (SdG) + // The spherical harmonics are calculated in ylmr2 + // + //int nylm, ngy, ipol; + // number of spherical harmonics + // the number of g vectors to compute + // desired polarization + //double g (3, ngy), gg (ngy), dylm (ngy, nylm) + // the coordinates of g vectors + // the moduli of g vectors + // the spherical harmonics derivatives + // + int ig, lm; + // counter on g vectors + // counter on l,m component + + const double delta = 1e-6; + double *dg, *dgi; + + matrix ylmaux; + // dg is the finite increment for numerical derivation: + // dg = delta |G| = delta * sqrt(gg) + // dgi= 1 /(delta * sqrt(gg)) + // gx = g +/- dg + + + Vector3 *gx = new Vector3 [ngy]; + + + dg = new double [ngy]; + dgi = new double [ngy]; + + ylmaux.create (nylm, ngy); + + dylm.zero_out(); + ylmaux.zero_out(); + + for( ig = 0;ig< ngy;ig++){ + gx[ig] = gk[ig]; + } + //$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(ig) + for( ig = 0;ig< ngy;ig++){ + dg [ig] = delta * gx[ig].norm() ; + if (gx[ig].norm2() > 1e-9) { + dgi [ig] = 1.0 / dg [ig]; + } + else{ + dgi [ig] = 0.0; + } + } + //$OMP END PARALLEL DO + + //$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(ig) + for( ig = 0;ig< ngy;ig++){ + if(ipol==0) + gx [ig].x = gk[ ig].x + dg [ig]; + else if(ipol==1) + gx [ig].y = gk [ ig].y + dg [ig]; + else if(ipol==2) + gx [ig].z = gk [ ig].z + dg [ig]; + } + //$OMP END PARALLEL DO + + Mathzone::Ylm_Real(nylm, ngy, gx, dylm); + //$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(ig) + for(ig = 0;ig< ngy;ig++){ + if(ipol==0) + gx [ig].x = gk [ ig].x - dg [ig]; + else if(ipol==1) + gx [ig].y = gk [ ig].y - dg [ig]; + else if(ipol==2) + gx [ig].z = gk [ ig].z - dg [ig]; + } + //$OMP END PARALLEL DO + + Mathzone::Ylm_Real(nylm, ngy, gx, ylmaux); + + + // zaxpy ( - 1.0, ylmaux, 1, dylm, 1); + for( lm = 0;lm< nylm;lm++){ + for(ig = 0;ig< ngy;ig++){ + dylm (lm,ig) = dylm(lm,ig) - ylmaux(lm,ig); + } + } + + + for( lm = 0;lm< nylm;lm++){ + //$OMP PARALLEL DO DEFAULT(SHARED) PRIVATE(ig) + for(ig = 0;ig< ngy;ig++){ + dylm (lm,ig) = dylm(lm,ig) * 0.5 * dgi [ig]; + } + //$OMP END PARALLEL DO + } + delete[] gx; + delete[] dg; + delete[] dgi; + + return; +} diff --git a/ABACUS.develop/source/src_pw/stress_func_print.cpp b/ABACUS.develop/source/src_pw/stress_func_print.cpp new file mode 100644 index 0000000000..d1162846a5 --- /dev/null +++ b/ABACUS.develop/source/src_pw/stress_func_print.cpp @@ -0,0 +1,104 @@ +#include"stress_func.h" + +static double output_acc = 1.0e-8; + +//print target stress term +void Stress_Func::print_stress(const string &name, const matrix& f, const bool screen, bool ry)const +{ + ofs_running << " --------------------------- " << name << " ----------------------------" << endl; + + + double fac = 1.0; + + if(!ry) + { + // fac = Ry_to_eV / 0.529177; + } + + cout << setprecision(5); + cout << setiosflags(ios::showpos); + + if(screen) + { + cout << " ------------------- " << name << " --------------------" << endl; + + } + + for (int i=0;i<3;i++) + { + ofs_running << setw(15)<< " "; + if( abs(f(i,0)) >output_acc) ofs_running << setw(15) << f(i,0) * fac; + else ofs_running << setw(15) << "0"; + if( abs(f(i,1)) >output_acc) ofs_running << setw(15) << f(i,1) * fac; + else ofs_running << setw(15) << "0"; + if( abs(f(i,2)) >output_acc) ofs_running << setw(15) << f(i,2) * fac; + else ofs_running << setw(15) << "0"; + ofs_running << endl; + + if(screen) + { + if( abs(f(i,0)) >output_acc) cout << setw(15) << f(i,0)*fac; + else cout << setw(15) << "0"; + if( abs(f(i,1)) >output_acc) cout << setw(15) << f(i,1)*fac; + else cout << setw(15) << "0"; + if( abs(f(i,2)) >output_acc) cout << setw(15) << f(i,2)*fac; + else cout << setw(15) << "0"; + cout << endl; + } + } + + + cout << resetiosflags(ios::showpos); + + return; +} + +//print total stress +void Stress_Func::printstress_total(const matrix& scs, bool ry) +{ +// zhengdy update 2016-10-08 + double unit_transform = 1; + + if(!ry) + { + unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * 1.0e-8; + } +// cout.setf(ios::fixed); + + + //ofs_running << setiosflags(ios::right); + ofs_running << setprecision(6) << setiosflags(ios::showpos) << setiosflags(ios::fixed) << endl; + NEW_PART("TOTAL-STRESS (KBAR)");//Ryd/(a.u.)^3 + cout << " ><><><><><><><><><><><><><><><><><><><><><><" << endl; + cout << " TOTAL-STRESS (KBAR):" << endl; + cout << " ><><><><><><><><><><><><><><><><><><><><><><" << endl; + +// if(INPUT.stress_set == 1) +// int TEST_STRESS = 1; + + if(TEST_STRESS) + { + cout << setiosflags(ios::fixed) << setprecision(6); + cout << setiosflags(ios::showpos); + cout << " ------------------- TOTAL STRESS --------------------" << endl; + cout << " " << setw(8) << "STRESS" << endl; + ofs_running << " " << setw(12) << "STRESS" << endl; + } + + + for (int i=0; i<3; i++) + { + + //if(TEST_STRESS) + cout << " " << setw(15) << scs(i,0)*unit_transform << setw(15) + << scs(i,1)*unit_transform << setw(15) << scs(i,2)*unit_transform << endl; + + ofs_running << " " << setw(15) << scs(i,0)*unit_transform << setw(15) + << scs(i,1)*unit_transform << setw(15) << scs(i,2)*unit_transform << endl; + + } + ofs_running << setiosflags(ios::left); + cout << resetiosflags(ios::showpos); + + return; +} diff --git a/ABACUS.develop/source/src_pw/stress_pw.cpp b/ABACUS.develop/source/src_pw/stress_pw.cpp new file mode 100644 index 0000000000..69f3335149 --- /dev/null +++ b/ABACUS.develop/source/src_pw/stress_pw.cpp @@ -0,0 +1,123 @@ +#include "./stress_pw.h" +#include "./H_XC_pw.h" + + +void Stress_PW::cal_stress(matrix& sigma) +{ + TITLE("Stress_PW","cal_stress"); + timer::tick("Stress_PW","cal_stress",'E'); + + matrix sigmaxc; + sigmaxc.create(3,3); + matrix sigmatot; + sigmatot.create(3,3); + matrix sigmahar; + sigmahar.create(3,3); + matrix sigmakin; + sigmakin.create(3,3); + matrix sigmaloc; + sigmaloc.create(3,3); + matrix sigmanl; + sigmanl.create(3,3); + matrix sigmaewa; + sigmaewa.create(3,3); + matrix sigmaxcc; + sigmaxcc.create(3,3); + matrix sigmavdw; + sigmavdw.create(3,3); + for(int i=0;i<3;i++) + { + for(int j=0;j<3;j++) + { + sigmatot(i,j) = 0.0; + sigmaxc(i,j) = 0.0; + sigmahar(i,j) = 0.0; + sigmakin(i,j) = 0.0; + sigmaloc(i,j) = 0.0; + sigmanl(i,j) = 0.0; + sigmaewa(i,j) = 0.0; + sigmaxcc(i,j) = 0.0; + sigmavdw(i,j) = 0.0; + } + } + //kinetic contribution + stress_kin(sigmakin); + + //hartree contribution + stress_har(sigmahar, 1); + + //ewald contribution + stress_ewa(sigmaewa, 1); + + //xc contribution: add gradient corrections(non diagonal) + for(int i=0;i<3;i++) + { + sigmaxc(i,i) = - (H_XC_pw::etxc - H_XC_pw::vtxc) / ucell.omega; + } + stress_gga(sigmaxc); + + //local contribution + stress_loc(sigmaloc, 1); + + //nlcc + stress_cc(sigmaxcc, 1); + + //nonlocal + stress_nl(sigmanl); + + //vdw term + stress_vdw(sigmavdw); + + for(int ipol=0;ipol<3;ipol++) + { + for(int jpol=0;jpol<3;jpol++) + { + sigmatot(ipol,jpol) = sigmakin(ipol,jpol) + + sigmahar(ipol,jpol) + + sigmanl(ipol,jpol) + + sigmaxc(ipol,jpol) + + sigmaxcc(ipol,jpol) + + sigmaewa(ipol,jpol) + + sigmaloc(ipol,jpol); + + sigmavdw(ipol,jpol); + } + } + + if(Symmetry::symm_flag) + { + symm.stress_symmetry(sigmatot); + } + + bool ry = false; + this->printstress_total(sigmatot, ry); + + if(TEST_STRESS) + { + ofs_running << "\n PARTS OF STRESS: " << endl; + ofs_running << setiosflags(ios::showpos); + ofs_running << setiosflags(ios::fixed) << setprecision(10) << endl; + this->print_stress("KINETIC STRESS",sigmakin,TEST_STRESS,ry); + this->print_stress("LOCAL STRESS",sigmaloc,TEST_STRESS,ry); + this->print_stress("HARTREE STRESS",sigmahar,TEST_STRESS,ry); + this->print_stress("NON-LOCAL STRESS",sigmanl,TEST_STRESS,ry); + this->print_stress("XC STRESS",sigmaxc,TEST_STRESS,ry); + this->print_stress("EWALD STRESS",sigmaewa,TEST_STRESS,ry); + this->print_stress("NLCC STRESS",sigmaxcc,TEST_STRESS,ry); + this->print_stress("TOTAL STRESS",sigmatot,TEST_STRESS,ry); + } + return; + +} + +void Stress_PW::stress_vdw(matrix& sigma) +{ + if(vdwd2.vdwD2) //Peize Lin add 2014-04-04, update 2019-04-26 + { + vdwd2.force(sigma, 1); + } + if(vdwd3.vdwD3) //jiyy add 2019-05-18 + { + vdwd3.force(sigma, 1); + } + return; +} diff --git a/ABACUS.develop/source/src_pw/stress_pw.h b/ABACUS.develop/source/src_pw/stress_pw.h new file mode 100644 index 0000000000..48e5ce1234 --- /dev/null +++ b/ABACUS.develop/source/src_pw/stress_pw.h @@ -0,0 +1,23 @@ +#ifndef STRESS_PW_H +#define STRESS_PW_H + +#include "stress_func.h" + +class Stress_PW:public Stress_Func +{ + public : + + Stress_PW (){}; + ~Stress_PW (){}; + + //calculate the stress in PW basis + void cal_stress(matrix& sigma); + + private : + //call the vdw stress + void stress_vdw(matrix& sigma); //force and stress calculated in vdw together. + + + +}; +#endif diff --git a/ABACUS.develop/source/src_pw/symmetry.cpp b/ABACUS.develop/source/src_pw/symmetry.cpp index 60907d3c95..7a171f8687 100644 --- a/ABACUS.develop/source/src_pw/symmetry.cpp +++ b/ABACUS.develop/source/src_pw/symmetry.cpp @@ -1593,7 +1593,7 @@ void Symmetry::force_symmetry(matrix &force , double* pos) // pengfei 2016-12- return; } -void Symmetry::stress_symmetry(double sigma[][3]) //zhengdy added 2017 +void Symmetry::stress_symmetry(matrix& sigma) //zhengdy added 2017 { double *tot_sigma, *temp; tot_sigma = new double[9]; @@ -1619,7 +1619,7 @@ void Symmetry::stress_symmetry(double sigma[][3]) //zhengdy added 2017 { for(int l=0;l<3;l++) { - tot_sigma[i*3 +j] += sigma[k][l] * temp[i*3+k] * temp[j*3+l]; + tot_sigma[i*3 +j] += sigma(k,l) * temp[i*3+k] * temp[j*3+l]; } } } @@ -1628,7 +1628,7 @@ void Symmetry::stress_symmetry(double sigma[][3]) //zhengdy added 2017 { for(int j = 0;j<3;j++) { - sigma[i][j] = tot_sigma[i*3+j]; + sigma(i,j) = tot_sigma[i*3+j]; } } ZEROS(temp, 9); @@ -1654,7 +1654,7 @@ void Symmetry::stress_symmetry(double sigma[][3]) //zhengdy added 2017 { for( int m=0; m<3; m++) { - tot_sigma[i * 3 +j] += sigma[l][m] * temp[i * 3 + l] * temp[j * 3 + m]; + tot_sigma[i * 3 +j] += sigma(l,m) * temp[i * 3 + l] * temp[j * 3 + m]; } } } @@ -1665,7 +1665,7 @@ void Symmetry::stress_symmetry(double sigma[][3]) //zhengdy added 2017 { for (int j = 0; j < 3; j++) { - sigma[i][j] = tot_sigma[i *3 + j] / nrotk; + sigma(i,j) = tot_sigma[i *3 + j] / nrotk; } } @@ -1696,7 +1696,7 @@ void Symmetry::stress_symmetry(double sigma[][3]) //zhengdy added 2017 { for(int l=0;l<3;l++) { - tot_sigma[i*3 +j] += sigma[k][l] * temp[i*3+k] * temp[j*3+l]; + tot_sigma[i*3 +j] += sigma(k,l) * temp[i*3+k] * temp[j*3+l]; } } } @@ -1706,7 +1706,7 @@ void Symmetry::stress_symmetry(double sigma[][3]) //zhengdy added 2017 { for(int j = 0;j<3;j++) { - sigma[i][j] = tot_sigma[i*3+j]; + sigma(i,j) = tot_sigma[i*3+j]; } } diff --git a/ABACUS.develop/source/src_pw/symmetry.h b/ABACUS.develop/source/src_pw/symmetry.h index 874d48db64..8a1f3ce4ed 100644 --- a/ABACUS.develop/source/src_pw/symmetry.h +++ b/ABACUS.develop/source/src_pw/symmetry.h @@ -91,7 +91,7 @@ class Symmetry : public Symmetry_Basic void checksym(Matrix3 &s, Vector3 >rans, double *pos); void rho_symmetry(double *rho, const int &nr1, const int &nr2, const int &nr3); void force_symmetry(matrix &force, double* pos); - void stress_symmetry(double sigma[][3]); + void stress_symmetry(matrix &sigma); void write(); void print_pos(const double* pos, const int &nat); From b68266318d98866293d306016eb5083da51b4f10 Mon Sep 17 00:00:00 2001 From: mohan Date: Mon, 1 Mar 2021 13:41:52 +0800 Subject: [PATCH 165/233] update notes in potential_libxc --- .../source/src_pw/potential_libxc.cpp | 52 ++++++++++++++++--- .../source/src_pw/potential_libxc.h | 15 ++++++ 2 files changed, 61 insertions(+), 6 deletions(-) diff --git a/ABACUS.develop/source/src_pw/potential_libxc.cpp b/ABACUS.develop/source/src_pw/potential_libxc.cpp index 72bec55a30..b00709a31e 100644 --- a/ABACUS.develop/source/src_pw/potential_libxc.cpp +++ b/ABACUS.develop/source/src_pw/potential_libxc.cpp @@ -34,9 +34,14 @@ void Potential_Libxc::v_xc( //---------------------------------------------------------- vector funcs = init_func(); + // the type of input_tmp is automatically set to 'tuple' // [rho, sigma, gdr] = cal_input( funcs, rho_in ); const auto input_tmp = cal_input( funcs, rho_in ); + + // obtain the electron charge density rho from 'get' function (first variable) const vector &rho = std::get<0>(input_tmp); + + // obtain the sigma from 'get' function (second variable) const vector &sigma = std::get<1>(input_tmp); for( xc_func_type &func : funcs ) @@ -80,7 +85,9 @@ void Potential_Libxc::v_xc( vector v_tmp(4); v_tmp[0] = e2 * (0.5 * (vrho[ir*2] + vrho[ir*2+1])); const double vs = 0.5 * (vrho[ir*2] - vrho[ir*2+1]); - const double amag = sqrt( pow(rho_in[1][ir],2) + pow(rho_in[2][ir],2) + pow(rho_in[3][ir],2) ); + const double amag = sqrt( pow(rho_in[1][ir],2) + + pow(rho_in[2][ir],2) + + pow(rho_in[3][ir],2) ); if(amag>vanishing_charge) { @@ -123,6 +130,7 @@ void Potential_Libxc::v_xc( } } + // define two dimensional array dh [ nspin, pw.nrxx ] vector> dh(nspin0(), vector(pw.nrxx)); for( size_t is=0; is!=nspin0(); ++is ) { @@ -190,9 +198,13 @@ void Potential_Libxc::v_xc( } } + //------------------------------------------------------------------ + // "func.info->family" includes LDA, GGA, Hybrid functional (HYB). + //------------------------------------------------------------------ switch( func.info->family ) { case XC_FAMILY_LDA: + // call Libxc function: xc_lda_exc_vxc xc_lda_exc_vxc( &func, pw.nrxx, VECTOR_TO_PTR(rho), VECTOR_TO_PTR(exc), VECTOR_TO_PTR(vrho) ); process_exc(sgn); @@ -200,6 +212,7 @@ void Potential_Libxc::v_xc( break; case XC_FAMILY_GGA: case XC_FAMILY_HYB_GGA: + // call Libxc function: xc_gga_exc_vxc xc_gga_exc_vxc( &func, pw.nrxx, VECTOR_TO_PTR(rho), VECTOR_TO_PTR(sigma), VECTOR_TO_PTR(exc), VECTOR_TO_PTR(vrho), VECTOR_TO_PTR(vsigma) ); @@ -212,9 +225,14 @@ void Potential_Libxc::v_xc( +" unfinished in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); break; } + // Libxc function: Deallocate memory xc_func_end(&func); } + + //------------------------------------------------- + // for MPI, reduce the exchange-correlation energy + //------------------------------------------------- Parallel_Reduce::reduce_double_pool( etxc ); Parallel_Reduce::reduce_double_pool( vtxc ); @@ -226,21 +244,35 @@ void Potential_Libxc::v_xc( } +//---------------------------------------------------------------------------- // for adding new xc functionals, only this function needs to be updated // now we use iexch, igcx, icorr, igcc in xcf to characterize XC functionals +//---------------------------------------------------------------------------- std::vector Potential_Libxc::init_func() { + // 'funcs' is the return value std::vector funcs; const int xc_polarized = (1==nspin0()) ? XC_UNPOLARIZED : XC_POLARIZED; + //------------------------------------------- + // define a function named 'add_func', which + // will be called in the following codes + //------------------------------------------- auto add_func = [&]( const int function ) { funcs.push_back({}); + // 'xc_func_init' is defined in Libxc xc_func_init( &funcs.back(), function, xc_polarized ); }; - - if( 6==xcf.iexch_now && 8==xcf.igcx_now && 4==xcf.icorr_now && 4==xcf.igcc_now ) + + //-------------------------------------- + // for the exchange energy + //-------------------------------------- + if( 6==xcf.iexch_now && + 8==xcf.igcx_now && + 4==xcf.icorr_now && + 4==xcf.igcc_now ) // GGA functional { add_func( XC_HYB_GGA_XC_PBEH ); double parameter_hse[3] = { exx_global.info.hybrid_alpha, @@ -249,7 +281,10 @@ std::vector Potential_Libxc::init_func() xc_func_set_ext_params(&funcs.back(), parameter_hse); return funcs; } - else if( 9==xcf.iexch_now && 12==xcf.igcx_now && 4==xcf.icorr_now && 4==xcf.igcc_now ) + else if( 9==xcf.iexch_now && + 12==xcf.igcx_now && + 4==xcf.icorr_now && + 4==xcf.igcc_now ) // HSE06 hybrid functional { add_func( XC_HYB_GGA_XC_HSE06 ); double parameter_hse[3] = { exx_global.info.hybrid_alpha, @@ -259,11 +294,13 @@ std::vector Potential_Libxc::init_func() return funcs; } - if( 1==xcf.iexch_now && 0==xcf.igcx_now ) + if( 1==xcf.iexch_now && + 0==xcf.igcx_now ) // LDA functional { add_func( XC_LDA_X ); } - else if( 1==xcf.iexch_now && 3==xcf.igcx_now ) + else if( 1==xcf.iexch_now && + 3==xcf.igcx_now ) // GGA functional { add_func( XC_GGA_X_PBE ); } @@ -273,6 +310,9 @@ std::vector Potential_Libxc::init_func() +TO_STRING(xcf.igcx_now)+" unfinished in "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); } + //-------------------------------------- + // for the correlation energy part + //-------------------------------------- if( 1==xcf.icorr_now && 0==xcf.igcc_now ) { add_func( XC_LDA_C_PZ ); diff --git a/ABACUS.develop/source/src_pw/potential_libxc.h b/ABACUS.develop/source/src_pw/potential_libxc.h index 869e4c8713..54c3352523 100644 --- a/ABACUS.develop/source/src_pw/potential_libxc.h +++ b/ABACUS.develop/source/src_pw/potential_libxc.h @@ -21,6 +21,10 @@ class Potential_Libxc { public: + //------------------------------------------------ + // evaluate the exchange-correlation (XC) energy + // by using the input charge density rho_in + //------------------------------------------------ static void v_xc( const double * const * const rho_in, double &etxc, @@ -29,8 +33,16 @@ class Potential_Libxc private: + //------------------------------------------- + // return the type of XC functional by + // calling init_func() + //------------------------------------------- static std::vector init_func(); + //------------------------------------------------ + // evaluate three quantities: rho, sigma, and gdr + // according to the input types of XC functionals + //------------------------------------------------ // [rho, sigma, gdr] = cal_input( funcs, rho_in ) static std::tuple< std::vector, @@ -40,6 +52,9 @@ class Potential_Libxc const std::vector &funcs, const double * const * const rho_in ); + //---------------------------- + // decide the value of spin + //---------------------------- static int nspin0() // may need updates from SOC { if (NSPIN==1 || (NSPIN==4 && (!DOMAG && !DOMAG_Z))) return 1; From 9ae99443cba5fbd58f11f3357c66131e5b601e7b Mon Sep 17 00:00:00 2001 From: mohan Date: Mon, 1 Mar 2021 17:03:50 +0800 Subject: [PATCH 166/233] move blas_interface and ylm from src_lcao to src_global --- .../{src_lcao => src_global}/blas_interface.h | 0 .../source/{src_lcao => src_global}/ylm.cpp | 0 .../source/{src_lcao => src_global}/ylm.h | 0 .../{src_lcao => src_io}/cal_r_overlap_R.cpp | 32 +++++++++++++++++-- .../{src_lcao => src_io}/cal_r_overlap_R.h | 24 +++++++------- .../source/src_io/istate_charge.cpp | 17 ++++------ ABACUS.develop/source/src_io/istate_charge.h | 3 +- .../source/src_io/unk_overlap_lcao.h | 20 ++++++------ .../source/src_lcao/ORB_gen_tables.cpp | 4 +-- .../source/src_lcao/ORB_gen_tables.h | 4 +-- .../source/src_lcao/center2_orb-orb11.cpp | 2 +- .../source/src_lcao/center2_orb-orb21.cpp | 4 +-- ABACUS.develop/source/src_lcao/gint_gamma.cpp | 6 ++-- ABACUS.develop/source/src_lcao/gint_k.cpp | 7 ++-- ABACUS.develop/source/src_lcao/gint_k_rho.cpp | 7 ++-- ABACUS.develop/source/src_lcao/gint_k_vl.cpp | 6 ++-- ABACUS.develop/source/src_lcao/grid_base.cpp | 4 +-- .../source/src_lcao/grid_base_beta.cpp | 5 ++- .../source/src_lcao/local_orbital_ions.cpp | 2 +- .../exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp | 6 ++-- .../source/src_ri/exx_abfs-matrix_orbs11.cpp | 4 +-- .../source/src_ri/exx_abfs-matrix_orbs21.cpp | 2 +- .../source/src_ri/exx_abfs-matrix_orbs22.cpp | 6 ++-- 23 files changed, 93 insertions(+), 72 deletions(-) rename ABACUS.develop/source/{src_lcao => src_global}/blas_interface.h (100%) rename ABACUS.develop/source/{src_lcao => src_global}/ylm.cpp (100%) rename ABACUS.develop/source/{src_lcao => src_global}/ylm.h (100%) rename ABACUS.develop/source/{src_lcao => src_io}/cal_r_overlap_R.cpp (94%) rename ABACUS.develop/source/{src_lcao => src_io}/cal_r_overlap_R.h (66%) diff --git a/ABACUS.develop/source/src_lcao/blas_interface.h b/ABACUS.develop/source/src_global/blas_interface.h similarity index 100% rename from ABACUS.develop/source/src_lcao/blas_interface.h rename to ABACUS.develop/source/src_global/blas_interface.h diff --git a/ABACUS.develop/source/src_lcao/ylm.cpp b/ABACUS.develop/source/src_global/ylm.cpp similarity index 100% rename from ABACUS.develop/source/src_lcao/ylm.cpp rename to ABACUS.develop/source/src_global/ylm.cpp diff --git a/ABACUS.develop/source/src_lcao/ylm.h b/ABACUS.develop/source/src_global/ylm.h similarity index 100% rename from ABACUS.develop/source/src_lcao/ylm.h rename to ABACUS.develop/source/src_global/ylm.h diff --git a/ABACUS.develop/source/src_lcao/cal_r_overlap_R.cpp b/ABACUS.develop/source/src_io/cal_r_overlap_R.cpp similarity index 94% rename from ABACUS.develop/source/src_lcao/cal_r_overlap_R.cpp rename to ABACUS.develop/source/src_io/cal_r_overlap_R.cpp index 5451668168..ff803ecd56 100644 --- a/ABACUS.develop/source/src_lcao/cal_r_overlap_R.cpp +++ b/ABACUS.develop/source/src_io/cal_r_overlap_R.cpp @@ -24,6 +24,8 @@ cal_r_overlap_R::~cal_r_overlap_R() void cal_r_overlap_R::init() { + TITLE("cal_r_overlap_R","init"); + this->R_x_num = GridD.getCellX(); this->R_y_num = GridD.getCellY(); this->R_z_num = GridD.getCellZ(); @@ -31,7 +33,7 @@ void cal_r_overlap_R::init() this->R_minY = (int)GridD.getD_minY(); this->R_minZ = (int)GridD.getD_minZ(); - + // allocate for psi_r_psi psi_r_psi = new Vector3 ***[R_x_num]; for(int ix = 0; ix < R_x_num; ix++) { @@ -48,7 +50,8 @@ void cal_r_overlap_R::init() this->allocate_psi_r_psi = true; - int Lmax_used, Lmax; + int Lmax_used=0; + int Lmax=0; MOT.allocate( ORB.get_ntype(),// number of atom types @@ -198,22 +201,45 @@ void cal_r_overlap_R::init() } for( auto &co1 : center2_orb11 ) + { for( auto &co2 : co1.second ) + { for( auto &co3 : co2.second ) + { for( auto &co4 : co3.second ) + { for( auto &co5 : co4.second ) + { for( auto &co6 : co5.second ) + { co6.second.init_radial_table(); + } + } + } + } + } + } for( auto &co1 : center2_orb21_r ) + { for( auto &co2 : co1.second ) + { for( auto &co3 : co2.second ) + { for( auto &co4 : co3.second ) + { for( auto &co5 : co4.second ) + { for( auto &co6 : co5.second ) + { co6.second.init_radial_table(); + } + } + } + } + } + } - return; } diff --git a/ABACUS.develop/source/src_lcao/cal_r_overlap_R.h b/ABACUS.develop/source/src_io/cal_r_overlap_R.h similarity index 66% rename from ABACUS.develop/source/src_lcao/cal_r_overlap_R.h rename to ABACUS.develop/source/src_io/cal_r_overlap_R.h index ef81b85353..4464e55353 100644 --- a/ABACUS.develop/source/src_lcao/cal_r_overlap_R.h +++ b/ABACUS.develop/source/src_io/cal_r_overlap_R.h @@ -8,20 +8,22 @@ using std::map; #include using std::set; -#include "../src_lcao/center2_orb.h" -#include "../src_lcao/center2_orb-orb11.h" -#include "../src_lcao/center2_orb-orb21.h" +#include "src_lcao/center2_orb.h" +#include "src_lcao/center2_orb-orb11.h" +#include "src_lcao/center2_orb-orb21.h" -#include "../src_lcao/ORB_radial_table.h" -#include "../src_lcao/ORB_gaunt_table.h" -#include "../src_lcao/ORB_atomic_lm.h" -#include "../src_lcao/ORB_read.h" -#include "../src_global/vector3.h" -#include "../src_lcao/ylm.h" -#include "../src_lcao/global_fp.h" +#include "src_lcao/ORB_radial_table.h" +#include "src_lcao/ORB_gaunt_table.h" +#include "src_lcao/ORB_atomic_lm.h" +#include "src_lcao/ORB_read.h" +#include "src_global/vector3.h" +#include "src_global/ylm.h" +#include "src_lcao/global_fp.h" -#include "../src_pw/global.h" +#include "src_pw/global.h" + +// output r_R matrix, added by Jingan class cal_r_overlap_R { diff --git a/ABACUS.develop/source/src_io/istate_charge.cpp b/ABACUS.develop/source/src_io/istate_charge.cpp index 48bb2ac4e8..d1fe886e92 100644 --- a/ABACUS.develop/source/src_io/istate_charge.cpp +++ b/ABACUS.develop/source/src_io/istate_charge.cpp @@ -2,22 +2,16 @@ #include "../src_pw/global.h" #include "../src_pw/tools.h" -IState_Charge::IState_Charge() -{ +IState_Charge::IState_Charge(){} -} - -IState_Charge::~IState_Charge() -{ - -} +IState_Charge::~IState_Charge(){} void IState_Charge::begin(void) { TITLE("IState_Charge","begin"); - cout << " perform |psi(i)|^2 for selected bands." << endl; + cout << " Perform |psi(i)|^2 for selected bands." << endl; if(!GAMMA_ONLY_LOCAL) { @@ -28,7 +22,9 @@ void IState_Charge::begin(void) if(NBANDS_ISTATE > 0) mode = 1; else mode = 2; - int fermi_band, bands_below, bands_above; + int fermi_band=0; + int bands_below=0; + int bands_above=0; // (2) cicle: // (2.1) calculate the selected density matrix @@ -42,7 +38,6 @@ void IState_Charge::begin(void) // (1.1) allocate the space for LOWF.WFC_GAMMA // (1.2) read in LOWF_GAMMA.dat - OUT(ofs_running,"LOWF.allocate_flag",LOWF.get_allocate_flag()); cout << " number of electrons = " << ucell.nelec << endl; diff --git a/ABACUS.develop/source/src_io/istate_charge.h b/ABACUS.develop/source/src_io/istate_charge.h index 63510f03b1..a112f53b6d 100644 --- a/ABACUS.develop/source/src_io/istate_charge.h +++ b/ABACUS.develop/source/src_io/istate_charge.h @@ -4,13 +4,14 @@ class IState_Charge { public: + IState_Charge(); ~IState_Charge(); void begin(); - private: + int *bands_picked; void idmatrix(const int &ib); diff --git a/ABACUS.develop/source/src_io/unk_overlap_lcao.h b/ABACUS.develop/source/src_io/unk_overlap_lcao.h index 6b97bd2c6e..e7dc7a0c16 100644 --- a/ABACUS.develop/source/src_io/unk_overlap_lcao.h +++ b/ABACUS.develop/source/src_io/unk_overlap_lcao.h @@ -8,18 +8,18 @@ using std::map; #include using std::set; -#include "../src_lcao/center2_orb.h" -#include "../src_lcao/center2_orb-orb11.h" -#include "../src_lcao/center2_orb-orb21.h" +#include "src_lcao/center2_orb.h" +#include "src_lcao/center2_orb-orb11.h" +#include "src_lcao/center2_orb-orb21.h" -#include "../src_lcao/ORB_radial_table.h" -#include "../src_lcao/ORB_gaunt_table.h" -#include "../src_lcao/ORB_atomic_lm.h" -#include "../src_lcao/ORB_read.h" -#include "../src_global/vector3.h" -#include "../src_lcao/ylm.h" +#include "src_lcao/ORB_radial_table.h" +#include "src_lcao/ORB_gaunt_table.h" +#include "src_lcao/ORB_atomic_lm.h" +#include "src_lcao/ORB_read.h" +#include "src_global/vector3.h" +#include "src_global/ylm.h" -#include "../src_pw/global.h" +#include "src_pw/global.h" class unkOverlap_lcao { diff --git a/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp b/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp index f96c37eba2..26a8298f0d 100644 --- a/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp @@ -1,7 +1,7 @@ -#include "../src_pw/global.h" +#include "src_pw/global.h" #include "ORB_read.h" #include "ORB_gen_tables.h" -#include "ylm.h" +#include "src_global/ylm.h" // here is a member of ORB_gen_tables class ORB_gen_tables UOT; diff --git a/ABACUS.develop/source/src_lcao/ORB_gen_tables.h b/ABACUS.develop/source/src_lcao/ORB_gen_tables.h index 4201237e1f..8ae7360adb 100644 --- a/ABACUS.develop/source/src_lcao/ORB_gen_tables.h +++ b/ABACUS.develop/source/src_lcao/ORB_gen_tables.h @@ -5,10 +5,10 @@ #ifndef USE_OVERLAP_TABLE_H #define USE_OVERLAP_TABLE_H -#include "../src_pw/tools.h" +#include "src_pw/tools.h" #include "ORB_radial_table.h" #include "ORB_gaunt_table.h" -#include "ylm.h" +#include "src_global/ylm.h" //------------------------------------ // used to be 'Use_Overlap_Table', diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb11.cpp b/ABACUS.develop/source/src_lcao/center2_orb-orb11.cpp index 098fee8536..00a1a71f73 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb11.cpp +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb11.cpp @@ -6,7 +6,7 @@ #include "center2_orb-orb11.h" #include "src_global/constants.h" -#include "src_lcao/ylm.h" +#include "src_global/ylm.h" #include diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb21.cpp b/ABACUS.develop/source/src_lcao/center2_orb-orb21.cpp index abc33a0e79..fa16ea7866 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb21.cpp +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb21.cpp @@ -6,7 +6,7 @@ #include "center2_orb-orb21.h" #include "src_global/constants.h" -#include "src_lcao/ylm.h" +#include "src_global/ylm.h" #include @@ -132,4 +132,4 @@ double Center2_Orb::Orb21::cal_overlap( } return overlap; -} \ No newline at end of file +} diff --git a/ABACUS.develop/source/src_lcao/gint_gamma.cpp b/ABACUS.develop/source/src_lcao/gint_gamma.cpp index 3575992e78..166454977e 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma.cpp @@ -1,7 +1,7 @@ #include "gint_gamma.h" -#include "../src_pw/global.h" -#include "ylm.h" -#include "../src_global/sltk_atom_arrange.h" +#include "src_pw/global.h" +#include "src_global/ylm.h" +#include "src_global/sltk_atom_arrange.h" Gint_Gamma::Gint_Gamma() { diff --git a/ABACUS.develop/source/src_lcao/gint_k.cpp b/ABACUS.develop/source/src_lcao/gint_k.cpp index f5ede0f3a8..4866746a71 100644 --- a/ABACUS.develop/source/src_lcao/gint_k.cpp +++ b/ABACUS.develop/source/src_lcao/gint_k.cpp @@ -1,11 +1,10 @@ -#include "../src_pw/tools.h" +#include "src_pw/tools.h" #include "gint_k.h" #include "LCAO_nnr.h" #include "ORB_read.h" #include "grid_technique.h" -#include "ylm.h" -#include "../src_pw/global.h" - +#include "src_global/ylm.h" +#include "src_pw/global.h" #include "global_fp.h" // mohan add 2021-01-30 Gint_k::Gint_k() diff --git a/ABACUS.develop/source/src_lcao/gint_k_rho.cpp b/ABACUS.develop/source/src_lcao/gint_k_rho.cpp index 634e0271f3..79915507a7 100644 --- a/ABACUS.develop/source/src_lcao/gint_k_rho.cpp +++ b/ABACUS.develop/source/src_lcao/gint_k_rho.cpp @@ -1,12 +1,11 @@ -#include "../src_pw/tools.h" +#include "src_pw/tools.h" #include "gint_k.h" #include "LCAO_nnr.h" #include "ORB_read.h" #include "grid_technique.h" -#include "ylm.h" -#include "../src_pw/global.h" +#include "src_global/ylm.h" +#include "src_pw/global.h" #include "src_global/blas_connector.h" - #include "global_fp.h" // mohan add 2021-01-30 inline void setVindex(const int ncyz, const int ibx, const int jby, const int kbz, int* vindex) diff --git a/ABACUS.develop/source/src_lcao/gint_k_vl.cpp b/ABACUS.develop/source/src_lcao/gint_k_vl.cpp index 0969dfe3cf..4a90e5ba4f 100644 --- a/ABACUS.develop/source/src_lcao/gint_k_vl.cpp +++ b/ABACUS.develop/source/src_lcao/gint_k_vl.cpp @@ -1,10 +1,10 @@ -#include "../src_pw/tools.h" +#include "src_pw/tools.h" #include "gint_k.h" #include "LCAO_nnr.h" #include "ORB_read.h" #include "grid_technique.h" -#include "ylm.h" -#include "../src_pw/global.h" +#include "src_global/ylm.h" +#include "src_pw/global.h" #include "src_global/blas_connector.h" //#include diff --git a/ABACUS.develop/source/src_lcao/grid_base.cpp b/ABACUS.develop/source/src_lcao/grid_base.cpp index 09644971a7..12c1264e2f 100644 --- a/ABACUS.develop/source/src_lcao/grid_base.cpp +++ b/ABACUS.develop/source/src_lcao/grid_base.cpp @@ -1,5 +1,5 @@ -#include "../src_pw/global.h" -#include "ylm.h" +#include "src_pw/global.h" +#include "src_global/ylm.h" #include "ORB_read.h" #include "grid_base.h" #include "global_fp.h" // mohan add 2021-01-30 diff --git a/ABACUS.develop/source/src_lcao/grid_base_beta.cpp b/ABACUS.develop/source/src_lcao/grid_base_beta.cpp index fef5d98700..b385e4a6af 100644 --- a/ABACUS.develop/source/src_lcao/grid_base_beta.cpp +++ b/ABACUS.develop/source/src_lcao/grid_base_beta.cpp @@ -1,6 +1,5 @@ -#include "../src_pw/global.h" -#include "ylm.h" - +#include "src_pw/global.h" +#include "src_global/ylm.h" #include "global_fp.h" // mohan add 2021-01-30 Grid_Base_Beta::Grid_Base_Beta() diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index 1d466cae5b..3b593988f3 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -7,7 +7,7 @@ #include "stress_lcao.h" #include "src_global/global_function.h" #include "src_io/hs_matrix.h" -#include "src_lcao/cal_r_overlap_R.h" +#include "src_io/cal_r_overlap_R.h" #include "src_ions/variable_cell.h" // mohan add 2021-02-01 #include "src_ri/exx_abfs.h" #include "src_ri/exx_opt_orb.h" diff --git a/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp b/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp index 499d3e1524..763692cab3 100644 --- a/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.cpp @@ -1,8 +1,8 @@ #include "exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h" -#include "../src_pw/global.h" +#include "src_pw/global.h" #include "src_lcao/ORB_read.h" -#include "src_lcao/ylm.h" -#include "../src_external/src_test/test_function.h" // Peize Lin test 2016-04-05 +#include "src_global/ylm.h" +#include "src_external/src_test/test_function.h" // Peize Lin test 2016-04-05 void Exx_Abfs::Matrix_Lcaoslcaos_Lcaoslcaos::init( const int mode, diff --git a/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs11.cpp b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs11.cpp index cc4fc86b35..b4b11c5e0c 100644 --- a/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs11.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs11.cpp @@ -4,7 +4,7 @@ #include #include "src_pw/global.h" #include "src_lcao/ORB_read.h" -#include "src_lcao/ylm.h" +#include "src_global/ylm.h" #include "src_global/global_function.h" #include // Peize Lin test @@ -323,4 +323,4 @@ gettimeofday( &t_start, NULL); ofs<<"TIME@Exx_Abfs::Matrix_Orbs11::cal_overlap_matrix\t"< #include "src_pw/global.h" #include "src_lcao/ORB_read.h" -#include "src_lcao/ylm.h" +#include "src_global/ylm.h" #include // Peize Lin test #include "src_external/src_test/test_function.h" // Peize Lin test 2016-04-05 diff --git a/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs22.cpp b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs22.cpp index 2999026054..ce9da0d84e 100644 --- a/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs22.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs22.cpp @@ -5,9 +5,9 @@ #include "src_pw/global.h" #include "src_lcao/ORB_read.h" -#include "src_lcao/ylm.h" +#include "src_global/ylm.h" -#include "../src_external/src_test/test_function.h" // Peize Lin test 2016-04-05 +#include "src_external/src_test/test_function.h" // Peize Lin test 2016-04-05 #include "src_external/src_test/src_ri/exx_lcao-test.h" #include "src_lcao/global_fp.h" @@ -309,4 +309,4 @@ gettimeofday( &t_start, NULL); ofs<<"TIME@Exx_Abfs::Matrix_Orbs22::cal_overlap_matrix\t"< Date: Tue, 2 Mar 2021 10:56:07 +0800 Subject: [PATCH 167/233] 1. delete void Wfc_Dm_2d::cal_dm(const matrix &wg, const int ik) --- ABACUS.develop/source/src_lcao/wfc_dm_2d.cpp | 142 ++++++++----------- ABACUS.develop/source/src_lcao/wfc_dm_2d.h | 6 +- 2 files changed, 64 insertions(+), 84 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/wfc_dm_2d.cpp b/ABACUS.develop/source/src_lcao/wfc_dm_2d.cpp index cbe87159e3..e98017514e 100644 --- a/ABACUS.develop/source/src_lcao/wfc_dm_2d.cpp +++ b/ABACUS.develop/source/src_lcao/wfc_dm_2d.cpp @@ -15,6 +15,7 @@ void Wfc_Dm_2d::init() { + TITLE("Wfc_Dm_2d", "init"); if(GAMMA_ONLY_LOCAL) { wfc_gamma.resize(NSPIN); @@ -29,6 +30,8 @@ void Wfc_Dm_2d::init() void Wfc_Dm_2d::cal_dm(const matrix &wg) { + TITLE("Wfc_Dm_2d", "cal_dm"); + #ifdef TEST_DIAG { static int istep=0; @@ -52,7 +55,36 @@ void Wfc_Dm_2d::cal_dm(const matrix &wg) assert(wg.nr==NSPIN); for(int is=0; is!=NSPIN; ++is) { - cal_dm(wg,is); + std::vector wg_local(ParaO.ncol,0.0); + for(int ib_global=0; ib_global!=wg.nc; ++ib_global) + { + const int ib_local = ParaO.trace_loc_col[ib_global]; + if(ib_local>=0) + { + wg_local[ib_local] = wg(is,ib_global); + } + } + + // wg_wfc(ib,iw) = wg[ib] * wfc(ib,iw); + matrix wg_wfc(wfc_gamma[is]); + for(int ir=0; ir!=wg_wfc.nr; ++ir) + { + LapackConnector::scal( wg_wfc.nc, wg_local[ir], wg_wfc.c+ir*wg_wfc.nc, 1 ); + } + + // C++: dm(iw1,iw2) = wfc(ib,iw1).T * wg_wfc(ib,iw2) + const double one_float=1.0, zero_float=0.0; + const int one_int=1; + const char N_char='N', T_char='T'; + dm_gamma[is].create( wfc_gamma[is].nr, wfc_gamma[is].nc ); + pdgemm_( + &N_char, &T_char, + &NLOCAL, &NLOCAL, &wg.nc, + &one_float, + wg_wfc.c, &one_int, &one_int, ParaO.desc, + wfc_gamma[is].c, &one_int, &one_int, ParaO.desc, + &zero_float, + dm_gamma[is].c, &one_int, &one_int, ParaO.desc); } } else @@ -60,7 +92,36 @@ void Wfc_Dm_2d::cal_dm(const matrix &wg) assert(wg.nr==kv.nks); for(int ik=0; ik!=kv.nks; ++ik) { - cal_dm(wg,ik); + std::vector wg_local(ParaO.ncol,0.0); + for(int ib_global=0; ib_global!=wg.nc; ++ib_global) + { + const int ib_local = ParaO.trace_loc_col[ib_global]; + if(ib_local>=0) + { + wg_local[ib_local] = wg(ik,ib_global); + } + } + + // wg_wfc(ib,iw) = wg[ib] * wfc(ib,iw).conj(); + ComplexMatrix wg_wfc = conj(wfc_k[ik]); + for(int ir=0; ir!=wg_wfc.nr; ++ir) + { + LapackConnector::scal( wg_wfc.nc, wg_local[ir], wg_wfc.c+ir*wg_wfc.nc, 1 ); + } + + // C++: dm(iw1,iw2) = wfc(ib,iw1).T * wg_wfc(ib,iw2) + const double one_float=1.0, zero_float=0.0; + const int one_int=1; + const char N_char='N', T_char='T'; + dm_k[ik].create( wfc_k[ik].nr, wfc_k[ik].nc ); + pzgemm_( + &N_char, &T_char, + &NLOCAL, &NLOCAL, &wg.nc, + &one_float, + wg_wfc.c, &one_int, &one_int, ParaO.desc, + wfc_k[ik].c, &one_int, &one_int, ParaO.desc, + &zero_float, + dm_k[ik].c, &one_int, &one_int, ParaO.desc); } } @@ -81,80 +142,3 @@ void Wfc_Dm_2d::cal_dm(const matrix &wg) return; } - -void Wfc_Dm_2d::cal_dm(const matrix &wg, const int ik) -{ - TITLE("Wfc_Dm_2d","cal_dm"); - - // dm = wfc.T * wg * wfc.conj() - // dm[ik](iw1,iw2) = \sum_{ib} wfc[ik](ib,iw1).T * wg(ik,ib) * wfc[ik](ib,iw2).conj() - assert(wg.nc<=NLOCAL); - if(GAMMA_ONLY_LOCAL) - { - std::vector wg_local(ParaO.ncol,0.0); - for(int ib_global=0; ib_global!=wg.nc; ++ib_global) - { - const int ib_local = ParaO.trace_loc_col[ib_global]; - if(ib_local>=0) - { - wg_local[ib_local] = wg(ik,ib_global); - } - } - - // wg_wfc(ib,iw) = wg[ib] * wfc(ib,iw); - matrix wg_wfc(wfc_gamma[ik]); - for(int ir=0; ir!=wg_wfc.nr; ++ir) - { - LapackConnector::scal( wg_wfc.nc, wg_local[ir], wg_wfc.c+ir*wg_wfc.nc, 1 ); - } - - // C++: dm(iw1,iw2) = wfc(ib,iw1).T * wg_wfc(ib,iw2) - const double one_float=1.0, zero_float=0.0; - const int one_int=1; - const char N_char='N', T_char='T'; - dm_gamma[ik].create( wfc_gamma[ik].nr, wfc_gamma[ik].nc ); - pdgemm_( - &N_char, &T_char, - &NLOCAL, &NLOCAL, &wg.nc, - &one_float, - wg_wfc.c, &one_int, &one_int, ParaO.desc, - wfc_gamma[ik].c, &one_int, &one_int, ParaO.desc, - &zero_float, - dm_gamma[ik].c, &one_int, &one_int, ParaO.desc); - } - else - { - std::vector wg_local(ParaO.ncol,0.0); - for(int ib_global=0; ib_global!=wg.nc; ++ib_global) - { - const int ib_local = ParaO.trace_loc_col[ib_global]; - if(ib_local>=0) - { - wg_local[ib_local] = wg(ik,ib_global); - } - } - - // wg_wfc(ib,iw) = wg[ib] * wfc(ib,iw).conj(); - ComplexMatrix wg_wfc = conj(wfc_k[ik]); - for(int ir=0; ir!=wg_wfc.nr; ++ir) - { - LapackConnector::scal( wg_wfc.nc, wg_local[ir], wg_wfc.c+ir*wg_wfc.nc, 1 ); - } - - // C++: dm(iw1,iw2) = wfc(ib,iw1).T * wg_wfc(ib,iw2) - const double one_float=1.0, zero_float=0.0; - const int one_int=1; - const char N_char='N', T_char='T'; - dm_k[ik].create( wfc_k[ik].nr, wfc_k[ik].nc ); - pzgemm_( - &N_char, &T_char, - &NLOCAL, &NLOCAL, &wg.nc, - &one_float, - wg_wfc.c, &one_int, &one_int, ParaO.desc, - wfc_k[ik].c, &one_int, &one_int, ParaO.desc, - &zero_float, - dm_k[ik].c, &one_int, &one_int, ParaO.desc); - } - - return; -} diff --git a/ABACUS.develop/source/src_lcao/wfc_dm_2d.h b/ABACUS.develop/source/src_lcao/wfc_dm_2d.h index f126c0b9f7..436fbb79c3 100644 --- a/ABACUS.develop/source/src_lcao/wfc_dm_2d.h +++ b/ABACUS.develop/source/src_lcao/wfc_dm_2d.h @@ -17,20 +17,16 @@ class Wfc_Dm_2d // wfc stands for wave functions std::vector wfc_gamma; // wfc_gamma[is](ib,iw); - std::vector wfc_k; // wfc_k[ik](ib,iw); // dm stands for density matrix std::vector dm_gamma; // dm_gamma[is](iw1,iw2); - std::vector dm_k; // dm_k[ik](iw1,iw2); void init(void); - void cal_dm(const matrix &wg); // wg(ik,ib), cal all dm - - void cal_dm(const matrix &wg, const int ik); // wg(ik,ib), cal only dm[ik] // dm = wfc.T * wg * wfc.conj() + void cal_dm(const matrix &wg); // wg(ik,ib), cal all dm }; #endif From e757fba576f323029ab926e89f013e466467ec5e Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 2 Mar 2021 17:23:40 +0800 Subject: [PATCH 168/233] add some notes in charge_extra.h and charge_extra.cpp --- .../source/src_lcao/local_orbital_ions.cpp | 44 +--- ABACUS.develop/source/src_pw/charge_extra.cpp | 220 ++++-------------- ABACUS.develop/source/src_pw/charge_extra.h | 14 +- ABACUS.develop/source/src_pw/ions.cpp | 2 +- 4 files changed, 68 insertions(+), 212 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index 3b593988f3..f7041bc6c4 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -43,7 +43,7 @@ void Local_Orbital_Ions::opt_ions(void) //Ions_Move_Methods IMM.allocate(); //Charge_Extrapolation - CE.allocate(); + CE.allocate_ions(); } // pengfei Li 2018-05-14 @@ -325,68 +325,40 @@ bool Local_Orbital_Ions::force_stress(const int &istep, int &force_step, int &st } timer::tick("Local_Orbital_Ions","force_stress",'D'); - //return 0; - - //if(FORCE) + //-------------------------------------------------- + // only forces are needed, no stresses are needed + //-------------------------------------------------- if(FORCE && !STRESS) { - //force_lo - Force_LCAO FL; // init the class. + Force_LCAO FL; FL.allocate (); FL.start_force(); - // (2) move the ions according to - // the algorithms of molecular dynamics. - //if(CALCULATION=="md") - //{ - // md.init_md(istep, FL.fcs); - //} - // move the atoms according to CG or BFGS - // methods. - //else - //{ - //---------- for test --------------------- - //FL.fcs.zero_out(); // mohan test - //ofstream ofs("tmp_force.txt"); - //ifstream ifs("tmp_force.txt"); - //for(int i=0; i> FL.fcs.c[i]; - //} - //ofs.close(); - //ifs.close(); - //----------------------------------------- - #ifdef __MPI //2015-10-01, xiaohui atom_arrange::delete_vector( SEARCH_RADIUS ); #endif //2015-10-01, xiaohui - //xiaohui add CALCULATION==relax 2015-09-30 - //if(CALCULATION=="relax") IMM.cal_movement(istep, FL.fcs, en.etot); if(CALCULATION=="relax") { IMM.cal_movement(istep, istep, FL.fcs, en.etot); if(IMM.get_converged() || (istep==NSTEP)) { - return 1; + return 1; // 1 means converged } - else + else // ions are not converged { CE.istep = istep; CE.extrapolate_charge(); - if(pot.extra_pot=="dm")//xiaohui modify 2015-02-01 + if(pot.extra_pot=="dm") { - // done after grid technique. } else { pot.init_pot( istep ); } } - return 0; } else diff --git a/ABACUS.develop/source/src_pw/charge_extra.cpp b/ABACUS.develop/source/src_pw/charge_extra.cpp index 162fd98d1c..8ef14f105c 100644 --- a/ABACUS.develop/source/src_pw/charge_extra.cpp +++ b/ABACUS.develop/source/src_pw/charge_extra.cpp @@ -6,11 +6,12 @@ Charge_Extra::Charge_Extra() { init_rho = false; - //xiaohui add 2014-05-07, for first-order extrapolation + + // for first-order extrapolation this->delta_rho1 = new double*[NSPIN]; this->delta_rho2 = new double*[NSPIN]; this->delta_rho = new double*[NSPIN]; - //xiaohui add 2014-05-10, for second-order extrapolation + // for second-order extrapolation this->delta_rho3 = new double*[NSPIN]; for(int is=0; isdim = 0;//xiaohui modify 2015-02-01 - //xiaohui add 2014-05-10, for second-order extrapolation + + this->dim = 0; + + // for the second-order extrapolation pos_dim = ucell.nat * 3; delete[] this->pos_old1; @@ -101,35 +98,12 @@ void Charge_Extra::allocate(void) ZEROS(pos_now, pos_dim); ZEROS(pos_next, pos_dim); - /* xiaohui modify 2014-05-12, test - //xiaohui add 2014-05-11, test - delete[] this->pos_old1; - this->pos_old1 = new double[pos_dim]; - ZEROS(pos_old1, pos_dim); - - delete[] this->pos_old2; - this->pos_old2 = new double[pos_dim]; - ZEROS(pos_old2, pos_dim); - - //delete[] this->pos_now; - //this->pos_now = new double[pos_dim]; - //ZEROS(pos_now, pos_dim); - - //delete[] this->pos_next; - //this->pos_next = new double[pos_dim]; - //ZEROS(pos_next, pos_dim); - */ - - //cout<<"here pos_dim is: "<rho_ion = new double**[dim]; for(int i=0; irho_ion[0][is][ir]; - } + //------------------------------------------------------- - // (3) save the current charge density for next step. - for(int ir=0; irrho_ion[0][is][ir] = rho_tmp[ir]; - } - - delete[] rho_tmp; - } - } - else if(pot.extra_pot == 2) - { - // 2 nd order - } - else if(pot.extra_pot == 3) - { - // start from atomic charge density. - // worst method ever! - CHR.atomic_rho(NSPIN, CHR.rho); - } -xiaohui modify 2015-02-01*/ - //else if(pot.extra_pot == 4) if(pot.extra_pot == "dm")//xiaohui modify 2015-02-01 { - //if(LOCAL_BASIS!=4 || LINEAR_SCALING!=1) xiaohui modify 2013-09-01 - if(BASIS_TYPE=="pw" || BASIS_TYPE=="lcao_in_pw") //xiaohui add 2013-09-01 + if(BASIS_TYPE=="pw" || BASIS_TYPE=="lcao_in_pw") { - WARNING_QUIT("Charge_Extra","extrapolate_charge"); + WARNING_QUIT("Charge_Extra","charge extrapolation method is not available"); } else { pw.setup_structure_factor(); - // should not do this after grid_technique is done!. -// for(int is=0; isdelta_rho1 = new double*[NSPIN]; - //this->delta_rho2 = new double*[NSPIN]; - //this->delta_rho = new double*[NSPIN]; for(int is=0; isdelta_rho1 = new double*[NSPIN]; - //this->delta_rho2 = new double*[NSPIN]; - //this->delta_rho = new double*[NSPIN]; for(int is=0; is Date: Tue, 2 Mar 2021 20:39:55 +0800 Subject: [PATCH 169/233] move Input::Print to src_io --- ABACUS.develop/source/Makefile.Objects | 1 + ABACUS.develop/source/input.cpp | 317 +----------------- ABACUS.develop/source/input.h | 1 + ABACUS.develop/source/src_io/write_input.cpp | 292 ++++++++++++++++ ABACUS.develop/source/src_lcao/force_lcao.cpp | 35 +- ABACUS.develop/source/src_pw/forces.cpp | 7 +- 6 files changed, 319 insertions(+), 334 deletions(-) create mode 100644 ABACUS.develop/source/src_io/write_input.cpp diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 60a1235820..bf6b9a0ba1 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -14,6 +14,7 @@ HEADERS = *.h OBJS_MAIN=driver.o\ input.o \ +write_input.o\ input_conv.o\ run_pw.o\ run_lcao.o\ diff --git a/ABACUS.develop/source/input.cpp b/ABACUS.develop/source/input.cpp index fe4a8a8b55..6b08824743 100644 --- a/ABACUS.develop/source/input.cpp +++ b/ABACUS.develop/source/input.cpp @@ -2290,7 +2290,8 @@ void Input::Bcast() } #endif -void Input::Check(void) + + void Input::Check(void) { TITLE("Input","Check"); @@ -2939,320 +2940,6 @@ void Input::Check(void) return; } - - -void Input::Print(const string &fn)const -{ - if (MY_RANK!=0) return; - - TITLE("Input","Print"); - - ofstream ofs(fn.c_str()); - - //---------------------------------- - // output the information in INPUT. - //---------------------------------- - ofs << "INPUT_PARAMETERS" << endl; - ofs << setiosflags(ios::left); - - ofs << "#Parameters (1.General)" << endl; - OUTP(ofs,"suffix",suffix,"the name of main output directory"); - OUTP(ofs,"latname",latname,"the name of lattice name"); - OUTP(ofs,"atom_file",global_atom_card,"the filename of file containing atom positions");//xiaohui modify 2015-02-01 - OUTP(ofs,"kpoint_file",global_kpoint_card,"the name of file containing k points");//xiaohui modify 2015-02-01 - OUTP(ofs,"pseudo_dir",global_pseudo_dir,"the directory containing pseudo files"); - OUTP(ofs,"pseudo_type",global_pseudo_type,"the type pseudo files"); // mohan add 2013-05-20 (xiaohui add 2013-06-23) - OUTP(ofs,"dft_functional",dft_functional,"exchange correlation functional"); // xiaohui add 2015-03-24 -// OUTP(ofs,"wannier_card",wannier_card,"not used now"); - OUTP(ofs,"calculation",calculation,"test; scf; relax; nscf; ienvelope; istate;"); - OUTP(ofs,"ntype",ntype,"atom species number"); - OUTP(ofs,"nspin",nspin,"1: single spin; 2: up and down spin; 4: noncollinear spin"); - OUTP(ofs,"nbands",nbands,"number of bands"); - OUTP(ofs,"nbands_sto",nbands_sto,"number of stochastic bands"); - OUTP(ofs,"nbands_istate",nbands_istate,"number of bands around Fermi level for istate calulation"); - OUTP(ofs,"nche_sto",nche_sto,"number of orders for Chebyshev expansion in stochastic DFT"); - OUTP(ofs,"symmetry",symmetry,"turn symmetry on or off"); - OUTP(ofs,"nelec",nelec,"input number of electrons"); - //OUTP(ofs,"lmax1",lmax1,"lmax"); - ofs << "\n#Parameters (2.PW)" << endl; - OUTP(ofs,"ecutwfc",ecutwfc,"#energy cutoff for wave functions"); - //if(diago_type=="cg") xiaohui modify 2013-09-01 - if(ks_solver=="cg") //xiaohui add 2013-09-01 - { - OUTP(ofs,"diago_cg_maxiter",diago_cg_maxiter,"max iteration number for cg"); - OUTP(ofs,"diago_cg_prec",diago_cg_prec,"diago_cg_prec"); - } - //else if(diago_type=="dav") xiaohui modify 2013-09-01 - else if(ks_solver=="dav") //xiaohui add 2013-09-01 - { - OUTP(ofs,"diago_david_ndim",diago_david_ndim,"max dimension for davidson"); - } - OUTP(ofs,"ethr",ethr,"threshold for eigenvalues is cg electron iterations"); - OUTP(ofs,"dr2",dr2,"charge density error"); - OUTP(ofs,"start_wfc",start_wfc,"start wave functions are from 'atomic' or 'file'"); - OUTP(ofs,"start_charge",start_pot,"start charge is from 'atomic' or file"); - OUTP(ofs,"charge_extrap",charge_extrap,"atomic; first-order; second-order; dm:coefficients of SIA"); - OUTP(ofs,"out_charge",out_charge,">0 output charge density for selected electron steps"); - OUTP(ofs,"out_potential",out_potential,"output realspace potential"); - OUTP(ofs,"out_wf",out_wf,"output wave functions"); - OUTP(ofs,"out_dos",out_dos,"output energy and dos"); - OUTP(ofs,"out_band",out_band,"output energy and band structure"); - OUTP(ofs,"restart_save",restart_save,"print to disk every step for restart"); - OUTP(ofs,"restart_load",restart_load,"restart from disk"); -// OUTP(ofs,"ecutrho",ecutrho); -// OUTP(ofs,"ncx",ncx); -// OUTP(ofs,"ncy",ncy); -// OUTP(ofs,"ncz",ncz); - OUTP(ofs,"nx",nx,"number of points along x axis for FFT grid"); - OUTP(ofs,"ny",ny,"number of points along y axis for FFT grid"); - OUTP(ofs,"nz",nz,"number of points along z axis for FFT grid"); - - ofs << "\n#Parameters (3.Relaxation)" << endl; - //OUTP(ofs,"diago_type",DIAGO_TYPE,"cg; david; lapack; hpseps;"); xiaohui modify 2013-09-01 - OUTP(ofs,"ks_solver",KS_SOLVER,"cg; david; lapack; genelpa; hpseps; scalapack_gvx"); - OUTP(ofs,"niter",niter,"#number of electron iterations"); - //OUTP(ofs,"force",force,"calculate the force or not"); - OUTP(ofs,"force_set",force_set,"output the force_set or not"); - OUTP(ofs,"nstep",nstep,"number of ion iteration steps"); - OUTP(ofs,"out_stru",out_stru,"output the structure files after each ion step"); - OUTP(ofs,"force_thr",force_thr,"force threshold, unit: Ry/Bohr"); - OUTP(ofs,"force_thr_ev",force_thr*13.6058/0.529177,"force threshold, unit: eV/Angstrom"); - OUTP(ofs,"force_thr_ev2",force_thr_ev2,"force invalid threshold, unit: eV/Angstrom"); - OUTP(ofs,"stress_thr",stress_thr,"stress threshold"); //LiuXh add 20180515 - OUTP(ofs,"press1",press1,"target pressure, unit: KBar"); - OUTP(ofs,"press2",press2,"target pressure, unit: KBar"); - OUTP(ofs,"press3",press3,"target pressure, unit: KBar"); - OUTP(ofs,"bfgs_w1",bfgs_w1,"wolfe condition 1 for bfgs"); - OUTP(ofs,"bfgs_w2",bfgs_w2,"wolfe condition 2 for bfgs"); - OUTP(ofs,"trust_radius_max", trust_radius_max,"maximal trust radius, unit: Bohr"); - OUTP(ofs,"trust_radius_min", trust_radius_min,"minimal trust radius, unit: Bohr"); - OUTP(ofs,"trust_radius_ini", trust_radius_ini,"initial trust radius, unit: Bohr"); - OUTP(ofs,"stress",stress,"calculate the stress or not"); - OUTP(ofs,"fixed_axes",fixed_axes,"which axes are fixed"); - OUTP(ofs,"move_method",ion_dynamics,"bfgs; sd; cg; cg_bfgs;"); //pengfei add 2013-08-15 - OUTP(ofs,"out_level",out_level,"ie(for electrons); i(for ions);"); - OUTP(ofs,"out_dm",out_dm,">0 output density matrix"); - - OUTP(ofs,"out_descriptor",out_descriptor,">0 compute descriptor for deepks");//caoyu add 2020-11-24, mohan added 2021-01-03 - OUTP(ofs,"lmax_descriptor",lmax_descriptor,">0 lmax used in descriptor for deepks");//caoyu add 2020-11-24, mohan added 2021-01-03 - - ofs << "\n#Parameters (4.LCAO)" << endl; - //OUTP(ofs,"local_basis",local_basis,"0:PW; 1:LO in pw; 4:LCAO"); xiaohui modify 2013-09-01 - OUTP(ofs,"basis_type",basis_type,"PW; LCAO in pw; LCAO"); //xiaohui add 2013-09-01 - //OUTP(ofs,"linear_scaling",linear_scaling,"0:PW 1:LCAO 2:DMM"); xiaohui modify 2013-09-01 - //if(diago_type=="HPSEPS") xiaohui modify 2013-09-01 - if(ks_solver=="HPSEPS" || ks_solver=="genelpa" || ks_solver=="scalapack_gvx") //xiaohui add 2013-09-01 - { - OUTP(ofs,"nb2d",nb2d,"2d distribution of atoms"); - } - OUTP(ofs,"search_radius",search_radius,"input search radius (Bohr)"); - OUTP(ofs,"search_pbc",search_pbc,"input periodic boundary condition"); - OUTP(ofs,"lcao_ecut",lcao_ecut,"energy cutoff for LCAO"); - OUTP(ofs,"lcao_dk",lcao_dk,"delta k for 1D integration in LCAO"); - OUTP(ofs,"lcao_dr",lcao_dr,"delta r for 1D integration in LCAO"); - OUTP(ofs,"lcao_rmax",lcao_rmax,"max R for 1D two-center integration table"); - OUTP(ofs,"out_hs",out_hs,"output H and S matrix"); - OUTP(ofs,"out_lowf",out_lowf,"ouput LCAO wave functions"); - OUTP(ofs,"bx",bx,"division of an element grid in FFT grid along x"); - OUTP(ofs,"by",by,"division of an element grid in FFT grid along y"); - OUTP(ofs,"bz",bz,"division of an element grid in FFT grid along z"); - - ofs << "\n#Parameters (5.Smearing)" << endl; - //OUTP(ofs,"occupations",occupations,"fixed; smearing"); - OUTP(ofs,"smearing",smearing,"type of smearing: gauss; fd; fixed; mp; mp2"); - OUTP(ofs,"sigma",degauss,"energy range for smearing"); - - ofs << "\n#Parameters (6.Charge Mixing)" << endl; - OUTP(ofs,"mixing_type",mixing_mode,"plain; kerker; pulay; pulay-kerker"); - OUTP(ofs,"mixing_beta",mixing_beta,"mixing parameter: 0 means no new charge"); - OUTP(ofs,"mixing_ndim",mixing_ndim,"mixing dimension in pulay"); - OUTP(ofs,"mixing_gg0",mixing_gg0,"mixing parameter in kerker"); - - ofs << "\n#Parameters (7.DOS)" << endl; - OUTP(ofs,"dos_emin_ev",dos_emin_ev,"minimal range for dos"); - OUTP(ofs,"dos_emax_ev",dos_emax_ev,"maximal range for dos"); - OUTP(ofs,"dos_edelta_ev",dos_edelta_ev,"delta energy for dos"); - OUTP(ofs,"dos_sigma",b_coef,"gauss b coefficeinet(default=0.07)"); - - ofs << "\n#Parameters (8.Technique)" << endl; - OUTP(ofs,"gamma_only",gamma_only,"gamma only"); - OUTP(ofs,"diago_proc",DIAGO_PROC,"number of proc used to diago");//mohan add 2012-01-13 - OUTP(ofs,"npool",npool,"number of pools for k points, pw only"); - OUTP(ofs,"mem_saver",mem_saver,"memory saver for many k points used"); - OUTP(ofs,"printe",printe,"print band energy for selectively ionic steps"); - - - ofs << "\n#Parameters (9.SIAO)" << endl; - OUTP(ofs,"selinv_npole",selinv_npole,"number of selected poles"); - OUTP(ofs,"selinv_temp",selinv_temp,"temperature for Fermi-Dirac distribution"); - OUTP(ofs,"selinv_gap",selinv_gap,"supposed gap in the calculation"); - OUTP(ofs,"selinv_deltae",selinv_deltae,"expected energy range"); - OUTP(ofs,"selinv_mu",selinv_mu,"chosen mu as Fermi energy"); - OUTP(ofs,"selinv_threshold",selinv_threshold,"threshold for calculated electron number"); - OUTP(ofs,"selinv_niter",selinv_niter,"max number of steps to update mu"); - - ofs << "\n#Parameters (10.Molecular dynamics)" << endl; - //added by zheng daye - OUTP(ofs,"md_mdtype",md_mdtype,"choose ensemble"); - //OUTP(ofs,"md_tauthermo",md_tauthermo,); - //OUTP(ofs,"md_taubaro",md_taubaro,); - OUTP(ofs,"md_dt",md_dt,"time step"); - OUTP(ofs,"md_nresn",md_nresn,"parameter during integrater"); - OUTP(ofs,"md_nyosh",md_nyosh,"parameter during integrater"); - OUTP(ofs,"md_qmass",md_qmass,"mass of thermostat"); - OUTP(ofs,"md_tfirst",md_tfirst,"temperature first"); - OUTP(ofs,"md_tlast",md_tlast,"temperature last"); - OUTP(ofs,"md_dumpmdfred",md_dumpmdfred,"The period to dump MD information for monitoring and restarting MD"); - OUTP(ofs,"md_mdoutpath",md_mdoutpath,"output path of md"); - OUTP(ofs,"md_domsd",md_domsd,"whether compute "); - OUTP(ofs,"md_domsdatom",md_domsdatom,"whether compute msd for each atom"); - OUTP(ofs,"md_rstmd",md_rstmd,"whether restart"); - //OUTP(ofs,"md_outputstressperiod",md_outputstressperiod,"period to output stress"); - OUTP(ofs,"md_fixtemperature",md_fixtemperature,"period to change temperature"); - OUTP(ofs,"md_ediff",md_ediff,"parameter for constraining total energy change"); - OUTP(ofs,"md_ediffg",md_ediffg,"parameter for constraining max force change"); - OUTP(ofs,"md_msdstarttime",md_msdstartTime,"choose which step that msd be calculated"); - //end of zheng daye's adding - - ofs << "\n#Parameters (11.Efield)" << endl; - OUTP(ofs,"efield",efield,"add electric field"); - OUTP(ofs,"edir",edir,"add electric field"); - OUTP(ofs,"emaxpos",emaxpos,"maximal position of efield [0,1)"); - OUTP(ofs,"eopreg",eopreg,"where sawlike potential decrease"); - OUTP(ofs,"eamp",eamp,"amplitute of the efield, unit is a.u."); - OUTP(ofs,"eamp_v",eamp*51.44,"amplitute of the efield, unit is V/A"); - - ofs << "\n#Parameters (12.Test)" << endl; - OUTP(ofs,"out_alllog",out_alllog,"output information for each processor, when parallel"); - OUTP(ofs,"nurse", nurse,"for coders"); - OUTP(ofs,"colour", colour,"for coders, make their live colourful"); - OUTP(ofs,"t_in_h", t_in_h,"calculate the kinetic energy or not"); - OUTP(ofs,"vl_in_h", vl_in_h,"calculate the local potential or not"); - OUTP(ofs,"vnl_in_h", vnl_in_h,"calculate the nonlocal potential or not"); - OUTP(ofs,"test_force", test_force, "test the force"); - OUTP(ofs,"test_stress", test_stress, "test the force"); - - - ofs << "\n#Parameters (13.Other Methods)" << endl; - OUTP(ofs,"mlwf_flag",mlwf_flag,"turn MLWF on or off"); - OUTP(ofs,"opt_epsilon2",opt_epsilon2,"calculate the dielectic function"); - OUTP(ofs,"opt_nbands",opt_nbands,"number of bands for optical calculation"); - - - ofs << "\n#Parameters (14.VdW Correction)" << endl; - -//jiyy add 2019-08-04 - OUTP(ofs,"vdw_method",vdw_method,"the method of calculating vdw (none ; d2 ; d3_0 ; d3_bj"); - OUTP(ofs,"vdw_s6",vdw_s6,"scale parameter of d2/d3_0/d3_bj"); - OUTP(ofs,"vdw_s8",vdw_s8,"scale parameter of d3_0/d3_bj"); - OUTP(ofs,"vdw_a1",vdw_a1,"damping parameter of d3_0/d3_bj"); - OUTP(ofs,"vdw_a2",vdw_a2,"damping parameter of d3_bj"); - OUTP(ofs,"vdw_d",vdw_d,"damping parameter of d2"); - OUTP(ofs,"vdw_abc",vdw_abc,"third-order term?"); - OUTP(ofs,"vdw_C6_file",vdw_C6_file,"filename of C6"); - OUTP(ofs,"vdw_C6_unit",vdw_C6_unit,"unit of C6, Jnm6/mol or eVA6"); - OUTP(ofs,"vdw_R0_file",vdw_R0_file,"filename of R0"); - OUTP(ofs,"vdw_R0_unit",vdw_R0_unit,"unit of R0, A or Bohr"); - OUTP(ofs,"vdw_model",vdw_model,"expression model of periodic structure, radius or period"); - OUTP(ofs,"vdw_radius",vdw_radius,"radius cutoff for periodic structure"); - OUTP(ofs,"vdw_radius_unit",vdw_radius_unit,"unit of radius cutoff for periodic structure"); - OUTP(ofs,"vdw_cn_thr",vdw_cn_thr,"radius cutoff for cn"); - OUTP(ofs,"vdw_cn_thr_unit",vdw_cn_thr_unit,"unit of cn_thr, Bohr or Angstrom"); - ofs << setw(20) << "vdw_period" << vdw_period.x << " " << vdw_period.y << " " << vdw_period.z<< " #periods of periodic structure" << endl; - - - ofs << "\n#Parameters (15.spectrum)" << endl; // pengfei Li add 2016-11-23 - //OUTP(ofs,"epsilon",epsilon,"calculate epsilon or not"); - //OUTP(ofs,"epsilon_choice",epsilon_choice,"0: hilbert_transform method; 1: standard method"); - OUTP(ofs,"spectral_type",spectral_type,"the type of the calculated spectrum"); - OUTP(ofs,"spectral_method",spectral_method,"0: tddft(linear response)"); - OUTP(ofs,"kernel_type",kernel_type,"the kernel type: rpa, tdlda ..."); - OUTP(ofs,"eels_method",eels_method,"0: hilbert_transform method; 1: standard method"); - OUTP(ofs,"absorption_method",absorption_method,"0: vasp's method 1: pwscf's method"); - OUTP(ofs,"system",system,"the calculate system"); - OUTP(ofs,"eta",eta,"eta(Ry)"); - OUTP(ofs,"domega",domega,"domega(Ry)"); - OUTP(ofs,"nomega",nomega,"nomega"); - OUTP(ofs,"ecut_chi",ecut_chi,"the dimension of chi matrix"); - //OUTP(ofs,"oband",oband,"the number of occupied bands"); - ofs << setw(20) <<"q_start"<"); - for(int i=0; i" < using namespace std; diff --git a/ABACUS.develop/source/src_io/write_input.cpp b/ABACUS.develop/source/src_io/write_input.cpp new file mode 100644 index 0000000000..0b6f1a9fa9 --- /dev/null +++ b/ABACUS.develop/source/src_io/write_input.cpp @@ -0,0 +1,292 @@ +#include "input.h" +#include "src_pw/tools.h" + +void Input::Print(const string &fn)const +{ + if (MY_RANK!=0) return; + + TITLE("Input","Print"); + + ofstream ofs(fn.c_str()); + + //---------------------------------- + // output the information in INPUT. + //---------------------------------- + ofs << "INPUT_PARAMETERS" << endl; + ofs << setiosflags(ios::left); + + ofs << "#Parameters (1.General)" << endl; + OUTP(ofs,"suffix",suffix,"the name of main output directory"); + OUTP(ofs,"latname",latname,"the name of lattice name"); + OUTP(ofs,"atom_file",global_atom_card,"the filename of file containing atom positions"); + OUTP(ofs,"kpoint_file",global_kpoint_card,"the name of file containing k points"); + OUTP(ofs,"pseudo_dir",global_pseudo_dir,"the directory containing pseudo files"); + OUTP(ofs,"pseudo_type",global_pseudo_type,"the type pseudo files"); + OUTP(ofs,"dft_functional",dft_functional,"exchange correlation functional"); + OUTP(ofs,"calculation",calculation,"test; scf; relax; nscf; ienvelope; istate;"); + OUTP(ofs,"ntype",ntype,"atom species number"); + OUTP(ofs,"nspin",nspin,"1: single spin; 2: up and down spin; 4: noncollinear spin"); + OUTP(ofs,"nbands",nbands,"number of bands"); + OUTP(ofs,"nbands_sto",nbands_sto,"number of stochastic bands"); + OUTP(ofs,"nbands_istate",nbands_istate,"number of bands around Fermi level for istate calulation"); + OUTP(ofs,"nche_sto",nche_sto,"number of orders for Chebyshev expansion in stochastic DFT"); + OUTP(ofs,"symmetry",symmetry,"turn symmetry on or off"); + OUTP(ofs,"nelec",nelec,"input number of electrons"); + + ofs << "\n#Parameters (2.PW)" << endl; + OUTP(ofs,"ecutwfc",ecutwfc,"#energy cutoff for wave functions"); + if(ks_solver=="cg") + { + OUTP(ofs,"diago_cg_maxiter",diago_cg_maxiter,"max iteration number for cg"); + OUTP(ofs,"diago_cg_prec",diago_cg_prec,"diago_cg_prec"); + } + else if(ks_solver=="dav") + { + OUTP(ofs,"diago_david_ndim",diago_david_ndim,"max dimension for davidson"); + } + OUTP(ofs,"ethr",ethr,"threshold for eigenvalues is cg electron iterations"); + OUTP(ofs,"dr2",dr2,"charge density error"); + OUTP(ofs,"start_wfc",start_wfc,"start wave functions are from 'atomic' or 'file'"); + OUTP(ofs,"start_charge",start_pot,"start charge is from 'atomic' or file"); + OUTP(ofs,"charge_extrap",charge_extrap,"atomic; first-order; second-order; dm:coefficients of SIA"); + OUTP(ofs,"out_charge",out_charge,">0 output charge density for selected electron steps"); + OUTP(ofs,"out_potential",out_potential,"output realspace potential"); + OUTP(ofs,"out_wf",out_wf,"output wave functions"); + OUTP(ofs,"out_dos",out_dos,"output energy and dos"); + OUTP(ofs,"out_band",out_band,"output energy and band structure"); + OUTP(ofs,"restart_save",restart_save,"print to disk every step for restart"); + OUTP(ofs,"restart_load",restart_load,"restart from disk"); + OUTP(ofs,"nx",nx,"number of points along x axis for FFT grid"); + OUTP(ofs,"ny",ny,"number of points along y axis for FFT grid"); + OUTP(ofs,"nz",nz,"number of points along z axis for FFT grid"); + + ofs << "\n#Parameters (3.Relaxation)" << endl; + OUTP(ofs,"ks_solver",KS_SOLVER,"cg; david; lapack; genelpa; hpseps; scalapack_gvx"); + OUTP(ofs,"niter",niter,"#number of electron iterations"); + OUTP(ofs,"force_set",force_set,"output the force_set or not"); + OUTP(ofs,"nstep",nstep,"number of ion iteration steps"); + OUTP(ofs,"out_stru",out_stru,"output the structure files after each ion step"); + OUTP(ofs,"force_thr",force_thr,"force threshold, unit: Ry/Bohr"); + OUTP(ofs,"force_thr_ev",force_thr*13.6058/0.529177,"force threshold, unit: eV/Angstrom"); + OUTP(ofs,"force_thr_ev2",force_thr_ev2,"force invalid threshold, unit: eV/Angstrom"); + OUTP(ofs,"stress_thr",stress_thr,"stress threshold"); + OUTP(ofs,"press1",press1,"target pressure, unit: KBar"); + OUTP(ofs,"press2",press2,"target pressure, unit: KBar"); + OUTP(ofs,"press3",press3,"target pressure, unit: KBar"); + OUTP(ofs,"bfgs_w1",bfgs_w1,"wolfe condition 1 for bfgs"); + OUTP(ofs,"bfgs_w2",bfgs_w2,"wolfe condition 2 for bfgs"); + OUTP(ofs,"trust_radius_max", trust_radius_max,"maximal trust radius, unit: Bohr"); + OUTP(ofs,"trust_radius_min", trust_radius_min,"minimal trust radius, unit: Bohr"); + OUTP(ofs,"trust_radius_ini", trust_radius_ini,"initial trust radius, unit: Bohr"); + OUTP(ofs,"stress",stress,"calculate the stress or not"); + OUTP(ofs,"fixed_axes",fixed_axes,"which axes are fixed"); + OUTP(ofs,"move_method",ion_dynamics,"bfgs; sd; cg; cg_bfgs;"); //pengfei add 2013-08-15 + OUTP(ofs,"out_level",out_level,"ie(for electrons); i(for ions);"); + OUTP(ofs,"out_dm",out_dm,">0 output density matrix"); + + // for deepks + OUTP(ofs,"out_descriptor",out_descriptor,">0 compute descriptor for deepks"); + OUTP(ofs,"lmax_descriptor",lmax_descriptor,">0 lmax used in descriptor for deepks"); + + ofs << "\n#Parameters (4.LCAO)" << endl; + OUTP(ofs,"basis_type",basis_type,"PW; LCAO in pw; LCAO"); + if(ks_solver=="HPSEPS" || ks_solver=="genelpa" || ks_solver=="scalapack_gvx") + { + OUTP(ofs,"nb2d",nb2d,"2d distribution of atoms"); + } + OUTP(ofs,"search_radius",search_radius,"input search radius (Bohr)"); + OUTP(ofs,"search_pbc",search_pbc,"input periodic boundary condition"); + OUTP(ofs,"lcao_ecut",lcao_ecut,"energy cutoff for LCAO"); + OUTP(ofs,"lcao_dk",lcao_dk,"delta k for 1D integration in LCAO"); + OUTP(ofs,"lcao_dr",lcao_dr,"delta r for 1D integration in LCAO"); + OUTP(ofs,"lcao_rmax",lcao_rmax,"max R for 1D two-center integration table"); + OUTP(ofs,"out_hs",out_hs,"output H and S matrix"); + OUTP(ofs,"out_lowf",out_lowf,"ouput LCAO wave functions"); + OUTP(ofs,"bx",bx,"division of an element grid in FFT grid along x"); + OUTP(ofs,"by",by,"division of an element grid in FFT grid along y"); + OUTP(ofs,"bz",bz,"division of an element grid in FFT grid along z"); + + ofs << "\n#Parameters (5.Smearing)" << endl; + OUTP(ofs,"smearing",smearing,"type of smearing: gauss; fd; fixed; mp; mp2"); + OUTP(ofs,"sigma",degauss,"energy range for smearing"); + + ofs << "\n#Parameters (6.Charge Mixing)" << endl; + OUTP(ofs,"mixing_type",mixing_mode,"plain; kerker; pulay; pulay-kerker"); + OUTP(ofs,"mixing_beta",mixing_beta,"mixing parameter: 0 means no new charge"); + OUTP(ofs,"mixing_ndim",mixing_ndim,"mixing dimension in pulay"); + OUTP(ofs,"mixing_gg0",mixing_gg0,"mixing parameter in kerker"); + + ofs << "\n#Parameters (7.DOS)" << endl; + OUTP(ofs,"dos_emin_ev",dos_emin_ev,"minimal range for dos"); + OUTP(ofs,"dos_emax_ev",dos_emax_ev,"maximal range for dos"); + OUTP(ofs,"dos_edelta_ev",dos_edelta_ev,"delta energy for dos"); + OUTP(ofs,"dos_sigma",b_coef,"gauss b coefficeinet(default=0.07)"); + + ofs << "\n#Parameters (8.Technique)" << endl; + OUTP(ofs,"gamma_only",gamma_only,"gamma only"); + OUTP(ofs,"diago_proc",DIAGO_PROC,"number of proc used to diago"); + OUTP(ofs,"npool",npool,"number of pools for k points, pw only"); + OUTP(ofs,"mem_saver",mem_saver,"memory saver for many k points used"); + OUTP(ofs,"printe",printe,"print band energy for selectively ionic steps"); + + ofs << "\n#Parameters (9.SIAO)" << endl; + OUTP(ofs,"selinv_npole",selinv_npole,"number of selected poles"); + OUTP(ofs,"selinv_temp",selinv_temp,"temperature for Fermi-Dirac distribution"); + OUTP(ofs,"selinv_gap",selinv_gap,"supposed gap in the calculation"); + OUTP(ofs,"selinv_deltae",selinv_deltae,"expected energy range"); + OUTP(ofs,"selinv_mu",selinv_mu,"chosen mu as Fermi energy"); + OUTP(ofs,"selinv_threshold",selinv_threshold,"threshold for calculated electron number"); + OUTP(ofs,"selinv_niter",selinv_niter,"max number of steps to update mu"); + + ofs << "\n#Parameters (10.Molecular dynamics)" << endl; + OUTP(ofs,"md_mdtype",md_mdtype,"choose ensemble"); + OUTP(ofs,"md_dt",md_dt,"time step"); + OUTP(ofs,"md_nresn",md_nresn,"parameter during integrater"); + OUTP(ofs,"md_nyosh",md_nyosh,"parameter during integrater"); + OUTP(ofs,"md_qmass",md_qmass,"mass of thermostat"); + OUTP(ofs,"md_tfirst",md_tfirst,"temperature first"); + OUTP(ofs,"md_tlast",md_tlast,"temperature last"); + OUTP(ofs,"md_dumpmdfred",md_dumpmdfred,"The period to dump MD information for monitoring and restarting MD"); + OUTP(ofs,"md_mdoutpath",md_mdoutpath,"output path of md"); + OUTP(ofs,"md_domsd",md_domsd,"whether compute "); + OUTP(ofs,"md_domsdatom",md_domsdatom,"whether compute msd for each atom"); + OUTP(ofs,"md_rstmd",md_rstmd,"whether restart"); + OUTP(ofs,"md_fixtemperature",md_fixtemperature,"period to change temperature"); + OUTP(ofs,"md_ediff",md_ediff,"parameter for constraining total energy change"); + OUTP(ofs,"md_ediffg",md_ediffg,"parameter for constraining max force change"); + OUTP(ofs,"md_msdstarttime",md_msdstartTime,"choose which step that msd be calculated"); + + ofs << "\n#Parameters (11.Efield)" << endl; + OUTP(ofs,"efield",efield,"add electric field"); + OUTP(ofs,"edir",edir,"add electric field"); + OUTP(ofs,"emaxpos",emaxpos,"maximal position of efield [0,1)"); + OUTP(ofs,"eopreg",eopreg,"where sawlike potential decrease"); + OUTP(ofs,"eamp",eamp,"amplitute of the efield, unit is a.u."); + OUTP(ofs,"eamp_v",eamp*51.44,"amplitute of the efield, unit is V/A"); + + ofs << "\n#Parameters (12.Test)" << endl; + OUTP(ofs,"out_alllog",out_alllog,"output information for each processor, when parallel"); + OUTP(ofs,"nurse", nurse,"for coders"); + OUTP(ofs,"colour", colour,"for coders, make their live colourful"); + OUTP(ofs,"t_in_h", t_in_h,"calculate the kinetic energy or not"); + OUTP(ofs,"vl_in_h", vl_in_h,"calculate the local potential or not"); + OUTP(ofs,"vnl_in_h", vnl_in_h,"calculate the nonlocal potential or not"); + OUTP(ofs,"test_force", test_force, "test the force"); + OUTP(ofs,"test_stress", test_stress, "test the force"); + + ofs << "\n#Parameters (13.Other Methods)" << endl; + OUTP(ofs,"mlwf_flag",mlwf_flag,"turn MLWF on or off"); + OUTP(ofs,"opt_epsilon2",opt_epsilon2,"calculate the dielectic function"); + OUTP(ofs,"opt_nbands",opt_nbands,"number of bands for optical calculation"); + + ofs << "\n#Parameters (14.VdW Correction)" << endl; + OUTP(ofs,"vdw_method",vdw_method,"the method of calculating vdw (none ; d2 ; d3_0 ; d3_bj"); + OUTP(ofs,"vdw_s6",vdw_s6,"scale parameter of d2/d3_0/d3_bj"); + OUTP(ofs,"vdw_s8",vdw_s8,"scale parameter of d3_0/d3_bj"); + OUTP(ofs,"vdw_a1",vdw_a1,"damping parameter of d3_0/d3_bj"); + OUTP(ofs,"vdw_a2",vdw_a2,"damping parameter of d3_bj"); + OUTP(ofs,"vdw_d",vdw_d,"damping parameter of d2"); + OUTP(ofs,"vdw_abc",vdw_abc,"third-order term?"); + OUTP(ofs,"vdw_C6_file",vdw_C6_file,"filename of C6"); + OUTP(ofs,"vdw_C6_unit",vdw_C6_unit,"unit of C6, Jnm6/mol or eVA6"); + OUTP(ofs,"vdw_R0_file",vdw_R0_file,"filename of R0"); + OUTP(ofs,"vdw_R0_unit",vdw_R0_unit,"unit of R0, A or Bohr"); + OUTP(ofs,"vdw_model",vdw_model,"expression model of periodic structure, radius or period"); + OUTP(ofs,"vdw_radius",vdw_radius,"radius cutoff for periodic structure"); + OUTP(ofs,"vdw_radius_unit",vdw_radius_unit,"unit of radius cutoff for periodic structure"); + OUTP(ofs,"vdw_cn_thr",vdw_cn_thr,"radius cutoff for cn"); + OUTP(ofs,"vdw_cn_thr_unit",vdw_cn_thr_unit,"unit of cn_thr, Bohr or Angstrom"); + ofs << setw(20) << "vdw_period" << vdw_period.x + << " " << vdw_period.y << " " + << vdw_period.z<< " #periods of periodic structure" << endl; + + + ofs << "\n#Parameters (15.spectrum)" << endl; // pengfei Li add 2016-11-23 + OUTP(ofs,"spectral_type",spectral_type,"the type of the calculated spectrum"); + OUTP(ofs,"spectral_method",spectral_method,"0: tddft(linear response)"); + OUTP(ofs,"kernel_type",kernel_type,"the kernel type: rpa, tdlda ..."); + OUTP(ofs,"eels_method",eels_method,"0: hilbert_transform method; 1: standard method"); + OUTP(ofs,"absorption_method",absorption_method,"0: vasp's method 1: pwscf's method"); + OUTP(ofs,"system",system,"the calculate system"); + OUTP(ofs,"eta",eta,"eta(Ry)"); + OUTP(ofs,"domega",domega,"domega(Ry)"); + OUTP(ofs,"nomega",nomega,"nomega"); + OUTP(ofs,"ecut_chi",ecut_chi,"the dimension of chi matrix"); + ofs << setw(20) <<"q_start"<"); + for(int i=0; i" < Date: Wed, 3 Mar 2021 22:00:38 +0800 Subject: [PATCH 170/233] add some comments in wavefunc.h and .cpp, the class needs to be reconstructed --- .../source/src_lcao/local_orbital_charge.cpp | 43 +++++++++-- .../source/src_pw/threshold_elec.cpp | 76 +++++++------------ ABACUS.develop/source/src_pw/threshold_elec.h | 10 ++- ABACUS.develop/source/src_pw/wavefunc.cpp | 5 +- ABACUS.develop/source/src_pw/wavefunc.h | 1 + ABACUS.develop/source/src_pw/wf_igk.cpp | 8 +- ABACUS.develop/source/src_pw/wf_igk.h | 19 +++-- 7 files changed, 96 insertions(+), 66 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp b/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp index ec3613aa6e..d7baf1e733 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_charge.cpp @@ -743,13 +743,15 @@ void Local_Orbital_Charge::cal_dk_k(const Grid_Technique >) return; } + + // calculate the grid distributed DM matrix from 2D block-cyclic distributed DM matrix // transform dm_gamma[is].c to this->DM[is] void Local_Orbital_Charge::cal_dk_gamma_from_2D(void) { - //timer::tick("LCAO_Charge","newDM",'F'); timer::tick("LCAO_Charge","dm_2dTOgrid",'F'); OUT(ofs_running,"cal_dk_gamma_from_2D, NSPIN", NSPIN); + for(int is=0; is1) @@ -777,6 +779,7 @@ void Local_Orbital_Charge::cal_dk_gamma_from_2D(void) } ofs_running<<"=========================================\n"; } + // put data from dm_gamma[is] to sender index int nNONZERO=0; for(int i=0; i1) { OUT(ofs_running,"number of non-zero elements in receiver_buffer",nNONZERO); @@ -856,9 +860,10 @@ void Local_Orbital_Charge::cal_dk_gamma_from_2D(void) ofs_running<<"=========================================\n"; } } - //timer::tick("LCAO_Charge","newDM",'F'); timer::tick("LCAO_Charge","dm_2dTOgrid",'F'); + return; } + //------------------------------------------------------------- //------------------------------------------------------------- // NOTE: @@ -894,23 +899,35 @@ void Local_Orbital_Charge::cal_dk_gamma(void) #ifdef __MPI //2015-09-06, xiaohui #if EXX_DM==2 - if( Exx_Global::Hybrid_Type::HF==exx_lcao.info.hybrid_type || Exx_Global::Hybrid_Type::PBE0==exx_lcao.info.hybrid_type || Exx_Global::Hybrid_Type::HSE==exx_lcao.info.hybrid_type ) + if( Exx_Global::Hybrid_Type::HF==exx_lcao.info.hybrid_type + || Exx_Global::Hybrid_Type::PBE0==exx_lcao.info.hybrid_type + || Exx_Global::Hybrid_Type::HSE==exx_lcao.info.hybrid_type ) exx_lcao.DM_para.clear_DMr(); #endif // Peize Lin update 2018-07-02 - for( int is=0; isDM[is][i], lgd_now); + } + } - int nprocs,myid; + // initialize + int nprocs=0; + int myid=0; //MPI_Status status; MPI_Comm_size(DIAG_HPSEPS_WORLD,&nprocs); MPI_Comm_rank(DIAG_HPSEPS_WORLD,&myid); + + // DSIZE: number of processors in diag world vector bands_local(DSIZE); for (int id=0; idnpwx = this->setupIndGk(pw, nks); - // mohan add 2009-12-24 + // band energies this->ekb = new double*[nks]; for(int ik=0; ikallocate_ekb = true; - this->wg.create(nks, NBANDS); // the weight of each k point and band + // the weight of each k point and band + this->wg.create(nks, NBANDS); Memory::record("wavefunc","ekb",nks*NBANDS,"double"); Memory::record("wavefunc","wg",nks*NBANDS,"double"); diff --git a/ABACUS.develop/source/src_pw/wavefunc.h b/ABACUS.develop/source/src_pw/wavefunc.h index b5731cf683..57153fdb66 100644 --- a/ABACUS.develop/source/src_pw/wavefunc.h +++ b/ABACUS.develop/source/src_pw/wavefunc.h @@ -50,6 +50,7 @@ class wavefunc : public WF_atomic int iw2it( int iw); int iw2ia( int iw); + void init_after_vc(const int nks); //LiuXh 20180515 private: // pengfei 2016-11-23 diff --git a/ABACUS.develop/source/src_pw/wf_igk.cpp b/ABACUS.develop/source/src_pw/wf_igk.cpp index ce53c5d349..4177ccf838 100644 --- a/ABACUS.develop/source/src_pw/wf_igk.cpp +++ b/ABACUS.develop/source/src_pw/wf_igk.cpp @@ -27,6 +27,7 @@ int WF_igk::setupIndGk(const PW_Basis &pwb,const int nks) { TITLE("WF_igk","setupIndGk"); timer::tick("WF_igk","setupIndGk"); + //============================================ // Find out for each k point, // how many planewave within the radius ggpsi @@ -121,9 +122,8 @@ int WF_igk::setupIndGk(const PW_Basis &pwb,const int nks) return npw_max; } // end setupIndGk() + //-------------------------------------------------------- -// MEMBER FUNCTION : -// NAME : ekin // Compute kinetic energy for each k-point //-------------------------------------------------------- void WF_igk::ekin(const int ik) @@ -145,6 +145,7 @@ void WF_igk::ekin(const int ik) return ; } + Vector3 WF_igk::get_1qvec_cartesian(const int ik,const int ig)const { Vector3 qvec = kv.kvec_c[ik] + pw.gcar[ this->igk(ik, ig) ]; @@ -162,6 +163,7 @@ Vector3 WF_igk::get_1qvec_cartesian(const int ik,const int ig)const return qvec; } + double* WF_igk::get_qvec_cartesian(const int &ik) { double *qmod = new double[ kv.ngk[ik] ]; @@ -176,6 +178,7 @@ double* WF_igk::get_qvec_cartesian(const int &ik) return qmod; } + complex* WF_igk::get_sk(const int ik, const int it, const int ia)const { timer::tick("WF_igk","get_sk"); @@ -195,6 +198,7 @@ complex* WF_igk::get_sk(const int ik, const int it, const int ia)const return sk; } + complex* WF_igk::get_skq(int ik, const int it, const int ia, Vector3 q) //pengfei 2016-11-23 { complex *skq = new complex[ kv.ngk[ik] ]; diff --git a/ABACUS.develop/source/src_pw/wf_igk.h b/ABACUS.develop/source/src_pw/wf_igk.h index 02f556e8be..420a367d02 100644 --- a/ABACUS.develop/source/src_pw/wf_igk.h +++ b/ABACUS.develop/source/src_pw/wf_igk.h @@ -11,18 +11,23 @@ class WF_igk WF_igk(); ~WF_igk(); - // for each k point , find the number of pws - int setupIndGk(const PW_Basis &pwb,const int nks); - + //--------------------------------------------------- + // npwx: max npw + // npw + // igk: [nks, npw_max] + // g2kin: [npwx],kinetic energy for current k point + //--------------------------------------------------- int npwx; - int npw; - IntArray igk; - - // g2kin : [npw],kinetic energy for current k point double *g2kin; + public: + + // for each k point , find the number of pws + int setupIndGk(const PW_Basis &pwb,const int nks); + + // Calculate kinetic energy void ekin(const int ik); From 973e053368ae08eea8613ca984350e97c18ffc36 Mon Sep 17 00:00:00 2001 From: mohan Date: Thu, 4 Mar 2021 22:20:21 +0800 Subject: [PATCH 171/233] delete SOME_PW option in run_lcao.cpp --- ABACUS.develop/source/run_lcao.cpp | 40 +++++-------------- .../source/src_lcao/ORB_radial_table.cpp | 1 - 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index f129bd95e6..5f118670a3 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -100,9 +100,6 @@ void Run_lcao::lcao_line(void) pot.allocate(pw.nrxx); DONE(ofs_running,"INIT POTENTIAL"); - // declration - enum use_wf_coef {SOME_PW, ALL_LO}; - use_wf_coef uoc = ALL_LO; // Peize Lin add 2018-11-30 if(CALCULATION=="nscf") @@ -117,33 +114,16 @@ void Run_lcao::lcao_line(void) } } - switch (uoc) - { - case ALL_LO: - // Init the local wave functions. - wf.init_local(); - // Init the FFT. - UFFT.allocate(); - // Init the local part of NC pseudopotential. - ppcell.init_vloc(); - // Init the potential. - pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs - break; - - case SOME_PW: - wf.allocate(kv.nks); - UFFT.allocate(); - ppcell.init(ucell.ntype); - hm.hpw.init(wf.npwx, NPOL, ppcell.nkb, pw.nrxx); - ppcell.init_vloc(); - ppcell.init_vnl(); - pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs - pot.newd();//once - DONE(ofs_running,"INIT POTENTIAL"); - wf.wfcinit(); - DONE(ofs_running,"INIT SOME_PW"); - break; - } + + // Init the local wave functions. + wf.init_local(); + // Init the FFT. + UFFT.allocate(); + // Init the local part of NC pseudopotential. + ppcell.init_vloc(); + // Init the potential. + pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs + // Peize Lin 2016-12-03 if (CALCULATION=="scf" || CALCULATION=="md" || CALCULATION=="relax" || CALCULATION=="cell-relax") diff --git a/ABACUS.develop/source/src_lcao/ORB_radial_table.cpp b/ABACUS.develop/source/src_lcao/ORB_radial_table.cpp index ecf6a95cf6..8c7f68b9ca 100644 --- a/ABACUS.develop/source/src_lcao/ORB_radial_table.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_radial_table.cpp @@ -8,7 +8,6 @@ double Make_Overlap_Table::dr = -1.0; Make_Overlap_Table::Make_Overlap_Table() { -// cout << " \n Make_Overlap_Table::Make_Overlap_Table" << endl; destroy_sr = false; destroy_tr = false; destroy_nr = false; From 1de18836d9210b1f35ad2ce6eb096d89ddf30e41 Mon Sep 17 00:00:00 2001 From: zdy Date: Fri, 5 Mar 2021 13:39:37 +0800 Subject: [PATCH 172/233] refactor the force and stress calculation in LCAO base --- ABACUS.develop/source/Makefile.Objects | 3 +- ABACUS.develop/source/input_conv.cpp | 4 +- ABACUS.develop/source/input_update.cpp | 10 +- ABACUS.develop/source/src_lcao/force_lcao.cpp | 960 ---------- ABACUS.develop/source/src_lcao/force_lcao.h | 54 - .../source/src_lcao/force_lcao_gamma.cpp | 1604 ++++++++--------- .../source/src_lcao/force_lcao_gamma.h | 84 +- .../source/src_lcao/force_lcao_k.cpp | 360 ++-- ABACUS.develop/source/src_lcao/force_lcao_k.h | 31 +- .../source/src_lcao/force_stress_lcao.cpp | 730 ++++++++ .../source/src_lcao/force_stress_lcao.h | 73 + ABACUS.develop/source/src_lcao/gint_k.cpp | 30 +- ABACUS.develop/source/src_lcao/gint_k.h | 8 +- ABACUS.develop/source/src_lcao/gint_k_fvl.cpp | 4 +- .../source/src_lcao/local_orbital_ions.cpp | 34 +- .../source/src_lcao/stress_lcao.cpp | 204 --- ABACUS.develop/source/src_lcao/stress_lcao.h | 21 - ABACUS.develop/source/src_pw/H_XC_pw.h | 3 +- ABACUS.develop/source/src_pw/forces.cpp | 95 +- ABACUS.develop/source/src_pw/forces.h | 23 +- ABACUS.develop/source/src_pw/ions.cpp | 30 +- ABACUS.develop/source/src_pw/md.cpp | 19 +- ABACUS.develop/source/src_pw/md.h | 2 +- .../source/src_pw/stress_func_gga.cpp | 2 +- ABACUS.develop/source/src_pw/stress_pw.cpp | 6 +- ABACUS.develop/source/src_pw/vdwd2.cpp | 29 +- ABACUS.develop/source/src_pw/vdwd2.h | 6 +- ABACUS.develop/source/src_pw/vdwd3.cpp | 21 +- ABACUS.develop/source/src_pw/vdwd3.h | 7 +- 29 files changed, 1969 insertions(+), 2488 deletions(-) delete mode 100644 ABACUS.develop/source/src_lcao/force_lcao.cpp delete mode 100644 ABACUS.develop/source/src_lcao/force_lcao.h create mode 100644 ABACUS.develop/source/src_lcao/force_stress_lcao.cpp create mode 100644 ABACUS.develop/source/src_lcao/force_stress_lcao.h delete mode 100644 ABACUS.develop/source/src_lcao/stress_lcao.cpp delete mode 100644 ABACUS.develop/source/src_lcao/stress_lcao.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index bf6b9a0ba1..25312929b5 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -148,10 +148,9 @@ LCAO_nnr.o \ LCAO_diago.o\ LCAO_evolve.o\ ylm.o\ -force_lcao.o\ +force_stress_lcao.o\ force_lcao_gamma.o\ force_lcao_k.o\ -stress_lcao.o\ parallel_orbitals.o \ global_fp.o \ pdiag_double.o \ diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index 730ec5a386..4e210b9ff9 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -4,7 +4,7 @@ #include "input_conv.h" #include "src_ions/ions_move_basic.h" #include "src_io/optical.h" -#include "src_lcao/force_lcao.h" +#include "src_lcao/force_stress_lcao.h" #include "src_lcao/local_orbital_charge.h" #include "src_lcao/ORB_read.h" #include "src_pw/efield.h" @@ -70,7 +70,7 @@ void Input_Conv::Convert(void) PRESS1 = INPUT.press1; PRESS2 = INPUT.press2; PRESS3 = INPUT.press3; - Force_LCAO::force_invalid_threshold_ev = INPUT.force_thr_ev2; + Force_Stress_LCAO::force_invalid_threshold_ev = INPUT.force_thr_ev2; BFGS_Basic::w1 = INPUT.bfgs_w1; BFGS_Basic::w2 = INPUT.bfgs_w2; diff --git a/ABACUS.develop/source/input_update.cpp b/ABACUS.develop/source/input_update.cpp index d4ae855df5..8ad7a1c56d 100644 --- a/ABACUS.develop/source/input_update.cpp +++ b/ABACUS.develop/source/input_update.cpp @@ -8,7 +8,7 @@ #include "input.h" #include "src_ions/ions_move_basic.h" #include "src_io/optical.h" -#include "src_lcao/force_lcao.h" +#include "src_lcao/force_stress_lcao.h" #include "src_lcao/local_orbital_charge.h" #include "src_lcao/global_fp.h" // mohan update 2021-01-30 @@ -107,10 +107,10 @@ bool Update_input::Read(const string &fn) else if (strcmp("force_thr_ev2", word) == 0) { read_value(ifs, force_thr_ev2); - if(force_thr_ev2!=Force_LCAO::force_invalid_threshold_ev) + if(force_thr_ev2!=Force_Stress_LCAO::force_invalid_threshold_ev) { - this->change(ofs_warning,"force_thr threshold(Ry/Bohr)",Force_LCAO::force_invalid_threshold_ev,force_thr_ev2); - Force_LCAO::force_invalid_threshold_ev = this->force_thr_ev2; + this->change(ofs_warning,"force_thr threshold(Ry/Bohr)",Force_Stress_LCAO::force_invalid_threshold_ev,force_thr_ev2); + Force_Stress_LCAO::force_invalid_threshold_ev = this->force_thr_ev2; } } #endif @@ -267,7 +267,7 @@ void Update_input::Bcast() { Parallel_Common::bcast_int( FORCE ); Parallel_Common::bcast_double( FORCE_THR); - Parallel_Common::bcast_double( Force_LCAO::force_invalid_threshold_ev); + Parallel_Common::bcast_double( Force_Stress_LCAO::force_invalid_threshold_ev); Parallel_Common::bcast_double( DRHO2 ); Parallel_Common::bcast_int( NITER ); Parallel_Common::bcast_int( NSTEP ); diff --git a/ABACUS.develop/source/src_lcao/force_lcao.cpp b/ABACUS.develop/source/src_lcao/force_lcao.cpp deleted file mode 100644 index 6e176b40db..0000000000 --- a/ABACUS.develop/source/src_lcao/force_lcao.cpp +++ /dev/null @@ -1,960 +0,0 @@ -#include "force_lcao.h" -#include "src_pw/global.h" -#include "src_pw/potential_libxc.h" -#include "dftu.h" //Quxin add for DFT+U on 20201029 -// new -#include "src_pw/H_XC_pw.h" - -double Force_LCAO::force_invalid_threshold_ev = 0.00; - -Force_LCAO::Force_LCAO () -{ - allocate_flag = false; - output_acc = 1.0e-8; -} - -Force_LCAO::~Force_LCAO () -{ - this->destroy(); -} - -void Force_LCAO::destroy (void) -{ - if (allocate_flag) - { - for (int iat = 0; iat < ucell.nat; iat++) - { - //------------------------------- - // use energy density matrix - //------------------------------- - delete [] foverlap[iat]; - //------------------------------- - // use density matrix - //------------------------------- - delete [] ftvnl_dphi[iat]; - delete [] fvnl_dbeta[iat]; - //------------------------------- - // use grid integration - //------------------------------- - delete [] fvl_dphi[iat]; - //------------------------------- - // use plane wave - //------------------------------- - delete [] fvl_dvl[iat]; - delete [] fewalds[iat]; - delete [] fcc[iat]; - delete [] fscc[iat]; - } - - delete [] foverlap; - delete [] ftvnl_dphi; - delete [] fvnl_dbeta; - delete [] fvl_dphi; - delete [] fvl_dvl; - delete [] fewalds; - delete [] fcc; - delete [] fscc; - - allocate_flag = false; - } -} - -void Force_LCAO::allocate(void) -{ - TITLE("Force_LCAO","init"); - - // reduce memory occupy by vlocal - delete[] ParaO.sender_local_index; - delete[] ParaO.sender_size_process; - delete[] ParaO.sender_displacement_process; - delete[] ParaO.receiver_global_index; - delete[] ParaO.receiver_size_process; - delete[] ParaO.receiver_displacement_process; - - ParaO.sender_local_index = new int[1]; - ParaO.sender_size_process = new int[1]; - ParaO.sender_displacement_process = new int[1]; - ParaO.receiver_global_index = new int[1]; - ParaO.receiver_size_process = new int[1]; - ParaO.receiver_displacement_process = new int[1]; - - if (allocate_flag) - { - this->destroy(); - } - - const int nat = ucell.nat; - - this->fcs.create (nat, 3); - - // part of total force - foverlap = new double*[nat]; - ftvnl_dphi = new double*[nat]; - fvnl_dbeta = new double*[nat]; - fvl_dphi = new double*[nat]; - fvl_dvl = new double*[nat]; - fewalds = new double*[nat]; - fcc = new double*[nat]; - fscc = new double*[nat]; - - for (int iat = 0; iat < nat; iat++) - { - foverlap[iat] = new double[3]; - ftvnl_dphi[iat] = new double[3]; - fvnl_dbeta[iat] = new double[3]; - fvl_dphi[iat] = new double[3]; - fvl_dvl[iat] = new double[3]; - fewalds[iat] = new double[3]; - fcc[iat] = new double[3]; - fscc[iat] = new double[3]; - - ZEROS (foverlap[iat], 3); - ZEROS (ftvnl_dphi[iat], 3); - ZEROS (fvnl_dbeta[iat], 3); - ZEROS (fvl_dphi[iat],3); - ZEROS (fvl_dvl[iat],3); - ZEROS (fewalds[iat], 3); - ZEROS (fcc[iat], 3); - ZEROS (fscc[iat],3); - } - - allocate_flag = true; - - Memory::record("Force_LCAO","Paremeters",nat*3*8,"double"); - return; -} - -#include "../src_pw/efield.h" -#include "../src_pw/forces.h" -// be called in : Local_Orbital_Ions::force_stress -void Force_LCAO::start_force(void) -{ - TITLE("Force_LCAO","start_force"); - timer::tick("Force_LCAO","start_force",'E'); - - - //-------------------------------------------------------- - // local pseudopotential force: - // use charge density; plane wave; local pseudopotential; - //-------------------------------------------------------- - this->cal_force_loc (); - - //-------------------------------------------------------- - // ewald force: use plane wave only. - //-------------------------------------------------------- - this->cal_force_ew (); //remain problem - - - //-------------------------------------------------------- - // force due to core correlation. - //-------------------------------------------------------- - this->cal_force_cc(); - - //-------------------------------------------------------- - // force due to self-consistent charge. - //-------------------------------------------------------- - this->cal_force_scc(); - - //-------------------------------------------------------- - // need to move atom positions here. - //-------------------------------------------------------- - if(GAMMA_ONLY_LOCAL) - { - this->ftable_gamma(); - } - else - { - this->ftable_k(); - } - - // clear the data. - this->fcs.zero_out(); - - // zhengdy added in 2018-10-29 - stress_vdw.create(3,3); - // Peize Lin add 2014-04-04, update 2019-04-26 - if(vdwd2.vdwD2) - { - vdwd2.force(stress_vdw, STRESS); - } - // jiyy add 2019-05-18 - else if(vdwd3.vdwD3) - { - vdwd3.force(stress_vdw, STRESS); - } - - matrix fefield; - if(EFIELD) - { - fefield.create(ucell.nat, 3); - Efield::compute_force(fefield); - } - - for(int i=0; i<3; i++) - { - double sum = 0.0; - - for (int iat = 0; iat < ucell.nat; iat++) - { - fcs(iat, i) += foverlap[iat][i] - + ftvnl_dphi[iat][i] - + fvnl_dbeta[iat][i] - + fvl_dphi[iat][i] - + fvl_dvl[iat][i] // derivative of local potential force (pw) - + fewalds[iat][i] // ewald force (pw) - + fcc[iat][i] //nonlinear core correction force (pw) - + fscc[iat][i];//self consistent corretion force (pw) - - // Force contribution from DFT+U, Quxin add on 20201029 - if(INPUT.dft_plus_u) - { - fcs(iat, i) += dftu.force_dftu.at(iat).at(i); - } - - // Peize Lin add 2014-04-04, update 2019-04-261 - if(vdwd2.vdwD2) - { - switch(i) - { - case 0: fcs(iat,i) += vdwd2.force_result[iat].x; break; - case 1: fcs(iat,i) += vdwd2.force_result[iat].y; break; - case 2: fcs(iat,i) += vdwd2.force_result[iat].z; break; - } - - } - // jiyy add 2019-05-18 - if(vdwd3.vdwD3) - { - switch(i) - { - case 0: fcs(iat,i) += vdwd3.force_result[iat][0]; break; - case 1: fcs(iat,i) += vdwd3.force_result[iat][1]; break; - case 2: fcs(iat,i) += vdwd3.force_result[iat][2]; break; - } - - } - - if(EFIELD) - { - fcs(iat, i) = fcs(iat, i) + fefield(iat, i); - } - - sum += fcs(iat, i); - } - - for(int iat=0; iatprint_force("OVERLAP FORCE",foverlap,TEST_FORCE,ry); - // this->print_force("TVNL_DPHI force",ftvnl_dphi,TEST_FORCE); - // this->print_force("VNL_DBETA force",fvnl_dbeta,TEST_FORCE); - this->print_force("T_VNL FORCE",ftvnl,TEST_FORCE,ry); - - this->print_force("VL_dPHI FORCE",fvl_dphi,TEST_FORCE,ry); - this->print_force("VL_dVL FORCE",fvl_dvl,TEST_FORCE,ry); - // this->print_force("VLOCAL FORCE",fvlocal,TEST_FORCE); - - this->print_force("EWALD FORCE",fewalds,TEST_FORCE,ry); - this->print_force("NLCC FORCE",fcc,TEST_FORCE,ry); - this->print_force("SCC FORCE",fscc,TEST_FORCE,ry); - } - - // mohan fix bug 2012-03-22 - for(int iat=0; iatprintforce_total(ry); - - ofs_running << resetiosflags(ios::showpos); - - if(TEST_FORCE) - { - ofs_running << "\n FORCE INVALID TABLE." << endl; - ofs_running << " " << setw(8) << "atom" << setw(5) << "x" << setw(5) << "y" << setw(5) << "z" << endl; - for(int iat=0; iatoutput_acc) ofs_running << setw(15) << f[iat][0]*fac; - else ofs_running << setw(15) << "0"; - if( abs(f[iat][1]) >output_acc) ofs_running << setw(15) << f[iat][1]*fac; - else ofs_running << setw(15) << "0"; - if( abs(f[iat][2]) >output_acc) ofs_running << setw(15) << f[iat][2]*fac; - else ofs_running << setw(15) << "0"; - ofs_running << endl; - - if(screen) - { - cout << " " << setw(8) << ss.str(); - if( abs(f[iat][0]) >output_acc) cout << setw(15) << f[iat][0]*fac; - else cout << setw(15) << "0"; - if( abs(f[iat][1]) >output_acc) cout << setw(15) << f[iat][1]*fac; - else cout << setw(15) << "0"; - if( abs(f[iat][2]) >output_acc) cout << setw(15) << f[iat][2]*fac; - else cout << setw(15) << "0"; - cout << endl; - } - - iat++; - } - } - - - cout << resetiosflags(ios::showpos); - - return; -} - -void Force_LCAO::printforce_total (bool ry) -{ - TITLE("Force_LCAO","printforce_total"); - double unit_transform = 1; - - if(!ry) - { - unit_transform = Ry_to_eV / 0.529177; - } -// cout.setf(ios::fixed); - - int iat=0; - - //ofs_running << setiosflags(ios::right); - ofs_running << setprecision(6) << setiosflags(ios::showpos) << setiosflags(ios::fixed) << endl; - NEW_PART("TOTAL-FORCE (eV/Angstrom)"); - - // print out forces - if(INPUT.force_set == 1) - { - ofstream ofs("FORCE.dat"); - if(!ofs) - { - cout << "open FORCE.dat error !" < *aux = new complex[pw.nrxx]; - ZEROS(aux, pw.nrxx); - - // now, in all pools , the charge are the same, - // so, the force calculated by each pool is equal. - - for (int is=0; is( CHR.rho[is][ir], 0.0 ); - } - } - - pw.FFT_chg.FFT3D(aux, -1); - - int gstart_here = pw.gstart; - if (pw.ggs[0] != 0) gstart_here = 0; - - int iat = 0; - for (int it = 0; it < ucell.ntype; it++) - { - for (int ia = 0; ia < ucell.atoms[it].na; ia++) - { - fvl_dvl[iat][0]=0.0; - fvl_dvl[iat][1]=0.0; - fvl_dvl[iat][2]=0.0; - - for (int ig = gstart_here; ig < pw.ngmc; ig++) - { - const double phase = TWO_PI * (pw.gcar[ig] * ucell.atoms[it].tau[ia]); - const double factor = ppcell.vloc(it, pw.ig2ngg[ig]) * - ( cos(phase) * aux[ pw.ig2fftc[ig] ].imag() - + sin(phase) * aux[ pw.ig2fftc[ig] ].real()); - - fvl_dvl[iat][0] += pw.gcar[ig].x * factor; - fvl_dvl[iat][1] += pw.gcar[ig].y * factor; - fvl_dvl[iat][2] += pw.gcar[ig].z * factor; - } - for (int ipol = 0; ipol < 3; ipol++) - { - this->fvl_dvl[iat][ipol] *= (ucell.tpiba * ucell.omega); - } - ++iat; - - } - } - - //this->print(ofs_running, "local forces", forcelc); - for (int iat = 0; iat < ucell.nat; iat++) - { - Parallel_Reduce::reduce_double_pool(this->fvl_dvl[iat], 3); - } - - delete[] aux; - - timer::tick("Force_LCAO","cal_force_loc"); - return; -} - - -#include "src_pw/H_Ewald_pw.h" -void Force_LCAO::cal_force_ew(void) -{ - timer::tick("Force_lo","cal_force_ew",'E'); - - double fact = 2.0; - complex *aux = new complex [pw.ngmc]; - ZEROS(aux, pw.ngmc); - - int gstart = pw.gstart; - - if (pw.ggs[0] != 0) gstart = 0; - - for (int it = 0; it < ucell.ntype; it++) - { - for (int ig = gstart; ig < pw.ngmc; ig++) - { - aux[ig] += static_cast(ucell.atoms[it].zv) * conj(pw.strucFac(it, ig)); - } - } - - for (int ig = gstart; ig < pw.ngmc; ig++) - { - aux[ig] *= exp(-1.0 * pw.gg[ig] * ucell.tpiba2 / H_Ewald_pw::alpha / 4.0) / (pw.gg[ig] * ucell.tpiba2); - } - - int iat = 0; - for (int it = 0; it < ucell.ntype; it++) - { - for (int ia = 0; ia < ucell.atoms[it].na; ia++) - { - ZEROS(fewalds[iat],3); - for (int ig = gstart; ig < pw.ngmc; ig++) - { - const double arg = TWO_PI * (pw.gcar[ig] * ucell.atoms[it].tau[ia]); - double sumnb = -cos(arg) * aux[ig].imag() + sin(arg) * aux[ig].real(); - fewalds[iat][0] += pw.gcar[ig].x * sumnb; - fewalds[iat][1] += pw.gcar[ig].y * sumnb; - fewalds[iat][2] += pw.gcar[ig].z * sumnb; - } - for (int ipol = 0; ipol < 3; ipol++) - { - fewalds[iat][ipol] *= ucell.atoms[it].zv * e2 * ucell.tpiba * TWO_PI / ucell.omega * fact; - } - iat++; - } - } - delete [] aux; - - for (int iat = 0; iat < ucell.nat; iat++) - { - Parallel_Reduce::reduce_double_pool(this->fewalds[iat], 3); - } - - // mohan fix bug 2010-07-15 - // means that the processor contains G=0 term. - if (gstart == 1) - { - double rmax = 5.0 / (sqrt(H_Ewald_pw::alpha) * ucell.lat0); - int nrm = 0; - - //output of rgen: the number of vectors in the sphere - const int mxr = 50; - // the maximum number of R vectors included in r - Vector3 *r = new Vector3[mxr]; - double *r2 = new double[mxr]; - int *irr = new int[mxr]; - ZEROS(r2, mxr); - ZEROS(irr, mxr); - // the square modulus of R_j-tau_s-tau_s' - - int iat1 = 0; - for (int it1 = 0; it1 < ucell.ntype; it1++) - { - for (int ia1 = 0; ia1 < ucell.atoms[it1].na; ia1++) - { - int iat2 = 0; // mohan fix serious bug 2011-06-07 - for (int it2 = 0; it2 < ucell.ntype; it2++) - { - for (int ia2 = 0; ia2 < ucell.atoms[it2].na; ia2++) - { - if (iat1 != iat2) - { - Vector3 d_tau = ucell.atoms[it1].tau[ia1] - ucell.atoms[it2].tau[ia2]; - H_Ewald_pw::rgen(d_tau, rmax, irr, ucell.latvec, ucell.G, r, r2, nrm); - // return r2[n], r(n, ipol) -// cout << "nrm = " << nrm << endl; - - for (int n = 0; n < nrm; n++) - { - assert (H_Ewald_pw::alpha >= 0.0); - - const double rr = sqrt(r2[n]) * ucell.lat0; - double factor = ucell.atoms[it1].zv * ucell.atoms[it2].zv * e2 / (rr * rr) - * (erfc(sqrt(H_Ewald_pw::alpha) * rr) / rr - + sqrt(8.0 * H_Ewald_pw::alpha / TWO_PI) - * exp(-1.0 * H_Ewald_pw::alpha * rr * rr)) * ucell.lat0; - - //remian problem - //fix bug iat -> iat1 - fewalds[iat1][0] -= factor * r[n].x; - fewalds[iat1][1] -= factor * r[n].y; - fewalds[iat1][2] -= factor * r[n].z; - } - } - iat2++; - }//ia2 - }//atom b - iat1++; - }//ia1 - }//atom a - - delete[] r; - delete[] r2; - delete[] irr; - }//gstart - -#ifdef __MPI - // (1) only used force to do BFGS in processor 0. - // or (2) ewalds bcast from processor 0, which is - // happen to be gstart=1. - for (int iat = 0; iat < ucell.nat; iat++) - { - Parallel_Common::bcast_double(this->fewalds[iat], 3); - } -#endif - - // this->print(ofs_running, "ewald forces", forceion); - timer::tick("Force_lo","cal_force_ew"); - - return; -} - -void Force_LCAO::cal_force_cc(void) -{ - timer::tick("Force_LCAO","cal_force_cc",'E'); - // recalculate the exchange-correlation potential. - matrix vxc(NSPIN, pw.nrxx); - #ifdef TEST_LIBXC - Potential_Libxc::v_xc(CHR.rho, en.etxc, en.vtxc, vxc); - #else - H_XC_pw::v_xc(pw.nrxx, pw.ncxyz, ucell.omega, CHR.rho, CHR.rho_core, vxc); - #endif - - complex * psiv = new complex [pw.nrxx]; - ZEROS(psiv, pw.nrxx); - if (NSPIN == 1 || NSPIN == 4) - { - for (int ir = 0;ir < pw.nrxx;ir++) - { - psiv[ir] = complex(vxc(0, ir), 0.0); - } - } - else - { - for (int ir = 0;ir < pw.nrxx;ir++) - { - psiv[ir] = 0.5 * (vxc(0 ,ir) + vxc(1, ir)); - } - } - - // to G space - pw.FFT_chg.FFT3D(psiv, -1); - - //psiv contains now Vxc(G) - double * rhocg = new double [pw.nggm]; - ZEROS(rhocg, pw.nggm); - - for (int T1 = 0;T1 < ucell.ntype;T1++) - { - if (ucell.atoms[T1].nlcc) - { - //call drhoc - CHR.non_linear_core_correction( - ppcell.numeric, - ucell.atoms[T1].msh, - ucell.atoms[T1].r, - ucell.atoms[T1].rab, - ucell.atoms[T1].rho_atc, - rhocg); - int iat = 0; - - - complex ipol0, ipol1, ipol2; - for (int T2 = 0;T2 < ucell.ntype;T2++) - { - for (int I2 = 0;I2 < ucell.atoms[T2].na;I2++) - { - if (T2 == T1) - { - for (int ig = pw.gstart; ig < pw.ngmc; ig++) - { - const double arg = TWO_PI * (pw.gcar[ig].x * ucell.atoms[T2].tau[I2].x - + pw.gcar[ig].y * ucell.atoms[T2].tau[I2].y - + pw.gcar[ig].z * ucell.atoms[T2].tau[I2].z); - - ipol0 = ucell.tpiba * ucell.omega * rhocg[pw.ig2ngg[ig]] - * pw.gcar[ig].x * conj(psiv[pw.ig2fftc[ig]]) - * complex(sin(arg), cos(arg)) ; - this->fcc[iat][0] += ipol0.real(); - - ipol1 = ucell.tpiba * ucell.omega * rhocg[pw.ig2ngg[ig]] - * pw.gcar[ig].y * conj(psiv[pw.ig2fftc[ig]]) - * complex(sin(arg), cos(arg)) ; - this->fcc[iat][1] += ipol1.real(); - - ipol2 = ucell.tpiba * ucell.omega * rhocg[pw.ig2ngg[ig]] - * pw.gcar[ig].z * conj(psiv[pw.ig2fftc[ig]]) - * complex(sin(arg), cos(arg)) ; - - this->fcc[iat][2] += ipol2.real(); - } - ++iat; - } - } - } - } - } - delete [] rhocg; - delete [] psiv; // mohan fix bug 2012-03-22 - - // need to be improved here, otherwise the calling time is - // to many! - for(int iat=0; iatfcc[iat], 3); - } - timer::tick("Force_LCAO","cal_force_cc",'E'); - return; -} - - -void Force_LCAO::cal_force_scc(void) -{ - TITLE ("Force_LCAO", "cal_force_scc"); - timer::tick ("Force_LCAO", "cal_force_scc",'E'); - -// cout << " calculate scc force" << endl; - - complex* psic = new complex [pw.nrxx]; - ZEROS(psic, pw.nrxx); - - if (NSPIN == 1 || NSPIN == 4) - { - for (int i = 0; i < pw.nrxx; i++) - { - psic[i] = pot.vnew(0,i); - } - } - else - { - int isup = 0; - int isdw = 1; - for (int i = 0; i < pw.nrxx; i++) - { - psic[i] = (pot.vnew(isup, i) + pot.vnew(isdw, i)) * 0.5; - } - } - - int ndm = 0; - for (int it = 0; it < ucell.ntype; it++) - { - if (ndm < ucell.atoms[it].msh) - { - ndm = ucell.atoms[it].msh; - } - } - - //work space - double* aux = new double[ndm]; - ZEROS(aux, ndm); - - double* rhocgnt = new double[pw.nggm]; - ZEROS(rhocgnt, pw.nggm); - - pw.FFT_chg.FFT3D(psic, -1); - - double fact = 2.0; - for (int nt = 0; nt < ucell.ntype; nt++) - { -// Here we compute the G.ne.0 term - const int mesh = ucell.atoms[nt].msh; - for (int ig = pw.gstart; ig < pw.nggm; ig++) - { - const double gx = sqrt(pw.ggs[ig]) * ucell.tpiba; - for (int ir = 0; ir < mesh; ir++) - { - if (ucell.atoms[nt].r[ir] < 1.0e-8) - { - aux[ir] = ucell.atoms[nt].rho_at[ir]; - } - else - { - const double gxx = gx * ucell.atoms[nt].r[ir]; - aux[ir] = ucell.atoms[nt].rho_at[ir] * sin(gxx) / gxx; - } - } - Mathzone::Simpson_Integral(mesh , aux, ucell.atoms[nt].rab , rhocgnt [ig]); - } - - int iat = 0; - for (int it = 0; it < ucell.ntype; it++) - { - Atom* atom = &ucell.atoms[it]; - for (int ia = 0; ia < ucell.atoms[it].na; ia++) - { - if (nt == it) - { - for (int ig = pw.gstart; ig < pw.ngmc; ig++) - { - const double arg = TWO_PI * (pw.gcar[ig].x * atom->tau[ia].x - + pw.gcar[ig].y * atom->tau[ia].y - + pw.gcar[ig].z * atom->tau[ia].z); - - const complex cpm = complex(sin(arg), cos(arg)) * conj(psic[pw.ig2fftc[ig] ]); - - fscc[iat][0] += fact * rhocgnt [pw.ig2ngg[ig] ] * ucell.tpiba * pw.gcar[ig].x * cpm.real(); - fscc[iat][1] += fact * rhocgnt [pw.ig2ngg[ig] ] * ucell.tpiba * pw.gcar[ig].y * cpm.real(); - fscc[iat][2] += fact * rhocgnt [pw.ig2ngg[ig] ] * ucell.tpiba * pw.gcar[ig].z * cpm.real(); - } - } - // cout << " fscc=" << fscc[iat][0] << " " << fscc[iat][1] << " " << fscc[iat][2] << endl; - iat++; - } - } - } - - for (int iat = 0; iat < ucell.nat; iat++) - { - Parallel_Reduce::reduce_double_pool(this->fscc[iat], 3); - } - - delete[] psic; // mohan fix bug 2012-03-22 - delete[] aux; // mohan fix bug 2012-03-22 - delete[] rhocgnt; // mohan fix bug 2012-03-22 - timer::tick ("Force_LCAO", "cal_force_scc",'E'); - return; -} - - -void Force_LCAO::cal_stress(matrix &stress) -{ - TITLE("Force_LCAO","cal_stress"); - - Stress_LCAO SS; - SS.start_stress(this->soverlap, this->stvnl_dphi, this->svnl_dbeta, this->svl_dphi, this->stress_vdw, stress); - - double unit_transform = 0.0; - unit_transform = RYDBERG_SI / pow(BOHR_RADIUS_SI,3) * 1.0e-8; - double external_stress[3] = {PRESS1,PRESS2,PRESS3}; - - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - - //quxin added for DFT+U; stress contribution from DFT+U - if(INPUT.dft_plus_u) stress(i,j) += dftu.stress_dftu.at(i).at(j); - } - stress(i,i) -= external_stress[i]/unit_transform; - - } - PRESSURE = (stress(0,0)+stress(1,1)+stress(2,2))/3; - - - return; -} diff --git a/ABACUS.develop/source/src_lcao/force_lcao.h b/ABACUS.develop/source/src_lcao/force_lcao.h deleted file mode 100644 index 65aa6fd0d5..0000000000 --- a/ABACUS.develop/source/src_lcao/force_lcao.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef FORCE_LCAO_H -#define FORCE_LCAO_H - -#include "../src_pw/tools.h" -#include "force_lcao_k.h" -#include "stress_lcao.h" -#include "../input_conv.h" - -class Force_LCAO : private Force_LCAO_k -{ - // mohan add 2021-02-09 - friend class md; - friend void Input_Conv::Convert(); - friend class Update_input; - friend class Local_Orbital_Ions; - - public : - - Force_LCAO (); - ~Force_LCAO (); - - private: - - void allocate (void); - void destroy (void); - - void cal_force_loc (void); - void cal_force_ew (void); - void cal_force_scc (void); - void cal_force_cc (void); - - void print_force(const string &name, double** f, const bool screen, bool ry)const; - void printforce_total (bool ry); - - void start_force(void); - - void cal_stress(matrix &stress); - - // total force - matrix fcs; - static double force_invalid_threshold_ev; // mohan add 2011-04-17 - - matrix stress_vdw;//zhengdy added for vdw-stress-part - - //each part of force - double** fvl_dvl; - double** fewalds; - double** fcc; - double** fscc; - - bool allocate_flag; - double output_acc; // control the accuracy -}; -#endif diff --git a/ABACUS.develop/source/src_lcao/force_lcao_gamma.cpp b/ABACUS.develop/source/src_lcao/force_lcao_gamma.cpp index bce5066dc1..6a0f326ad3 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao_gamma.cpp +++ b/ABACUS.develop/source/src_lcao/force_lcao_gamma.cpp @@ -11,7 +11,17 @@ Force_LCAO_gamma::~Force_LCAO_gamma () } // be called in force_lo.cpp -void Force_LCAO_gamma::ftable_gamma (void) +void Force_LCAO_gamma::ftable_gamma ( + const bool isforce, + const bool isstress, + matrix& foverlap, + matrix& ftvnl_dphi, + matrix& fvnl_dbeta, + matrix& fvl_dphi, + matrix& soverlap, + matrix& stvnl_dphi, + matrix& svnl_dbeta, + matrix& svl_dphi) { TITLE("Force_LCAO_gamma", "ftable"); timer::tick("Force_LCAO_gamma","ftable_gamma",'F'); @@ -21,13 +31,13 @@ void Force_LCAO_gamma::ftable_gamma (void) this->allocate_gamma(); // calculate the 'energy density matrix' here. - this->cal_foverlap(); + this->cal_foverlap(isforce, isstress, foverlap, soverlap); if(NEW_DM>0) { - this->cal_ftvnl_dphi(LOC.wfc_dm_2d.dm_gamma); - this->cal_fvnl_dbeta(LOC.wfc_dm_2d.dm_gamma); - this->cal_fvl_dphi(LOC.wfc_dm_2d.dm_gamma); + this->cal_ftvnl_dphi(LOC.wfc_dm_2d.dm_gamma, isforce, isstress, ftvnl_dphi, stvnl_dphi); + this->cal_fvnl_dbeta(LOC.wfc_dm_2d.dm_gamma, isforce, isstress, fvnl_dbeta, svnl_dbeta); + this->cal_fvl_dphi(LOC.wfc_dm_2d.dm_gamma, isforce, isstress, fvl_dphi, svl_dphi); //quxin added for DFT+U if(INPUT.dft_plus_u) @@ -40,24 +50,18 @@ void Force_LCAO_gamma::ftable_gamma (void) { timer::tick("Force_LCAO_gamma","cal_dm_grid",'G'); // calculate the 'density matrix' here. - double** dm2d = new double*[NSPIN]; - for(int is=0; isset_EDM_gamma(dm2d[is], with_energy, is); - } + this->set_EDM_gamma(dm2d, with_energy); + timer::tick("Force_LCAO_gamma","cal_dm_grid",'G'); - this->cal_ftvnl_dphi(dm2d); - this->cal_fvnl_dbeta(dm2d); + this->cal_ftvnl_dphi(dm2d, isforce, isstress, ftvnl_dphi, stvnl_dphi); + this->cal_fvnl_dbeta(dm2d, isforce, isstress, fvnl_dbeta, svnl_dbeta); //quxin added for DFT+U if(INPUT.dft_plus_u) @@ -67,28 +71,22 @@ void Force_LCAO_gamma::ftable_gamma (void) } // calculate < dphi | V | phi > on real space grid. - this->cal_fvl_dphi(dm2d); + this->cal_fvl_dphi(dm2d, isforce, isstress, fvl_dphi, svl_dphi); - for(int is=0; isfoverlap[iat], 3); - Parallel_Reduce::reduce_double_pool( this->ftvnl_dphi[iat], 3); - Parallel_Reduce::reduce_double_pool( this->fvnl_dbeta[iat], 3); - Parallel_Reduce::reduce_double_pool( this->fvl_dphi[iat], 3); - } - if(STRESS)for (int ipol=0; ipol<3; ipol++) - { - Parallel_Reduce::reduce_double_pool( this->soverlap[ipol], 3); - Parallel_Reduce::reduce_double_pool( this->stvnl_dphi[ipol], 3); - Parallel_Reduce::reduce_double_pool( this->svnl_dbeta[ipol], 3); - Parallel_Reduce::reduce_double_pool( this->svl_dphi[ipol], 3); + Parallel_Reduce::reduce_double_pool( soverlap.c, soverlap.nr * soverlap.nc); + Parallel_Reduce::reduce_double_pool( stvnl_dphi.c, stvnl_dphi.nr * stvnl_dphi.nc); + Parallel_Reduce::reduce_double_pool( svnl_dbeta.c, svnl_dbeta.nr * svnl_dbeta.nc); + Parallel_Reduce::reduce_double_pool( svl_dphi.c, svl_dphi.nr * svl_dphi.nc); } // delete DSloc_x, DSloc_y, DSloc_z @@ -233,7 +231,7 @@ double Force_LCAO_gamma::set_EDM_element( } //#include "../src_develop/src_siao/selinv.h" -void Force_LCAO_gamma::set_EDM_gamma(double* dm, bool with_energy, const int &ispin)//ispin is the spin index. +void Force_LCAO_gamma::set_EDM_gamma(matrix& dm, bool with_energy) { TITLE("Force_LCAO_gamma","set_EDM_gamma"); timer::tick("Force_LCAO_gamma","set_EDM"); @@ -275,569 +273,575 @@ void Force_LCAO_gamma::set_EDM_gamma(double* dm, bool with_energy, const int &is MPI_Comm_rank(DIAG_HPSEPS_WORLD,&myid); int local_band=NBANDS/DSIZE; - if (DRANK= NBANDS) - { - lastband_in_proc = i; - lastband_number = NBANDS - (count_bands - local_bands[i]); - break; - } - } - - double** w1; - w1 = new double*[NSPIN]; - for(int is=0; is= 1) - { - double** ZW_300; - ZW_300 = new double*[NSPIN]; - for(int is=0; is= 0 && col_nu >= 0) - { - int index = row_mu * ParaO.ncol + col_nu; - //dm[index] = rho_300[ispin][i_col + i_row*300]; - dm[index] = rho_300[ispin][i_row + i_col*300]; - } - } - } - } - for(int is=0; is= 0 && col_nu >= 0) - { - int index = row_mu * ParaO.ncol + col_nu; - //dm[index] = rho_300_remain[ispin][i_col + i_row*col_remain]; - dm[index] = rho_300_remain[ispin][i_row + i_col*300]; - } - } - } - } - for(int is=0; is= 0 && col_nu >= 0) - { - int index = row_mu * ParaO.ncol + col_nu; - dm[index] = rho_remain_300[ispin][i_row + i_col*row_remain]; - } - } - } - } - for(int is=0; is= 0 && col_nu >= 0) - { - int index = row_mu * ParaO.ncol + col_nu; - dm[index] = rho_remain_remain[ispin][i_row + i_col*row_remain]; - } - } - } - } - for(int is=0; is= 0 && col_nu >= 0) - { - int index = row_mu * ParaO.ncol + col_nu; - dm[index] = rho_NLOCAL_NLOCAL[ispin][i_col + i_row*NLOCAL]; - } - } - } - } - for(int is=0; is= NBANDS) + { + lastband_in_proc = i; + lastband_number = NBANDS - (count_bands - local_bands[i]); + break; + } + } + + for(int ispin=0;ispin= 1) + { + double** ZW_300; + ZW_300 = new double*[NSPIN]; + for(int is=0; is= 0 && col_nu >= 0) + { + int index = row_mu * ParaO.ncol + col_nu; + //dm[index] = rho_300[ispin][i_col + i_row*300]; + dm(ispin, index) = rho_300[ispin][i_row + i_col*300]; + } + } + } + } + for(int is=0; is= 0 && col_nu >= 0) + { + int index = row_mu * ParaO.ncol + col_nu; + //dm[index] = rho_300_remain[ispin][i_col + i_row*col_remain]; + dm(ispin, index) = rho_300_remain[ispin][i_row + i_col*300]; + } + } + } + } + for(int is=0; is= 0 && col_nu >= 0) + { + int index = row_mu * ParaO.ncol + col_nu; + dm(ispin, index) = rho_remain_300[ispin][i_row + i_col*row_remain]; + } + } + } + } + for(int is=0; is= 0 && col_nu >= 0) + { + int index = row_mu * ParaO.ncol + col_nu; + dm(ispin, index) = rho_remain_remain[ispin][i_row + i_col*row_remain]; + } + } + } + } + for(int is=0; is= 0 && col_nu >= 0) + { + int index = row_mu * ParaO.ncol + col_nu; + dm(ispin, index) = rho_NLOCAL_NLOCAL[ispin][i_col + i_row*NLOCAL]; + } + } + } + } + for(int is=0; is=0 && jj>=0) - { - ene = this->set_EDM_element(ii, jj, with_energy, LOWF.WFC_GAMMA, LOWF.WFC_GAMMA, ispin); - } - - // (2) - else if(ii>=0 && jj<0) - { - const int a4 = LOWF.trace_aug[j]; - assert(a4>=0); - ene = this->set_EDM_element(ii, a4, with_energy, LOWF.WFC_GAMMA, LOWF.WFC_GAMMA_aug, ispin); - } - else if(ii<0 && jj>=0) - { - const int a3 = LOWF.trace_aug[i]; - assert(a3>=0); - // mohan fix serious bug 2011-07-01 (ii, a3) -> (a3, jj) !!!!!!!!!!!! - ene = this->set_EDM_element(a3, jj, with_energy, LOWF.WFC_GAMMA_aug, LOWF.WFC_GAMMA, ispin); - } - else if(ii<0 && jj<0) - { - const int a3 = LOWF.trace_aug[i]; - const int a4 = LOWF.trace_aug[j]; - assert(a3>=0); - assert(a4>=0); - ene = this->set_EDM_element(a3, a4, with_energy, LOWF.WFC_GAMMA_aug, LOWF.WFC_GAMMA_aug, ispin); - } - - dm[index] = ene; - //dm[index] = 1.0;// mohan tmp - }// end j - }// end i + for(int ispin=0;ispin=0 && jj>=0) + { + ene = this->set_EDM_element(ii, jj, with_energy, LOWF.WFC_GAMMA, LOWF.WFC_GAMMA, ispin); + } + + // (2) + else if(ii>=0 && jj<0) + { + const int a4 = LOWF.trace_aug[j]; + assert(a4>=0); + ene = this->set_EDM_element(ii, a4, with_energy, LOWF.WFC_GAMMA, LOWF.WFC_GAMMA_aug, ispin); + } + else if(ii<0 && jj>=0) + { + const int a3 = LOWF.trace_aug[i]; + assert(a3>=0); + // mohan fix serious bug 2011-07-01 (ii, a3) -> (a3, jj) !!!!!!!!!!!! + ene = this->set_EDM_element(a3, jj, with_energy, LOWF.WFC_GAMMA_aug, LOWF.WFC_GAMMA, ispin); + } + else if(ii<0 && jj<0) + { + const int a3 = LOWF.trace_aug[i]; + const int a4 = LOWF.trace_aug[j]; + assert(a3>=0); + assert(a4>=0); + ene = this->set_EDM_element(a3, a4, with_energy, LOWF.WFC_GAMMA_aug, LOWF.WFC_GAMMA_aug, ispin); + } + + dm(ispin, index) = ene; + //dm[index] = 1.0;// mohan tmp + }// end j + }// end i + }//end ispin #endif //2015-09-06, xiaohui timer::tick("Force_LCAO_gamma","set_EDM"); return; @@ -870,21 +874,15 @@ void Force_LCAO_gamma::DerivT_PW(void) // force due to the overlap matrix. // need energy density matrix here. -void Force_LCAO_gamma::cal_foverlap(void) +void Force_LCAO_gamma::cal_foverlap( + const bool isforce, + const bool isstress, + matrix& foverlap, + matrix& soverlap) { TITLE("Force_LCAO_gamma","cal_foverlap"); timer::tick("Force_LCAO_gamma","cal_foverlap",'G'); - // set the force arrays. - for(int iat=0; iatsoverlap[ipol], 3); - } - // set energy density matrix. if(NEW_DM>0) { @@ -925,18 +923,21 @@ void Force_LCAO_gamma::cal_foverlap(void) } sum *= 2.0; - this->foverlap[iat][0] += sum * LM.DSloc_x[index]; - this->foverlap[iat][1] += sum * LM.DSloc_y[index]; - this->foverlap[iat][2] += sum * LM.DSloc_z[index]; + if(isforce) + { + foverlap(iat,0) += sum * LM.DSloc_x[index]; + foverlap(iat,1) += sum * LM.DSloc_y[index]; + foverlap(iat,2) += sum * LM.DSloc_z[index]; + } - if(STRESS) + if(isstress) { - this->soverlap[0][0] += sum/2.0 * LM.DSloc_11[index]; - this->soverlap[0][1] += sum/2.0 * LM.DSloc_12[index]; - this->soverlap[0][2] += sum/2.0 * LM.DSloc_13[index]; - this->soverlap[1][1] += sum/2.0 * LM.DSloc_22[index]; - this->soverlap[1][2] += sum/2.0 * LM.DSloc_23[index]; - this->soverlap[2][2] += sum/2.0 * LM.DSloc_33[index]; + soverlap(0,0) += sum/2.0 * LM.DSloc_11[index]; + soverlap(0,1) += sum/2.0 * LM.DSloc_12[index]; + soverlap(0,2) += sum/2.0 * LM.DSloc_13[index]; + soverlap(1,1) += sum/2.0 * LM.DSloc_22[index]; + soverlap(1,2) += sum/2.0 * LM.DSloc_23[index]; + soverlap(2,2) += sum/2.0 * LM.DSloc_33[index]; } } @@ -946,30 +947,15 @@ void Force_LCAO_gamma::cal_foverlap(void) else { timer::tick("Force_LCAO_gamma","cal_edm_grid",'H'); - double** edm2d = new double*[NSPIN]; - for(int is=0; isset_EDM_gamma(edm2d[is], with_energy,is); - //stringstream ss; - //ss<<"EDM_"<set_EDM_gamma(edm2d, with_energy); + timer::tick("Force_LCAO_gamma","cal_edm_grid",'H'); //summation \sum_{i,j} E(i,j)*dS(i,j) @@ -996,47 +982,39 @@ void Force_LCAO_gamma::cal_foverlap(void) double sum = 0.0; for(int is=0; isfoverlap[iat][0] += sum * LM.DSloc_x[index]; - this->foverlap[iat][1] += sum * LM.DSloc_y[index]; - this->foverlap[iat][2] += sum * LM.DSloc_z[index]; - if(STRESS) + if(isforce) + { + foverlap(iat,0) += sum * LM.DSloc_x[index]; + foverlap(iat,1) += sum * LM.DSloc_y[index]; + foverlap(iat,2) += sum * LM.DSloc_z[index]; + } + + if(isstress) { - this->soverlap[0][0] += sum/2.0 * LM.DSloc_11[index]; - this->soverlap[0][1] += sum/2.0 * LM.DSloc_12[index]; - this->soverlap[0][2] += sum/2.0 * LM.DSloc_13[index]; - this->soverlap[1][1] += sum/2.0 * LM.DSloc_22[index]; - this->soverlap[1][2] += sum/2.0 * LM.DSloc_23[index]; - this->soverlap[2][2] += sum/2.0 * LM.DSloc_33[index]; - } + soverlap(0,0) += sum/2.0 * LM.DSloc_11[index]; + soverlap(0,1) += sum/2.0 * LM.DSloc_12[index]; + soverlap(0,2) += sum/2.0 * LM.DSloc_13[index]; + soverlap(1,1) += sum/2.0 * LM.DSloc_22[index]; + soverlap(1,2) += sum/2.0 * LM.DSloc_23[index]; + soverlap(2,2) += sum/2.0 * LM.DSloc_33[index]; + } } } } - - for(int is=0; issoverlap[j][i] = this->soverlap[i][j]; - } - } - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - this->soverlap[i][j] *= ucell.lat0 / ucell.omega; + if(istvnl_dphi[ipol], 3); - } for(int i=0; iftvnl_dphi[iat][0] += sum * LM.DHloc_fixed_x[index]; - this->ftvnl_dphi[iat][1] += sum * LM.DHloc_fixed_y[index]; - this->ftvnl_dphi[iat][2] += sum * LM.DHloc_fixed_z[index]; - if(STRESS) + if(isforce) + { + ftvnl_dphi(iat,0) += sum * LM.DHloc_fixed_x[index]; + ftvnl_dphi(iat,1) += sum * LM.DHloc_fixed_y[index]; + ftvnl_dphi(iat,2) += sum * LM.DHloc_fixed_z[index]; + } + if(isstress) { - this->stvnl_dphi[0][0] += sum/2.0 * LM.DHloc_fixed_11[index]; - this->stvnl_dphi[0][1] += sum/2.0 * LM.DHloc_fixed_12[index]; - this->stvnl_dphi[0][2] += sum/2.0 * LM.DHloc_fixed_13[index]; - this->stvnl_dphi[1][1] += sum/2.0 * LM.DHloc_fixed_22[index]; - this->stvnl_dphi[1][2] += sum/2.0 * LM.DHloc_fixed_23[index]; - this->stvnl_dphi[2][2] += sum/2.0 * LM.DHloc_fixed_33[index]; + stvnl_dphi(0,0) += sum/2.0 * LM.DHloc_fixed_11[index]; + stvnl_dphi(0,1) += sum/2.0 * LM.DHloc_fixed_12[index]; + stvnl_dphi(0,2) += sum/2.0 * LM.DHloc_fixed_13[index]; + stvnl_dphi(1,1) += sum/2.0 * LM.DHloc_fixed_22[index]; + stvnl_dphi(1,2) += sum/2.0 * LM.DHloc_fixed_23[index]; + stvnl_dphi(2,2) += sum/2.0 * LM.DHloc_fixed_33[index]; } } } } - if(STRESS){ + if(isstress){ for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { - if(istvnl_dphi[j][i] = this->stvnl_dphi[i][j]; - } - } - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - this->stvnl_dphi[i][j] *= ucell.lat0 / ucell.omega; + if(isvl_dphi[ipol], 3); - } } @@ -1208,19 +1188,22 @@ void Force_LCAO_gamma::cal_fvl_dphi(double** dm2d) const int index = mu * ParaO.ncol + nu; //contribution from deriv of AO's in T+VNL term - double dm2d2 = 2.0 * dm2d[is][index]; + double dm2d2 = 2.0 * dm2d(is, index); - this->fvl_dphi[iat][0] -= dm2d2 * ( LM.DHloc_fixed_x[index] + tmpDHx[index] ); - this->fvl_dphi[iat][1] -= dm2d2 * ( LM.DHloc_fixed_y[index] + tmpDHy[index] ); - this->fvl_dphi[iat][2] -= dm2d2 * ( LM.DHloc_fixed_z[index] + tmpDHz[index] ); - if(STRESS) + if(isforce) + { + fvl_dphi(iat,0) -= dm2d2 * ( LM.DHloc_fixed_x[index] + tmpDHx[index] ); + fvl_dphi(iat,1) -= dm2d2 * ( LM.DHloc_fixed_y[index] + tmpDHy[index] ); + fvl_dphi(iat,2) -= dm2d2 * ( LM.DHloc_fixed_z[index] + tmpDHz[index] ); + } + if(isstress) { - this->svl_dphi[0][0] += dm2d2 * LM.DHloc_fixed_11[index]; - this->svl_dphi[0][1] += dm2d2 * LM.DHloc_fixed_12[index]; - this->svl_dphi[0][2] += dm2d2 * LM.DHloc_fixed_13[index]; - this->svl_dphi[1][1] += dm2d2 * LM.DHloc_fixed_22[index]; - this->svl_dphi[1][2] += dm2d2 * LM.DHloc_fixed_23[index]; - this->svl_dphi[2][2] += dm2d2 * LM.DHloc_fixed_33[index]; + svl_dphi(0,0) += dm2d2 * LM.DHloc_fixed_11[index]; + svl_dphi(0,1) += dm2d2 * LM.DHloc_fixed_12[index]; + svl_dphi(0,2) += dm2d2 * LM.DHloc_fixed_13[index]; + svl_dphi(1,1) += dm2d2 * LM.DHloc_fixed_22[index]; + svl_dphi(1,2) += dm2d2 * LM.DHloc_fixed_23[index]; + svl_dphi(2,2) += dm2d2 * LM.DHloc_fixed_33[index]; } // cout << setw(5) << iat << setw(5) << iat2 // << setw(5) << mu << setw(5) << nu @@ -1242,20 +1225,14 @@ void Force_LCAO_gamma::cal_fvl_dphi(double** dm2d) // test mohan tmp // test_gamma(LM.DHloc_fixed_x,"LM.DHloc_fixed_x"); - if(STRESS) + if(isstress) { for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { - if(isvl_dphi[j][i] = this->svl_dphi[i][j]; - } - } - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - this->svl_dphi[i][j] /= ucell.omega; + if(isvnl_dbeta[ipol], 3); - } + for(int iat=0; iatiw2n[kk], // n1 tau0, it); double nlm1[3] = {0,0,0}; - if(STRESS) UOT.snap_psibeta( + if(isstress) UOT.snap_psibeta( nlm1, 1, tau2, T2, atom2->iw2l[kk], // L2 @@ -1373,20 +1353,24 @@ void Force_LCAO_gamma::cal_fvnl_dbeta(double** dm2d) double sum = 0.0; for(int is=0; isfvnl_dbeta[iat][0] -= sum * nlm[0]; - this->fvnl_dbeta[iat][1] -= sum * nlm[1]; - this->fvnl_dbeta[iat][2] -= sum * nlm[2]; - - if(STRESS) + + if(isforce) + { + fvnl_dbeta(iat,0) -= sum * nlm[0]; + fvnl_dbeta(iat,1) -= sum * nlm[1]; + fvnl_dbeta(iat,2) -= sum * nlm[2]; + } + + if(isstress) { - for(int ipol=0;ipol<3;ipol++){ - this->svnl_dbeta[0][ipol] -= sum/2.0 * (nlm[0] * r0[ipol] + nlm1[0] * r1[ipol])* -1; - this->svnl_dbeta[1][ipol] -= sum/2.0 * (nlm[1] * r0[ipol] + nlm1[1] * r1[ipol])* -1; - this->svnl_dbeta[2][ipol] -= sum/2.0 * (nlm[2] * r0[ipol] + nlm1[2] * r1[ipol])* -1; + for(int ipol=0;ipol<3;ipol++) + { + svnl_dbeta(0,ipol) -= sum/2.0 * (nlm[0] * r0[ipol] + nlm1[0] * r1[ipol])* -1; + svnl_dbeta(1,ipol) -= sum/2.0 * (nlm[1] * r0[ipol] + nlm1[1] * r1[ipol])* -1; + svnl_dbeta(2,ipol) -= sum/2.0 * (nlm[2] * r0[ipol] + nlm1[2] * r1[ipol])* -1; } } }//!kk @@ -1394,13 +1378,13 @@ void Force_LCAO_gamma::cal_fvnl_dbeta(double** dm2d) }//!jj }//!ad1 }//!iat - if(STRESS) + if(isstress) { for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { - this->svnl_dbeta[i][j] *= ucell.lat0 / ucell.omega; + svnl_dbeta(i,j) *= ucell.lat0 / ucell.omega; } } } @@ -1409,16 +1393,16 @@ void Force_LCAO_gamma::cal_fvnl_dbeta(double** dm2d) } -void Force_LCAO_gamma::cal_ftvnl_dphi(const std::vector &dm2d) +void Force_LCAO_gamma::cal_ftvnl_dphi( + const std::vector &dm2d, + const bool isforce, + const bool isstress, + matrix& ftvnl_dphi, + matrix& stvnl_dphi) { TITLE("Force_LCAO_gamma","cal_ftvnl_dphi"); timer::tick("Force_LCAO_gamma","cal_ftvnl_dphi",'G'); - if(STRESS)for(int ipol=0; ipol<3; ++ipol) - { - ZEROS( this->stvnl_dphi[ipol], 3); - } - for(int i=0; i &dm2d) } sum *= 2.0; - this->ftvnl_dphi[iat][0] += sum * LM.DHloc_fixed_x[index]; - this->ftvnl_dphi[iat][1] += sum * LM.DHloc_fixed_y[index]; - this->ftvnl_dphi[iat][2] += sum * LM.DHloc_fixed_z[index]; - if(STRESS) + if(isforce) + { + ftvnl_dphi(iat,0) += sum * LM.DHloc_fixed_x[index]; + ftvnl_dphi(iat,1) += sum * LM.DHloc_fixed_y[index]; + ftvnl_dphi(iat,2) += sum * LM.DHloc_fixed_z[index]; + } + if(isstress) { - this->stvnl_dphi[0][0] += sum/2.0 * LM.DHloc_fixed_11[index]; - this->stvnl_dphi[0][1] += sum/2.0 * LM.DHloc_fixed_12[index]; - this->stvnl_dphi[0][2] += sum/2.0 * LM.DHloc_fixed_13[index]; - this->stvnl_dphi[1][1] += sum/2.0 * LM.DHloc_fixed_22[index]; - this->stvnl_dphi[1][2] += sum/2.0 * LM.DHloc_fixed_23[index]; - this->stvnl_dphi[2][2] += sum/2.0 * LM.DHloc_fixed_33[index]; + stvnl_dphi(0,0) += sum/2.0 * LM.DHloc_fixed_11[index]; + stvnl_dphi(0,1) += sum/2.0 * LM.DHloc_fixed_12[index]; + stvnl_dphi(0,2) += sum/2.0 * LM.DHloc_fixed_13[index]; + stvnl_dphi(1,1) += sum/2.0 * LM.DHloc_fixed_22[index]; + stvnl_dphi(1,2) += sum/2.0 * LM.DHloc_fixed_23[index]; + stvnl_dphi(2,2) += sum/2.0 * LM.DHloc_fixed_33[index]; } } } } - if(STRESS) - { + if(isstress){ for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { - if(istvnl_dphi[j][i] = this->stvnl_dphi[i][j]; - } - } - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - this->stvnl_dphi[i][j] *= ucell.lat0 / ucell.omega; + if(i &dm2d) return; } -void Force_LCAO_gamma::cal_fvl_dphi(const std::vector &dm2d) +void Force_LCAO_gamma::cal_fvl_dphi( + const std::vector &dm2d, + const bool isforce, + const bool isstress, + matrix& fvl_dphi, + matrix& svl_dphi) { TITLE("Force_LCAO_gamma","cal_fvl_dphi"); timer::tick("Force_LCAO_gamma","cal_fvl_dphi",'G'); @@ -1491,10 +1476,6 @@ void Force_LCAO_gamma::cal_fvl_dphi(const std::vector &dm2d) ZEROS (LM.DHloc_fixed_22, ParaO.nloc); ZEROS (LM.DHloc_fixed_23, ParaO.nloc); ZEROS (LM.DHloc_fixed_33, ParaO.nloc); - for(int ipol=0; ipol<3; ++ipol) - { - ZEROS( this->svl_dphi[ipol], 3); - } } @@ -1554,17 +1535,20 @@ void Force_LCAO_gamma::cal_fvl_dphi(const std::vector &dm2d) double dm2d2 = 2.0 * dm2d[is](nu, mu); - this->fvl_dphi[iat][0] -= dm2d2 * ( LM.DHloc_fixed_x[index] + tmpDHx[index] ); - this->fvl_dphi[iat][1] -= dm2d2 * ( LM.DHloc_fixed_y[index] + tmpDHy[index] ); - this->fvl_dphi[iat][2] -= dm2d2 * ( LM.DHloc_fixed_z[index] + tmpDHz[index] ); - if(STRESS) + if(isforce) + { + fvl_dphi(iat,0) -= dm2d2 * ( LM.DHloc_fixed_x[index] + tmpDHx[index] ); + fvl_dphi(iat,1) -= dm2d2 * ( LM.DHloc_fixed_y[index] + tmpDHy[index] ); + fvl_dphi(iat,2) -= dm2d2 * ( LM.DHloc_fixed_z[index] + tmpDHz[index] ); + } + if(isstress) { - this->svl_dphi[0][0] += dm2d2 * LM.DHloc_fixed_11[index]; - this->svl_dphi[0][1] += dm2d2 * LM.DHloc_fixed_12[index]; - this->svl_dphi[0][2] += dm2d2 * LM.DHloc_fixed_13[index]; - this->svl_dphi[1][1] += dm2d2 * LM.DHloc_fixed_22[index]; - this->svl_dphi[1][2] += dm2d2 * LM.DHloc_fixed_23[index]; - this->svl_dphi[2][2] += dm2d2 * LM.DHloc_fixed_33[index]; + svl_dphi(0,0) += dm2d2 * LM.DHloc_fixed_11[index]; + svl_dphi(0,1) += dm2d2 * LM.DHloc_fixed_12[index]; + svl_dphi(0,2) += dm2d2 * LM.DHloc_fixed_13[index]; + svl_dphi(1,1) += dm2d2 * LM.DHloc_fixed_22[index]; + svl_dphi(1,2) += dm2d2 * LM.DHloc_fixed_23[index]; + svl_dphi(2,2) += dm2d2 * LM.DHloc_fixed_33[index]; } //cout << setw(5) << iat << setw(5) << iat2 //<< setw(5) << mu << setw(5) << nu @@ -1585,20 +1569,14 @@ void Force_LCAO_gamma::cal_fvl_dphi(const std::vector &dm2d) // test mohan tmp //test_gamma(LM.DHloc_fixed_x,"LM.DHloc_fixed_x"); - if(STRESS) + if(isstress) { for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { - if(isvl_dphi[j][i] = this->svl_dphi[i][j]; - } - } - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - this->svl_dphi[i][j] /= ucell.omega; + if(i &dm2d) return; } -void Force_LCAO_gamma::cal_fvnl_dbeta(const std::vector &dm2d) +void Force_LCAO_gamma::cal_fvnl_dbeta( + const std::vector &dm2d, + const bool isforce, + const bool isstress, + matrix& fvnl_dbeta, + matrix& svnl_dbeta) { TITLE("Force_LCAO_gamma","cal_fvnl_dbeta"); timer::tick("Force_LCAO_gamma","cal_fvnl_dbeta",'G'); - if(STRESS)for(int ipol=0; ipol<3; ++ipol) - { - ZEROS( this->svnl_dbeta[ipol], 3); - } + for(int iat=0; iat &dm2d) const double dist1 = (tau1-tau0).norm() * ucell.lat0; const double dist2 = (tau2-tau0).norm() * ucell.lat0; - double r0[3],r1[3]; - if(STRESS) + double r0[3]; + double r1[3]; + if(isstress) { r1[0] = ( tau1.x - tau0.x) ; r1[1] = ( tau1.y - tau0.y) ; @@ -1694,7 +1675,7 @@ void Force_LCAO_gamma::cal_fvnl_dbeta(const std::vector &dm2d) atom2->iw2n[kk], // n1 tau0, it); double nlm1[3] = {0,0,0}; - if(STRESS) UOT.snap_psibeta( + if(isstress) UOT.snap_psibeta( nlm1, 1, tau2, T2, atom2->iw2l[kk], // L2 @@ -1719,17 +1700,20 @@ void Force_LCAO_gamma::cal_fvnl_dbeta(const std::vector &dm2d) } sum *= 2.0; - this->fvnl_dbeta[iat][0] -= sum * nlm[0]; - this->fvnl_dbeta[iat][1] -= sum * nlm[1]; - this->fvnl_dbeta[iat][2] -= sum * nlm[2]; + if(isforce) + { + fvnl_dbeta(iat,0) -= sum * nlm[0]; + fvnl_dbeta(iat,1) -= sum * nlm[1]; + fvnl_dbeta(iat,2) -= sum * nlm[2]; + } - if(STRESS) + if(isstress) { for(int ipol=0;ipol<3;ipol++) - { - this->svnl_dbeta[0][ipol] -= sum/2.0 * (nlm[0] * r0[ipol] + nlm1[0] * r1[ipol])* -1; - this->svnl_dbeta[1][ipol] -= sum/2.0 * (nlm[1] * r0[ipol] + nlm1[1] * r1[ipol])* -1; - this->svnl_dbeta[2][ipol] -= sum/2.0 * (nlm[2] * r0[ipol] + nlm1[2] * r1[ipol])* -1; + { + svnl_dbeta(0,ipol) -= sum/2.0 * (nlm[0] * r0[ipol] + nlm1[0] * r1[ipol])* -1; + svnl_dbeta(1,ipol) -= sum/2.0 * (nlm[1] * r0[ipol] + nlm1[1] * r1[ipol])* -1; + svnl_dbeta(2,ipol) -= sum/2.0 * (nlm[2] * r0[ipol] + nlm1[2] * r1[ipol])* -1; } } }//!kk @@ -1737,13 +1721,13 @@ void Force_LCAO_gamma::cal_fvnl_dbeta(const std::vector &dm2d) }//!jj }//!ad1 }//!iat - if(STRESS) + if(isstress) { for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { - this->svnl_dbeta[i][j] *= ucell.lat0 / ucell.omega; + svnl_dbeta(i,j) *= ucell.lat0 / ucell.omega; } } } diff --git a/ABACUS.develop/source/src_lcao/force_lcao_gamma.h b/ABACUS.develop/source/src_lcao/force_lcao_gamma.h index 031e8d4924..5b772e36e2 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao_gamma.h +++ b/ABACUS.develop/source/src_lcao/force_lcao_gamma.h @@ -7,47 +7,79 @@ class Force_LCAO_gamma { public : - + + friend class Force_Stress_LCAO; + Force_LCAO_gamma (); ~Force_LCAO_gamma (); - protected: + private: //orthonormal force + contribution from T and VNL - void ftable_gamma (void); - - //each part of force - double** foverlap; - double** ftvnl_dphi; - double** fvnl_dbeta; - double** fvl_dphi; - - public: - //each part of stress - double soverlap[3][3]; - double stvnl_dphi[3][3]; - double svnl_dbeta[3][3]; - double svl_dphi[3][3]; - - private: + void ftable_gamma ( + const bool isforce, + const bool isstress, + matrix& foverlap, + matrix& ftvnl_dphi, + matrix& fvnl_dbeta, + matrix& fvl_dphi, + matrix& soverlap, + matrix& stvnl_dphi, + matrix& svnl_dbeta, + matrix& svl_dphi + ); // get the ds, dt, dvnl. void allocate_gamma(void); void finish_ftable_gamma(void); - void set_EDM_gamma(double* dm, bool with_energy, const int &is); + void set_EDM_gamma(matrix& dm, bool with_energy); // mohan fix bug 2011-06-15 double set_EDM_element(const int &ii, const int &jj, const bool with_energy, double*** coef1, double*** coef2, const int &is); - void cal_foverlap(void); - void cal_ftvnl_dphi(double** dm2d); - void cal_fvnl_dbeta(double** dm2d); - void cal_fvl_dphi(double** dm2d); + void cal_foverlap( + const bool isforce, + const bool isstress, + matrix& foverlap, + matrix& soverlap); + void cal_ftvnl_dphi( + matrix& dm2d, + const bool isforce, + const bool isstress, + matrix& ftvnl_dphi, + matrix& stvnl_dphi); + void cal_fvnl_dbeta( + matrix& dm2d, + const bool isforce, + const bool isstress, + matrix& fvnl_dbeta, + matrix& svnl_dbeta); + void cal_fvl_dphi( + matrix& dm2d, + const bool isforce, + const bool isstress, + matrix& fvl_dphi, + matrix& svl_dphi); - void cal_ftvnl_dphi(const std::vector &dm2d); - void cal_fvnl_dbeta(const std::vector &dm2d); - void cal_fvl_dphi(const std::vector &dm2d); + void cal_ftvnl_dphi( + const std::vector &dm2d, + const bool isforce, + const bool isstress, + matrix& ftvnl_dphi, + matrix& stvnl_dphi); + void cal_fvnl_dbeta( + const std::vector &dm2d, + const bool isforce, + const bool isstress, + matrix& fvnl_dbeta, + matrix& svnl_dbeta); + void cal_fvl_dphi( + const std::vector &dm2d, + const bool isforce, + const bool isstress, + matrix& fvl_dphi, + matrix& svl_dphi); void DerivT_PW (void); diff --git a/ABACUS.develop/source/src_lcao/force_lcao_k.cpp b/ABACUS.develop/source/src_lcao/force_lcao_k.cpp index 40e0b1f58e..8513afc394 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao_k.cpp +++ b/ABACUS.develop/source/src_lcao/force_lcao_k.cpp @@ -12,7 +12,18 @@ Force_LCAO_k::~Force_LCAO_k () #include "LCAO_nnr.h" // be called in Force_LCAO::start_force_calculation -void Force_LCAO_k::ftable_k (void) +void Force_LCAO_k::ftable_k ( + const bool isforce, + const bool isstress, + matrix& foverlap, + matrix& ftvnl_dphi, + matrix& fvnl_dbeta, + matrix& fvl_dphi, + matrix& soverlap, + matrix& stvnl_dphi, + matrix& svnl_dbeta, + matrix& svl_dphi + ) { TITLE("Force_LCAO_k", "ftable_k"); timer::tick("Force_LCAO_k","ftable_k",'F'); @@ -21,12 +32,12 @@ void Force_LCAO_k::ftable_k (void) // calculate the energy density matrix // and the force related to overlap matrix and energy density matrix. - this->cal_foverlap_k(); + this->cal_foverlap_k(isforce, isstress, foverlap, soverlap); // calculate the density matrix double** dm2d = new double*[NSPIN]; for(int is=0; isset_EDM_k(dm2d, with_energy); - - /* - ofs_running << " Density Matrix" << endl; - for(int i=0; ical_ftvnl_dphi_k(dm2d); + + this->cal_ftvnl_dphi_k(dm2d, isforce, isstress, ftvnl_dphi, stvnl_dphi); //Quxin add for DFT+U on 20201029 if(INPUT.dft_plus_u) @@ -57,10 +59,10 @@ void Force_LCAO_k::ftable_k (void) // --------------------------------------- // doing on the real space grid. // --------------------------------------- - this->cal_fvl_dphi_k(dm2d); + this->cal_fvl_dphi_k(dm2d, isforce, isstress, fvl_dphi, svl_dphi); + + this->cal_fvnl_dbeta_k(dm2d, isforce, isstress, fvnl_dbeta, svnl_dbeta); - this->cal_fvnl_dbeta_k(dm2d); - for(int is=0; isfoverlap[iat], 3); - Parallel_Reduce::reduce_double_pool( this->ftvnl_dphi[iat], 3); - Parallel_Reduce::reduce_double_pool( this->fvnl_dbeta[iat], 3); - Parallel_Reduce::reduce_double_pool( this->fvl_dphi[iat], 3); - } - for (int ipol=0; ipol<3; ipol++) + if(isforce) + { + Parallel_Reduce::reduce_double_pool( foverlap.c, foverlap.nr * foverlap.nc); + Parallel_Reduce::reduce_double_pool( ftvnl_dphi.c, ftvnl_dphi.nr * ftvnl_dphi.nc); + Parallel_Reduce::reduce_double_pool( fvnl_dbeta.c, fvnl_dbeta.nr * fvnl_dbeta.nc); + Parallel_Reduce::reduce_double_pool( fvl_dphi.c, fvl_dphi.nr * fvl_dphi.nc); + } + if(isstress) { - Parallel_Reduce::reduce_double_pool( this->soverlap[ipol], 3); - Parallel_Reduce::reduce_double_pool( this->stvnl_dphi[ipol], 3); - Parallel_Reduce::reduce_double_pool( this->svnl_dbeta[ipol], 3); - Parallel_Reduce::reduce_double_pool( this->svl_dphi[ipol], 3); + Parallel_Reduce::reduce_double_pool( soverlap.c, soverlap.nr * soverlap.nc); + Parallel_Reduce::reduce_double_pool( stvnl_dphi.c, stvnl_dphi.nr * stvnl_dphi.nc); + Parallel_Reduce::reduce_double_pool( svnl_dbeta.c, svnl_dbeta.nr * svnl_dbeta.nc); + Parallel_Reduce::reduce_double_pool( svl_dphi.c, svl_dphi.nr * svl_dphi.nc); } // test the force. @@ -389,7 +391,11 @@ complex Force_LCAO_k::set_EDM_k_element( } -void Force_LCAO_k::cal_foverlap_k(void) +void Force_LCAO_k::cal_foverlap_k( + const bool isforce, + const bool isstress, + matrix& foverlap, + matrix& soverlap) { TITLE("Force_LCAO_k","cal_foverlap_k"); timer::tick("Force_LCAO_k","cal_foverlap_k",'G'); @@ -419,15 +425,6 @@ void Force_LCAO_k::cal_foverlap_k(void) Record_adj RA; RA.for_2d(); - for(int iat=0; iatsoverlap[ipol], 3); - } - int irr = 0; int iat = 0; for(int T1=0; T1foverlap[iat][0] -= edm2d2 * LM.DSloc_Rx[irr]; - this->foverlap[iat][1] -= edm2d2 * LM.DSloc_Ry[irr]; - this->foverlap[iat][2] -= edm2d2 * LM.DSloc_Rz[irr]; - if(STRESS) + if(isforce) { - for(int ipol = 0;ipol<3;ipol++){ - this->soverlap[0][ipol] += edm2d[is][irr] * LM.DSloc_Rx[irr] * LM.DH_r[irr * 3 + ipol]; - this->soverlap[1][ipol] += edm2d[is][irr] * LM.DSloc_Ry[irr] * LM.DH_r[irr * 3 + ipol]; - this->soverlap[2][ipol] += edm2d[is][irr] * LM.DSloc_Rz[irr] * LM.DH_r[irr * 3 + ipol]; + foverlap(iat,0) -= edm2d2 * LM.DSloc_Rx[irr]; + foverlap(iat,1) -= edm2d2 * LM.DSloc_Ry[irr]; + foverlap(iat,2) -= edm2d2 * LM.DSloc_Rz[irr]; + } + if(isstress) + { + for(int ipol = 0;ipol<3;ipol++) + { + soverlap(0,ipol) += edm2d[is][irr] * LM.DSloc_Rx[irr] * LM.DH_r[irr * 3 + ipol]; + soverlap(1,ipol) += edm2d[is][irr] * LM.DSloc_Ry[irr] * LM.DH_r[irr * 3 + ipol]; + soverlap(2,ipol) += edm2d[is][irr] * LM.DSloc_Rz[irr] * LM.DH_r[irr * 3 + ipol]; } } } @@ -500,12 +501,12 @@ void Force_LCAO_k::cal_foverlap_k(void) setw(15) << foverlap[iat][2]*fac << endl; } */ - if(STRESS){ + if(isstress){ for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { - this->soverlap[i][j] *= ucell.lat0 / ucell.omega; + soverlap(i,j) *= ucell.lat0 / ucell.omega; } } } @@ -523,12 +524,17 @@ void Force_LCAO_k::cal_foverlap_k(void) } delete[] edm2d; -RA.delete_grid();//xiaohui add 2015-02-04 + RA.delete_grid();//xiaohui add 2015-02-04 timer::tick("Force_LCAO_k","cal_foverlap_k",'G'); return; } -void Force_LCAO_k::cal_ftvnl_dphi_k(double** dm2d) +void Force_LCAO_k::cal_ftvnl_dphi_k( + double** dm2d, + const bool isforce, + const bool isstress, + matrix& ftvnl_dphi, + matrix& stvnl_dphi) { TITLE("Force_LCAO_k","cal_ftvnl_dphi"); timer::tick("Force_LCAO_k","cal_ftvnl_dphi",'G'); @@ -539,15 +545,6 @@ void Force_LCAO_k::cal_ftvnl_dphi_k(double** dm2d) Record_adj RA; RA.for_2d(); - for(int iat=0; iatftvnl_dphi[iat], 3); - } - for(int ipol=0; ipol<3; ++ipol) - { - ZEROS( this->stvnl_dphi[ipol], 3); - } - int irr = 0; for(int T1=0; T1ftvnl_dphi[iat][0] += dm2d2 * LM.DHloc_fixedR_x[irr]; - this->ftvnl_dphi[iat][1] += dm2d2 * LM.DHloc_fixedR_y[irr]; - this->ftvnl_dphi[iat][2] += dm2d2 * LM.DHloc_fixedR_z[irr]; - if(STRESS){ - this->stvnl_dphi[0][0] -= dm2d[is][irr] * LM.stvnl11[irr]; - this->stvnl_dphi[0][1] -= dm2d[is][irr] * LM.stvnl12[irr]; - this->stvnl_dphi[0][2] -= dm2d[is][irr] * LM.stvnl13[irr]; - this->stvnl_dphi[1][1] -= dm2d[is][irr] * LM.stvnl22[irr]; - this->stvnl_dphi[1][2] -= dm2d[is][irr] * LM.stvnl23[irr]; - this->stvnl_dphi[2][2] -= dm2d[is][irr] * LM.stvnl33[irr]; - + if(isforce) + { + ftvnl_dphi(iat,0) += dm2d2 * LM.DHloc_fixedR_x[irr]; + ftvnl_dphi(iat,1) += dm2d2 * LM.DHloc_fixedR_y[irr]; + ftvnl_dphi(iat,2) += dm2d2 * LM.DHloc_fixedR_z[irr]; + } + if(isstress) + { + stvnl_dphi(0,0) -= dm2d[is][irr] * LM.stvnl11[irr]; + stvnl_dphi(0,1) -= dm2d[is][irr] * LM.stvnl12[irr]; + stvnl_dphi(0,2) -= dm2d[is][irr] * LM.stvnl13[irr]; + stvnl_dphi(1,1) -= dm2d[is][irr] * LM.stvnl22[irr]; + stvnl_dphi(1,2) -= dm2d[is][irr] * LM.stvnl23[irr]; + stvnl_dphi(2,2) -= dm2d[is][irr] * LM.stvnl33[irr]; } } ++irr; @@ -606,33 +606,18 @@ void Force_LCAO_k::cal_ftvnl_dphi_k(double** dm2d) // test(LM.DSloc_Rx); // test(dm2d[0],"dm2d"); - if(STRESS){ + if(isstress){ for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { - if(istvnl_dphi[j][i] = this->stvnl_dphi[i][j]; - } - } - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - this->stvnl_dphi[i][j] *= ucell.lat0 / ucell.omega; + if(i force - //-------------------------------- -// for(int iat=0; iat tau1, tau2, dtau; - Vector3 tau0, dtau1, dtau2; - - for(int ipol=0; ipol<3; ++ipol) - { - ZEROS( this->svnl_dbeta[ipol], 3); - } + Vector3 tau1; + Vector3 tau2; + Vector3 dtau; + Vector3 tau0; + Vector3 dtau1; + Vector3 dtau2; double rcut; double distance; - double rcut1, rcut2; - double distance1, distance2; + double rcut1; + double rcut2; + double distance1; + double distance2; for (int T1 = 0; T1 < ucell.ntype; ++T1) { @@ -812,7 +803,8 @@ void Force_LCAO_k::cal_fvnl_dbeta_k(double** dm2d) distance2 = dtau2.norm() * ucell.lat0; rcut2 = ORB.Phi[T2].getRcut() + ORB.Beta[T0].get_rcut_max(); - double r0[3],r1[3]; + double r0[3]; + double r1[3]; r1[0] = ( tau1.x - tau0.x) ; r1[1] = ( tau1.y - tau0.y) ; r1[2] = ( tau1.z - tau0.z) ; @@ -841,8 +833,9 @@ void Force_LCAO_k::cal_fvnl_dbeta_k(double** dm2d) ); double nlm1[3]={0,0,0}; - if(STRESS){ - UOT.snap_psibeta( + if(isstress) + { + UOT.snap_psibeta( nlm1, 1, tau1, T1, @@ -861,16 +854,18 @@ void Force_LCAO_k::cal_fvnl_dbeta_k(double** dm2d) for(int is=0; isfvnl_dbeta[iat0][0] -= dm2d2 * nlm[0]; - this->fvnl_dbeta[iat0][1] -= dm2d2 * nlm[1]; - this->fvnl_dbeta[iat0][2] -= dm2d2 * nlm[2]; - - if(STRESS) + for(int jpol=0;jpol<3;jpol++) { - for(int ipol=0;ipol<3;ipol++){ - this->svnl_dbeta[0][ipol] += dm2d[is][iir] * (nlm[0] * r1[ipol] + nlm1[0] * r0[ipol]); - this->svnl_dbeta[1][ipol] += dm2d[is][iir] * (nlm[1] * r1[ipol] + nlm1[1] * r0[ipol]); - this->svnl_dbeta[2][ipol] += dm2d[is][iir] * (nlm[2] * r1[ipol] + nlm1[2] * r0[ipol]); + if(isforce) + { + fvnl_dbeta(iat0, jpol) -= dm2d2 * nlm[jpol]; + } + if(isstress) + { + for(int ipol=0;ipol<3;ipol++) + { + svnl_dbeta(jpol, ipol) += dm2d[is][iir] * (nlm[jpol] * r1[ipol] + nlm1[jpol] * r0[ipol]); + } } } } @@ -888,12 +883,12 @@ void Force_LCAO_k::cal_fvnl_dbeta_k(double** dm2d) assert( iir == LNNR.nnr ); - if(STRESS){ + if(isstress){ for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { - this->svnl_dbeta[i][j] *= ucell.lat0 / ucell.omega; + svnl_dbeta(i,j) *= ucell.lat0 / ucell.omega; } } } @@ -904,24 +899,21 @@ void Force_LCAO_k::cal_fvnl_dbeta_k(double** dm2d) // calculate the force due to < phi | Vlocal | dphi > -void Force_LCAO_k::cal_fvl_dphi_k(double** dm2d) +void Force_LCAO_k::cal_fvl_dphi_k( + double** dm2d, + const bool isforce, + const bool isstress, + matrix& fvl_dphi, + matrix& svl_dphi) { TITLE("Force_LCAO_k","cal_fvl_dphi_k"); timer::tick("Force_LCAO_k","cal_fvl_dphi_k",'G'); + if(!isforce&&!isstress) return; assert(LM.DHloc_fixedR_x!=NULL); assert(LM.DHloc_fixedR_y!=NULL); assert(LM.DHloc_fixedR_z!=NULL); - for(int iat=0; iatsvl_dphi[ipol], 3); - } - int istep = 1; // if Vna potential is not used. @@ -945,127 +937,17 @@ void Force_LCAO_k::cal_fvl_dphi_k(double** dm2d) // Grid integration here. //-------------------------------- // fvl_dphi can not be set to zero here if Vna is used - if(STRESS) {UHM.GK.svl_k_RealSpace(fvl_dphi,svl_dphi,pot.vrs1);} - else {UHM.GK.fvl_k_RealSpace(fvl_dphi,pot.vrs1);} - -/* - cout << " fvl_dphi" << endl; - for(int iat=0; iat= 0 && nu >= 0 ) - { - const int index = mu * ParaO.ncol + nu; - //contribution from deriv of AO's in T+VNL term - this->fvl_dphi[iat][0] -= 2.0 * dm2d[0][index] * LM.DHloc_fixed_x[index] ; - this->fvl_dphi[iat][1] -= 2.0 * dm2d[0][index] * LM.DHloc_fixed_y[index] ; - this->fvl_dphi[iat][2] -= 2.0 * dm2d[0][index] * LM.DHloc_fixed_z[index] ; - - cout << setw(5) << iat << setw(5) << iat2 - << setw(5) << mu << setw(5) << nu - << setw(15) << LM.DHloc_fixed_z[index] << endl; - } - } - } - */ - /* - Record_adj RA; - RA.for_2d(); - - for(int iat=0; iatna; I1++) - { - const int iat = ucell.itia2iat(T1,I1); - const int start1 = ucell.itiaiw2iwt(T1,I1,0); - for (int cb = 0; cb < RA.na_each[iat]; cb++) - { - const int T2 = RA.info[iat][cb][3]; - const int I2 = RA.info[iat][cb][4]; - const int start2 = ucell.itiaiw2iwt(T2,I2,0); - Atom* atom2 = &ucell.atoms[T2]; - for(int jj=0; jjnw; jj++) - { - const int iw1_all = start1 + jj; - // HPSEPS's mu - const int mu = ParaO.trace_loc_row[iw1_all]; - if(mu<0)continue; - for(int kk=0; kknw; kk++) - { - const int iw2_all = start2 + kk; - // HPSEPS's nu - const int nu = ParaO.trace_loc_col[iw2_all]; - if(nu<0)continue; - //============================================================== - // here we use 'minus', but in GAMMA_ONLY_LOCAL we use 'plus', - // both are correct because the 'DSloc_Rx' is used in 'row' (-), - // however, the 'DSloc_x' is used in 'col' (+), - // mohan update 2011-06-16 - //============================================================== - for(int is=0; isfvl_dphi[iat][0] += 2.0 * dm2d[is][irr] * LM.DHloc_fixedR_x[irr]; -// this->fvl_dphi[iat][1] += 2.0 * dm2d[is][irr] * LM.DHloc_fixedR_y[irr]; -// this->fvl_dphi[iat][2] += 2.0 * dm2d[is][irr] * LM.DHloc_fixedR_z[irr]; - -// because dm2d has to be used in other places, so.... - this->fvl_dphi[iat][0] += 2.0 * LM.DHloc_fixedR_x[irr]; - this->fvl_dphi[iat][1] += 2.0 * LM.DHloc_fixedR_y[irr]; - this->fvl_dphi[iat][2] += 2.0 * LM.DHloc_fixedR_z[irr]; - } - ++irr; - }//end kk - }//end jj - }// end cb - } - } - assert(irr==LNNR.nnr); - */ - if(STRESS){ + if(isstress){ for(int ipol=0;ipol<3;ipol++){ for(int jpol=0;jpol<3;jpol++){ - if(ipol < jpol) svl_dphi[jpol][ipol] = svl_dphi[ipol][jpol]; - svl_dphi[ipol][jpol] /= ucell.omega; + if(ipol < jpol) svl_dphi(jpol, ipol) = svl_dphi(ipol, jpol); + svl_dphi(ipol, jpol) /= ucell.omega; } } } diff --git a/ABACUS.develop/source/src_lcao/force_lcao_k.h b/ABACUS.develop/source/src_lcao/force_lcao_k.h index f59ac892bb..523787dc11 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao_k.h +++ b/ABACUS.develop/source/src_lcao/force_lcao_k.h @@ -9,15 +9,26 @@ class Force_LCAO_k : public Force_LCAO_gamma { public : + friend class Force_Stress_LCAO; + Force_LCAO_k (); ~Force_LCAO_k (); - protected: + private: //orthonormal force + contribution from T and VNL - void ftable_k (void); - - private: + void ftable_k ( + const bool isforce, + const bool isstress, + matrix& foverlap, + matrix& ftvnl_dphi, + matrix& fvnl_dbeta, + matrix& fvl_dphi, + matrix& soverlap, + matrix& stvnl_dphi, + matrix& svnl_dbeta, + matrix& svl_dphi + ); // get the ds, dt, dvnl. void allocate_k(void); @@ -26,7 +37,7 @@ class Force_LCAO_k : public Force_LCAO_gamma void finish_k(void); - void set_EDM_k(double **dmR, const bool with_energy); + void set_EDM_k(double** dm2d, const bool with_energy); // mohan add 2012-01-09 @@ -38,22 +49,22 @@ class Force_LCAO_k : public Force_LCAO_gamma // calculate the force due to < dphi | beta > < beta | phi > - void cal_ftvnl_dphi_k(double **dmR); + void cal_ftvnl_dphi_k(double** dm2d, const bool isforce, const bool isstress, matrix& ftvnl_dphi, matrix& stvnl_dphi); // calculate the force due to < phi | Vlocal | dphi > - void cal_fvl_dphi_k(double **dmR); + void cal_fvl_dphi_k(double** dm2d, const bool isforce, const bool isstress, matrix& fvl_dphi, matrix& svl_dphi); // calculate the overlap force - void cal_foverlap_k(void); + void cal_foverlap_k(const bool isforce, const bool isstress, matrix& foverlap, matrix& soverlap); // calculate the force due to < phi | dbeta > < beta | phi > - void cal_fvnl_dbeta_k(double** dmR); + void cal_fvnl_dbeta_k(double** dm2d, const bool isforce, const bool isstress, matrix& fvnl_dbeta, matrix& svnl_dbeta); void test(double* mm, const string &name); - + }; #endif diff --git a/ABACUS.develop/source/src_lcao/force_stress_lcao.cpp b/ABACUS.develop/source/src_lcao/force_stress_lcao.cpp new file mode 100644 index 0000000000..ce85f2fbcb --- /dev/null +++ b/ABACUS.develop/source/src_lcao/force_stress_lcao.cpp @@ -0,0 +1,730 @@ +#include "./force_stress_lcao.h" +#include "../src_pw/global.h" +#include "../src_pw/potential_libxc.h" +#include "./dftu.h" //Quxin add for DFT+U on 20201029 +// new +#include "../src_pw/H_XC_pw.h" + +double Force_Stress_LCAO::force_invalid_threshold_ev = 0.00; +double Force_Stress_LCAO::output_acc = 1.0e-8; + +Force_Stress_LCAO::Force_Stress_LCAO () +{ +} + +Force_Stress_LCAO::~Force_Stress_LCAO () +{ +} + +void Force_Stress_LCAO::allocate(void) +{ + TITLE("Force_Stress_LCAO","init"); + + // reduce memory occupy by vlocal + delete[] ParaO.sender_local_index; + delete[] ParaO.sender_size_process; + delete[] ParaO.sender_displacement_process; + delete[] ParaO.receiver_global_index; + delete[] ParaO.receiver_size_process; + delete[] ParaO.receiver_displacement_process; + + ParaO.sender_local_index = new int[1]; + ParaO.sender_size_process = new int[1]; + ParaO.sender_displacement_process = new int[1]; + ParaO.receiver_global_index = new int[1]; + ParaO.receiver_size_process = new int[1]; + ParaO.receiver_displacement_process = new int[1]; + + return; +} + +#include "../src_pw/efield.h" +// be called in : Local_Orbital_Ions::force_stress +void Force_Stress_LCAO::getForceStress( + const bool isforce, + const bool isstress, + const bool istestf, + const bool istests, + matrix& fcs, + matrix& scs) +{ + TITLE("Force_Stress_LCAO","getForceStress"); + timer::tick("Force_Stress_LCAO","getForceStress",'E'); + + if(!isforce&&!isstress) return; + + const int nat = ucell.nat; + + //total force : matrix fcs; + + // part of total force + matrix foverlap; + matrix ftvnl_dphi; + matrix fvnl_dbeta; + matrix fvl_dphi; + matrix fvl_dvl; + matrix fewalds; + matrix fcc; + matrix fscc; + fvl_dphi.create (nat, 3);//must do it now, update it later, noted by zhengdy + if(isforce) + { + fcs.create (nat, 3); + foverlap.create (nat, 3); + ftvnl_dphi.create (nat, 3); + fvnl_dbeta.create (nat, 3); + fvl_dvl.create (nat, 3); + fewalds.create (nat, 3); + fcc.create (nat, 3); + fscc.create (nat, 3); + //calculate basic terms in Force, same method with PW base + this->calForcePwPart(fvl_dvl, fewalds, fcc, fscc); + } + + //total stress : matrix scs + matrix sigmacc; + matrix sigmadvl; + matrix sigmaewa; + matrix sigmaxc; + matrix sigmahar; + matrix soverlap; + matrix stvnl_dphi; + matrix svnl_dbeta; + matrix svl_dphi; + if(isstress) + { + scs.create(3,3); + sigmacc.create(3,3); + sigmadvl.create(3,3); + sigmaewa.create(3,3); + sigmaxc.create(3,3); + sigmahar.create(3,3); + + soverlap.create(3,3); + stvnl_dphi.create(3,3); + svnl_dbeta.create(3,3); + svl_dphi.create(3,3); + //calculate basic terms in Stress, similar method with PW base + this->calStressPwPart( + sigmadvl, + sigmahar, + sigmaewa, + sigmacc, + sigmaxc); + } + + //-------------------------------------------------------- + // implement four terms which needs integration + //-------------------------------------------------------- + this->calForceStressIntegralPart( + GAMMA_ONLY_LOCAL, + isforce, + isstress, + foverlap, + ftvnl_dphi, + fvnl_dbeta, + fvl_dphi, + soverlap, + stvnl_dphi, + svnl_dbeta, + svl_dphi); + + //implement vdw force or stress here + // Peize Lin add 2014-04-04, update 2019-04-26 + matrix force_vdw; + matrix stress_vdw; + if(vdwd2.vdwD2) + { + if(isforce) force_vdw.create(nat,3); + if(isstress) stress_vdw.create(3,3); + vdwd2.force(isforce, isstress, force_vdw, stress_vdw); + } + // jiyy add 2019-05-18 + else if(vdwd3.vdwD3) + { + if(isforce) force_vdw.create(nat,3); + if(isstress) stress_vdw.create(3,3); + vdwd3.force(isforce, isstress, force_vdw, stress_vdw); + } + //implement force from E-field + matrix fefield; + if(EFIELD&&isforce) + { + fefield.create(nat, 3); + Efield::compute_force(fefield); + } + //Force contribution from DFT+U + matrix force_dftu; + matrix stress_dftu; + if(INPUT.dft_plus_u) + { + if(isforce) + { + force_dftu.create(nat, 3); + } + if(isstress) + { + stress_dftu.create(3, 3); + } + for(int i=0; i<3; i++) + { + if(isstress) + { + for(int j=0; j<3; j++) + { + stress_dftu(j,i) = dftu.stress_dftu.at(j).at(i); + } + } + if(isforce) + { + for (int iat = 0; iat < nat; iat++) + { + force_dftu(iat, i) = dftu.force_dftu.at(iat).at(i); + } + } + } + } + //-------------------------------- + //begin calculate and output force + //-------------------------------- + if(isforce) + { + //--------------------------------- + //sum all parts of force! + //--------------------------------- + for(int i=0; i<3; i++) + { + double sum = 0.0; + + for (int iat = 0; iat < nat; iat++) + { + fcs(iat, i) += foverlap(iat, i) + + ftvnl_dphi(iat, i) + + fvnl_dbeta(iat, i) + + fvl_dphi(iat, i) + + fvl_dvl(iat, i) // derivative of local potential force (pw) + + fewalds(iat, i) // ewald force (pw) + + fcc(iat, i) //nonlinear core correction force (pw) + + fscc(iat, i);//self consistent corretion force (pw) + + // Force contribution from DFT+U, Quxin add on 20201029 + if(INPUT.dft_plus_u) + { + fcs(iat, i) += force_dftu(iat, i); + } + //VDW force of vdwd2 or vdwd3 + if(vdwd2.vdwD2||vdwd3.vdwD3) + { + fcs(iat,i) += force_vdw(iat,i); + } + //E-field force + if(EFIELD) + { + fcs(iat, i) += fefield(iat, i); + } + //DFT plus U force + if(INPUT.dft_plus_u) + { + fcs(iat, i) += force_dftu(iat, i); + } + //sum total force for correction + sum += fcs(iat, i); + } + + for(int iat=0; iatforceSymmetry(fcs); + } + + // print Rydberg force or not + bool ry = false; + if(istestf) + { + // test + //matrix fvlocal; + //fvlocal.create(nat,3); + matrix ftvnl; + ftvnl.create(nat, 3); + for (int iat = 0; iat < nat; iat++) + { + for(int i=0; i<3; i++) + { + //fvlocal(iat,i) = fvl_dphi(iat,i) + fvl_dvl(iat,i); + ftvnl(iat,i) = ftvnl_dphi(iat,i) + fvnl_dbeta(iat,i); + } + } + + ofs_running << "\n PARTS OF FORCE: " << endl; + ofs_running << setiosflags(ios::showpos); + ofs_running << setiosflags(ios::fixed) << setprecision(8) << endl; + //----------------------------- + //regular force terms test. + //----------------------------- + this->print_force("OVERLAP FORCE",foverlap,1,ry); + // this->print_force("TVNL_DPHI force",ftvnl_dphi,TEST_FORCE); + // this->print_force("VNL_DBETA force",fvnl_dbeta,TEST_FORCE); + this->print_force("T_VNL FORCE",ftvnl,1,ry); + this->print_force("VL_dPHI FORCE",fvl_dphi,1,ry); + this->print_force("VL_dVL FORCE",fvl_dvl,1,ry); + // this->print_force("VLOCAL FORCE",fvlocal,TEST_FORCE); + this->print_force("EWALD FORCE",fewalds,1,ry); + this->print_force("NLCC FORCE",fcc,1,ry); + this->print_force("SCC FORCE",fscc,1,ry); + //------------------------------- + //put extra force here for test! + //------------------------------- + if(EFIELD) + { + this->print_force("EFIELD FORCE",fefield,1,ry); + } + if(vdwd2.vdwD2||vdwd3.vdwD3) + { + this->print_force("VDW FORCE",force_vdw,1,ry); + } + } + + ofs_running << setiosflags(ios::left); + + this->printforce_total(ry, istestf, fcs); + if(istestf) + { + ofs_running << "\n FORCE INVALID TABLE." << endl; + ofs_running << " " << setw(8) << "atom" << setw(5) << "x" << setw(5) << "y" << setw(5) << "z" << endl; + for(int iat=0; iatoutput_acc) ofs_running << setw(15) << f(iat,0)*fac; + else ofs_running << setw(15) << "0"; + if( abs(f(iat,1)) >output_acc) ofs_running << setw(15) << f(iat,1)*fac; + else ofs_running << setw(15) << "0"; + if( abs(f(iat,2)) >output_acc) ofs_running << setw(15) << f(iat,2)*fac; + else ofs_running << setw(15) << "0"; + ofs_running << endl; + + if(screen) + { + cout << " " << setw(8) << ss.str(); + if( abs(f(iat,0)) >output_acc) cout << setw(15) << f(iat,0)*fac; + else cout << setw(15) << "0"; + if( abs(f(iat,1)) >output_acc) cout << setw(15) << f(iat,1)*fac; + else cout << setw(15) << "0"; + if( abs(f(iat,2)) >output_acc) cout << setw(15) << f(iat,2)*fac; + else cout << setw(15) << "0"; + cout << endl; + } + + iat++; + } + } + + + cout << resetiosflags(ios::showpos); + + return; +} + +//print total force +void Force_Stress_LCAO::printforce_total (const bool ry, const bool istestf, matrix& fcs) +{ + TITLE("Force_Stress_LCAO","printforce_total"); + double unit_transform = 1; + + if(!ry) + { + unit_transform = Ry_to_eV / 0.529177; + } +// cout.setf(ios::fixed); + + int iat=0; + + //ofs_running << setiosflags(ios::right); + ofs_running << setprecision(6) << setiosflags(ios::showpos) << setiosflags(ios::fixed) << endl; + NEW_PART("TOTAL-FORCE (eV/Angstrom)"); + + // print out forces + if(INPUT.force_set == 1) + { + ofstream ofs("FORCE.dat"); + if(!ofs) + { + cout << "open FORCE.dat error !" < * DM(R) to // calculate the force. -void Gint_k::folding_force(double** fvl_dphi, +void Gint_k::folding_force(matrix& fvl_dphi, double* pvdpx, double* pvdpy, double* pvdpz) { TITLE("Gint_k","folding_force"); @@ -275,9 +275,9 @@ void Gint_k::folding_force(double** fvl_dphi, } const int iat = ucell.iwt2iat[i]; const int index = 3*j; - fvl_dphi[iat][0] += 2.0*tmp[index]; - fvl_dphi[iat][1] += 2.0*tmp[index+1]; - fvl_dphi[iat][2] += 2.0*tmp[index+2]; + fvl_dphi(iat,0) += 2.0*tmp[index]; + fvl_dphi(iat,1) += 2.0*tmp[index+1]; + fvl_dphi(iat,2) += 2.0*tmp[index+2]; } } delete[] tmp; @@ -304,7 +304,7 @@ void Gint_k::folding_force(double** fvl_dphi, // fold the * DM(R) to // calculate the stress. -void Gint_k::folding_stress(double** fvl_dphi, double svl_dphi[][3], +void Gint_k::folding_stress(matrix& fvl_dphi, matrix& svl_dphi, double* pvdpx, double* pvdpy, double* pvdpz, double* pvdp11, double* pvdp22, double* pvdp33,double* pvdp12, double* pvdp13, double* pvdp23) { @@ -504,16 +504,16 @@ void Gint_k::folding_stress(double** fvl_dphi, double svl_dphi[][3], const int iat = ucell.iwt2iat[i]; const int index = 3*j; const int index1 = 6*j; - fvl_dphi[iat][0] += 2.0*tmp[index]; - fvl_dphi[iat][1] += 2.0*tmp[index+1]; - fvl_dphi[iat][2] += 2.0*tmp[index+2]; - - svl_dphi[0][0] -= 2.0*tmp1[index1]; - svl_dphi[1][1] -= 2.0*tmp1[index1+1]; - svl_dphi[2][2] -= 2.0*tmp1[index1+2]; - svl_dphi[0][1] -= 2.0*tmp1[index1+3]; - svl_dphi[0][2] -= 2.0*tmp1[index1+4]; - svl_dphi[1][2] -= 2.0*tmp1[index1+5]; + fvl_dphi(iat,0) += 2.0*tmp[index]; + fvl_dphi(iat,1) += 2.0*tmp[index+1]; + fvl_dphi(iat,2) += 2.0*tmp[index+2]; + + svl_dphi(0,0) -= 2.0*tmp1[index1]; + svl_dphi(1,1) -= 2.0*tmp1[index1+1]; + svl_dphi(2,2) -= 2.0*tmp1[index1+2]; + svl_dphi(0,1) -= 2.0*tmp1[index1+3]; + svl_dphi(0,2) -= 2.0*tmp1[index1+4]; + svl_dphi(1,2) -= 2.0*tmp1[index1+5]; } } delete[] tmp; diff --git a/ABACUS.develop/source/src_lcao/gint_k.h b/ABACUS.develop/source/src_lcao/gint_k.h index a8d1c22906..92e784b816 100644 --- a/ABACUS.develop/source/src_lcao/gint_k.h +++ b/ABACUS.develop/source/src_lcao/gint_k.h @@ -46,12 +46,12 @@ class Gint_k : public Gint_k_init // folding the < dphi_0 | V | phi_R> matrix to // < dphi_0i | V | phi_0j> - void folding_force(double** fvl_dphi, + void folding_force(matrix& fvl_dphi, double* pvdpx, double* pvdpy, double* pvdpz);//mohan add 2012-1-6 // folding the < dphi_0 | V * R_beta | phi_R> matrix // < dphi_0i | V | phi_0j> - void folding_stress(double** fvl_dphi, double svl_dphi[][3], + void folding_stress(matrix& fvl_dphi, matrix& svl_dphi, double* pvdpx, double* pvdpy, double* pvdpz, double* pvdp11, double* pvdp22, double* pvdp33, double* pvdp12, double* pvdp13, double* pvdp23);//zhengdy add 2016-10-18 @@ -67,8 +67,8 @@ class Gint_k : public Gint_k_init // drive routine //>>>>>>>>>>>>>>>>>>>> // calculate the force (many k-points). - void fvl_k_RealSpace(double** fvl_dphi, const double* vl);//mohan add 2011-06-19 - void svl_k_RealSpace(double** fvl_dphi, double svl_dphi[][3], const double* vl);//zhengdy add 2016-10-18 + void fvl_k_RealSpace(matrix& fvl_dphi, const double* vl);//mohan add 2011-06-19 + void svl_k_RealSpace(matrix& fvl_dphi, matrix& svl_dphi, const double* vl);//zhengdy add 2016-10-18 // reset the spin. diff --git a/ABACUS.develop/source/src_lcao/gint_k_fvl.cpp b/ABACUS.develop/source/src_lcao/gint_k_fvl.cpp index 23a314cb64..110f8da139 100644 --- a/ABACUS.develop/source/src_lcao/gint_k_fvl.cpp +++ b/ABACUS.develop/source/src_lcao/gint_k_fvl.cpp @@ -4,7 +4,7 @@ #include "global_fp.h" // mohan add 2021-01-30 -void Gint_k::fvl_k_RealSpace(double** fvl_dphi, const double *vl) +void Gint_k::fvl_k_RealSpace(matrix& fvl_dphi, const double *vl) { TITLE("Gint_k","cal_force"); timer::tick("Gint_k","cal_force"); @@ -199,7 +199,7 @@ void Gint_k::fvl_k_RealSpace(double** fvl_dphi, const double *vl) return; } -void Gint_k::svl_k_RealSpace(double** fvl_dphi, double svl_dphi[][3], const double *vl) +void Gint_k::svl_k_RealSpace(matrix& fvl_dphi, matrix& svl_dphi, const double *vl) { TITLE("Gint_k","cal_stress"); timer::tick("Gint_k","cal_stress"); diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index f7041bc6c4..45d1b1d506 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -3,8 +3,7 @@ #include "src_parallel/parallel_orbitals.h" #include "src_pdiag/pdiag_double.h" #include "LCAO_nnr.h" -#include "force_lcao.h" -#include "stress_lcao.h" +#include "force_stress_lcao.h" #include "src_global/global_function.h" #include "src_io/hs_matrix.h" #include "src_io/cal_r_overlap_R.h" @@ -324,15 +323,16 @@ bool Local_Orbital_Ions::force_stress(const int &istep, int &force_step, int &st return 1; } timer::tick("Local_Orbital_Ions","force_stress",'D'); - + matrix fcs; + matrix scs; + Force_Stress_LCAO FSL; + FSL.allocate (); + FSL.getForceStress(FORCE, STRESS, TEST_FORCE, TEST_STRESS, fcs, scs); //-------------------------------------------------- // only forces are needed, no stresses are needed //-------------------------------------------------- if(FORCE && !STRESS) { - Force_LCAO FL; - FL.allocate (); - FL.start_force(); #ifdef __MPI //2015-10-01, xiaohui atom_arrange::delete_vector( SEARCH_RADIUS ); @@ -340,7 +340,7 @@ bool Local_Orbital_Ions::force_stress(const int &istep, int &force_step, int &st if(CALCULATION=="relax") { - IMM.cal_movement(istep, istep, FL.fcs, en.etot); + IMM.cal_movement(istep, istep, fcs, en.etot); if(IMM.get_converged() || (istep==NSTEP)) { @@ -396,17 +396,13 @@ xiaohui modify 2014-08-09*/ if(!FORCE&&STRESS) { - Force_LCAO FL; // init the class. - matrix stress_lcao;//this is the stress matrix same as src_pw/ion.cpp - stress_lcao.create(3,3); - FL.cal_stress(stress_lcao); #ifdef __MPI atom_arrange::delete_vector( SEARCH_RADIUS ); #endif if(CALCULATION=="cell-relax") { - LCM.cal_lattice_change(stress_step, stress_lcao, en.etot); + LCM.cal_lattice_change(stress_step, scs, en.etot); converged_stress = LCM.get_converged(); if(converged_stress) { @@ -429,9 +425,6 @@ xiaohui modify 2014-08-09*/ if(FORCE&&STRESS) { - Force_LCAO FL; // init the class. - FL.allocate (); - FL.start_force(); //#ifdef __MPI atom_arrange::delete_vector( SEARCH_RADIUS ); @@ -440,19 +433,16 @@ xiaohui modify 2014-08-09*/ //if(CALCULATION=="relax") IMM.cal_movement(istep, FL.fcs, en.etot); if(CALCULATION=="relax" || CALCULATION=="cell-relax") { - IMM.cal_movement(istep, force_step, FL.fcs, en.etot); + IMM.cal_movement(istep, force_step, fcs, en.etot); if(IMM.get_converged()) { force_step = 1; - matrix stress_lcao;//this is the stress matrix same as src_pw/ion.cpp - stress_lcao.create(3,3); - FL.cal_stress(stress_lcao); if(CALCULATION=="cell-relax") { - LCM.cal_lattice_change(stress_step, stress_lcao, en.etot); + LCM.cal_lattice_change(stress_step, scs, en.etot); converged_stress = LCM.get_converged(); if(converged_stress) { @@ -499,10 +489,6 @@ xiaohui modify 2014-08-09*/ } else { - matrix stress_lcao;//this is the stress matrix same as src_pw/ion.cpp - stress_lcao.create(3,3); - FL.cal_stress(stress_lcao); - return 1; } } diff --git a/ABACUS.develop/source/src_lcao/stress_lcao.cpp b/ABACUS.develop/source/src_lcao/stress_lcao.cpp deleted file mode 100644 index 64077a4e25..0000000000 --- a/ABACUS.develop/source/src_lcao/stress_lcao.cpp +++ /dev/null @@ -1,204 +0,0 @@ -#include"./stress_lcao.h" -#include "../src_pw/H_XC_pw.h" - -void Stress_LCAO::start_stress -( -const double overlap[][3], -const double tvnl_dphi[][3], -const double vnl_dbeta[][3], -const double vl_dphi[][3], -const matrix& stress_vdw, -matrix& scs -) -{ - TITLE("Stress_LCAO","start_stress"); - timer::tick("Stress_LCAO","start_stress",'E'); - - matrix soverlap; - soverlap.create(3,3); - matrix stvnl_dphi; - stvnl_dphi.create(3,3); - matrix svnl_dbeta; - svnl_dbeta.create(3,3); - matrix svl_dphi; - svl_dphi.create(3,3); - matrix sigmacc; - sigmacc.create(3,3); - matrix sigmadvl; - sigmadvl.create(3,3); - matrix sigmaewa; - sigmaewa.create(3,3); - matrix sigmaxc; - sigmaxc.create(3,3); - matrix sigmahar; - sigmahar.create(3,3); - - for(int i=0;i<3;i++) - { - for(int j=0;j<3;j++) - { - scs(i,j) = 0.0; - soverlap(i,j) = overlap[i][j]; - stvnl_dphi(i,j) = tvnl_dphi[i][j]; - svnl_dbeta(i,j) = vnl_dbeta[i][j]; - svl_dphi(i,j) = vl_dphi[i][j]; - sigmacc(i,j) = 0.0; - sigmadvl(i,j) = 0.0; - sigmaewa(i,j) = 0.0; - sigmaxc(i,j) = 0.0; - sigmahar(i,j) = 0.0; - } - } - //-------------------------------------------------------- - // local pseudopotential stress: - // use charge density; plane wave; local pseudopotential; - //-------------------------------------------------------- - this->stress_loc (sigmadvl, 0); - - //-------------------------------------------------------- - //hartree term - //-------------------------------------------------------- - this->stress_har (sigmahar, 0); - - //-------------------------------------------------------- - // ewald stress: use plane wave only. - //-------------------------------------------------------- - this->stress_ewa (sigmaewa, 0); //remain problem - - - //-------------------------------------------------------- - // stress due to core correlation. - //-------------------------------------------------------- - this->stress_cc(sigmacc, 0); - - //-------------------------------------------------------- - // stress due to self-consistent charge. - //-------------------------------------------------------- - for(int i=0;i<3;i++) - { - sigmaxc(i,i) = -(H_XC_pw::etxc) / ucell.omega; - } - //Exchange-correlation for PBE - stress_gga(sigmaxc); - -/* if(vdwd2.vdwD2) //Peize Lin add 2014-04-04, update 2019-04-26 - { - vdwd2.stress(); - } -*/ -/* if(vdwd3.vdwD3) //jiyy add 2019-05-18 - { - vdwd3.stress(); - } -*/ -/* matrix sefield; - if(EFIELD) - { - sefield.create(3, 3); - Efield::compute_stress(sefield); - }*/ - - for(int i=0; i<3; i++) - { - for (int j=0;j<3;j++) - { - scs(i,j) += soverlap(i,j) - + stvnl_dphi(i,j) - + svnl_dbeta(i,j) - + svl_dphi(i,j) - + sigmadvl(i,j) // derivative of local potential stress (pw) - + sigmaewa(i,j) // ewald stress (pw) - + sigmacc(i,j) //nonlinear core correction stress (pw) - + sigmaxc(i,j)//exchange corretion stress - + sigmahar(i,j);// hartree stress - - if(vdwd2.vdwD2) // Peize Lin update 2019-04-26 - { - scs(i,j) += stress_vdw(i , j); - } - if(vdwd3.vdwD3) // jiyy add 2019-05-18 - { - scs(i,j) += stress_vdw(i , j); - } - /* if(EFIELD) - { - scs(iat, i) = scs(iat, i) + sefield(iat, i); - } - */ - - } - - // if(OUT_LEVEL != "m") ofs_running << " correction stress for each atom along direction " - // << i+1 << " is " << sum/ucell.nat << endl; - } - - // test - matrix svlocal; - svlocal.create(3,3); - for (int i = 0; i<3; i++) - { - for(int j=0; j<3; j++) - { - svlocal(i,j) = 0.0; - svlocal(i,j) = svl_dphi(i,j) + sigmadvl(i,j); - } - } - - // test - matrix stvnl; - stvnl.create(3,3); - for (int i = 0; i < 3; i++) - { - for(int j=0; j<3; j++) - { - stvnl(i,j) = 0.0; - stvnl(i,j) = stvnl_dphi(i,j) + svnl_dbeta(i,j); - } - } - - if(Symmetry::symm_flag) - { - symm.stress_symmetry(scs); - }//end symmetry - - // print Rydberg stress or not - bool ry = false; - -// int TEST_STRESS = 1; - if(TEST_STRESS) - { - ofs_running << "\n PARTS OF STRESS: " << endl; - ofs_running << setiosflags(ios::showpos); - ofs_running << setiosflags(ios::fixed) << setprecision(8) << endl; - this->print_stress("OVERLAP STRESS",soverlap,TEST_STRESS,ry); - //test - this->print_stress("T STRESS",stvnl_dphi,TEST_STRESS,ry); - this->print_stress("VNL STRESS",svnl_dbeta,TEST_STRESS,ry); - - this->print_stress("T_VNL STRESS",stvnl,TEST_STRESS,ry); - - this->print_stress("VL_dPHI STRESS",svl_dphi,TEST_STRESS,ry); - this->print_stress("VL_dVL STRESS",sigmadvl,TEST_STRESS,ry); - this->print_stress("HAR STRESS",sigmahar,TEST_STRESS,ry); - - this->print_stress("EWALD STRESS",sigmaewa,TEST_STRESS,ry); - this->print_stress("cc STRESS",sigmacc,TEST_STRESS,ry); - // this->print_stress("NLCC STRESS",sigmacc,TEST_STRESS,ry); - this->print_stress("XC STRESS",sigmaxc,TEST_STRESS,ry); - this->print_stress("TOTAL STRESS",scs,TEST_STRESS,ry); - } - - -/* if(EFIELD) - { - STRESS::print("EFIELD STRESS", sefield); - } -*/ - ofs_running << setiosflags(ios::left); - - this->printstress_total(scs, ry); - - - timer::tick("Stress_LCAO","start_stress",'E'); - return; -} diff --git a/ABACUS.develop/source/src_lcao/stress_lcao.h b/ABACUS.develop/source/src_lcao/stress_lcao.h deleted file mode 100644 index f002be6216..0000000000 --- a/ABACUS.develop/source/src_lcao/stress_lcao.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef STRESS_LCAO_H -#define STRESS_LCAO_H -#include "./../src_pw/stress_func.h" - -class Stress_LCAO:public Stress_Func -{ - public : - - Stress_LCAO (){}; - ~Stress_LCAO (){}; - - //calculate the stress in LCAO basis - void start_stress( - const double overlap[][3], - const double tvnl_dphi[][3], - const double vnl_dbeta[][3], - const double vl_dphi[][3], - const matrix& stress_vdw, - matrix& scs); -}; -#endif diff --git a/ABACUS.develop/source/src_pw/H_XC_pw.h b/ABACUS.develop/source/src_pw/H_XC_pw.h index 639ea5d44e..06c6992ed8 100644 --- a/ABACUS.develop/source/src_pw/H_XC_pw.h +++ b/ABACUS.develop/source/src_pw/H_XC_pw.h @@ -9,9 +9,8 @@ class H_XC_pw friend class Stress_Func; friend class Stress_PW; - friend class Stress_LCAO; friend class Forces; - friend class Force_LCAO; + friend class Force_Stress_LCAO; friend class potential; friend class energy; friend class eximport; diff --git a/ABACUS.develop/source/src_pw/forces.cpp b/ABACUS.develop/source/src_pw/forces.cpp index 1fd10708ef..18a3a529b2 100644 --- a/ABACUS.develop/source/src_pw/forces.cpp +++ b/ABACUS.develop/source/src_pw/forces.cpp @@ -8,32 +8,48 @@ double Forces::output_acc = 1.0e-8; // (Ryd/angstrom). -Forces::Forces(const int natom): nat(natom) +Forces::Forces() { } Forces::~Forces() {} #include "efield.h" -void Forces::init() +void Forces::init(matrix& force) { - TITLE("Forces", "init"); - this->force.create(nat, 3); + TITLE("Forces", "init"); + this->nat = ucell.nat; + force.create(nat, 3); - this->cal_force_loc(); - this->cal_force_ew(); - this->cal_force_nl(); - this->cal_force_cc(); - this->cal_force_scc(); - - matrix stress_vdw_pw(3,3);//.create(3,3); + matrix forcelc(nat, 3); + matrix forceion(nat, 3); + matrix forcecc(nat, 3); + matrix forcenl(nat, 3); + matrix forcescc(nat, 3); + this->cal_force_loc(forcelc); + this->cal_force_ew(forceion); + this->cal_force_nl(forcenl); + this->cal_force_cc(forcecc); + this->cal_force_scc(forcescc); + + matrix stress_vdw_pw;//.create(3,3); + matrix force_vdw; + force_vdw.create(nat, 3); if(vdwd2.vdwD2) //Peize Lin add 2014-04-03, update 2019-04-26 { - vdwd2.force(stress_vdw_pw, STRESS); + vdwd2.force(1, 0, force_vdw, stress_vdw_pw); + if(TEST_FORCE) + { + Forces::print("VDW FORCE (Ry/Bohr)", force_vdw); + } } else if(vdwd3.vdwD3) //jiyy add 2019-05-18 { - vdwd3.force(stress_vdw_pw, STRESS); + vdwd3.force(1, 0, force_vdw, stress_vdw_pw); + if(TEST_FORCE) + { + Forces::print("VDW FORCE (Ry/Bohr)", force_vdw); + } } //impose total force = 0 int iat = 0; @@ -61,25 +77,10 @@ void Forces::init() + forcecc(iat, ipol) + forcescc(iat, ipol); - if(vdwd2.vdwD2) //Peize Lin add 2014-04-03, update 2019-04-26 + if(vdwd2.vdwD2 || vdwd3.vdwD3) //linpz and jiyy added vdw force, modified by zhengdy { - switch(ipol) - { - case 0: force(iat,ipol) += vdwd2.force_result[iat].x; break; - case 1: force(iat,ipol) += vdwd2.force_result[iat].y; break; - case 2: force(iat,ipol) += vdwd2.force_result[iat].z; break; - } - - } - if(vdwd3.vdwD3) //jiyy add 2019-05-18 - { - switch(ipol) - { - case 0: force(iat,ipol) += vdwd3.force_result[iat][0]; break; - case 1: force(iat,ipol) += vdwd3.force_result[iat][1]; break; - case 2: force(iat,ipol) += vdwd3.force_result[iat][2]; break; - } - } + force(iat, ipol) += force_vdw(iat, ipol); + } if(EFIELD) { @@ -167,7 +168,7 @@ void Forces::init() if(!ofs) { cout << "open FORCE.dat error !" <forcelc.create(nat, 3); complex *aux = new complex[pw.nrxx]; ZEROS(aux, pw.nrxx); @@ -348,7 +348,6 @@ void Forces::cal_force_loc(void) // ofs_running << "\n ggs = " << pw.ggs[0]; // ofs_running << "\n gstart_here = " << gstart_here; - int iat = 0; for (int it = 0;it < ucell.ntype;it++) { @@ -366,25 +365,22 @@ void Forces::cal_force_loc(void) } for (int ipol = 0;ipol < 3;ipol++) { - this->forcelc(iat, ipol) *= (ucell.tpiba * ucell.omega); + forcelc(iat, ipol) *= (ucell.tpiba * ucell.omega); } ++iat; } } - //this->print(ofs_running, "local forces", forcelc); Parallel_Reduce::reduce_double_pool(forcelc.c, forcelc.nr * forcelc.nc); - delete[] aux; timer::tick("Forces","cal_force_loc"); return; } #include "H_Ewald_pw.h" -void Forces::cal_force_ew(void) +void Forces::cal_force_ew(matrix& forceion) { timer::tick("Forces","cal_force_ew"); - this->forceion.create(nat, 3); double fact = 2.0; complex *aux = new complex [pw.ngmc]; @@ -451,7 +447,7 @@ void Forces::cal_force_ew(void) } for (int ipol = 0;ipol < 3;ipol++) { - this->forceion(iat, ipol) *= ucell.atoms[it].zv * e2 * ucell.tpiba * TWO_PI / ucell.omega * fact; + forceion(iat, ipol) *= ucell.atoms[it].zv * e2 * ucell.tpiba * TWO_PI / ucell.omega * fact; } // cout << " atom" << iat << endl; @@ -502,9 +498,9 @@ void Forces::cal_force_ew(void) * (erfc(sqrt(alpha) * rr) / rr + sqrt(8.0 * alpha / TWO_PI) * exp(-1.0 * alpha * rr * rr)) * ucell.lat0; - this->forceion(iat1, 0) -= factor * r[n].x; - this->forceion(iat1, 1) -= factor * r[n].y; - this->forceion(iat1, 2) -= factor * r[n].z; + forceion(iat1, 0) -= factor * r[n].x; + forceion(iat1, 1) -= factor * r[n].y; + forceion(iat1, 2) -= factor * r[n].z; // cout << " r.z=" << r[n].z << " r2=" << r2[n] << endl; // cout << " " << iat1 << " " << iat2 << " n=" << n @@ -535,10 +531,8 @@ void Forces::cal_force_ew(void) return; } -void Forces::cal_force_cc(void) +void Forces::cal_force_cc(matrix& forcecc) { - this->forcecc.create(nat, 3); - // recalculate the exchange-correlation potential. matrix vxc(NSPIN, pw.nrxx); H_XC_pw::v_xc(pw.nrxx, pw.ncxyz, ucell.omega, CHR.rho, CHR.rho_core, vxc); @@ -623,12 +617,11 @@ void Forces::cal_force_cc(void) return; } -void Forces::cal_force_nl(void) +void Forces::cal_force_nl(matrix& forcenl) { TITLE("Forces","cal_force_nl"); timer::tick("Forces","cal_force_nl"); - this->forcenl.create(nat, 3); const int nkb = ppcell.nkb; if(nkb == 0) return; // mohan add 2010-07-25 @@ -774,10 +767,8 @@ void Forces::cal_force_nl(void) return; } -void Forces::cal_force_scc(void) +void Forces::cal_force_scc(matrix& forcescc) { - forcescc.create(nat, 3); - complex* psic = new complex [pw.nrxx]; ZEROS(psic, pw.nrxx); diff --git a/ABACUS.develop/source/src_pw/forces.h b/ABACUS.develop/source/src_pw/forces.h index bb87f04235..b6ca06255e 100644 --- a/ABACUS.develop/source/src_pw/forces.h +++ b/ABACUS.develop/source/src_pw/forces.h @@ -6,7 +6,7 @@ class Forces { public: - friend class Force_LCAO; + friend class Force_Stress_LCAO; /* This routine is a driver routine which compute the forces * acting on the atoms, the complete forces in plane waves * is computed from 4 main parts @@ -16,28 +16,21 @@ class Forces * (4) cal_nl: contribution due to the non-local pseudopotential. * (4) cal_scc: contributino due to incomplete SCF calculation. */ - Forces(const int natom); + Forces(); ~Forces(); - void init(); + void init(matrix& matrix); - matrix force; private: int nat; static double output_acc; - matrix forcelc; - matrix forceion; - matrix forcecc; - matrix forcenl; - matrix forcescc; - - void cal_force_loc(); - void cal_force_ew(); - void cal_force_cc(); - void cal_force_nl(); - void cal_force_scc(); + void cal_force_loc(matrix& forcelc); + void cal_force_ew(matrix& forceion); + void cal_force_cc(matrix& forcecc); + void cal_force_nl(matrix& forcenl); + void cal_force_scc(matrix& forcescc); static void print( const string &name, const matrix &f, bool rv=true ); static void print_to_files( ofstream &ofs, const string &name, const matrix &f ); diff --git a/ABACUS.develop/source/src_pw/ions.cpp b/ABACUS.develop/source/src_pw/ions.cpp index 6efbf6732e..a8c0c85dd7 100644 --- a/ABACUS.develop/source/src_pw/ions.cpp +++ b/ABACUS.develop/source/src_pw/ions.cpp @@ -253,8 +253,9 @@ bool Ions::force_stress(const int &istep, int &force_step, int &stress_step) // if(FORCE&&!STRESS) { // (1) calculate the force. - Forces fcs(ucell.nat); - fcs.init(); + matrix force; + Forces fcs; + fcs.init(force); // (2) move the ions. bool converged = false; @@ -268,7 +269,7 @@ bool Ions::force_stress(const int &istep, int &force_step, int &stress_step) // //} if(CALCULATION=="relax") { - IMM.cal_movement(istep, istep, fcs.force, en.etot); + IMM.cal_movement(istep, istep, force, en.etot); converged = IMM.get_converged(); if(converged || (istep==NSTEP) ) @@ -308,7 +309,6 @@ bool Ions::force_stress(const int &istep, int &force_step, int &stress_step) // { Stress_PW ss; matrix stress; - stress.create(3,3); ss.cal_stress(stress); double unit_transform = 0.0; @@ -349,12 +349,16 @@ bool Ions::force_stress(const int &istep, int &force_step, int &stress_step) // { //cout<<" istep force_step stress_step converged_force converged_stress = "< #include"tools.h" #include"global.h" -#include"../src_lcao/force_lcao.h" +#include"../src_lcao/force_stress_lcao.h" #include"unitcell_pseudo.h" using namespace std; diff --git a/ABACUS.develop/source/src_pw/stress_func_gga.cpp b/ABACUS.develop/source/src_pw/stress_func_gga.cpp index 75c5af9941..41718cb95b 100644 --- a/ABACUS.develop/source/src_pw/stress_func_gga.cpp +++ b/ABACUS.develop/source/src_pw/stress_func_gga.cpp @@ -217,7 +217,7 @@ void Stress_Func::stress_gga(matrix& sigma) { for(int j=0;j<3;j++) { - sigma(i,j) += sigma_gradcorr[i][j]; + sigma(i,j) += sigma_gradcorr[i][j] / pw.ncxyz; } } diff --git a/ABACUS.develop/source/src_pw/stress_pw.cpp b/ABACUS.develop/source/src_pw/stress_pw.cpp index 69f3335149..7964698056 100644 --- a/ABACUS.develop/source/src_pw/stress_pw.cpp +++ b/ABACUS.develop/source/src_pw/stress_pw.cpp @@ -7,6 +7,7 @@ void Stress_PW::cal_stress(matrix& sigma) TITLE("Stress_PW","cal_stress"); timer::tick("Stress_PW","cal_stress",'E'); + sigma.create(3,3); matrix sigmaxc; sigmaxc.create(3,3); matrix sigmatot; @@ -111,13 +112,14 @@ void Stress_PW::cal_stress(matrix& sigma) void Stress_PW::stress_vdw(matrix& sigma) { + matrix force; if(vdwd2.vdwD2) //Peize Lin add 2014-04-04, update 2019-04-26 { - vdwd2.force(sigma, 1); + vdwd2.force(0, 1, force, sigma); } if(vdwd3.vdwD3) //jiyy add 2019-05-18 { - vdwd3.force(sigma, 1); + vdwd3.force(0, 1, force, sigma); } return; } diff --git a/ABACUS.develop/source/src_pw/vdwd2.cpp b/ABACUS.develop/source/src_pw/vdwd2.cpp index a903a5c8f6..2d5b4d3785 100644 --- a/ABACUS.develop/source/src_pw/vdwd2.cpp +++ b/ABACUS.develop/source/src_pw/vdwd2.cpp @@ -124,7 +124,12 @@ double Vdwd2::energy() return energy_result; } -const std::vector> &Vdwd2::force(matrix &stress_result, const bool stress_for_vdw) +const std::vector> &Vdwd2::force( + const bool force_for_vdw, + const bool stress_for_vdw, + matrix &force_vdw, + matrix &stress_result +) { TITLE("Vdwd2","force"); initset(); @@ -178,12 +183,30 @@ const std::vector> &Vdwd2::force(matrix &stress_result, const bo } // end for it2 } // end for it1 for( int iat=0; iat!=ucell.nat; ++iat ) + { force_result[iat] *= scaling/ucell.lat0; + } + for(int ipol=0;ipol<3;ipol++) { - for(int jpol=0;jpol<3;jpol++) + if(stress_for_vdw) + { + for(int jpol=0;jpol<3;jpol++) + { + stress_result(ipol,jpol) *= scaling / ucell.omega; + } + } + if(force_for_vdw) { - stress_result(ipol,jpol) *= scaling / ucell.omega; + for(int iat=0;iat> force_result; - const std::vector> &force(matrix &stress_result, const bool stress_for_vdw); + const std::vector> &force( + const bool force_for_vdw, + const bool stress_for_vdw, + matrix &force_vdw, + matrix &stress_result ); private: diff --git a/ABACUS.develop/source/src_pw/vdwd3.cpp b/ABACUS.develop/source/src_pw/vdwd3.cpp index 2426f14033..3d02cf1397 100644 --- a/ABACUS.develop/source/src_pw/vdwd3.cpp +++ b/ABACUS.develop/source/src_pw/vdwd3.cpp @@ -210,7 +210,12 @@ double Vdwd3::energy() return energy_result; } -vector< vector > Vdwd3::force(matrix &stress_result, const bool stress_for_vdw) +vector< vector > Vdwd3::force( + const bool force_for_vdw, + const bool stress_for_vdw, + matrix &force_vdw, + matrix &stress_result +) { TITLE("Vdwd3","force"); initset(); @@ -249,9 +254,19 @@ vector< vector > Vdwd3::force(matrix &stress_result, const bool stress_f } for(int ipol=0;ipol<3;ipol++) { - for(int jpol=0;jpol<3;jpol++) + if(stress_for_vdw) { - stress_result(ipol,jpol) = 2*sigma[ipol][jpol]/ucell.omega; + for(int jpol=0;jpol<3;jpol++) + { + stress_result(ipol,jpol) = 2*sigma[ipol][jpol]/ucell.omega; + } + } + if(force_for_vdw) + { + for(int iat=0;iat > force_result; - vector< vector > force(matrix &stress_result, const bool stress_for_vdw); + vector< vector > force( + const bool force_for_vdw, + const bool stress_for_vdw, + matrix &force_vdw, + matrix &stress_result + ); private: //third-order term? From 8dbd83aa975ee6c5b5f35729aa787e1e86a06fb5 Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 5 Mar 2021 20:20:34 +0800 Subject: [PATCH 173/233] move force_lcao_gamma to FORCE_gamma, move force_lcao_k to FORCE_k, move force_stress_lcao to FORCE_STRESS --- ABACUS.develop/source/Makefile.Objects | 6 ++-- ABACUS.develop/source/input_conv.cpp | 2 +- ABACUS.develop/source/input_update.cpp | 2 +- ...force_stress_lcao.cpp => FORCE_STRESS.cpp} | 2 +- .../{force_stress_lcao.h => FORCE_STRESS.h} | 5 ++- .../{force_lcao_gamma.cpp => FORCE_gamma.cpp} | 2 +- .../{force_lcao_gamma.h => FORCE_gamma.h} | 35 ++++++++++++------- .../{force_lcao_k.cpp => FORCE_k.cpp} | 2 +- .../src_lcao/{force_lcao_k.h => FORCE_k.h} | 2 +- .../source/src_lcao/local_orbital_ions.cpp | 2 +- ABACUS.develop/source/src_pw/md.h | 2 +- 11 files changed, 37 insertions(+), 25 deletions(-) rename ABACUS.develop/source/src_lcao/{force_stress_lcao.cpp => FORCE_STRESS.cpp} (99%) rename ABACUS.develop/source/src_lcao/{force_stress_lcao.h => FORCE_STRESS.h} (98%) rename ABACUS.develop/source/src_lcao/{force_lcao_gamma.cpp => FORCE_gamma.cpp} (99%) rename ABACUS.develop/source/src_lcao/{force_lcao_gamma.h => FORCE_gamma.h} (91%) rename ABACUS.develop/source/src_lcao/{force_lcao_k.cpp => FORCE_k.cpp} (99%) rename ABACUS.develop/source/src_lcao/{force_lcao_k.h => FORCE_k.h} (98%) diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 25312929b5..9b91b623ff 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -148,9 +148,9 @@ LCAO_nnr.o \ LCAO_diago.o\ LCAO_evolve.o\ ylm.o\ -force_stress_lcao.o\ -force_lcao_gamma.o\ -force_lcao_k.o\ +FORCE_STRESS.o\ +FORCE_gamma.o\ +FORCE_k.o\ parallel_orbitals.o \ global_fp.o \ pdiag_double.o \ diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index 4e210b9ff9..6a0d6bc1a8 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -4,7 +4,7 @@ #include "input_conv.h" #include "src_ions/ions_move_basic.h" #include "src_io/optical.h" -#include "src_lcao/force_stress_lcao.h" +#include "src_lcao/FORCE_STRESS.h" #include "src_lcao/local_orbital_charge.h" #include "src_lcao/ORB_read.h" #include "src_pw/efield.h" diff --git a/ABACUS.develop/source/input_update.cpp b/ABACUS.develop/source/input_update.cpp index 8ad7a1c56d..ec7c689d04 100644 --- a/ABACUS.develop/source/input_update.cpp +++ b/ABACUS.develop/source/input_update.cpp @@ -8,7 +8,7 @@ #include "input.h" #include "src_ions/ions_move_basic.h" #include "src_io/optical.h" -#include "src_lcao/force_stress_lcao.h" +#include "src_lcao/FORCE_STRESS.h" #include "src_lcao/local_orbital_charge.h" #include "src_lcao/global_fp.h" // mohan update 2021-01-30 diff --git a/ABACUS.develop/source/src_lcao/force_stress_lcao.cpp b/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/force_stress_lcao.cpp rename to ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp index ce85f2fbcb..6dc8e2ea49 100644 --- a/ABACUS.develop/source/src_lcao/force_stress_lcao.cpp +++ b/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp @@ -1,4 +1,4 @@ -#include "./force_stress_lcao.h" +#include "FORCE_STRESS.h" #include "../src_pw/global.h" #include "../src_pw/potential_libxc.h" #include "./dftu.h" //Quxin add for DFT+U on 20201029 diff --git a/ABACUS.develop/source/src_lcao/force_stress_lcao.h b/ABACUS.develop/source/src_lcao/FORCE_STRESS.h similarity index 98% rename from ABACUS.develop/source/src_lcao/force_stress_lcao.h rename to ABACUS.develop/source/src_lcao/FORCE_STRESS.h index 43ceca22c5..3a983f3f69 100644 --- a/ABACUS.develop/source/src_lcao/force_stress_lcao.h +++ b/ABACUS.develop/source/src_lcao/FORCE_STRESS.h @@ -2,7 +2,7 @@ #define FORCE_STRESS_LCAO_H #include "../src_pw/tools.h" -#include "./force_lcao_k.h" +#include "FORCE_k.h" //#include "./force_lcao_gamma.h" #include "../src_pw/stress_func.h" #include "../input_conv.h" @@ -43,11 +43,13 @@ class Force_Stress_LCAO matrix& scs); void forceSymmetry(matrix& fcs); + void calForcePwPart( matrix& fvl_dvl, matrix& fewalds, matrix& fcc, matrix& fscc); + void calForceStressIntegralPart( const bool isGammaOnly, const bool isforce, @@ -60,6 +62,7 @@ class Force_Stress_LCAO matrix& stvnl_dphi, matrix& svnl_dbeta, matrix& svl_dphi); + void calStressPwPart( matrix& sigmadvl, matrix& sigmahar, diff --git a/ABACUS.develop/source/src_lcao/force_lcao_gamma.cpp b/ABACUS.develop/source/src_lcao/FORCE_gamma.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/force_lcao_gamma.cpp rename to ABACUS.develop/source/src_lcao/FORCE_gamma.cpp index 6a0f326ad3..50b1ec8e98 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao_gamma.cpp +++ b/ABACUS.develop/source/src_lcao/FORCE_gamma.cpp @@ -1,4 +1,4 @@ -#include "force_lcao_gamma.h" +#include "FORCE_gamma.h" #include "../src_pw/global.h" #include "dftu.h" //Quxin add for DFT+U on 20201029 diff --git a/ABACUS.develop/source/src_lcao/force_lcao_gamma.h b/ABACUS.develop/source/src_lcao/FORCE_gamma.h similarity index 91% rename from ABACUS.develop/source/src_lcao/force_lcao_gamma.h rename to ABACUS.develop/source/src_lcao/FORCE_gamma.h index 5b772e36e2..9cd7da2f0d 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao_gamma.h +++ b/ABACUS.develop/source/src_lcao/FORCE_gamma.h @@ -32,35 +32,27 @@ class Force_LCAO_gamma // get the ds, dt, dvnl. void allocate_gamma(void); void finish_ftable_gamma(void); + + // forces related to energy density matrix void set_EDM_gamma(matrix& dm, bool with_energy); - // mohan fix bug 2011-06-15 double set_EDM_element(const int &ii, const int &jj, const bool with_energy, double*** coef1, double*** coef2, const int &is); + // forces reated to overlap matrix void cal_foverlap( const bool isforce, const bool isstress, matrix& foverlap, matrix& soverlap); + + // forces related to non-local pseudopotentials void cal_ftvnl_dphi( matrix& dm2d, const bool isforce, const bool isstress, matrix& ftvnl_dphi, matrix& stvnl_dphi); - void cal_fvnl_dbeta( - matrix& dm2d, - const bool isforce, - const bool isstress, - matrix& fvnl_dbeta, - matrix& svnl_dbeta); - void cal_fvl_dphi( - matrix& dm2d, - const bool isforce, - const bool isstress, - matrix& fvl_dphi, - matrix& svl_dphi); void cal_ftvnl_dphi( const std::vector &dm2d, @@ -68,12 +60,29 @@ class Force_LCAO_gamma const bool isstress, matrix& ftvnl_dphi, matrix& stvnl_dphi); + + void cal_fvnl_dbeta( + matrix& dm2d, + const bool isforce, + const bool isstress, + matrix& fvnl_dbeta, + matrix& svnl_dbeta); + void cal_fvnl_dbeta( const std::vector &dm2d, const bool isforce, const bool isstress, matrix& fvnl_dbeta, matrix& svnl_dbeta); + + // forces related to local pseudopotentials + void cal_fvl_dphi( + matrix& dm2d, + const bool isforce, + const bool isstress, + matrix& fvl_dphi, + matrix& svl_dphi); + void cal_fvl_dphi( const std::vector &dm2d, const bool isforce, diff --git a/ABACUS.develop/source/src_lcao/force_lcao_k.cpp b/ABACUS.develop/source/src_lcao/FORCE_k.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/force_lcao_k.cpp rename to ABACUS.develop/source/src_lcao/FORCE_k.cpp index 8513afc394..cdcc000a63 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao_k.cpp +++ b/ABACUS.develop/source/src_lcao/FORCE_k.cpp @@ -1,4 +1,4 @@ -#include "force_lcao_k.h" +#include "FORCE_k.h" #include "../src_pw/global.h" #include "dftu.h" //Quxin add for DFT+U on 20201029 diff --git a/ABACUS.develop/source/src_lcao/force_lcao_k.h b/ABACUS.develop/source/src_lcao/FORCE_k.h similarity index 98% rename from ABACUS.develop/source/src_lcao/force_lcao_k.h rename to ABACUS.develop/source/src_lcao/FORCE_k.h index 523787dc11..a30362ec00 100644 --- a/ABACUS.develop/source/src_lcao/force_lcao_k.h +++ b/ABACUS.develop/source/src_lcao/FORCE_k.h @@ -3,7 +3,7 @@ #include "../src_pw/tools.h" #include "LCAO_matrix.h" -#include "force_lcao_gamma.h" +#include "FORCE_gamma.h" class Force_LCAO_k : public Force_LCAO_gamma { diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index 45d1b1d506..1d28f4aee2 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -3,7 +3,7 @@ #include "src_parallel/parallel_orbitals.h" #include "src_pdiag/pdiag_double.h" #include "LCAO_nnr.h" -#include "force_stress_lcao.h" +#include "FORCE_STRESS.h" #include "src_global/global_function.h" #include "src_io/hs_matrix.h" #include "src_io/cal_r_overlap_R.h" diff --git a/ABACUS.develop/source/src_pw/md.h b/ABACUS.develop/source/src_pw/md.h index 1c3c0bf21a..3aee8f41d5 100644 --- a/ABACUS.develop/source/src_pw/md.h +++ b/ABACUS.develop/source/src_pw/md.h @@ -9,7 +9,7 @@ #include #include"tools.h" #include"global.h" -#include"../src_lcao/force_stress_lcao.h" +#include"../src_lcao/FORCE_STRESS.h" #include"unitcell_pseudo.h" using namespace std; From d2adab961323969bd23977defb479f462181710d Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 5 Mar 2021 20:41:52 +0800 Subject: [PATCH 174/233] divide FORCE_gamma to four parts, FORCE_gamma_edm, FORCE_gamma_vl, FORCE_gamma_tvnl, and FORCE_gamma --- ABACUS.develop/source/Makefile.Objects | 3 + .../source/src_lcao/FORCE_gamma.cpp | 1481 ----------------- ABACUS.develop/source/src_lcao/FORCE_gamma.h | 26 +- .../source/src_lcao/FORCE_gamma_edm.cpp | 794 +++++++++ .../source/src_lcao/FORCE_gamma_tvnl.cpp | 421 +++++ .../source/src_lcao/FORCE_gamma_vl.cpp | 278 ++++ 6 files changed, 1513 insertions(+), 1490 deletions(-) create mode 100644 ABACUS.develop/source/src_lcao/FORCE_gamma_edm.cpp create mode 100644 ABACUS.develop/source/src_lcao/FORCE_gamma_tvnl.cpp create mode 100644 ABACUS.develop/source/src_lcao/FORCE_gamma_vl.cpp diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 9b91b623ff..f14c5b94b9 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -150,6 +150,9 @@ LCAO_evolve.o\ ylm.o\ FORCE_STRESS.o\ FORCE_gamma.o\ +FORCE_gamma_edm.o\ +FORCE_gamma_vl.o\ +FORCE_gamma_tvnl.o\ FORCE_k.o\ parallel_orbitals.o \ global_fp.o \ diff --git a/ABACUS.develop/source/src_lcao/FORCE_gamma.cpp b/ABACUS.develop/source/src_lcao/FORCE_gamma.cpp index 50b1ec8e98..9a06374dbe 100644 --- a/ABACUS.develop/source/src_lcao/FORCE_gamma.cpp +++ b/ABACUS.develop/source/src_lcao/FORCE_gamma.cpp @@ -206,647 +206,6 @@ void Force_LCAO_gamma::finish_ftable_gamma(void) return; } -double Force_LCAO_gamma::set_EDM_element( - const int &ii, const int &jj, - const bool with_energy, - double*** coef1, double*** coef2, const int &is) -{ - double ene = 0.0; - for (int ib = 0; ib < NBANDS; ib++) - { - const double w1 = wf.wg(is,ib); - if(w1>0.0) - { - if(with_energy) - { - ene += w1 * wf.ekb[is][ib] * coef1[is][ib][ii] * coef2[is][ib][jj]; - } - else - { - ene += w1 * coef1[is][ib][ii] * coef2[is][ib][jj]; - } - } - } - return ene; -} - -//#include "../src_develop/src_siao/selinv.h" -void Force_LCAO_gamma::set_EDM_gamma(matrix& dm, bool with_energy) -{ - TITLE("Force_LCAO_gamma","set_EDM_gamma"); - timer::tick("Force_LCAO_gamma","set_EDM"); - -#ifdef __SELINV -//xiaohui modified 2013-03-23, adding "/*" -/* if(DIAGO_TYPE=="selinv") - { -// cout << " set_EDM_gamma()" << endl; -// cout << " fill dm with density matrix or energy density matrix here." << endl; - - //-------------------------------------------------- - // job=1: density matrix for charge density (grid). - // job=2: density matrix for force (dm2d). - // job=3: energy density matrix for force (dm2d). - //-------------------------------------------------- - const int ik = 0; - int job = 0; - if(with_energy) - { - job=3; - } - else - { - job=2; - } - Selinv::dm_ptr = dm; - Selinv::using_SELINV(ik, job, LM.Hloc, LM.Sloc); - - return; - } -*/ -#endif - //xiaohui add 2015-03-24, like density matrix calculation -#ifdef __MPI //2015-09-06, xiaohui - int nprocs,myid; - MPI_Status status; - MPI_Comm_size(DIAG_HPSEPS_WORLD,&nprocs); - MPI_Comm_rank(DIAG_HPSEPS_WORLD,&myid); - - int local_band=NBANDS/DSIZE; - if (DRANK= NBANDS) - { - lastband_in_proc = i; - lastband_number = NBANDS - (count_bands - local_bands[i]); - break; - } - } - - for(int ispin=0;ispin= 1) - { - double** ZW_300; - ZW_300 = new double*[NSPIN]; - for(int is=0; is= 0 && col_nu >= 0) - { - int index = row_mu * ParaO.ncol + col_nu; - //dm[index] = rho_300[ispin][i_col + i_row*300]; - dm(ispin, index) = rho_300[ispin][i_row + i_col*300]; - } - } - } - } - for(int is=0; is= 0 && col_nu >= 0) - { - int index = row_mu * ParaO.ncol + col_nu; - //dm[index] = rho_300_remain[ispin][i_col + i_row*col_remain]; - dm(ispin, index) = rho_300_remain[ispin][i_row + i_col*300]; - } - } - } - } - for(int is=0; is= 0 && col_nu >= 0) - { - int index = row_mu * ParaO.ncol + col_nu; - dm(ispin, index) = rho_remain_300[ispin][i_row + i_col*row_remain]; - } - } - } - } - for(int is=0; is= 0 && col_nu >= 0) - { - int index = row_mu * ParaO.ncol + col_nu; - dm(ispin, index) = rho_remain_remain[ispin][i_row + i_col*row_remain]; - } - } - } - } - for(int is=0; is= 0 && col_nu >= 0) - { - int index = row_mu * ParaO.ncol + col_nu; - dm(ispin, index) = rho_NLOCAL_NLOCAL[ispin][i_col + i_row*NLOCAL]; - } - } - } - } - for(int is=0; is=0 && jj>=0) - { - ene = this->set_EDM_element(ii, jj, with_energy, LOWF.WFC_GAMMA, LOWF.WFC_GAMMA, ispin); - } - - // (2) - else if(ii>=0 && jj<0) - { - const int a4 = LOWF.trace_aug[j]; - assert(a4>=0); - ene = this->set_EDM_element(ii, a4, with_energy, LOWF.WFC_GAMMA, LOWF.WFC_GAMMA_aug, ispin); - } - else if(ii<0 && jj>=0) - { - const int a3 = LOWF.trace_aug[i]; - assert(a3>=0); - // mohan fix serious bug 2011-07-01 (ii, a3) -> (a3, jj) !!!!!!!!!!!! - ene = this->set_EDM_element(a3, jj, with_energy, LOWF.WFC_GAMMA_aug, LOWF.WFC_GAMMA, ispin); - } - else if(ii<0 && jj<0) - { - const int a3 = LOWF.trace_aug[i]; - const int a4 = LOWF.trace_aug[j]; - assert(a3>=0); - assert(a4>=0); - ene = this->set_EDM_element(a3, a4, with_energy, LOWF.WFC_GAMMA_aug, LOWF.WFC_GAMMA_aug, ispin); - } - - dm(ispin, index) = ene; - //dm[index] = 1.0;// mohan tmp - }// end j - }// end i - }//end ispin -#endif //2015-09-06, xiaohui - timer::tick("Force_LCAO_gamma","set_EDM"); - return; -} - void Force_LCAO_gamma::DerivT_PW(void) { @@ -872,216 +231,6 @@ void Force_LCAO_gamma::DerivT_PW(void) return; } -// force due to the overlap matrix. -// need energy density matrix here. -void Force_LCAO_gamma::cal_foverlap( - const bool isforce, - const bool isstress, - matrix& foverlap, - matrix& soverlap) -{ - TITLE("Force_LCAO_gamma","cal_foverlap"); - timer::tick("Force_LCAO_gamma","cal_foverlap",'G'); - - // set energy density matrix. - if(NEW_DM>0) - { - timer::tick("Force_LCAO_gamma","cal_edm_2d",'H'); - - matrix wgEkb; - wgEkb.create(NSPIN, NBANDS); - - for(int is=0; is=0 && nu>=0) - { - const int index = mu * ParaO.ncol + nu; - double sum = 0.0; - for(int is=0; isset_EDM_gamma(edm2d, with_energy); - - timer::tick("Force_LCAO_gamma","cal_edm_grid",'H'); - - //summation \sum_{i,j} E(i,j)*dS(i,j) - //BEGIN CALCULATION OF FORCE OF EACH ATOM - - for(int i=0; i= 0 && nu >= 0 ) - { - const int index = mu * ParaO.ncol + nu; - - //================================================================ - // here is the normal order, the force of each atom is calculated - // according to each 'column' in DSloc_x, y, z - // because the DSloc_x,y,z are anti-symmetry matrix. - //================================================================ - - double sum = 0.0; - for(int is=0; is= 0 && nu >= 0 ) - { - const int index = mu * ParaO.ncol + nu; - //contribution from deriv of AO's in T+VNL term - - double sum = 0.0; - for(int is=0; is tau0 = ucell.atoms[it].tau[ia]; - //find ajacent atom of atom ia - //GridD.Find_atom( ucell.atoms[it].tau[ia] ); - GridD.Find_atom( ucell.atoms[it].tau[ia] ,it, ia); - - //FOLLOWING ARE CONTRIBUTIONS FROM - //VNL DUE TO PROJECTOR'S DISPLACEMENT - for (int ad1 =0 ; ad1 < GridD.getAdjacentNum()+1; ad1++) - { - const int T1 = GridD.getType (ad1); - const Atom* atom1 = &ucell.atoms[T1]; - const int I1 = GridD.getNatom (ad1); - const int start1 = ucell.itiaiw2iwt(T1, I1, 0); - const Vector3 tau1 = GridD.getAdjacentTau (ad1); - - for (int ad2 =0 ; ad2 < GridD.getAdjacentNum()+1; ad2++) - { - const int T2 = GridD.getType (ad2); - const Atom* atom2 = &ucell.atoms[T2]; - const int I2 = GridD.getNatom (ad2); - const int start2 = ucell.itiaiw2iwt(T2, I2, 0); - const Vector3 tau2 = GridD.getAdjacentTau (ad2); - - const double Rcut_Beta = ORB.Beta[it].get_rcut_max(); - const double Rcut_AO1 = ORB.Phi[T1].getRcut(); - const double Rcut_AO2 = ORB.Phi[T2].getRcut(); - - const double dist1 = (tau1-tau0).norm() * ucell.lat0; - const double dist2 = (tau2-tau0).norm() * ucell.lat0; - double r0[3]; - double r1[3]; - if(isstress) - { - r1[0] = ( tau1.x - tau0.x) ; - r1[1] = ( tau1.y - tau0.y) ; - r1[2] = ( tau1.z - tau0.z) ; - r0[0] = ( tau2.x - tau0.x) ; - r0[1] = ( tau2.y - tau0.y) ; - r0[2] = ( tau2.z - tau0.z) ; - } - - if (dist1 > Rcut_Beta + Rcut_AO1 - || dist2 > Rcut_Beta + Rcut_AO2) - { - continue; - } - - for (int jj = 0; jj < ucell.atoms[T1].nw; jj++) - { - const int iw1_all = start1 + jj; - const int mu = ParaO.trace_loc_row[iw1_all]; - if(mu<0) continue; - for (int kk = 0; kk < ucell.atoms[T2].nw; kk++) - { - const int iw2_all = start2 + kk; - const int nu = ParaO.trace_loc_col[iw2_all]; - if(nu<0) continue; - - double nlm[3] = {0,0,0}; - - UOT.snap_psibeta( - nlm, 1, - tau1, T1, - atom1->iw2l[jj], // L2 - atom1->iw2m[jj], // m2 - atom1->iw2n[jj], // N2 - tau2, T2, - atom2->iw2l[kk], // L1 - atom2->iw2m[kk], // m1 - atom2->iw2n[kk], // n1 - tau0, it); - double nlm1[3] = {0,0,0}; - if(isstress) UOT.snap_psibeta( - nlm1, 1, - tau2, T2, - atom2->iw2l[kk], // L2 - atom2->iw2m[kk], // m2 - atom2->iw2n[kk], // N2 - tau1, T1, - atom1->iw2l[jj], // L1 - atom1->iw2m[jj], // m1 - atom1->iw2n[jj], // n1 - tau0, it); - - const int index = mu * ParaO.ncol + nu; - - // dbeta is minus, that's consistent. - // only one projector for each atom force. - - double sum = 0.0; - for(int is=0; is &dm2d, - const bool isforce, - const bool isstress, - matrix& ftvnl_dphi, - matrix& stvnl_dphi) -{ - TITLE("Force_LCAO_gamma","cal_ftvnl_dphi"); - timer::tick("Force_LCAO_gamma","cal_ftvnl_dphi",'G'); - - for(int i=0; i= 0 && nu >= 0 ) - { - const int index = mu * ParaO.ncol + nu; - //contribution from deriv of AO's in T+VNL term - - double sum = 0.0; - for(int is=0; is &dm2d, - const bool isforce, - const bool isstress, - matrix& fvl_dphi, - matrix& svl_dphi) -{ - TITLE("Force_LCAO_gamma","cal_fvl_dphi"); - timer::tick("Force_LCAO_gamma","cal_fvl_dphi",'G'); - - ZEROS (LM.DHloc_fixed_x, ParaO.nloc); - ZEROS (LM.DHloc_fixed_y, ParaO.nloc); - ZEROS (LM.DHloc_fixed_z, ParaO.nloc); - if(STRESS) - { - ZEROS (LM.DHloc_fixed_11, ParaO.nloc); - ZEROS (LM.DHloc_fixed_12, ParaO.nloc); - ZEROS (LM.DHloc_fixed_13, ParaO.nloc); - ZEROS (LM.DHloc_fixed_22, ParaO.nloc); - ZEROS (LM.DHloc_fixed_23, ParaO.nloc); - ZEROS (LM.DHloc_fixed_33, ParaO.nloc); - } - - - double* tmpDHx = new double[ParaO.nloc]; - double* tmpDHy = new double[ParaO.nloc]; - double* tmpDHz = new double[ParaO.nloc]; - ZEROS( tmpDHx, ParaO.nloc ); - ZEROS( tmpDHy, ParaO.nloc ); - ZEROS( tmpDHz, ParaO.nloc ); - for(int i=0; i &dm2d, - const bool isforce, - const bool isstress, - matrix& fvnl_dbeta, - matrix& svnl_dbeta) -{ - TITLE("Force_LCAO_gamma","cal_fvnl_dbeta"); - timer::tick("Force_LCAO_gamma","cal_fvnl_dbeta",'G'); - - for(int iat=0; iat tau0 = ucell.atoms[it].tau[ia]; - //find ajacent atom of atom ia - //GridD.Find_atom( ucell.atoms[it].tau[ia] ); - GridD.Find_atom( ucell.atoms[it].tau[ia] ,it, ia); - - //FOLLOWING ARE CONTRIBUTIONS FROM - //VNL DUE TO PROJECTOR'S DISPLACEMENT - for (int ad1 =0 ; ad1 < GridD.getAdjacentNum()+1; ad1++) - { - const int T1 = GridD.getType (ad1); - const Atom* atom1 = &ucell.atoms[T1]; - const int I1 = GridD.getNatom (ad1); - const int start1 = ucell.itiaiw2iwt(T1, I1, 0); - const Vector3 tau1 = GridD.getAdjacentTau (ad1); - - for (int ad2 =0 ; ad2 < GridD.getAdjacentNum()+1; ad2++) - { - const int T2 = GridD.getType (ad2); - const Atom* atom2 = &ucell.atoms[T2]; - const int I2 = GridD.getNatom (ad2); - const int start2 = ucell.itiaiw2iwt(T2, I2, 0); - const Vector3 tau2 = GridD.getAdjacentTau (ad2); - - const double Rcut_Beta = ORB.Beta[it].get_rcut_max(); - const double Rcut_AO1 = ORB.Phi[T1].getRcut(); - const double Rcut_AO2 = ORB.Phi[T2].getRcut(); - - const double dist1 = (tau1-tau0).norm() * ucell.lat0; - const double dist2 = (tau2-tau0).norm() * ucell.lat0; - double r0[3]; - double r1[3]; - if(isstress) - { - r1[0] = ( tau1.x - tau0.x) ; - r1[1] = ( tau1.y - tau0.y) ; - r1[2] = ( tau1.z - tau0.z) ; - r0[0] = ( tau2.x - tau0.x) ; - r0[1] = ( tau2.y - tau0.y) ; - r0[2] = ( tau2.z - tau0.z) ; - } - - if (dist1 > Rcut_Beta + Rcut_AO1 - || dist2 > Rcut_Beta + Rcut_AO2) - { - continue; - } - - for (int jj = 0; jj < ucell.atoms[T1].nw; jj++) - { - const int iw1_all = start1 + jj; - const int mu = ParaO.trace_loc_row[iw1_all]; - if(mu<0) continue; - for (int kk = 0; kk < ucell.atoms[T2].nw; kk++) - { - const int iw2_all = start2 + kk; - const int nu = ParaO.trace_loc_col[iw2_all]; - if(nu<0) continue; - - double nlm[3] = {0,0,0}; - - UOT.snap_psibeta( - nlm, 1, - tau1, T1, - atom1->iw2l[jj], // L2 - atom1->iw2m[jj], // m2 - atom1->iw2n[jj], // N2 - tau2, T2, - atom2->iw2l[kk], // L1 - atom2->iw2m[kk], // m1 - atom2->iw2n[kk], // n1 - tau0, it); - double nlm1[3] = {0,0,0}; - if(isstress) UOT.snap_psibeta( - nlm1, 1, - tau2, T2, - atom2->iw2l[kk], // L2 - atom2->iw2m[kk], // m2 - atom2->iw2n[kk], // N2 - tau1, T1, - atom1->iw2l[jj], // L1 - atom1->iw2m[jj], // m1 - atom1->iw2n[jj], // n1 - tau0, it); - - const int index = mu * ParaO.ncol + nu; - - // dbeta is minus, that's consistent. - // only one projector for each atom force. - - double sum = 0.0; - for(int is=0; is0.0) + { + if(with_energy) + { + ene += w1 * wf.ekb[is][ib] * coef1[is][ib][ii] * coef2[is][ib][jj]; + } + else + { + ene += w1 * coef1[is][ib][ii] * coef2[is][ib][jj]; + } + } + } + return ene; +} + +//#include "../src_develop/src_siao/selinv.h" +void Force_LCAO_gamma::set_EDM_gamma(matrix& dm, bool with_energy) +{ + TITLE("Force_LCAO_gamma","set_EDM_gamma"); + timer::tick("Force_LCAO_gamma","set_EDM"); + +#ifdef __SELINV +//xiaohui modified 2013-03-23, adding "/*" +/* if(DIAGO_TYPE=="selinv") + { +// cout << " set_EDM_gamma()" << endl; +// cout << " fill dm with density matrix or energy density matrix here." << endl; + + //-------------------------------------------------- + // job=1: density matrix for charge density (grid). + // job=2: density matrix for force (dm2d). + // job=3: energy density matrix for force (dm2d). + //-------------------------------------------------- + const int ik = 0; + int job = 0; + if(with_energy) + { + job=3; + } + else + { + job=2; + } + Selinv::dm_ptr = dm; + Selinv::using_SELINV(ik, job, LM.Hloc, LM.Sloc); + + return; + } +*/ +#endif + //xiaohui add 2015-03-24, like density matrix calculation +#ifdef __MPI //2015-09-06, xiaohui + int nprocs,myid; + MPI_Status status; + MPI_Comm_size(DIAG_HPSEPS_WORLD,&nprocs); + MPI_Comm_rank(DIAG_HPSEPS_WORLD,&myid); + + int local_band=NBANDS/DSIZE; + if (DRANK= NBANDS) + { + lastband_in_proc = i; + lastband_number = NBANDS - (count_bands - local_bands[i]); + break; + } + } + + for(int ispin=0;ispin= 1) + { + double** ZW_300; + ZW_300 = new double*[NSPIN]; + for(int is=0; is= 0 && col_nu >= 0) + { + int index = row_mu * ParaO.ncol + col_nu; + //dm[index] = rho_300[ispin][i_col + i_row*300]; + dm(ispin, index) = rho_300[ispin][i_row + i_col*300]; + } + } + } + } + for(int is=0; is= 0 && col_nu >= 0) + { + int index = row_mu * ParaO.ncol + col_nu; + //dm[index] = rho_300_remain[ispin][i_col + i_row*col_remain]; + dm(ispin, index) = rho_300_remain[ispin][i_row + i_col*300]; + } + } + } + } + for(int is=0; is= 0 && col_nu >= 0) + { + int index = row_mu * ParaO.ncol + col_nu; + dm(ispin, index) = rho_remain_300[ispin][i_row + i_col*row_remain]; + } + } + } + } + for(int is=0; is= 0 && col_nu >= 0) + { + int index = row_mu * ParaO.ncol + col_nu; + dm(ispin, index) = rho_remain_remain[ispin][i_row + i_col*row_remain]; + } + } + } + } + for(int is=0; is= 0 && col_nu >= 0) + { + int index = row_mu * ParaO.ncol + col_nu; + dm(ispin, index) = rho_NLOCAL_NLOCAL[ispin][i_col + i_row*NLOCAL]; + } + } + } + } + for(int is=0; is=0 && jj>=0) + { + ene = this->set_EDM_element(ii, jj, with_energy, LOWF.WFC_GAMMA, LOWF.WFC_GAMMA, ispin); + } + + // (2) + else if(ii>=0 && jj<0) + { + const int a4 = LOWF.trace_aug[j]; + assert(a4>=0); + ene = this->set_EDM_element(ii, a4, with_energy, LOWF.WFC_GAMMA, LOWF.WFC_GAMMA_aug, ispin); + } + else if(ii<0 && jj>=0) + { + const int a3 = LOWF.trace_aug[i]; + assert(a3>=0); + // mohan fix serious bug 2011-07-01 (ii, a3) -> (a3, jj) !!!!!!!!!!!! + ene = this->set_EDM_element(a3, jj, with_energy, LOWF.WFC_GAMMA_aug, LOWF.WFC_GAMMA, ispin); + } + else if(ii<0 && jj<0) + { + const int a3 = LOWF.trace_aug[i]; + const int a4 = LOWF.trace_aug[j]; + assert(a3>=0); + assert(a4>=0); + ene = this->set_EDM_element(a3, a4, with_energy, LOWF.WFC_GAMMA_aug, LOWF.WFC_GAMMA_aug, ispin); + } + + dm(ispin, index) = ene; + //dm[index] = 1.0;// mohan tmp + }// end j + }// end i + }//end ispin +#endif //2015-09-06, xiaohui + timer::tick("Force_LCAO_gamma","set_EDM"); + return; +} + + +// force due to the overlap matrix. +// need energy density matrix here. +void Force_LCAO_gamma::cal_foverlap( + const bool isforce, + const bool isstress, + matrix& foverlap, + matrix& soverlap) +{ + TITLE("Force_LCAO_gamma","cal_foverlap"); + timer::tick("Force_LCAO_gamma","cal_foverlap",'G'); + + // set energy density matrix. + if(NEW_DM>0) + { + timer::tick("Force_LCAO_gamma","cal_edm_2d",'H'); + + matrix wgEkb; + wgEkb.create(NSPIN, NBANDS); + + for(int is=0; is=0 && nu>=0) + { + const int index = mu * ParaO.ncol + nu; + double sum = 0.0; + for(int is=0; isset_EDM_gamma(edm2d, with_energy); + + timer::tick("Force_LCAO_gamma","cal_edm_grid",'H'); + + //summation \sum_{i,j} E(i,j)*dS(i,j) + //BEGIN CALCULATION OF FORCE OF EACH ATOM + + for(int i=0; i= 0 && nu >= 0 ) + { + const int index = mu * ParaO.ncol + nu; + + //================================================================ + // here is the normal order, the force of each atom is calculated + // according to each 'column' in DSloc_x, y, z + // because the DSloc_x,y,z are anti-symmetry matrix. + //================================================================ + + double sum = 0.0; + for(int is=0; is= 0 && nu >= 0 ) + { + const int index = mu * ParaO.ncol + nu; + //contribution from deriv of AO's in T+VNL term + + double sum = 0.0; + for(int is=0; is tau0 = ucell.atoms[it].tau[ia]; + //find ajacent atom of atom ia + //GridD.Find_atom( ucell.atoms[it].tau[ia] ); + GridD.Find_atom( ucell.atoms[it].tau[ia] ,it, ia); + + //FOLLOWING ARE CONTRIBUTIONS FROM + //VNL DUE TO PROJECTOR'S DISPLACEMENT + for (int ad1 =0 ; ad1 < GridD.getAdjacentNum()+1; ad1++) + { + const int T1 = GridD.getType (ad1); + const Atom* atom1 = &ucell.atoms[T1]; + const int I1 = GridD.getNatom (ad1); + const int start1 = ucell.itiaiw2iwt(T1, I1, 0); + const Vector3 tau1 = GridD.getAdjacentTau (ad1); + + for (int ad2 =0 ; ad2 < GridD.getAdjacentNum()+1; ad2++) + { + const int T2 = GridD.getType (ad2); + const Atom* atom2 = &ucell.atoms[T2]; + const int I2 = GridD.getNatom (ad2); + const int start2 = ucell.itiaiw2iwt(T2, I2, 0); + const Vector3 tau2 = GridD.getAdjacentTau (ad2); + + const double Rcut_Beta = ORB.Beta[it].get_rcut_max(); + const double Rcut_AO1 = ORB.Phi[T1].getRcut(); + const double Rcut_AO2 = ORB.Phi[T2].getRcut(); + + const double dist1 = (tau1-tau0).norm() * ucell.lat0; + const double dist2 = (tau2-tau0).norm() * ucell.lat0; + double r0[3]; + double r1[3]; + if(isstress) + { + r1[0] = ( tau1.x - tau0.x) ; + r1[1] = ( tau1.y - tau0.y) ; + r1[2] = ( tau1.z - tau0.z) ; + r0[0] = ( tau2.x - tau0.x) ; + r0[1] = ( tau2.y - tau0.y) ; + r0[2] = ( tau2.z - tau0.z) ; + } + + if (dist1 > Rcut_Beta + Rcut_AO1 + || dist2 > Rcut_Beta + Rcut_AO2) + { + continue; + } + + for (int jj = 0; jj < ucell.atoms[T1].nw; jj++) + { + const int iw1_all = start1 + jj; + const int mu = ParaO.trace_loc_row[iw1_all]; + if(mu<0) continue; + for (int kk = 0; kk < ucell.atoms[T2].nw; kk++) + { + const int iw2_all = start2 + kk; + const int nu = ParaO.trace_loc_col[iw2_all]; + if(nu<0) continue; + + double nlm[3] = {0,0,0}; + + UOT.snap_psibeta( + nlm, 1, + tau1, T1, + atom1->iw2l[jj], // L2 + atom1->iw2m[jj], // m2 + atom1->iw2n[jj], // N2 + tau2, T2, + atom2->iw2l[kk], // L1 + atom2->iw2m[kk], // m1 + atom2->iw2n[kk], // n1 + tau0, it); + double nlm1[3] = {0,0,0}; + if(isstress) UOT.snap_psibeta( + nlm1, 1, + tau2, T2, + atom2->iw2l[kk], // L2 + atom2->iw2m[kk], // m2 + atom2->iw2n[kk], // N2 + tau1, T1, + atom1->iw2l[jj], // L1 + atom1->iw2m[jj], // m1 + atom1->iw2n[jj], // n1 + tau0, it); + + const int index = mu * ParaO.ncol + nu; + + // dbeta is minus, that's consistent. + // only one projector for each atom force. + + double sum = 0.0; + for(int is=0; is &dm2d, + const bool isforce, + const bool isstress, + matrix& ftvnl_dphi, + matrix& stvnl_dphi) +{ + TITLE("Force_LCAO_gamma","cal_ftvnl_dphi"); + timer::tick("Force_LCAO_gamma","cal_ftvnl_dphi",'G'); + + for(int i=0; i= 0 && nu >= 0 ) + { + const int index = mu * ParaO.ncol + nu; + //contribution from deriv of AO's in T+VNL term + + double sum = 0.0; + for(int is=0; is &dm2d, + const bool isforce, + const bool isstress, + matrix& fvnl_dbeta, + matrix& svnl_dbeta) +{ + TITLE("Force_LCAO_gamma","cal_fvnl_dbeta"); + timer::tick("Force_LCAO_gamma","cal_fvnl_dbeta",'G'); + + for(int iat=0; iat tau0 = ucell.atoms[it].tau[ia]; + //find ajacent atom of atom ia + //GridD.Find_atom( ucell.atoms[it].tau[ia] ); + GridD.Find_atom( ucell.atoms[it].tau[ia] ,it, ia); + + //FOLLOWING ARE CONTRIBUTIONS FROM + //VNL DUE TO PROJECTOR'S DISPLACEMENT + for (int ad1 =0 ; ad1 < GridD.getAdjacentNum()+1; ad1++) + { + const int T1 = GridD.getType (ad1); + const Atom* atom1 = &ucell.atoms[T1]; + const int I1 = GridD.getNatom (ad1); + const int start1 = ucell.itiaiw2iwt(T1, I1, 0); + const Vector3 tau1 = GridD.getAdjacentTau (ad1); + + for (int ad2 =0 ; ad2 < GridD.getAdjacentNum()+1; ad2++) + { + const int T2 = GridD.getType (ad2); + const Atom* atom2 = &ucell.atoms[T2]; + const int I2 = GridD.getNatom (ad2); + const int start2 = ucell.itiaiw2iwt(T2, I2, 0); + const Vector3 tau2 = GridD.getAdjacentTau (ad2); + + const double Rcut_Beta = ORB.Beta[it].get_rcut_max(); + const double Rcut_AO1 = ORB.Phi[T1].getRcut(); + const double Rcut_AO2 = ORB.Phi[T2].getRcut(); + + const double dist1 = (tau1-tau0).norm() * ucell.lat0; + const double dist2 = (tau2-tau0).norm() * ucell.lat0; + double r0[3]; + double r1[3]; + if(isstress) + { + r1[0] = ( tau1.x - tau0.x) ; + r1[1] = ( tau1.y - tau0.y) ; + r1[2] = ( tau1.z - tau0.z) ; + r0[0] = ( tau2.x - tau0.x) ; + r0[1] = ( tau2.y - tau0.y) ; + r0[2] = ( tau2.z - tau0.z) ; + } + + if (dist1 > Rcut_Beta + Rcut_AO1 + || dist2 > Rcut_Beta + Rcut_AO2) + { + continue; + } + + for (int jj = 0; jj < ucell.atoms[T1].nw; jj++) + { + const int iw1_all = start1 + jj; + const int mu = ParaO.trace_loc_row[iw1_all]; + if(mu<0) continue; + for (int kk = 0; kk < ucell.atoms[T2].nw; kk++) + { + const int iw2_all = start2 + kk; + const int nu = ParaO.trace_loc_col[iw2_all]; + if(nu<0) continue; + + double nlm[3] = {0,0,0}; + + UOT.snap_psibeta( + nlm, 1, + tau1, T1, + atom1->iw2l[jj], // L2 + atom1->iw2m[jj], // m2 + atom1->iw2n[jj], // N2 + tau2, T2, + atom2->iw2l[kk], // L1 + atom2->iw2m[kk], // m1 + atom2->iw2n[kk], // n1 + tau0, it); + double nlm1[3] = {0,0,0}; + if(isstress) UOT.snap_psibeta( + nlm1, 1, + tau2, T2, + atom2->iw2l[kk], // L2 + atom2->iw2m[kk], // m2 + atom2->iw2n[kk], // N2 + tau1, T1, + atom1->iw2l[jj], // L1 + atom1->iw2m[jj], // m1 + atom1->iw2n[jj], // n1 + tau0, it); + + const int index = mu * ParaO.ncol + nu; + + // dbeta is minus, that's consistent. + // only one projector for each atom force. + + double sum = 0.0; + for(int is=0; is &dm2d, + const bool isforce, + const bool isstress, + matrix& fvl_dphi, + matrix& svl_dphi) +{ + TITLE("Force_LCAO_gamma","cal_fvl_dphi"); + timer::tick("Force_LCAO_gamma","cal_fvl_dphi",'G'); + + ZEROS (LM.DHloc_fixed_x, ParaO.nloc); + ZEROS (LM.DHloc_fixed_y, ParaO.nloc); + ZEROS (LM.DHloc_fixed_z, ParaO.nloc); + if(STRESS) + { + ZEROS (LM.DHloc_fixed_11, ParaO.nloc); + ZEROS (LM.DHloc_fixed_12, ParaO.nloc); + ZEROS (LM.DHloc_fixed_13, ParaO.nloc); + ZEROS (LM.DHloc_fixed_22, ParaO.nloc); + ZEROS (LM.DHloc_fixed_23, ParaO.nloc); + ZEROS (LM.DHloc_fixed_33, ParaO.nloc); + } + + + double* tmpDHx = new double[ParaO.nloc]; + double* tmpDHy = new double[ParaO.nloc]; + double* tmpDHz = new double[ParaO.nloc]; + ZEROS( tmpDHx, ParaO.nloc ); + ZEROS( tmpDHy, ParaO.nloc ); + ZEROS( tmpDHz, ParaO.nloc ); + for(int i=0; i Date: Sat, 6 Mar 2021 17:45:21 +0800 Subject: [PATCH 175/233] clean up ORB_radial_table --- ABACUS.develop/source/src_lcao/FORCE_k.h | 11 +- .../source/src_lcao/ORB_radial_table.cpp | 245 +----------------- 2 files changed, 5 insertions(+), 251 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/FORCE_k.h b/ABACUS.develop/source/src_lcao/FORCE_k.h index a30362ec00..0ccd9e8807 100644 --- a/ABACUS.develop/source/src_lcao/FORCE_k.h +++ b/ABACUS.develop/source/src_lcao/FORCE_k.h @@ -33,32 +33,25 @@ class Force_LCAO_k : public Force_LCAO_gamma // get the ds, dt, dvnl. void allocate_k(void); - void finish_k(void); - void set_EDM_k(double** dm2d, const bool with_energy); - // mohan add 2012-01-09 complex set_EDM_k_element( const complex &phase, const bool with_energy, complex &coef1, complex &coef2, const double &ekb); - // calculate the force due to < dphi | beta > < beta | phi > void cal_ftvnl_dphi_k(double** dm2d, const bool isforce, const bool isstress, matrix& ftvnl_dphi, matrix& stvnl_dphi); - - // calculate the force due to < phi | Vlocal | dphi > - void cal_fvl_dphi_k(double** dm2d, const bool isforce, const bool isstress, matrix& fvl_dphi, matrix& svl_dphi); - - // calculate the overlap force void cal_foverlap_k(const bool isforce, const bool isstress, matrix& foverlap, matrix& soverlap); + // calculate the force due to < phi | Vlocal | dphi > + void cal_fvl_dphi_k(double** dm2d, const bool isforce, const bool isstress, matrix& fvl_dphi, matrix& svl_dphi); // calculate the force due to < phi | dbeta > < beta | phi > void cal_fvnl_dbeta_k(double** dm2d, const bool isforce, const bool isstress, matrix& fvnl_dbeta, matrix& svnl_dbeta); diff --git a/ABACUS.develop/source/src_lcao/ORB_radial_table.cpp b/ABACUS.develop/source/src_lcao/ORB_radial_table.cpp index 8c7f68b9ca..b50a0a1dbd 100644 --- a/ABACUS.develop/source/src_lcao/ORB_radial_table.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_radial_table.cpp @@ -131,7 +131,6 @@ void Make_Overlap_Table::cal_ST_Phi12_R double* drs ) const { -// TITLE("Make_Overlap_Table","cal_ST_Phi12_R"); timer::tick("Make_Overlap_Table", "cal_ST_Phi12_R"); double* k1_dot_k2 = new double[kmesh]; @@ -177,58 +176,19 @@ void Make_Overlap_Table::cal_ST_Phi12_R k1_dot_k2_dot_kpoint[ik] = k1_dot_k2[ik] * this->kpoint[ik]; } -// Mathzone_Add1::Sbt_new (3, l, r, dr, rmesh, kpoint, dk, kmesh, k1_dot_k2, 2, rs); -// for (int ir = 0; ir < rmesh; ir++) rs[ir] *= FOUR_PI; - - //test -// double tmporg = Mathzone_Add1::uni_simpson (k1_dot_k2, kmesh, dk); -// tmporg *= FOUR_PI; - - //liaochen modify on 2010/4/21 - //for origin - //Drs //djl = (l*j(l-1) - (l+1)j(l+1))/(2l+1) - /* - if (l == 0) - { - double* tmp1 = new double[rmesh]; - ZEROS (tmp1, rmesh); - Mathzone_Add1::Sbt_new (3, 1, r, dr, rmesh, kpoint, dk, kmesh, k1_dot_k2, 1, tmp1); - for (int ir = 0; ir < rmesh; ir++) drs[ir] = -FOUR_PI*tmp1[ir]; - delete[] tmp1; - } - else - { - double* tmp1 = new double[rmesh]; - double* tmp2 = new double[rmesh]; - ZEROS (tmp1, rmesh); - ZEROS (tmp2, rmesh); - Mathzone_Add1::Sbt_new (3, l-1, r, dr, rmesh, kpoint, dk, kmesh, k1_dot_k2, 1, tmp1); - Mathzone_Add1::Sbt_new (3, l+1, r, dr, rmesh, kpoint, dk, kmesh, k1_dot_k2, 1, tmp2); - for (int ir = 0; ir < rmesh; ir++) drs[ir] = FOUR_PI*(l*tmp1[ir]-(l+1)*tmp2[ir])/(2.0*l+1); - delete[] tmp1; - delete[] tmp2; - } - */ //previous version double* integrated_func = new double[kmesh]; -// double* jl = new double[kmesh]; - const vector> &jlm1 = pSB->get_jlx()[l-1]; const vector> &jl = pSB->get_jlx()[l]; const vector> &jlp1 = pSB->get_jlx()[l+1]; for (int ir = 0; ir < rmesh; ir++) { -// ZEROS(integrated_func,kmesh); -// ZEROS(jl,kmesh); - // Generate Spherical Bessel Function -// Mathzone::Spherical_Bessel(this->kmesh,this->kpoint,this->r[ir], l, jl); - const vector &jl_r = jl[ir]; for (int ik=0; ik 0) - { - // ZEROS(jl,kmesh); - // Mathzone::Spherical_Bessel(this->kmesh,this->kpoint,this->r[ir], l-1, jl); - - const vector &jlm1_r = jlm1[ir]; - for (int ik=0; ikkmesh,this->kpoint,this->r[ir], l+1, jl); - - const vector &jlp1_r = jlp1[ir]; - for (int ik=0; ik &jlm1_r = jlm1[ir]; const vector &jlp1_r = jlp1[ir]; @@ -295,7 +217,6 @@ void Make_Overlap_Table::cal_ST_Phi12_R integrated_func[ik] = (jlp1_r[ik]-fac*jlm1_r[ik]) * k1_dot_k2_dot_kpoint[ik]; } } -// Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp); Mathzone::Simpson_Integral(kmesh,integrated_func,dk,temp); drs[ir] = -FOUR_PI*(l+1)/(2.0*l+1) * temp; } @@ -319,137 +240,15 @@ void Make_Overlap_Table::cal_ST_Phi12_R rs[0] = FOUR_PI / Mathzone_Add1::dualfac (2*l+1) * temp; } -// delete [] jl; delete [] integrated_func; delete [] k1_dot_k2; delete [] k1_dot_k2_dot_kpoint; - /* - double* integrated_func1 = new double[kmesh]; - double* integrated_func2 = new double[kmesh]; - - for (int ir = 0; ir < rmesh; ir++) - { - ZEROS(integrated_func1, kmesh); - ZEROS(integrated_func2, kmesh); -// ZEROS(jl, kmesh); -// ZEROS(djldr, kmesh); - - // Generate Spherical Bessel Function -// Mathzone::Spherical_Bessel(this->kmesh,this->kpoint,this->r[ir], l, jl, djldr); - for (int ik = 0; ik < kmesh; ik++) - { - integrated_func1[ik] = this->jlx[ik][ir][l] * k1_dot_k2[ik]; - integrated_func2[ik] = this->djlx[ik][ir][l] * k1_dot_k2[ik] * this->kpoint[ik]; - } - // Call simpson integration - Mathzone::Simpson_Integral(kmesh,integrated_func1,kab,rs[ir]); - Mathzone::Simpson_Integral(kmesh,integrated_func2,kab,drs[ir]); - - rs[ir] *= FOUR_PI; - drs[ir] *= FOUR_PI; - } - - - delete[] integrated_func1; - delete[] integrated_func2; -// delete[] jl; - */ - timer::tick("Make_Overlap_Table", "cal_ST_Phi12_R"); return; } -/* -// Peize Lin add 2017-10-13 -void Make_Overlap_Table::cal_ST_Phi12_R -( - const int &job, - const int &l, - const Numerical_Orbital_Lm &n1, - const Numerical_Orbital_Lm &n2, - const set &radials, - double* rs, - double* drs -) const -{ -// TITLE("Make_Overlap_Table","cal_ST_Phi12_R"); - timer::tick("Make_Overlap_Table", "cal_ST_Phi12_R"); - - vector k1_dot_k2(kmesh); - switch(job) - { - case 1: // calculate overlap - for (int ik = 0; ik < kmesh; ik++) - k1_dot_k2[ik] = n1.getPsi_k(ik) * n2.getPsi_k(ik); - break; - - case 2: // calculate kinetic energy - for (int ik = 0; ik < kmesh; ik++) - k1_dot_k2[ik] = n1.getPsi_k(ik) * n2.getPsi_k(ik) * this->kpoint[ik] * this->kpoint[ik]; - break; - } - - vector k1_dot_k2_dot_kpoint(kmesh); - for (int ik = 0; ik < kmesh; ik++) - k1_dot_k2_dot_kpoint[ik] = k1_dot_k2[ik] * this->kpoint[ik]; - - - vector integrated_func(kmesh); - - const vector> &jlm1 = pSB->get_jlx()[l-1]; - const vector> &jl = pSB->get_jlx()[l]; - const vector> &jlp1 = pSB->get_jlx()[l+1]; - - for( const size_t &ir : radials ) - { - // if(rs[ir]) => rs[ir] has been calculated - // if(drs[ir]) => drs[ir] has been calculated - // Actually, if(ir[ir]||dr[ir]) is enough. Double insurance for the sake of avoiding numerical errors - if( rs[ir] && drs[ir] ) continue; - - const vector &jl_r = jl[ir]; - for (int ik=0; ik &jlm1_r = jlm1[ir]; - const vector &jlp1_r = jlp1[ir]; - const double fac = l/(l+1.0); - if( l==0 ) - for (int ik=0; ik 0) - { - if( radials.find(0)!=radials.end() ) - { - for (int ik = 0; ik < kmesh; ik++) - integrated_func[ik] = k1_dot_k2[ik] * pow (kpoint[ik], l); - double temp = 0.0; - // Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp); - Mathzone::Simpson_Integral(kmesh,VECTOR_TO_PTR(integrated_func),dk,temp); - rs[0] = FOUR_PI / Mathzone_Add1::dualfac (2*l+1) * temp; - } - } - - timer::tick("Make_Overlap_Table", "cal_ST_Phi12_R"); - - return; -} -*/ // Peize Lin add 2017-10-27 void Make_Overlap_Table::cal_ST_Phi12_R @@ -1200,8 +999,6 @@ void Make_Overlap_Table::init_OV_Tpair(void) this->OV_Tpair.create(ntype, ntype); this->OV_L2plus1.create(ntype, ntype); // mohan fix bug 2011-03-14 -// OUT(ofs_running,"Number of type pairs",this->OV_nTpairs); - int index = 0; for (int T1 = 0; T1 < ntype ; T1++) { @@ -1432,45 +1229,6 @@ void Make_Overlap_Table::init_Lmax (const int orb_num, const int mode, int &Lmax break; } -/* if( mode==1 || mode==2) - { - //obtain maxL of all type - - const int ntype = ORB.get_ntype(); - for (int it = 0; it < ntype; it++) - { - const int Lmax_now = ORB.Phi[it].getLmax (); - Lmax = max(Lmax, Lmax_now); - } - - if(mode==1) - { - // fix bug. - // mohan add the nonlocal part. - // 2011-03-07 - for(int it=0; it< ntype; it++) - { - const int Lmax_now = ORB.Beta[it].getLmax(); - Lmax = max(Lmax, Lmax_now); - } - } - - //use 2lmax+1 in dS - Lmax_used = 2*Lmax + 1; - - // Peize Lin add 2016-01-26 - if(mode==2) - { - Lmax = max(Lmax, Use_Psi3_Center2::exx_ri_lmax); - Lmax_used += Use_Psi3_Center2::exx_ri_lmax; - } - } - else if( mode==3 ) - { - Lmax = Use_Psi3_Center2::exx_ri_lmax; - Lmax_used = 2*Lmax + 1; - }*/ - assert(Lmax_used >= 1); } @@ -1482,11 +1240,14 @@ void Make_Overlap_Table::init_Table_Spherical_Bessel (const int orb_num, const i this->init_Lmax (orb_num,mode,Lmax_used,Lmax); // Peize Lin add 2016-01-26 for( auto & sb : Sph_Bessel_Recursive_Pool::D2::sb_pool ) + { if( this->dr * this->dk == sb.get_dx() ) { pSB = &sb; break; } + } + if(!pSB) { Sph_Bessel_Recursive_Pool::D2::sb_pool.push_back({}); From d4aeb86d9299a5327463364827817c1206d22611 Mon Sep 17 00:00:00 2001 From: mohan Date: Sat, 6 Mar 2021 21:47:07 +0800 Subject: [PATCH 176/233] divide ORB_radial_table into ORB_table_phi and ORB_table_beta --- ABACUS.develop/source/Makefile.Objects | 3 +- .../source/src_io/cal_r_overlap_R.h | 2 +- .../source/src_io/unk_overlap_lcao.h | 2 +- .../source/src_lcao/ORB_control.cpp | 2 +- .../source/src_lcao/ORB_gen_tables.cpp | 95 ++-- .../source/src_lcao/ORB_gen_tables.h | 4 +- .../source/src_lcao/ORB_table_beta.cpp | 451 ++++++++++++++++++ .../source/src_lcao/ORB_table_beta.h | 74 +++ ...ORB_radial_table.cpp => ORB_table_phi.cpp} | 393 +-------------- .../{ORB_radial_table.h => ORB_table_phi.h} | 35 +- .../source/src_lcao/center2_orb-orb11.h | 2 +- .../source/src_lcao/center2_orb-orb21.h | 2 +- .../source/src_lcao/center2_orb-orb22.h | 4 +- .../exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h | 2 +- .../source/src_ri/exx_abfs-matrix_orbs11.h | 2 +- .../source/src_ri/exx_abfs-matrix_orbs21.h | 2 +- .../source/src_ri/exx_abfs-matrix_orbs22.h | 2 +- 17 files changed, 580 insertions(+), 497 deletions(-) create mode 100644 ABACUS.develop/source/src_lcao/ORB_table_beta.cpp create mode 100644 ABACUS.develop/source/src_lcao/ORB_table_beta.h rename ABACUS.develop/source/src_lcao/{ORB_radial_table.cpp => ORB_table_phi.cpp} (67%) rename ABACUS.develop/source/src_lcao/{ORB_radial_table.h => ORB_table_phi.h} (76%) diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index f14c5b94b9..66a004ddb4 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -127,7 +127,8 @@ ORB_atomic_lm.o\ ORB_nonlocal.o\ ORB_nonlocal_lm.o\ ORB_gaunt_table.o\ -ORB_radial_table.o\ +ORB_table_beta.o\ +ORB_table_phi.o\ ORB_gen_tables.o\ local_orbital_wfc.o\ local_orbital_elec.o\ diff --git a/ABACUS.develop/source/src_io/cal_r_overlap_R.h b/ABACUS.develop/source/src_io/cal_r_overlap_R.h index 4464e55353..05a4ae4334 100644 --- a/ABACUS.develop/source/src_io/cal_r_overlap_R.h +++ b/ABACUS.develop/source/src_io/cal_r_overlap_R.h @@ -12,7 +12,7 @@ using std::set; #include "src_lcao/center2_orb-orb11.h" #include "src_lcao/center2_orb-orb21.h" -#include "src_lcao/ORB_radial_table.h" +#include "src_lcao/ORB_table_phi.h" #include "src_lcao/ORB_gaunt_table.h" #include "src_lcao/ORB_atomic_lm.h" #include "src_lcao/ORB_read.h" diff --git a/ABACUS.develop/source/src_io/unk_overlap_lcao.h b/ABACUS.develop/source/src_io/unk_overlap_lcao.h index e7dc7a0c16..b495ed69eb 100644 --- a/ABACUS.develop/source/src_io/unk_overlap_lcao.h +++ b/ABACUS.develop/source/src_io/unk_overlap_lcao.h @@ -12,7 +12,7 @@ using std::set; #include "src_lcao/center2_orb-orb11.h" #include "src_lcao/center2_orb-orb21.h" -#include "src_lcao/ORB_radial_table.h" +#include "src_lcao/ORB_table_phi.h" #include "src_lcao/ORB_gaunt_table.h" #include "src_lcao/ORB_atomic_lm.h" #include "src_lcao/ORB_read.h" diff --git a/ABACUS.develop/source/src_lcao/ORB_control.cpp b/ABACUS.develop/source/src_lcao/ORB_control.cpp index 7206eed0e8..9be615436f 100644 --- a/ABACUS.develop/source/src_lcao/ORB_control.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_control.cpp @@ -56,6 +56,6 @@ void ORB_control::clear_after_ions() { TITLE("ORB_control","clear_after_ions"); UOT.MOT.Destroy_Table(); - UOT.MOT.Destroy_Table_Beta(); + UOT.tbeta.Destroy_Table_Beta(); return; } diff --git a/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp b/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp index 26a8298f0d..cda7c3d225 100644 --- a/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp @@ -28,27 +28,21 @@ void ORB_gen_tables::gen_tables( const int &job0 ) ORB.get_dR(),// delta R, for making radial table ORB.get_dk() ); // delta k, for integration in k space + tbeta.allocate( + ORB.get_ntype(),// number of atom types + ORB.get_lmax(),// max L used to calculate overlap + ORB.get_kmesh(), // kpoints, for integration in k space + ORB.get_Rmax(),// max value of radial table + ORB.get_dR(),// delta R, for making radial table + ORB.get_dk() ); // delta k, for integration in k space + // OV: overlap MOT.init_OV_Tpair(); MOT.init_OV_Opair(); // NL: nonlocal - MOT.init_NL_Tpair(); - MOT.init_NL_Opair(); // add 2009-5-8 - - // mohan comment out 2021-02-09 - // if we decompose the VNA into projectors, - // we need to prepare for the vna table. - //if(VNA==-1) - //{ - // MVT.allocate( - // ORB.get_ntype(),// number of atom types - // ORB.get_lmax(),// max L used to calculate overlap - // ORB.get_kmesh(), // kpoints, for integration in k space - // ORB.get_Rmax(),// max value of radial table - // ORB.get_dR(),// delta R, for making radial table - // ORB.get_dk() ); // delta k, for integration in k space - //} + tbeta.init_NL_Tpair(); + tbeta.init_NL_Opair(); // add 2009-5-8 //========================================= @@ -63,7 +57,7 @@ void ORB_gen_tables::gen_tables( const int &job0 ) //calculate S(R) for interpolation MOT.init_Table(job0); - MOT.init_Table_Beta();// add 2009-5-8 + tbeta.init_Table_Beta( MOT.pSB );// add 2009-5-8 //========================================= // (3) make Gaunt coefficients table @@ -141,8 +135,8 @@ void ORB_gen_tables::snap_psibeta( all_out = false; calproj[ip] = true; //length of table for interpolation - rmesh1[ip] = this->MOT.get_rmesh(Rcut1, Rcut0); - rmesh2[ip] = this->MOT.get_rmesh(Rcut2, Rcut0); + rmesh1[ip] = tbeta.get_rmesh(Rcut1, Rcut0); + rmesh2[ip] = tbeta.get_rmesh(Rcut2, Rcut0); } } @@ -174,7 +168,7 @@ void ORB_gen_tables::snap_psibeta( return x1*x2*(table[iq]*x3+table[iq+3]*x0)/6.0 + x0*x3*(table[iq+1]*x2-table[iq+2]*x1)/2.0; */ - psa = distance10 / MOT.dr; + psa = distance10 / tbeta.dr; iqa = static_cast(psa); x0a = psa - static_cast(iqa); x1a = 1.0 - x0a; @@ -185,7 +179,7 @@ void ORB_gen_tables::snap_psibeta( x032a = x0a*x3a*x2a/2.0; x031a = x0a*x3a*x1a/2.0; - psb = distance20 / MOT.dr; + psb = distance20 / tbeta.dr; iqb = (int) psb; x0b = psb - (double)iqb ; x1b = 1.0 - x0b; @@ -219,10 +213,10 @@ void ORB_gen_tables::snap_psibeta( // Notice!!! T1 must be orbital, // T0 must be nonlocal orbital // usage : pairs_nonlocal_type(T1 : orbital, T0 : projector); - const int Tpair1 = this->MOT.NL_Tpair(T1, T0); - const int Tpair2 = this->MOT.NL_Tpair(T2, T0); - const int T1_2Lplus1 = this->MOT.NL_L2plus1(T1, T0); - const int T2_2Lplus1 = this->MOT.NL_L2plus1(T2, T0); + const int Tpair1 = tbeta.NL_Tpair(T1, T0); + const int Tpair2 = tbeta.NL_Tpair(T2, T0); + const int T1_2Lplus1 = tbeta.NL_L2plus1(T1, T0); + const int T2_2Lplus1 = tbeta.NL_L2plus1(T2, T0); //gaunt index const int gindex1 = L1*L1+m1; @@ -257,9 +251,9 @@ void ORB_gen_tables::snap_psibeta( //const int next_ip = 2* L0 +1; // - const int Opair1 = this->MOT.NL_Opair(Tpair1, L1, N1, nb); + const int Opair1 = tbeta.NL_Opair(Tpair1, L1, N1, nb); // - const int Opair2 = this->MOT.NL_Opair(Tpair2, L2, N2, nb); + const int Opair2 = tbeta.NL_Opair(Tpair2, L2, N2, nb); for(int m0=0; m0<2*L0+1; m0++) @@ -289,9 +283,7 @@ void ORB_gen_tables::snap_psibeta( double Interp_Vnla = 0.0; if (distance10 > tiny2) { - //Interp_Vnla = i_exp * Mathzone::Polynomial_Interpolation( - //this->MOT.Table_NR[0][Tpair1][Opair1][L], rmesh1, this->MOT.dr, distance10); - curr = this->MOT.Table_NR[0][Tpair1][Opair1][L]; + curr = tbeta.Table_NR[0][Tpair1][Opair1][L]; if( iqa >= rmesh1[nb]-4) { Interp_Vnla = 0.0; @@ -304,7 +296,7 @@ void ORB_gen_tables::snap_psibeta( } else { - Interp_Vnla = i_exp * this->MOT.Table_NR[0][Tpair1][Opair1][L][0]; + Interp_Vnla = i_exp * tbeta.Table_NR[0][Tpair1][Opair1][L][0]; } //------------------------------------------ @@ -368,9 +360,7 @@ void ORB_gen_tables::snap_psibeta( double rl2 = pow (distance20, L); if (distance20 > tiny2) { - //Interp_Vnlb = i_exp * Mathzone::Polynomial_Interpolation( - //this->MOT.Table_NR[0][Tpair2][Opair2][L], rmesh2, this->MOT.dr, distance20); - curr = this->MOT.Table_NR[0][Tpair2][Opair2][L]; + curr = tbeta.Table_NR[0][Tpair2][Opair2][L]; if( iqb >= rmesh2[nb]-4) Interp_Vnlb = 0.0; else Interp_Vnlb = i_exp * (x123b*curr[iqb]+x120b*curr[iqb+3]+x032b*curr[iqb+1]-curr[iqb+2]*x031b); @@ -379,7 +369,7 @@ void ORB_gen_tables::snap_psibeta( } else { - Interp_Vnlb = i_exp * this->MOT.Table_NR[0][Tpair2][Opair2][L][0]; + Interp_Vnlb = i_exp * tbeta.Table_NR[0][Tpair2][Opair2][L][0]; } @@ -387,10 +377,7 @@ void ORB_gen_tables::snap_psibeta( { if (distance20 > tiny2) { - //Interp_Vnlc = i_exp * Mathzone::Polynomial_Interpolation( - //this->MOT.Table_NR[1][Tpair2][Opair2][L], rmesh2, this->MOT.dr, distance20); - - curr = this->MOT.Table_NR[1][Tpair2][Opair2][L]; + curr = tbeta.Table_NR[1][Tpair2][Opair2][L]; if( iqb >= rmesh2[nb]-4) Interp_Vnlc = 0.0; else Interp_Vnlc = i_exp * (x123b*curr[iqb]+x120b*curr[iqb+3]+x032b*curr[iqb+1]-curr[iqb+2]*x031b); @@ -441,10 +428,6 @@ void ORB_gen_tables::snap_psibeta( term_b_nc[ip] = term_b; } - - - - //=============================================== // THIRD PART: SUM THE VALUE FROM ALL PROJECTS. //=============================================== @@ -454,14 +437,6 @@ void ORB_gen_tables::snap_psibeta( { //nlm[0] += term_a * term_b * ORB.Beta[T0].getCoefficient_D(L0, L0);//LiuXh 2016-01-14 if(!has_so) nlm[0] += term_a * term_b * ORB.Beta[T0].getCoefficient_D(nb, nb);//LiuXh 2016-01-14 -/* else if(nlm1!=NULL) - { - - } - else - { - WARNING_QUIT("ORB_gen_tables::snap_psibeta","something wrong with snap_psibeta."); - }*/ break; } case 1: //calculate the derivative part. @@ -469,7 +444,10 @@ void ORB_gen_tables::snap_psibeta( for(int jr = 0; jr < 3; jr++) { //nlm[jr] += term_c[jr] * term_a * ORB.Beta[T0].getCoefficient_D(L0, L0);//LiuXh 2016-01-14 - if(!has_so) nlm[jr] += term_c[jr] * term_a * ORB.Beta[T0].getCoefficient_D(nb, nb);//LiuXh 2016-01-14 + if(!has_so) + { + nlm[jr] += term_c[jr] * term_a * ORB.Beta[T0].getCoefficient_D(nb, nb);//LiuXh 2016-01-14 + } else { @@ -484,13 +462,6 @@ void ORB_gen_tables::snap_psibeta( //zhengdy-soc, calculate non-local term if(has_so) { - /*for(int p1=0;p1 +#include "../src_ri/exx_abfs.h" + +double ORB_table_beta::dr = -1.0; + +ORB_table_beta::ORB_table_beta() +{ + destroy_nr = false; + + ntype = 0; + lmax = 0; + kmesh = 0; + Rmax = 0.0; + dr = 0.0; + dk = 0.0; + + nlm = 0; + Rmesh = 0; + + kpoint = new double[1]; + r=new double[1]; + rab=new double[1]; + kab=new double[1]; +} + +ORB_table_beta::~ORB_table_beta() +{ + delete[] kpoint; + delete[] r; + delete[] rab; + delete[] kab; +} + +void ORB_table_beta::allocate +( + const int &ntype_in, + const int &lmax_in, + const int &kmesh_in, + const double &Rmax_in, + const double &dr_in, + const double &dk_in +) +{ + TITLE("ORB_table_beta", "allocate"); + + this->ntype = ntype_in;// type of elements. + this->lmax = lmax_in; + this->kmesh = kmesh_in; + this->Rmax = Rmax_in; + this->dr = dr_in; + this->dk = dk_in; + + assert(ntype > 0); + assert(lmax >= 0); + assert(kmesh > 0.0); + assert(Rmax >= 0.0); + assert(dr>0.0); + assert(dk>0.0); + + // calculated from input parameters + this->nlm = (2*lmax+1) * (2*lmax+1); + this->Rmesh = static_cast( Rmax/dr ) + 4; + if(Rmesh%2==0) + { + ++Rmesh; + } + +// OUT(ofs_running,"lmax",lmax); +// OUT(ofs_running,"Rmax (Bohr)",Rmax); +// OUT(ofs_running,"dr (Bohr)",dr); +// OUT(ofs_running,"dk",dk); +// OUT(ofs_running,"nlm",nlm); +// OUT(ofs_running,"kmesh",kmesh); + + delete[] kpoint; + delete[] r; + kpoint = new double[kmesh]; + r = new double[Rmesh]; + + delete[] rab; + delete[] kab; + kab = new double[kmesh]; + rab = new double[Rmesh]; + + for (int ik = 0; ik < kmesh; ik++) + { + kpoint[ik] = ik * dk_in; + kab[ik] = dk_in; + } + + for (int ir = 0; ir < Rmesh; ir++) + { + r[ir] = ir * dr; + rab[ir] = dr; + } + +// OUT(ofs_running,"allocate kpoint, r, rab, kab","Done"); + return; +} + + +int ORB_table_beta::get_rmesh(const double &R1, const double &R2) +{ + int rmesh = static_cast((R1+R2)/ ORB_table_beta::dr) + 5; + //mohan update 2009-09-08 +1 ==> +5 + //considering interpolation or so on... + if (rmesh % 2 == 0) rmesh ++; + + if(rmesh <= 0) + { + ofs_warning << "\n R1 = " << R1 << " R2 = " << R2; + ofs_warning << "\n rmesh = " << rmesh; + WARNING_QUIT("ORB_table_beta::get_rmesh", "rmesh <= 0"); + } + return rmesh; +} + + + +void ORB_table_beta::cal_VNL_PhiBeta_R( + Sph_Bessel_Recursive::D2 *pSB, // mohan add 2021-03-06 + const int &l, + const Numerical_Orbital_Lm &n1, + const Numerical_Nonlocal_Lm &n2, + const int &rmesh, + double *rs, + double *drs) +{ + timer::tick ("ORB_table_beta", "VNL_PhiBeta_R"); + + assert(kmesh > 0); + + //start calc + double *k1_dot_k2 = new double[kmesh]; + + for (int ik = 0; ik < kmesh; ik++) + { + k1_dot_k2[ik] = n1.getPsi_k(ik) * n2.getBeta_k(ik); + } + + //previous version + double* integrated_func = new double[kmesh]; + + const vector> &jlm1 = pSB->get_jlx()[l-1]; + const vector> &jl = pSB->get_jlx()[l]; + const vector> &jlp1 = pSB->get_jlx()[l+1]; + for (int ir = 0; ir < rmesh; ir++) + { + ZEROS(integrated_func,kmesh); + double temp = 0.0; + + for (int ik = 0; ik < kmesh; ik++) + { + integrated_func[ik] = jl[ir][ik] * k1_dot_k2[ik]; + } + // Call simpson integration + Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp); + rs[ir] = temp * FOUR_PI; + + //drs + double temp1, temp2; + + if (l > 0) + { + for (int ik = 0; ik < kmesh; ik++) + { + integrated_func[ik] = jlm1[ir][ik] * k1_dot_k2[ik] * kpoint[ik]; + } + + Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp1); + } + + + for (int ik = 0; ik < kmesh; ik++) + { + integrated_func[ik] = jlp1[ir][ik] * k1_dot_k2[ik] * kpoint[ik]; + } + + Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp2); + + if (l == 0) + { + drs[ir] = -FOUR_PI*temp2; + } + else + { + drs[ir] = FOUR_PI*(temp1*l-(l+1)*temp2)/(2.0*l+1); + } + } + + //liaochen modify on 2010/4/22 + //special case for R=0 + //we store Slm(R) / R**l at the fisrt point, rather than Slm(R) + if (l > 0) + { + ZEROS(integrated_func,kmesh); + double temp = 0.0; + + for (int ik = 0; ik < kmesh; ik++) + { + integrated_func[ik] = k1_dot_k2[ik] * pow (kpoint[ik], l); + } + + // Call simpson integration + Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp); + rs[0] = FOUR_PI / Mathzone_Add1::dualfac (2*l+1) * temp; + } + + delete [] integrated_func; + + + delete[] k1_dot_k2; + timer::tick ("ORB_table_beta", "VNL_PhiBeta_R"); + return; +} + + +void ORB_table_beta::init_Table_Beta(Sph_Bessel_Recursive::D2 *pSB) +{ + TITLE("ORB_table_beta", "init_Table_Beta"); + timer::tick("ORB_table_beta", "init_Table_Beta",'D'); + + // (1) allocate 1st dimension ( overlap, derivative) + this->Table_NR = new double****[2]; + // (2) allocate 2nd dimension ( overlap, derivative) + this->Table_NR[0] = new double*** [this->NL_nTpairs]; + this->Table_NR[1] = new double*** [this->NL_nTpairs]; + + + // <1Phi|2Beta> + for (int T1 = 0; T1 < ntype ; T1++) // type 1 is orbital + { + for (int T2 = 0 ; T2 < ntype ; T2++)// type 2 is non-local projector + { + // Tpair: type pair. + const int Tpair=this->NL_Tpair(T1,T2); + const int Lmax1 = ORB.Phi[T1].getLmax(); + + const int NBeta = ORB.nproj[T2]; + + //------------------------------------------------------------- + // how many + // here we count all possible psi with (L,N) index for type T1. + //------------------------------------------------------------- + const int pairs_chi = ORB.Phi[T1].getTotal_nchi() * NBeta; + + // CAUTION!!! + // no matter nchi = 0 or NBeta = 0, + // means the Tpair in this table is never used! + if(pairs_chi == 0)continue; + + // init 2nd dimension + this->Table_NR[0][Tpair] = new double** [ pairs_chi ]; + this->Table_NR[1][Tpair] = new double** [ pairs_chi ]; + + const int T12_2Lplus1 = this->NL_L2plus1(T1,T2); + + const double Rcut1 = ORB.Phi[T1].getRcut(); + for (int L1 = 0; L1 < Lmax1 + 1; L1++) + { + for (int N1 = 0; N1 < ORB.Phi[T1].getNchi(L1); N1++) + { + + // number of projectors. + for (int nb = 0; nb < NBeta; nb ++) + { + const int L2 = ORB.Beta[T2].getL_Beta(nb); + + const double Rcut2 = ORB.Beta[T2].Proj[nb].getRcut(); + + const int Opair = this->NL_Opair(Tpair,L1,N1,nb); + assert( Opair < pairs_chi ); + + // init 3rd dimension + this->Table_NR[0][ Tpair ][ Opair ] = new double *[T12_2Lplus1]; + this->Table_NR[1][ Tpair ][ Opair ] = new double *[T12_2Lplus1]; + + const int rmesh = this->get_rmesh( Rcut1, Rcut2); + assert( rmesh < this->Rmesh ); + + //not all L in T12_2Lplus1 would function + const int SL = abs(L1-L2); + const int AL = L1+L2; + + for (int L=0; L < T12_2Lplus1 ; L++) + { + //Allocation + this->Table_NR[0][Tpair][Opair][L] = new double[rmesh]; + this->Table_NR[1][Tpair][Opair][L] = new double[rmesh]; + + Memory::record("ORB_table_beta","Table_NR", + 2*NL_nTpairs*pairs_chi*rmesh,"double"); + + //for those L whose Gaunt Coefficients = 0, we + //assign every element in Table_NR as zero + if ((L > AL) || (L < SL) || ((L-SL) % 2 == 1)) + { + ZEROS (Table_NR[0][Tpair][Opair][L], rmesh); + ZEROS (Table_NR[1][Tpair][Opair][L], rmesh); + + continue; + } + + assert(nb < ORB.nproj[T2]); + this->cal_VNL_PhiBeta_R( + pSB, // mohan add 2021-03-06 + L, + ORB.Phi[T1].PhiLN(L1,N1), + ORB.Beta[T2].Proj[nb], // mohan update 2011-03-07 + rmesh, + this->Table_NR[0][Tpair][Opair][L], + this->Table_NR[1][Tpair][Opair][L]); + }// end T12_2Lplus1 + }// end L2 + }// end N1 + }// end L1 + }// end T2 + }// end T1 + destroy_nr = true; + + +// OUT(ofs_running,"allocate non-local potential matrix","Done"); + timer::tick("ORB_table_beta", "init_Table_Beta",'D'); + return; +} + + +void ORB_table_beta::Destroy_Table_Beta(void) +{ + if(!destroy_nr) return; + + const int ntype = ORB.get_ntype(); + for(int ir = 0; ir < 2; ir ++) + { + for(int T1=0; T1NL_Tpair(T1,T2); + const int L2plus1 = this->NL_L2plus1(T1,T2); + const int pairs = ORB.Phi[T1].getTotal_nchi() * ORB.nproj[T2]; + + // mohan fix bug 2011-03-30 + if(pairs ==0) continue; + for(int dim2=0; dim20); + this->NL_nTpairs = this->ntype * this->ntype; + this->NL_Tpair.create( this->ntype, this->ntype); + this->NL_L2plus1.create( this->ntype, this->ntype); // mohan fix bug 2011-03-14 + +// OUT(ofs_running,"Number of Nonlocal Pairs",NL_nTpairs); + + int index = 0; + for (int T1 = 0; T1 < ntype ; T1++) + { + for (int T0 = 0 ; T0 < ntype ; T0++) + { + this->NL_Tpair(T1,T0) = index; + ++index; + + // the pair < psi | beta > + // be careful! This is not a symmetry matrix. + this->NL_L2plus1(T1,T0) = std::max(ORB.Phi[T1].getLmax(), ORB.Beta[T0].getLmax() )*2+1; + + // there are special situations: + // for example, two H atom without projector. + // if we use s orbital, + // Phi.getLmax = 0, + // Beta.getLmax < 0, + // so the value is 1. + // however, there are no projectors. + if(NL_L2plus1(T1,T0) <= 0) + { + WARNING_QUIT("ORB_table_beta::init_paris_nonlocal_type","NL_L2plus1<=0"); + } + } + } + return; +} + + + +void ORB_table_beta::init_NL_Opair(void) +{ + const int lmax = ORB.get_lmax(); + const int nchimax = ORB.get_nchimax(); + const int nprojmax = ORB.nprojmax; + + // may have bug if we use all H! + if( nprojmax == 0) + { + WARNING("ORB_table_beta","nproj for nonlocal pseudopotetials are zero, it must be all H atoms"); + return; + } + assert( NL_nTpairs > 0); + + this->NL_Opair.create( this->NL_nTpairs, lmax+1, nchimax, nprojmax); + + // <1psi|2beta> + // 1. orbital + for(int T1=0; T1NL_Tpair(T1, T0); + int index = 0; + for(int L1=0; L1NL_Opair(nlpair, L1, N1, ip) = index; + ++index; + } + } + } + } + } + + return; +} diff --git a/ABACUS.develop/source/src_lcao/ORB_table_beta.h b/ABACUS.develop/source/src_lcao/ORB_table_beta.h new file mode 100644 index 0000000000..17488fe18e --- /dev/null +++ b/ABACUS.develop/source/src_lcao/ORB_table_beta.h @@ -0,0 +1,74 @@ +#ifndef ORB_TABLE_BETA_H +#define ORB_TABLE_BETA_H + +#include "src_pw/tools.h" +#include "ORB_atomic.h" +#include "ORB_atomic_lm.h" +#include "ORB_nonlocal.h" +#include "ORB_nonlocal_lm.h" +#include "ORB_gaunt_table.h" +#include "src_global/sph_bessel_recursive.h" + +class ORB_table_beta +{ + public: + + ORB_table_beta(); + ~ORB_table_beta(); + + void allocate ( + const int &ntype, + const int &lmax_in, + const int &kmesh_in, + const double &Rmax_in, + const double &dR_in, + const double &dk_in); + + double***** Table_NR; + bool destroy_nr; + + //------------------------- + // NL stands for 'nonlocal' + // T stands for atom type. + // O stands for orbitals. + //------------------------- + void init_NL_Tpair(void); + void init_NL_Opair(void); + int NL_nTpairs; + IntArray NL_Tpair; + IntArray NL_Opair; + IntArray NL_L2plus1; + + void init_Table_Beta(Sph_Bessel_Recursive::D2 *pSB); + + void Destroy_Table_Beta(void); + + static int get_rmesh( const double &R1, const double &R2); + + static double dr; + int Rmesh; + + private: + + void cal_VNL_PhiBeta_R( + Sph_Bessel_Recursive::D2 *pSB, // mohan add 2021-03-06 + const int &l, + const Numerical_Orbital_Lm &n1, + const Numerical_Nonlocal_Lm &n2, + const int &rmesh, + double *rs, + double *drs); + + // variables + int ntype; + int lmax; + double Rmax; + double dk; + int nlm; + int kmesh; + double *kpoint; + double *r; + double *rab; + double *kab; +}; +#endif diff --git a/ABACUS.develop/source/src_lcao/ORB_radial_table.cpp b/ABACUS.develop/source/src_lcao/ORB_table_phi.cpp similarity index 67% rename from ABACUS.develop/source/src_lcao/ORB_radial_table.cpp rename to ABACUS.develop/source/src_lcao/ORB_table_phi.cpp index b50a0a1dbd..9791c8bdc4 100644 --- a/ABACUS.develop/source/src_lcao/ORB_radial_table.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_table_phi.cpp @@ -1,6 +1,5 @@ -#include "ORB_radial_table.h" +#include "ORB_table_phi.h" #include "ORB_read.h" - #include #include "../src_ri/exx_abfs.h" @@ -10,7 +9,6 @@ Make_Overlap_Table::Make_Overlap_Table() { destroy_sr = false; destroy_tr = false; - destroy_nr = false; ntype = 0; lmax = 0; @@ -373,169 +371,6 @@ void Make_Overlap_Table::cal_ST_Phi12_R } -void Make_Overlap_Table::cal_VNL_PhiBeta_R( - const int &l, - const Numerical_Orbital_Lm &n1, - const Numerical_Nonlocal_Lm &n2, - const int &rmesh, - double *rs, - double *drs) -{ - timer::tick ("Make_Overlap_Table", "VNL_PhiBeta_R"); - - assert(kmesh > 0); - - //start calc - double *k1_dot_k2 = new double[kmesh]; - - for (int ik = 0; ik < kmesh; ik++) - { - k1_dot_k2[ik] = n1.getPsi_k(ik) * n2.getBeta_k(ik); - } - -// Mathzone_Add1::Sbt_new (3, l, r, dr, rmesh, kpoint, dk, kmesh, k1_dot_k2, 2, rs); -// for (int ir = 0; ir < rmesh; ir++) rs[ir] *= FOUR_PI; - - - //Drs - //djl = (l*j(l-1) - (l+1)j(l+1))/(2l+1) - /* - if (l == 0) - { - double* tmp1 = new double[rmesh]; - ZEROS (tmp1, rmesh); - Mathzone_Add1::Sbt_new (3, 1, r, dr, rmesh, kpoint, dk, kmesh, k1_dot_k2, 1, tmp1); - for (int ir = 0; ir < rmesh; ir++) drs[ir] = -FOUR_PI*tmp1[ir]; - delete[] tmp1; - } - else - { - double* tmp1 = new double[rmesh]; - double* tmp2 = new double[rmesh]; - ZEROS (tmp1, rmesh); - ZEROS (tmp2, rmesh); - Mathzone_Add1::Sbt_new (3, l-1, r, dr, rmesh, kpoint, dk, kmesh, k1_dot_k2, 1, tmp1); - Mathzone_Add1::Sbt_new (3, l+1, r, dr, rmesh, kpoint, dk, kmesh, k1_dot_k2, 1, tmp2); - for (int ir = 0; ir < rmesh; ir++) drs[ir] = FOUR_PI*(l*tmp1[ir]-(l+1)*tmp2[ir])/(2.0*l+1); - delete[] tmp1; - delete[] tmp2; - } - */ - - //previous version - double* integrated_func = new double[kmesh]; -// double* jl = new double[kmesh]; - - const vector> &jlm1 = pSB->get_jlx()[l-1]; - const vector> &jl = pSB->get_jlx()[l]; - const vector> &jlp1 = pSB->get_jlx()[l+1]; - for (int ir = 0; ir < rmesh; ir++) - { - ZEROS(integrated_func,kmesh); -// ZEROS(jl,kmesh); - double temp = 0.0; - // Generate Spherical Bessel Function -// Mathzone::Spherical_Bessel(this->kmesh,this->kpoint,this->r[ir], l, jl); - - for (int ik = 0; ik < kmesh; ik++) - { - integrated_func[ik] = jl[ir][ik] * k1_dot_k2[ik]; - } - // Call simpson integration - Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp); - rs[ir] = temp * FOUR_PI; - - //drs - double temp1, temp2; - - if (l > 0) - { -// ZEROS(jl,kmesh); -// Mathzone::Spherical_Bessel(this->kmesh,this->kpoint,this->r[ir], l-1, jl); - - for (int ik = 0; ik < kmesh; ik++) - { - integrated_func[ik] = jlm1[ir][ik] * k1_dot_k2[ik] * kpoint[ik]; - } - - Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp1); - } - -// ZEROS(jl,kmesh); -// Mathzone::Spherical_Bessel(this->kmesh,this->kpoint,this->r[ir], l+1, jl); - - for (int ik = 0; ik < kmesh; ik++) - { - integrated_func[ik] = jlp1[ir][ik] * k1_dot_k2[ik] * kpoint[ik]; - } - - Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp2); - - if (l == 0) - { - drs[ir] = -FOUR_PI*temp2; - } - else - { - drs[ir] = FOUR_PI*(temp1*l-(l+1)*temp2)/(2.0*l+1); - } - } - - //liaochen modify on 2010/4/22 - //special case for R=0 - //we store Slm(R) / R**l at the fisrt point, rather than Slm(R) - if (l > 0) - { - ZEROS(integrated_func,kmesh); - double temp = 0.0; - - for (int ik = 0; ik < kmesh; ik++) - { - integrated_func[ik] = k1_dot_k2[ik] * pow (kpoint[ik], l); - } - - // Call simpson integration - Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp); - rs[0] = FOUR_PI / Mathzone_Add1::dualfac (2*l+1) * temp; - } - - delete [] integrated_func; -// delete [] jl; - - /* - double* integrated_func1 = new double[kmesh]; - double* integrated_func2 = new double[kmesh]; - - for (int ir = 0; ir < rmesh; ir++) - { - ZEROS(integrated_func1, kmesh); - ZEROS(integrated_func2, kmesh); -// ZEROS(jl, kmesh); -// ZEROS(djldr, kmesh); - - // Generate Spherical Bessel Function -// Mathzone::Spherical_Bessel(this->kmesh,this->kpoint,this->r[ir], l, jl, djldr); - for (int ik = 0; ik < kmesh; ik++) - { - integrated_func1[ik] = this->jlx[ik][ir][l] * k1_dot_k2[ik]; - integrated_func2[ik] = this->djlx[ik][ir][l] * k1_dot_k2[ik] * this->kpoint[ik]; - } - // Call simpson integration - Mathzone::Simpson_Integral(kmesh,integrated_func1,kab,rs[ir]); - Mathzone::Simpson_Integral(kmesh,integrated_func2,kab,drs[ir]); - - rs[ir] *= FOUR_PI; - drs[ir] *= FOUR_PI; - } - - delete [] integrated_func1; - delete [] integrated_func2; - */ - - delete[] k1_dot_k2; - timer::tick ("Make_Overlap_Table", "VNL_PhiBeta_R"); - return; -} void Make_Overlap_Table::init_Table( const int &job0 ) { @@ -800,113 +635,6 @@ void Make_Overlap_Table::init_Table( const int &job0 ) return; } -void Make_Overlap_Table::init_Table_Beta(void) -{ - TITLE("Make_Overlap_Table", "init_Table_Beta"); - timer::tick("Make_Overlap_Table", "init_Table_Beta",'D'); - - // (1) allocate 1st dimension ( overlap, derivative) - this->Table_NR = new double****[2]; - // (2) allocate 2nd dimension ( overlap, derivative) - this->Table_NR[0] = new double*** [this->NL_nTpairs]; - this->Table_NR[1] = new double*** [this->NL_nTpairs]; - - - // <1Phi|2Beta> - for (int T1 = 0; T1 < ntype ; T1++) // type 1 is orbital - { - for (int T2 = 0 ; T2 < ntype ; T2++)// type 2 is non-local projector - { - // Tpair: type pair. - const int Tpair=this->NL_Tpair(T1,T2); - const int Lmax1 = ORB.Phi[T1].getLmax(); - - const int NBeta = ORB.nproj[T2]; - - //------------------------------------------------------------- - // how many - // here we count all possible psi with (L,N) index for type T1. - //------------------------------------------------------------- - const int pairs_chi = ORB.Phi[T1].getTotal_nchi() * NBeta; - - // CAUTION!!! - // no matter nchi = 0 or NBeta = 0, - // means the Tpair in this table is never used! - if(pairs_chi == 0)continue; - - // init 2nd dimension - this->Table_NR[0][Tpair] = new double** [ pairs_chi ]; - this->Table_NR[1][Tpair] = new double** [ pairs_chi ]; - - const int T12_2Lplus1 = this->NL_L2plus1(T1,T2); - - const double Rcut1 = ORB.Phi[T1].getRcut(); - for (int L1 = 0; L1 < Lmax1 + 1; L1++) - { - for (int N1 = 0; N1 < ORB.Phi[T1].getNchi(L1); N1++) - { - - // number of projectors. - for (int nb = 0; nb < NBeta; nb ++) - { - const int L2 = ORB.Beta[T2].getL_Beta(nb); - - const double Rcut2 = ORB.Beta[T2].Proj[nb].getRcut(); - - const int Opair = this->NL_Opair(Tpair,L1,N1,nb); - assert( Opair < pairs_chi ); - - // init 3rd dimension - this->Table_NR[0][ Tpair ][ Opair ] = new double *[T12_2Lplus1]; - this->Table_NR[1][ Tpair ][ Opair ] = new double *[T12_2Lplus1]; - - const int rmesh = this->get_rmesh( Rcut1, Rcut2); - assert( rmesh < this->Rmesh ); - - //not all L in T12_2Lplus1 would function - const int SL = abs(L1-L2); - const int AL = L1+L2; - - for (int L=0; L < T12_2Lplus1 ; L++) - { - //Allocation - this->Table_NR[0][Tpair][Opair][L] = new double[rmesh]; - this->Table_NR[1][Tpair][Opair][L] = new double[rmesh]; - - Memory::record("Make_Overlap_Table","Table_NR", - 2*NL_nTpairs*pairs_chi*rmesh,"double"); - - //for those L whose Gaunt Coefficients = 0, we - //assign every element in Table_NR as zero - if ((L > AL) || (L < SL) || ((L-SL) % 2 == 1)) - { - ZEROS (Table_NR[0][Tpair][Opair][L], rmesh); - ZEROS (Table_NR[1][Tpair][Opair][L], rmesh); - - continue; - } - - assert(nb < ORB.nproj[T2]); - this->cal_VNL_PhiBeta_R(L, - ORB.Phi[T1].PhiLN(L1,N1), - ORB.Beta[T2].Proj[nb], // mohan update 2011-03-07 - rmesh, - this->Table_NR[0][Tpair][Opair][L], - this->Table_NR[1][Tpair][Opair][L]); - }// end T12_2Lplus1 - }// end L2 - }// end N1 - }// end L1 - }// end T2 - }// end T1 - destroy_nr = true; - - -// OUT(ofs_running,"allocate non-local potential matrix","Done"); - timer::tick("Make_Overlap_Table", "init_Table_Beta",'D'); - return; -} - void Make_Overlap_Table::Destroy_Table(void) { @@ -955,39 +683,6 @@ void Make_Overlap_Table::Destroy_Table(void) return; } -void Make_Overlap_Table::Destroy_Table_Beta(void) -{ - if(!destroy_nr) return; - - const int ntype = ORB.get_ntype(); - for(int ir = 0; ir < 2; ir ++) - { - for(int T1=0; T1NL_Tpair(T1,T2); - const int L2plus1 = this->NL_L2plus1(T1,T2); - const int pairs = ORB.Phi[T1].getTotal_nchi() * ORB.nproj[T2]; - - // mohan fix bug 2011-03-30 - if(pairs ==0) continue; - for(int dim2=0; dim20); - this->NL_nTpairs = this->ntype * this->ntype; - this->NL_Tpair.create( this->ntype, this->ntype); - this->NL_L2plus1.create( this->ntype, this->ntype); // mohan fix bug 2011-03-14 - -// OUT(ofs_running,"Number of Nonlocal Pairs",NL_nTpairs); - - int index = 0; - for (int T1 = 0; T1 < ntype ; T1++) - { - for (int T0 = 0 ; T0 < ntype ; T0++) - { - this->NL_Tpair(T1,T0) = index; - ++index; - - // the pair < psi | beta > - // be careful! This is not a symmetry matrix. - this->NL_L2plus1(T1,T0) = std::max(ORB.Phi[T1].getLmax(), ORB.Beta[T0].getLmax() )*2+1; - - // there are special situations: - // for example, two H atom without projector. - // if we use s orbital, - // Phi.getLmax = 0, - // Beta.getLmax < 0, - // so the value is 1. - // however, there are no projectors. - if(NL_L2plus1(T1,T0) <= 0) - { - WARNING_QUIT("Make_Overlap_Table::init_paris_nonlocal_type","NL_L2plus1<=0"); - } - } - } - return; -} - void Make_Overlap_Table::init_OV_Opair(void) { @@ -1098,54 +755,6 @@ void Make_Overlap_Table::init_OV_Opair(void) return; } -void Make_Overlap_Table::init_NL_Opair(void) -{ - const int lmax = ORB.get_lmax(); - const int nchimax = ORB.get_nchimax(); - const int nprojmax = ORB.nprojmax; - - // may have bug if we use all H! - if( nprojmax == 0) - { - WARNING("Make_Overlap_Table","nproj for nonlocal pseudopotetials are zero, it must be all H atoms"); - return; - } - assert( NL_nTpairs > 0); - - this->NL_Opair.create( this->NL_nTpairs, lmax+1, nchimax, nprojmax); - - // <1psi|2beta> - // 1. orbital - for(int T1=0; T1NL_Tpair(T1, T0); - int index = 0; - for(int L1=0; L1NL_Opair(nlpair, L1, N1, ip) = index; - ++index; - } - } - } - } - } - - return; -} - // Peize Lin update 2016-01-26 void Make_Overlap_Table::init_Lmax (const int orb_num, const int mode, int &Lmax_used, int &Lmax) const { diff --git a/ABACUS.develop/source/src_lcao/ORB_radial_table.h b/ABACUS.develop/source/src_lcao/ORB_table_phi.h similarity index 76% rename from ABACUS.develop/source/src_lcao/ORB_radial_table.h rename to ABACUS.develop/source/src_lcao/ORB_table_phi.h index 585537a99d..cd2b176f58 100644 --- a/ABACUS.develop/source/src_lcao/ORB_radial_table.h +++ b/ABACUS.develop/source/src_lcao/ORB_table_phi.h @@ -1,19 +1,12 @@ -//========================================================= -//AUTHOR : Mohan -//DATE : 2009-04-22 -//========================================================= -#ifndef MAKE_OVERLAP_TABLE_H -#define MAKE_OVERLAP_TABLE_H +#ifndef ORB_TABLE_PHI_H +#define ORB_TABLE_PHI_H #include "src_pw/tools.h" #include "ORB_atomic.h" #include "ORB_atomic_lm.h" -#include "ORB_nonlocal.h" -#include "ORB_nonlocal_lm.h" #include "ORB_gaunt_table.h" #include "center2_orb.h" #include "src_global/sph_bessel_recursive.h" - #include class Make_Overlap_Table @@ -32,9 +25,7 @@ class Make_Overlap_Table const double &dk_in); void init_Table(const int &job); - void init_Table_Beta(void); void Destroy_Table(void); - void Destroy_Table_Beta(void); // Five dimension: // (1) 0: normal (S(R)) ; 1: derivative( dS/dR ) @@ -44,11 +35,9 @@ class Make_Overlap_Table // (5) Distance between atoms: R. double***** Table_SR; double***** Table_TR; - double***** Table_NR; bool destroy_sr; bool destroy_tr; - bool destroy_nr; //================================================= //make table of Spherical bessel @@ -79,18 +68,6 @@ class Make_Overlap_Table IntArray OV_Opair; IntArray OV_L2plus1; - //------------------------- - // NL stands for 'nonlocal' - // T stands for atom type. - // O stands for orbitals. - //------------------------- - void init_NL_Tpair(void); - void init_NL_Opair(void); - int NL_nTpairs; - IntArray NL_Tpair; - IntArray NL_Opair; - IntArray NL_L2plus1; - //======================================================== // Small function //======================================================== @@ -120,14 +97,6 @@ class Make_Overlap_Table double *rs, double *drs) const; - void cal_VNL_PhiBeta_R( - const int &l, - const Numerical_Orbital_Lm &n1, - const Numerical_Nonlocal_Lm &n2, - const int &rmesh, - double *rs, - double *drs); - // variables int ntype; int lmax; diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb11.h b/ABACUS.develop/source/src_lcao/center2_orb-orb11.h index 3ae4fab883..0dd57f9831 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb11.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb11.h @@ -15,7 +15,7 @@ using std::set; #include "center2_orb.h" -#include "src_lcao/ORB_radial_table.h" +#include "src_lcao/ORB_table_phi.h" #include "src_lcao/ORB_gaunt_table.h" #include "src_lcao/ORB_atomic_lm.h" #include "src_global/vector3.h" diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb21.h b/ABACUS.develop/source/src_lcao/center2_orb-orb21.h index 451dbb3302..1eb4c11f6c 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb21.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb21.h @@ -16,7 +16,7 @@ using std::set; #include "center2_orb.h" #include "center2_orb-orb11.h" -#include "src_lcao/ORB_radial_table.h" +#include "src_lcao/ORB_table_phi.h" #include "src_lcao/ORB_gaunt_table.h" #include "src_lcao/ORB_atomic_lm.h" #include "src_global/vector3.h" diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb22.h b/ABACUS.develop/source/src_lcao/center2_orb-orb22.h index 2bb5b28ec4..206397fa2a 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb22.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb22.h @@ -16,7 +16,7 @@ using std::set; #include "center2_orb.h" #include "center2_orb-orb21.h" -#include "src_lcao/ORB_radial_table.h" +#include "src_lcao/ORB_table_phi.h" #include "src_lcao/ORB_gaunt_table.h" #include "src_lcao/ORB_atomic_lm.h" #include "src_global/vector3.h" @@ -52,4 +52,4 @@ class Center2_Orb::Orb22 // this->orb21s[L34].psi2_center2[L12].Table_r[L1234][ir] -#endif // CENTER2_ORB_ORB22_H \ No newline at end of file +#endif // CENTER2_ORB_ORB22_H diff --git a/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h b/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h index 8720126cca..1e9f0a4f81 100644 --- a/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h @@ -9,7 +9,7 @@ using std::map; using std::set; #include "exx_abfs.h" -#include "src_lcao/ORB_radial_table.h" +#include "src_lcao/ORB_table_phi.h" #include "src_lcao/ORB_gaunt_table.h" #include "src_lcao/center2_orb-orb22.h" diff --git a/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs11.h b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs11.h index 057aa97aa0..60223a5efd 100644 --- a/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs11.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs11.h @@ -9,7 +9,7 @@ using std::map; using std::set; #include "exx_abfs.h" -#include "src_lcao/ORB_radial_table.h" +#include "src_lcao/ORB_table_phi.h" #include "src_lcao/ORB_gaunt_table.h" #include "src_lcao/center2_orb-orb11.h" diff --git a/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs21.h b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs21.h index 501e6b2164..88e3093a97 100644 --- a/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs21.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs21.h @@ -14,7 +14,7 @@ using std::map; using std::set; #include "exx_abfs.h" -#include "src_lcao/ORB_radial_table.h" +#include "src_lcao/ORB_table_phi.h" #include "src_lcao/ORB_gaunt_table.h" #include "src_lcao/center2_orb-orb21.h" diff --git a/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs22.h b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs22.h index 7c8db9635d..e321281f32 100644 --- a/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs22.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-matrix_orbs22.h @@ -5,7 +5,7 @@ using std::map; #include "exx_abfs.h" -#include "src_lcao/ORB_radial_table.h" +#include "src_lcao/ORB_table_phi.h" #include "src_lcao/ORB_gaunt_table.h" #include "src_lcao/center2_orb-orb22.h" From 525b6f761be4b98d7c4907aa8dd52700b92d590f Mon Sep 17 00:00:00 2001 From: zdy Date: Sun, 7 Mar 2021 11:28:04 +0800 Subject: [PATCH 177/233] adjust write_rho and read_rho function --- ABACUS.develop/source/src_io/istate_charge.cpp | 2 +- ABACUS.develop/source/src_io/istate_envelope.cpp | 2 +- ABACUS.develop/source/src_io/read_rho.cpp | 6 +++--- ABACUS.develop/source/src_io/write_rho.cpp | 8 ++++---- ABACUS.develop/source/src_io/write_rho_dipole.cpp | 12 ++++++------ ABACUS.develop/source/src_lcao/ELEC_scf.cpp | 6 +++--- ABACUS.develop/source/src_pw/charge.h | 6 +++--- ABACUS.develop/source/src_pw/electrons.cpp | 4 ++-- ABACUS.develop/source/src_pw/potential.cpp | 2 +- ABACUS.develop/source/src_pw/sto_elec.cpp | 4 ++-- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/ABACUS.develop/source/src_io/istate_charge.cpp b/ABACUS.develop/source/src_io/istate_charge.cpp index d1fe886e92..0151f92b23 100644 --- a/ABACUS.develop/source/src_io/istate_charge.cpp +++ b/ABACUS.develop/source/src_io/istate_charge.cpp @@ -134,7 +134,7 @@ void IState_Charge::begin(void) for(int is=0; is> rho[is][i*pw.ncy*pw.ncz + j*pw.ncz +k]; + ifs >> rho[i*pw.ncy*pw.ncz + j*pw.ncz +k]; } } } @@ -110,7 +110,7 @@ bool Charge::read_rho(const int &is, const string &fn) //add by dwan } } } - Pgrid.zpiece_to_all(zpiece, iz, rho[is]); + Pgrid.zpiece_to_all(zpiece, iz, rho); }// iz delete[] zpiece; #endif diff --git a/ABACUS.develop/source/src_io/write_rho.cpp b/ABACUS.develop/source/src_io/write_rho.cpp index 6aa3337b8c..6eb4f0ae12 100644 --- a/ABACUS.develop/source/src_io/write_rho.cpp +++ b/ABACUS.develop/source/src_io/write_rho.cpp @@ -1,7 +1,7 @@ #include "src_pw/charge.h" #include "src_pw/global.h" -void Charge::write_rho(const int &is, const int &iter, const string &fn, const int &precision, const bool for_plot) +void Charge::write_rho(const double* rho_save, const int &is, const int &iter, const string &fn, const int &precision, const bool for_plot) { TITLE("Charge","write_rho"); @@ -95,7 +95,7 @@ void Charge::write_rho(const int &is, const int &iter, const string &fn, const i for(int i=0; i Date: Sun, 7 Mar 2021 20:50:11 +0800 Subject: [PATCH 178/233] move density-matrix-related codes from local_orbital_charge.cpp to DM_k.cpp and DM_gamma.cpp, move write_dm and read_dm to src_io/ --- ABACUS.develop/source/Makefile.Objects | 4 + ABACUS.develop/source/src_io/read_dm.cpp | 185 +++ ABACUS.develop/source/src_io/write_dm.cpp | 229 +++ ABACUS.develop/source/src_lcao/DM_gamma.cpp | 580 ++++++++ ABACUS.develop/source/src_lcao/DM_k.cpp | 322 ++++ .../source/src_lcao/local_orbital_charge.cpp | 1306 ----------------- .../source/src_lcao/local_orbital_charge.h | 14 +- 7 files changed, 1331 insertions(+), 1309 deletions(-) create mode 100644 ABACUS.develop/source/src_io/read_dm.cpp create mode 100644 ABACUS.develop/source/src_io/write_dm.cpp create mode 100644 ABACUS.develop/source/src_lcao/DM_gamma.cpp create mode 100644 ABACUS.develop/source/src_lcao/DM_k.cpp diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 66a004ddb4..f91384c01a 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -139,6 +139,8 @@ ELEC_scf.o\ ELEC_nscf.o\ local_orbital_ions.o\ local_orbital_charge.o\ +DM_gamma.o\ +DM_k.o\ record_adj.o\ istate_charge.o \ istate_envelope.o \ @@ -228,9 +230,11 @@ H_XC_pw.o \ read_rho.o\ read_atoms.o\ read_pseudopot.o\ +read_dm.o\ write_pot.o\ write_rho.o\ write_rho_dipole.o\ +write_dm.o\ potential_libxc.o \ efield.o \ magnetism.o\ diff --git a/ABACUS.develop/source/src_io/read_dm.cpp b/ABACUS.develop/source/src_io/read_dm.cpp new file mode 100644 index 0000000000..c92a0ffd69 --- /dev/null +++ b/ABACUS.develop/source/src_io/read_dm.cpp @@ -0,0 +1,185 @@ +#include "src_lcao/local_orbital_charge.h" +#include "src_pw/global.h" +#include "src_global/blas_connector.h" + + +void Local_Orbital_Charge::read_dm(const int &is, const string &fn) +{ + TITLE("Local_Orbital_Charge","read_dm"); + timer::tick("Local_Orbital_Charge","read_dm"); + + ofs_running << "\n processor 0 is reading density matrix from file < " << fn << " > " << endl; + //xiaohui modify 2015-03-25 + //bool quit_mesia = false; + bool quit_abacus = false; + + ifstream ifs; + if(MY_RANK==0) + { + ifs.open(fn.c_str()); + if (!ifs) + { + //xiaohui modify 2015-03-25 + //quit_mesia = true; + quit_abacus = true; + } + else + { + // if the number is not match, + // quit the program or not. + bool quit=false; + + string name; + ifs >> name; + + // check lattice constant, unit is Angstrom + CHECK_DOUBLE(ifs,ucell.lat0 * BOHR_TO_A,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e11,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e12,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e13,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e21,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e22,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e23,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e31,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e32,quit); + CHECK_DOUBLE(ifs,ucell.latvec.e33,quit); + + for(int it=0; it> coordinate; + + for(int it=0; it> DM[is][i][j]; + } + } + } + else + { + WARNING_QUIT("Local_Orbital_Charge::read_dm","The nnrg should not be update"); + CHECK_INT(ifs,LNNR.nnrg); + + for(int i=0; i> DM_R[is][i]; + } + } +#else + + // distribution of necessary data + //xiaohui modify 2015-03-25 + //Parallel_Common::bcast_bool(quit_mesia); + Parallel_Common::bcast_bool(quit_abacus); + //xiaohui modify 2015-03-25 + //if(quit_mesia) + if(quit_abacus) + { + WARNING_QUIT("Local_Orbital_Charge::read_dm","Can not find the density matrix file."); + } + + + if(NSPIN==1||NSPIN==4) + { + Parallel_Common::bcast_double(en.ef); + } + else if(NSPIN==2) + { + Parallel_Common::bcast_double(en.ef_up); + Parallel_Common::bcast_double(en.ef_dw); + } + + + if(GAMMA_ONLY_LOCAL) + { + //ofs_running << " NLOCAL=" << NLOCAL << endl; + //ofs_running << " lgd_now=" << lgd_now << endl; + //ofs_running << " GridT.lgd=" << GridT.lgd << endl; + + double *tmp = new double[NLOCAL]; + for(int i=0; itaud[ia].x + << " " << atom->taud[ia].y + << " " << atom->taud[ia].z << endl; + } + } + + ofs << "\n " << NSPIN; + if(NSPIN==1||NSPIN==4) + { + ofs << "\n " << en.ef << " (fermi energy)"; + } + else if(NSPIN==2) + { + if(is==0)ofs << "\n " << en.ef_up << " (fermi energy for spin=1)"; + else if(is==1)ofs << "\n " << en.ef_dw << " (fermi energy for spin=2)"; + } + else + { + WARNING_QUIT("write_rho","check nspin!"); + } + + + ofs << "\n " << NLOCAL << " " << NLOCAL << endl; + + ofs << setprecision(precision); + ofs << scientific; + + } + + //ofs << "\n " << GAMMA_ONLY_LOCAL << " (GAMMA ONLY LOCAL)" << endl; +#ifndef __MPI + if(GAMMA_ONLY_LOCAL) + { + for(int i=0; iDM[is][i][j]; + } + } + } + else + { + WARNING_QUIT("write_dm","not ready yet"); + ofs << " " << LNNR.nnrg << " (nnrg)" << endl; + for(int i=0; iDM_R[is][i]; + } + } +#else + if(GAMMA_ONLY_LOCAL) + { + //xiaohui modify 2014-06-18 + + double* tmp = new double[NLOCAL]; + int* count = new int[NLOCAL]; + for (int i=0; i= 0) + { + for (int j=0; j= 0) + { + count[j]=1; + } + } + } + Parallel_Reduce::reduce_int_all( count, NLOCAL ); + + // reduce the density matrix for 'i' line. + ZEROS(tmp, NLOCAL); + if (mu >= 0) + { + for (int j=0; j=0) + { + tmp[j] = DM[is][mu][nu]; + //ofs_running << " dmi=" << i << " j=" << j << " " << DM[is][mu][nu] << endl; + } + } + } + Parallel_Reduce::reduce_double_all( tmp, NLOCAL ); + + if(MY_RANK==0) + { + for (int j=0; j0) + { + ofs << " " << tmp[j]/(double)count[j]; + } + else + { + ofs << " 0"; + } + } + } + } + delete[] tmp; + delete[] count; + + //xiaohui add 2014-06-18 + //for(int i=0; iDM[is][i][j]; + // } + //} + + } + else + { + ofs << " " << LNNR.nnrg << " (nnrg)" << endl; + WARNING_QUIT("local_orbital_charge","not ready to output DM_R"); + } +#endif + if(MY_RANK==0) + { + end = time(NULL); + OUT_TIME("write_rho",start,end); + ofs.close(); + } + timer::tick("Local_Orbital_Charge","write_dm"); + + return; +} diff --git a/ABACUS.develop/source/src_lcao/DM_gamma.cpp b/ABACUS.develop/source/src_lcao/DM_gamma.cpp new file mode 100644 index 0000000000..f98f018642 --- /dev/null +++ b/ABACUS.develop/source/src_lcao/DM_gamma.cpp @@ -0,0 +1,580 @@ +#include "local_orbital_charge.h" +#include "../src_pw/global.h" +#include "src_global/blas_connector.h" + +extern "C" +{ + void Cblacs_gridinfo(int icontxt, int* nprow, int *npcol, int *myprow, int *mypcol); + void Cblacs_pinfo(int *myid, int *nprocs); + void Cblacs_pcoord(int icontxt, int pnum, int *prow, int *pcol); + int Cblacs_pnum(int icontxt, int prow, int pcol); +} + +// setup buffer parameters for tranforming 2D block-cyclic distributed DM matrix +inline int globalIndex(int localIndex, int nblk, int nprocs, int myproc) +{ + int iblock, gIndex; + iblock=localIndex/nblk; + gIndex=(iblock*nprocs+myproc)*nblk+localIndex%nblk; + return gIndex; + //return (localIndex/nblk*nprocs+myproc)*nblk+localIndex%nblk; +} + + +inline int localIndex(int globalIndex, int nblk, int nprocs, int& myproc) +{ + myproc=int((globalIndex%(nblk*nprocs))/nblk); + return int(globalIndex/(nblk*nprocs))*nblk+globalIndex%nblk; +} + + +int Local_Orbital_Charge::setAlltoallvParameter(MPI_Comm comm_2D, int blacs_ctxt, int nblk) +{ + OUT(ofs_running,"enter setAlltoallvParameter, nblk", nblk); + timer::tick("LCAO_Charge","newDM_index",'F'); + // setup blacs parameters + int nprows=0; + int npcols=0; + int nprocs=0; + int myprow=0; + int mypcol=0; + int myproc=0; + + Cblacs_gridinfo(blacs_ctxt, &nprows, &npcols, &myprow, &mypcol); + + Cblacs_pinfo(&myproc, &nprocs); + // OUT(ofs_running,"nprocs",nprocs); + + + // init data arrays + delete[] sender_size_process; + sender_size_process=new int[nprocs]; + delete[] sender_displacement_process; + sender_displacement_process=new int[nprocs]; + + // OUT(ofs_running,"lgd_now",lgd_now); + + receiver_size=lgd_now*lgd_now; + receiver_size_process=new int[nprocs]; + delete[] receiver_displacement_process; + receiver_displacement_process=new int[nprocs]; + delete[] receiver_local_index; + receiver_local_index=new int[receiver_size]; + delete[] receiver_buffer; + receiver_buffer=new double[receiver_size]; + + int *trace_2D_row=new int[lgd_now]; + int *trace_2D_col=new int[lgd_now]; + int *trace_2D_prow=new int[lgd_now]; + int *trace_2D_pcol=new int[lgd_now]; + //int *trace_global=new int[lgd_now]; + + int *nRow_in_proc=new int[nprows]; + int *nCol_in_proc=new int[npcols]; + + // OUT(ofs_running,"nprows",nprows); + // OUT(ofs_running,"npcols",npcols); + + for(int i=0; i=0) + { + //trace_global[iLocalGrid]=iGlobal; + int p; + trace_2D_row[iLocalGrid]=localIndex(iGlobal, nblk, nprows, p); + trace_2D_prow[iLocalGrid]=p; + nRow_in_proc[trace_2D_prow[iLocalGrid]]++; + trace_2D_col[iLocalGrid]=localIndex(iGlobal, nblk, npcols, p); + trace_2D_pcol[iLocalGrid]=p; + nCol_in_proc[trace_2D_pcol[iLocalGrid]]++; + } + } + // OUT(ofs_running,"NLOCAL",NLOCAL); + receiver_displacement_process[0]=0; + // OUT(ofs_running,"receiver_displacement_process[0]",receiver_displacement_process[0]); + for(int pnum=0; pnum1) + { + OUT(ofs_running,"pnum",pnum); + OUT(ofs_running,"prow",prow); + OUT(ofs_running,"pcol",pcol); + OUT(ofs_running,"nRow_in_proc",nRow_in_proc[prow]); + OUT(ofs_running,"nCol_in_proc",nCol_in_proc[pcol]); + } + if(pnum>0) + { + receiver_displacement_process[pnum]=receiver_displacement_process[pnum-1]+receiver_size_process[pnum-1]; + } + } + // OUT(ofs_running,"last receiver_size_process",receiver_size_process[nprocs-1]); + + // build the index to be received + int* pos=new int[nprocs]; + int *receiver_2D_index=new int[receiver_size]; + for(int i=0; i1) + { + ofs_running<<"receiver_size is "<lgd_now = gt.lgd; + //xiaohui add 'OUT_LEVEL' line, 2015-09-16 + if(OUT_LEVEL != "m") OUT(ofs_running,"lgd_last",lgd_last); + if(OUT_LEVEL != "m") OUT(ofs_running,"lgd_now",lgd_now); + + // mohan add 2010-07-01 + if(this->init_DM) + { + assert(lgd_last > 0); + for (int is=0; is 0) + { + this->DM = new double**[NSPIN]; + this->DM_pool = new double *[NSPIN]; + for(int is=0; isDM_pool[is]=new double [lgd_now*lgd_now]; + ZEROS(DM_pool[is], lgd_now*lgd_now); + this->DM[is] = new double*[lgd_now]; + + for (int i=0; iinit_DM = true; + this->lgd_last = lgd_now; + //xiaohui add 'OUT_LEVEL', 2015-09-16 + if(OUT_LEVEL != "m") ofs_running << " allocate DM , the dimension is " << lgd_now << endl; + } + else if(lgd_now == 0) + { + this->init_DM = false; + } + else + { + WARNING_QUIT("Local_Orbital_Charge::allocate","lgd<0!Something Wrong!"); + } + + setAlltoallvParameter(ParaO.comm_2D, ParaO.blacs_ctxt, ParaO.nb); + + // Peize Lin test 2019-01-16 + wfc_dm_2d.init(); + + return; +} + + +// calculate the grid distributed DM matrix from 2D block-cyclic distributed DM matrix +// transform dm_gamma[is].c to this->DM[is] +void Local_Orbital_Charge::cal_dk_gamma_from_2D(void) +{ + timer::tick("LCAO_Charge","dm_2dTOgrid",'F'); + OUT(ofs_running,"cal_dk_gamma_from_2D, NSPIN", NSPIN); + + for(int is=0; is1) + // outputDM( ParaO.blacs_ctxt, ParaO.nb); + { + // int myid; + // MPI_Comm_rank(MPI_COMM_WORLD, &myid); + // if(myid==0) + // { + // ofs_running<<"DM[0][0:1][0:1] before send:"<1) + { + OUT(ofs_running,"number of non-zero elements in sender_buffer",nNONZERO); + OUT(ofs_running,"sender_size",sender_size); + OUT(ofs_running,"last sender_buffer",sender_buffer[sender_size-1]); + } + // transform data via MPI_Alltoallv + MPI_Alltoallv(sender_buffer, sender_size_process, sender_displacement_process, MPI_DOUBLE, + receiver_buffer, receiver_size_process, receiver_displacement_process, MPI_DOUBLE, ParaO.comm_2D); + // put data from receiver buffer to this->DM[is] + nNONZERO=0; + // init DM[is] + /*for(int i=0; i1) + { + OUT(ofs_running,"number of non-zero elements in receiver_buffer",nNONZERO); + OUT(ofs_running,"receiver_size",receiver_size); + OUT(ofs_running,"last receiver_buffer",receiver_buffer[receiver_size-1]); + // ofs_running<<"DM[0][0:1][0:1] after receiver:"<=0) + // { + // ofs_running<<"DM(0,0)"<=0 && idx1>=0) + // { + // ofs_running<<"DM(0,1)"<=0) + // { + // ofs_running<<"DM(1,1)"<DM[is][i], lgd_now); + } + } + + // initialize + int nprocs=0; + int myid=0; + //MPI_Status status; + MPI_Comm_size(DIAG_HPSEPS_WORLD,&nprocs); + MPI_Comm_rank(DIAG_HPSEPS_WORLD,&myid); + + + // DSIZE: number of processors in diag world + vector bands_local(DSIZE); + for (int id=0; id= NBANDS) + { + lastband_in_proc = id; + break; + } + } + + matrix wg_local(NSPIN,band_local); + for(int id=0, Total_Bands=0; id <= lastband_in_proc; ++id) + { + if(myid == id) + { + for(int is=0; isDM[is][row_mu][col_nu] = rho_row_col(i_row,i_col); + } + } + } + + #if EXX_DM==2 + if( Exx_Global::Hybrid_Type::HF==exx_lcao.info.hybrid_type + || Exx_Global::Hybrid_Type::PBE0==exx_lcao.info.hybrid_type + || Exx_Global::Hybrid_Type::HSE==exx_lcao.info.hybrid_type ) + { + exx_lcao.DM_para.set_DM_gamma( rho_row_col, is, {row_count*300,col_count*300} ); + } + #endif + } // end for col_count + } // end for row_count + + ofs_running<<"DM[0][0:1][0:1] in cal_dk_gamma:"<=0) + { + ofs_running<<"DM(0,0)"<=0 && idx1>=0) + { + ofs_running<<"DM(0,1)"<=0) + { + ofs_running<<"DM(1,1)"<nnrg_now = LNNR.nnrg; + //xiaohui add 'OUT_LEVEL' line, 2015-09-16 + if(OUT_LEVEL != "m") OUT(ofs_running,"nnrg_last",nnrg_last); + if(OUT_LEVEL != "m") OUT(ofs_running,"nnrg_now",nnrg_now); + + if(this->init_DM_R) + { + assert(nnrg_last > 0); + for(int is=0; is0) + { + this->DM_R = new double*[NSPIN]; + for(int is=0; isDM_R[is] = new double[nnrg_now]; + ZEROS(DM_R[is], nnrg_now); + } + this->nnrg_last = nnrg_now; + this->init_DM_R = true; + Memory::record("LocalOrbital_Charge","Density_Matrix",NSPIN*nnrg_now,"double"); + } + else if(nnrg_now==0) + { + this->init_DM_R = false; + } + else + { + WARNING_QUIT("Local_Orbital_Charge::allocate_k","check init_DM_R."); + } + + // Peize Lin test 2019-01-16 + wfc_dm_2d.init(); + + return; +} + + + +#include "record_adj.h" +inline void cal_DM_ATOM(const Grid_Technique >, const complex fac, Record_adj RA, + const int ia1, const int iw1_lo, const int nw1, const int gstart, + complex *WFC_PHASE, complex **DM_ATOM) +{ + const char transa='N', transb='T'; + const complex alpha=1, beta=1; + + for(int ik=0; ik **wfc = LOWF.WFC_K[ik]; + const int ispin = kv.isk[ik]; + int atom2start=0; + + for (int ia2 = 0; ia2 < RA.na_each[ia1]; ++ia2) + { + complex *DM=&DM_ATOM[ispin][atom2start]; + const int T2 = RA.info[ia1][ia2][3]; + const int I2 = RA.info[ia1][ia2][4]; + Atom* atom2 = &ucell.atoms[T2]; + const int start2 = ucell.itiaiw2iwt(T2,I2,0); + const int iw2_lo=gt.trace_lo[start2]; + const int nw2=atom2->nw; + complex exp_R= exp( fac * ( + kv.kvec_d[ik].x * RA.info[ia1][ia2][0] + + kv.kvec_d[ik].y * RA.info[ia1][ia2][1] + + kv.kvec_d[ik].z * RA.info[ia1][ia2][2] + ) ); + + //ZEROS(WFC_PHASE, NBANDS*nw1); + int ibStart=0; + int nRow=0; + for(int ib=0; ib0) + { + if(nRow==0) ibStart=ib; + const int iline=nRow*nw1; + complex phase=exp_R*wg_local; + for(int iw1=0; iw1 fac, Record_adj RA, + const int ia1, const int iw1_lo, const int nw1, const int gstart, + complex *WFC_PHASE, complex **DM_ATOM) +{ + if(NSPIN !=4 ) WARNING_QUIT("Local_Orbital_Charge","NSPIN not match!"); + const char transa='N', transb='T'; + const complex alpha=1, beta=1; + int ispin=0; + + for(int is1=0;is1<2;is1++) + { + for(int is2=0;is2<2;is2++) + { + for(int ik=0; ik **wfc = LOWF.WFC_K[ik]; + int atom2start=0; + + for (int ia2 = 0; ia2 < RA.na_each[ia1]; ++ia2) + { + complex *DM=&DM_ATOM[ispin][atom2start]; + const int T2 = RA.info[ia1][ia2][3]; + const int I2 = RA.info[ia1][ia2][4]; + Atom* atom2 = &ucell.atoms[T2]; + const int start2 = ucell.itiaiw2iwt(T2,I2,0); + const int iw2_lo=gt.trace_lo[start2]/NPOL + gt.lgd/NPOL*is2; + const int nw2=atom2->nw; + complex exp_R= exp( fac * ( + kv.kvec_d[ik].x * RA.info[ia1][ia2][0] + + kv.kvec_d[ik].y * RA.info[ia1][ia2][1] + + kv.kvec_d[ik].z * RA.info[ia1][ia2][2] + ) ); + + //ZEROS(WFC_PHASE, NBANDS*nw1); + int ibStart=0; + int nRow=0; + for(int ib=0; ib0) + { + if(nRow==0) + { + ibStart=ib; + } + const int iline=nRow*nw1; + complex phase=exp_R*w1; + for(int iw1=0; iw1 tau1, dtau; + + Record_adj RA; + RA.for_grid(gt); + + int ca = 0; + complex fac = TWO_PI * IMAG_UNIT; + + complex *WFC_PHASE=new complex[NLOCAL*ucell.nwmax]; + + int DM_ATOM_SIZE=1; + complex **DM_ATOM=new complex *[NSPIN]; + for(int is=0; is[DM_ATOM_SIZE]; + ZEROS(DM_ATOM[is], DM_ATOM_SIZE); + } + for(int T1=0; T1na; I1++) + { + const int iat = ucell.itia2iat(T1,I1); + if(gt.in_this_processor[iat]) + { + const int start1 = ucell.itiaiw2iwt(T1,I1,0); + const int gstart = LNNR.nlocstartg[iat]; + const int ng = LNNR.nlocdimg[iat]; + const int iw1_lo=gt.trace_lo[start1]/NPOL; + const int nw1=atom1->nw; + + if(DM_ATOM_SIZE[DM_ATOM_SIZE]; + } + } + for(int is=0; isDM_R[is][gstart+iv]=DM_ATOM[is][iv].real(); + } + } + } + else + {//zhengdy-soc + for(int iv=0; ivDM_R[0][gstart+iv]=DM_ATOM[0][iv].real() + DM_ATOM[3][iv].real(); + if(NONCOLIN){//DOMAG + this->DM_R[1][gstart+iv]=DM_ATOM[1][iv].real() + DM_ATOM[2][iv].real(); + this->DM_R[2][gstart+iv]=DM_ATOM[1][iv].imag() - DM_ATOM[2][iv].imag(); + this->DM_R[3][gstart+iv]=DM_ATOM[0][iv].real() - DM_ATOM[3][iv].real(); + } + else if(!NONCOLIN)//DOMAG_Z + { + this->DM_R[1][gstart+iv]= 0.0; + this->DM_R[1][gstart+iv]= 0.0; + this->DM_R[3][gstart+iv]=DM_ATOM[0][iv].real() - DM_ATOM[3][iv].real(); + } + else//soc with no mag + { + this->DM_R[1][gstart+iv]= 0.0; + this->DM_R[2][gstart+iv]= 0.0; + this->DM_R[3][gstart+iv]= 0.0; + } + } + } + } // if gt.in_this_processor + }// I1 + }// T1 + + + //------------ + // for test + //------------ +/* cout << setprecision(3); + for(int i=0; innrg_now = LNNR.nnrg; - //xiaohui add 'OUT_LEVEL' line, 2015-09-16 - if(OUT_LEVEL != "m") OUT(ofs_running,"nnrg_last",nnrg_last); - if(OUT_LEVEL != "m") OUT(ofs_running,"nnrg_now",nnrg_now); - - if(this->init_DM_R) - { - assert(nnrg_last > 0); - for(int is=0; is0) - { - this->DM_R = new double*[NSPIN]; - for(int is=0; isDM_R[is] = new double[nnrg_now]; - ZEROS(DM_R[is], nnrg_now); - } - this->nnrg_last = nnrg_now; - this->init_DM_R = true; - Memory::record("LocalOrbital_Charge","Density_Matrix",NSPIN*nnrg_now,"double"); - } - else if(nnrg_now==0) - { - this->init_DM_R = false; - } - else - { - WARNING_QUIT("Local_Orbital_Charge::allocate_k","check init_DM_R."); - } - - // Peize Lin test 2019-01-16 - wfc_dm_2d.init(); - - return; -} - - -// setup buffer parameters for tranforming 2D block-cyclic distributed DM matrix -inline int globalIndex(int localIndex, int nblk, int nprocs, int myproc) -{ - int iblock, gIndex; - iblock=localIndex/nblk; - gIndex=(iblock*nprocs+myproc)*nblk+localIndex%nblk; - return gIndex; - //return (localIndex/nblk*nprocs+myproc)*nblk+localIndex%nblk; -} - - -inline int localIndex(int globalIndex, int nblk, int nprocs, int& myproc) -{ - myproc=int((globalIndex%(nblk*nprocs))/nblk); - return int(globalIndex/(nblk*nprocs))*nblk+globalIndex%nblk; -} - - - -int Local_Orbital_Charge::setAlltoallvParameter(MPI_Comm comm_2D, int blacs_ctxt, int nblk) -{ - OUT(ofs_running,"enter setAlltoallvParameter, nblk", nblk); - timer::tick("LCAO_Charge","newDM_index",'F'); - // setup blacs parameters - int nprows, npcols, nprocs; - int myprow, mypcol, myproc; - Cblacs_gridinfo(blacs_ctxt, &nprows, &npcols, &myprow, &mypcol); - Cblacs_pinfo(&myproc, &nprocs); - // OUT(ofs_running,"nprocs",nprocs); - // init data arrays - delete[] sender_size_process; - sender_size_process=new int[nprocs]; - delete[] sender_displacement_process; - sender_displacement_process=new int[nprocs]; - - // OUT(ofs_running,"lgd_now",lgd_now); - - receiver_size=lgd_now*lgd_now; - receiver_size_process=new int[nprocs]; - delete[] receiver_displacement_process; - receiver_displacement_process=new int[nprocs]; - delete[] receiver_local_index; - receiver_local_index=new int[receiver_size]; - delete[] receiver_buffer; - receiver_buffer=new double[receiver_size]; - - int *trace_2D_row=new int[lgd_now]; - int *trace_2D_col=new int[lgd_now]; - int *trace_2D_prow=new int[lgd_now]; - int *trace_2D_pcol=new int[lgd_now]; - //int *trace_global=new int[lgd_now]; - - int *nRow_in_proc=new int[nprows]; - int *nCol_in_proc=new int[npcols]; - - // OUT(ofs_running,"nprows",nprows); - // OUT(ofs_running,"npcols",npcols); - - for(int i=0; i=0) - { - //trace_global[iLocalGrid]=iGlobal; - int p; - trace_2D_row[iLocalGrid]=localIndex(iGlobal, nblk, nprows, p); - trace_2D_prow[iLocalGrid]=p; - nRow_in_proc[trace_2D_prow[iLocalGrid]]++; - trace_2D_col[iLocalGrid]=localIndex(iGlobal, nblk, npcols, p); - trace_2D_pcol[iLocalGrid]=p; - nCol_in_proc[trace_2D_pcol[iLocalGrid]]++; - } - } - // OUT(ofs_running,"NLOCAL",NLOCAL); - receiver_displacement_process[0]=0; - // OUT(ofs_running,"receiver_displacement_process[0]",receiver_displacement_process[0]); - for(int pnum=0; pnum1) - { - OUT(ofs_running,"pnum",pnum); - OUT(ofs_running,"prow",prow); - OUT(ofs_running,"pcol",pcol); - OUT(ofs_running,"nRow_in_proc",nRow_in_proc[prow]); - OUT(ofs_running,"nCol_in_proc",nCol_in_proc[pcol]); - } - if(pnum>0) - { - receiver_displacement_process[pnum]=receiver_displacement_process[pnum-1]+receiver_size_process[pnum-1]; - } - } - // OUT(ofs_running,"last receiver_size_process",receiver_size_process[nprocs-1]); - - // build the index to be received - int* pos=new int[nprocs]; - int *receiver_2D_index=new int[receiver_size]; - for(int i=0; i1) - { - ofs_running<<"receiver_size is "<lgd_now = gt.lgd; - //xiaohui add 'OUT_LEVEL' line, 2015-09-16 - if(OUT_LEVEL != "m") OUT(ofs_running,"lgd_last",lgd_last); - if(OUT_LEVEL != "m") OUT(ofs_running,"lgd_now",lgd_now); - - // mohan add 2010-07-01 - if(this->init_DM) - { - assert(lgd_last > 0); - for (int is=0; is 0) - { - this->DM = new double**[NSPIN]; - this->DM_pool = new double *[NSPIN]; - for(int is=0; isDM_pool[is]=new double [lgd_now*lgd_now]; - ZEROS(DM_pool[is], lgd_now*lgd_now); - this->DM[is] = new double*[lgd_now]; - - for (int i=0; iinit_DM = true; - this->lgd_last = lgd_now; - //xiaohui add 'OUT_LEVEL', 2015-09-16 - if(OUT_LEVEL != "m") ofs_running << " allocate DM , the dimension is " << lgd_now << endl; - } - else if(lgd_now == 0) - { - this->init_DM = false; - } - else - { - WARNING_QUIT("Local_Orbital_Charge::allocate","lgd<0!Something Wrong!"); - } - - setAlltoallvParameter(ParaO.comm_2D, ParaO.blacs_ctxt, ParaO.nb); - - // Peize Lin test 2019-01-16 - wfc_dm_2d.init(); - - return; -} - void Local_Orbital_Charge::sum_bands(void) { TITLE("Local_Orbital_Charge","sum_bands"); @@ -482,1006 +179,3 @@ void Local_Orbital_Charge::sum_bands(void) timer::tick("Local_Orbital_Cha","sum_bands",'E'); return; } - -#include "record_adj.h" -inline void cal_DM_ATOM(const Grid_Technique >, const complex fac, Record_adj RA, - const int ia1, const int iw1_lo, const int nw1, const int gstart, - complex *WFC_PHASE, complex **DM_ATOM) -{ - const char transa='N', transb='T'; - const complex alpha=1, beta=1; - - for(int ik=0; ik **wfc = LOWF.WFC_K[ik]; - const int ispin = kv.isk[ik]; - int atom2start=0; - - for (int ia2 = 0; ia2 < RA.na_each[ia1]; ++ia2) - { - complex *DM=&DM_ATOM[ispin][atom2start]; - const int T2 = RA.info[ia1][ia2][3]; - const int I2 = RA.info[ia1][ia2][4]; - Atom* atom2 = &ucell.atoms[T2]; - const int start2 = ucell.itiaiw2iwt(T2,I2,0); - const int iw2_lo=gt.trace_lo[start2]; - const int nw2=atom2->nw; - complex exp_R= exp( fac * ( - kv.kvec_d[ik].x * RA.info[ia1][ia2][0] + - kv.kvec_d[ik].y * RA.info[ia1][ia2][1] + - kv.kvec_d[ik].z * RA.info[ia1][ia2][2] - ) ); - - //ZEROS(WFC_PHASE, NBANDS*nw1); - int ibStart=0; - int nRow=0; - for(int ib=0; ib0) - { - if(nRow==0) ibStart=ib; - const int iline=nRow*nw1; - complex phase=exp_R*wg_local; - for(int iw1=0; iw1 fac, Record_adj RA, - const int ia1, const int iw1_lo, const int nw1, const int gstart, - complex *WFC_PHASE, complex **DM_ATOM) -{ - if(NSPIN !=4 ) WARNING_QUIT("Local_Orbital_Charge","NSPIN not match!"); - const char transa='N', transb='T'; - const complex alpha=1, beta=1; - int ispin=0; - - for(int is1=0;is1<2;is1++) - { - for(int is2=0;is2<2;is2++) - { - for(int ik=0; ik **wfc = LOWF.WFC_K[ik]; - int atom2start=0; - - for (int ia2 = 0; ia2 < RA.na_each[ia1]; ++ia2) - { - complex *DM=&DM_ATOM[ispin][atom2start]; - const int T2 = RA.info[ia1][ia2][3]; - const int I2 = RA.info[ia1][ia2][4]; - Atom* atom2 = &ucell.atoms[T2]; - const int start2 = ucell.itiaiw2iwt(T2,I2,0); - const int iw2_lo=gt.trace_lo[start2]/NPOL + gt.lgd/NPOL*is2; - const int nw2=atom2->nw; - complex exp_R= exp( fac * ( - kv.kvec_d[ik].x * RA.info[ia1][ia2][0] + - kv.kvec_d[ik].y * RA.info[ia1][ia2][1] + - kv.kvec_d[ik].z * RA.info[ia1][ia2][2] - ) ); - - //ZEROS(WFC_PHASE, NBANDS*nw1); - int ibStart=0; - int nRow=0; - for(int ib=0; ib0) - { - if(nRow==0) ibStart=ib; - const int iline=nRow*nw1; - complex phase=exp_R*w1; - for(int iw1=0; iw1 tau1, dtau; - - Record_adj RA; - RA.for_grid(gt); - - int ca = 0; - complex fac = TWO_PI * IMAG_UNIT; - - complex *WFC_PHASE=new complex[NLOCAL*ucell.nwmax]; - - int DM_ATOM_SIZE=1; - complex **DM_ATOM=new complex *[NSPIN]; - for(int is=0; is[DM_ATOM_SIZE]; - ZEROS(DM_ATOM[is], DM_ATOM_SIZE); - } - for(int T1=0; T1na; I1++) - { - const int iat = ucell.itia2iat(T1,I1); - if(gt.in_this_processor[iat]) - { - const int start1 = ucell.itiaiw2iwt(T1,I1,0); - const int gstart = LNNR.nlocstartg[iat]; - const int ng = LNNR.nlocdimg[iat]; - const int iw1_lo=gt.trace_lo[start1]/NPOL; - const int nw1=atom1->nw; - - if(DM_ATOM_SIZE[DM_ATOM_SIZE]; - } - } - for(int is=0; isDM_R[is][gstart+iv]=DM_ATOM[is][iv].real(); - } - } - } - else - {//zhengdy-soc - for(int iv=0; ivDM_R[0][gstart+iv]=DM_ATOM[0][iv].real() + DM_ATOM[3][iv].real(); - if(NONCOLIN){//DOMAG - this->DM_R[1][gstart+iv]=DM_ATOM[1][iv].real() + DM_ATOM[2][iv].real(); - this->DM_R[2][gstart+iv]=DM_ATOM[1][iv].imag() - DM_ATOM[2][iv].imag(); - this->DM_R[3][gstart+iv]=DM_ATOM[0][iv].real() - DM_ATOM[3][iv].real(); - } - else if(!NONCOLIN)//DOMAG_Z - { - this->DM_R[1][gstart+iv]= 0.0; - this->DM_R[1][gstart+iv]= 0.0; - this->DM_R[3][gstart+iv]=DM_ATOM[0][iv].real() - DM_ATOM[3][iv].real(); - } - else//soc with no mag - { - this->DM_R[1][gstart+iv]= 0.0; - this->DM_R[2][gstart+iv]= 0.0; - this->DM_R[3][gstart+iv]= 0.0; - } - } - } - } // if gt.in_this_processor - }// I1 - }// T1 - - - //------------ - // for test - //------------ -/* cout << setprecision(3); - for(int i=0; iDM[is] -void Local_Orbital_Charge::cal_dk_gamma_from_2D(void) -{ - timer::tick("LCAO_Charge","dm_2dTOgrid",'F'); - OUT(ofs_running,"cal_dk_gamma_from_2D, NSPIN", NSPIN); - - for(int is=0; is1) - // outputDM( ParaO.blacs_ctxt, ParaO.nb); - { - // int myid; - // MPI_Comm_rank(MPI_COMM_WORLD, &myid); - // if(myid==0) - // { - // ofs_running<<"DM[0][0:1][0:1] before send:"<1) - { - OUT(ofs_running,"number of non-zero elements in sender_buffer",nNONZERO); - OUT(ofs_running,"sender_size",sender_size); - OUT(ofs_running,"last sender_buffer",sender_buffer[sender_size-1]); - } - // transform data via MPI_Alltoallv - MPI_Alltoallv(sender_buffer, sender_size_process, sender_displacement_process, MPI_DOUBLE, - receiver_buffer, receiver_size_process, receiver_displacement_process, MPI_DOUBLE, ParaO.comm_2D); - // put data from receiver buffer to this->DM[is] - nNONZERO=0; - // init DM[is] - /*for(int i=0; i1) - { - OUT(ofs_running,"number of non-zero elements in receiver_buffer",nNONZERO); - OUT(ofs_running,"receiver_size",receiver_size); - OUT(ofs_running,"last receiver_buffer",receiver_buffer[receiver_size-1]); - // ofs_running<<"DM[0][0:1][0:1] after receiver:"<=0) - // { - // ofs_running<<"DM(0,0)"<=0 && idx1>=0) - // { - // ofs_running<<"DM(0,1)"<=0) - // { - // ofs_running<<"DM(1,1)"<DM[is][i], lgd_now); - } - } - - // initialize - int nprocs=0; - int myid=0; - //MPI_Status status; - MPI_Comm_size(DIAG_HPSEPS_WORLD,&nprocs); - MPI_Comm_rank(DIAG_HPSEPS_WORLD,&myid); - - - // DSIZE: number of processors in diag world - vector bands_local(DSIZE); - for (int id=0; id= NBANDS) - { - lastband_in_proc = id; - break; - } - } - - matrix wg_local(NSPIN,band_local); - for(int id=0, Total_Bands=0; id <= lastband_in_proc; ++id) - { - if(myid == id) - { - for(int is=0; isDM[is][row_mu][col_nu] = rho_row_col(i_row,i_col); - } - } - } - - #if EXX_DM==2 - if( Exx_Global::Hybrid_Type::HF==exx_lcao.info.hybrid_type - || Exx_Global::Hybrid_Type::PBE0==exx_lcao.info.hybrid_type - || Exx_Global::Hybrid_Type::HSE==exx_lcao.info.hybrid_type ) - { - exx_lcao.DM_para.set_DM_gamma( rho_row_col, is, {row_count*300,col_count*300} ); - } - #endif - } // end for col_count - } // end for row_count - - ofs_running<<"DM[0][0:1][0:1] in cal_dk_gamma:"<=0) - { - ofs_running<<"DM(0,0)"<=0 && idx1>=0) - { - ofs_running<<"DM(0,1)"<=0) - { - ofs_running<<"DM(1,1)"<taud[ia].x - << " " << atom->taud[ia].y - << " " << atom->taud[ia].z << endl; - } - } - - ofs << "\n " << NSPIN; - if(NSPIN==1||NSPIN==4) - { - ofs << "\n " << en.ef << " (fermi energy)"; - } - else if(NSPIN==2) - { - if(is==0)ofs << "\n " << en.ef_up << " (fermi energy for spin=1)"; - else if(is==1)ofs << "\n " << en.ef_dw << " (fermi energy for spin=2)"; - } - else - { - WARNING_QUIT("write_rho","check nspin!"); - } - - - ofs << "\n " << NLOCAL << " " << NLOCAL << endl; - - ofs << setprecision(precision); - ofs << scientific; - - } - - //ofs << "\n " << GAMMA_ONLY_LOCAL << " (GAMMA ONLY LOCAL)" << endl; -#ifndef __MPI - if(GAMMA_ONLY_LOCAL) - { - for(int i=0; iDM[is][i][j]; - } - } - } - else - { - WARNING_QUIT("write_dm","not ready yet"); - ofs << " " << LNNR.nnrg << " (nnrg)" << endl; - for(int i=0; iDM_R[is][i]; - } - } -#else - if(GAMMA_ONLY_LOCAL) - { - //xiaohui modify 2014-06-18 - - double* tmp = new double[NLOCAL]; - int* count = new int[NLOCAL]; - for (int i=0; i= 0) - { - for (int j=0; j= 0) - { - count[j]=1; - } - } - } - Parallel_Reduce::reduce_int_all( count, NLOCAL ); - - // reduce the density matrix for 'i' line. - ZEROS(tmp, NLOCAL); - if (mu >= 0) - { - for (int j=0; j=0) - { - tmp[j] = DM[is][mu][nu]; - //ofs_running << " dmi=" << i << " j=" << j << " " << DM[is][mu][nu] << endl; - } - } - } - Parallel_Reduce::reduce_double_all( tmp, NLOCAL ); - - if(MY_RANK==0) - { - for (int j=0; j0) - { - ofs << " " << tmp[j]/(double)count[j]; - } - else - { - ofs << " 0"; - } - } - } - } - delete[] tmp; - delete[] count; - - //xiaohui add 2014-06-18 - //for(int i=0; iDM[is][i][j]; - // } - //} - - } - else - { - ofs << " " << LNNR.nnrg << " (nnrg)" << endl; - WARNING_QUIT("local_orbital_charge","not ready to output DM_R"); - } -#endif - if(MY_RANK==0) - { - end = time(NULL); - OUT_TIME("write_rho",start,end); - ofs.close(); - } - timer::tick("Local_Orbital_Charge","write_dm"); - - return; -} - - -void Local_Orbital_Charge::read_dm(const int &is, const string &fn) -{ - TITLE("Local_Orbital_Charge","read_dm"); - timer::tick("Local_Orbital_Charge","read_dm"); - - ofs_running << "\n processor 0 is reading density matrix from file < " << fn << " > " << endl; - //xiaohui modify 2015-03-25 - //bool quit_mesia = false; - bool quit_abacus = false; - - ifstream ifs; - if(MY_RANK==0) - { - ifs.open(fn.c_str()); - if (!ifs) - { - //xiaohui modify 2015-03-25 - //quit_mesia = true; - quit_abacus = true; - } - else - { - // if the number is not match, - // quit the program or not. - bool quit=false; - - string name; - ifs >> name; - - // check lattice constant, unit is Angstrom - CHECK_DOUBLE(ifs,ucell.lat0 * BOHR_TO_A,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e11,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e12,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e13,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e21,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e22,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e23,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e31,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e32,quit); - CHECK_DOUBLE(ifs,ucell.latvec.e33,quit); - - for(int it=0; it> coordinate; - - for(int it=0; it> DM[is][i][j]; - } - } - } - else - { - WARNING_QUIT("Local_Orbital_Charge::read_dm","The nnrg should not be update"); - CHECK_INT(ifs,LNNR.nnrg); - - for(int i=0; i> DM_R[is][i]; - } - } -#else - - // distribution of necessary data - //xiaohui modify 2015-03-25 - //Parallel_Common::bcast_bool(quit_mesia); - Parallel_Common::bcast_bool(quit_abacus); - //xiaohui modify 2015-03-25 - //if(quit_mesia) - if(quit_abacus) - { - WARNING_QUIT("Local_Orbital_Charge::read_dm","Can not find the density matrix file."); - } - - - if(NSPIN==1||NSPIN==4) - { - Parallel_Common::bcast_double(en.ef); - } - else if(NSPIN==2) - { - Parallel_Common::bcast_double(en.ef_up); - Parallel_Common::bcast_double(en.ef_dw); - } - - - if(GAMMA_ONLY_LOCAL) - { - //ofs_running << " NLOCAL=" << NLOCAL << endl; - //ofs_running << " lgd_now=" << lgd_now << endl; - //ofs_running << " GridT.lgd=" << GridT.lgd << endl; - - double *tmp = new double[NLOCAL]; - for(int i=0; i Date: Sun, 7 Mar 2021 21:35:43 +0800 Subject: [PATCH 179/233] add some notes in gint_k.h and gint_k.cpp --- ABACUS.develop/source/src_lcao/DM_k.cpp | 8 +- ABACUS.develop/source/src_lcao/gint_k.cpp | 23 +++-- ABACUS.develop/source/src_lcao/gint_k.h | 102 ++++++++++------------ 3 files changed, 67 insertions(+), 66 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/DM_k.cpp b/ABACUS.develop/source/src_lcao/DM_k.cpp index 8df68428b7..e40b183c48 100644 --- a/ABACUS.develop/source/src_lcao/DM_k.cpp +++ b/ABACUS.develop/source/src_lcao/DM_k.cpp @@ -57,6 +57,7 @@ inline void cal_DM_ATOM(const Grid_Technique >, const complex fac, Rec const int ia1, const int iw1_lo, const int nw1, const int gstart, complex *WFC_PHASE, complex **DM_ATOM) { + const char transa='N', transb='T'; const complex alpha=1, beta=1; @@ -93,11 +94,15 @@ inline void cal_DM_ATOM(const Grid_Technique >, const complex fac, Rec const int iline=nRow*nw1; complex phase=exp_R*wg_local; for(int iw1=0; iw1DM_R[0][gstart+iv]=DM_ATOM[0][iv].real() + DM_ATOM[3][iv].real(); - if(NONCOLIN){//DOMAG + if(NONCOLIN) + {//DOMAG this->DM_R[1][gstart+iv]=DM_ATOM[1][iv].real() + DM_ATOM[2][iv].real(); this->DM_R[2][gstart+iv]=DM_ATOM[1][iv].imag() - DM_ATOM[2][iv].imag(); this->DM_R[3][gstart+iv]=DM_ATOM[0][iv].real() - DM_ATOM[3][iv].real(); diff --git a/ABACUS.develop/source/src_lcao/gint_k.cpp b/ABACUS.develop/source/src_lcao/gint_k.cpp index 0d07806da2..4249aff9a7 100644 --- a/ABACUS.develop/source/src_lcao/gint_k.cpp +++ b/ABACUS.develop/source/src_lcao/gint_k.cpp @@ -52,9 +52,14 @@ void Gint_k::allocate_pvpR(void) this->pvpR_reduced[is] = new double[LNNR.nnrg]; ZEROS( pvpR_reduced[is], LNNR.nnrg); } + double mem = Memory::record("allocate_pvpR", "pvpR_reduced", LNNR.nnrg * NSPIN , "double"); - //xiaohui add 'OUT_LEVEL' line, 2015-09-16 - if(OUT_LEVEL != "m") ofs_running << " Memory of pvpR : " << mem << " MB" << endl; + + if(OUT_LEVEL != "m") + { + ofs_running << " Memory of pvpR : " << mem << " MB" << endl; + } + if( mem > 800 ) { ofs_warning << " memory for pvpR = " << mem << endl; @@ -67,8 +72,12 @@ void Gint_k::allocate_pvpR(void) { double mem = Memory::record("allocate_pvpR", "pvpR", GridT.lgd * GridT.nutot * GridT.lgd * GridT.nutot , "double"); - //xiaohui add 'OUT_LEVEL' line, 2015-09-16 - if(OUT_LEVEL != "m") ofs_running << " Memory of pvpR : " << mem << " MB" << endl; + + if(OUT_LEVEL != "m") + { + ofs_running << " Memory of pvpR : " << mem << " MB" << endl; + } + if( mem > 800 ) { ofs_warning << " memory for pvpR = " << mem << endl; @@ -76,10 +85,6 @@ void Gint_k::allocate_pvpR(void) WARNING_QUIT("Gint_k","allocate_pvpR"); } - // output information - //cout << " MEMORY OF pvpR : " << Memory::record("allocate_pvpR", "pvpR", GridT.lgd * GridT.nutot - //* GridT.lgd * GridT.nutot , "cdouble") << " MB" << endl; - //---------------------------------------------- // allocate the complex matrix !! // nutot : total number of unitcells involved. @@ -87,8 +92,10 @@ void Gint_k::allocate_pvpR(void) // 3*3*3 = 27. //---------------------------------------------- const int LDIM=GridT.lgd*GridT.nutot; + this->pvpR_pool = new double[LDIM*LDIM]; ZEROS(pvpR_pool, LDIM*LDIM); + this->pvpR = new double*[LDIM]; for(int i=0; i>>>>>>>>>>>>>>>>>>> - // drive routine - //>>>>>>>>>>>>>>>>>>>> + // get the spin. + int get_spin(void)const{return spin_now;} + + + //------------------------------------------------------ + // in gint_k_vl.cpp + //------------------------------------------------------ // calculate the matrix elements of Hamiltonian matrix, // < phi_0 | Vl + Vh + Vxc | phi_R> or if the Vna is used, // < phi_0 | delta_Vh + Vxc | phi_R>. void cal_vlocal_k(const double* vrs1, const Grid_Technique >, const int spin=0); + //------------------------------------------------------ + // in gint_k.cpp + //------------------------------------------------------ void cal_vlocal_R(const int current_spin); //LiuXh add 2019-07-15 - // folding the < phi_0 | V | phi_R> matrix to // // V is (Vl + Vh + Vxc) if no Vna is used, @@ -43,7 +51,6 @@ class Gint_k : public Gint_k_init void folding_vl_k(const int &ik); void folding_vl_k_nc(const int &ik);//zhengdy-soc - // folding the < dphi_0 | V | phi_R> matrix to // < dphi_0i | V | phi_0j> void folding_force(matrix& fvl_dphi, @@ -53,89 +60,72 @@ class Gint_k : public Gint_k_init // < dphi_0i | V | phi_0j> void folding_stress(matrix& fvl_dphi, matrix& svl_dphi, double* pvdpx, double* pvdpy, double* pvdpz, - double* pvdp11, double* pvdp22, double* pvdp33, double* pvdp12, double* pvdp13, double* pvdp23);//zhengdy add 2016-10-18 - + double* pvdp11, double* pvdp22, double* pvdp33, + double* pvdp12, double* pvdp13, double* pvdp23);//zhengdy add 2016-10-18 - //>>>>>>>>>>>>>>>>>>>> - // drive routine - //>>>>>>>>>>>>>>>>>>>> + //------------------------------------------------------ + // in gint_k_rho.cpp + //------------------------------------------------------ // calculate the charge density. void calculate_charge(void); - - //>>>>>>>>>>>>>>>>>>>> - // drive routine - //>>>>>>>>>>>>>>>>>>>> + //------------------------------------------------------ + // in gint_k_fvl.cpp + //------------------------------------------------------ // calculate the force (many k-points). void fvl_k_RealSpace(matrix& fvl_dphi, const double* vl);//mohan add 2011-06-19 void svl_k_RealSpace(matrix& fvl_dphi, matrix& svl_dphi, const double* vl);//zhengdy add 2016-10-18 - - // reset the spin. - void reset_spin(const int &spin_now); - - - // get the spin. - int get_spin(void)const{return spin_now;} - - private: - - //============================ + //------------------------------------------------------ + // in gint_k.cpp + //------------------------------------------------------ // set the orbital info - //============================ // set the orbital/Ylm information on each real space grid. void set_ijk_atom(const int &grid_index, const int &size, double*** psir_ylm, double*** dr, bool** cal_flag, double** distance, double* ylma, const double &delta_r); - - //============================ - // set the orbital info - //============================ - // set the derivative/Ylm information on each real space grid. - void set_ijk_atom_force(const int &grid_index, const int &size, - double*** psir_ylm, double*** dr, bool** cal_flag, - double** distance, double* ylma, const double &delta_r, - double*** dphi_x, double ***dphi_y, double*** dphi_z); - - - //---------------------------- - // detail grid integration: - //---------------------------- + //------------------------------------------------------ + // in gint_k_vl.cpp + //------------------------------------------------------ // evaluate the matrix element < phi0 | V | phiR> and store them in // a full H matrix. void evaluate_pvpR_full(const int &grid_index, const int &size, double*** psir_ylm, bool** cal_flag, double* vldr3); - - //---------------------------- - // detail grid integration: - //---------------------------- // reduced means the H storage take the advance of adjacent atoms. - void evaluate_pvpR_reduced(double* pvpR, const int &grid_index, const int &size, const int &i, const int &j, const int &k, - double*** psir_ylm, bool** cal_flag, double* vldr3, double** distance, const Grid_Technique >); - - - - //---------------------------- - // detail grid integration: - //---------------------------- + void evaluate_pvpR_reduced(double* pvpR, const int &grid_index, + const int &size, const int &i, const int &j, const int &k, + double*** psir_ylm, bool** cal_flag, double* vldr3, + double** distance, const Grid_Technique >); + + //------------------------------------------------------ + // in gint_k_rho.cpp + //------------------------------------------------------ // evaluate the to get the charge density. void evaluate_pDMp(const int &grid_index, const int &size, bool** cal_flag, double*** psir_ylm, int* vindex); + //------------------------------------------------------ + // in gint_k_fvl.cpp + //------------------------------------------------------ + // set the orbital info + // set the derivative/Ylm information on each real space grid. + void set_ijk_atom_force(const int &grid_index, const int &size, + double*** psir_ylm, double*** dr, bool** cal_flag, + double** distance, double* ylma, const double &delta_r, + double*** dphi_x, double ***dphi_y, double*** dphi_z); - //---------------------------- - // detail grid integration: - //---------------------------- // evaluate the force due to local potential. void evaluate_vl_force(const int &grid_index, const int &size, const int &i, const int &j, const int &k, double*** psir_ylm, bool** cal_flag, double* vldr3, double** distance, double*** dphi_x, double*** dphi_y, double*** dphi_z, double* pvdpx, double* pvdpy, double* pvdpz, const Grid_Technique >); + + // evaluate the stresses due to local potential void evaluate_vl_stress(const int &grid_index, const int &size, const int &i, const int &j, const int &k, double*** psir_ylm, bool** cal_flag, double* vldr3, double** distance, double*** dphi_x, double*** dphi_y, double*** dphi_z, @@ -163,8 +153,6 @@ class Gint_k : public Gint_k_init // save the < phi_0i | V | phi_Rj > in sparse H matrix. double** pvpR_reduced; - - //---------------------------- // key variable //---------------------------- From c9056cdb1ddeeea2b0f9c8b65c2880015b04a909 Mon Sep 17 00:00:00 2001 From: mohan Date: Mon, 8 Mar 2021 21:19:31 +0800 Subject: [PATCH 180/233] add some notes in gint_gamma --- .../source/src_lcao/gint_gamma_env.cpp | 10 +- .../source/src_lcao/gint_gamma_fvl.cpp | 162 ++++++++---------- .../source/src_lcao/gint_gamma_mull.cpp | 7 +- 3 files changed, 81 insertions(+), 98 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_env.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_env.cpp index 23a2f1209d..b0b883d2c5 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_env.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_env.cpp @@ -15,10 +15,7 @@ void Gint_Gamma::cal_env(const double* wfc, double* rho) return; } -// this subroutine lies in the heart of LCAO algorithms. -// so it should be done very efficiently, very carefully. -// I might repeat again to emphasize this: need to optimize -// this code very efficiently, very carefully. + void Gint_Gamma::gamma_envelope(const double* wfc, double* rho) { TITLE("Grid_Integral","gamma_charge"); @@ -124,7 +121,10 @@ void Gint_Gamma::gamma_envelope(const double* wfc, double* rho) dr[ib][id][1] = GridT.meshcell_pos[ib][1] + mt[1]; dr[ib][id][2] = GridT.meshcell_pos[ib][2] + mt[2]; - distance[ib][id] = std::sqrt(dr[ib][id][0]*dr[ib][id][0] + dr[ib][id][1]*dr[ib][id][1] + dr[ib][id][2]*dr[ib][id][2]); + distance[ib][id] = std::sqrt(dr[ib][id][0]*dr[ib][id][0] + + dr[ib][id][1]*dr[ib][id][1] + + dr[ib][id][2]*dr[ib][id][2]); + if(distance[ib][id] <= ORB.Phi[it].getRcut()) { cal_flag[ib][id]=true; diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_fvl.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_fvl.cpp index df1d2edfcd..ec3a0cdb78 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_fvl.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_fvl.cpp @@ -15,6 +15,7 @@ void Gint_Gamma::cal_force(const double* vlocal_in) timer::tick("Gint_Gamma","cal_force",'H'); } + inline void setVindex(const int ncyz, const int ibx, const int jby, const int kbz, int* vindex) { int bindex = 0; @@ -34,11 +35,22 @@ inline void setVindex(const int ncyz, const int ibx, const int jby, const int kb } } -inline void cal_psir_ylm_dphi(int size, int grid_index, double delta_r, vector &rly, vector> &grly, // Peize Lin change rly, grly 2016-08-26 - const Numerical_Orbital_Lm* pointer, - int* block_index, int* block_iw, int* block_size, bool** cal_flag, - double** psir_ylm, double** dphix, double** dphiy, double** dphiz, - realArray& drr) +inline void cal_psir_ylm_dphi( + int size, + int grid_index, + double delta_r, + vector &rly, + vector> &grly, // Peize Lin change rly, grly 2016-08-26 + const Numerical_Orbital_Lm* pointer, + int* block_index, + int* block_iw, + int* block_size, + bool** cal_flag, + double** psir_ylm, + double** dphix, + double** dphiy, + double** dphiz, + realArray& drr) { block_index[0]=0; double mt[3]={0,0,0}; @@ -71,6 +83,7 @@ inline void cal_psir_ylm_dphi(int size, int grid_index, double delta_r, vector ORB.Phi[it].getRcut()) { ZEROS(p_psir_ylm, block_size[id]); @@ -96,6 +114,7 @@ inline void cal_psir_ylm_dphi(int size, int grid_index, double delta_r, vector>> the old method // ylma[id] = new double[nnn[it]]; // liaochen found this bug 2010/03/29 @@ -131,21 +150,6 @@ inline void cal_psir_ylm_dphi(int size, int grid_index, double delta_r, vectoriq[id] = static_cast(position); - //this->x0[id] = position - iq[id]; - //this->x1[id] = 1.0 - x0[id]; - //this->x2[id] = 2.0 - x0[id]; - //this->x3[id] = 3.0 - x0[id]; - //this->x12[id] = x1[id]*x2[id] / 6; - //this->x03[id] = x0[id]*x3[id] / 2; - // iq[id] = static_cast(position); - // x0[id] = position - iq[id]; - // x1[id] = 1.0 - x0[id]; - // x2[id] = 2.0 - x0[id]; - // x3[id] = 3.0 - x0[id]; - // x12[id] = x1[id]*x2[id] / 6; - // x03[id] = x0[id]*x3[id] / 2; - iq = static_cast(position); x0 = position - iq; @@ -192,15 +196,6 @@ inline void cal_psir_ylm_dphi(int size, int grid_index, double delta_r, vectorpsi_uniform[iq[id]]*x3[id] - // +pointer->psi_uniform[iq[id]+3]*x0[id]) - // + x03[id]*(pointer->psi_uniform[iq[id]+1]*x2[id] - // -pointer->psi_uniform[iq[id]+2]*x1[id]); - - // dtmp = x12[id]*(pointer->dpsi_uniform[iq[id]]*x3[id] - // +pointer->dpsi_uniform[iq[id]+3]*x0[id]) - // + x03[id]*(pointer->dpsi_uniform[iq[id]+1]*x2[id] - // -pointer->dpsi_uniform[iq[id]+2]*x1[id]); tmp = x12*(pointer->psi_uniform[iq]*x3 +pointer->psi_uniform[iq+3]*x0) @@ -272,13 +267,20 @@ inline void cal_psir_ylm_dphi(int size, int grid_index, double delta_r, vectorgrid_index = (k-GridT.nbzp_start) + j * GridT.nbzp + i * GridT.nby * GridT.nbzp; const int size = GridT.how_many_atoms[ this->grid_index ]; if(size==0)continue; - //timer::tick("Gint_Gamma","vindex",'J'); setVindex(ncyz, ibx, jby, kbz, vindex); for(int ib=0; ibvlocal[vindex[ib]] * this->vfactor; } - //timer::tick("Gint_Gamma","vindex",'J'); - // OUT(ofs_running, "k was setted as", k); - - //inline void cal_psir_ylm_dphi(int size, int grid_index, double delta_r, double rly, double grly, - // const Numerical_Orbital_Lm* pointer, - // int* block_index, int* block_iw, int* block_size, - // double** psir_ylm, double** dphix, double** dphiy, double** dphiz) - //OUT(ofs_running,"Start cal_psir_ylm_dphi"); - //timer::tick("Gint_Gamma","dphi",'J'); cal_psir_ylm_dphi(size, grid_index, delta_r, rly, grly, pointer, block_index, block_iw, block_size, cal_flag, psir_ylm, dphix, dphiy, dphiz, drr); - //timer::tick("Gint_Gamma","dphi",'J'); - //inline void cal_meshball_DGridV(int size, int GridT.lgd, int LD_pool, int* block_index, int* block_iw, int* block_size, double* vldr3, - // double** psir_ylm, double** psir_vlbr3, double** dphix, double** dphiy, double** dphiz, - // double** DGridV_x, double** DGridV_y, double** DGridV_z) - // OUT(ofs_running,"Start cal_meshball_DGridV"); - - //timer::tick("Gint_Gamma","dpvp",'J'); cal_meshball_DGridV(size, GridT.lgd, LD_pool, block_index, block_iw, block_size, cal_flag, vldr3, psir_ylm, psir_vlbr3, dphix, dphiy, dphiz, DGridV_x, DGridV_y, DGridV_z, DGridV_11, DGridV_12, DGridV_13, DGridV_22, DGridV_23, DGridV_33, drr); - //timer::tick("Gint_Gamma","dpvp",'J'); - // OUT(ofs_running,"cal_meshball_DGridV was done"); }// k }// j }// i @@ -728,30 +706,32 @@ void Gint_Gamma::gamma_force(void) double* tmp22; double* tmp23; double* tmp33; - if(STRESS) - { - tmp11 = new double[NLOCAL]; - tmp12 = new double[NLOCAL]; - tmp13 = new double[NLOCAL]; - tmp22 = new double[NLOCAL]; - tmp23 = new double[NLOCAL]; - tmp33 = new double[NLOCAL]; - } + + if(STRESS) + { + tmp11 = new double[NLOCAL]; + tmp12 = new double[NLOCAL]; + tmp13 = new double[NLOCAL]; + tmp22 = new double[NLOCAL]; + tmp23 = new double[NLOCAL]; + tmp33 = new double[NLOCAL]; + } for (int i=0; i Date: Tue, 9 Mar 2021 20:48:31 +0800 Subject: [PATCH 181/233] add RELAX_cell in src_lcao --- ABACUS.develop/source/Makefile.Objects | 1 + ABACUS.develop/source/run_lcao.cpp | 8 +++++--- ABACUS.develop/source/src_lcao/RELAX_cell.cpp | 17 +++++++++++++++++ ABACUS.develop/source/src_lcao/RELAX_cell.h | 15 +++++++++++++++ .../source/src_lcao/local_orbital_wfc.cpp | 19 +++++++++---------- 5 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 ABACUS.develop/source/src_lcao/RELAX_cell.cpp create mode 100644 ABACUS.develop/source/src_lcao/RELAX_cell.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index f91384c01a..b81affeb2a 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -137,6 +137,7 @@ ELEC_cbands_gamma.o\ ELEC_evolve.o\ ELEC_scf.o\ ELEC_nscf.o\ +RELAX_cell.o\ local_orbital_ions.o\ local_orbital_charge.o\ DM_gamma.o\ diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index 5f118670a3..d7ee66a019 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -10,7 +10,7 @@ #include "src_lcao/dftu.h" //Quxin add for DFT+U on 20201029 #include "src_io/winput.h" #include "src_global/sltk_atom_arrange.h" -#include "src_lcao/local_orbital_ions.h" +#include "src_lcao/RELAX_cell.h" #include "src_io/print_info.h" #include "src_pw/symmetry.h" @@ -149,8 +149,10 @@ void Run_lcao::lcao_line(void) dftu.init(); } - Local_Orbital_Ions ions; - ions.opt_ions(); + // mohan add 2021-03-09 + RELAX_cell rcell; + rcell.opt_cell(); + en.perform_dos(); timer::tick("Run_lcao","lcao_line",'A'); diff --git a/ABACUS.develop/source/src_lcao/RELAX_cell.cpp b/ABACUS.develop/source/src_lcao/RELAX_cell.cpp new file mode 100644 index 0000000000..3b7a7e776b --- /dev/null +++ b/ABACUS.develop/source/src_lcao/RELAX_cell.cpp @@ -0,0 +1,17 @@ +#include "RELAX_cell.h" +#include "local_orbital_ions.h" + + +RELAX_cell::RELAX_cell(){} + +RELAX_cell::~RELAX_cell(){} + + +void RELAX_cell::opt_cell() +{ + Local_Orbital_Ions ions; + ions.opt_ions(); + + return; +} + diff --git a/ABACUS.develop/source/src_lcao/RELAX_cell.h b/ABACUS.develop/source/src_lcao/RELAX_cell.h new file mode 100644 index 0000000000..05fab63a0e --- /dev/null +++ b/ABACUS.develop/source/src_lcao/RELAX_cell.h @@ -0,0 +1,15 @@ +#ifndef RELAX_CELL_H +#define RELAX_CELL_H + +class RELAX_cell +{ + public: + + RELAX_cell(); + ~RELAX_cell(); + + void opt_cell(void); + +}; + +#endif diff --git a/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp b/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp index 5cb397f1d8..7e1e607a88 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_wfc.cpp @@ -167,8 +167,10 @@ void Local_Orbital_wfc::set_trace_aug(const Grid_Technique >) // this function must be called after ParaO.trace_loc_row // , ParaO.trace_loc_col and GridT.trace_lo have been called. - //xiaohui add 'OUT_LEVEL' line, 2015-09-16 - if(OUT_LEVEL != "m") ofs_running << "\n SETUP ARRAY FOR EXTRA WAVE FUNCTIONS" << endl; + if(OUT_LEVEL != "m") + { + ofs_running << "\n SETUP ARRAY FOR EXTRA WAVE FUNCTIONS" << endl; + } bool* occ2d = new bool[NLOCAL]; for(int i=0; itrace_aug[i] = daug; -// ofs_running << " report daug " << setw(5) << i << setw(5) << daug << endl; ++daug; } } @@ -217,10 +218,6 @@ void Local_Orbital_wfc::set_trace_aug(const Grid_Technique >) //--------------------------------- //second part: prepare for c_aug. //--------------------------------- - // mohan add 2010-09-26 - //OUT(ofs_running,"allocate_aug_flag",allocate_aug_flag); - - // mohan fix bug 2011-03-03 static bool first = true; if(first) { @@ -255,7 +252,7 @@ void Local_Orbital_wfc::set_trace_aug(const Grid_Technique >) } } } - else //mohan add 2012-01-08 + else { for(int ik=0; ik Date: Wed, 10 Mar 2021 21:58:28 +0800 Subject: [PATCH 182/233] add some notes in pdiag_double --- .../source/src_lcao/LCAO_matrix.cpp | 2 + .../source/src_pdiag/pdiag_double.cpp | 60 +++++++++++++++---- .../source/src_pdiag/pdiag_double.h | 3 + 3 files changed, 55 insertions(+), 10 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/LCAO_matrix.cpp b/ABACUS.develop/source/src_lcao/LCAO_matrix.cpp index bbba7fd10b..4f57025ddb 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_matrix.cpp @@ -44,6 +44,8 @@ void LCAO_Matrix::divide_HS_in_frag(void) { ofs_running << " divide the H&S matrix using 2D block algorithms." << endl; #ifdef __MPI + // the storage form of H and S matrices on each processor + // is determined in 'divide_HS_2d' subroutine ParaO.divide_HS_2d(DIAG_WORLD); #else WARNING_QUIT("LCAO_Matrix::init","diago method is not ready."); diff --git a/ABACUS.develop/source/src_pdiag/pdiag_double.cpp b/ABACUS.develop/source/src_pdiag/pdiag_double.cpp index df466f5e1a..1e70060e77 100644 --- a/ABACUS.develop/source/src_pdiag/pdiag_double.cpp +++ b/ABACUS.develop/source/src_pdiag/pdiag_double.cpp @@ -395,8 +395,13 @@ void Pdiag_Double::divide_HS_2d return; } -void Pdiag_Double::diago_double_begin(const int &ik, double **wfc, matrix &wfc_2d, - double* h_mat, double* s_mat, double* ekb) +void Pdiag_Double::diago_double_begin( + const int &ik, // k-point index + double **wfc, // wave functions + matrix &wfc_2d, // wave functions in 2d + double* h_mat, // hamiltonian matrix + double* s_mat, // overlap matrix + double* ekb) // eigenvalues for each k-point and band { #ifdef TEST_DIAG { @@ -512,6 +517,7 @@ void Pdiag_Double::diago_double_begin(const int &ik, double **wfc, matrix &wfc_2 MPI_Reduce(&nloc, &maxnloc, 1, MPI_LONG, MPI_MAX, 0, comm_2D); MPI_Bcast(&maxnloc, 1, MPI_LONG, 0, comm_2D); wfc_2d.create(this->ncol,this->nrow); // Fortran order + double *work=new double[maxnloc]; // work/buffer matrix static int method; bool wantEigenVector=true; @@ -545,9 +551,11 @@ void Pdiag_Double::diago_double_begin(const int &ik, double **wfc, matrix &wfc_2 LapackConnector::copy(NBANDS, eigen, inc, ekb, inc); delete[] eigen; OUT(ofs_running,"eigenvalues were copied to ekb"); + if(NEW_DM==0) { - //convert wave function to band distribution and calculate the density matrix in the tranditional way + // convert wave function to band distribution + // and calculate the density matrix in the tranditional way // redistribute eigenvectors to wfc / wfc_aug timer::tick("Diago_LCAO_Matrix","gath_eig",'G'); @@ -630,18 +638,30 @@ void Pdiag_Double::diago_double_begin(const int &ik, double **wfc, matrix &wfc_2 const int itype=1; int lwork=-1, info=0; vector work(1,0); - dsygv_(&itype, &jobz, &uplo, &NLOCAL, wfc_2d.c, &NLOCAL, s_tmp.c, &NLOCAL, ekb_tmp.data(), work.data(), &lwork, &info); + dsygv_(&itype, &jobz, &uplo, &NLOCAL, wfc_2d.c, &NLOCAL, + s_tmp.c, &NLOCAL, ekb_tmp.data(), work.data(), &lwork, &info); + if(info) + { throw runtime_error("info="+TO_STRING(info)+". "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + } + lwork = work[0]; work.resize(lwork); - dsygv_(&itype, &jobz, &uplo, &NLOCAL, wfc_2d.c, &NLOCAL, s_tmp.c, &NLOCAL, ekb_tmp.data(), work.data(), &lwork, &info); + + dsygv_(&itype, &jobz, &uplo, &NLOCAL, wfc_2d.c, &NLOCAL, + s_tmp.c, &NLOCAL, ekb_tmp.data(), work.data(), &lwork, &info); + if(info) + { throw runtime_error("info="+TO_STRING(info)+". "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + } memcpy( ekb, ekb_tmp.data(), sizeof(double)*NBANDS ); if(NEW_DM==0) + { throw domain_error("NEW_DM must be 1. "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + } } else if(KS_SOLVER=="lapack_gvx") { @@ -658,23 +678,35 @@ void Pdiag_Double::diago_double_begin(const int &ik, double **wfc, matrix &wfc_2 vector work(1,0); vector iwork(5*NLOCAL,0); vector ifail(NLOCAL,0); + dsygvx_(&itype, &jobz, &range, &uplo, &NLOCAL, h_tmp.c, &NLOCAL, s_tmp.c, &NLOCAL, NULL, NULL, &il, &iu, &abstol, &M, ekb, wfc_2d.c, &NLOCAL, work.data(), &lwork, iwork.data(), ifail.data(), &info); + if(info) + { throw runtime_error("info="+TO_STRING(info)+". "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + } + lwork = work[0]; work.resize(lwork); dsygvx_(&itype, &jobz, &range, &uplo, &NLOCAL, h_tmp.c, &NLOCAL, s_tmp.c, &NLOCAL, NULL, NULL, &il, &iu, &abstol, &M, ekb, wfc_2d.c, &NLOCAL, work.data(), &lwork, iwork.data(), ifail.data(), &info); + if(info) + { throw runtime_error("info="+TO_STRING(info)+". "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + } if(M!=NBANDS) + { throw runtime_error("M="+TO_STRING(M)+". NBANDS="+TO_STRING(NBANDS)+". "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + } if(NEW_DM==0) + { throw domain_error("NEW_DM must be 1. "+TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + } } else if(KS_SOLVER=="scalapack_gvx") { @@ -699,32 +731,42 @@ void Pdiag_Double::diago_double_begin(const int &ik, double **wfc, matrix &wfc_2 NULL, NULL, &il, &iu, &abstol, &M, &NZ, ekb, &orfac, wfc_2d.c, &one, &one, desc, work.data(), &lwork, iwork.data(), &liwork, ifail.data(), iclustr.data(), gap.data(), &info); + ofs_running<<"lwork="< **wfc, ComplexMatrix &wfc_2d, complex *ch_mat, complex *cs_mat, double *ekb); // Peize Lin add wfc_2d 2019-01-17 @@ -32,6 +34,7 @@ class Pdiag_Double : public Pdiag_Basic void readin(const string &fa, const string &fb, const int &nlocal, double *eigen, double *eigvr); #endif + // be called void divide_HS_2d ( #ifdef __MPI From eaf9cac7c823083b7195d00eb8bd0943460d810f Mon Sep 17 00:00:00 2001 From: mohan Date: Thu, 11 Mar 2021 21:42:56 +0800 Subject: [PATCH 183/233] add notes in gint_gamma_vl --- ABACUS.develop/source/src_lcao/LCAO_diago.cpp | 34 ++++---- .../source/src_lcao/gint_gamma_vl.cpp | 78 ++++++++----------- .../source/src_pdiag/pdiag_basic.cpp | 33 ++++---- .../source/src_pdiag/pdiag_double.cpp | 5 +- 4 files changed, 63 insertions(+), 87 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/LCAO_diago.cpp b/ABACUS.develop/source/src_lcao/LCAO_diago.cpp index f360707ac9..b6afd053ce 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_diago.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_diago.cpp @@ -8,15 +8,15 @@ Diago_LCAO_Matrix::Diago_LCAO_Matrix(){} Diago_LCAO_Matrix::~Diago_LCAO_Matrix(){} -void Diago_LCAO_Matrix::solve_complex_matrix(const int &ik, complex** wfc, ComplexMatrix &wfc_2d)const +void Diago_LCAO_Matrix::solve_complex_matrix( + const int &ik, + complex** wfc, + ComplexMatrix &wfc_2d)const { TITLE("Diago_LCAO_Matrix","solve_complex_matrix"); time_t time_start = time(NULL); -// ofs_running << " Start Time : " << ctime(&time_start); -// - //if(DIAGO_TYPE=="lapack") xiaohui modify 2013-09-02 - if(KS_SOLVER=="lapack") //xiaohui add 2013-09-02 + if(KS_SOLVER=="lapack") { this->using_LAPACK_complex(ik, wfc); } @@ -30,27 +30,28 @@ void Diago_LCAO_Matrix::solve_complex_matrix(const int &ik, complex** wf } time_t time_end = time(NULL); -// ofs_running << " End Time : " << ctime(&time_end); -// ofs_running << " FINAL Time : " << difftime(time_end, time_start) << " (SEC)" << endl; OUT_TIME("diago(complex)", time_start, time_end); return; } -void Diago_LCAO_Matrix::solve_double_matrix(const int &ik, double** wfc, matrix &wfc_2d)const + +void Diago_LCAO_Matrix::solve_double_matrix( + const int &ik, + double** wfc, + matrix &wfc_2d)const { TITLE("Diago_LCAO_Matrix","solve_double_matrix"); timer::tick("Diago_LCAO_Matrix","solve_double_matrix",'F'); time_t time_start = time(NULL); - if(KS_SOLVER=="lapack") //xiaohui add 2013-09-02 + if(KS_SOLVER=="lapack") { this->using_LAPACK(ik, wfc); } #ifdef __MPI - // yshen add 7/15/2016 else if(KS_SOLVER=="hpseps" || KS_SOLVER=="genelpa"|| KS_SOLVER=="scalapack_gvx") { this->using_HPSEPS_double(ik, wfc, wfc_2d); @@ -61,6 +62,7 @@ void Diago_LCAO_Matrix::solve_double_matrix(const int &ik, double** wfc, matrix cout << " Diago_LCAO_Matrix, diago_type = " << KS_SOLVER << endl; WARNING_QUIT("Diago_LCAO_Matrix::init","Check KS_SOLVER."); } + time_t time_end = time(NULL); OUT_TIME("diago(double)",time_start, time_end); @@ -83,14 +85,6 @@ void Diago_LCAO_Matrix::using_HPSEPS_double(const int &ik, double**wfc, matrix & // prallel eigensolver. ParaO.diago_double_begin(ik, wfc, wfc_2d, LM.Hloc, LM.Sloc, wf.ekb[ik]); - /* - string fh = "/home/mohan/3_my_program/1_DAPE/data/data-H32"; - string fs = "/home/mohan/3_my_program/1_DAPE/data/data-S32"; - double* eigen = new double[32]; - double* eigvr = new double[32*32]; - PD.readin(fh, fs, 32, eigen, eigvr); - */ - return; } @@ -181,16 +175,16 @@ void Diago_LCAO_Matrix::using_LAPACK_complex(const int &ik, complex **wf } } - //cout << "\n Energy for k=" << ik << endl; + // energy for k-point ik for(int ib=0; ibnw; + colidx[id+1]=colidx[id]+atom->nw; + // meshball_positions should be the bigcell position in meshball // to the center of meshball. // calculated in cartesian coordinates @@ -69,6 +85,7 @@ inline void cal_psir_ylm(int size, int grid_index, double delta_r, double phi, mt[1]=GridT.meshball_positions[imcell][1] - GridT.tau_in_bigcell[iat][1]; mt[2]=GridT.meshball_positions[imcell][2] - GridT.tau_in_bigcell[iat][2]; + // number of grids in each big cell (bxyz) for(int ib=0; ibgrid_index=(k-nbz_start) + j * nbz + i * nby * nbz; int grid_index_thread=(k-nbz_start) + j * nbz + i * nby * nbz; // get the value: how many atoms has orbital value on this grid. @@ -521,23 +534,11 @@ void Gint_Gamma::gamma_vlocal(void) // Peize Lin update OpenMP 2020.09.27 vldr3[ib]=this->vlocal[vindex[ib]] * this->vfactor; } - //OUT(ofs_running, "vldr3 was inited"); - //timer::tick("Gint_Gamma","cal_vlocal_psir",'J'); - //cal_psir_ylm(size, this->grid_index, delta_r, phi, mt, dr, - // distance, pointer, ylma, colidx, block_iw, bsize, psir_ylm, cal_flag); cal_psir_ylm(size, grid_index_thread, delta_r, phi, mt, dr, distance, pointer, ylma, colidx, block_iw, bsize, psir_ylm, cal_flag); - //cal_psir_ylm(size, this->grid_index, delta_r, phi, mt, dr, - // distance, pointer, ylma, colidx, block_iw, bsize, psir_ylm, i, j, k); - //timer::tick("Gint_Gamma","cal_vlocal_psir",'J'); - //OUT(ofs_running, "psir_ylm was calculated"); - //timer::tick("Gint_Gamma","cal_meshball_vlocal",'J'); - //cal_meshball_vlocal(size, LD_pool, block_iw, bsize, colidx, - // vldr3, psir_ylm, psir_vlbr3, vindex, lgd_now, GridVlocal); + cal_meshball_vlocal(size, LD_pool, block_iw, bsize, colidx, cal_flag, vldr3, psir_ylm, psir_vlbr3, vindex, lgd_now, GridVlocal_thread); - //timer::tick("Gint_Gamma","cal_meshball_vlocal",'J'); - //OUT(ofs_running, "GridVlocal was calculated"); }// k }// j }// i @@ -600,14 +601,6 @@ void Gint_Gamma::gamma_vlocal(void) // Peize Lin update OpenMP 2020.09.27 if(CHR.get_new_e_iteration()) { timer::tick("Gint_Gamma","distri_vl_index",'K'); - // OUT(ofs_running, "Setup Buffer Parameters"); - // inline int setBufferParameter(MPI_Comm comm_2D, int blacs_ctxt, int nblk, - // int& sender_index_size, int*& sender_local_index, - // int*& sender_size_process, int*& sender_displacement_process, - // int& sender_size, double*& sender_buffer, - // int& receiver_index_size, int*& receiver_global_index, - // int*& receiver_size_process, int*& receiver_displacement_process, - // int& receiver_size, double*& receiver_buffer) setBufferParameter(ParaO.comm_2D, ParaO.blacs_ctxt, ParaO.nb, ParaO.sender_index_size, ParaO.sender_local_index, ParaO.sender_size_process, ParaO.sender_displacement_process, @@ -621,14 +614,11 @@ void Gint_Gamma::gamma_vlocal(void) // Peize Lin update OpenMP 2020.09.27 timer::tick("Gint_Gamma","distri_vl_index",'K'); } - // OUT(ofs_running, "Start data transforming"); timer::tick("Gint_Gamma","distri_vl_value",'K'); + // put data to send buffer for(int i=0; i=NLOCAL||g_row<0 || g_row>=NLOCAL) @@ -666,10 +654,8 @@ void Gint_Gamma::gamma_vlocal(void) // Peize Lin update OpenMP 2020.09.27 LM.set_HSgamma(g_row,g_col,ParaO.receiver_buffer[i/2],'L'); } - // OUT(ofs_running, "received vlocal data are put in to H") timer::tick("Gint_Gamma","distri_vl_value",'K'); timer::tick("Gint_Gamma","distri_vl",'K'); - //OUT(ofs_running, "reduce all vlocal ok,"); for (int i=0; ilastband_in_proc = 0; this->lastband_number = 0; @@ -101,7 +100,7 @@ void Pdiag_Basic::set_parameters(void) { if (idim0 = (int)sqrt((double)DSIZE); //mohan update 2012/01/13 //while (NPROC_IN_POOL%dim0!=0) @@ -325,7 +322,7 @@ void Pdiag_Double::divide_HS_2d } assert(dim0 > 0); this->dim1=DSIZE/dim0; -// testpb=1; //mohan test + if(testpb)OUT(ofs_running,"dim0",dim0); if(testpb)OUT(ofs_running,"dim1",dim1); From 1613038a302e0213d661ded13e0e4bc5b203d555 Mon Sep 17 00:00:00 2001 From: mohan Date: Thu, 11 Mar 2021 22:14:03 +0800 Subject: [PATCH 184/233] add notes in gint_gamma_vl.cpp --- .../source/src_lcao/gint_gamma_vl.cpp | 155 +++++++++++------- 1 file changed, 94 insertions(+), 61 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp index 9c09a257c4..8053da31e8 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp @@ -264,61 +264,91 @@ inline int localIndex(int globalIndex, int nblk, int nprocs, int& myproc) } -inline int setBufferParameter(MPI_Comm comm_2D, int blacs_ctxt, int nblk, - int& sender_index_size, int*& sender_local_index, - int*& sender_size_process, int*& sender_displacement_process, - int& sender_size, double*& sender_buffer, - int& receiver_index_size, int*& receiver_global_index, - int*& receiver_size_process, int*& receiver_displacement_process, - int& receiver_size, double*& receiver_buffer) +//------------------------------------------------------------------ +// mohan add notes: 2021-03-11 +// this subroutine is used to transform data from grid integrals +// to 2D-block distribution +// s stands for 'sender' and r stands for 'receiver' +//------------------------------------------------------------------ +inline int setBufferParameter( + MPI_Comm comm_2D, + int blacs_ctxt, + int nblk, + int& s_index_siz, + int*& s_local_index, + int*& s_siz_pro, + int*& s_dis_pro, + int& s_siz, + double*& s_buffer, + int& r_index_siz, + int*& r_global_index, + int*& r_siz_pro, + int*& r_dis_pro, + int& r_siz, + double*& r_buffer) { + //----------------------------------------- // setup blacs parameters + //----------------------------------------- int nprows, npcols, nprocs; int myprow, mypcol, myproc; + Cblacs_gridinfo(blacs_ctxt, &nprows, &npcols, &myprow, &mypcol); + + //----------------------------------------- + // set index of current proor: myproc + // set number of total proors: nprocs + //----------------------------------------- Cblacs_pinfo(&myproc, &nprocs); - // init data arrays - delete[] sender_size_process; - sender_size_process=new int[nprocs]; - delete[] sender_displacement_process; - sender_displacement_process=new int[nprocs]; - - delete[] receiver_size_process; - receiver_size_process=new int[nprocs]; - delete[] receiver_displacement_process; - receiver_displacement_process=new int[nprocs]; - - // build the local index to be sent to other process (sender_local_index), - // the global index to be received from other process (receiver_global_index), - // the send/receive size/displacement for data exchange by MPI_Alltoall - sender_index_size=GridT.lgd*GridT.lgd*2; - delete[] sender_local_index; - sender_local_index=new int[sender_index_size]; - - int *sender_global_index=new int[sender_index_size]; + // initialize data arrays + delete[] s_siz_pro; + delete[] s_dis_pro; + delete[] r_siz_pro; + delete[] r_dis_pro; + + s_siz_pro=new int[nprocs]; + s_dis_pro=new int[nprocs]; + r_siz_pro=new int[nprocs]; + r_dis_pro=new int[nprocs]; + + //--------------------------------------------------------------------- + // build the local index to be sent to other pro (s_local_index), + // the global index to be received from other pro (r_global_index), + // the send/receive siz/dis for data exchange by MPI_Alltoall + //--------------------------------------------------------------------- + s_index_siz=GridT.lgd*GridT.lgd*2; + + delete[] s_local_index; + s_local_index=new int[s_index_siz]; + + int *s_global_index=new int[s_index_siz]; int pos=0; - sender_size_process[0]=0; + s_siz_pro[0]=0; for(int iproc=0; iproc= NLOCAL) continue; + for(int icol=0, gcol=0; gcol= NLOCAL) continue; - // if(pos<0 || pos >= current_sender_index_size) + // if(pos<0 || pos >= current_s_index_siz) // { // OUT(ofs_running, "pos error, pos:", pos); // OUT(ofs_running, "irow:", irow); @@ -328,58 +358,61 @@ inline int setBufferParameter(MPI_Comm comm_2D, int blacs_ctxt, int nblk, // OUT(ofs_running, "lrow:", grow); // OUT(ofs_running, "lcol:", gcol); // } - sender_global_index[pos]=grow; - sender_global_index[pos+1]=gcol; - sender_local_index[pos]=lrow; - sender_local_index[pos+1]=lcol; + s_global_index[pos]=grow; + s_global_index[pos+1]=gcol; + s_local_index[pos]=lrow; + s_local_index[pos+1]=lcol; pos+=2; } } - sender_size_process[iproc]=pos-sender_displacement_process[iproc]; + s_siz_pro[iproc]=pos-s_dis_pro[iproc]; } - MPI_Alltoall(sender_size_process, 1, MPI_INT, - receiver_size_process, 1, MPI_INT, comm_2D); + MPI_Alltoall(s_siz_pro, 1, MPI_INT, + r_siz_pro, 1, MPI_INT, comm_2D); - receiver_index_size=receiver_size_process[0]; - receiver_displacement_process[0]=0; + r_index_siz=r_siz_pro[0]; + r_dis_pro[0]=0; for(int i=1; i Date: Wed, 10 Mar 2021 14:36:41 +0800 Subject: [PATCH 185/233] 1. Restructure vdwd2. Split class Vdwd2 to Vdwd2 and Vdwd2_Parameters. --- ABACUS.develop/source/input_conv.cpp | 20 +- ABACUS.develop/source/src_global/matrix3.cpp | 9 + ABACUS.develop/source/src_global/matrix3.h | 4 +- .../source/src_lcao/FORCE_STRESS.cpp | 31 +- .../source/src_lcao/local_orbital_elec.cpp | 8 +- .../source/src_lcao/local_orbital_ions.cpp | 6 +- ABACUS.develop/source/src_pw/energy.cpp | 26 +- ABACUS.develop/source/src_pw/energy.h | 1 + ABACUS.develop/source/src_pw/forces.cpp | 12 +- ABACUS.develop/source/src_pw/global.cpp | 3 +- ABACUS.develop/source/src_pw/global.h | 2 + ABACUS.develop/source/src_pw/ions.cpp | 8 +- ABACUS.develop/source/src_pw/stress_pw.cpp | 5 +- .../source/src_pw/unitcell_pseudo.cpp | 3 + ABACUS.develop/source/src_pw/vdwd2.cpp | 196 +++----- ABACUS.develop/source/src_pw/vdwd2.h | 58 ++- .../source/src_pw/vdwd2_parameters.cpp | 448 ++++++++++-------- .../source/src_pw/vdwd2_parameters.h | 39 ++ 18 files changed, 474 insertions(+), 405 deletions(-) create mode 100644 ABACUS.develop/source/src_pw/vdwd2_parameters.h diff --git a/ABACUS.develop/source/input_conv.cpp b/ABACUS.develop/source/input_conv.cpp index 6a0d6bc1a8..0cc6c51edb 100644 --- a/ABACUS.develop/source/input_conv.cpp +++ b/ABACUS.develop/source/input_conv.cpp @@ -9,7 +9,7 @@ #include "src_lcao/ORB_read.h" #include "src_pw/efield.h" #include "src_lcao/global_fp.h" -#include "src_pw/vdwd2.h" +#include "src_pw/vdwd2_parameters.h" #include "src_pw/vdwd3.h" #include "src_io/chi0_hilbert.h" #include "src_io/chi0_standard.h" @@ -189,26 +189,26 @@ void Input_Conv::Convert(void) //---------------------------------------------------------- if(INPUT.vdw_method=="d2") { - vdwd2.vdwD2 = true; - vdwd2.scaling = std::stod(INPUT.vdw_s6); - vdwd2.damping = INPUT.vdw_d; - vdwd2.C6_input(INPUT.vdw_C6_file, INPUT.vdw_C6_unit); - vdwd2.R0_input(INPUT.vdw_R0_file, INPUT.vdw_R0_unit); - vdwd2.model = INPUT.vdw_model; + vdwd2_para.flag_vdwd2 = true; + vdwd2_para.scaling = std::stod(INPUT.vdw_s6); + vdwd2_para.damping = INPUT.vdw_d; + vdwd2_para.C6_input(INPUT.vdw_C6_file, INPUT.vdw_C6_unit); + vdwd2_para.R0_input(INPUT.vdw_R0_file, INPUT.vdw_R0_unit); + vdwd2_para.model = INPUT.vdw_model; if(INPUT.vdw_model=="radius") { if(INPUT.vdw_radius_unit=="Bohr") { - vdwd2.radius = std::stod(INPUT.vdw_radius); + vdwd2_para.radius = std::stod(INPUT.vdw_radius); } else { - vdwd2.radius = std::stod(INPUT.vdw_radius) * BOHR_TO_A; + vdwd2_para.radius = std::stod(INPUT.vdw_radius) * BOHR_TO_A; } } else if(INPUT.vdw_model=="period") { - vdwd2.period = INPUT.vdw_period; + vdwd2_para.period = INPUT.vdw_period; } } if(INPUT.vdw_method=="d3_0" || INPUT.vdw_method=="d3_bj") diff --git a/ABACUS.develop/source/src_global/matrix3.cpp b/ABACUS.develop/source/src_global/matrix3.cpp index d26ad50462..5495eb1de9 100644 --- a/ABACUS.develop/source/src_global/matrix3.cpp +++ b/ABACUS.develop/source/src_global/matrix3.cpp @@ -193,3 +193,12 @@ void Matrix3::print(void)const cout << e31 << setw(15) << e32 << setw(15) << e33 << endl ; return; } + +matrix Matrix3::to_matrix(void)const // Peize Lin add 2021.03.09 +{ + matrix m(3,3); + m(0,0)=e11; m(0,1)=e12; m(0,2)=e13; + m(1,0)=e21; m(1,1)=e22; m(1,2)=e23; + m(2,0)=e31; m(2,1)=e32; m(2,2)=e33; + return m; +} \ No newline at end of file diff --git a/ABACUS.develop/source/src_global/matrix3.h b/ABACUS.develop/source/src_global/matrix3.h index a11ee16f00..a22afc9144 100644 --- a/ABACUS.develop/source/src_global/matrix3.h +++ b/ABACUS.develop/source/src_global/matrix3.h @@ -9,7 +9,8 @@ #include "../src_parallel/mcd.h" #endif -#include "vector3.h" +#include "src_global/vector3.h" +#include "src_global/matrix.h" class Matrix3 { @@ -36,6 +37,7 @@ class Matrix3 Matrix3& operator/=(const double &s); void print(void)const; + matrix to_matrix(void)const; }; Matrix3 operator +(const Matrix3 &m1, const Matrix3 &m2); //m1+m2 diff --git a/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp b/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp index 6dc8e2ea49..5eb7d1e623 100644 --- a/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp +++ b/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp @@ -130,14 +130,27 @@ void Force_Stress_LCAO::getForceStress( svl_dphi); //implement vdw force or stress here - // Peize Lin add 2014-04-04, update 2019-04-26 + // Peize Lin add 2014-04-04, update 2021-03-09 matrix force_vdw; matrix stress_vdw; - if(vdwd2.vdwD2) + if(vdwd2.flag_vdwd2()) { - if(isforce) force_vdw.create(nat,3); - if(isstress) stress_vdw.create(3,3); - vdwd2.force(isforce, isstress, force_vdw, stress_vdw); + if(isforce) + { + force_vdw.create(nat,3); + vdwd2.cal_force(); + for(int iat=0; iatprint_force("EFIELD FORCE",fefield,1,ry); } - if(vdwd2.vdwD2||vdwd3.vdwD3) + if(vdwd2.flag_vdwd2()||vdwd3.vdwD3) { this->print_force("VDW FORCE",force_vdw,1,ry); } @@ -343,7 +356,7 @@ void Force_Stress_LCAO::getForceStress( + sigmahar(i,j);// hartree stress //VDW stress from linpz and jiyy - if(vdwd2.vdwD2||vdwd3.vdwD3) + if(vdwd2.flag_vdwd2()||vdwd3.vdwD3) { scs(i,j) += stress_vdw(i , j); } @@ -399,7 +412,7 @@ void Force_Stress_LCAO::getForceStress( sc_pw.print_stress("cc STRESS",sigmacc,TEST_STRESS,ry); // sc_pw.print_stress("NLCC STRESS",sigmacc,TEST_STRESS,ry); sc_pw.print_stress("XC STRESS",sigmaxc,TEST_STRESS,ry); - if(vdwd2.vdwD2||vdwd3.vdwD3) + if(vdwd2.flag_vdwd2()||vdwd3.vdwD3) { sc_pw.print_stress("VDW STRESS",sigmaxc,TEST_STRESS,ry); } diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp index 302a6e1cca..109660b1ff 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp @@ -139,15 +139,17 @@ void Local_Orbital_Elec::solver(const int &istep) TITLE("Local_Orbital_Elec","solver"); timer::tick("Local_Orbital_Elec","solver",'D'); - // Peize Lin add 2014-04-04, update 2019-04-26 - if(vdwd2.vdwD2) + // Peize Lin add 2014.04.04, update 2021.03.09 + if(vdwd2.flag_vdwd2()) { - vdwd2.energy(); + vdwd2.cal_energy(); + en.evdw = vdwd2.energy_result; } // jiyy add 2019-05-18 else if(vdwd3.vdwD3) { vdwd3.energy(); + en.evdw = vdwd3.energy_result; } // self consistent calculations for electronic ground state diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index 1d28f4aee2..4755748d2f 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -546,13 +546,15 @@ void Local_Orbital_Ions::final_scf(void) UHM.set_lcao_matrices(); - if(vdwd2.vdwD2) //Peize Lin add 2014-04-04, update 2019-04-26 + if(vdwd2.flag_vdwd2()) //Peize Lin add 2014-04-04, update 2021-03-09 { - vdwd2.energy(); + vdwd2.cal_energy(); + en.evdw = vdwd2.energy_result; } else if(vdwd3.vdwD3) //jiyy add 2019-05-18 { vdwd3.energy(); + en.evdw = vdwd3.energy_result; } ELEC_scf es; diff --git a/ABACUS.develop/source/src_pw/energy.cpp b/ABACUS.develop/source/src_pw/energy.cpp index 71f6ed5b6e..5c1ee10126 100644 --- a/ABACUS.develop/source/src_pw/energy.cpp +++ b/ABACUS.develop/source/src_pw/energy.cpp @@ -54,7 +54,10 @@ void energy::calculate_harris(const int &flag) + (H_XC_pw::etxc - etxcc) + H_Ewald_pw::ewald_energy + H_Hartree_pw::hartree_energy - + demet + exx + Efield::etotefield; + + demet + + exx + + Efield::etotefield + + evdw; // Peize Lin add evdw 2021.03.09 if(INPUT.dft_plus_u) { @@ -73,18 +76,11 @@ void energy::calculate_etot(void) + (H_XC_pw::etxc - etxcc) + H_Ewald_pw::ewald_energy + H_Hartree_pw::hartree_energy - + demet + descf + exx + Efield::etotefield; - - // Peize Lin add 2014-04-03, update 2019-04-26 - if(vdwd2.vdwD2) - { - this->etot += vdwd2.energy_result; - } - // jiyy add 2019-05-18 - else if(vdwd3.vdwD3) - { - this->etot += vdwd3.energy_result; - } + + demet + + descf + + exx + + Efield::etotefield + + evdw; // Peize Lin add evdw 2021.03.09 //Quxin adds for DFT+U energy correction on 20201029 @@ -136,9 +132,9 @@ bool print) this->print_format("E_demet",demet); //mohan add 2011-12-02 this->print_format("E_descf",descf); this->print_format("E_efield",Efield::etotefield); - if(vdwd2.vdwD2) //Peize Lin add 2014-04, update 2019-04-26 + if(vdwd2.flag_vdwd2()) //Peize Lin add 2014-04, update 2021-03-09 { - this->print_format("E_vdwD2",vdwd2.energy_result); + this->print_format("E_vdwD2",evdw); } if(vdwd3.vdwD3) //jiyy add 2019-05 { diff --git a/ABACUS.develop/source/src_pw/energy.h b/ABACUS.develop/source/src_pw/energy.h index 69eceede51..442f89be2d 100644 --- a/ABACUS.develop/source/src_pw/energy.h +++ b/ABACUS.develop/source/src_pw/energy.h @@ -50,6 +50,7 @@ class energy double etxcc; // the nlcc exchange and correlation double exx; // the exact exchange energy. + double evdw; // the vdw energy // Peize Lin add 2021.03.09 double demet; // correction for metals diff --git a/ABACUS.develop/source/src_pw/forces.cpp b/ABACUS.develop/source/src_pw/forces.cpp index 18a3a529b2..ceeaafdb64 100644 --- a/ABACUS.develop/source/src_pw/forces.cpp +++ b/ABACUS.develop/source/src_pw/forces.cpp @@ -35,9 +35,15 @@ void Forces::init(matrix& force) matrix stress_vdw_pw;//.create(3,3); matrix force_vdw; force_vdw.create(nat, 3); - if(vdwd2.vdwD2) //Peize Lin add 2014-04-03, update 2019-04-26 + if(vdwd2.flag_vdwd2()) //Peize Lin add 2014.04.03, update 2021.03.09 { - vdwd2.force(1, 0, force_vdw, stress_vdw_pw); + vdwd2.cal_force(); + for(int iat=0; iatcal_meshx(); + // setup vdwd2 parameters + vdwd2_para.initset(*this); // Peize Lin add 2021.03.09 + // stringstream ss; // ss << global_out_dir << "unitcell_pp.log"; // print_unitcell_pseudo( ss.str() ); diff --git a/ABACUS.develop/source/src_pw/vdwd2.cpp b/ABACUS.develop/source/src_pw/vdwd2.cpp index 2d5b4d3785..ff00986186 100644 --- a/ABACUS.develop/source/src_pw/vdwd2.cpp +++ b/ABACUS.develop/source/src_pw/vdwd2.cpp @@ -9,93 +9,22 @@ #include"src_global/constants.h" #include -Vdwd2::Vdwd2( const UnitCell_pseudo &unitcell): - energy_result(0), - ucell(unitcell), - init_set(false) -{ - init_C6(); - init_R0(); -} - -void Vdwd2::C6_input(const std::string &file, const std::string &unit) -{ - if( file != "default" ) - { - ifstream ifs(file); - if(!ifs) - WARNING_QUIT("Vdwd2::C6_input", "Can not find the file "+TO_STRING(file)); - std::string element; - double value; - while( ifs >> element >> value ) - C6[element]=value; - ifs.close(); - } - for(auto &c6 : C6) - { - if( unit == "Jnm6/mol") - c6.second *= 1e6/(ELECTRONVOLT_SI*NA)/pow(BOHR_TO_A,6)/Ry_to_eV; - else if( unit == "eVA6") - c6.second /= pow(BOHR_TO_A,6)/Ry_to_eV; -// else if( unit == "RyBohr6"); - else - WARNING_QUIT("Input","vdwD2_C6_unit must be Jnm6/mol or eVA6"); - } -} - -void Vdwd2::R0_input(const std::string &file, const std::string &unit) -{ - if( file != "default" ) - { - ifstream ifs(file.c_str()); - if(!ifs) - WARNING_QUIT("Vdwd2::R0_input", "Can not find the file "+TO_STRING(file)); - std::string element; - double value; - while( ifs >> element >> value ) - R0[element]=value; - ifs.close(); - } - for(auto &r0 : R0) - { - if( unit == "A") - r0.second/= BOHR_TO_A; - else if( unit == "Bohr") ; - else - WARNING_QUIT("Input","vdwD2_R0_unit must be A or Bohr"); - } -} +Vdwd2::Vdwd2(const UnitCell_pseudo &unit_in, Vdwd2_Parameters ¶_in): + ucell(unit_in), + para(para_in){} -void Vdwd2::initset() -{ - if(!init_set) - { - for(auto &c6 : C6) - c6.second /= pow(ucell.lat0,6); - for(auto &r0 : R0) - r0.second /= ucell.lat0; - if(model=="radius") - { - period.x = 2*ceil(radius/ucell.lat0/sqrt(ucell.a1.norm2())) +1; - period.y = 2*ceil(radius/ucell.lat0/sqrt(ucell.a2.norm2())) +1; - period.z = 2*ceil(radius/ucell.lat0/sqrt(ucell.a3.norm2())) +1; - } - init_set=true; - } -} - -double Vdwd2::energy() +void Vdwd2::cal_energy() { TITLE("Vdwd2","energy"); - initset(); + para.initset(ucell); energy_result = 0; for( int it1=0; it1!=ucell.ntype; ++it1 ) { for( int it2=0; it2!=ucell.ntype; ++it2 ) { - const double C6_product = sqrt( C6.at(ucell.atoms[it1].label) * C6.at(ucell.atoms[it2].label) ); - const double R0_sum = R0.at(ucell.atoms[it1].label) + R0.at(ucell.atoms[it2].label); + const double C6_product = sqrt( para.C6.at(ucell.atoms[it1].label) * para.C6.at(ucell.atoms[it2].label) )/pow(ucell.lat0,6) ; + const double R0_sum = ( para.R0.at(ucell.atoms[it1].label) + para.R0.at(ucell.atoms[it2].label) )/ucell.lat0; if(!R0_sum) WARNING_QUIT("Input", "R0_sum can not be 0"); for( int ia1=0; ia1!=ucell.atoms[it1].na; ++ia1 ) @@ -103,9 +32,9 @@ double Vdwd2::energy() for( int ia2=0; ia2!=ucell.atoms[it2].na; ++ia2 ) { Vector3 ilat_loop; - for( ilat_loop.x = -period.x/2; ilat_loop.x <= (period.x-1)/2; ++ilat_loop.x ) - for( ilat_loop.y = -period.y/2; ilat_loop.y <= (period.y-1)/2; ++ilat_loop.y ) - for( ilat_loop.z = -period.z/2; ilat_loop.z <= (period.z-1)/2; ++ilat_loop.z ) + for( ilat_loop.x = -para.period.x/2; ilat_loop.x <= (para.period.x-1)/2; ++ilat_loop.x ) + for( ilat_loop.y = -para.period.y/2; ilat_loop.y <= (para.period.y-1)/2; ++ilat_loop.y ) + for( ilat_loop.z = -para.period.z/2; ilat_loop.z <= (para.period.z-1)/2; ++ilat_loop.z ) { if( (!( ilat_loop.x || ilat_loop.y || ilat_loop.z )) && (it1==it2) && (ia1==ia2) ) continue; @@ -113,37 +42,30 @@ double Vdwd2::energy() const Vector3 tau2 = ucell.atoms[it2].tau[ia2] + ilat_loop * ucell.latvec; const double r_sqr = (tau1 - tau2).norm2(); const double r = sqrt(r_sqr); - const double tmp_damp_recip = 1+ exp( -damping* (r/R0_sum-1) ); + const double tmp_damp_recip = 1+ exp( -para.damping* (r/R0_sum-1) ); energy_result -= C6_product/ pow(r_sqr,3)/ tmp_damp_recip/ 2; } // end for ilat_loop } // end for ia2 } // end for ia1 } // end for it2 } // end for it1 - energy_result *= scaling; - return energy_result; + energy_result *= para.scaling; } -const std::vector> &Vdwd2::force( - const bool force_for_vdw, - const bool stress_for_vdw, - matrix &force_vdw, - matrix &stress_result -) +void Vdwd2::cal_force() { TITLE("Vdwd2","force"); - initset(); + para.initset(ucell); force_result.clear(); force_result.resize(ucell.nat); - if(stress_for_vdw) stress_result.zero_out(); for( int it1=0; it1!=ucell.ntype; ++it1 ) { for( int it2=0; it2!=ucell.ntype; ++it2 ) { - const double C6_product = sqrt( C6.at(ucell.atoms[it1].label) * C6.at(ucell.atoms[it2].label) ) ; - const double R0_sum = R0.at(ucell.atoms[it1].label) + R0.at(ucell.atoms[it2].label) ; + const double C6_product = sqrt( para.C6.at(ucell.atoms[it1].label) * para.C6.at(ucell.atoms[it2].label) )/pow(ucell.lat0,6); + const double R0_sum = ( para.R0.at(ucell.atoms[it1].label) + para.R0.at(ucell.atoms[it2].label) )/ucell.lat0; if(!R0_sum) WARNING_QUIT("Input", "R0_sum can not be 0"); for( int ia1=0; ia1!=ucell.atoms[it1].na; ++ia1 ) @@ -151,9 +73,9 @@ const std::vector> &Vdwd2::force( for( int ia2=0; ia2!=ucell.atoms[it2].na; ++ia2 ) { Vector3 ilat_loop; - for( ilat_loop.x = -period.x/2; ilat_loop.x <= (period.x-1)/2; ++ilat_loop.x ) - for( ilat_loop.y = -period.y/2; ilat_loop.y <= (period.y-1)/2; ++ilat_loop.y ) - for( ilat_loop.z = -period.z/2; ilat_loop.z <= (period.z-1)/2; ++ilat_loop.z ) + for( ilat_loop.x = -para.period.x/2; ilat_loop.x <= (para.period.x-1)/2; ++ilat_loop.x ) + for( ilat_loop.y = -para.period.y/2; ilat_loop.y <= (para.period.y-1)/2; ++ilat_loop.y ) + for( ilat_loop.z = -para.period.z/2; ilat_loop.z <= (para.period.z-1)/2; ++ilat_loop.z ) { if( (!( ilat_loop.x || ilat_loop.y || ilat_loop.z )) && (it1==it2) && (ia1==ia2) ) continue; @@ -161,22 +83,9 @@ const std::vector> &Vdwd2::force( const Vector3 tau2 = ucell.atoms[it2].tau[ia2] + ilat_loop * ucell.latvec; const double r_sqr = (tau1 - tau2).norm2(); const double r = sqrt(r_sqr); - const double tmp_exp = exp( -damping* (r/R0_sum-1) ); - const double tmp_factor = C6_product/ pow(r_sqr,3)/ r/ (1+tmp_exp)* ( -6/r + tmp_exp/(1+tmp_exp)*damping/R0_sum); + const double tmp_exp = exp( -para.damping* (r/R0_sum-1) ); + const double tmp_factor = C6_product/ pow(r_sqr,3)/ r/ (1+tmp_exp)* ( -6/r + tmp_exp/(1+tmp_exp)*para.damping/R0_sum); force_result[ucell.itia2iat(it1,ia1)] += tmp_factor*(tau1-tau2); - if(stress_for_vdw)//added by zhengdy 2018/10/28 - { - double dr[3]={tau2.x - tau1.x, tau2.y - tau1.y, tau2.z - tau1.z}; - for(int ipol = 0;ipol<3;ipol++) - { - for(int jpol = 0;jpol<3;jpol++) - { - stress_result(ipol,jpol) += tmp_factor* dr[ipol] *dr[jpol]/2 ; - } -// stress_result(ipol,1) += tmp_factor* (tau1.y - tau2.y); -// stress_result(ipol,2) += tmp_factor* (tau1.z - tau2.z); - } - } // end if stress } // end for ilat_loop } // end for ia2 } // end for ia1 @@ -184,31 +93,52 @@ const std::vector> &Vdwd2::force( } // end for it1 for( int iat=0; iat!=ucell.nat; ++iat ) { - force_result[iat] *= scaling/ucell.lat0; + force_result[iat] *= para.scaling/ucell.lat0; } +} - for(int ipol=0;ipol<3;ipol++) + +void Vdwd2::cal_stress() +{ + TITLE("Vdwd2","force"); + para.initset(ucell); + + stress_result.Reset(); + + for( int it1=0; it1!=ucell.ntype; ++it1 ) { - if(stress_for_vdw) - { - for(int jpol=0;jpol<3;jpol++) - { - stress_result(ipol,jpol) *= scaling / ucell.omega; - } - } - if(force_for_vdw) + for( int it2=0; it2!=ucell.ntype; ++it2 ) { - for(int iat=0;iat ilat_loop; + for( ilat_loop.x = -para.period.x/2; ilat_loop.x <= (para.period.x-1)/2; ++ilat_loop.x ) + for( ilat_loop.y = -para.period.y/2; ilat_loop.y <= (para.period.y-1)/2; ++ilat_loop.y ) + for( ilat_loop.z = -para.period.z/2; ilat_loop.z <= (para.period.z-1)/2; ++ilat_loop.z ) + { + if( (!( ilat_loop.x || ilat_loop.y || ilat_loop.z )) && (it1==it2) && (ia1==ia2) ) + continue; + const Vector3 tau1 = ucell.atoms[it1].tau[ia1]; + const Vector3 tau2 = ucell.atoms[it2].tau[ia2] + ilat_loop * ucell.latvec; + const Vector3 dr = tau2 - tau1; + const double r_sqr = (tau1 - tau2).norm2(); + const double r = sqrt(r_sqr); + const double tmp_exp = exp( -para.damping* (r/R0_sum-1) ); + const double tmp_factor = C6_product/ pow(r_sqr,3)/ r/ (1+tmp_exp)* ( -6/r + tmp_exp/(1+tmp_exp)*para.damping/R0_sum); + stress_result += tmp_factor / 2 * Matrix3( + dr.x*dr.x, dr.x*dr.y, dr.x*dr.z, + dr.y*dr.x, dr.y*dr.y, dr.y*dr.z, + dr.z*dr.x, dr.z*dr.y, dr.z*dr.z); + } // end for ilat_loop + } // end for ia2 + } // end for ia1 + } // end for it2 + } // end for it1 + stress_result *= para.scaling / ucell.omega; } diff --git a/ABACUS.develop/source/src_pw/vdwd2.h b/ABACUS.develop/source/src_pw/vdwd2.h index 42a7b74daa..bc1e44222b 100644 --- a/ABACUS.develop/source/src_pw/vdwd2.h +++ b/ABACUS.develop/source/src_pw/vdwd2.h @@ -5,52 +5,48 @@ //========================================================== #ifndef VDWD2_H #define VDWD2_H -#include"input_conv.h" +#include"src_pw/vdwd2_parameters.h" #include"src_pw/unitcell_pseudo.h" #include"src_global/vector3.h" -#include #include class Vdwd2 { public: - Vdwd2( const UnitCell_pseudo &unitcell); - - bool vdwD2; + Vdwd2(const UnitCell_pseudo &unit_in, Vdwd2_Parameters ¶_in); - double energy_result; - double energy(); + double energy_result = 0; + void cal_energy(); std::vector> force_result; - const std::vector> &force( - const bool force_for_vdw, - const bool stress_for_vdw, - matrix &force_vdw, - matrix &stress_result ); - + void cal_force(); + + Matrix3 stress_result; + void cal_stress(); + private: - - double scaling; - double damping; - - std::string model; - double radius; - Vector3 period; - - map C6; - map R0; - void init_C6(); - void init_R0(); - void C6_input(const std::string &file, const std::string &unit); - void R0_input(const std::string &file, const std::string &unit); const UnitCell_pseudo &ucell; + Vdwd2_Parameters ¶ - bool init_set; - void initset(); - - friend void Input_Conv::Convert(); +public: + + bool flag_vdwd2()const{ return para.flag_vdwd2; } }; #endif + + + +/* + for(int iat=0;iat> element >> value ) + C6[element]=value; + ifs.close(); + } + for(auto &c6 : C6) + { + if( unit == "Jnm6/mol") + c6.second *= 1e6/(ELECTRONVOLT_SI*NA)/pow(BOHR_TO_A,6)/Ry_to_eV; + else if( unit == "eVA6") + c6.second /= pow(BOHR_TO_A,6)/Ry_to_eV; +// else if( unit == "RyBohr6"); + else + WARNING_QUIT("Input","vdwD2_C6_unit must be Jnm6/mol or eVA6"); + } +} + +void Vdwd2_Parameters::R0_input(const std::string &file, const std::string &unit) +{ + if( file != "default" ) + { + ifstream ifs(file.c_str()); + if(!ifs) + WARNING_QUIT("Vdwd2::R0_input", "Can not find the file "+TO_STRING(file)); + std::string element; + double value; + while( ifs >> element >> value ) + R0[element]=value; + ifs.close(); + } + for(auto &r0 : R0) + { + if( unit == "A") + r0.second/= BOHR_TO_A; + else if( unit == "Bohr") ; + else + WARNING_QUIT("Input","vdwD2_R0_unit must be A or Bohr"); + } +} + +void Vdwd2_Parameters::init_C6() +{ + C6 = + { + {"H", 0.14 }, + {"He", 0.08 }, + {"Li", 1.61 }, + {"Be", 1.61 }, + {"B", 3.13 }, + {"C", 1.75 }, + {"N", 1.23 }, + {"O", 0.70 }, + {"F", 0.75 }, + {"Ne", 0.63 }, + {"Na", 5.71 }, + {"Mg", 5.71 }, + {"Al", 10.79 }, + {"Si", 9.23 }, + {"P", 7.84 }, + {"S", 5.57 }, + {"Cl", 5.07 }, + {"Ar", 4.61 }, + {"K", 10.8 }, + {"Ca", 10.8 }, + {"Sc", 10.8 }, + {"Ti", 10.8 }, + {"V", 10.8 }, + {"Cr", 10.8 }, + {"Mn", 10.8 }, + {"Fe", 10.8 }, + {"Co", 10.8 }, + {"Ni", 10.8 }, + {"Cu", 10.8 }, + {"Zn", 10.8 }, + {"Ga", 16.99 }, + {"Ge", 17.10 }, + {"As", 16.37 }, + {"Se", 12.64 }, + {"Br", 12.47 }, + {"Kr", 12.01 }, + {"Rb", 24.67 }, + {"Sr", 24.67 }, + {"Y", 24.67 }, + {"Zr", 24.67 }, + {"Nb", 24.67 }, + {"Mo", 24.67 }, + {"Tc", 24.67 }, + {"Ru", 24.67 }, + {"Rh", 24.67 }, + {"Pd", 24.67 }, + {"Ag", 24.67 }, + {"Cd", 24.67 }, + {"In", 37.32 }, + {"Sn", 38.71 }, + {"Sb", 38.44 }, + {"Te", 31.74 }, + {"I", 31.50 }, + {"Xe", 29.99 }, + {"Cs", 315.275 }, + {"Ba", 226.994 }, + {"La", 176.252 }, + {"Ce", 140.68 }, + {"Pr", 140.68 }, + {"Nd", 140.68 }, + {"Pm", 140.68 }, + {"Sm", 140.68 }, + {"Eu", 140.68 }, + {"Gd", 140.68 }, + {"Tb", 140.68 }, + {"Dy", 140.68 }, + {"Ho", 140.68 }, + {"Er", 140.68 }, + {"Tm", 140.68 }, + {"Yb", 140.68 }, + {"Lu", 140.68 }, + {"Hf", 105.112 }, + {"Ta", 81.24 }, + {"W", 81.24 }, + {"Re", 81.24 }, + {"Os", 81.24 }, + {"Ir", 81.24 }, + {"Pt", 81.24 }, + {"Au", 81.24 }, + {"Hg", 57.364 }, + {"Tl", 57.254 }, + {"Pb", 63.162 }, + {"Bi", 63.540 }, + {"Po", 55.283 }, + {"At", 57.171 }, + {"Rn", 56.64 } + }; +} + +void Vdwd2_Parameters::init_R0() +{ + R0 = + { + {"H", 1.001 }, + {"He", 1.012 }, + {"Li", 0.825 }, + {"Be", 1.408 }, + {"B", 1.485 }, + {"C", 1.452 }, + {"N", 1.397 }, + {"O", 1.342 }, + {"F", 1.287 }, + {"Ne", 1.243 }, + {"Na", 1.144 }, + {"Mg", 1.364 }, + {"Al", 1.639 }, + {"Si", 1.716 }, + {"P", 1.705 }, + {"S", 1.683 }, + {"Cl", 1.639 }, + {"Ar", 1.595 }, + {"K", 1.485 }, + {"Ca", 1.474 }, + {"Sc", 1.562 }, + {"Ti", 1.562 }, + {"V", 1.562 }, + {"Cr", 1.562 }, + {"Mn", 1.562 }, + {"Fe", 1.562 }, + {"Co", 1.562 }, + {"Ni", 1.562 }, + {"Cu", 1.562 }, + {"Zn", 1.562 }, + {"Ga", 1.65 }, + {"Ge", 1.727 }, + {"As", 1.76 }, + {"Se", 1.771 }, + {"Br", 1.749 }, + {"Kr", 1.727 }, + {"Rb", 1.628 }, + {"Sr", 1.606 }, + {"Y", 1.639 }, + {"Zr", 1.639 }, + {"Nb", 1.639 }, + {"Mo", 1.639 }, + {"Tc", 1.639 }, + {"Ru", 1.639 }, + {"Rh", 1.639 }, + {"Pd", 1.639 }, + {"Ag", 1.639 }, + {"Cd", 1.639 }, + {"In", 1.672 }, + {"Sn", 1.804 }, + {"Sb", 1.881 }, + {"Te", 1.892 }, + {"I", 1.892 }, + {"Xe", 1.881 }, + {"Cs", 1.8018 }, + {"Ba", 1.7622 }, + {"La", 1.7204 }, + {"Ce", 1.7534 }, + {"Pr", 1.7534 }, + {"Nd", 1.7534 }, + {"Pm", 1.7534 }, + {"Sm", 1.7534 }, + {"Eu", 1.7534 }, + {"Gd", 1.7534 }, + {"Tb", 1.7534 }, + {"Dy", 1.7534 }, + {"Ho", 1.7534 }, + {"Er", 1.7534 }, + {"Tm", 1.7534 }, + {"Yb", 1.7534 }, + {"Lu", 1.7534 }, + {"Hf", 1.7875 }, + {"Ta", 1.7721 }, + {"W", 1.7721 }, + {"Re", 1.7721 }, + {"Os", 1.7721 }, + {"Ir", 1.7721 }, + {"Pt", 1.7721 }, + {"Au", 1.7721 }, + {"Hg", 1.7578 }, + {"Tl", 1.9855 }, + {"Pb", 1.9437 }, + {"Bi", 1.8975 }, + {"Po", 2.0053 }, + {"At", 1.991 }, + {"Rn", 1.9239 } + }; } \ No newline at end of file diff --git a/ABACUS.develop/source/src_pw/vdwd2_parameters.h b/ABACUS.develop/source/src_pw/vdwd2_parameters.h new file mode 100644 index 0000000000..4d10e6b46b --- /dev/null +++ b/ABACUS.develop/source/src_pw/vdwd2_parameters.h @@ -0,0 +1,39 @@ +//========================================================== +// AUTHOR: Peize Lin +// DATE: 2021-03-09 +//========================================================== + +#ifndef VDWD2_PARAMETERS_H +#define VDWD2_PARAMETERS_H + +#include +#include +#include "src_global/vector3.h" +#include "src_pw/unitcell_pseudo.h" + +class Vdwd2_Parameters +{ +public: + Vdwd2_Parameters(); + + void init_C6(); + void init_R0(); + void C6_input(const std::string &file, const std::string &unit); + void R0_input(const std::string &file, const std::string &unit); + + bool flag_vdwd2; + + map C6; + map R0; + + double scaling; + double damping; + + std::string model; + double radius; + Vector3 period; + + void initset(const UnitCell_pseudo &ucell); +}; + +#endif // define VDWD2_PARAMETERS_H \ No newline at end of file From eed5009bdc91ec447375c9d1608a784896d1d365 Mon Sep 17 00:00:00 2001 From: linpz Date: Fri, 12 Mar 2021 02:01:47 +0800 Subject: [PATCH 186/233] 1. delete global variable vdwd2 --- .../source/src_lcao/FORCE_STRESS.cpp | 13 +++++++----- .../source/src_lcao/local_orbital_elec.cpp | 4 +++- .../source/src_lcao/local_orbital_ions.cpp | 4 +++- ABACUS.develop/source/src_pw/energy.cpp | 2 +- ABACUS.develop/source/src_pw/forces.cpp | 5 +++-- ABACUS.develop/source/src_pw/global.cpp | 1 - ABACUS.develop/source/src_pw/global.h | 1 - ABACUS.develop/source/src_pw/ions.cpp | 3 ++- ABACUS.develop/source/src_pw/stress_pw.cpp | 5 +++-- ABACUS.develop/source/src_pw/vdwd2.h | 20 +------------------ 10 files changed, 24 insertions(+), 34 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp b/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp index 5eb7d1e623..08321366dc 100644 --- a/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp +++ b/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp @@ -4,6 +4,7 @@ #include "./dftu.h" //Quxin add for DFT+U on 20201029 // new #include "../src_pw/H_XC_pw.h" +#include "src_pw/vdwd2.h" double Force_Stress_LCAO::force_invalid_threshold_ev = 0.00; double Force_Stress_LCAO::output_acc = 1.0e-8; @@ -133,11 +134,12 @@ void Force_Stress_LCAO::getForceStress( // Peize Lin add 2014-04-04, update 2021-03-09 matrix force_vdw; matrix stress_vdw; - if(vdwd2.flag_vdwd2()) + if(vdwd2_para.flag_vdwd2) { if(isforce) { force_vdw.create(nat,3); + Vdwd2 vdwd2(ucell,vdwd2_para); vdwd2.cal_force(); for(int iat=0; iatprint_force("EFIELD FORCE",fefield,1,ry); } - if(vdwd2.flag_vdwd2()||vdwd3.vdwD3) + if(vdwd2_para.flag_vdwd2||vdwd3.vdwD3) { this->print_force("VDW FORCE",force_vdw,1,ry); } @@ -356,7 +359,7 @@ void Force_Stress_LCAO::getForceStress( + sigmahar(i,j);// hartree stress //VDW stress from linpz and jiyy - if(vdwd2.flag_vdwd2()||vdwd3.vdwD3) + if(vdwd2_para.flag_vdwd2||vdwd3.vdwD3) { scs(i,j) += stress_vdw(i , j); } @@ -412,7 +415,7 @@ void Force_Stress_LCAO::getForceStress( sc_pw.print_stress("cc STRESS",sigmacc,TEST_STRESS,ry); // sc_pw.print_stress("NLCC STRESS",sigmacc,TEST_STRESS,ry); sc_pw.print_stress("XC STRESS",sigmaxc,TEST_STRESS,ry); - if(vdwd2.flag_vdwd2()||vdwd3.vdwD3) + if(vdwd2_para.flag_vdwd2||vdwd3.vdwD3) { sc_pw.print_stress("VDW STRESS",sigmaxc,TEST_STRESS,ry); } diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp index 109660b1ff..458bf7598e 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp @@ -19,6 +19,7 @@ // #include "src_ri/exx_abfs.h" #include "src_ri/exx_opt_orb.h" +#include "src_pw/vdwd2.h" void Local_Orbital_Elec::solve_elec_stru(const int &istep) @@ -140,8 +141,9 @@ void Local_Orbital_Elec::solver(const int &istep) timer::tick("Local_Orbital_Elec","solver",'D'); // Peize Lin add 2014.04.04, update 2021.03.09 - if(vdwd2.flag_vdwd2()) + if(vdwd2_para.flag_vdwd2) { + Vdwd2 vdwd2(ucell,vdwd2_para); vdwd2.cal_energy(); en.evdw = vdwd2.energy_result; } diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index 4755748d2f..74ed03011b 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -12,6 +12,7 @@ #include "src_ri/exx_opt_orb.h" #include "ELEC_scf.h" #include "src_global/sltk_atom_arrange.h" +#include "src_pw/vdwd2.h" Local_Orbital_Ions::Local_Orbital_Ions() {} @@ -546,8 +547,9 @@ void Local_Orbital_Ions::final_scf(void) UHM.set_lcao_matrices(); - if(vdwd2.flag_vdwd2()) //Peize Lin add 2014-04-04, update 2021-03-09 + if(vdwd2_para.flag_vdwd2) //Peize Lin add 2014-04-04, update 2021-03-09 { + Vdwd2 vdwd2(ucell,vdwd2_para); vdwd2.cal_energy(); en.evdw = vdwd2.energy_result; } diff --git a/ABACUS.develop/source/src_pw/energy.cpp b/ABACUS.develop/source/src_pw/energy.cpp index 5c1ee10126..93fb5a3915 100644 --- a/ABACUS.develop/source/src_pw/energy.cpp +++ b/ABACUS.develop/source/src_pw/energy.cpp @@ -132,7 +132,7 @@ bool print) this->print_format("E_demet",demet); //mohan add 2011-12-02 this->print_format("E_descf",descf); this->print_format("E_efield",Efield::etotefield); - if(vdwd2.flag_vdwd2()) //Peize Lin add 2014-04, update 2021-03-09 + if(vdwd2_para.flag_vdwd2) //Peize Lin add 2014-04, update 2021-03-09 { this->print_format("E_vdwD2",evdw); } diff --git a/ABACUS.develop/source/src_pw/forces.cpp b/ABACUS.develop/source/src_pw/forces.cpp index ceeaafdb64..000483c7f4 100644 --- a/ABACUS.develop/source/src_pw/forces.cpp +++ b/ABACUS.develop/source/src_pw/forces.cpp @@ -35,8 +35,9 @@ void Forces::init(matrix& force) matrix stress_vdw_pw;//.create(3,3); matrix force_vdw; force_vdw.create(nat, 3); - if(vdwd2.flag_vdwd2()) //Peize Lin add 2014.04.03, update 2021.03.09 + if(vdwd2_para.flag_vdwd2) //Peize Lin add 2014.04.03, update 2021.03.09 { + Vdwd2 vdwd2(ucell,vdwd2_para); vdwd2.cal_force(); for(int iat=0; iat Date: Fri, 12 Mar 2021 07:04:54 +0800 Subject: [PATCH 187/233] add notes in grid integrals --- .../source/src_lcao/gint_gamma_rho.cpp | 93 +++++++------------ .../source/src_lcao/gint_gamma_vl.cpp | 90 ++++++++++++++---- 2 files changed, 110 insertions(+), 73 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp index 41bd5bc8b9..bb6328be5c 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_rho.cpp @@ -27,11 +27,18 @@ void Gint_Gamma::setVindex(const int ncyz, const int ibx, const int jby, const i } } -//inline void cal_psir_ylm(int size, int grid_index, double delta_r, -void Gint_Gamma::cal_psir_ylm_rho(int size, int grid_index, double delta_r, - double** distance, double* ylma, - int* at, int* block_index, int* block_iw, int* block_size, - int** cal_flag, double** psir_ylm) +void Gint_Gamma::cal_psir_ylm_rho( + int size, + int grid_index, + double delta_r, + double** distance, + double* ylma, + int* at, + int* block_index, + int* block_iw, + int* block_size, + int** cal_flag, + double** psir_ylm) { const Numerical_Orbital_Lm *pointer; double mt[3]; @@ -122,14 +129,23 @@ void Gint_Gamma::cal_psir_ylm_rho(int size, int grid_index, double delta_r, } // end iw }// end ib }// end id + return; } // can be done by GPU -//inline void cal_band_rho(int size, int LD_pool, int* block_iw, int* bsize, int* colidx, -void Gint_Gamma::cal_band_rho(int size, int LD_pool, int* block_iw, int* bsize, int* colidx, - int** cal_flag, double ** psir_ylm, double **psir_DM, - double* psir_DM_pool, int* vindex) +void Gint_Gamma::cal_band_rho( + int size, + int LD_pool, + int* block_iw, + int* bsize, + int* colidx, + int** cal_flag, + double ** psir_ylm, + double **psir_DM, + double* psir_DM_pool, + int* vindex) { + //parameters for dsymm, dgemm and ddot char side='L', uplo='U'; char transa='N', transb='N'; @@ -139,14 +155,12 @@ void Gint_Gamma::cal_band_rho(int size, int LD_pool, int* block_iw, int* bsize, for(int is=0; is0) { - // dsymm_(&side, &uplo, &bsize[ia1], &k, - // &alpha_symm, &LOC.DM[is][iw1_lo][iw1_lo], &GridT.lgd, - // &psir_ylm[ib][colidx[ia1]], &LD_pool, - // &beta, &psir_DM[ib][colidx[ia1]], &LD_pool); dsymv_(&uplo, &bsize[ia1], &alpha_symm, &LOC.DM[is][iw1_lo][iw1_lo], &GridT.lgd, &psir_ylm[ib][colidx[ia1]], &inc, @@ -238,15 +248,10 @@ void Gint_Gamma::cal_band_rho(int size, int LD_pool, int* block_iw, int* bsize, } else { - // int k=1; for(int ib=first_ib; ib0 && cal_flag[ib][ia2]>0) { - // dgemm_(&transa, &transb, &bsize[ia2], &k, &bsize[ia1], - // &alpha_gemm, &LOC.DM[is][iw1_lo][iw2_lo], &GridT.lgd, - // &psir_ylm[ib][colidx[ia1]], &LD_pool, - // &beta, &psir_DM[ib][colidx[ia2]], &LD_pool); dgemv_(&transa, &bsize[ia2], &bsize[ia1], &alpha_gemm, &LOC.DM[is][iw1_lo][iw2_lo], &GridT.lgd, &psir_ylm[ib][colidx[ia1]], &inc, @@ -257,23 +262,16 @@ void Gint_Gamma::cal_band_rho(int size, int LD_pool, int* block_iw, int* bsize, //OUT(ofs_running, "upper triangle part of psir_DM done, atom2", ia2); }// ia2 } // ia1 - //xiaohui move 2015-09-25, fix lcao+k bug; - //timer::tick("Gint_Gamma","cal_band_psir",'J'); - // calculate rho - //xiaohui move 2015-09-25, fix lcao+k bug; - //timer::tick("Gint_Gamma","cal_band_rho",'J'); double *rhop = CHR.rho[is]; for(int ib=0; ibgrid_index = (k-nbz_start) + j * nbz + i * nby * nbz; const int grid_index_thread = (k-nbz_start) + j * nbz + i * nby * nbz; // get the value: how many atoms has orbital value on this grid. @@ -406,20 +392,14 @@ double Gint_Gamma::gamma_charge(void) // Peize Lin update OpenMP 2020.09.28 const int size = GridT.how_many_atoms[ grid_index_thread ]; if(size==0) continue; this->setVindex(ncyz, ibx, jby, kbz, vindex); - // cal_psir_ylm(size, this->grid_index, delta_r, phi, mt, dr, distance, pointer, ylma, colidx, block_iw, bsize, psir_ylm); - timer::tick("Gint_Gamma","rho_psir_ylm",'J'); - //cal_psir_ylm(size, this->grid_index, delta_r, distance, ylma, this->cal_psir_ylm_rho(size, grid_index_thread, delta_r, distance, ylma, at, block_index, block_iw, block_size, cal_flag, psir_ylm); - timer::tick("Gint_Gamma","rho_psir_ylm",'J'); - // cal_band_rho(size, LD_pool, block_iw, block_size, block_index, psir_ylm, psir_DM, psir_DM_pool, vindex); - timer::tick("Gint_Gamma","cal_band_rho",'J'); + cal_band_rho(size, LD_pool, block_iw, block_size, block_index, cal_flag, psir_ylm, psir_DM, psir_DM_pool, vindex); - timer::tick("Gint_Gamma","cal_band_rho",'J'); }// k }// j }// i @@ -457,7 +437,6 @@ double Gint_Gamma::gamma_charge(void) // Peize Lin update OpenMP 2020.09.28 } // end of if(max_size) //ENDandRETURN: - //xiaohui add 'OUT_LEVEL', 2015-09-16 if(OUT_LEVEL != "m") OUT(ofs_running, "sum", sum); timer::tick("Gint_Gamma","reduce_charge",'J'); diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp index 8053da31e8..207aa636bb 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_vl.cpp @@ -15,16 +15,24 @@ extern "C" void Cblacs_pcoord(int icontxt, int pnum, int *prow, int *pcol); } -inline void setVindex(const int ncyz, const int ibx, const int jby, const int kbz, - int* vindex) +// here vindex refers to local potentials +inline void setVindex + (const int ncyz, + const int ibx, + const int jby, + const int kbz, + int* vindex) { int bindex=0; // z is the fastest, + + // ipart can be obtained by using a previously stored array for(int ii=0; ii0 && lgd_now>0) { + //------------------------------------------------------ + // + //------------------------------------------------------ double *GridVlocal_pool=new double [lgd_now*lgd_now]; ZEROS(GridVlocal_pool, lgd_now*lgd_now); + double **GridVlocal_thread=new double*[lgd_now]; for (int i=0; igrid_index ]; + //------------------------------------------------------------------ + // get the value: how many atoms are involved in this grid (big cell) + //------------------------------------------------------------------ const int size=GridT.how_many_atoms[ grid_index_thread ]; + if(size==0) continue; + + //------------------------------------------------------------------ + // kbz can be obtained using a previously stored array + //------------------------------------------------------------------ const int kbz=k*pw.bz-pw.nczp_start; + + //------------------------------------------------------------------ + // set the index for obtaining local potentials + //------------------------------------------------------------------ setVindex(ncyz, ibx, jby, kbz, vindex); - //OUT(ofs_running, "vindex was set"); + + //------------------------------------------------------------------ // extract the local potentials. + //------------------------------------------------------------------ for(int ib=0; ibvlocal[vindex[ib]] * this->vfactor; } + //------------------------------------------------------------------ + // compute atomic basis phi(r) with both radial and angular parts + //------------------------------------------------------------------ cal_psir_ylm(size, grid_index_thread, delta_r, phi, mt, dr, distance, pointer, ylma, colidx, block_iw, bsize, psir_ylm, cal_flag); + //------------------------------------------------------------------ + // calculate + //------------------------------------------------------------------ cal_meshball_vlocal(size, LD_pool, block_iw, bsize, colidx, cal_flag, vldr3, psir_ylm, psir_vlbr3, vindex, lgd_now, GridVlocal_thread); }// k From 1de5de699f48b62b76ed0007eec9c6840a631946 Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 12 Mar 2021 11:02:33 +0800 Subject: [PATCH 188/233] fix a bug when use Libxc: usage of etxc and vtxc --- ABACUS.develop/source/src_pw/potential.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index b553a37e80..8955561e5e 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -273,7 +273,7 @@ void potential::v_of_rho //---------------------------------------------------------- #ifdef USE_LIBXC - Potential_Libxc::v_xc(rho_in, en.etxc, en.vtxc, v_in); + Potential_Libxc::v_xc(rho_in, H_XC_pw::etxc, H_XC_pw::vtxc, v_in); #else H_XC_pw::v_xc(pw.nrxx, pw.ncxyz, ucell.omega, rho_in, CHR.rho_core, v_in); #endif From d77d62b4f202504d4084a481493d29e2e41e4999 Mon Sep 17 00:00:00 2001 From: linpz Date: Fri, 12 Mar 2021 11:19:22 +0800 Subject: [PATCH 189/233] 1. add get in Vdwd2 --- .../source/src_lcao/FORCE_STRESS.cpp | 8 ++++---- .../source/src_lcao/local_orbital_elec.cpp | 2 +- .../source/src_lcao/local_orbital_ions.cpp | 2 +- ABACUS.develop/source/src_pw/forces.cpp | 6 +++--- ABACUS.develop/source/src_pw/ions.cpp | 2 +- ABACUS.develop/source/src_pw/stress_pw.cpp | 2 +- ABACUS.develop/source/src_pw/vdwd2.cpp | 20 +++++++++---------- ABACUS.develop/source/src_pw/vdwd2.h | 15 ++++++++------ 8 files changed, 30 insertions(+), 27 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp b/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp index 08321366dc..23359fdd22 100644 --- a/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp +++ b/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp @@ -143,16 +143,16 @@ void Force_Stress_LCAO::getForceStress( vdwd2.cal_force(); for(int iat=0; iat> force_result; + void cal_energy(); void cal_force(); - - Matrix3 stress_result; void cal_stress(); + const double &get_energy()const{ return energy; } + const std::vector> &get_force() const{ return force; } + const Matrix3 &get_stress()const{ return stress; } + private: const UnitCell_pseudo &ucell; Vdwd2_Parameters ¶ + + double energy = 0; + std::vector> force; + Matrix3 stress; }; #endif \ No newline at end of file From 3af7acadbe51941b22b49c73e334296ef5652400 Mon Sep 17 00:00:00 2001 From: linpz Date: Fri, 12 Mar 2021 11:51:38 +0800 Subject: [PATCH 190/233] 1. change en.etxc to H_XC_pw::etxc when calling Potential_Libxc::v_xc 2. add "#include " in src_ri/exx_abfs-parallel-communicate-dm3.h 3. add "#ifdef USE_CEREAL_SERIALIZATION" in exx_abfs-parallel-communicate-dm3-allreduce.cpp --- ABACUS.develop/source/src_pw/potential.cpp | 2 +- ABACUS.develop/source/src_pw/potential_libxc.cpp | 2 +- ...exx_abfs-parallel-communicate-dm3-allreduce.cpp | 14 +++++++++++++- .../src_ri/exx_abfs-parallel-communicate-dm3.h | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index b553a37e80..8955561e5e 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -273,7 +273,7 @@ void potential::v_of_rho //---------------------------------------------------------- #ifdef USE_LIBXC - Potential_Libxc::v_xc(rho_in, en.etxc, en.vtxc, v_in); + Potential_Libxc::v_xc(rho_in, H_XC_pw::etxc, H_XC_pw::vtxc, v_in); #else H_XC_pw::v_xc(pw.nrxx, pw.ncxyz, ucell.omega, rho_in, CHR.rho_core, v_in); #endif diff --git a/ABACUS.develop/source/src_pw/potential_libxc.cpp b/ABACUS.develop/source/src_pw/potential_libxc.cpp index b00709a31e..371f3e45ee 100644 --- a/ABACUS.develop/source/src_pw/potential_libxc.cpp +++ b/ABACUS.develop/source/src_pw/potential_libxc.cpp @@ -11,7 +11,7 @@ #include "src_lcao/global_fp.h" #include "src_pw/tools.h" #include "src_global/global_function.h" -#include "src_pw/gga_pw.h" +#include "src_pw/xc_gga_pw.h" void Potential_Libxc::v_xc( const double * const * const rho_in, // CHR.rho_core may be needed in future diff --git a/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm3-allreduce.cpp b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm3-allreduce.cpp index 8fe40b92a4..79e6f31e2f 100644 --- a/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm3-allreduce.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm3-allreduce.cpp @@ -3,7 +3,10 @@ #include "src_pw/global.h" #include "src_global/global_function.h" -#include "src_global/serialization_cereal.h" + +#ifdef USE_CEREAL_SERIALIZATION + #include "src_global/serialization_cereal.h" +#endif #include #include @@ -282,12 +285,17 @@ vector>> Exx_Abfs::Parallel::Communicate::DM3::Allreduce: for(const size_t iat2 : H_atom_pairs.second) if(atom_in_2D_list[rank].second[iat2]) atom_required[iat1].insert(iat2); + + #ifdef USE_CEREAL_SERIALIZATION { stringstream atom_send_ss; cereal::BinaryOutputArchive ar(atom_send_ss); ar(atom_required); atom_send_str[rank] = atom_send_ss.str(); } + #else + throw invalid_argument(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + #endif if( MPI_Isend( atom_send_str[rank].c_str(), atom_send_str[rank].size(), MPI_CHAR, rank, tag, mpi_comm, &request[rank] ) !=MPI_SUCCESS) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); } @@ -303,10 +311,14 @@ vector>> Exx_Abfs::Parallel::Communicate::DM3::Allreduce: if( MPI_Recv( ss_buffer.data(), size_recv, MPI_CHAR, status.MPI_SOURCE, tag, mpi_comm, MPI_STATUS_IGNORE ) !=MPI_SUCCESS) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); stringstream atom_recv_ss; atom_recv_ss.rdbuf()->pubsetbuf(ss_buffer.data(),size_recv); + #ifdef USE_CEREAL_SERIALIZATION { cereal::BinaryInputArchive ar(atom_recv_ss); ar(H_atom_pairs_group_rank[status.MPI_SOURCE]); } + #else + throw invalid_argument(TO_STRING(__FILE__)+" line "+TO_STRING(__LINE__)); + #endif } if( MPI_Waitall( comm_sz, request.data(), MPI_STATUSES_IGNORE ) !=MPI_SUCCESS) throw runtime_error(TO_STRING(__FILE__)+TO_STRING(__LINE__)); diff --git a/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm3.h b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm3.h index 05dbe241c0..8fddefc0af 100644 --- a/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm3.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-parallel-communicate-dm3.h @@ -8,6 +8,7 @@ #include #include #include +#include using namespace std; From 1a7738938a267c307285997e4bb23070d49ba0a5 Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 12 Mar 2021 16:14:55 +0800 Subject: [PATCH 191/233] add run_md.h and run_md.cpp --- ABACUS.develop/source/Makefile.Objects | 1 + ABACUS.develop/source/run_lcao.cpp | 15 +- ABACUS.develop/source/src_lcao/ELEC_scf.h | 1 + ABACUS.develop/source/src_lcao/FORCE_STRESS.h | 1 + .../source/src_lcao/local_orbital_ions.cpp | 72 +-- ABACUS.develop/source/src_lcao/run_md.cpp | 525 ++++++++++++++++++ ABACUS.develop/source/src_lcao/run_md.h | 50 ++ 7 files changed, 592 insertions(+), 73 deletions(-) create mode 100644 ABACUS.develop/source/src_lcao/run_md.cpp create mode 100644 ABACUS.develop/source/src_lcao/run_md.h diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index b81affeb2a..d0f10d73c6 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -139,6 +139,7 @@ ELEC_scf.o\ ELEC_nscf.o\ RELAX_cell.o\ local_orbital_ions.o\ +run_md.o\ local_orbital_charge.o\ DM_gamma.o\ DM_k.o\ diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index d7ee66a019..18f43309a7 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -13,6 +13,7 @@ #include "src_lcao/RELAX_cell.h" #include "src_io/print_info.h" #include "src_pw/symmetry.h" +#include "src_lcao/run_md.h" Run_lcao::Run_lcao(){} Run_lcao::~Run_lcao(){} @@ -149,9 +150,17 @@ void Run_lcao::lcao_line(void) dftu.init(); } - // mohan add 2021-03-09 - RELAX_cell rcell; - rcell.opt_cell(); + + if(CALCULATION=="md") + { + Run_MD run_md; + run_md.opt_ions(); + } + else + { + RELAX_cell rcell; + rcell.opt_cell(); + } en.perform_dos(); diff --git a/ABACUS.develop/source/src_lcao/ELEC_scf.h b/ABACUS.develop/source/src_lcao/ELEC_scf.h index 20ee25607b..e92e535b54 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_scf.h +++ b/ABACUS.develop/source/src_lcao/ELEC_scf.h @@ -15,6 +15,7 @@ class ELEC_scf: private Threshold_Elec friend class Local_Orbital_Elec; friend class Local_Orbital_Ions; + friend class Run_MD; public: diff --git a/ABACUS.develop/source/src_lcao/FORCE_STRESS.h b/ABACUS.develop/source/src_lcao/FORCE_STRESS.h index 3a983f3f69..a41979f352 100644 --- a/ABACUS.develop/source/src_lcao/FORCE_STRESS.h +++ b/ABACUS.develop/source/src_lcao/FORCE_STRESS.h @@ -12,6 +12,7 @@ class Force_Stress_LCAO { // mohan add 2021-02-09 friend class md; + friend class Run_MD; friend void Input_Conv::Convert(); friend class Update_input; friend class Local_Orbital_Ions; diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp index 74ed03011b..4a12e6841b 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp @@ -53,25 +53,6 @@ void Local_Orbital_Ions::opt_ions(void) LCM.allocate(); } - //add by zhengdy 2015/4/27 - if(CALCULATION=="md") - { - mdtype= INPUT.md_mdtype;//control md - - // NVT ensemble - if(mdtype==1||mdtype==2) - { - MDNVT.md_allocate(); - MDNVT.initMD(); - } - // NVE ensemble - else if(mdtype==0) - { - MDNVE.md_allocate(); - MDNVE.initMD(); - } - } - this->istep = 1; int force_step = 1; int stress_step = 1; @@ -97,13 +78,6 @@ void Local_Orbital_Ions::opt_ions(void) { cout << " SELF-CONSISTENT : " << endl; } - else if(CALCULATION=="md") //xiaohui add 2015-09-15 - { - if(mdtype==1||mdtype==2) - { - cout<<" Molecular Dynamics (NVT) STEP "<< MDNVT.step_rst + istep<0. - CE.extrapolate_charge(); - - if(pot.extra_pot=="dm")//xiaohui modify 2015-02-01 - { - // done after grid technique. - } - else - { - pot.init_pot( istep ); - } - } - - - if(OUT_LEVEL=="i") { double etime_min = difftime(eend, estart)/60.0; diff --git a/ABACUS.develop/source/src_lcao/run_md.cpp b/ABACUS.develop/source/src_lcao/run_md.cpp new file mode 100644 index 0000000000..e3b6e2bab6 --- /dev/null +++ b/ABACUS.develop/source/src_lcao/run_md.cpp @@ -0,0 +1,525 @@ +#include "run_md.h" +#include "src_pw/global.h" +#include "src_parallel/parallel_orbitals.h" +#include "src_pdiag/pdiag_double.h" +#include "LCAO_nnr.h" +#include "FORCE_STRESS.h" +#include "src_global/global_function.h" +#include "src_io/hs_matrix.h" +#include "src_io/cal_r_overlap_R.h" +#include "src_ions/variable_cell.h" // mohan add 2021-02-01 +#include "src_ri/exx_abfs.h" +#include "src_ri/exx_opt_orb.h" +#include "ELEC_scf.h" +#include "src_global/sltk_atom_arrange.h" +#include "src_pw/vdwd2.h" + +Run_MD::Run_MD() +{} + +Run_MD::~Run_MD() +{} + +void Run_MD::opt_ions(void) +{ + TITLE("Run_MD","opt_ions"); + timer::tick("Run_MD","opt_ions",'B'); + + if(OUT_LEVEL=="i") + { + cout << setprecision(12); + cout<< " " << setw(7)<< "ISTEP" + <istep = 1; + int force_step = 1; + int stress_step = 1; + bool stop = false; + while(istep <= NSTEP && !stop) + { + time_t estart = time(NULL); + + // xiaohui add "m" option, 2015-09-16 + if(OUT_LEVEL=="ie" || OUT_LEVEL=="m") + { + cout << " ---------------------------------------------------------" << endl; + if(mdtype==1||mdtype==2) + { + cout<<" Molecular Dynamics (NVT) STEP "<< MDNVT.step_rst + istep<istep); + + time_t eend = time(NULL); + + //xiaohui add 2014-07-07, for second-order extrapolation + int iat=0; + + for(int it = 0;it < ucell.ntype;it++) + { + Atom* atom = &ucell.atoms[it]; + for(int ia =0;ia< ucell.atoms[it].na;ia++) + { + CE.pos_old2[3*iat ] = CE.pos_old1[3*iat ]; + CE.pos_old2[3*iat+1] = CE.pos_old1[3*iat+1]; + CE.pos_old2[3*iat+2] = CE.pos_old1[3*iat+2]; + + CE.pos_old1[3*iat ] = CE.pos_now[3*iat ]; + CE.pos_old1[3*iat+1] = CE.pos_now[3*iat+1]; + CE.pos_old1[3*iat+2] = CE.pos_now[3*iat+2]; + + CE.pos_now[3*iat ] = atom->tau[ia].x*ucell.lat0; + CE.pos_now[3*iat+1] = atom->tau[ia].y*ucell.lat0; + CE.pos_now[3*iat+2] = atom->tau[ia].z*ucell.lat0; + + iat++; + } + } + + if(mdtype==1||mdtype==2) + { + MDNVT.runnvt(istep); + } + else if(mdtype==0) + { + MDNVE.runNVE(istep); + } + if((mdtype==1||mdtype==2)&&(istep==NSTEP||stop)) + { + MDNVT.md_release(); + } + if(mdtype==0&&(istep==NSTEP||stop)) + { + MDNVE.md_release(); + } + + if(pot.out_potential == 2) + { + stringstream ssp; + stringstream ssp_ave; + ssp << global_out_dir << "ElecStaticPot"; + ssp_ave << global_out_dir << "ElecStaticPot_AVE"; + pot.write_elecstat_pot(ssp.str(), ssp_ave.str()); //output 'Hartree + local pseudopot' + } + + time_t fstart = time(NULL); + time_t fend = time(NULL); + + //xiaohui add 2014-07-07, for second-order extrapolation + iat=0; + for(int it = 0;it < ucell.ntype;it++) + { + Atom* atom = &ucell.atoms[it]; + for(int ia =0;ia< ucell.atoms[it].na;ia++) + { + CE.pos_next[3*iat ] = atom->tau[ia].x*ucell.lat0; + CE.pos_next[3*iat+1] = atom->tau[ia].y*ucell.lat0; + CE.pos_next[3*iat+2] = atom->tau[ia].z*ucell.lat0; + + iat++; + } + } + + //xiaohui add CE.istep = istep 2014-07-07 + CE.istep = istep; + + // charge extrapolation if istep>0. + CE.extrapolate_charge(); + + if(pot.extra_pot=="dm")//xiaohui modify 2015-02-01 + { + // done after grid technique. + } + else + { + pot.init_pot( istep ); + } + + + if(OUT_LEVEL=="i") + { + double etime_min = difftime(eend, estart)/60.0; + double ftime_min = difftime(fend, fstart)/60.0; + stringstream ss; + ss << MOVE_IONS << istep; + + cout << setiosflags(ios::scientific) + << " " << setw(7) << ss.str() + << setw(5) << ELEC_scf::iter + << setw(18) << setprecision(6) << en.etot * Ry_to_eV; + + cout << setprecision(2) << setiosflags(ios::scientific) + << setw(10) << IMM.get_ediff() * Ry_to_eV * 1000 + << setw(10) << IMM.get_largest_grad() * Ry_to_eV / BOHR_TO_A; + + cout << resetiosflags(ios::scientific) + << setprecision(2) << setw(10) << etime_min + ftime_min; + cout << endl; + } + + ++istep; + } + + // mohan update 2021-02-10 + hm.orb_con.clear_after_ions(); + + timer::tick("Run_MD","opt_ions",'B'); + return; +} + +//bool Run_MD::force_stress(void) +bool Run_MD::force_stress(const int &istep, int &force_step, int &stress_step) +{ + TITLE("Run_MD","force_stress"); + if(!FORCE && !STRESS) + { + return 1; + } + timer::tick("Run_MD","force_stress",'D'); + matrix fcs; + matrix scs; + Force_Stress_LCAO FSL; + FSL.allocate (); + FSL.getForceStress(FORCE, STRESS, TEST_FORCE, TEST_STRESS, fcs, scs); + //-------------------------------------------------- + // only forces are needed, no stresses are needed + //-------------------------------------------------- + if(FORCE && !STRESS) + { + +#ifdef __MPI //2015-10-01, xiaohui + atom_arrange::delete_vector( SEARCH_RADIUS ); +#endif //2015-10-01, xiaohui + + if(CALCULATION=="relax") + { + IMM.cal_movement(istep, istep, fcs, en.etot); + + if(IMM.get_converged() || (istep==NSTEP)) + { + return 1; // 1 means converged + } + else // ions are not converged + { + CE.istep = istep; + CE.extrapolate_charge(); + + if(pot.extra_pot=="dm") + { + } + else + { + pot.init_pot( istep ); + } + } + return 0; + } + else + { + return 1; + } + + // mohan update 2013-04-11 + // setup the structure factor + // and do the density extraploation. + // for both ionic iteratoin and + // force calculations. + + //xiaohui modify 2014-08-09 + //pw.setup_structure_factor(); + + // charge extrapolation if istep>0. + //xiaohui modify 2014-08-09 + //CE.extrapolate_charge(); + +/*xiaohui modify 2014-08-09 + if(pot.extra_pot==4) + { + // done after grid technique. + } + else + { + pot.init_pot( istep ); + } +xiaohui modify 2014-08-09*/ + } + + static bool converged_force = false; + static bool converged_stress = false; + + if(!FORCE&&STRESS) + { + +#ifdef __MPI + atom_arrange::delete_vector( SEARCH_RADIUS ); +#endif + if(CALCULATION=="cell-relax") + { + LCM.cal_lattice_change(stress_step, scs, en.etot); + converged_stress = LCM.get_converged(); + if(converged_stress) + { + return 1; + } + else + { + Variable_Cell::init_after_vc(); + pot.init_pot(stress_step); + + ++stress_step; + return 0; + } + } + else + { + return 1; + } + } + + if(FORCE&&STRESS) + { + +//#ifdef __MPI + atom_arrange::delete_vector( SEARCH_RADIUS ); +//#endif + + //if(CALCULATION=="relax") IMM.cal_movement(istep, FL.fcs, en.etot); + if(CALCULATION=="relax" || CALCULATION=="cell-relax") + { + IMM.cal_movement(istep, force_step, fcs, en.etot); + + if(IMM.get_converged()) + { + force_step = 1; + + + if(CALCULATION=="cell-relax") + { + LCM.cal_lattice_change(stress_step, scs, en.etot); + converged_stress = LCM.get_converged(); + if(converged_stress) + { + return 1; + } + else + { + Variable_Cell::init_after_vc(); + pot.init_pot(stress_step); + + ++stress_step; + return 0; + } + } + else + { + return 1; + } + +#ifdef __MPI + //atom_arrange::delete_vector( SEARCH_RADIUS ); +#endif + } + else + { +#ifdef __MPI + //atom_arrange::delete_vector( SEARCH_RADIUS ); +#endif + //CE.istep = istep; + CE.istep = force_step; + CE.extrapolate_charge(); + + if(pot.extra_pot=="dm")//xiaohui modify 2015-02-01 + { + // done after grid technique. + } + else + { + pot.init_pot( istep ); + } + ++force_step; + return 0; + } + } + else + { + return 1; + } + } + + return 0; + + timer::tick("Run_MD","force_stress",'D'); +} + +void Run_MD::final_scf(void) +{ + TITLE("Run_MD","final_scf"); + + FINAL_SCF = true; + Variable_Cell::final_calculation_after_vc(); + atom_arrange::set_sr_NL(); + atom_arrange::search( SEARCH_RADIUS ); + GridT.set_pbc_grid( + pw.ncx, pw.ncy, pw.ncz, + pw.bx, pw.by, pw.bz, + pw.nbx, pw.nby, pw.nbz, + pw.nbxx, pw.nbzp_start, pw.nbzp); + + // (2) If k point is used here, allocate HlocR after atom_arrange. + if(!GAMMA_ONLY_LOCAL) + { + // For each atom, calculate the adjacent atoms in different cells + // and allocate the space for H(R) and S(R). + LNNR.cal_nnr(); + LM.allocate_HS_R(LNNR.nnr); + + // need to first calculae lgd. + // using GridT.init. + LNNR.cal_nnrg(GridT); + } + + // (4) set the augmented orbitals index. + // after ParaO and GridT, + // this information is used to calculate + // the force. + LOWF.set_trace_aug(GridT); + + // (5) init density kernel + // (6) init wave functions. + if(GAMMA_ONLY_LOCAL) + { + // here we reset the density matrix dimension. + LOC.allocate_gamma(GridT); + } + else + { + LOWF.allocate_k(GridT); + LOC.allocate_DM_k(); + } + + UHM.set_lcao_matrices(); + + if(vdwd2_para.flag_vdwd2) //Peize Lin add 2014-04-04, update 2021-03-09 + { + Vdwd2 vdwd2(ucell,vdwd2_para); + vdwd2.cal_energy(); + en.evdw = vdwd2.energy_result; + } + else if(vdwd3.vdwD3) //jiyy add 2019-05-18 + { + vdwd3.energy(); + en.evdw = vdwd3.energy_result; + } + + ELEC_scf es; + es.scf(0); + + if(CALCULATION=="scf" || CALCULATION=="relax") + { + ofs_running << "\n\n --------------------------------------------" << endl; + ofs_running << setprecision(16); + ofs_running << " !FINAL_ETOT_IS " << en.etot * Ry_to_eV << " eV" << endl; + ofs_running << " --------------------------------------------\n\n" << endl; + } + + return; +} + +void Run_MD::output_HS_R(void) +{ + TITLE("Run_MD","output_HS_R"); + timer::tick("Run_MD","output_HS_R",'D'); + + // add by jingan for out r_R matrix 2019.8.14 + if(INPUT.out_r_matrix) + { + cal_r_overlap_R r_matrix; + r_matrix.init(); + r_matrix.out_r_overlap_R(NSPIN); + } + + if(NSPIN==1||NSPIN==4) + { + UHM.calculate_STN_R(); + UHM.GK.cal_vlocal_R(0); + UHM.GK.distribute_pvpR_tr(); + HS_Matrix::save_HSR_tr(0); + } + ///* + else if(NSPIN==2) + { + UHM.calculate_STN_R(); + for(int ik=0; ik Date: Fri, 12 Mar 2021 19:42:13 +0800 Subject: [PATCH 192/233] fixed bug of last version --- ABACUS.develop/source/src_lcao/run_md.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ABACUS.develop/source/src_lcao/run_md.cpp b/ABACUS.develop/source/src_lcao/run_md.cpp index e3b6e2bab6..82021edb5e 100644 --- a/ABACUS.develop/source/src_lcao/run_md.cpp +++ b/ABACUS.develop/source/src_lcao/run_md.cpp @@ -444,7 +444,7 @@ void Run_MD::final_scf(void) { Vdwd2 vdwd2(ucell,vdwd2_para); vdwd2.cal_energy(); - en.evdw = vdwd2.energy_result; + en.evdw = vdwd2.get_energy(); } else if(vdwd3.vdwD3) //jiyy add 2019-05-18 { From 23414c84cb4754ff1c967c5aebf811b5297b048e Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 12 Mar 2021 19:42:56 +0800 Subject: [PATCH 193/233] update to LOOP_cell, LOOP_ions, and LOOP_elec classes --- ABACUS.develop/source/Makefile.Objects | 8 ++++---- ABACUS.develop/source/run_lcao.cpp | 2 +- ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp | 2 +- ABACUS.develop/source/src_lcao/ELEC_cbands_k.cpp | 2 +- ABACUS.develop/source/src_lcao/ELEC_evolve.cpp | 2 +- .../source/src_lcao/{RELAX_cell.cpp => LOOP_cell.cpp} | 4 ++-- .../source/src_lcao/{RELAX_cell.h => LOOP_cell.h} | 0 .../src_lcao/{local_orbital_elec.cpp => LOOP_elec.cpp} | 2 +- .../source/src_lcao/{local_orbital_elec.h => LOOP_elec.h} | 0 .../src_lcao/{local_orbital_ions.cpp => LOOP_ions.cpp} | 2 +- .../source/src_lcao/{local_orbital_ions.h => LOOP_ions.h} | 2 +- ABACUS.develop/source/src_lcao/dftu.cpp | 2 +- ABACUS.develop/source/src_lcao/dftu_relax.cpp | 2 +- ABACUS.develop/source/src_lcao/dftu_yukawa.cpp | 2 +- ABACUS.develop/source/src_lcao/run_md.cpp | 2 +- ABACUS.develop/source/src_lcao/run_md.h | 2 +- ABACUS.develop/source/src_pw/md.cpp | 2 +- 17 files changed, 19 insertions(+), 19 deletions(-) rename ABACUS.develop/source/src_lcao/{RELAX_cell.cpp => LOOP_cell.cpp} (72%) rename ABACUS.develop/source/src_lcao/{RELAX_cell.h => LOOP_cell.h} (100%) rename ABACUS.develop/source/src_lcao/{local_orbital_elec.cpp => LOOP_elec.cpp} (99%) rename ABACUS.develop/source/src_lcao/{local_orbital_elec.h => LOOP_elec.h} (100%) rename ABACUS.develop/source/src_lcao/{local_orbital_ions.cpp => LOOP_ions.cpp} (99%) rename ABACUS.develop/source/src_lcao/{local_orbital_ions.h => LOOP_ions.h} (96%) diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index d0f10d73c6..4bfdf83c59 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -131,16 +131,16 @@ ORB_table_beta.o\ ORB_table_phi.o\ ORB_gen_tables.o\ local_orbital_wfc.o\ -local_orbital_elec.o\ +local_orbital_charge.o\ ELEC_cbands_k.o\ ELEC_cbands_gamma.o\ ELEC_evolve.o\ ELEC_scf.o\ ELEC_nscf.o\ -RELAX_cell.o\ -local_orbital_ions.o\ +LOOP_cell.o\ +LOOP_elec.o\ +LOOP_ions.o\ run_md.o\ -local_orbital_charge.o\ DM_gamma.o\ DM_k.o\ record_adj.o\ diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index 18f43309a7..71da381030 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -10,7 +10,7 @@ #include "src_lcao/dftu.h" //Quxin add for DFT+U on 20201029 #include "src_io/winput.h" #include "src_global/sltk_atom_arrange.h" -#include "src_lcao/RELAX_cell.h" +#include "src_lcao/LOOP_cell.h" #include "src_io/print_info.h" #include "src_pw/symmetry.h" #include "src_lcao/run_md.h" diff --git a/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp b/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp index 3ee1cb589d..104fa5a680 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp @@ -1,5 +1,5 @@ #include "ELEC_cbands_gamma.h" -#include "local_orbital_elec.h" +#include "LOOP_elec.h" #include "LCAO_diago.h" #include "src_pw/global.h" #include "src_pw/symmetry_rho.h" diff --git a/ABACUS.develop/source/src_lcao/ELEC_cbands_k.cpp b/ABACUS.develop/source/src_lcao/ELEC_cbands_k.cpp index 17db6c76a2..def8c71123 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_cbands_k.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_cbands_k.cpp @@ -1,5 +1,5 @@ #include "ELEC_cbands_k.h" -#include "local_orbital_elec.h" +#include "LOOP_elec.h" #include "LCAO_diago.h" #include "src_pw/global.h" #include "src_pw/symmetry_rho.h" diff --git a/ABACUS.develop/source/src_lcao/ELEC_evolve.cpp b/ABACUS.develop/source/src_lcao/ELEC_evolve.cpp index b853c3cba0..a4b90cb946 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_evolve.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_evolve.cpp @@ -1,5 +1,5 @@ #include "ELEC_evolve.h" -#include "local_orbital_elec.h" +#include "LOOP_elec.h" #include "LCAO_diago.h" #include "src_pw/global.h" #include "src_pw/symmetry_rho.h" diff --git a/ABACUS.develop/source/src_lcao/RELAX_cell.cpp b/ABACUS.develop/source/src_lcao/LOOP_cell.cpp similarity index 72% rename from ABACUS.develop/source/src_lcao/RELAX_cell.cpp rename to ABACUS.develop/source/src_lcao/LOOP_cell.cpp index 3b7a7e776b..54c963c6d9 100644 --- a/ABACUS.develop/source/src_lcao/RELAX_cell.cpp +++ b/ABACUS.develop/source/src_lcao/LOOP_cell.cpp @@ -1,5 +1,5 @@ -#include "RELAX_cell.h" -#include "local_orbital_ions.h" +#include "LOOP_cell.h" +#include "LOOP_ions.h" RELAX_cell::RELAX_cell(){} diff --git a/ABACUS.develop/source/src_lcao/RELAX_cell.h b/ABACUS.develop/source/src_lcao/LOOP_cell.h similarity index 100% rename from ABACUS.develop/source/src_lcao/RELAX_cell.h rename to ABACUS.develop/source/src_lcao/LOOP_cell.h diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp b/ABACUS.develop/source/src_lcao/LOOP_elec.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/local_orbital_elec.cpp rename to ABACUS.develop/source/src_lcao/LOOP_elec.cpp index 94ea73ed07..70e8c659e8 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_elec.cpp +++ b/ABACUS.develop/source/src_lcao/LOOP_elec.cpp @@ -1,4 +1,4 @@ -#include "local_orbital_elec.h" +#include "LOOP_elec.h" #include "LCAO_diago.h" #include "src_pw/global.h" #include "src_pw/symmetry_rho.h" diff --git a/ABACUS.develop/source/src_lcao/local_orbital_elec.h b/ABACUS.develop/source/src_lcao/LOOP_elec.h similarity index 100% rename from ABACUS.develop/source/src_lcao/local_orbital_elec.h rename to ABACUS.develop/source/src_lcao/LOOP_elec.h diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp b/ABACUS.develop/source/src_lcao/LOOP_ions.cpp similarity index 99% rename from ABACUS.develop/source/src_lcao/local_orbital_ions.cpp rename to ABACUS.develop/source/src_lcao/LOOP_ions.cpp index 9730ba8426..fc57c595b4 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.cpp +++ b/ABACUS.develop/source/src_lcao/LOOP_ions.cpp @@ -1,4 +1,4 @@ -#include "local_orbital_ions.h" +#include "LOOP_ions.h" #include "src_pw/global.h" #include "src_parallel/parallel_orbitals.h" #include "src_pdiag/pdiag_double.h" diff --git a/ABACUS.develop/source/src_lcao/local_orbital_ions.h b/ABACUS.develop/source/src_lcao/LOOP_ions.h similarity index 96% rename from ABACUS.develop/source/src_lcao/local_orbital_ions.h rename to ABACUS.develop/source/src_lcao/LOOP_ions.h index ddb957bedf..7d28779aaa 100644 --- a/ABACUS.develop/source/src_lcao/local_orbital_ions.h +++ b/ABACUS.develop/source/src_lcao/LOOP_ions.h @@ -1,7 +1,7 @@ #ifndef LOCAL_ORBITAL_IONS_H #define LOCAL_ORBITAL_IONS_H -#include "local_orbital_elec.h" +#include "LOOP_elec.h" #include "../src_ions/ions_move_methods.h" #include "../src_pw/charge_extra.h" #include "../src_pw/md.h" diff --git a/ABACUS.develop/source/src_lcao/dftu.cpp b/ABACUS.develop/source/src_lcao/dftu.cpp index 511f233a8e..521e70b74d 100644 --- a/ABACUS.develop/source/src_lcao/dftu.cpp +++ b/ABACUS.develop/source/src_lcao/dftu.cpp @@ -20,7 +20,7 @@ #include "../src_global/scalapack_connector.h" #include "../src_global/lapack_connector.h" #include "../src_global/inverse_matrix.h" -#include "local_orbital_ions.h" +#include "LOOP_ions.h" #include "LCAO_matrix.h" #include "../src_pw/magnetism.h" #include "ORB_gen_tables.h" diff --git a/ABACUS.develop/source/src_lcao/dftu_relax.cpp b/ABACUS.develop/source/src_lcao/dftu_relax.cpp index 2c3747e78c..9051fd32a1 100644 --- a/ABACUS.develop/source/src_lcao/dftu_relax.cpp +++ b/ABACUS.develop/source/src_lcao/dftu_relax.cpp @@ -19,7 +19,7 @@ #include "../src_global/scalapack_connector.h" #include "../src_global/lapack_connector.h" #include "../src_global/inverse_matrix.h" -#include "local_orbital_ions.h" +#include "LOOP_ions.h" #include "LCAO_matrix.h" #include "../src_pw/magnetism.h" #include "ORB_gen_tables.h" diff --git a/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp b/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp index 9338c9061b..f789958888 100644 --- a/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp +++ b/ABACUS.develop/source/src_lcao/dftu_yukawa.cpp @@ -17,7 +17,7 @@ #include "../src_pw/global.h" #include "global_fp.h" #include "../src_global/global_function.h" -#include "local_orbital_ions.h" +#include "LOOP_ions.h" #include "LCAO_matrix.h" diff --git a/ABACUS.develop/source/src_lcao/run_md.cpp b/ABACUS.develop/source/src_lcao/run_md.cpp index e3b6e2bab6..82021edb5e 100644 --- a/ABACUS.develop/source/src_lcao/run_md.cpp +++ b/ABACUS.develop/source/src_lcao/run_md.cpp @@ -444,7 +444,7 @@ void Run_MD::final_scf(void) { Vdwd2 vdwd2(ucell,vdwd2_para); vdwd2.cal_energy(); - en.evdw = vdwd2.energy_result; + en.evdw = vdwd2.get_energy(); } else if(vdwd3.vdwD3) //jiyy add 2019-05-18 { diff --git a/ABACUS.develop/source/src_lcao/run_md.h b/ABACUS.develop/source/src_lcao/run_md.h index 51df7a4718..5f42f8f563 100644 --- a/ABACUS.develop/source/src_lcao/run_md.h +++ b/ABACUS.develop/source/src_lcao/run_md.h @@ -1,7 +1,7 @@ #ifndef RUN_MD_H #define RUN_MD_H -#include "local_orbital_elec.h" +#include "LOOP_elec.h" #include "../src_ions/ions_move_methods.h" #include "../src_pw/charge_extra.h" #include "../src_pw/md.h" diff --git a/ABACUS.develop/source/src_pw/md.cpp b/ABACUS.develop/source/src_pw/md.cpp index 4a4d19a3a8..be99fd8763 100644 --- a/ABACUS.develop/source/src_pw/md.cpp +++ b/ABACUS.develop/source/src_pw/md.cpp @@ -7,7 +7,7 @@ #include #include"md.h" #include"../input.h" -#include"../src_lcao/local_orbital_ions.h" +#include"../src_lcao/LOOP_ions.h" #include "../src_global/sltk_atom_arrange.h" //2015-10-01, xiaohui md::md(int n) From 981b9f892e514970b552364d614f9047143af8c8 Mon Sep 17 00:00:00 2001 From: zdy Date: Sat, 13 Mar 2021 00:00:20 +0800 Subject: [PATCH 194/233] rename Local_orbital_ions to LOOP_ions, rename Local_orbital_elec to LOOP_elec, update ETOT output in cell-relax --- .../source/src_io/istate_charge.cpp | 2 +- .../source/src_ions/variable_cell.cpp | 1 - .../source/src_lcao/ELEC_cbands_gamma.cpp | 2 +- ABACUS.develop/source/src_lcao/ELEC_nscf.cpp | 2 +- ABACUS.develop/source/src_lcao/ELEC_nscf.h | 4 +- ABACUS.develop/source/src_lcao/ELEC_scf.h | 4 +- .../source/src_lcao/FORCE_STRESS.cpp | 2 +- ABACUS.develop/source/src_lcao/FORCE_STRESS.h | 2 +- .../source/src_lcao/LCAO_hamilt.cpp | 2 +- ABACUS.develop/source/src_lcao/LCAO_nnr.cpp | 2 +- ABACUS.develop/source/src_lcao/LOOP_cell.cpp | 2 +- ABACUS.develop/source/src_lcao/LOOP_elec.cpp | 34 ++++++++--------- ABACUS.develop/source/src_lcao/LOOP_elec.h | 10 ++--- ABACUS.develop/source/src_lcao/LOOP_ions.cpp | 38 +++++++++---------- ABACUS.develop/source/src_lcao/LOOP_ions.h | 12 +++--- ABACUS.develop/source/src_lcao/dftu.h | 2 +- .../source/src_lcao/grid_technique.cpp | 2 +- ABACUS.develop/source/src_lcao/run_md.h | 2 +- ABACUS.develop/source/src_pw/energy.h | 2 +- 19 files changed, 63 insertions(+), 64 deletions(-) diff --git a/ABACUS.develop/source/src_io/istate_charge.cpp b/ABACUS.develop/source/src_io/istate_charge.cpp index 0151f92b23..03b45f0503 100644 --- a/ABACUS.develop/source/src_io/istate_charge.cpp +++ b/ABACUS.develop/source/src_io/istate_charge.cpp @@ -110,7 +110,7 @@ void IState_Charge::begin(void) { cout << " Perform band decomposed charge density for band " << ib+1 << endl; // (1) - // This has been done once in local_orbital_ions. + // This has been done once in LOOP_ions. // but here we need to done for each band. LOC.allocate_gamma(GridT); diff --git a/ABACUS.develop/source/src_ions/variable_cell.cpp b/ABACUS.develop/source/src_ions/variable_cell.cpp index b524477951..97a89d6ec8 100644 --- a/ABACUS.develop/source/src_ions/variable_cell.cpp +++ b/ABACUS.develop/source/src_ions/variable_cell.cpp @@ -8,7 +8,6 @@ //#include "src_lcao/dftu.h" //Quxin add for DFT+U on 20201029 //#include "src_pw/winput.h" //#include "src_lcao/sltk_atom_arrange.h" -//#include "src_lcao/local_orbital_ions.h" Variable_Cell::Variable_Cell(){} Variable_Cell::~Variable_Cell(){} diff --git a/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp b/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp index 104fa5a680..914a53fc06 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_cbands_gamma.cpp @@ -89,7 +89,7 @@ void ELEC_cbands_gamma::cal_bands(const int &istep, LCAO_Hamilt &uhm) ofs_running << " no diagonalization." << endl; #else cout << " DCOLOR=" << DCOLOR << endl; - WARNING_QUIT("Local_Orbital_Elec::cal_bands","no diagonalization"); + WARNING_QUIT("ELEC_cbands_gamma::cal_bands","no diagonalization"); #endif } diff --git a/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp b/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp index e60852891a..b37d8434d7 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp +++ b/ABACUS.develop/source/src_lcao/ELEC_nscf.cpp @@ -30,7 +30,7 @@ void ELEC_nscf::nscf(LCAO_Hamilt &uhm) } // mohan add 2021-02-09 - // in local_orbital_ions, istep starts from 1, + // in LOOP_ions, istep starts from 1, // then when the istep is a variable of scf or nscf, // istep becomes istep-1, this should be fixed in future int istep=0; diff --git a/ABACUS.develop/source/src_lcao/ELEC_nscf.h b/ABACUS.develop/source/src_lcao/ELEC_nscf.h index 324205739b..711c2a6f4f 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_nscf.h +++ b/ABACUS.develop/source/src_lcao/ELEC_nscf.h @@ -14,8 +14,8 @@ class ELEC_nscf { - friend class Local_Orbital_Ions; - friend class Local_Orbital_Elec; + friend class LOOP_ions; + friend class LOOP_elec; public: diff --git a/ABACUS.develop/source/src_lcao/ELEC_scf.h b/ABACUS.develop/source/src_lcao/ELEC_scf.h index e92e535b54..7a937d4677 100644 --- a/ABACUS.develop/source/src_lcao/ELEC_scf.h +++ b/ABACUS.develop/source/src_lcao/ELEC_scf.h @@ -13,8 +13,8 @@ class ELEC_scf: private Threshold_Elec { - friend class Local_Orbital_Elec; - friend class Local_Orbital_Ions; + friend class LOOP_elec; + friend class LOOP_ions; friend class Run_MD; diff --git a/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp b/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp index 23359fdd22..cbfd4ea799 100644 --- a/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp +++ b/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp @@ -40,7 +40,7 @@ void Force_Stress_LCAO::allocate(void) } #include "../src_pw/efield.h" -// be called in : Local_Orbital_Ions::force_stress +// be called in : LOOP_ions::force_stress void Force_Stress_LCAO::getForceStress( const bool isforce, const bool isstress, diff --git a/ABACUS.develop/source/src_lcao/FORCE_STRESS.h b/ABACUS.develop/source/src_lcao/FORCE_STRESS.h index a41979f352..3e1992b15e 100644 --- a/ABACUS.develop/source/src_lcao/FORCE_STRESS.h +++ b/ABACUS.develop/source/src_lcao/FORCE_STRESS.h @@ -15,7 +15,7 @@ class Force_Stress_LCAO friend class Run_MD; friend void Input_Conv::Convert(); friend class Update_input; - friend class Local_Orbital_Ions; + friend class LOOP_ions; public : diff --git a/ABACUS.develop/source/src_lcao/LCAO_hamilt.cpp b/ABACUS.develop/source/src_lcao/LCAO_hamilt.cpp index aa3d70048c..ebd502af03 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_hamilt.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_hamilt.cpp @@ -181,7 +181,7 @@ void LCAO_Hamilt::calculate_STNR_gamma(void) #include "LCAO_nnr.h" -// be called in Local_Orbital_Elec::cal_bands(). +// be called in LOOP_elec::cal_bands(). void LCAO_Hamilt::calculate_Hk(const int &ik) { TITLE("LCAO_Hamilt","calculate_Hk"); diff --git a/ABACUS.develop/source/src_lcao/LCAO_nnr.cpp b/ABACUS.develop/source/src_lcao/LCAO_nnr.cpp index e62f0aa77d..b52352411b 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_nnr.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_nnr.cpp @@ -41,7 +41,7 @@ LCAO_nnr::~LCAO_nnr() } } -// be called in local_orbital_ions.cpp +// be called in LOOP_ions.cpp void LCAO_nnr::cal_nnr(void) { TITLE("LCAO_nnr","cal_nnr"); diff --git a/ABACUS.develop/source/src_lcao/LOOP_cell.cpp b/ABACUS.develop/source/src_lcao/LOOP_cell.cpp index 54c963c6d9..1381edeec2 100644 --- a/ABACUS.develop/source/src_lcao/LOOP_cell.cpp +++ b/ABACUS.develop/source/src_lcao/LOOP_cell.cpp @@ -9,7 +9,7 @@ RELAX_cell::~RELAX_cell(){} void RELAX_cell::opt_cell() { - Local_Orbital_Ions ions; + LOOP_ions ions; ions.opt_ions(); return; diff --git a/ABACUS.develop/source/src_lcao/LOOP_elec.cpp b/ABACUS.develop/source/src_lcao/LOOP_elec.cpp index 70e8c659e8..778574a103 100644 --- a/ABACUS.develop/source/src_lcao/LOOP_elec.cpp +++ b/ABACUS.develop/source/src_lcao/LOOP_elec.cpp @@ -22,10 +22,10 @@ #include "src_pw/vdwd2.h" -void Local_Orbital_Elec::solve_elec_stru(const int &istep) +void LOOP_elec::solve_elec_stru(const int &istep) { - TITLE("Local_Orbital_Elec","solve_elec_stru"); - timer::tick("Local_Orbital_Elec","solve_elec_stru",'C'); + TITLE("LOOP_elec","solve_elec_stru"); + timer::tick("LOOP_elec","solve_elec_stru",'C'); // prepare HS matrices, prepare grid integral this->set_matrix_grid(); @@ -34,15 +34,15 @@ void Local_Orbital_Elec::solve_elec_stru(const int &istep) // do self-interaction calculations / nscf/ tddft, etc. this->solver(istep); - timer::tick("Local_Orbital_Elec","solve_elec_stru",'C'); + timer::tick("LOOP_elec","solve_elec_stru",'C'); return; } -void Local_Orbital_Elec::set_matrix_grid(void) +void LOOP_elec::set_matrix_grid(void) { - TITLE("Local_Orbital_Elec","set_matrix_grid"); - timer::tick("Local_Orbital_Elec","set_matrix_grid",'D'); + TITLE("LOOP_elec","set_matrix_grid"); + timer::tick("LOOP_elec","set_matrix_grid",'D'); // (1) Find adjacent atoms for each atom. atom_arrange::set_sr_NL(); @@ -69,15 +69,15 @@ void Local_Orbital_Elec::set_matrix_grid(void) LNNR.cal_nnrg(GridT); } - timer::tick("Local_Orbital_Elec","set_matrix_grid",'D'); + timer::tick("LOOP_elec","set_matrix_grid",'D'); return; } -void Local_Orbital_Elec::before_solver(const int &istep) +void LOOP_elec::before_solver(const int &istep) { - TITLE("Local_Orbital_Elec","before_solver"); - timer::tick("Local_Orbital_Elec","before_solver",'D'); + TITLE("LOOP_elec","before_solver"); + timer::tick("LOOP_elec","before_solver",'D'); // set the augmented orbitals index. // after ParaO and GridT, @@ -131,14 +131,14 @@ void Local_Orbital_Elec::before_solver(const int &istep) // (9) compute S, T, Vnl, Vna matrix. UHM.set_lcao_matrices(); - timer::tick("Local_Orbital_Elec","before_solver",'D'); + timer::tick("LOOP_elec","before_solver",'D'); return; } -void Local_Orbital_Elec::solver(const int &istep) +void LOOP_elec::solver(const int &istep) { - TITLE("Local_Orbital_Elec","solver"); - timer::tick("Local_Orbital_Elec","solver",'D'); + TITLE("LOOP_elec","solver"); + timer::tick("LOOP_elec","solver",'D'); // Peize Lin add 2014.04.04, update 2021.03.09 if(vdwd2_para.flag_vdwd2) @@ -229,10 +229,10 @@ void Local_Orbital_Elec::solver(const int &istep) } else { - WARNING_QUIT("Local_Orbital_Ions::solver","CALCULATION type not supported"); + WARNING_QUIT("LOOP_elec::solver","CALCULATION type not supported"); } - timer::tick("Local_Orbital_Elec","solver",'D'); + timer::tick("LOOP_elec","solver",'D'); return; } diff --git a/ABACUS.develop/source/src_lcao/LOOP_elec.h b/ABACUS.develop/source/src_lcao/LOOP_elec.h index b349df288a..260b0680c1 100644 --- a/ABACUS.develop/source/src_lcao/LOOP_elec.h +++ b/ABACUS.develop/source/src_lcao/LOOP_elec.h @@ -1,14 +1,14 @@ -#ifndef LOCAL_ORBTIAL_ELEC -#define LOCAL_ORBITAL_ELEC +#ifndef LOOP_ELEC_H +#define LOOP_ELEC_H #include "../src_pw/tools.h" -class Local_Orbital_Elec +class LOOP_elec { public: - Local_Orbital_Elec(){}; - ~Local_Orbital_Elec(){}; + LOOP_elec(){}; + ~LOOP_elec(){}; // mohan add 2021-02-09 void solve_elec_stru(const int &istep); diff --git a/ABACUS.develop/source/src_lcao/LOOP_ions.cpp b/ABACUS.develop/source/src_lcao/LOOP_ions.cpp index fc57c595b4..8e48f8eec0 100644 --- a/ABACUS.develop/source/src_lcao/LOOP_ions.cpp +++ b/ABACUS.develop/source/src_lcao/LOOP_ions.cpp @@ -14,16 +14,16 @@ #include "src_global/sltk_atom_arrange.h" #include "src_pw/vdwd2.h" -Local_Orbital_Ions::Local_Orbital_Ions() +LOOP_ions::LOOP_ions() {} -Local_Orbital_Ions::~Local_Orbital_Ions() +LOOP_ions::~LOOP_ions() {} -void Local_Orbital_Ions::opt_ions(void) +void LOOP_ions::opt_ions(void) { - TITLE("Local_Orbital_Ions","opt_ions"); - timer::tick("Local_Orbital_Ions","opt_ions",'B'); + TITLE("LOOP_ions","opt_ions"); + timer::tick("LOOP_ions","opt_ions",'B'); if(OUT_LEVEL=="i") { @@ -212,7 +212,7 @@ void Local_Orbital_Ions::opt_ions(void) ++istep; } - if(CALCULATION=="scf" || CALCULATION=="relax") + if(CALCULATION=="scf" || CALCULATION=="relax" || CALCULATION=="cell-relax") { ofs_running << "\n\n --------------------------------------------" << endl; ofs_running << setprecision(16); @@ -243,19 +243,19 @@ void Local_Orbital_Ions::opt_ions(void) // mohan update 2021-02-10 hm.orb_con.clear_after_ions(); - timer::tick("Local_Orbital_Ions","opt_ions",'B'); + timer::tick("LOOP_ions","opt_ions",'B'); return; } -//bool Local_Orbital_Ions::force_stress(void) -bool Local_Orbital_Ions::force_stress(const int &istep, int &force_step, int &stress_step) +//bool LOOP_ions::force_stress(void) +bool LOOP_ions::force_stress(const int &istep, int &force_step, int &stress_step) { - TITLE("Local_Orbital_Ions","force_stress"); + TITLE("LOOP_ions","force_stress"); if(!FORCE && !STRESS) { return 1; } - timer::tick("Local_Orbital_Ions","force_stress",'D'); + timer::tick("LOOP_ions","force_stress",'D'); matrix fcs; matrix scs; Force_Stress_LCAO FSL; @@ -428,12 +428,12 @@ xiaohui modify 2014-08-09*/ return 0; - timer::tick("Local_Orbital_Ions","force_stress",'D'); + timer::tick("LOOP_ions","force_stress",'D'); } -void Local_Orbital_Ions::final_scf(void) +void LOOP_ions::final_scf(void) { - TITLE("Local_Orbital_Ions","final_scf"); + TITLE("LOOP_ions","final_scf"); FINAL_SCF = true; Variable_Cell::final_calculation_after_vc(); @@ -494,7 +494,7 @@ void Local_Orbital_Ions::final_scf(void) ELEC_scf es; es.scf(0); - if(CALCULATION=="scf" || CALCULATION=="relax") + if(CALCULATION=="scf" || CALCULATION=="relax" || CALCULATION=="cell-relax") { ofs_running << "\n\n --------------------------------------------" << endl; ofs_running << setprecision(16); @@ -505,10 +505,10 @@ void Local_Orbital_Ions::final_scf(void) return; } -void Local_Orbital_Ions::output_HS_R(void) +void LOOP_ions::output_HS_R(void) { - TITLE("Local_Orbital_Ions","output_HS_R"); - timer::tick("Local_Orbital_Ions","output_HS_R",'D'); + TITLE("LOOP_ions","output_HS_R"); + timer::tick("LOOP_ions","output_HS_R",'D'); // add by jingan for out r_R matrix 2019.8.14 if(INPUT.out_r_matrix) @@ -559,6 +559,6 @@ void Local_Orbital_Ions::output_HS_R(void) UHM.GK.destroy_pvpR(); } //LiuXh 20181011 - timer::tick("Local_Orbital_Ions","output_HS_R",'D'); + timer::tick("LOOP_ions","output_HS_R",'D'); return; } diff --git a/ABACUS.develop/source/src_lcao/LOOP_ions.h b/ABACUS.develop/source/src_lcao/LOOP_ions.h index 7d28779aaa..630eb86b91 100644 --- a/ABACUS.develop/source/src_lcao/LOOP_ions.h +++ b/ABACUS.develop/source/src_lcao/LOOP_ions.h @@ -1,5 +1,5 @@ -#ifndef LOCAL_ORBITAL_IONS_H -#define LOCAL_ORBITAL_IONS_H +#ifndef LOOP_IONS_H +#define LOOP_IONS_H #include "LOOP_elec.h" #include "../src_ions/ions_move_methods.h" @@ -9,15 +9,15 @@ #include "../src_pw/mdNVE.h" #include "../src_ions/lattice_change_methods.h" -class Local_Orbital_Ions +class LOOP_ions { public: - Local_Orbital_Ions(); - ~Local_Orbital_Ions(); + LOOP_ions(); + ~LOOP_ions(); - Local_Orbital_Elec LOE; + LOOP_elec LOE; void opt_ions(void); void output_HS_R(void); //LiuXh add 2019-07-15 diff --git a/ABACUS.develop/source/src_lcao/dftu.h b/ABACUS.develop/source/src_lcao/dftu.h index 5bf95fd68e..a5f80724d0 100644 --- a/ABACUS.develop/source/src_lcao/dftu.h +++ b/ABACUS.develop/source/src_lcao/dftu.h @@ -26,7 +26,7 @@ class DFTU : public DFTU_RELAX //called at Run_Frag::frag_LCAO_line(void) void init(); // initialize the input terms of U, J, double_counting etc - //called at Local_Orbital_Elec::scf(const int &istep) + //called at LOOP_elec::scf(const int &istep) //calculate the local occupation number matrix void cal_occup_m_k(const int iter); void cal_occup_m_gamma(const int iter); diff --git a/ABACUS.develop/source/src_lcao/grid_technique.cpp b/ABACUS.develop/source/src_lcao/grid_technique.cpp index ea9dc7401b..746c66b3ee 100644 --- a/ABACUS.develop/source/src_lcao/grid_technique.cpp +++ b/ABACUS.develop/source/src_lcao/grid_technique.cpp @@ -33,7 +33,7 @@ Grid_Technique::~Grid_Technique() } -// This function is called in local_orbital_ions.cpp +// This function is called in LOOP_ions.cpp // after the orbital information has been read, // this function control the routinue to generate // grid technique parameters. diff --git a/ABACUS.develop/source/src_lcao/run_md.h b/ABACUS.develop/source/src_lcao/run_md.h index 5f42f8f563..103d9c0d4f 100644 --- a/ABACUS.develop/source/src_lcao/run_md.h +++ b/ABACUS.develop/source/src_lcao/run_md.h @@ -17,7 +17,7 @@ class Run_MD Run_MD(); ~Run_MD(); - Local_Orbital_Elec LOE; + LOOP_elec LOE; void opt_ions(void); void output_HS_R(void); //LiuXh add 2019-07-15 diff --git a/ABACUS.develop/source/src_pw/energy.h b/ABACUS.develop/source/src_pw/energy.h index 442f89be2d..aa2c20a9b8 100644 --- a/ABACUS.develop/source/src_pw/energy.h +++ b/ABACUS.develop/source/src_pw/energy.h @@ -11,7 +11,7 @@ class energy public: friend class Electrons; friend class Electrons_Stochastic;//mohan add 2021-01-31 - friend class Local_Orbital_Elec; + friend class LOOP_elec; friend class Local_Orbital_Charge; friend class Threshold_Elec; friend class Forces; From 81147705b2e58643f2149fb0b45ca0ca2ab8729c Mon Sep 17 00:00:00 2001 From: mohan Date: Sat, 13 Mar 2021 15:16:18 +0800 Subject: [PATCH 195/233] change RELAX_cell to LOOP_cell --- ABACUS.develop/source/run_lcao.cpp | 65 ++++++++------- ABACUS.develop/source/src_lcao/LOOP_cell.cpp | 8 +- ABACUS.develop/source/src_lcao/LOOP_cell.h | 10 +-- .../source/src_lcao/gint_gamma_fvl.cpp | 83 ++++++++++--------- .../source/src_lcao/gint_gamma_rho.cpp | 11 +-- ABACUS.develop/source/src_lcao/run_md.cpp | 10 +++ ABACUS.develop/source/src_lcao/run_md.h | 1 + 7 files changed, 104 insertions(+), 84 deletions(-) diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index 71da381030..38d934498c 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -116,53 +116,54 @@ void Run_lcao::lcao_line(void) } - // Init the local wave functions. + // Initialize the local wave functions. wf.init_local(); - // Init the FFT. + // Initialize the FFT. UFFT.allocate(); - // Init the local part of NC pseudopotential. + // Initialize the local part of NC pseudopotential. ppcell.init_vloc(); - // Init the potential. + // Initialize the potential. pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs - // Peize Lin 2016-12-03 - if (CALCULATION=="scf" || CALCULATION=="md" || CALCULATION=="relax" || CALCULATION=="cell-relax") - { - switch(exx_global.info.hybrid_type) - { - case Exx_Global::Hybrid_Type::HF: - case Exx_Global::Hybrid_Type::PBE0: - case Exx_Global::Hybrid_Type::HSE: - exx_lcao.init(); - break; - case Exx_Global::Hybrid_Type::No: - case Exx_Global::Hybrid_Type::Generate_Matrix: - break; - default: - throw invalid_argument(TO_STRING(__FILE__)+TO_STRING(__LINE__)); - } - } - - // Quxin added for DFT+U - if(INPUT.dft_plus_u) - { - dftu.init(); - } - if(CALCULATION=="md") { Run_MD run_md; - run_md.opt_ions(); + run_md.opt_cell(); } else { - RELAX_cell rcell; - rcell.opt_cell(); + // Peize Lin 2016-12-03 + if (CALCULATION=="scf" || CALCULATION=="md" || CALCULATION=="relax" || CALCULATION=="cell-relax") + { + switch(exx_global.info.hybrid_type) + { + case Exx_Global::Hybrid_Type::HF: + case Exx_Global::Hybrid_Type::PBE0: + case Exx_Global::Hybrid_Type::HSE: + exx_lcao.init(); + break; + case Exx_Global::Hybrid_Type::No: + case Exx_Global::Hybrid_Type::Generate_Matrix: + break; + default: + throw invalid_argument(TO_STRING(__FILE__)+TO_STRING(__LINE__)); + } + } + + // Quxin added for DFT+U + if(INPUT.dft_plus_u) + { + dftu.init(); + } + + LOOP_cell lc; + lc.opt_cell(); + + en.perform_dos(); } - en.perform_dos(); timer::tick("Run_lcao","lcao_line",'A'); return; diff --git a/ABACUS.develop/source/src_lcao/LOOP_cell.cpp b/ABACUS.develop/source/src_lcao/LOOP_cell.cpp index 1381edeec2..24ab0724d4 100644 --- a/ABACUS.develop/source/src_lcao/LOOP_cell.cpp +++ b/ABACUS.develop/source/src_lcao/LOOP_cell.cpp @@ -2,12 +2,10 @@ #include "LOOP_ions.h" -RELAX_cell::RELAX_cell(){} +LOOP_cell::LOOP_cell(){} +LOOP_cell::~LOOP_cell(){} -RELAX_cell::~RELAX_cell(){} - - -void RELAX_cell::opt_cell() +void LOOP_cell::opt_cell() { LOOP_ions ions; ions.opt_ions(); diff --git a/ABACUS.develop/source/src_lcao/LOOP_cell.h b/ABACUS.develop/source/src_lcao/LOOP_cell.h index 05fab63a0e..4e8883deb8 100644 --- a/ABACUS.develop/source/src_lcao/LOOP_cell.h +++ b/ABACUS.develop/source/src_lcao/LOOP_cell.h @@ -1,12 +1,12 @@ -#ifndef RELAX_CELL_H -#define RELAX_CELL_H +#ifndef LOOP_CELL_H +#define LOOP_CELL_H -class RELAX_cell +class LOOP_cell { public: - RELAX_cell(); - ~RELAX_cell(); + LOOP_cell(); + ~LOOP_cell(); void opt_cell(void); diff --git a/ABACUS.develop/source/src_lcao/gint_gamma_fvl.cpp b/ABACUS.develop/source/src_lcao/gint_gamma_fvl.cpp index ec3a0cdb78..782830c817 100644 --- a/ABACUS.develop/source/src_lcao/gint_gamma_fvl.cpp +++ b/ABACUS.develop/source/src_lcao/gint_gamma_fvl.cpp @@ -367,6 +367,7 @@ inline void cal_meshball_DGridV( &dphiz[0][idx2], &LD_pool, &psir_vlbr3[0][idx1], &LD_pool, &beta, &DGridV_z[iw1_lo][iw2_lo], &lgd_now); + if(STRESS) { k=1; @@ -432,44 +433,50 @@ inline void cal_meshball_DGridV( &dphiz[ib][idx2], &LD_pool, &psir_vlbr3[ib][idx1], &LD_pool, &beta, &DGridV_z[iw1_lo][iw2_lo], &lgd_now); + if(STRESS) - { - double stress_alpha1 = alpha * drr(ia2,ib,0); - double stress_alpha2 = alpha * drr(ia2,ib,1); - double stress_alpha3 = alpha * drr(ia2,ib,2); - dgemm_ (&transa, &transb, &n, &m, &k, &stress_alpha1, - &dphix[ib][idx2], &LD_pool, - &psir_vlbr3[ib][idx1], &LD_pool, - &beta, &DGridV_11[iw1_lo][iw2_lo], &lgd_now); - dgemm_ (&transa, &transb, &n, &m, &k, &stress_alpha2, - &dphix[ib][idx2], &LD_pool, - &psir_vlbr3[ib][idx1], &LD_pool, - &beta, &DGridV_12[iw1_lo][iw2_lo], &lgd_now); - dgemm_ (&transa, &transb, &n, &m, &k, &stress_alpha3, - &dphix[ib][idx2], &LD_pool, - &psir_vlbr3[ib][idx1], &LD_pool, - &beta, &DGridV_13[iw1_lo][iw2_lo], &lgd_now); - dgemm_ (&transa, &transb, &n, &m, &k, &stress_alpha2, - &dphiy[ib][idx2], &LD_pool, - &psir_vlbr3[ib][idx1], &LD_pool, - &beta, &DGridV_22[iw1_lo][iw2_lo], &lgd_now); - dgemm_ (&transa, &transb, &n, &m, &k, &stress_alpha3, - &dphiy[ib][idx2], &LD_pool, - &psir_vlbr3[ib][idx1], &LD_pool, - &beta, &DGridV_23[iw1_lo][iw2_lo], &lgd_now); - dgemm_ (&transa, &transb, &n, &m, &k, &stress_alpha3, - &dphiz[ib][idx2], &LD_pool, - &psir_vlbr3[ib][idx1], &LD_pool, - &beta, &DGridV_33[iw1_lo][iw2_lo], &lgd_now); -// DGridV_11[iw1_lo*GridT.lgd + iw2_lo] += DGridV_x[iw1_lo][iw2_lo] * drr[ia2][ib][0]; -// DGridV_12[iw1_lo*GridT.lgd + iw2_lo] += DGridV_x[iw1_lo][iw2_lo] * drr[ia2][ib][1]; -// DGridV_13[iw1_lo*GridT.lgd + iw2_lo] += DGridV_x[iw1_lo][iw2_lo] * drr[ia2][ib][2]; -// DGridV_22[iw1_lo*GridT.lgd + iw2_lo] += DGridV_y[iw1_lo][iw2_lo] * drr[ia2][ib][1]; -// DGridV_23[iw1_lo*GridT.lgd + iw2_lo] += DGridV_y[iw1_lo][iw2_lo] * drr[ia2][ib][2]; -// DGridV_33[iw1_lo*GridT.lgd + iw2_lo] += DGridV_z[iw1_lo][iw2_lo] * drr[ia2][ib][2]; -//cout<<"DGridV: "< Date: Sat, 13 Mar 2021 20:05:19 +0800 Subject: [PATCH 196/233] updates LCAO_matrix by adding more input parameters into subroutines where H and S are divided and initilized --- ABACUS.develop/source/run_lcao.cpp | 23 +++++++----------- ABACUS.develop/source/src_io/energy_dos.cpp | 2 -- .../source/src_lcao/LCAO_matrix.cpp | 23 ++++++++---------- ABACUS.develop/source/src_lcao/LCAO_matrix.h | 24 +++++++++++++++---- 4 files changed, 39 insertions(+), 33 deletions(-) diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index 38d934498c..d43b951237 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -29,6 +29,7 @@ void Run_lcao::lcao_line(void) // improvement: a) separating the first reading of the atom_card and subsequent // cell relaxation. b) put NLOCAL and NBANDS as input parameters ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running); + //ucell.setup_cell( global_pseudo_dir , global_atom_card , ofs_running, NLOCAL, NBANDS); DONE(ofs_running, "SETUP UNITCELL"); @@ -40,7 +41,7 @@ void Run_lcao::lcao_line(void) } // Setup the k points according to symmetry. - kv.set( symm, global_kpoint_card, NSPIN, ucell.G, ucell.latvec ); + kv.set(symm, global_kpoint_card, NSPIN, ucell.G, ucell.latvec ); DONE(ofs_running,"INIT K-POINTS"); // print information @@ -49,21 +50,15 @@ void Run_lcao::lcao_line(void) PI.setup_parameters(); - - // for LCAO basis, reading the orbitals and construct - // the interpolation tables. - - // read orbital information. - // init overlap matrix table, which is 'S Table' - // init kinetical matrix element table, which is 'T Table' - // init non-local pseudopotential matrix element table, which is 'NL Table' + // * reading the localized orbitals/projectors + // * construct the interpolation tables. hm.orb_con.set_orb_tables(); - // xiaohui add 2015-09-06 - // (1) divide the H and S matrix into each CPU, count the dimensions - // (2) set the 'trace' between local H/S and global H/S - // (2) allocate the needed H and S memory - LM.divide_HS_in_frag(); + // * divide the H and S according to computational resources + // * set the 'trace' between local H/S and global H/S + // * allocate the needed H and S memory for Gamma/multi k-points + LM.divide_HS_in_frag(GAMMA_ONLY_LOCAL, ParaO); + //-------------------------------------- diff --git a/ABACUS.develop/source/src_io/energy_dos.cpp b/ABACUS.develop/source/src_io/energy_dos.cpp index 3579108f46..4f54e904cf 100644 --- a/ABACUS.develop/source/src_io/energy_dos.cpp +++ b/ABACUS.develop/source/src_io/energy_dos.cpp @@ -342,8 +342,6 @@ void energy::perform_dos(void) if(is == kv.isk[ik]) { - - LM.allocate_HS_k(ParaO.nloc); LM.zeros_HSk('S'); LNNR.folding_fixedH(ik); diff --git a/ABACUS.develop/source/src_lcao/LCAO_matrix.cpp b/ABACUS.develop/source/src_lcao/LCAO_matrix.cpp index 4f57025ddb..a3477a0833 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_matrix.cpp @@ -32,7 +32,7 @@ LCAO_Matrix::~LCAO_Matrix() } -void LCAO_Matrix::divide_HS_in_frag(void) +void LCAO_Matrix::divide_HS_in_frag(const bool isGamma, Parallel_Orbitals &po) { TITLE("LCAO_Matrix","divide_HS_in_frag"); @@ -44,9 +44,9 @@ void LCAO_Matrix::divide_HS_in_frag(void) { ofs_running << " divide the H&S matrix using 2D block algorithms." << endl; #ifdef __MPI - // the storage form of H and S matrices on each processor + // storage form of H and S matrices on each processor // is determined in 'divide_HS_2d' subroutine - ParaO.divide_HS_2d(DIAG_WORLD); + po.divide_HS_2d(DIAG_WORLD); #else WARNING_QUIT("LCAO_Matrix::init","diago method is not ready."); #endif @@ -54,25 +54,22 @@ void LCAO_Matrix::divide_HS_in_frag(void) else { // the full matrix - ParaO.nloc = NLOCAL * NLOCAL; + po.nloc = NLOCAL * NLOCAL; } // (2) set the trace, then we can calculate the nnr. - // for 2d: calculate ParaO.nloc first, then trace_loc_row and trace_loc_col + // for 2d: calculate po.nloc first, then trace_loc_row and trace_loc_col // for O(N): calculate the three together. - ParaO.set_trace(); + po.set_trace(); - // (3) allocate matrix. - if(GAMMA_ONLY_LOCAL) + // (3) allocate for S, H_fixed, H, and S_diag + if(isGamma) { - // allocate for S, H_fixed, H, and S_diag - allocate_HS_gamma(ParaO.nloc); + allocate_HS_gamma(po.nloc); } else { - // allocate for S, H_fixed, H, and S_diag - // for version 2 - allocate_HS_k(ParaO.nloc); + allocate_HS_k(po.nloc); } return; diff --git a/ABACUS.develop/source/src_lcao/LCAO_matrix.h b/ABACUS.develop/source/src_lcao/LCAO_matrix.h index aafd586947..6c50e854cc 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_matrix.h +++ b/ABACUS.develop/source/src_lcao/LCAO_matrix.h @@ -2,13 +2,28 @@ #define LCAO_MATRIX_H #include "../src_pw/tools.h" +#include "src_parallel/parallel_orbitals.h" class LCAO_Matrix { + friend class energy; + friend class Mulliken_Charge; + public: + LCAO_Matrix(); ~LCAO_Matrix(); + void divide_HS_in_frag(const bool isGamma, Parallel_Orbitals &po); + + private: + + void allocate_HS_gamma(const long &nloc); + + void allocate_HS_k(const long &nloc); + + + public: //------------------------------ // H, S, Hfixed // used in gamma only algorithm. @@ -123,15 +138,18 @@ class LCAO_Matrix double* DHloc_fixed_23; double* DHloc_fixed_33; - void divide_HS_in_frag(void); + void set_HSgamma(const int &iw1_all, const int &iw2_all, const double &v, const char &dtype); void set_HSk(const int &iw1_all, const int &iw2_all, const complex &v, const char &dtype, const int spin = 0); + void set_force (const int& iw1_all, const int& iw2_all, const double& vx, const double& vy, const double& vz, const char &dtype); void set_stress (const int& iw1_all, const int& iw2_all, const double& vx, const double& vy, const double& vz, const char &dtype, const Vector3 &dtau); + void set_HR_tr(const int &Rx, const int &Ry, const int &Rz, const int &iw1_all, const int &iw2_all, const double &v); - void set_HR_tr_soc(const int &Rx, const int &Ry, const int &Rz, const int &iw1_all, const int &iw2_all, const complex &v); //LiuXh add 2019-07-16 + void set_HR_tr_soc(const int &Rx, const int &Ry, const int &Rz, + const int &iw1_all, const int &iw2_all, const complex &v); //LiuXh add 2019-07-16 void zeros_HSgamma(const char &mtype); void zeros_HSk(const char &mtype); @@ -143,8 +161,6 @@ class LCAO_Matrix void update_Hloc2(void); void allocate_HS_R(const int &nnr); - void allocate_HS_gamma(const long &nloc); - void allocate_HS_k(const long &nloc); void output_HSk(const char &mtype, string &fn); //LiuXh add 2019-07-15 From 81b83f92224b1f6ce6beb78bb8b8317caac89c8a Mon Sep 17 00:00:00 2001 From: mohan Date: Sat, 13 Mar 2021 20:46:43 +0800 Subject: [PATCH 197/233] add H_TDDFT_pw file, update run_lcao.cpp in order to reconstruct the cell-ion-electron loops --- ABACUS.develop/source/Makefile.Objects | 1 + ABACUS.develop/source/run_lcao.cpp | 33 ++-- .../source/src_ions/variable_cell.cpp | 2 +- ABACUS.develop/source/src_pw/H_TDDFT_pw.cpp | 111 +++++++++++++ ABACUS.develop/source/src_pw/potential.cpp | 147 +++--------------- ABACUS.develop/source/src_pw/wavefunc.cpp | 4 +- ABACUS.develop/source/src_pw/wavefunc.h | 2 +- 7 files changed, 149 insertions(+), 151 deletions(-) create mode 100644 ABACUS.develop/source/src_pw/H_TDDFT_pw.cpp diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 4bfdf83c59..fe41bb5ab8 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -229,6 +229,7 @@ potential.o \ H_Ewald_pw.o\ H_Hartree_pw.o\ H_XC_pw.o \ +H_TDDFT_pw.o\ read_rho.o\ read_atoms.o\ read_pseudopot.o\ diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index d43b951237..fb3f46ebc5 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -24,7 +24,6 @@ void Run_lcao::lcao_line(void) TITLE("Run_lcao","lcao_line"); timer::tick("Run_lcao","lcao_line",'A'); - // Setup the unitcell. // improvement: a) separating the first reading of the atom_card and subsequent // cell relaxation. b) put NLOCAL and NBANDS as input parameters @@ -49,50 +48,42 @@ void Run_lcao::lcao_line(void) Print_Info PI; PI.setup_parameters(); - // * reading the localized orbitals/projectors // * construct the interpolation tables. hm.orb_con.set_orb_tables(); - // * divide the H and S according to computational resources + // * allocate H and S matrices according to computational resources // * set the 'trace' between local H/S and global H/S - // * allocate the needed H and S memory for Gamma/multi k-points LM.divide_HS_in_frag(GAMMA_ONLY_LOCAL, ParaO); - - //-------------------------------------- // cell relaxation should begin here //-------------------------------------- - // Initalize the plane wave basis set pw.gen_pw(ofs_running, ucell, kv); DONE(ofs_running,"INIT PLANEWAVE"); cout << " UNIFORM GRID DIM : " << pw.nx <<" * " << pw.ny <<" * "<< pw.nz << endl; cout << " UNIFORM GRID DIM(BIG): " << pw.nbx <<" * " << pw.nby <<" * "<< pw.nbz << endl; - - // mohan add 2010-10-10, just to test the symmetry of a variety - // of systems. + // the symmetry of a variety of systems. if(CALCULATION == "test") { Cal_Test::test_memory(); QUIT(); } - // mohan add 2010-09-13 // initialize the real-space uniform grid for FFT and parallel // distribution of plane waves Pgrid.init(pw.ncx, pw.ncy, pw.ncz, pw.nczp, pw.nrxx, pw.nbz, pw.bz); // mohan add 2010-07-22, update 2011-05-04 - // (1) Inititlize the charge density. + // Inititlize the charge density. CHR.allocate(NSPIN, pw.nrxx, pw.ngmc); DONE(ofs_running,"INIT CHARGE"); - // (2) Initializee the potential. + // Initializee the potential. pot.allocate(pw.nrxx); DONE(ofs_running,"INIT POTENTIAL"); @@ -112,14 +103,20 @@ void Run_lcao::lcao_line(void) // Initialize the local wave functions. - wf.init_local(); + // npwx, eigenvalues, and weights + wf.allocate_ekb_wg(kv.nks); + // Initialize the FFT. UFFT.allocate(); - // Initialize the local part of NC pseudopotential. + + // Initialize the local part of + // NC pseudopotentials ppcell.init_vloc(); - // Initialize the potential. - pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs + // Initialize the sum of all local potentials. + // if ion_step==0, read in/initialize the potentials + int ion_step=0; + pot.init_pot(ion_step); if(CALCULATION=="md") @@ -130,7 +127,7 @@ void Run_lcao::lcao_line(void) else { // Peize Lin 2016-12-03 - if (CALCULATION=="scf" || CALCULATION=="md" || CALCULATION=="relax" || CALCULATION=="cell-relax") + if (CALCULATION=="scf" || CALCULATION=="relax" || CALCULATION=="cell-relax") { switch(exx_global.info.hybrid_type) { diff --git a/ABACUS.develop/source/src_ions/variable_cell.cpp b/ABACUS.develop/source/src_ions/variable_cell.cpp index 97a89d6ec8..3a4d551da7 100644 --- a/ABACUS.develop/source/src_ions/variable_cell.cpp +++ b/ABACUS.develop/source/src_ions/variable_cell.cpp @@ -132,7 +132,7 @@ void Variable_Cell::final_calculation_after_vc(void) } else { - wf.init_local(); + wf.allocate_ekb_wg(kv.nks); } UFFT.allocate(); diff --git a/ABACUS.develop/source/src_pw/H_TDDFT_pw.cpp b/ABACUS.develop/source/src_pw/H_TDDFT_pw.cpp new file mode 100644 index 0000000000..5c509123a9 --- /dev/null +++ b/ABACUS.develop/source/src_pw/H_TDDFT_pw.cpp @@ -0,0 +1,111 @@ +#include "src_pw/potential.h" +#include "global.h" + +//========================================================== +// this function aims to add external time-dependent potential +// (eg: linear potential) used in tddft +// fuxiang add in 2017-05 +//========================================================== +void potential::set_vrs_tddft(const int istep) +{ + TITLE("potential","set_vrs_tddft"); + timer::tick("potential","set_vrs_tddft"); + + for (int is = 0;is < NSPIN;is++) + { + //==================================================== + // add external linear potential, fuxiang add in 2017/05 + //==================================================== + + const int timescale = 1; // get the time that vext influences; + if (istep >= timescale) + { + for (int i = 0;i < pw.nrxx;i++) + { + this->vrs(is, i) = this->vltot[i] + this->vr(is, i); + } + cout << "vext = 0! " << endl; + } + else + { + this->vextold = new double[pw.nrxx]; + this->vext = new double[pw.nrxx]; + const int yz = pw.ncy*pw.nczp; + int index, i, j, k; + + for(int ir=0; irvextold[ir] = (0.019447*k/pw.ncx-0.001069585)*ucell.lat0; + else if (k>=pw.ncx*0.05 && kvextold[ir] = -0.0019447*k/pw.ncx*ucell.lat0; + else if (k>=pw.ncx*0.95) this->vextold[ir] = (0.019447*(1.0*k/pw.ncx-1)-0.001069585)*ucell.lat0; + } + else if(vext_dire == 2) + { + if (jvextold[ir] = (0.019447*j/pw.ncx-0.001069585)*ucell.lat0; + else if (j>=pw.ncx*0.05 && jvextold[ir] = -0.0019447*j/pw.ncx*ucell.lat0; + else if (j>=pw.ncx*0.95) this->vextold[ir] = (0.019447*(1.0*j/pw.ncx-1)-0.001069585)*ucell.lat0; + } + else if(vext_dire == 3) + { + if (ivextold[ir] = (0.019447*i/pw.ncx-0.001069585)*ucell.lat0; + else if (i>=pw.ncx*0.05 && ivextold[ir] = -0.0019447*i/pw.ncx*ucell.lat0; + else if (i>=pw.ncx*0.95) this->vextold[ir] = (0.019447*(1.0*i/pw.ncx-1)-0.001069585)*ucell.lat0; + } + + // Gauss +/* + const double w = 22.13; // eV + const double sigmasquare = 6836; + const double timecenter = 700; + const double timenow = (istep-timecenter)*INPUT.md_dt*41.34; + this->vext[ir] = this->vextold[ir]*cos(w/27.2116*timenow)*exp(-timenow*timenow*0.5/(sigmasquare))*0.25; //0.1 is modified in 2018/1/12 +*/ + + //HHG of H atom +/* + if(istep < 1875) + { + this->vext[ir] = this->vextold[ir]*2.74*istep/1875*cos(0.0588*istep*INPUT.md_dt*41.34); // 2.75 is equal to E0; + } + else if(istep < 5625) + { + this->vext[ir] = this->vextold[ir]*2.74*cos(0.0588*istep*INPUT.md_dt*41.34); + } + else if(istep < 7500) + { + this->vext[ir] = this->vextold[ir]*2.74*(7500-istep)/1875*cos(0.0588*istep*INPUT.md_dt*41.34); + } +*/ + + //HHG of H2 + + //const double timenow = (istep)*INPUT.md_dt*41.34; + //this->vext[ir] = this->vextold[ir]*2.74*cos(0.856*timenow)*sin(0.0214*timenow)*sin(0.0214*timenow); + //this->vext[ir] = this->vextold[ir]*2.74*cos(0.856*timenow)*sin(0.0214*timenow)*sin(0.0214*timenow)*0.01944; + //this->vext[ir] = this->vextold[ir]*2.74*cos(0.0428*timenow)*sin(0.00107*timenow)*sin(0.00107*timenow); + + this->vrs(is,ir) = this->vltot[ir] + this->vr(is, ir) + this->vext[ir]; + + //cout << "x: " << k <<" " << "y: " << j <<" "<< "z: "<< i <<" "<< "ir: " << ir << endl; + //cout << "vext: " << this->vext[ir] << endl; + //cout << "vrs: " << vrs(is,ir) <vextold; + delete[] this->vext; + } + } + + + timer::tick("potential","set_vrs_tddft"); + return; +} //end subroutine set_vrs_tddft diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index 8955561e5e..542bd5e441 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -57,27 +57,25 @@ void potential::init_pot(const int &istep) assert(istep>=0); - vrs.zero_out(); + // total potential in real space + this->vrs.zero_out(); - // mohan fix bug 2011-07-08 // the vltot should and must be zero here. ZEROS(this->vltot, pw.nrxx); //------------------------------------------------------------------- - // put the local pseudopotential + electric field (if any) in vltot + // (1) local pseudopotential + electric field (if any) in vltot //------------------------------------------------------------------- this->set_local(this->vltot); - // mohan fix bug 2011-07-07 - // set pseudopotentials. - int nspin0=NSPIN;//zhengdy-soc, pauli matrix, just index 0 has vlocal term. + // zhengdy-soc, pauli matrix, just index 0 has vlocal term + int nspin0=NSPIN; - if(NSPIN==4) nspin0=1; + if(NSPIN==4) + { + nspin0=1; + } - //------------------------------------------------------------------- - // put the local pseudopotential + electric field (if any) in vltot - // vrs saves the total potential. - //------------------------------------------------------------------- for(int is=0; isv_of_rho(CHR.rho, vr); //---------------------------------------------------------- - // Define the total local potential (external+scf) in DFT - // Define TDDFT potential, by Fuxiang He + // (4) total potentials //---------------------------------------------------------- if(vext == 0) { @@ -200,6 +201,7 @@ void potential::init_pot(const int &istep) this->set_vrs_tddft(istep); } + // plots //figure::picture(this->vrs1,pw.ncx,pw.ncy,pw.ncz); timer::tick("potential","init_pot"); return; @@ -316,21 +318,20 @@ void potential::set_vrs(void) //================================================================= if(NSPIN==4&&is>0) { - for (int i = 0;i < pw.nrxx;i++) + for (int i = 0;i < pw.nrxx; i++) { this->vrs(is, i) = this->vr(is, i); } } else { - for (int i = 0;i < pw.nrxx;i++) + for (int i = 0;i < pw.nrxx; i++) { this->vrs(is, i) = this->vltot[i] + this->vr(is, i); } } } - timer::tick("potential","set_vrs"); return; } @@ -403,113 +404,3 @@ void potential::newd(void) } return; } // end subroutine newd - - -//========================================================== -// this function aims to add external time-dependent potential -// (eg: linear potential) used in tddft -// fuxiang add in 2017-05 -//========================================================== -void potential::set_vrs_tddft(const int istep) -{ - TITLE("potential","set_vrs_tddft"); - timer::tick("potential","set_vrs_tddft"); - - for (int is = 0;is < NSPIN;is++) - { - //==================================================== - // add external linear potential, fuxiang add in 2017/05 - //==================================================== - - const int timescale = 1; // get the time that vext influences; - if (istep >= timescale) - { - for (int i = 0;i < pw.nrxx;i++) - { - this->vrs(is, i) = this->vltot[i] + this->vr(is, i); - } - cout << "vext = 0! " << endl; - } - else - { - this->vextold = new double[pw.nrxx]; - this->vext = new double[pw.nrxx]; - const int yz = pw.ncy*pw.nczp; - int index, i, j, k; - - for(int ir=0; irvextold[ir] = (0.019447*k/pw.ncx-0.001069585)*ucell.lat0; - else if (k>=pw.ncx*0.05 && kvextold[ir] = -0.0019447*k/pw.ncx*ucell.lat0; - else if (k>=pw.ncx*0.95) this->vextold[ir] = (0.019447*(1.0*k/pw.ncx-1)-0.001069585)*ucell.lat0; - } - else if(vext_dire == 2) - { - if (jvextold[ir] = (0.019447*j/pw.ncx-0.001069585)*ucell.lat0; - else if (j>=pw.ncx*0.05 && jvextold[ir] = -0.0019447*j/pw.ncx*ucell.lat0; - else if (j>=pw.ncx*0.95) this->vextold[ir] = (0.019447*(1.0*j/pw.ncx-1)-0.001069585)*ucell.lat0; - } - else if(vext_dire == 3) - { - if (ivextold[ir] = (0.019447*i/pw.ncx-0.001069585)*ucell.lat0; - else if (i>=pw.ncx*0.05 && ivextold[ir] = -0.0019447*i/pw.ncx*ucell.lat0; - else if (i>=pw.ncx*0.95) this->vextold[ir] = (0.019447*(1.0*i/pw.ncx-1)-0.001069585)*ucell.lat0; - } - - // Gauss -/* - const double w = 22.13; // eV - const double sigmasquare = 6836; - const double timecenter = 700; - const double timenow = (istep-timecenter)*INPUT.md_dt*41.34; - this->vext[ir] = this->vextold[ir]*cos(w/27.2116*timenow)*exp(-timenow*timenow*0.5/(sigmasquare))*0.25; //0.1 is modified in 2018/1/12 -*/ - - //HHG of H atom -/* - if(istep < 1875) - { - this->vext[ir] = this->vextold[ir]*2.74*istep/1875*cos(0.0588*istep*INPUT.md_dt*41.34); // 2.75 is equal to E0; - } - else if(istep < 5625) - { - this->vext[ir] = this->vextold[ir]*2.74*cos(0.0588*istep*INPUT.md_dt*41.34); - } - else if(istep < 7500) - { - this->vext[ir] = this->vextold[ir]*2.74*(7500-istep)/1875*cos(0.0588*istep*INPUT.md_dt*41.34); - } -*/ - - //HHG of H2 - - //const double timenow = (istep)*INPUT.md_dt*41.34; - //this->vext[ir] = this->vextold[ir]*2.74*cos(0.856*timenow)*sin(0.0214*timenow)*sin(0.0214*timenow); - //this->vext[ir] = this->vextold[ir]*2.74*cos(0.856*timenow)*sin(0.0214*timenow)*sin(0.0214*timenow)*0.01944; - //this->vext[ir] = this->vextold[ir]*2.74*cos(0.0428*timenow)*sin(0.00107*timenow)*sin(0.00107*timenow); - - this->vrs(is,ir) = this->vltot[ir] + this->vr(is, ir) + this->vext[ir]; - - //cout << "x: " << k <<" " << "y: " << j <<" "<< "z: "<< i <<" "<< "ir: " << ir << endl; - //cout << "vext: " << this->vext[ir] << endl; - //cout << "vrs: " << vrs(is,ir) <vextold; - delete[] this->vext; - } - } - - - timer::tick("potential","set_vrs_tddft"); - return; -} //end subroutine set_vrs_tddft diff --git a/ABACUS.develop/source/src_pw/wavefunc.cpp b/ABACUS.develop/source/src_pw/wavefunc.cpp index e2807ad274..af4a3bddd7 100644 --- a/ABACUS.develop/source/src_pw/wavefunc.cpp +++ b/ABACUS.develop/source/src_pw/wavefunc.cpp @@ -27,10 +27,9 @@ wavefunc::~wavefunc() } } -void wavefunc::init_local(void) +void wavefunc::allocate_ekb_wg(const int nks) { TITLE("wavefunc","init_local"); - const int nks = kv.nks; this->npwx = this->setupIndGk(pw, nks); // band energies @@ -47,7 +46,6 @@ void wavefunc::init_local(void) Memory::record("wavefunc","ekb",nks*NBANDS,"double"); Memory::record("wavefunc","wg",nks*NBANDS,"double"); - if(test_wf)ofs_running << " Allocate : EigenValue; Weight;" << endl; return; } diff --git a/ABACUS.develop/source/src_pw/wavefunc.h b/ABACUS.develop/source/src_pw/wavefunc.h index 57153fdb66..5bc4c858b0 100644 --- a/ABACUS.develop/source/src_pw/wavefunc.h +++ b/ABACUS.develop/source/src_pw/wavefunc.h @@ -13,7 +13,7 @@ class wavefunc : public WF_atomic // allocate memory void allocate(const int nks); - void init_local(void); + void allocate_ekb_wg(const int nks); int out_wf; //qianrui modify 2020-10-19 From 5e37899adfc722b9f5f4a907347a5c8809f81b78 Mon Sep 17 00:00:00 2001 From: zdy Date: Sat, 13 Mar 2021 23:09:05 +0800 Subject: [PATCH 198/233] Rename Make_Overlap_Table to ORB_table_phi --- .../source/src_io/cal_r_overlap_R.h | 2 +- .../source/src_io/unk_overlap_lcao.h | 2 +- .../source/src_lcao/ORB_gen_tables.h | 2 +- .../source/src_lcao/ORB_table_phi.cpp | 70 +-- .../source/src_lcao/ORB_table_phi.h | 6 +- .../source/src_lcao/center2_orb-orb11.cpp | 2 +- .../source/src_lcao/center2_orb-orb11.h | 4 +- .../source/src_lcao/center2_orb-orb21.cpp | 2 +- .../source/src_lcao/center2_orb-orb21.h | 4 +- .../source/src_lcao/center2_orb-orb22.cpp | 2 +- .../source/src_lcao/center2_orb-orb22.h | 4 +- .../source/src_lcao/center2_orb-orb22_ccp.h | 2 +- ABACUS.develop/source/src_pw/MD_thermo.cpp | 452 ++++++++++++++++++ ABACUS.develop/source/src_pw/MD_thermo.h | 65 +++ .../exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h | 2 +- .../source/src_ri/exx_abfs-matrix_orbs11.h | 2 +- .../source/src_ri/exx_abfs-matrix_orbs21.h | 2 +- .../source/src_ri/exx_abfs-matrix_orbs22.h | 2 +- 18 files changed, 572 insertions(+), 55 deletions(-) create mode 100644 ABACUS.develop/source/src_pw/MD_thermo.cpp create mode 100644 ABACUS.develop/source/src_pw/MD_thermo.h diff --git a/ABACUS.develop/source/src_io/cal_r_overlap_R.h b/ABACUS.develop/source/src_io/cal_r_overlap_R.h index 05a4ae4334..cb1e7bde76 100644 --- a/ABACUS.develop/source/src_io/cal_r_overlap_R.h +++ b/ABACUS.develop/source/src_io/cal_r_overlap_R.h @@ -33,7 +33,7 @@ class cal_r_overlap_R ~cal_r_overlap_R(); - Make_Overlap_Table MOT; + ORB_table_phi MOT; Make_Gaunt_Table MGT; diff --git a/ABACUS.develop/source/src_io/unk_overlap_lcao.h b/ABACUS.develop/source/src_io/unk_overlap_lcao.h index b495ed69eb..f7a3907a24 100644 --- a/ABACUS.develop/source/src_io/unk_overlap_lcao.h +++ b/ABACUS.develop/source/src_io/unk_overlap_lcao.h @@ -25,7 +25,7 @@ class unkOverlap_lcao { public: - Make_Overlap_Table MOT; + ORB_table_phi MOT; Make_Gaunt_Table MGT; Numerical_Orbital_Lm orb_r; // 新建的r矢é‡,以原å­è½¨é“å½¢å¼å­˜åœ¨,以solidçƒè°å‡½æ•°å±•å¼€ diff --git a/ABACUS.develop/source/src_lcao/ORB_gen_tables.h b/ABACUS.develop/source/src_lcao/ORB_gen_tables.h index 8a257b88e6..57d13f138e 100644 --- a/ABACUS.develop/source/src_lcao/ORB_gen_tables.h +++ b/ABACUS.develop/source/src_lcao/ORB_gen_tables.h @@ -67,7 +67,7 @@ class ORB_gen_tables // set as public because in hamilt_linear, // we need to destroy the tables: SR,TR,NR // after ionic optimization is done. - Make_Overlap_Table MOT; + ORB_table_phi MOT; ORB_table_beta tbeta; // if we want to add table for descriptors, diff --git a/ABACUS.develop/source/src_lcao/ORB_table_phi.cpp b/ABACUS.develop/source/src_lcao/ORB_table_phi.cpp index 9791c8bdc4..03ff1e1060 100644 --- a/ABACUS.develop/source/src_lcao/ORB_table_phi.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_table_phi.cpp @@ -3,9 +3,9 @@ #include #include "../src_ri/exx_abfs.h" -double Make_Overlap_Table::dr = -1.0; +double ORB_table_phi::dr = -1.0; -Make_Overlap_Table::Make_Overlap_Table() +ORB_table_phi::ORB_table_phi() { destroy_sr = false; destroy_tr = false; @@ -26,7 +26,7 @@ Make_Overlap_Table::Make_Overlap_Table() kab=new double[1]; } -Make_Overlap_Table::~Make_Overlap_Table() +ORB_table_phi::~ORB_table_phi() { delete[] kpoint; delete[] r; @@ -34,7 +34,7 @@ Make_Overlap_Table::~Make_Overlap_Table() delete[] kab; } -void Make_Overlap_Table::allocate +void ORB_table_phi::allocate ( const int &ntype_in, const int &lmax_in, @@ -44,7 +44,7 @@ void Make_Overlap_Table::allocate const double &dk_in ) { - TITLE("Make_Overlap_Table", "allocate"); + TITLE("ORB_table_phi", "allocate"); this->ntype = ntype_in;// type of elements. this->lmax = lmax_in; @@ -101,9 +101,9 @@ void Make_Overlap_Table::allocate return; } -int Make_Overlap_Table::get_rmesh(const double &R1, const double &R2) +int ORB_table_phi::get_rmesh(const double &R1, const double &R2) { - int rmesh = static_cast((R1+R2)/ Make_Overlap_Table::dr) + 5; + int rmesh = static_cast((R1+R2)/ ORB_table_phi::dr) + 5; //mohan update 2009-09-08 +1 ==> +5 //considering interpolation or so on... if (rmesh % 2 == 0) rmesh ++; @@ -112,13 +112,13 @@ int Make_Overlap_Table::get_rmesh(const double &R1, const double &R2) { ofs_warning << "\n R1 = " << R1 << " R2 = " << R2; ofs_warning << "\n rmesh = " << rmesh; - WARNING_QUIT("Make_Overlap_Table::get_rmesh", "rmesh <= 0"); + WARNING_QUIT("ORB_table_phi::get_rmesh", "rmesh <= 0"); } return rmesh; } // Peize Lin accelerate 2017-10-02 -void Make_Overlap_Table::cal_ST_Phi12_R +void ORB_table_phi::cal_ST_Phi12_R ( const int &job, const int &l, @@ -129,7 +129,7 @@ void Make_Overlap_Table::cal_ST_Phi12_R double* drs ) const { - timer::tick("Make_Overlap_Table", "cal_ST_Phi12_R"); + timer::tick("ORB_table_phi", "cal_ST_Phi12_R"); double* k1_dot_k2 = new double[kmesh]; double* k1_dot_k2_dot_kpoint = new double[kmesh]; @@ -242,14 +242,14 @@ void Make_Overlap_Table::cal_ST_Phi12_R delete [] k1_dot_k2; delete [] k1_dot_k2_dot_kpoint; - timer::tick("Make_Overlap_Table", "cal_ST_Phi12_R"); + timer::tick("ORB_table_phi", "cal_ST_Phi12_R"); return; } // Peize Lin add 2017-10-27 -void Make_Overlap_Table::cal_ST_Phi12_R +void ORB_table_phi::cal_ST_Phi12_R ( const int &job, const int &l, @@ -260,8 +260,8 @@ void Make_Overlap_Table::cal_ST_Phi12_R double* drs ) const { -// TITLE("Make_Overlap_Table","cal_ST_Phi12_R"); - timer::tick("Make_Overlap_Table", "cal_ST_Phi12_R"); +// TITLE("ORB_table_phi","cal_ST_Phi12_R"); + timer::tick("ORB_table_phi", "cal_ST_Phi12_R"); vector k1_dot_k2(kmesh); switch(job) @@ -365,19 +365,19 @@ void Make_Overlap_Table::cal_ST_Phi12_R } } - timer::tick("Make_Overlap_Table", "cal_ST_Phi12_R"); + timer::tick("ORB_table_phi", "cal_ST_Phi12_R"); return; } -void Make_Overlap_Table::init_Table( const int &job0 ) +void ORB_table_phi::init_Table( const int &job0 ) { - TITLE("Make_Overlap_Table", "init_Table"); - timer::tick("Make_Overlap_Table", "init_Table",'D'); + TITLE("ORB_table_phi", "init_Table"); + timer::tick("ORB_table_phi", "init_Table",'D'); const int ntype = ORB.get_ntype(); - assert( Make_Overlap_Table::dr > 0.0); + assert( ORB_table_phi::dr > 0.0); assert( OV_nTpairs>0); // init 1st dimension @@ -516,7 +516,7 @@ void Make_Overlap_Table::init_Table( const int &job0 ) Table_SR[0][Tpair][Opair][L] = new double[rmesh]; Table_SR[1][Tpair][Opair][L] = new double[rmesh]; - Memory::record("Make_Overlap_Table","Table_SR", + Memory::record("ORB_table_phi","Table_SR", 2*OV_nTpairs*pairs_chi*rmesh,"double"); break; @@ -524,7 +524,7 @@ void Make_Overlap_Table::init_Table( const int &job0 ) Table_TR[0][Tpair][Opair][L] = new double[rmesh]; Table_TR[1][Tpair][Opair][L] = new double[rmesh]; - Memory::record("Make_Overlap_Table","Table_TR", + Memory::record("ORB_table_phi","Table_TR", 2*OV_nTpairs*pairs_chi*rmesh,"double"); break; @@ -534,7 +534,7 @@ void Make_Overlap_Table::init_Table( const int &job0 ) Table_TR[0][Tpair][Opair][L] = new double[rmesh]; Table_TR[1][Tpair][Opair][L] = new double[rmesh]; - Memory::record("Make_Overlap_Table","Table_SR&TR", + Memory::record("ORB_table_phi","Table_SR&TR", 2*2*OV_nTpairs*pairs_chi*rmesh,"double"); break; } @@ -631,12 +631,12 @@ void Make_Overlap_Table::init_Table( const int &job0 ) break; } - timer::tick("Make_Overlap_Table", "init_Table",'D'); + timer::tick("ORB_table_phi", "init_Table",'D'); return; } -void Make_Overlap_Table::Destroy_Table(void) +void ORB_table_phi::Destroy_Table(void) { if(!destroy_sr && !destroy_tr) return; @@ -685,9 +685,9 @@ void Make_Overlap_Table::Destroy_Table(void) -void Make_Overlap_Table::init_OV_Tpair(void) +void ORB_table_phi::init_OV_Tpair(void) { - TITLE("Make_Overlap_Table","init_OV_Tpair"); + TITLE("ORB_table_phi","init_OV_Tpair"); assert(ntype>0); this->OV_nTpairs = this->ntype * (this->ntype + 1) / 2; @@ -718,7 +718,7 @@ void Make_Overlap_Table::init_OV_Tpair(void) -void Make_Overlap_Table::init_OV_Opair(void) +void ORB_table_phi::init_OV_Opair(void) { const int lmax = ORB.get_lmax(); const int nchimax = ORB.get_nchimax(); @@ -756,7 +756,7 @@ void Make_Overlap_Table::init_OV_Opair(void) } // Peize Lin update 2016-01-26 -void Make_Overlap_Table::init_Lmax (const int orb_num, const int mode, int &Lmax_used, int &Lmax) const +void ORB_table_phi::init_Lmax (const int orb_num, const int mode, int &Lmax_used, int &Lmax) const { auto cal_Lmax_Phi = [](int &Lmax) { @@ -803,7 +803,7 @@ void Make_Overlap_Table::init_Lmax (const int orb_num, const int mode, int &Lmax Lmax_used = 2*Lmax + 1; break; default: - throw invalid_argument("Make_Overlap_Table::init_Lmax orb_num=2, mode error"); + throw invalid_argument("ORB_table_phi::init_Lmax orb_num=2, mode error"); break; } break; @@ -817,7 +817,7 @@ void Make_Overlap_Table::init_Lmax (const int orb_num, const int mode, int &Lmax Lmax_used += Exx_Abfs::Lmax; break; default: - throw invalid_argument("Make_Overlap_Table::init_Lmax orb_num=3, mode error"); + throw invalid_argument("ORB_table_phi::init_Lmax orb_num=3, mode error"); break; } break; @@ -829,12 +829,12 @@ void Make_Overlap_Table::init_Lmax (const int orb_num, const int mode, int &Lmax Lmax_used = 2*( 2*Lmax + 1 ); break; default: - throw invalid_argument("Make_Overlap_Table::init_Lmax orb_num=4, mode error"); + throw invalid_argument("ORB_table_phi::init_Lmax orb_num=4, mode error"); break; } break; default: - throw invalid_argument("Make_Overlap_Table::init_Lmax orb_num error"); + throw invalid_argument("ORB_table_phi::init_Lmax orb_num error"); break; } @@ -842,9 +842,9 @@ void Make_Overlap_Table::init_Lmax (const int orb_num, const int mode, int &Lmax } // Peize Lin update 2016-01-26 -void Make_Overlap_Table::init_Table_Spherical_Bessel (const int orb_num, const int mode, int &Lmax_used, int &Lmax) +void ORB_table_phi::init_Table_Spherical_Bessel (const int orb_num, const int mode, int &Lmax_used, int &Lmax) { - TITLE("Make_Overlap_Table", "init_Table_Spherical_Bessel"); + TITLE("ORB_table_phi", "init_Table_Spherical_Bessel"); this->init_Lmax (orb_num,mode,Lmax_used,Lmax); // Peize Lin add 2016-01-26 @@ -890,5 +890,5 @@ void Make_Overlap_Table::init_Table_Spherical_Bessel (const int orb_num, const i OUT(ofs_running,"lmax used to generate Jlq",Lmax_used); // OUT(ofs_running,"kmesh",kmesh); // OUT(ofs_running,"Rmesh",Rmesh); - Memory::record ("Make_Overlap_Table", "Jl(x)", (Lmax_used+1) * this->kmesh * this->Rmesh, "double"); + Memory::record ("ORB_table_phi", "Jl(x)", (Lmax_used+1) * this->kmesh * this->Rmesh, "double"); } diff --git a/ABACUS.develop/source/src_lcao/ORB_table_phi.h b/ABACUS.develop/source/src_lcao/ORB_table_phi.h index cd2b176f58..416a51075a 100644 --- a/ABACUS.develop/source/src_lcao/ORB_table_phi.h +++ b/ABACUS.develop/source/src_lcao/ORB_table_phi.h @@ -9,12 +9,12 @@ #include "src_global/sph_bessel_recursive.h" #include -class Make_Overlap_Table +class ORB_table_phi { public: - Make_Overlap_Table(); - ~Make_Overlap_Table(); + ORB_table_phi(); + ~ORB_table_phi(); void allocate ( const int &ntype, diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb11.cpp b/ABACUS.develop/source/src_lcao/center2_orb-orb11.cpp index 00a1a71f73..0a362208fa 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb11.cpp +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb11.cpp @@ -13,7 +13,7 @@ Center2_Orb::Orb11::Orb11( const Numerical_Orbital_Lm &nA_in, const Numerical_Orbital_Lm &nB_in, - const Make_Overlap_Table &MOT_in, + const ORB_table_phi &MOT_in, const Make_Gaunt_Table &MGT_in ) :nA(nA_in), diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb11.h b/ABACUS.develop/source/src_lcao/center2_orb-orb11.h index 0dd57f9831..d6178ee038 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb11.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb11.h @@ -27,7 +27,7 @@ class Center2_Orb::Orb11 Orb11( const Numerical_Orbital_Lm &nA_in, const Numerical_Orbital_Lm &nB_in, - const Make_Overlap_Table &MOT_in, + const ORB_table_phi &MOT_in, const Make_Gaunt_Table &MGT_in ); void init_radial_table(void); @@ -43,7 +43,7 @@ class Center2_Orb::Orb11 const Numerical_Orbital_Lm &nA; const Numerical_Orbital_Lm &nB; - const Make_Overlap_Table &MOT; + const ORB_table_phi &MOT; const Make_Gaunt_Table &MGT; map> Table_r; // unit: Bohr/MOT.dr diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb21.cpp b/ABACUS.develop/source/src_lcao/center2_orb-orb21.cpp index fa16ea7866..e6c0d7ddff 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb21.cpp +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb21.cpp @@ -14,7 +14,7 @@ Center2_Orb::Orb21::Orb21( const Numerical_Orbital_Lm &nA1_in, const Numerical_Orbital_Lm &nA2_in, const Numerical_Orbital_Lm &nB_in, - const Make_Overlap_Table &MOT_in, + const ORB_table_phi &MOT_in, const Make_Gaunt_Table &MGT_in ) :nA1(nA1_in), diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb21.h b/ABACUS.develop/source/src_lcao/center2_orb-orb21.h index 1eb4c11f6c..6c6e34ae75 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb21.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb21.h @@ -30,7 +30,7 @@ class Center2_Orb::Orb21 const Numerical_Orbital_Lm &nA1_in, const Numerical_Orbital_Lm &nA2_in, const Numerical_Orbital_Lm &nB_in, - const Make_Overlap_Table &MOT_in, + const ORB_table_phi &MOT_in, const Make_Gaunt_Table &MGT_in ); void init_radial_table(); @@ -47,7 +47,7 @@ class Center2_Orb::Orb21 const Numerical_Orbital_Lm &nA2; const Numerical_Orbital_Lm &nB; - const Make_Overlap_Table &MOT; + const ORB_table_phi &MOT; const Make_Gaunt_Table &MGT; map nA; diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb22.cpp b/ABACUS.develop/source/src_lcao/center2_orb-orb22.cpp index 778108d61a..e689163f75 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb22.cpp +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb22.cpp @@ -10,7 +10,7 @@ Center2_Orb::Orb22::Orb22( const Numerical_Orbital_Lm &nA2_in, const Numerical_Orbital_Lm &nB1_in, const Numerical_Orbital_Lm &nB2_in, - const Make_Overlap_Table &MOT_in, + const ORB_table_phi &MOT_in, const Make_Gaunt_Table &MGT_in ) :nA1(nA1_in), diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb22.h b/ABACUS.develop/source/src_lcao/center2_orb-orb22.h index 206397fa2a..9c9b39cafe 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb22.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb22.h @@ -29,7 +29,7 @@ class Center2_Orb::Orb22 const Numerical_Orbital_Lm &nA2_in, const Numerical_Orbital_Lm &nB1_in, const Numerical_Orbital_Lm &nB2_in, - const Make_Overlap_Table &MOT_in, + const ORB_table_phi &MOT_in, const Make_Gaunt_Table &MGT_in ); void init_radial_table(); void init_radial_table( const set &radials ); // unit: Bohr/MOT.dr @@ -43,7 +43,7 @@ class Center2_Orb::Orb22 const Numerical_Orbital_Lm &nB1; const Numerical_Orbital_Lm &nB2; - const Make_Overlap_Table &MOT; + const ORB_table_phi &MOT; const Make_Gaunt_Table &MGT; map nB; diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb22_ccp.h b/ABACUS.develop/source/src_lcao/center2_orb-orb22_ccp.h index 51a0fcd96d..3f80716336 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb22_ccp.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb22_ccp.h @@ -12,7 +12,7 @@ class Center2_Orb::Orb22_Ccp: public Center2_Orb::Orb22 const Numerical_Orbital_Lm &nA2_in, const Numerical_Orbital_Lm &nB1_in, const Numerical_Orbital_Lm &nB2_in, - const Make_Overlap_Table &MOT_in, + const ORB_table_phi &MOT_in, const Make_Gaunt_Table &MGT_in ) : Orb22( nA1_in, nA2_in, nB1_in, nB2_in, MOT_in, MGT_in ){} diff --git a/ABACUS.develop/source/src_pw/MD_thermo.cpp b/ABACUS.develop/source/src_pw/MD_thermo.cpp new file mode 100644 index 0000000000..fe55fcf2ff --- /dev/null +++ b/ABACUS.develop/source/src_pw/MD_thermo.cpp @@ -0,0 +1,452 @@ +#include"MD_thermo.h" + +MD_thermo::init_NHC( + const int &MNHC_in, + const int &NVT_control, + ofstream &ofs, + const int &numIon + ) +{ + this->MNHC = MNHC_in; + unsigned long init[4]={0x123, 0x234, 0x345, 0x456}, length=4; + init_by_array(init, length); + ofs<<" ...............Nose-Hoover Chain parameter initialization............... " << endl; + ofs<<" Temperature = "<< temperature << endl; + ofs<<" Temperature2 = "<< temperature/K_BOLTZMAN_AU << endl; + ofs<<" NHC frequency = "<< 1.0/NVT_tau << endl; + ofs<<" NHC chain = "<< MNHC << endl; + ofs<<" Qmass = "<< Qmass << endl; + ofs<<" ............................................................... " << endl; + w[0]=0.7845136105; + w[6]=0.7845136105; + w[1]=0.2355732134; + w[5]=0.2355732134; + w[2]=-1.177679984; + w[4]=-1.177679984; + w[3]=1-w[0]-w[1]-w[2]-w[4]-w[5]-w[6]; + // + for(int i=0;i[MNHC*numIon]; + delete[] NHCeta; + NHCeta=new Vector3[MNHC*numIon]; + delete[] NHCpeta; + NHCpeta=new Vector3[MNHC*numIon]; + + for(int j=0;j=1;j--) + { + for(int k=0;k=0;j--) + { + for(int k=0;k=0;j--) + { + for(int k=0;k *G; //parameter in NHC + Vector3 *NHCeta; //NHC position + Vector3 *NHCpeta; //NHC momentum + +}; \ No newline at end of file diff --git a/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h b/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h index 1e9f0a4f81..7f6c40fa46 100644 --- a/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h @@ -41,7 +41,7 @@ class Exx_Abfs::Matrix_Lcaoslcaos_Lcaoslcaos private: - Make_Overlap_Table MOT; + ORB_table_phi MOT; Make_Gaunt_Table MGT; map Date: Sun, 14 Mar 2021 03:35:33 +0800 Subject: [PATCH 199/233] output jle(r) --- ABACUS.develop/source/src_io/bessel_basis.cpp | 57 ++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/ABACUS.develop/source/src_io/bessel_basis.cpp b/ABACUS.develop/source/src_io/bessel_basis.cpp index ff5e90519b..47f7a40d8e 100644 --- a/ABACUS.develop/source/src_io/bessel_basis.cpp +++ b/ABACUS.develop/source/src_io/bessel_basis.cpp @@ -203,11 +203,47 @@ void Bessel_Basis::init_TableOne( } } + //caoyu add 2021-3-10 + //=========output .orb format============= + stringstream ss; + ss << global_out_dir << "jle.orb"; + ofstream ofs(ss.str().c_str()); + ofs << "---------------------------------------------------------------------------"<< endl; + ofs << setiosflags(ios::left) << setw(28) << "Energy Cutoff(Ry)" << ecutwfc << endl; + ofs << setiosflags(ios::left) << setw(28) << "Radius Cutoff(a.u.)" << rcut << endl; + ofs << setiosflags(ios::left) << setw(28) << "Lmax" << lmax << endl; + for (int l = 0; l < lmax + 1; l++) + { + switch (l) + { + case 0: + ofs << setiosflags(ios::left) << setw(28) << "Number of Sorbitals-->" << ecut_number << endl; + break; + case 1: + ofs << setiosflags(ios::left) << setw(28) << "Number of Porbitals-->" << ecut_number << endl; + break; + case 2: + ofs << setiosflags(ios::left) << setw(28) << "Number of Dorbitals-->" << ecut_number << endl; + break; + case 3: + ofs << setiosflags(ios::left) << setw(28) << "Number of Forbitals-->" << ecut_number << endl; + break; + default: + ofs << setiosflags(ios::left) << setw(28) << "Number of Gorbitals-->" << ecut_number << endl; + } + } + ofs << "---------------------------------------------------------------------------"<< endl; + ofs << "SUMMARY END" << endl << endl; + ofs << setiosflags(ios::left) << setw(28) << "Mesh" << rmesh << endl; + ofs << setiosflags(ios::left) << setw(28) << "dr" << dr << endl ; + //=========output .orb format============= // init eigenvalue of Jl for(int l=0; l Date: Sun, 14 Mar 2021 15:12:15 +0800 Subject: [PATCH 200/233] improve cinitcgg function with blas lib --- ABACUS.develop/source/src_pw/hamilt_pw.cpp | 38 ++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/ABACUS.develop/source/src_pw/hamilt_pw.cpp b/ABACUS.develop/source/src_pw/hamilt_pw.cpp index b71903b41f..b2459fe9d3 100644 --- a/ABACUS.develop/source/src_pw/hamilt_pw.cpp +++ b/ABACUS.develop/source/src_pw/hamilt_pw.cpp @@ -323,7 +323,41 @@ void Hamilt_PW::cinitcgg( else { // As the evc and psi may refer to the same matrix, we first - // create a temporary matrix to story the result. (by wangjp) + // create a temporary matrix to story the result. (by wangjp) + //qianrui improve this part 2021-3-13 + char transa = 'N'; + char transb = 'T'; + if(NPOL == 1) + { + ComplexMatrix evctmp(n_band, wf.npw,false); + zgemm_(&transa,&transb,&wf.npw,&n_band,&nstart,&ONE,psi.c,&wf.npw,hvec.c,&n_band,&ZERO,evctmp.c,&wf.npw); + for(int ib=0; ib Date: Sun, 14 Mar 2021 16:26:06 +0800 Subject: [PATCH 201/233] improve cinitcgg , now efficiency of this part is comparable with QE --- ABACUS.develop/source/src_pw/hamilt_pw.cpp | 64 +++++++++++++++------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/ABACUS.develop/source/src_pw/hamilt_pw.cpp b/ABACUS.develop/source/src_pw/hamilt_pw.cpp index b2459fe9d3..31a78be605 100644 --- a/ABACUS.develop/source/src_pw/hamilt_pw.cpp +++ b/ABACUS.develop/source/src_pw/hamilt_pw.cpp @@ -113,7 +113,41 @@ void Hamilt_PW::cinitcgg( ComplexMatrix hc(nstart, nstart); ComplexMatrix sc(nstart, nstart); ComplexMatrix hvec(nstart,n_band); + int dmin,dmax; + const int npw = kv.ngk[ik]; + if(!NONCOLIN) + { + dmin= npw; + dmax = wf.npwx; + } + else { + dmin = wf.npwx*NPOL; + dmax = wf.npwx*NPOL; + } + //qianrui improve this part 2021-3-14 + complex *aux=new complex [dmax*nstart]; + complex *paux = aux; + complex *ppsi = psi.c; + for(int m=0;mh_psi(ppsi, paux); + paux += dmax; + ppsi += dmax; + } + char trans1 = 'C'; + char trans2 = 'N'; + zgemm_(&trans1,&trans2,&nstart,&nstart,&dmin,&ONE,psi.c,&dmax,aux,&dmax,&ZERO,hc.c,&nstart); + zgemm_(&trans1,&trans2,&nstart,&nstart,&dmin,&ONE,psi.c,&dmax,psi.c,&dmax,&ZERO,sc.c,&nstart); + //After psis are strictly normalized, we should use this part. + //for(int m=1;m **p = new complex*[nstart]; for(int i=0; i* hpsi = new complex[dmin]; complex* spsi = new complex[dmin]; @@ -180,6 +202,14 @@ void Hamilt_PW::cinitcgg( } } + delete[] hpsi; + delete[] spsi; + for(int i=0; i1) { @@ -217,11 +243,7 @@ void Hamilt_PW::cinitcgg( Parallel_Reduce::reduce_complex_double_pool( sc.c, nstart*nstart ); } - for(int i=0; i Date: Sun, 14 Mar 2021 20:32:46 +0800 Subject: [PATCH 202/233] update dftu.init --- ABACUS.develop/source/run_lcao.cpp | 7 - ABACUS.develop/source/src_lcao/LOOP_cell.cpp | 8 ++ ABACUS.develop/source/src_lcao/dftu.cpp | 129 +++++++++++-------- ABACUS.develop/source/src_lcao/dftu.h | 13 +- ABACUS.develop/source/src_lcao/dftu_relax.h | 9 +- ABACUS.develop/source/src_pw/unitcell.h | 2 +- 6 files changed, 95 insertions(+), 73 deletions(-) diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index fb3f46ebc5..03bfc6f437 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -7,7 +7,6 @@ #include "input.h" #include "src_io/optical.h" #include "src_io/cal_test.h" -#include "src_lcao/dftu.h" //Quxin add for DFT+U on 20201029 #include "src_io/winput.h" #include "src_global/sltk_atom_arrange.h" #include "src_lcao/LOOP_cell.h" @@ -144,12 +143,6 @@ void Run_lcao::lcao_line(void) } } - // Quxin added for DFT+U - if(INPUT.dft_plus_u) - { - dftu.init(); - } - LOOP_cell lc; lc.opt_cell(); diff --git a/ABACUS.develop/source/src_lcao/LOOP_cell.cpp b/ABACUS.develop/source/src_lcao/LOOP_cell.cpp index 24ab0724d4..58bb436951 100644 --- a/ABACUS.develop/source/src_lcao/LOOP_cell.cpp +++ b/ABACUS.develop/source/src_lcao/LOOP_cell.cpp @@ -1,12 +1,20 @@ #include "LOOP_cell.h" #include "LOOP_ions.h" +#include "src_lcao/dftu.h" //Quxin add for DFT+U on 20201029 LOOP_cell::LOOP_cell(){} LOOP_cell::~LOOP_cell(){} void LOOP_cell::opt_cell() { + + // Quxin added for DFT+U + if(INPUT.dft_plus_u) + { + dftu.init(ucell, ParaO); + } + LOOP_ions ions; ions.opt_ions(); diff --git a/ABACUS.develop/source/src_lcao/dftu.cpp b/ABACUS.develop/source/src_lcao/dftu.cpp index 521e70b74d..e392616a9c 100644 --- a/ABACUS.develop/source/src_lcao/dftu.cpp +++ b/ABACUS.develop/source/src_lcao/dftu.cpp @@ -33,22 +33,36 @@ DFTU::DFTU(){} DFTU::~DFTU(){} -void DFTU::init() +void DFTU::init( + UnitCell_pseudo &cell, // unitcell class + Parallel_Orbitals &po // parallel orbitals parameters +) { - TITLE("DFTU", "init()"); + TITLE("DFTU", "init"); + + // please, do not use 'INPUT' directly in the class! + // needs reconstructions in future + // global parameters, need to be removed in future + const int npol = NPOL; // number of polarization directions + const int nlocal = NLOCAL; // number of total local orbitals + const int nks = kv.nks; // number of k-points + const int nspin = NSPIN; // number of spins + const int dftu_type = INPUT.dftu_type; + const int double_counting = INPUT.double_counting; + - if(INPUT.dftu_type==1 && INPUT.double_counting==1) cal_type = 1; - else if(INPUT.dftu_type==1 && INPUT.double_counting==2) cal_type = 2; - else if(INPUT.dftu_type==2 && INPUT.double_counting==1) cal_type = 3; - else if(INPUT.dftu_type==2 && INPUT.double_counting==2) cal_type = 4; + if(dftu_type==1 && double_counting==1) cal_type = 1; + else if(dftu_type==1 && double_counting==2) cal_type = 2; + else if(dftu_type==2 && double_counting==1) cal_type = 3; + else if(dftu_type==2 && double_counting==2) cal_type = 4; else WARNING_QUIT("DFT+U", "Wrong parameter"); this->EU = 0.0; if(FORCE) { - this->force_dftu.resize(ucell.nat); - for(int ia=0; iaforce_dftu.resize(cell.nat); + for(int ia=0; iaforce_dftu.at(ia).resize(3, 0.0); } @@ -65,36 +79,37 @@ void DFTU::init() if(GAMMA_ONLY_LOCAL) { - this->pot_eff_gamma.resize(kv.nks); - for(int ik=0; ikpot_eff_gamma.resize(nks); + for(int ik=0; ikpot_eff_gamma.at(ik).resize(ParaO.nloc, 0.0); + this->pot_eff_gamma.at(ik).resize(po.nloc, 0.0); } } else { - this->Sm_k.resize(kv.nks); - this->pot_eff_k.resize(kv.nks); + this->Sm_k.resize(nks); + this->pot_eff_k.resize(nks); - for(int ik=0; ikSm_k.at(ik).resize(ParaO.nloc, ZERO); - this->pot_eff_k.at(ik).resize(ParaO.nloc, ZERO); + this->Sm_k.at(ik).resize(po.nloc, ZERO); + this->pot_eff_k.at(ik).resize(po.nloc, ZERO); } } - this->locale.resize(ucell.nat); - this->locale_save.resize(ucell.nat); - - this->iatlnmipol2iwt.resize(ucell.nat); - this->iat2it.resize(ucell.nat); - this->iwt2it.resize(NLOCAL); - this->iwt2iat.resize(NLOCAL); - this->iwt2l.resize(NLOCAL); - this->iwt2n.resize(NLOCAL); - this->iwt2m.resize(NLOCAL); - this->iwt2ipol.resize(NLOCAL); - for(int i=0; ilocale.resize(cell.nat); + this->locale_save.resize(cell.nat); + + this->iatlnmipol2iwt.resize(cell.nat); + this->iat2it.resize(cell.nat); + this->iwt2it.resize(nlocal); + this->iwt2iat.resize(nlocal); + this->iwt2l.resize(nlocal); + this->iwt2n.resize(nlocal); + this->iwt2m.resize(nlocal); + this->iwt2ipol.resize(nlocal); + + for(int i=0; iiwt2it.at(i) = -1; this->iwt2iat.at(i) = -1; @@ -104,26 +119,26 @@ void DFTU::init() this->iwt2ipol.at(i) = -1; } - for(int it=0; itiat2it.at(iat) = it; - locale.at(iat).resize(ucell.atoms[it].nwl+1); - locale_save.at(iat).resize(ucell.atoms[it].nwl+1); + locale.at(iat).resize(cell.atoms[it].nwl+1); + locale_save.at(iat).resize(cell.atoms[it].nwl+1); - for(int l=0; l<=ucell.atoms[it].nwl; l++) + for(int l=0; l<=cell.atoms[it].nwl; l++) { - const int N = ucell.atoms[it].l_nchi[l]; + const int N = cell.atoms[it].l_nchi[l]; locale.at(iat).at(l).resize(N); locale_save.at(iat).at(l).resize(N); for(int n=0; niatlnmipol2iwt.at(iat).resize(ucell.atoms[it].nwl+1); - for(int L=0; L<=ucell.atoms[it].nwl; L++) + this->iatlnmipol2iwt.at(iat).resize(cell.atoms[it].nwl+1); + for(int L=0; L<=cell.atoms[it].nwl; L++) { - this->iatlnmipol2iwt.at(iat).at(L).resize(ucell.atoms[it].l_nchi[L]); + this->iatlnmipol2iwt.at(iat).at(L).resize(cell.atoms[it].l_nchi[L]); - for(int n=0; niatlnmipol2iwt.at(iat).at(L).at(n).resize(2*L+1); for(int m=0; m<2*L+1; m++) { - this->iatlnmipol2iwt.at(iat).at(L).at(n).at(m).resize(NPOL); + this->iatlnmipol2iwt.at(iat).at(L).at(n).at(m).resize(npol); } } } - for(int iw=0; iwiatlnmipol2iwt.at(iat).at(l).at(n).at(m).at(ipol) = iwt; this->iwt2it.at(iwt) = it; @@ -185,14 +200,14 @@ void DFTU::init() this->Yukawa = INPUT.yukawa_potential; if(Yukawa) { - this->Fk.resize(INPUT.ntype); + this->Fk.resize(cell.ntype); - this->U_Yukawa.resize(INPUT.ntype); - this->J_Yukawa.resize(INPUT.ntype); + this->U_Yukawa.resize(cell.ntype); + this->J_Yukawa.resize(cell.ntype); - for(int it=0; itFk.at(it).resize(NL); this->U_Yukawa.at(it).resize(NL); @@ -200,7 +215,7 @@ void DFTU::init() for(int l=0; lFk.at(it).at(l).resize(N); for(int n=0; n> force_dftu; //force_dftu[iat][dim] vector> stress_dftu; @@ -69,4 +70,4 @@ class DFTU_RELAX : public DFTU_Yukawa }; -#endif \ No newline at end of file +#endif diff --git a/ABACUS.develop/source/src_pw/unitcell.h b/ABACUS.develop/source/src_pw/unitcell.h index 8ad8b122b1..02139b858a 100644 --- a/ABACUS.develop/source/src_pw/unitcell.h +++ b/ABACUS.develop/source/src_pw/unitcell.h @@ -8,7 +8,7 @@ #include "tools.h" #include "atom_spec.h" -// the "base class" of UnitCell_pseudo or UnitCell_epm. +// the "base class" of UnitCell_pseudo. // provide the basic information about unitcell. class UnitCell { From a91330038b1d8c462aa78dc7d00a70ec36061060 Mon Sep 17 00:00:00 2001 From: zdy Date: Sun, 14 Mar 2021 20:49:27 +0800 Subject: [PATCH 203/233] Rename class Make_Gaunt_Table to ORB_gaunt_table --- .../src_ri/make_gaunt_table-unittest.h | 8 +-- .../source/src_io/cal_r_overlap_R.h | 2 +- .../source/src_io/unk_overlap_lcao.h | 2 +- .../source/src_lcao/ORB_gaunt_table.cpp | 70 +++++++++---------- .../source/src_lcao/ORB_gaunt_table.h | 10 +-- .../source/src_lcao/ORB_gen_tables.h | 2 +- .../source/src_lcao/center2_orb-orb11.cpp | 2 +- .../source/src_lcao/center2_orb-orb11.h | 4 +- .../source/src_lcao/center2_orb-orb21.cpp | 2 +- .../source/src_lcao/center2_orb-orb21.h | 4 +- .../source/src_lcao/center2_orb-orb22.cpp | 2 +- .../source/src_lcao/center2_orb-orb22.h | 4 +- .../source/src_lcao/center2_orb-orb22_ccp.h | 2 +- .../source/src_pw/pseudopot_cell_vnl.h | 2 +- .../exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h | 2 +- .../source/src_ri/exx_abfs-matrix_orbs11.h | 2 +- .../source/src_ri/exx_abfs-matrix_orbs21.h | 2 +- .../source/src_ri/exx_abfs-matrix_orbs22.h | 2 +- ABACUS.develop/source/src_ri/exx_abfs.cpp | 8 +-- 19 files changed, 66 insertions(+), 66 deletions(-) diff --git a/ABACUS.develop/source/src_external/src_test/src_ri/make_gaunt_table-unittest.h b/ABACUS.develop/source/src_external/src_test/src_ri/make_gaunt_table-unittest.h index c1b0acfc09..1c2626d7cb 100644 --- a/ABACUS.develop/source/src_external/src_test/src_ri/make_gaunt_table-unittest.h +++ b/ABACUS.develop/source/src_external/src_test/src_ri/make_gaunt_table-unittest.h @@ -8,7 +8,7 @@ #include "src_lcao/ORB_gaunt_table.h" -static void cout_MGT ( const Make_Gaunt_Table & MGT, const int Lmax ) +static void cout_MGT ( const ORB_gaunt_table & MGT, const int Lmax ) { for( int LA=0; LA<=Lmax; ++LA ) { @@ -28,9 +28,9 @@ static void cout_MGT ( const Make_Gaunt_Table & MGT, const int Lmax ) <>>> orb1_orb2_R; diff --git a/ABACUS.develop/source/src_lcao/ORB_gaunt_table.cpp b/ABACUS.develop/source/src_lcao/ORB_gaunt_table.cpp index 5a3ce0c5b9..b36b373ff0 100644 --- a/ABACUS.develop/source/src_lcao/ORB_gaunt_table.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_gaunt_table.cpp @@ -1,15 +1,15 @@ #include "ORB_gaunt_table.h" -Make_Gaunt_Table::Make_Gaunt_Table(){} -Make_Gaunt_Table::~Make_Gaunt_Table(){} +ORB_gaunt_table::ORB_gaunt_table(){} +ORB_gaunt_table::~ORB_gaunt_table(){} -void Make_Gaunt_Table::init_Gaunt(const int &lmax) +void ORB_gaunt_table::init_Gaunt(const int &lmax) { //---------------------------------------------------------- // EXPLAIN : make table of Gaunt Coefficients // --------------------------------------------------------- - TITLE("Make_Gaunt_Table", "init_Gaunt"); - timer::tick("Make_Gaunt_Table", "init_Gaunt",'D'); + TITLE("ORB_gaunt_table", "init_Gaunt"); + timer::tick("ORB_gaunt_table", "init_Gaunt",'D'); const int nlm = (lmax * 2 + 1) * (lmax * 2 + 1); this->Gaunt_Coefficients.create(nlm, nlm, nlm); @@ -84,11 +84,11 @@ void Make_Gaunt_Table::init_Gaunt(const int &lmax) } } - timer::tick("Make_Gaunt_Table", "init_Gaunt",'D'); + timer::tick("ORB_gaunt_table", "init_Gaunt",'D'); return; } -double Make_Gaunt_Table::Cal_Gaunt_single +double ORB_gaunt_table::Cal_Gaunt_single ( const int &L1, const int &m1, const int &L2, const int &m2, @@ -97,7 +97,7 @@ double Make_Gaunt_Table::Cal_Gaunt_single const double &s2, const double &e2 ) { - timer::tick("Make_Gaunt_Table", "Cal_Gaunt_single"); + timer::tick("ORB_gaunt_table", "Cal_Gaunt_single"); if ((L1 - L2 - L) % 2 != 0) { return 0.0; @@ -131,19 +131,19 @@ double Make_Gaunt_Table::Cal_Gaunt_single } result *= ((e1 - s1) / 2) * ((e2 - s2) / 2); - timer::tick("Make_Gaunt_Table", "Cal_Gaunt_single"); + timer::tick("ORB_gaunt_table", "Cal_Gaunt_single"); return result; } -void Make_Gaunt_Table::init_Ylm_Gaunt +void ORB_gaunt_table::init_Ylm_Gaunt ( const int &lmax, const double &s1, const double &e1, const double &s2, const double &e2 ) { - TITLE("Make_Gaunt_Table", "init_Ylm_Gaunt"); - timer::tick("Make_Gaunt_Table", "inite_Ylm_Gaunt"); + TITLE("ORB_gaunt_table", "init_Ylm_Gaunt"); + timer::tick("ORB_gaunt_table", "inite_Ylm_Gaunt"); const int nlm = (2*lmax+1) * (2*lmax+1); @@ -178,11 +178,11 @@ void Make_Gaunt_Table::init_Ylm_Gaunt Mathzone::Ylm_Real(nlm, 256, &g_gaunt[0], this->Ylm_Gaunt); - timer::tick("Make_Gaunt_Table", "init_Ylm_Gaunt"); + timer::tick("ORB_gaunt_table", "init_Ylm_Gaunt"); return; } -int Make_Gaunt_Table::get_lm_index(const int l, const int m) +int ORB_gaunt_table::get_lm_index(const int l, const int m) { return l*l+m; } @@ -192,19 +192,19 @@ int Make_Gaunt_Table::get_lm_index(const int l, const int m) ***********************/ //total pointers -int Make_Gaunt_Table::P_EL(const int& L) +int ORB_gaunt_table::P_EL(const int& L) { return (L+1) * (L+2) * (L+3) * (L+4) / 24; } //effective pointers -int Make_Gaunt_Table::EP_EL(const int& L) +int ORB_gaunt_table::EP_EL(const int& L) { if(L % 2 == 0) return (L+2) * (L+4) * (3*L*L+14*L+24) / 192; else return (L+1) * (L+3) * (L+5) * (3*L+5) / 192; } -int Make_Gaunt_Table::index_func +int ORB_gaunt_table::index_func ( const int& l1, const int& l2, @@ -219,10 +219,10 @@ int Make_Gaunt_Table::index_func return aux1 + aux2 + aux3 + m3; } -void Make_Gaunt_Table::init_Gaunt_CH(const int& Lmax) +void ORB_gaunt_table::init_Gaunt_CH(const int& Lmax) { - TITLE("Make_Gaunt_Table","init_Gaunt_CH"); - timer::tick("Make_Gaunt_Table","init_Gaunt_CH",'D'); + TITLE("ORB_gaunt_table","init_Gaunt_CH"); + timer::tick("ORB_gaunt_table","init_Gaunt_CH",'D'); // assert(Lmax <= 6); // Peize Lin delete 2016-08-26. why? @@ -233,7 +233,7 @@ void Make_Gaunt_Table::init_Gaunt_CH(const int& Lmax) int Eff_Np = this->EP_EL(L); - double mem = Memory::record("Make_Gaunt_Table","Gaunt_CH",Eff_Np * 30, "double"); + double mem = Memory::record("ORB_gaunt_table","Gaunt_CH",Eff_Np * 30, "double"); OUT(ofs_running,"Gaunt_CH (Memory, unit: MB)",mem); int ic1 = 0; @@ -277,12 +277,12 @@ void Make_Gaunt_Table::init_Gaunt_CH(const int& Lmax) } } - timer::tick("Make_Gaunt_Table","init_Gaunt_CH",'D'); + timer::tick("ORB_gaunt_table","init_Gaunt_CH",'D'); return; } //using wigner 3j expression -double Make_Gaunt_Table::Calc_Gaunt_CH +double ORB_gaunt_table::Calc_Gaunt_CH ( const int& l1, const int& m1, @@ -292,8 +292,8 @@ double Make_Gaunt_Table::Calc_Gaunt_CH const int& m3 ) { -// TITLE("Make_Gaunt_Table","Calc_Gaunt_CH"); - timer::tick("Make_Gaunt_Table","Calc_Gaunt_CH"); +// TITLE("ORB_gaunt_table","Calc_Gaunt_CH"); + timer::tick("ORB_gaunt_table","Calc_Gaunt_CH"); double fac = sqrt((2*l1+1) * (2*l2+1) * (2*l3+1) / FOUR_PI); @@ -321,10 +321,10 @@ double Make_Gaunt_Table::Calc_Gaunt_CH return fac * pow(-1.0, l1-l2-m3) * triangle_f * aux1 * aux2; - timer::tick("Make_Gaunt_Table","Calc_Gaunt_CH"); + timer::tick("ORB_gaunt_table","Calc_Gaunt_CH"); } -double Make_Gaunt_Table::Get_Gaunt_CH +double ORB_gaunt_table::Get_Gaunt_CH ( const int& l1, const int& m1, @@ -385,7 +385,7 @@ double Make_Gaunt_Table::Get_Gaunt_CH //Input value //m1, m2, m3 are restricted within 0 to 2l+1 //and should be transformed first -double Make_Gaunt_Table::Get_Gaunt_SH +double ORB_gaunt_table::Get_Gaunt_SH ( const int& l1, const int& mm1, @@ -395,8 +395,8 @@ double Make_Gaunt_Table::Get_Gaunt_SH const int& mm3 ) { -// TITLE("Make_Gaunt_Table","Get_Gaunt_SH"); - timer::tick("Make_Gaunt_Table","Get_Gaunt_SH"); +// TITLE("ORB_gaunt_table","Get_Gaunt_SH"); + timer::tick("ORB_gaunt_table","Get_Gaunt_SH"); //Tranform M index int m1 = Index_M(mm1); @@ -463,11 +463,11 @@ double Make_Gaunt_Table::Get_Gaunt_SH else return 0.0; } - timer::tick("Make_Gaunt_Table","Get_Gaunt_SH"); + timer::tick("ORB_gaunt_table","Get_Gaunt_SH"); } /* // Peize Lin delete 2016-08-26 -void Make_Gaunt_Table::ZEROS() +void ORB_gaunt_table::ZEROS() { for(int ir = 0; ir < 5000; ir++) { @@ -480,7 +480,7 @@ void Make_Gaunt_Table::ZEROS() } */ -double Make_Gaunt_Table::Fact(const int& n) +double ORB_gaunt_table::Fact(const int& n) { double val = 1.0; for(int i = 1; i <= n; i++) @@ -490,7 +490,7 @@ double Make_Gaunt_Table::Fact(const int& n) return val; } -void Make_Gaunt_Table::Swap(int& l1, int& m1, int& l2, int & m2) +void ORB_gaunt_table::Swap(int& l1, int& m1, int& l2, int & m2) { int tmp1, tmp2; if(l1 >= l2) return; @@ -508,7 +508,7 @@ void Make_Gaunt_Table::Swap(int& l1, int& m1, int& l2, int & m2) return; } -int Make_Gaunt_Table::Index_M(const int& m) +int ORB_gaunt_table::Index_M(const int& m) { if(m % 2 == 0) return (- m / 2); else return ((m+1) / 2); diff --git a/ABACUS.develop/source/src_lcao/ORB_gaunt_table.h b/ABACUS.develop/source/src_lcao/ORB_gaunt_table.h index 46fb98d232..aa09f9c51e 100644 --- a/ABACUS.develop/source/src_lcao/ORB_gaunt_table.h +++ b/ABACUS.develop/source/src_lcao/ORB_gaunt_table.h @@ -2,18 +2,18 @@ //AUTHOR : Mohan //DATE : 2009-04-23 //========================================================= -#ifndef MAKE_GAUNT_TABLE_H -#define MAKE_GAUNT_TABLE_H +#ifndef ORB_GAUNT_TABLE_H +#define ORB_GAUNT_TABLE_H #include "../src_pw/tools.h" #include -class Make_Gaunt_Table +class ORB_gaunt_table { public: - Make_Gaunt_Table(); - ~Make_Gaunt_Table(); + ORB_gaunt_table(); + ~ORB_gaunt_table(); /*************************************** * Method 2 diff --git a/ABACUS.develop/source/src_lcao/ORB_gen_tables.h b/ABACUS.develop/source/src_lcao/ORB_gen_tables.h index 57d13f138e..b19bd578fe 100644 --- a/ABACUS.develop/source/src_lcao/ORB_gen_tables.h +++ b/ABACUS.develop/source/src_lcao/ORB_gen_tables.h @@ -75,7 +75,7 @@ class ORB_gen_tables private: - Make_Gaunt_Table MGT; + ORB_gaunt_table MGT; double get_distance(const Vector3 &R1, const Vector3 &R2)const; diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb11.cpp b/ABACUS.develop/source/src_lcao/center2_orb-orb11.cpp index 0a362208fa..85cbf93408 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb11.cpp +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb11.cpp @@ -14,7 +14,7 @@ Center2_Orb::Orb11::Orb11( const Numerical_Orbital_Lm &nA_in, const Numerical_Orbital_Lm &nB_in, const ORB_table_phi &MOT_in, - const Make_Gaunt_Table &MGT_in + const ORB_gaunt_table &MGT_in ) :nA(nA_in), nB(nB_in), diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb11.h b/ABACUS.develop/source/src_lcao/center2_orb-orb11.h index d6178ee038..40c7529c32 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb11.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb11.h @@ -28,7 +28,7 @@ class Center2_Orb::Orb11 const Numerical_Orbital_Lm &nA_in, const Numerical_Orbital_Lm &nB_in, const ORB_table_phi &MOT_in, - const Make_Gaunt_Table &MGT_in ); + const ORB_gaunt_table &MGT_in ); void init_radial_table(void); @@ -44,7 +44,7 @@ class Center2_Orb::Orb11 const Numerical_Orbital_Lm &nB; const ORB_table_phi &MOT; - const Make_Gaunt_Table &MGT; + const ORB_gaunt_table &MGT; map> Table_r; // unit: Bohr/MOT.dr map> Table_dr; diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb21.cpp b/ABACUS.develop/source/src_lcao/center2_orb-orb21.cpp index e6c0d7ddff..708ae463a7 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb21.cpp +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb21.cpp @@ -15,7 +15,7 @@ Center2_Orb::Orb21::Orb21( const Numerical_Orbital_Lm &nA2_in, const Numerical_Orbital_Lm &nB_in, const ORB_table_phi &MOT_in, - const Make_Gaunt_Table &MGT_in + const ORB_gaunt_table &MGT_in ) :nA1(nA1_in), nA2(nA2_in), diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb21.h b/ABACUS.develop/source/src_lcao/center2_orb-orb21.h index 6c6e34ae75..ad21824748 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb21.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb21.h @@ -31,7 +31,7 @@ class Center2_Orb::Orb21 const Numerical_Orbital_Lm &nA2_in, const Numerical_Orbital_Lm &nB_in, const ORB_table_phi &MOT_in, - const Make_Gaunt_Table &MGT_in ); + const ORB_gaunt_table &MGT_in ); void init_radial_table(); @@ -48,7 +48,7 @@ class Center2_Orb::Orb21 const Numerical_Orbital_Lm &nB; const ORB_table_phi &MOT; - const Make_Gaunt_Table &MGT; + const ORB_gaunt_table &MGT; map nA; map orb11s; diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb22.cpp b/ABACUS.develop/source/src_lcao/center2_orb-orb22.cpp index e689163f75..f4839f27eb 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb22.cpp +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb22.cpp @@ -11,7 +11,7 @@ Center2_Orb::Orb22::Orb22( const Numerical_Orbital_Lm &nB1_in, const Numerical_Orbital_Lm &nB2_in, const ORB_table_phi &MOT_in, - const Make_Gaunt_Table &MGT_in + const ORB_gaunt_table &MGT_in ) :nA1(nA1_in), nA2(nA2_in), diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb22.h b/ABACUS.develop/source/src_lcao/center2_orb-orb22.h index 9c9b39cafe..49e9bdbbdb 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb22.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb22.h @@ -30,7 +30,7 @@ class Center2_Orb::Orb22 const Numerical_Orbital_Lm &nB1_in, const Numerical_Orbital_Lm &nB2_in, const ORB_table_phi &MOT_in, - const Make_Gaunt_Table &MGT_in ); + const ORB_gaunt_table &MGT_in ); void init_radial_table(); void init_radial_table( const set &radials ); // unit: Bohr/MOT.dr double cal_overlap( @@ -44,7 +44,7 @@ class Center2_Orb::Orb22 const Numerical_Orbital_Lm &nB2; const ORB_table_phi &MOT; - const Make_Gaunt_Table &MGT; + const ORB_gaunt_table &MGT; map nB; map orb21s; diff --git a/ABACUS.develop/source/src_lcao/center2_orb-orb22_ccp.h b/ABACUS.develop/source/src_lcao/center2_orb-orb22_ccp.h index 3f80716336..c7cf495b01 100644 --- a/ABACUS.develop/source/src_lcao/center2_orb-orb22_ccp.h +++ b/ABACUS.develop/source/src_lcao/center2_orb-orb22_ccp.h @@ -13,7 +13,7 @@ class Center2_Orb::Orb22_Ccp: public Center2_Orb::Orb22 const Numerical_Orbital_Lm &nB1_in, const Numerical_Orbital_Lm &nB2_in, const ORB_table_phi &MOT_in, - const Make_Gaunt_Table &MGT_in ) + const ORB_gaunt_table &MGT_in ) : Orb22( nA1_in, nA2_in, nB1_in, nB2_in, MOT_in, MGT_in ){} void init_radial_table(); diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h index c691617553..72318af3f1 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h +++ b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h @@ -90,7 +90,7 @@ class pseudopot_cell_vnl: public pseudopot_cell_vl double CG(int l1, int m1, int l2, int m2, int L, int M); void print_vnl(ofstream &ofs); - Make_Gaunt_Table MGT; + ORB_gaunt_table MGT; }; #endif // PSEUDOPOT_CELL_VNL_H diff --git a/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h b/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h index 7f6c40fa46..e3ff024e8f 100644 --- a/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-matrix_lcaoslcaos_lcaoslcaos.h @@ -42,7 +42,7 @@ class Exx_Abfs::Matrix_Lcaoslcaos_Lcaoslcaos private: ORB_table_phi MOT; - Make_Gaunt_Table MGT; + ORB_gaunt_table MGT; map>> @@ -639,7 +639,7 @@ cout<<"E"<>>> &&ms_abfs_abfs = m_abfs_abfs.cal_overlap_matrix( index_abfs, index_abfs ); ofs_ms("ms_abfs_abfs",ms_abfs_abfs); @@ -661,7 +661,7 @@ ofs_ms("ms_C",ms_C); cout<<"H"< Date: Sun, 14 Mar 2021 21:16:48 +0800 Subject: [PATCH 204/233] add pw.strucFac as a new variable in pot.init_pot --- ABACUS.develop/source/run_lcao.cpp | 20 +---------- ABACUS.develop/source/run_pw.cpp | 2 +- .../source/src_ions/variable_cell.cpp | 2 +- .../source/src_lcao/FORCE_gamma_vl.cpp | 5 +-- ABACUS.develop/source/src_lcao/FORCE_k.cpp | 2 +- ABACUS.develop/source/src_lcao/LOOP_cell.cpp | 21 +++++++++++- ABACUS.develop/source/src_lcao/LOOP_elec.cpp | 2 +- ABACUS.develop/source/src_lcao/LOOP_ions.cpp | 8 ++--- ABACUS.develop/source/src_lcao/run_md.cpp | 10 +++--- ABACUS.develop/source/src_pw/ions.cpp | 10 +++--- ABACUS.develop/source/src_pw/potential.cpp | 33 ++++++++++++++----- ABACUS.develop/source/src_pw/potential.h | 15 +++++++-- 12 files changed, 79 insertions(+), 51 deletions(-) diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index 03bfc6f437..7d857ec910 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -115,7 +115,7 @@ void Run_lcao::lcao_line(void) // Initialize the sum of all local potentials. // if ion_step==0, read in/initialize the potentials int ion_step=0; - pot.init_pot(ion_step); + pot.init_pot(ion_step, pw.strucFac); if(CALCULATION=="md") @@ -125,24 +125,6 @@ void Run_lcao::lcao_line(void) } else { - // Peize Lin 2016-12-03 - if (CALCULATION=="scf" || CALCULATION=="relax" || CALCULATION=="cell-relax") - { - switch(exx_global.info.hybrid_type) - { - case Exx_Global::Hybrid_Type::HF: - case Exx_Global::Hybrid_Type::PBE0: - case Exx_Global::Hybrid_Type::HSE: - exx_lcao.init(); - break; - case Exx_Global::Hybrid_Type::No: - case Exx_Global::Hybrid_Type::Generate_Matrix: - break; - default: - throw invalid_argument(TO_STRING(__FILE__)+TO_STRING(__LINE__)); - } - } - LOOP_cell lc; lc.opt_cell(); diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp index bf4031e8f8..0e017a67fb 100644 --- a/ABACUS.develop/source/run_pw.cpp +++ b/ABACUS.develop/source/run_pw.cpp @@ -110,7 +110,7 @@ void Run_pw::plane_wave_line(void) //========================================================= // calculate the total local pseudopotential in real space //========================================================= - pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs + pot.init_pot(0, pw.strucFac);//atomic_rho, v_of_rho, set_vrs pot.newd();//once DONE(ofs_running,"INIT POTENTIAL"); diff --git a/ABACUS.develop/source/src_ions/variable_cell.cpp b/ABACUS.develop/source/src_ions/variable_cell.cpp index 3a4d551da7..95d0a509b1 100644 --- a/ABACUS.develop/source/src_ions/variable_cell.cpp +++ b/ABACUS.develop/source/src_ions/variable_cell.cpp @@ -161,7 +161,7 @@ void Variable_Cell::final_calculation_after_vc(void) //========================================================= // calculate the total local pseudopotential in real space //========================================================= - pot.init_pot(0);//atomic_rho, v_of_rho, set_vrs + pot.init_pot(0, pw.strucFac);//atomic_rho, v_of_rho, set_vrs if(BASIS_TYPE=="pw") pot.newd();//once DONE(ofs_running,"INIT POTENTIAL"); diff --git a/ABACUS.develop/source/src_lcao/FORCE_gamma_vl.cpp b/ABACUS.develop/source/src_lcao/FORCE_gamma_vl.cpp index 9d0bab1376..4dbedb62ff 100644 --- a/ABACUS.develop/source/src_lcao/FORCE_gamma_vl.cpp +++ b/ABACUS.develop/source/src_lcao/FORCE_gamma_vl.cpp @@ -47,8 +47,9 @@ void Force_LCAO_gamma::cal_fvl_dphi( //calculate dVL //calculate + // mohan add 2021, needs reconstruction!!! int istep = 1; - pot.init_pot(istep); + pot.init_pot(istep, pw.strucFac); for(int is=0; is int istep = 1; - pot.init_pot(istep); + pot.init_pot(istep, pw.strucFac); for(int is=0; isset_local(this->vltot); + this->set_local( + this->vltot, // 3D local pseudopotentials + ucell.ntype, + pw.ngmc, + ppcell.vloc, + pw.ig2ngg, + sf // structure factors + ); // zhengdy-soc, pauli matrix, just index 0 has vlocal term int nspin0=NSPIN; @@ -211,20 +221,27 @@ void potential::init_pot(const int &istep) //========================================================== // This routine computes the local potential in real space //========================================================== -void potential::set_local(double* vl_pseudo)const +void potential::set_local( + double* vl_pseudo, // store the local pseudopotential + const int &ntype, // number of atom types + const int &ngmc, // number of |g|, g is plane wave + matrix &vloc, // local pseduopotentials + int* ig2ngg, // ig2ngg + ComplexMatrix &sf // structure factors +)const { TITLE("potential","set_local"); timer::tick("potential","set_local"); - complex *vg = new complex[pw.ngmc]; + complex *vg = new complex[ngmc]; - ZEROS( vg, pw.ngmc ); + ZEROS( vg, ngmc ); - for (int it=0; it Date: Sun, 14 Mar 2021 21:48:06 +0800 Subject: [PATCH 205/233] transpose should be added. --- ABACUS.develop/source/src_pw/hamilt_pw.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ABACUS.develop/source/src_pw/hamilt_pw.cpp b/ABACUS.develop/source/src_pw/hamilt_pw.cpp index 31a78be605..02afc33521 100644 --- a/ABACUS.develop/source/src_pw/hamilt_pw.cpp +++ b/ABACUS.develop/source/src_pw/hamilt_pw.cpp @@ -137,7 +137,9 @@ void Hamilt_PW::cinitcgg( char trans1 = 'C'; char trans2 = 'N'; zgemm_(&trans1,&trans2,&nstart,&nstart,&dmin,&ONE,psi.c,&dmax,aux,&dmax,&ZERO,hc.c,&nstart); + hc=transpose(hc,false); zgemm_(&trans1,&trans2,&nstart,&nstart,&dmin,&ONE,psi.c,&dmax,psi.c,&dmax,&ZERO,sc.c,&nstart); + sc=transpose(sc,false); //After psis are strictly normalized, we should use this part. //for(int m=1;m Date: Sun, 14 Mar 2021 22:19:55 +0800 Subject: [PATCH 206/233] add notes in diago_cg --- ABACUS.develop/source/src_pw/diago_cg.cpp | 34 ++++++++++------------- ABACUS.develop/source/src_pw/hamilt.cpp | 30 ++++++-------------- 2 files changed, 22 insertions(+), 42 deletions(-) diff --git a/ABACUS.develop/source/src_pw/diago_cg.cpp b/ABACUS.develop/source/src_pw/diago_cg.cpp index 9e8015561b..8ac9eaa522 100644 --- a/ABACUS.develop/source/src_pw/diago_cg.cpp +++ b/ABACUS.develop/source/src_pw/diago_cg.cpp @@ -66,15 +66,9 @@ void Diago_CG::diag hm.hpw.s_1psi(dim, phi_m, sphi); // sphi = S|psi(m)> this->schmit_orth(dim, m, phi, sphi, phi_m); -// cout<<"\n before h_1psi sphi"; -// for(int i=0; iddot_real(dim, phi_m, hphi ); -// cout<<"\n\n m="< -// if(test_cg>2) cout<<"\n\n m="< *hpsi, const complex *spsi, @@ -193,8 +185,6 @@ void Diago_CG::calculate_gradient( const double es = this->ddot_real( dim, spsi, ppsi); const double lambda = eh / es; -// OUT("lambda",lambda); - // Update g! for (int i=0; i *g, complex *sg, complex *lagrange, - const ComplexMatrix &eigenfunction, const int m) +void Diago_CG::orthogonal_gradient( + const int &dim, + complex *g, + complex *sg, + complex *lagrange, + const ComplexMatrix &eigenfunction, + const int m) { if (test_cg==1) TITLE("Diago_CG","orthogonal_gradient"); //timer::tick("Diago_CG","orth_grad"); @@ -319,6 +313,7 @@ void Diago_CG::calculate_gamma_cg( return; } + bool Diago_CG::update_psi( const int dim, double &cg_norm, @@ -336,6 +331,7 @@ bool Diago_CG::update_psi( //timer::tick("Diago_CG","update"); hm.hpw.h_1psi(dim, cg, hcg, scg); cg_norm = sqrt( this->ddot_real(dim, cg, scg) ); + if (cg_norm < 1.0e-10 ) return 1; const double a0 = this->ddot_real(dim, psi_m, hcg) * 2.0 / cg_norm; @@ -424,7 +420,6 @@ void Diago_CG::schmit_orth Parallel_Reduce::reduce_complex_double_pool( lagrange, m+1 ); double psi_norm = lagrange[m].real(); -// cout << "\n psi norm1 = " << psi_norm; for (int j = 0; j < m; j++) { @@ -432,7 +427,6 @@ void Diago_CG::schmit_orth { psi_m[ig] -= lagrange[j] * psi(j, ig); } -// cout << "\n j = " << j << " lagrange norm = " << ( conj(lagrange[j]) * lagrange[j] ).real(); psi_norm -= ( conj(lagrange[j]) * lagrange[j] ).real(); } @@ -442,10 +436,6 @@ void Diago_CG::schmit_orth for(int j=0; j<=m; ++j) { cout << "\n j = " << j << " lagrange norm = " << ( conj(lagrange[j]) * lagrange[j] ).real(); -// for(int ig=0; ig Diago_CG::ddot return result; } // end of ddot + // this return complex Diago_CG::ddot ( @@ -519,6 +511,7 @@ complex Diago_CG::ddot return result; } // end of ddot + // this return complex Diago_CG::ddot ( @@ -537,5 +530,6 @@ complex Diago_CG::ddot result += conj( psi_L(m,i) ) * psi_R(n,i) ; } Parallel_Reduce::reduce_complex_double_pool( result ); + return result; } // end of ddot diff --git a/ABACUS.develop/source/src_pw/hamilt.cpp b/ABACUS.develop/source/src_pw/hamilt.cpp index d26b190acd..9821aba060 100644 --- a/ABACUS.develop/source/src_pw/hamilt.cpp +++ b/ABACUS.develop/source/src_pw/hamilt.cpp @@ -88,10 +88,14 @@ void Hamilt::diago( Diago_CG cg; bool reorder = true; - if(NPOL==1) cg.diag(wf.evc[ik0], wf.ekb[ik], kv.ngk[ik], + if(NPOL==1) + { + cg.diag(wf.evc[ik0], wf.ekb[ik], kv.ngk[ik], NBANDS, precondition, ETHR, DIAGO_CG_MAXITER, reorder, notconv, avg); - else{ + } + else + { cg.diag(wf.evc[ik0], wf.ekb[ik], wf.npwx*NPOL, NBANDS, precondition, ETHR, DIAGO_CG_MAXITER, reorder, notconv, avg); @@ -138,6 +142,7 @@ void Hamilt::diago( return; } + bool Hamilt::test_exit_cond(const int &ntry, const int ¬conv) { //================================================================ @@ -203,7 +208,6 @@ void Hamilt::cdiaghg( // On output both matrix are unchanged // LAPACK version - uses both ZHEGV and ZHEGVX //===================================================================== -// BLOCK_HERE("cdiaghg"); int lwork; //======================================== @@ -213,20 +217,14 @@ void Hamilt::cdiaghg( ComplexMatrix sdum(nstart, ldh); ComplexMatrix hdum; -// cout << "\n nstart = " << nstart << endl; -// cout << "\n ldh = " << ldh << endl; -// cout << "\n nbands = " << nbands << endl; sdum = sc; const bool all_eigenvalues = (nstart == nbands); -// cout << "\n all eigenvalue = " << all_eigenvalues << endl; - // cout<<"\n dimension = "< 1 ); assert( order*nband < npw ); @@ -69,12 +69,15 @@ void Diago_David::diag ZEROS( convflag, nband ); for ( int m = 0 ; m < nband; m++ ) unconv[m] = m; - timer::tick("Diago_David","first"); + timer::tick("Diago_David","first",'G'); // orthogonalise the initial trial psi(0~nband-1) for (int m = 0; m < nband; m++) { // psi_m = psi(m) - for ( int ig = 0; ig < npw; ig++ ) psi_m[ig] = psi(m,ig); + for ( int ig = 0; ig < npw; ig++ ) + { + psi_m[ig] = psi(m,ig); + } this->SchmitOrth(npw, nband, m, basis, psi_m, spsi); @@ -96,30 +99,35 @@ void Diago_David::diag this->diag_zhegvx( nbase, nband, hc, sc, nbase_x, e, vc ); - for ( int m = 0; m < nband; m++ ) en[m] = e[m]; + for ( int m = 0; m < nband; m++ ) + { + en[m] = e[m]; + } - timer::tick("Diago_David","first"); + timer::tick("Diago_David","first",'G'); int dav_iter = 0; do { dav_iter++; - this->cal_grad( npw, nbase, notconv, basis, hp, sp, vc, unconv, precondition, e, hpsi, spsi, ppsi, respsi ); + this->cal_grad( npw, nbase, notconv, basis, hp, sp, vc, + unconv, precondition, e, hpsi, spsi, ppsi, respsi ); this->cal_elem( npw, nbase, notconv, basis, hp, sp, hc, sc ); this->diag_zhegvx( nbase, nband, hc, sc, nbase_x, e, vc ); // check convergence and update eigenvalues - timer::tick("Diago_David","check_update"); + timer::tick("Diago_David","check_update",'G'); notconv = 0; for ( int m = 0 ; m < nband; m++ ) { convflag[m] = ( abs( e[m] - en[m] ) < eps ); - if ( !convflag[m] ) { + if ( !convflag[m] ) + { unconv[notconv] = m; notconv++; } @@ -127,7 +135,7 @@ void Diago_David::diag en[m] = e[m]; } - timer::tick("Diago_David","check_update"); + timer::tick("Diago_David","check_update",'G'); /* // test_david==2 cout info of each iteration if( test_david==2 ) @@ -138,7 +146,7 @@ void Diago_David::diag */ if ( !notconv || ( nbase + notconv > nbase_x) || (dav_iter == maxiter) ) { - timer::tick("Diago_David","last"); + timer::tick("Diago_David","last",'G'); // updata eigenvectors of Hamiltonian psi.zero_out(); @@ -146,7 +154,10 @@ void Diago_David::diag { for ( int j = 0; j < nbase; j++ ) { - for ( int ig = 0; ig < npw; ig++ ) psi(m,ig) += vc(j,m) * basis(j,ig); + for ( int ig = 0; ig < npw; ig++ ) + { + psi(m,ig) += vc(j,m) * basis(j,ig); + } } } @@ -154,7 +165,7 @@ void Diago_David::diag { // overall convergence or last iteration: exit the iteration - timer::tick("Diago_David","last"); + timer::tick("Diago_David","last",'G'); break; } else @@ -164,7 +175,7 @@ void Diago_David::diag // estimate of the eigenvectors and set the basis dimension to N; this->refresh( npw, nband, nbase, en, psi, basis, hp, sp, hc, sc, vc ); - timer::tick("Diago_David","last"); + timer::tick("Diago_David","last",'G'); } }// end of if @@ -191,7 +202,7 @@ void Diago_David::diag delete[] convflag; delete[] unconv; - timer::tick("Diago_David", "diag"); + timer::tick("Diago_David", "diag", 'G'); return; } @@ -214,7 +225,7 @@ void Diago_David::cal_grad ) { if ( test_david ==1 ) TITLE("DIAGO_DAVID","cal_grad"); - timer::tick("Diago_David","cal_grad"); + timer::tick("Diago_David","cal_grad", 'G'); // expand the reduced basis set with the new basis vectors P|R(psi)>... // in which psi are the last eigenvectors @@ -230,7 +241,10 @@ void Diago_David::cal_grad } } - for ( int ig = 0; ig < npw; ig++ ) ppsi[ig] = respsi[ig] / precondition[ig] ; + for ( int ig = 0; ig < npw; ig++ ) + { + ppsi[ig] = respsi[ig] / precondition[ig] ; + } /* double ppsi_norm = Diago_CG::ddot_real( npw, ppsi, ppsi); double rpsi_norm = Diago_CG::ddot_real( npw, respsi, respsi); @@ -249,7 +263,7 @@ void Diago_David::cal_grad } } - timer::tick("Diago_David","cal_grad"); + timer::tick("Diago_David","cal_grad",'G'); return; } @@ -266,7 +280,7 @@ void Diago_David::cal_elem ) { if ( test_david ==1 ) TITLE("DIAGO_DAVID","cal_elem"); - timer::tick("Diago_David","cal_elem"); + timer::tick("Diago_David","cal_elem",'G'); // updat the reduced Hamiltonian int offset_h = nbase * hc.nr ; @@ -301,7 +315,7 @@ void Diago_David::cal_elem } */ nbase += notconv; - timer::tick("Diago_David","cal_elem"); + timer::tick("Diago_David","cal_elem",'G'); return; } @@ -330,7 +344,7 @@ void Diago_David::diag_zhegvx ) { // TITLE("DIAGO_DAVID","diag_zhegvx"); - timer::tick("Diago_David","diag_zhegvx"); + timer::tick("Diago_David","diag_zhegvx",'G'); assert( ldh >= max(1,n) ); int lwork ; int info = 0; @@ -382,7 +396,7 @@ void Diago_David::diag_zhegvx delete[] rwork; delete[] iwork; delete[] ifail; - timer::tick("Diago_David","diag_zhegvx"); + timer::tick("Diago_David","diag_zhegvx",'G'); return; } @@ -402,7 +416,7 @@ void Diago_David::refresh ) { if ( test_david==1 ) TITLE("Diago_David","refresh"); - timer::tick("Diago_David","refresh"); + timer::tick("Diago_David","refresh",'G'); // update hp,sp basis.zero_out(); @@ -445,7 +459,7 @@ void Diago_David::refresh vc(i,i) = ONE; } - timer::tick("Diago_David","refresh"); + timer::tick("Diago_David","refresh",'G'); return; } @@ -461,7 +475,7 @@ void Diago_David::cal_err complex* respsi ) { - timer::tick("Diago_David","cal_err"); + timer::tick("Diago_David","cal_err",'G'); double *err = new double[nband]; assert(err != 0); @@ -488,7 +502,7 @@ void Diago_David::cal_err } delete[] err; - timer::tick("Diago_David","cal_err"); + timer::tick("Diago_David","cal_err",'G'); return; } @@ -503,7 +517,7 @@ void Diago_David::SchmitOrth ) { // if(test_david == 1) TITLE("Diago_David","SchmitOrth"); - timer::tick("Diago_David","SchmitOrth"); + timer::tick("Diago_David","SchmitOrth",'G'); // orthogonalize starting eigenfunction to those already calculated // psi_m orthogonalize to psi(0) ~ psi(m-1) @@ -528,7 +542,10 @@ void Diago_David::SchmitOrth } // lagrange[j] = Diago_CG::ddot( npw, psi, j, spsi ); } - for (int ig = 0; ig Date: Mon, 15 Mar 2021 00:55:31 +0800 Subject: [PATCH 208/233] add parameter in init_vloc --- ABACUS.develop/source/run_lcao.cpp | 2 +- ABACUS.develop/source/run_pw.cpp | 2 +- ABACUS.develop/source/src_ions/variable_cell.cpp | 4 ++-- ABACUS.develop/source/src_pw/pseudopot_cell_vl.cpp | 12 ++++++------ ABACUS.develop/source/src_pw/pseudopot_cell_vl.h | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index 7d857ec910..61abd1c08d 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -110,7 +110,7 @@ void Run_lcao::lcao_line(void) // Initialize the local part of // NC pseudopotentials - ppcell.init_vloc(); + ppcell.init_vloc(pw.nggm); // Initialize the sum of all local potentials. // if ion_step==0, read in/initialize the potentials diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp index 0e017a67fb..065cde839c 100644 --- a/ABACUS.develop/source/run_pw.cpp +++ b/ABACUS.develop/source/run_pw.cpp @@ -98,7 +98,7 @@ void Run_pw::plane_wave_line(void) //================================= // initalize local pseudopotential //================================= - ppcell.init_vloc(); + ppcell.init_vloc(pw.nggm); DONE(ofs_running,"LOCAL POTENTIAL"); //====================================== diff --git a/ABACUS.develop/source/src_ions/variable_cell.cpp b/ABACUS.develop/source/src_ions/variable_cell.cpp index 95d0a509b1..1be1b81a0d 100644 --- a/ABACUS.develop/source/src_ions/variable_cell.cpp +++ b/ABACUS.develop/source/src_ions/variable_cell.cpp @@ -46,7 +46,7 @@ void Variable_Cell::init_after_vc(void) //================================= // initalize local pseudopotential //================================= - ppcell.init_vloc(); + ppcell.init_vloc(pw.nggm); DONE(ofs_running,"LOCAL POTENTIAL"); //====================================== @@ -148,7 +148,7 @@ void Variable_Cell::final_calculation_after_vc(void) //================================= // initalize local pseudopotential //================================= - ppcell.init_vloc(); + ppcell.init_vloc(pw.nggm); DONE(ofs_running,"LOCAL POTENTIAL"); //====================================== // Initalize non local pseudopotential diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_vl.cpp b/ABACUS.develop/source/src_pw/pseudopot_cell_vl.cpp index 8b2d4b135f..9cd011ff92 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_vl.cpp +++ b/ABACUS.develop/source/src_pw/pseudopot_cell_vl.cpp @@ -16,17 +16,16 @@ pseudopot_cell_vl::~pseudopot_cell_vl() } -void pseudopot_cell_vl::init_vloc(void) +void pseudopot_cell_vl::init_vloc(const int &nggm) { TITLE("pseudopot_cell_vl","init_vloc"); // This routine computes the fourier coefficient of the local // potential vloc(ig,it) for each type of atom - if(test_pp > 0) TITLE("pseudopot_cell_vl","init_vloc"); timer::tick("ppcell_vl","init_vloc",'C'); - double *vloc1d = new double[pw.nggm]; - ZEROS(vloc1d, pw.nggm); + double *vloc1d = new double[nggm]; + ZEROS(vloc1d, nggm); this->allocate(); @@ -34,7 +33,7 @@ void pseudopot_cell_vl::init_vloc(void) { const Atom* atom = &ucell.atoms[it]; - ZEROS(vloc1d, pw.nggm); + ZEROS(vloc1d, nggm); this->zp[it] = atom->zv; @@ -133,6 +132,7 @@ void pseudopot_cell_vl::vloc_of_g( ZEROS(aux, msh); ZEROS(aux1, msh); + // for tests /* for(ir=0; irconv_elec = false;//mohan add 2008-05-25 - clock_t start,finish; - double duration = 0.0; // mohan add 2010/3/25 // output the charge mixing data : @@ -156,7 +154,8 @@ void Electrons::self_consistent(const int &istep) else CHR.set_new_e_iteration(false); // record the start time. - start=std::clock(); + // the clock is not accurate, needs to be fixed 2021-03-15 mohan + clock_t start=std::clock(); //(1) set converged threshold, // automatically updated during self consistency. @@ -352,8 +351,9 @@ void Electrons::self_consistent(const int &istep) //print_eigenvalue(ofs_running); en.calculate_etot(); - finish=clock(); - duration = (double)(finish - start) / CLOCKS_PER_SEC; + // the clock is not accurate, needs to be fixed 2021-03-15 mohan + clock_t finish=clock(); + double duration = (double)(finish - start) / CLOCKS_PER_SEC; en.print_etot(conv_elec, istep, iter, dr2, duration, ETHR, avg_iter); diff --git a/ABACUS.develop/source/src_pw/energy.cpp b/ABACUS.develop/source/src_pw/energy.cpp index 93fb5a3915..8e77ff7f89 100644 --- a/ABACUS.develop/source/src_pw/energy.cpp +++ b/ABACUS.develop/source/src_pw/energy.cpp @@ -102,9 +102,15 @@ void energy::calculate_etot(void) return; } -void energy::print_etot(const bool converged, const int &istep, const int &iter_in, -const double &dr2, const double &duration, const double ðr, const double &avg_iter, -bool print) +void energy::print_etot( + const bool converged, + const int &istep, + const int &iter_in, + const double &dr2, + const double &duration, + const double ðr, + const double &avg_iter, + bool print) { TITLE("energy","print_etot"); this->iter = iter_in; @@ -116,7 +122,6 @@ bool print) if(OUT_LEVEL != "m") //xiaohui add "OUT_LEVEL", 2015-09-16 { - //if(!LOCAL_BASIS)OUT(ofs_running,"Error Threshold",ethr); xiaohui modify 2013-09-02 if(BASIS_TYPE=="pw")OUT(ofs_running,"Error Threshold",ethr); //xiaohui add 2013-09-02 if( this->printe>0 && ( (iter+1) % this->printe == 0 || converged || iter == NITER) ) @@ -171,19 +176,33 @@ bool print) //xiaohui add 2013-09-02, Peize Lin update 2020.11.14 string label; if(KS_SOLVER=="cg") + { label = "CG"; + } else if (KS_SOLVER=="lapack") + { label = "LA"; + } else if(KS_SOLVER=="hpseps") + { label = "HP"; + } else if(KS_SOLVER=="genelpa") + { label = "GE"; + } else if(KS_SOLVER=="dav") + { label = "DA"; + } else if(KS_SOLVER=="scalapack_gvx") + { label = "GV"; + } else + { WARNING_QUIT("Energy","print_etot"); + } ss << label << iter; //xiaohui add 2013-09-02 diff --git a/ABACUS.develop/source/src_pw/forces.cpp b/ABACUS.develop/source/src_pw/forces.cpp index da0fd4b926..2b944bf137 100644 --- a/ABACUS.develop/source/src_pw/forces.cpp +++ b/ABACUS.develop/source/src_pw/forces.cpp @@ -167,6 +167,7 @@ void Forces::init(matrix& force) if(EFIELD) Forces::print("EFIELD FORCE (Ry/Bohr)", force_e); } +/* Forces::print(" TOTAL-FORCE (Ry/Bohr)", force); if(INPUT.force_set) // pengfei 2016-12-20 @@ -184,6 +185,7 @@ void Forces::init(matrix& force) } ofs.close(); } +*/ // output force in unit eV/Angstrom ofs_running << endl; From 594cbebd0dbf83e38868eb0b932471d09aba2d1c Mon Sep 17 00:00:00 2001 From: qianrui <1962242031@qq.com> Date: Tue, 16 Mar 2021 18:11:41 +0800 Subject: [PATCH 210/233] improve hpsi --- ABACUS.develop/source/src_global/constants.h | 1 + ABACUS.develop/source/src_pw/diago_cg.cpp | 69 ++++++++++++++++---- ABACUS.develop/source/src_pw/diago_cg.h | 2 + ABACUS.develop/source/src_pw/hamilt.cpp | 4 +- ABACUS.develop/source/src_pw/hamilt_pw.cpp | 50 ++++++++++---- 5 files changed, 99 insertions(+), 27 deletions(-) diff --git a/ABACUS.develop/source/src_global/constants.h b/ABACUS.develop/source/src_global/constants.h index 89bc47ae3f..6e0b31b71a 100644 --- a/ABACUS.develop/source/src_global/constants.h +++ b/ABACUS.develop/source/src_global/constants.h @@ -35,6 +35,7 @@ const double SQRT3 = 1.73205080756887729352; //========================================================== const complex ZERO(0.0, 0.0); const complex ONE(1.0, 0.0); +const complex NEG_ONE(-1.0, 0.0); const complex IMAG_UNIT(0.0,1.0); const complex NEG_IMAG_UNIT(0.0,-1.0); diff --git a/ABACUS.develop/source/src_pw/diago_cg.cpp b/ABACUS.develop/source/src_pw/diago_cg.cpp index 9e8015561b..e3ff9bd632 100644 --- a/ABACUS.develop/source/src_pw/diago_cg.cpp +++ b/ABACUS.develop/source/src_pw/diago_cg.cpp @@ -16,6 +16,7 @@ void Diago_CG::diag ComplexMatrix &phi, double *e, const int &dim, + const int &dmx, const int &n_band, const double *precondition, const double &eps, @@ -64,7 +65,7 @@ void Diago_CG::diag for (int i=0; i - this->schmit_orth(dim, m, phi, sphi, phi_m); + this->schmit_orth(dim, dmx, m, phi, sphi, phi_m); // cout<<"\n before h_1psi sphi"; // for(int i=0; i>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Parallel_Reduce::reduce_complex_double_pool(lagrange, m); // (3) orthogonal |g> and |Sg> to all states (0~m-1) - for (int i=0; i>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> //timer::tick("Diago_CG","orth_grad"); return; @@ -393,6 +408,7 @@ bool Diago_CG::update_psi( void Diago_CG::schmit_orth ( const int& dim, + const int& dmx, const int& m, //end const ComplexMatrix &psi, complex *sphi, @@ -412,13 +428,21 @@ void Diago_CG::schmit_orth complex *lagrange = new complex[ m+1 ]; ZEROS(lagrange, m+1); - for (int j = 0; j <= m; j++) + //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + //qianrui replace 2021-3-15 + int inc=1; + int mp1 = m+1; + char trans='C'; + zgemv_(&trans,&dim,&mp1,&ONE,psi.c,&dmx,sphi,&inc,&ZERO,lagrange,&inc); + //====================================================================== + /*for (int j = 0; j <= m; j++) { for (int ig=0; ig < dim; ig++) { lagrange[j] += conj(psi( j, ig)) * sphi[ig] ; } - } + }*/ + //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> // be careful , here reduce m+1 Parallel_Reduce::reduce_complex_double_pool( lagrange, m+1 ); @@ -426,7 +450,13 @@ void Diago_CG::schmit_orth double psi_norm = lagrange[m].real(); // cout << "\n psi norm1 = " << psi_norm; - for (int j = 0; j < m; j++) + //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + //qianrui replace 2021-3-15 + char trans2='N'; + zgemv_(&trans2,&dim,&m,&NEG_ONE,psi.c,&dmx,lagrange,&inc,&ONE,psi_m,&inc); + psi_norm -= ddot_real(m,lagrange,lagrange); + //====================================================================== + /*for (int j = 0; j < m; j++) { for (int ig =0; ig < dim; ig++) { @@ -434,7 +464,8 @@ void Diago_CG::schmit_orth } // cout << "\n j = " << j << " lagrange norm = " << ( conj(lagrange[j]) * lagrange[j] ).real(); psi_norm -= ( conj(lagrange[j]) * lagrange[j] ).real(); - } + }*/ + //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> if ( psi_norm <= 0.0) { @@ -488,13 +519,25 @@ complex Diago_CG::ddot const complex * psi_R ) { - complex result(0, 0); - for (int i = 0; i < dim ; i++) + //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + //qianrui modify 2021-3-14 + //Note that ddot_(2*dim,a,1,b,1) = REAL( zdotc_(dim,a,1,b,1) ) + int dim2=2*dim; + double *pL,*pR; + pL=(double *)psi_L; + pR=(double *)psi_R; + double result=LapackConnector::dot(dim2,pL,1,pR,1); + Parallel_Reduce::reduce_double_pool( result ); + return result; + //====================================================================== + /*complex result(0,0); + for (int i=0;i>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> } // end of ddot // this return diff --git a/ABACUS.develop/source/src_pw/diago_cg.h b/ABACUS.develop/source/src_pw/diago_cg.h index 7998894645..d377b25acf 100644 --- a/ABACUS.develop/source/src_pw/diago_cg.h +++ b/ABACUS.develop/source/src_pw/diago_cg.h @@ -51,6 +51,7 @@ class Diago_CG ComplexMatrix &phi, double *e, const int &dim, + const int &dmx, const int &n_band, const double *precondition, const double &eps, @@ -61,6 +62,7 @@ class Diago_CG static void schmit_orth( const int &dim, + const int &dmx, const int &end, const ComplexMatrix &psi, complex *spsi, diff --git a/ABACUS.develop/source/src_pw/hamilt.cpp b/ABACUS.develop/source/src_pw/hamilt.cpp index d26b190acd..40050765ee 100644 --- a/ABACUS.develop/source/src_pw/hamilt.cpp +++ b/ABACUS.develop/source/src_pw/hamilt.cpp @@ -88,11 +88,11 @@ void Hamilt::diago( Diago_CG cg; bool reorder = true; - if(NPOL==1) cg.diag(wf.evc[ik0], wf.ekb[ik], kv.ngk[ik], + if(NPOL==1) cg.diag(wf.evc[ik0], wf.ekb[ik], kv.ngk[ik], wf.npwx, NBANDS, precondition, ETHR, DIAGO_CG_MAXITER, reorder, notconv, avg); else{ - cg.diag(wf.evc[ik0], wf.ekb[ik], wf.npwx*NPOL, + cg.diag(wf.evc[ik0], wf.ekb[ik], wf.npwx*NPOL, wf.npwx*NPOL, NBANDS, precondition, ETHR, DIAGO_CG_MAXITER, reorder, notconv, avg); } diff --git a/ABACUS.develop/source/src_pw/hamilt_pw.cpp b/ABACUS.develop/source/src_pw/hamilt_pw.cpp index 02afc33521..a7aeafd648 100644 --- a/ABACUS.develop/source/src_pw/hamilt_pw.cpp +++ b/ABACUS.develop/source/src_pw/hamilt_pw.cpp @@ -562,9 +562,19 @@ void Hamilt_PW::h_psi(const complex *psi_in, complex *hpsi) { if ( ppcell.nkb > 0) { - complex *becp = new complex[ ppcell.nkb * NPOL ]; + //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + //qianrui improve 2021-3-16 + int nkb=ppcell.nkb; + ComplexMatrix becp(NPOL,nkb,false); + char transa = 'C'; + char transb = 'N'; + zgemm_(&transa,&transb,&nkb,&NPOL,&wf.npw,&ONE,ppcell.vkb.c,&wf.npwx,psi_in,&wf.npwx,&ZERO,becp.c,&nkb); + becp=transpose(becp,false); + Parallel_Reduce::reduce_complex_double_pool( becp.c, ppcell.nkb * NPOL); + this->add_vuspsi(hpsi, becp.c); + //====================================================================== + /*complex *becp = new complex[ ppcell.nkb * NPOL ]; ZEROS(becp,ppcell.nkb * NPOL); - //zgemm('N','C',1,ppcell.nkb,wf.npw,ONE,psi,1,ppcell.vkb,ppcell.nkb,ZERO,becp,1); for (i=0;i< ppcell.nkb;i++) { const complex* p = &ppcell.vkb(i,0); @@ -572,18 +582,17 @@ void Hamilt_PW::h_psi(const complex *psi_in, complex *hpsi) const complex* psip = psi_in; for (;padd_vuspsi(hpsi, becp); - delete[] becp; + delete[] becp;*/ + //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> } } @@ -642,7 +651,13 @@ void Hamilt_PW::add_vuspsi(complex *hpsi_in,const complex *becp) // use simple method. - if(NSPIN!=4) + //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + //qianrui improve 2021-3-16 + char transa = 'N'; + char transb = 'T'; + zgemm_(&transa,&transb,&wf.npw,&NPOL,&ppcell.nkb,&ONE,ppcell.vkb.c,&wf.npwx,Ps,&NPOL,&ONE,hpsi_in,&wf.npwx); + //====================================================================== + /*if(!NONCOLIN) for(int i=0; i* p = &ppcell.vkb(i,0); @@ -667,10 +682,9 @@ void Hamilt_PW::add_vuspsi(complex *hpsi_in,const complex *becp) hp[0] += psp[0] * (p[0]); hp1[0] += psp[1] * (p[0]); } - } + }*/ + //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -// zgemm('N', 'N', 1, wf.npw, ppcell.nkb, ONE, this->Ps , 1, ppcell.vkb, -// ppcell.nkb, ONE, hpsi , 1); timer::tick("Hamilt_PW","add_vuspsi",'I'); return; } @@ -912,13 +926,25 @@ double Hamilt_PW::ddot_real const complex* psi_R )const { - complex result(0,0); + //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + //qianrui modify 2021-3-14 + //Note that ddot_(2*dim,a,1,b,1) = REAL( zdotc_(dim,a,1,b,1) ) + int dim2=2*dim; + double *pL,*pR; + pL=(double *)psi_L; + pR=(double *)psi_R; + double result=LapackConnector::dot(dim2,pL,1,pR,1); + Parallel_Reduce::reduce_double_pool( result ); + return result; + //====================================================================== + /*complex result(0,0); for (int i=0;i>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> } complex Hamilt_PW::ddot( From 2b2c9d9bc96848005f038b867809245a41ffa315 Mon Sep 17 00:00:00 2001 From: qianrui Date: Tue, 16 Mar 2021 20:12:46 +0800 Subject: [PATCH 211/233] fix a bug in orthogonal_gradient --- ABACUS.develop/source/src_pw/diago_cg.cpp | 13 ++++++------- ABACUS.develop/source/src_pw/diago_cg.h | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ABACUS.develop/source/src_pw/diago_cg.cpp b/ABACUS.develop/source/src_pw/diago_cg.cpp index e3ff9bd632..7543caa5e8 100644 --- a/ABACUS.develop/source/src_pw/diago_cg.cpp +++ b/ABACUS.develop/source/src_pw/diago_cg.cpp @@ -85,7 +85,7 @@ void Diago_CG::diag for (iter = 0;iter < maxter;iter++) { this->calculate_gradient( precondition, dim, hphi, sphi, g, pphi ); - this->orthogonal_gradient( dim, g, scg, lagrange, phi, m); + this->orthogonal_gradient( dim,dmx, g, scg, lagrange, phi, m); this->calculate_gamma_cg( iter, dim, precondition, g, scg, g0, cg, gg_last, cg_norm, theta, phi_m);// scg used as sg converged = this->update_psi( dim, cg_norm, theta, pphi, cg, scg, phi_m , @@ -211,7 +211,7 @@ void Diago_CG::calculate_gradient( } -void Diago_CG::orthogonal_gradient( const int &dim, +void Diago_CG::orthogonal_gradient( const int &dim, const int &dmx, complex *g, complex *sg, complex *lagrange, const ComplexMatrix &eigenfunction, const int m) { @@ -219,12 +219,11 @@ void Diago_CG::orthogonal_gradient( const int &dim, //timer::tick("Diago_CG","orth_grad"); hm.hpw.s_1psi(dim , g, sg); - + int inc=1; //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //qianrui replace 2021-3-15 - int inc=1; char trans='C'; - zgemv_(&trans,&dim,&m,&ONE,eigenfunction.c,&dim,sg,&inc,&ZERO,lagrange,&inc); + zgemv_(&trans,&dim,&m,&ONE,eigenfunction.c,&dmx,sg,&inc,&ZERO,lagrange,&inc); //====================================================================== /*for (int i=0; i *g, complex *scg, complex *lagrange, From af83e81267f345a735b8b3a9d9a40c14dba3077b Mon Sep 17 00:00:00 2001 From: qianrui Date: Tue, 16 Mar 2021 21:06:31 +0800 Subject: [PATCH 212/233] fix a bug in cinitcgg which make the result of multiple k point wrong --- ABACUS.develop/source/src_pw/hamilt_pw.cpp | 30 ++++------------------ 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/ABACUS.develop/source/src_pw/hamilt_pw.cpp b/ABACUS.develop/source/src_pw/hamilt_pw.cpp index 02afc33521..5cb5f9d89c 100644 --- a/ABACUS.develop/source/src_pw/hamilt_pw.cpp +++ b/ABACUS.develop/source/src_pw/hamilt_pw.cpp @@ -351,33 +351,13 @@ void Hamilt_PW::cinitcgg( //qianrui improve this part 2021-3-13 char transa = 'N'; char transb = 'T'; - if(NPOL == 1) - { - ComplexMatrix evctmp(n_band, wf.npw,false); - zgemm_(&transa,&transb,&wf.npw,&n_band,&nstart,&ONE,psi.c,&wf.npw,hvec.c,&n_band,&ZERO,evctmp.c,&wf.npw); - for(int ib=0; ib Date: Tue, 16 Mar 2021 22:16:56 +0800 Subject: [PATCH 213/233] move output_HS_R from LOOP_ions to src_io/write_HS_R --- ABACUS.develop/source/Makefile.Objects | 1 + ABACUS.develop/source/src_io/write_HS_R.cpp | 73 +++++++++++++++++++ ABACUS.develop/source/src_lcao/LOOP_ions.cpp | 66 ++--------------- .../source/src_lcao/ORB_control.cpp | 2 +- ABACUS.develop/source/src_lcao/run_md.cpp | 3 +- 5 files changed, 82 insertions(+), 63 deletions(-) create mode 100644 ABACUS.develop/source/src_io/write_HS_R.cpp diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index fe41bb5ab8..4351fb43a6 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -238,6 +238,7 @@ write_pot.o\ write_rho.o\ write_rho_dipole.o\ write_dm.o\ +write_HS_R.o\ potential_libxc.o \ efield.o \ magnetism.o\ diff --git a/ABACUS.develop/source/src_io/write_HS_R.cpp b/ABACUS.develop/source/src_io/write_HS_R.cpp new file mode 100644 index 0000000000..f21dc00545 --- /dev/null +++ b/ABACUS.develop/source/src_io/write_HS_R.cpp @@ -0,0 +1,73 @@ +#include "src_lcao/LOOP_ions.h" +#include "src_io/cal_r_overlap_R.h" +#include "src_pw/global.h" +#include "src_io/hs_matrix.h" + +/* +#include "src_parallel/parallel_orbitals.h" +#include "src_pdiag/pdiag_double.h" +#include "LCAO_nnr.h" +#include "FORCE_STRESS.h" +#include "src_global/global_function.h" +#include "src_ions/variable_cell.h" +#include "ELEC_scf.h" +#include "src_global/sltk_atom_arrange.h" +*/ + +void LOOP_ions::output_HS_R(void) +{ + TITLE("LOOP_ions","output_HS_R"); + timer::tick("LOOP_ions","output_HS_R",'D'); + + // add by jingan for out r_R matrix 2019.8.14 + if(INPUT.out_r_matrix) + { + cal_r_overlap_R r_matrix; + r_matrix.init(); + r_matrix.out_r_overlap_R(NSPIN); + } + + if(NSPIN==1||NSPIN==4) + { + UHM.calculate_STN_R(); + UHM.GK.cal_vlocal_R(0); + UHM.GK.distribute_pvpR_tr(); + HS_Matrix::save_HSR_tr(0); + } + ///* + else if(NSPIN==2) + { + UHM.calculate_STN_R(); + for(int ik=0; ikistep = 1; int force_step = 1; int stress_step = 1; @@ -504,61 +506,3 @@ void LOOP_ions::final_scf(void) return; } - -void LOOP_ions::output_HS_R(void) -{ - TITLE("LOOP_ions","output_HS_R"); - timer::tick("LOOP_ions","output_HS_R",'D'); - - // add by jingan for out r_R matrix 2019.8.14 - if(INPUT.out_r_matrix) - { - cal_r_overlap_R r_matrix; - r_matrix.init(); - r_matrix.out_r_overlap_R(NSPIN); - } - - if(NSPIN==1||NSPIN==4) - { - UHM.calculate_STN_R(); - UHM.GK.cal_vlocal_R(0); - UHM.GK.distribute_pvpR_tr(); - HS_Matrix::save_HSR_tr(0); - } - ///* - else if(NSPIN==2) - { - UHM.calculate_STN_R(); - for(int ik=0; ik Date: Tue, 16 Mar 2021 22:25:48 +0800 Subject: [PATCH 214/233] update vdwd2 and vdwd3, find atom label from pseudopotential files. --- ABACUS.develop/source/src_pw/vdwd2.cpp | 14 +++++++------- ABACUS.develop/source/src_pw/vdwd3.cpp | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ABACUS.develop/source/src_pw/vdwd2.cpp b/ABACUS.develop/source/src_pw/vdwd2.cpp index 9d4a639772..77a355ebaa 100644 --- a/ABACUS.develop/source/src_pw/vdwd2.cpp +++ b/ABACUS.develop/source/src_pw/vdwd2.cpp @@ -23,8 +23,8 @@ void Vdwd2::cal_energy() { for( int it2=0; it2!=ucell.ntype; ++it2 ) { - const double C6_product = sqrt( para.C6.at(ucell.atoms[it1].label) * para.C6.at(ucell.atoms[it2].label) )/pow(ucell.lat0,6) ; - const double R0_sum = ( para.R0.at(ucell.atoms[it1].label) + para.R0.at(ucell.atoms[it2].label) )/ucell.lat0; + const double C6_product = sqrt( para.C6.at(ucell.atoms[it1].psd) * para.C6.at(ucell.atoms[it2].psd) )/pow(ucell.lat0,6) ; + const double R0_sum = ( para.R0.at(ucell.atoms[it1].psd) + para.R0.at(ucell.atoms[it2].psd) )/ucell.lat0; if(!R0_sum) WARNING_QUIT("Input", "R0_sum can not be 0"); for( int ia1=0; ia1!=ucell.atoms[it1].na; ++ia1 ) @@ -64,8 +64,8 @@ void Vdwd2::cal_force() { for( int it2=0; it2!=ucell.ntype; ++it2 ) { - const double C6_product = sqrt( para.C6.at(ucell.atoms[it1].label) * para.C6.at(ucell.atoms[it2].label) )/pow(ucell.lat0,6); - const double R0_sum = ( para.R0.at(ucell.atoms[it1].label) + para.R0.at(ucell.atoms[it2].label) )/ucell.lat0; + const double C6_product = sqrt( para.C6.at(ucell.atoms[it1].psd) * para.C6.at(ucell.atoms[it2].psd) )/pow(ucell.lat0,6); + const double R0_sum = ( para.R0.at(ucell.atoms[it1].psd) + para.R0.at(ucell.atoms[it2].psd) )/ucell.lat0; if(!R0_sum) WARNING_QUIT("Input", "R0_sum can not be 0"); for( int ia1=0; ia1!=ucell.atoms[it1].na; ++ia1 ) @@ -100,7 +100,7 @@ void Vdwd2::cal_force() void Vdwd2::cal_stress() { - TITLE("Vdwd2","force"); + TITLE("Vdwd2","stress"); para.initset(ucell); stress.Reset(); @@ -109,8 +109,8 @@ void Vdwd2::cal_stress() { for( int it2=0; it2!=ucell.ntype; ++it2 ) { - const double C6_product = sqrt( para.C6.at(ucell.atoms[it1].label) * para.C6.at(ucell.atoms[it2].label) )/pow(ucell.lat0,6); - const double R0_sum = ( para.R0.at(ucell.atoms[it1].label) + para.R0.at(ucell.atoms[it2].label) )/ucell.lat0; + const double C6_product = sqrt( para.C6.at(ucell.atoms[it1].psd) * para.C6.at(ucell.atoms[it2].psd) )/pow(ucell.lat0,6); + const double R0_sum = ( para.R0.at(ucell.atoms[it1].psd) + para.R0.at(ucell.atoms[it2].psd) )/ucell.lat0; if(!R0_sum) WARNING_QUIT("Input", "R0_sum can not be 0"); for( int ia1=0; ia1!=ucell.atoms[it1].na; ++ia1 ) diff --git a/ABACUS.develop/source/src_pw/vdwd3.cpp b/ABACUS.develop/source/src_pw/vdwd3.cpp index 3d02cf1397..431d228556 100644 --- a/ABACUS.develop/source/src_pw/vdwd3.cpp +++ b/ABACUS.develop/source/src_pw/vdwd3.cpp @@ -30,7 +30,7 @@ void Vdwd3::atomkind (const UnitCell_pseudo &unitcell) { for (int j=0; j!=element_name.size(); j++) { - if ( unitcell.atoms[i].label == element_name[j] ) + if ( unitcell.atoms[i].psd == element_name[j] ) { atom_kind[i] = j ; break; From d1b31425b7c09600df28824e438937cc4ea845d1 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 16 Mar 2021 22:45:19 +0800 Subject: [PATCH 215/233] add ppcell.vloc in ppcell.init_vloc as input parameter --- ABACUS.develop/source/run_lcao.cpp | 14 +++++++------- ABACUS.develop/source/run_pw.cpp | 2 +- ABACUS.develop/source/src_ions/variable_cell.cpp | 4 ++-- ABACUS.develop/source/src_pw/pseudopot_cell_vl.cpp | 4 ++-- ABACUS.develop/source/src_pw/pseudopot_cell_vl.h | 6 +----- ABACUS.develop/source/src_pw/wf_igk.cpp | 1 - 6 files changed, 13 insertions(+), 18 deletions(-) diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index 61abd1c08d..f0f9c4cb05 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -1,7 +1,3 @@ -//========================================================== -// AUTHOR : mohan -// DATE : 2021-02-01 -//========================================================== #include "run_lcao.h" #include "src_pw/global.h" #include "input.h" @@ -103,17 +99,21 @@ void Run_lcao::lcao_line(void) // Initialize the local wave functions. // npwx, eigenvalues, and weights + // npwx may change according to cell change + // this function belongs to cell LOOP wf.allocate_ekb_wg(kv.nks); // Initialize the FFT. + // this function belongs to cell LOOP UFFT.allocate(); - // Initialize the local part of - // NC pseudopotentials - ppcell.init_vloc(pw.nggm); + // output is ppcell.vloc 3D local pseudopotentials + // this function belongs to cell LOOP + ppcell.init_vloc(pw.nggm, ppcell.vloc); // Initialize the sum of all local potentials. // if ion_step==0, read in/initialize the potentials + // this function belongs to ions LOOP int ion_step=0; pot.init_pot(ion_step, pw.strucFac); diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp index c521465920..22c875c10c 100644 --- a/ABACUS.develop/source/run_pw.cpp +++ b/ABACUS.develop/source/run_pw.cpp @@ -98,7 +98,7 @@ void Run_pw::plane_wave_line(void) //================================= // initalize local pseudopotential //================================= - ppcell.init_vloc(pw.nggm); + ppcell.init_vloc(pw.nggm, ppcell.vloc); DONE(ofs_running,"LOCAL POTENTIAL"); //====================================== diff --git a/ABACUS.develop/source/src_ions/variable_cell.cpp b/ABACUS.develop/source/src_ions/variable_cell.cpp index 1be1b81a0d..f8034f5e90 100644 --- a/ABACUS.develop/source/src_ions/variable_cell.cpp +++ b/ABACUS.develop/source/src_ions/variable_cell.cpp @@ -46,7 +46,7 @@ void Variable_Cell::init_after_vc(void) //================================= // initalize local pseudopotential //================================= - ppcell.init_vloc(pw.nggm); + ppcell.init_vloc(pw.nggm, ppcell.vloc); DONE(ofs_running,"LOCAL POTENTIAL"); //====================================== @@ -148,7 +148,7 @@ void Variable_Cell::final_calculation_after_vc(void) //================================= // initalize local pseudopotential //================================= - ppcell.init_vloc(pw.nggm); + ppcell.init_vloc(pw.nggm, ppcell.vloc); DONE(ofs_running,"LOCAL POTENTIAL"); //====================================== // Initalize non local pseudopotential diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_vl.cpp b/ABACUS.develop/source/src_pw/pseudopot_cell_vl.cpp index 9cd011ff92..7c08a04648 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_vl.cpp +++ b/ABACUS.develop/source/src_pw/pseudopot_cell_vl.cpp @@ -16,7 +16,7 @@ pseudopot_cell_vl::~pseudopot_cell_vl() } -void pseudopot_cell_vl::init_vloc(const int &nggm) +void pseudopot_cell_vl::init_vloc(const int &nggm, matrix &vloc_in) { TITLE("pseudopot_cell_vl","init_vloc"); @@ -53,7 +53,7 @@ void pseudopot_cell_vl::init_vloc(const int &nggm) WARNING_QUIT("init_vloc","not available now."); } - dcopy(vloc1d, this->vloc,it); + dcopy(vloc1d, vloc_in, it); } diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_vl.h b/ABACUS.develop/source/src_pw/pseudopot_cell_vl.h index d0ad582e28..7541e041d0 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_vl.h +++ b/ABACUS.develop/source/src_pw/pseudopot_cell_vl.h @@ -1,7 +1,3 @@ -//========================================================== -// AUTHOR : Lixin He,mohan -// DATE : 2008-11-6 -//========================================================== #ifndef pseudopot_cell_vl_H #define pseudopot_cell_vl_H @@ -14,7 +10,7 @@ class pseudopot_cell_vl pseudopot_cell_vl(); ~pseudopot_cell_vl(); - void init_vloc(const int &nggm); + void init_vloc(const int &nggm, matrix &vloc_in); matrix vloc; //(ntype,ngl),the local potential for each atom type(ntype,ngl) bool *numeric; //[ntype], =true diff --git a/ABACUS.develop/source/src_pw/wf_igk.cpp b/ABACUS.develop/source/src_pw/wf_igk.cpp index 4177ccf838..01c014e71d 100644 --- a/ABACUS.develop/source/src_pw/wf_igk.cpp +++ b/ABACUS.develop/source/src_pw/wf_igk.cpp @@ -39,7 +39,6 @@ int WF_igk::setupIndGk(const PW_Basis &pwb,const int nks) // Done this in each cpu ( use nks,not nkstot ) // notice : using cartesian coordinate //============================================= -// ofs_running << " " << setw(8) << "KPOINTS" << setw(10) << "ngk" << endl; for (int ik = 0; ik < nks; ik++) { int ng = 0; From 2fd61918a42d064de8dd06136b9d2fc693e3f528 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 17 Mar 2021 20:55:10 +0800 Subject: [PATCH 216/233] update vr_eff in potential --- ABACUS.develop/source/src_io/write_HS_R.cpp | 4 +- .../source/src_lcao/ELEC_cbands_gamma.cpp | 3 +- .../source/src_lcao/ELEC_cbands_k.cpp | 8 +-- .../source/src_lcao/ELEC_evolve.cpp | 8 +-- ABACUS.develop/source/src_lcao/ELEC_scf.cpp | 6 +- .../source/src_lcao/FORCE_gamma_vl.cpp | 8 +-- ABACUS.develop/source/src_lcao/FORCE_k.cpp | 13 +++-- .../source/src_lcao/LCAO_hamilt.cpp | 2 +- .../source/src_lcao/LCAO_matrix.cpp | 2 +- .../source/src_lcao/build_st_pw.cpp | 10 ++-- ABACUS.develop/source/src_lcao/run_md.cpp | 58 ------------------- ABACUS.develop/source/src_lcao/run_md.h | 1 - ABACUS.develop/source/src_pw/H_TDDFT_pw.cpp | 4 +- ABACUS.develop/source/src_pw/electrons.cpp | 2 +- ABACUS.develop/source/src_pw/hamilt_pw.cpp | 12 ++-- ABACUS.develop/source/src_pw/potential.cpp | 46 +++++++-------- ABACUS.develop/source/src_pw/potential.h | 10 ++-- ABACUS.develop/source/src_pw/sto_elec.cpp | 2 +- ABACUS.develop/source/src_pw/sto_hchi.cpp | 4 +- 19 files changed, 75 insertions(+), 128 deletions(-) diff --git a/ABACUS.develop/source/src_io/write_HS_R.cpp b/ABACUS.develop/source/src_io/write_HS_R.cpp index f21dc00545..ccdff24458 100644 --- a/ABACUS.develop/source/src_io/write_HS_R.cpp +++ b/ABACUS.develop/source/src_io/write_HS_R.cpp @@ -45,7 +45,7 @@ void LOOP_ions::output_HS_R(void) if(NSPIN==2)CURRENT_SPIN = kv.isk[ik]; for(int ir=0; ir wf.npw = kv.ngk[ik]; for(int ir=0; ir uhm.GK.reset_spin( CURRENT_SPIN ); // vlocal = Vh[rho] + Vxc[rho] + Vl(pseudo) - uhm.GK.cal_vlocal_k(pot.vrs1,GridT); + uhm.GK.cal_vlocal_k(pot.vr_eff1,GridT); // added by zhengdy-soc, for non-collinear case // integral 4 times, is there any method to simplify? if(NSPIN==4) @@ -58,9 +58,9 @@ void ELEC_evolve::evolve_psi(const int &istep, LCAO_Hamilt &uhm, complex { for(int ir=0; irGG.cal_vlocal(pot.vrs1); + this->GG.cal_vlocal(pot.vr_eff1); // Peize Lin add 2016-12-03 if( 5==xcf.iexch_now && 0==xcf.igcx_now ) // HF diff --git a/ABACUS.develop/source/src_lcao/LCAO_matrix.cpp b/ABACUS.develop/source/src_lcao/LCAO_matrix.cpp index a3477a0833..2907f91fc1 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_matrix.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_matrix.cpp @@ -40,7 +40,7 @@ void LCAO_Matrix::divide_HS_in_frag(const bool isGamma, Parallel_Orbitals &po) // (1) calculate nrow, ncol, nloc. if (KS_SOLVER=="genelpa" || KS_SOLVER=="hpseps" || KS_SOLVER=="scalpack" - || KS_SOLVER=="selinv" || KS_SOLVER=="scalapack_gvx") //xiaohui add 2013-09-02 + || KS_SOLVER=="selinv" || KS_SOLVER=="scalapack_gvx") { ofs_running << " divide the H&S matrix using 2D block algorithms." << endl; #ifdef __MPI diff --git a/ABACUS.develop/source/src_lcao/build_st_pw.cpp b/ABACUS.develop/source/src_lcao/build_st_pw.cpp index f10ee28974..ac6467bfc1 100644 --- a/ABACUS.develop/source/src_lcao/build_st_pw.cpp +++ b/ABACUS.develop/source/src_lcao/build_st_pw.cpp @@ -150,7 +150,7 @@ void Build_ST_pw::set_local(const int &ik) pw.FFT_wfc.FFT3D( psic, 1); for (int ir=0; ir< pw.nrxx; ir++) { - psic[ir] *= pot.vrs1[ir]; + psic[ir] *= pot.vr_eff1[ir]; } // (3) fft back to G space. @@ -205,10 +205,10 @@ void Build_ST_pw::set_local(const int &ik) complex sup,sdown; for (int ir=0; ir< pw.nrxx; ir++) { - sup = psic[ir] * (pot.vrs(0,ir) + pot.vrs(3,ir)) + - psic1[ir] * (pot.vrs(1,ir) - complex(0.0,1.0) * pot.vrs(2,ir)); - sdown = psic1[ir] * (pot.vrs(0,ir) - pot.vrs(3,ir)) + - psic[ir] * (pot.vrs(1,ir) + complex(0.0,1.0) * pot.vrs(2,ir)); + sup = psic[ir] * (pot.vr_eff(0,ir) + pot.vr_eff(3,ir)) + + psic1[ir] * (pot.vr_eff(1,ir) - complex(0.0,1.0) * pot.vr_eff(2,ir)); + sdown = psic1[ir] * (pot.vr_eff(0,ir) - pot.vr_eff(3,ir)) + + psic[ir] * (pot.vr_eff(1,ir) + complex(0.0,1.0) * pot.vr_eff(2,ir)); psic[ir] = sup; psic1[ir] = sdown; diff --git a/ABACUS.develop/source/src_lcao/run_md.cpp b/ABACUS.develop/source/src_lcao/run_md.cpp index 1c524ef826..fa78f17e7f 100644 --- a/ABACUS.develop/source/src_lcao/run_md.cpp +++ b/ABACUS.develop/source/src_lcao/run_md.cpp @@ -476,61 +476,3 @@ void Run_MD::final_scf(void) return; } - -void Run_MD::output_HS_R(void) -{ - TITLE("Run_MD","output_HS_R"); - timer::tick("Run_MD","output_HS_R",'D'); - - // add by jingan for out r_R matrix 2019.8.14 - if(INPUT.out_r_matrix) - { - cal_r_overlap_R r_matrix; - r_matrix.init(); - r_matrix.out_r_overlap_R(NSPIN); - } - - if(NSPIN==1||NSPIN==4) - { - UHM.calculate_STN_R(); - UHM.GK.cal_vlocal_R(0); - UHM.GK.distribute_pvpR_tr(); - HS_Matrix::save_HSR_tr(0); - } - ///* - else if(NSPIN==2) - { - UHM.calculate_STN_R(); - for(int ik=0; ikvrs(is, i) = this->vltot[i] + this->vr(is, i); + this->vr_eff(is, i) = this->vltot[i] + this->vr(is, i); } cout << "vext = 0! " << endl; } @@ -92,7 +92,7 @@ void potential::set_vrs_tddft(const int istep) //this->vext[ir] = this->vextold[ir]*2.74*cos(0.856*timenow)*sin(0.0214*timenow)*sin(0.0214*timenow)*0.01944; //this->vext[ir] = this->vextold[ir]*2.74*cos(0.0428*timenow)*sin(0.00107*timenow)*sin(0.00107*timenow); - this->vrs(is,ir) = this->vltot[ir] + this->vr(is, ir) + this->vext[ir]; + this->vr_eff(is,ir) = this->vltot[ir] + this->vr(is, ir) + this->vext[ir]; //cout << "x: " << k <<" " << "y: " << j <<" "<< "z: "<< i <<" "<< "ir: " << ir << endl; //cout << "vext: " << this->vext[ir] << endl; diff --git a/ABACUS.develop/source/src_pw/electrons.cpp b/ABACUS.develop/source/src_pw/electrons.cpp index 18b954785b..bccf567c75 100644 --- a/ABACUS.develop/source/src_pw/electrons.cpp +++ b/ABACUS.develop/source/src_pw/electrons.cpp @@ -341,7 +341,7 @@ void Electrons::self_consistent(const int &istep) if(vext == 0) { - pot.set_vrs(); + pot.set_vr_eff(); } else { diff --git a/ABACUS.develop/source/src_pw/hamilt_pw.cpp b/ABACUS.develop/source/src_pw/hamilt_pw.cpp index a9f9edfc96..7074a2b8c3 100644 --- a/ABACUS.develop/source/src_pw/hamilt_pw.cpp +++ b/ABACUS.develop/source/src_pw/hamilt_pw.cpp @@ -69,7 +69,7 @@ void Hamilt_PW::init_k(const int ik) // (3) Take the local potential. for (int ir=0; ir *psi_in, complex *hpsi) if(NSPIN!=4) { ZEROS( UFFT.porter, pw.nrxx); - UFFT.RoundTrip( psi_in, pot.vrs1, GR_index, UFFT.porter ); + UFFT.RoundTrip( psi_in, pot.vr_eff1, GR_index, UFFT.porter ); for (j = 0;j < wf.npw;j++) { @@ -515,10 +515,10 @@ void Hamilt_PW::h_psi(const complex *psi_in, complex *hpsi) complex sup,sdown; for (int ir=0; ir< pw.nrxx; ir++) { - sup = UFFT.porter[ir] * (pot.vrs(0,ir) + pot.vrs(3,ir)) + - porter1[ir] * (pot.vrs(1,ir) - complex(0.0,1.0) * pot.vrs(2,ir)); - sdown = porter1[ir] * (pot.vrs(0,ir) - pot.vrs(3,ir)) + - UFFT.porter[ir] * (pot.vrs(1,ir) + complex(0.0,1.0) * pot.vrs(2,ir)); + sup = UFFT.porter[ir] * (pot.vr_eff(0,ir) + pot.vr_eff(3,ir)) + + porter1[ir] * (pot.vr_eff(1,ir) - complex(0.0,1.0) * pot.vr_eff(2,ir)); + sdown = porter1[ir] * (pot.vr_eff(0,ir) - pot.vr_eff(3,ir)) + + UFFT.porter[ir] * (pot.vr_eff(1,ir) + complex(0.0,1.0) * pot.vr_eff(2,ir)); UFFT.porter[ir] = sup; porter1[ir] = sdown; } diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index a1de69c681..6d107e9638 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -13,14 +13,14 @@ potential::potential() { vltot = new double[1]; - vrs1 = new double[1]; + vr_eff1 = new double[1]; this->out_potential = 0; } potential::~potential() { delete[] vltot; - delete[] vrs1; + delete[] vr_eff1; } void potential::allocate(const int nrxx) @@ -33,13 +33,13 @@ void potential::allocate(const int nrxx) Memory::record("potential","vltot",nrxx,"double"); this->vr.create(NSPIN,nrxx); - this->vrs.create(NSPIN,nrxx); + this->vr_eff.create(NSPIN,nrxx); Memory::record("potential","vr",NSPIN*nrxx,"double"); - Memory::record("potential","vrs",NSPIN*nrxx,"double"); + Memory::record("potential","vr_eff",NSPIN*nrxx,"double"); - delete[] this->vrs1; - this->vrs1 = new double[nrxx]; - Memory::record("potential","vrs1",nrxx,"double"); + delete[] this->vr_eff1; + this->vr_eff1 = new double[nrxx]; + Memory::record("potential","vr_eff1",nrxx,"double"); this->vnew.create(NSPIN,nrxx); Memory::record("potential","vnew",NSPIN*nrxx,"double"); @@ -61,7 +61,7 @@ void potential::init_pot( assert(istep>=0); // total potential in real space - this->vrs.zero_out(); + this->vr_eff.zero_out(); // the vltot should and must be zero here. ZEROS(this->vltot, pw.nrxx); @@ -69,7 +69,7 @@ void potential::init_pot( //------------------------------------------------------------------- // (1) local pseudopotential + electric field (if any) in vltot //------------------------------------------------------------------- - this->set_local( + this->set_local_pot( this->vltot, // 3D local pseudopotentials ucell.ntype, pw.ngmc, @@ -90,7 +90,7 @@ void potential::init_pot( { for(int ir=0; irvrs(is,ir) = this->vltot[ir]; + this->vr_eff(is,ir) = this->vltot[ir]; } } @@ -204,7 +204,7 @@ void potential::init_pot( //---------------------------------------------------------- if(vext == 0) { - this->set_vrs(); + this->set_vr_eff(); } else { @@ -212,7 +212,7 @@ void potential::init_pot( } // plots - //figure::picture(this->vrs1,pw.ncx,pw.ncy,pw.ncz); + //figure::picture(this->vr_eff1,pw.ncx,pw.ncy,pw.ncz); timer::tick("potential","init_pot"); return; } @@ -221,7 +221,7 @@ void potential::init_pot( //========================================================== // This routine computes the local potential in real space //========================================================== -void potential::set_local( +void potential::set_local_pot( double* vl_pseudo, // store the local pseudopotential const int &ntype, // number of atom types const int &ngmc, // number of |g|, g is plane wave @@ -230,8 +230,8 @@ void potential::set_local( ComplexMatrix &sf // structure factors )const { - TITLE("potential","set_local"); - timer::tick("potential","set_local"); + TITLE("potential","set_local_pot"); + timer::tick("potential","set_local_pot"); complex *vg = new complex[ngmc]; @@ -266,7 +266,7 @@ void potential::set_local( } //ofs_running <<" set local pseudopotential done." << endl; - timer::tick("potential","set_local"); + timer::tick("potential","set_local_pot"); return; } @@ -318,15 +318,15 @@ void potential::v_of_rho //========================================================== -// set the total local potential vrs on the real space grid +// set the effective potential vr_eff on the real space grid // used in h_psi, adding the (spin dependent) scf (H+xc) // part and the sum of all the local pseudopotential // contributions. //========================================================== -void potential::set_vrs(void) +void potential::set_vr_eff(void) { - TITLE("potential","set_vrs"); - timer::tick("potential","set_vrs"); + TITLE("potential","set_vr_eff"); + timer::tick("potential","set_vr_eff"); for (int is = 0;is < NSPIN;is++) { @@ -337,19 +337,19 @@ void potential::set_vrs(void) { for (int i = 0;i < pw.nrxx; i++) { - this->vrs(is, i) = this->vr(is, i); + this->vr_eff(is, i) = this->vr(is, i); } } else { for (int i = 0;i < pw.nrxx; i++) { - this->vrs(is, i) = this->vltot[i] + this->vr(is, i); + this->vr_eff(is, i) = this->vltot[i] + this->vr(is, i); } } } - timer::tick("potential","set_vrs"); + timer::tick("potential","set_vr_eff"); return; } diff --git a/ABACUS.develop/source/src_pw/potential.h b/ABACUS.develop/source/src_pw/potential.h index fcc5371ca4..23bf74b177 100644 --- a/ABACUS.develop/source/src_pw/potential.h +++ b/ABACUS.develop/source/src_pw/potential.h @@ -19,7 +19,7 @@ class potential // start_pot : "atomic" or "file" // extra_pot : extrapolation methods for potential // vr(nspin,ncxyz) : Hartree + xc potentials in real space - // vrs(nspin,ncxyz) : total potential in real space + // vr_eff(nspin,ncxyz) : effective potential in real space // vnew(nspin,ncxyz) : V_out - V_in, needed in scf // vltot: the local potential in real space // out_potential: options to print out potentials @@ -28,9 +28,9 @@ class potential string start_pot; string extra_pot; matrix vr; - matrix vrs; + matrix vr_eff; matrix vnew; - double *vrs1; + double *vr_eff1; double *vltot; int out_potential; // mohan add 2011-02-28 @@ -43,7 +43,7 @@ class potential void v_of_rho(double** rho_in, matrix &v); - void set_vrs(void); + void set_vr_eff(void); void newd(void); @@ -59,7 +59,7 @@ class potential private: - void set_local( + void set_local_pot( double* vl_pseudo, // store the local pseudopotential const int &ntype, // number of atom types const int &ngmc, // number of |g|, g is plane wave diff --git a/ABACUS.develop/source/src_pw/sto_elec.cpp b/ABACUS.develop/source/src_pw/sto_elec.cpp index 0384a467d6..8cd94ffd0e 100644 --- a/ABACUS.develop/source/src_pw/sto_elec.cpp +++ b/ABACUS.develop/source/src_pw/sto_elec.cpp @@ -257,7 +257,7 @@ void Stochastic_Elec::scf_stochastic(const int &istep) if(vext == 0) { - pot.set_vrs(); + pot.set_vr_eff(); } //print_eigenvalue(ofs_running); diff --git a/ABACUS.develop/source/src_pw/sto_hchi.cpp b/ABACUS.develop/source/src_pw/sto_hchi.cpp index f3ee168e98..ae9f333636 100644 --- a/ABACUS.develop/source/src_pw/sto_hchi.cpp +++ b/ABACUS.develop/source/src_pw/sto_hchi.cpp @@ -163,10 +163,10 @@ void Stochastic_hchi::orthogonal_to_psi_real(complex *wfin, complex*chi_in, complex *hchi) +void Stochastic_hchi::hchi_real(complex*chi_in, complex *hchi) { - double*vr = pot.vrs1; //vr= pot.vrs1 temporarily use cutoff vr. + double*vr = pot.vr_eff1; //vr= pot.vrs1 temporarily use cutoff vr. //wait for init-------------------------------------- double dk1,dk2,dk3; From dc85d988c12137c9ebe4a96aee9c9e78d62cf4e0 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 17 Mar 2021 21:15:52 +0800 Subject: [PATCH 217/233] change potential to Potential --- ABACUS.develop/source/run_pw.cpp | 3 +- ABACUS.develop/source/src_io/write_pot.cpp | 17 ++++-- ABACUS.develop/source/src_pw/H_TDDFT_pw.cpp | 6 +- ABACUS.develop/source/src_pw/H_XC_pw.h | 2 +- ABACUS.develop/source/src_pw/energy.h | 2 +- ABACUS.develop/source/src_pw/global.cpp | 2 +- ABACUS.develop/source/src_pw/global.h | 2 +- ABACUS.develop/source/src_pw/ions.cpp | 2 - ABACUS.develop/source/src_pw/potential.cpp | 57 ++++++++++--------- ABACUS.develop/source/src_pw/potential.h | 6 +- .../source/src_pw/pseudopot_cell_vnl.h | 2 +- 11 files changed, 53 insertions(+), 48 deletions(-) diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp index 22c875c10c..d676a5cecf 100644 --- a/ABACUS.develop/source/run_pw.cpp +++ b/ABACUS.develop/source/run_pw.cpp @@ -112,7 +112,8 @@ void Run_pw::plane_wave_line(void) //========================================================= pot.init_pot(0, pw.strucFac);//atomic_rho, v_of_rho, set_vrs - pot.newd();//once + pot.newd(); + DONE(ofs_running,"INIT POTENTIAL"); //================================================== diff --git a/ABACUS.develop/source/src_io/write_pot.cpp b/ABACUS.develop/source/src_io/write_pot.cpp index 22d2098394..084eb93f86 100644 --- a/ABACUS.develop/source/src_io/write_pot.cpp +++ b/ABACUS.develop/source/src_io/write_pot.cpp @@ -2,8 +2,13 @@ #include "../src_pw/global.h" // translate from write_rho in charge.cpp. -void potential::write_potential(const int &is, const int &iter, const string &fn, -const matrix &v, const int &precision, const int &hartree)const +void Potential::write_potential( + const int &is, + const int &iter, + const string &fn, + const matrix &v, + const int &precision, + const int &hartree)const { TITLE("potential","write_potential"); @@ -191,10 +196,10 @@ const matrix &v, const int &precision, const int &hartree)const } -void potential::write_elecstat_pot(const string &fn, const string &fn_ave) +void Potential::write_elecstat_pot(const string &fn, const string &fn_ave) { - TITLE("potential","write_elecstat_pot"); - timer::tick("potential","write_elecstat_pot"); + TITLE("Potential","write_elecstat_pot"); + timer::tick("Potential","write_elecstat_pot"); double *v_elecstat; v_elecstat = new double[pw.nrxx]; @@ -478,6 +483,6 @@ void potential::write_elecstat_pot(const string &fn, const string &fn_ave) delete[] v_elecstat; delete[] vh_g; - timer::tick("potential","write_potential"); + timer::tick("Potential","write_potential"); return; } diff --git a/ABACUS.develop/source/src_pw/H_TDDFT_pw.cpp b/ABACUS.develop/source/src_pw/H_TDDFT_pw.cpp index 27719ad4fb..1befe288c0 100644 --- a/ABACUS.develop/source/src_pw/H_TDDFT_pw.cpp +++ b/ABACUS.develop/source/src_pw/H_TDDFT_pw.cpp @@ -6,10 +6,10 @@ // (eg: linear potential) used in tddft // fuxiang add in 2017-05 //========================================================== -void potential::set_vrs_tddft(const int istep) +void Potential::set_vrs_tddft(const int istep) { - TITLE("potential","set_vrs_tddft"); - timer::tick("potential","set_vrs_tddft"); + TITLE("Potential","set_vrs_tddft"); + timer::tick("Potential","set_vrs_tddft"); for (int is = 0;is < NSPIN;is++) { diff --git a/ABACUS.develop/source/src_pw/H_XC_pw.h b/ABACUS.develop/source/src_pw/H_XC_pw.h index 06c6992ed8..a8f6dc0d00 100644 --- a/ABACUS.develop/source/src_pw/H_XC_pw.h +++ b/ABACUS.develop/source/src_pw/H_XC_pw.h @@ -11,7 +11,7 @@ class H_XC_pw friend class Stress_PW; friend class Forces; friend class Force_Stress_LCAO; - friend class potential; + friend class Potential; friend class energy; friend class eximport; diff --git a/ABACUS.develop/source/src_pw/energy.h b/ABACUS.develop/source/src_pw/energy.h index aa2c20a9b8..e5759685eb 100644 --- a/ABACUS.develop/source/src_pw/energy.h +++ b/ABACUS.develop/source/src_pw/energy.h @@ -16,7 +16,7 @@ class energy friend class Threshold_Elec; friend class Forces; friend class Charge; - friend class potential; + friend class Potential; friend class Occupy; friend class wavefunc; friend class eximport; diff --git a/ABACUS.develop/source/src_pw/global.cpp b/ABACUS.develop/source/src_pw/global.cpp index 784b2eb1e6..2685fcc9dc 100644 --- a/ABACUS.develop/source/src_pw/global.cpp +++ b/ABACUS.develop/source/src_pw/global.cpp @@ -28,7 +28,7 @@ xcfunc xcf; Charge_Broyden CHR; Magnetism mag; -potential pot; +Potential pot; Symmetry symm; Parallel_Grid Pgrid; //mohan add 2010-06-06 Parallel_Kpoints Pkpoints; // mohan add 2010-06-07 diff --git a/ABACUS.develop/source/src_pw/global.h b/ABACUS.develop/source/src_pw/global.h index 279516fe2d..c9039d6d78 100644 --- a/ABACUS.develop/source/src_pw/global.h +++ b/ABACUS.develop/source/src_pw/global.h @@ -54,7 +54,7 @@ extern Exx_Lip exx_lip; extern pseudopot_cell_vnl ppcell; extern xcfunc xcf; extern Charge_Broyden CHR; -extern potential pot; +extern Potential pot; extern Symmetry symm; extern Magnetism mag; extern UnitCell_pseudo ucell; diff --git a/ABACUS.develop/source/src_pw/ions.cpp b/ABACUS.develop/source/src_pw/ions.cpp index b137cbdb1d..d3faddfcd1 100644 --- a/ABACUS.develop/source/src_pw/ions.cpp +++ b/ABACUS.develop/source/src_pw/ions.cpp @@ -294,9 +294,7 @@ bool Ions::force_stress(const int &istep, int &force_step, int &stress_step) // pot.init_pot( istep, pw.strucFac ); ofs_running << " Setup the new wave functions?" << endl; - // newd() not needed now(if Q in r space, needed). wf.wfcinit(); - // mp_bcast } } else diff --git a/ABACUS.develop/source/src_pw/potential.cpp b/ABACUS.develop/source/src_pw/potential.cpp index 6d107e9638..c95cffda30 100644 --- a/ABACUS.develop/source/src_pw/potential.cpp +++ b/ABACUS.develop/source/src_pw/potential.cpp @@ -10,39 +10,39 @@ #include "H_Hartree_pw.h" #include "H_XC_pw.h" -potential::potential() +Potential::Potential() { vltot = new double[1]; vr_eff1 = new double[1]; this->out_potential = 0; } -potential::~potential() +Potential::~Potential() { delete[] vltot; delete[] vr_eff1; } -void potential::allocate(const int nrxx) +void Potential::allocate(const int nrxx) { - TITLE("potential","allocate"); + TITLE("Potential","allocate"); assert(nrxx>0); delete[] this->vltot; this->vltot = new double[nrxx]; - Memory::record("potential","vltot",nrxx,"double"); + Memory::record("Potential","vltot",nrxx,"double"); this->vr.create(NSPIN,nrxx); this->vr_eff.create(NSPIN,nrxx); - Memory::record("potential","vr",NSPIN*nrxx,"double"); - Memory::record("potential","vr_eff",NSPIN*nrxx,"double"); + Memory::record("Potential","vr",NSPIN*nrxx,"double"); + Memory::record("Potential","vr_eff",NSPIN*nrxx,"double"); delete[] this->vr_eff1; this->vr_eff1 = new double[nrxx]; - Memory::record("potential","vr_eff1",nrxx,"double"); + Memory::record("Potential","vr_eff1",nrxx,"double"); this->vnew.create(NSPIN,nrxx); - Memory::record("potential","vnew",NSPIN*nrxx,"double"); + Memory::record("Potential","vnew",NSPIN*nrxx,"double"); return; } @@ -50,13 +50,13 @@ void potential::allocate(const int nrxx) //---------------------------------------------------------- // Initializes the self consistent potential //---------------------------------------------------------- -void potential::init_pot( +void Potential::init_pot( const int &istep, // number of ionic steps ComplexMatrix &sf // structure factors ) { - TITLE("potential","init_pot"); - timer::tick("potential","init_pot"); + TITLE("Potential","init_pot"); + timer::tick("Potential","init_pot"); assert(istep>=0); @@ -213,7 +213,7 @@ void potential::init_pot( // plots //figure::picture(this->vr_eff1,pw.ncx,pw.ncy,pw.ncz); - timer::tick("potential","init_pot"); + timer::tick("Potential","init_pot"); return; } @@ -221,7 +221,7 @@ void potential::init_pot( //========================================================== // This routine computes the local potential in real space //========================================================== -void potential::set_local_pot( +void Potential::set_local_pot( double* vl_pseudo, // store the local pseudopotential const int &ntype, // number of atom types const int &ngmc, // number of |g|, g is plane wave @@ -230,8 +230,8 @@ void potential::set_local_pot( ComplexMatrix &sf // structure factors )const { - TITLE("potential","set_local_pot"); - timer::tick("potential","set_local_pot"); + TITLE("Potential","set_local_pot"); + timer::tick("Potential","set_local_pot"); complex *vg = new complex[ngmc]; @@ -266,7 +266,7 @@ void potential::set_local_pot( } //ofs_running <<" set local pseudopotential done." << endl; - timer::tick("potential","set_local_pot"); + timer::tick("Potential","set_local_pot"); return; } @@ -276,16 +276,16 @@ void potential::set_local_pot( // The XC potential is computed in real space, while the // Hartree potential is computed in reciprocal space. //========================================================== -void potential::v_of_rho +void Potential::v_of_rho ( double **rho_in, matrix &v_in ) { - TITLE("potential","v_of_rho"); + TITLE("Potential","v_of_rho"); v_in.zero_out(); - timer::tick("potential","v_of_rho",'E'); + timer::tick("Potential","v_of_rho",'E'); //---------------------------------------------------------- // calculate the exchange-correlation potential @@ -311,7 +311,7 @@ void potential::v_of_rho EFID.add_efield(rho_in[is], &v_in.c[is*pw.nrxx]); } } - timer::tick("potential","v_of_rho",'E'); + timer::tick("Potential","v_of_rho",'E'); return; } //end subroutine v_of_rho @@ -323,10 +323,10 @@ void potential::v_of_rho // part and the sum of all the local pseudopotential // contributions. //========================================================== -void potential::set_vr_eff(void) +void Potential::set_vr_eff(void) { - TITLE("potential","set_vr_eff"); - timer::tick("potential","set_vr_eff"); + TITLE("Potential","set_vr_eff"); + timer::tick("Potential","set_vr_eff"); for (int is = 0;is < NSPIN;is++) { @@ -349,15 +349,15 @@ void potential::set_vr_eff(void) } } - timer::tick("potential","set_vr_eff"); + timer::tick("Potential","set_vr_eff"); return; } // ---------------------------------------------------------------------- -void potential::newd(void) +void Potential::newd(void) { - if (test_potential) TITLE("potential","newd"); + TITLE("Potential","newd"); // distringuish non-local pseudopotential in REAL or RECIPROCAL space. // if in real space, call new_r @@ -411,7 +411,8 @@ void potential::newd(void) ppcell.deeq_nc(is, iat, jh, ih) = ppcell.dvan(it, ih, jh); } } - else{ + else + { ppcell.deeq(is, iat, ih, jh) = ppcell.dvan(it, ih, jh); ppcell.deeq(is, iat, jh, ih) = ppcell.dvan(it, ih, jh); } diff --git a/ABACUS.develop/source/src_pw/potential.h b/ABACUS.develop/source/src_pw/potential.h index 23bf74b177..3580c2a668 100644 --- a/ABACUS.develop/source/src_pw/potential.h +++ b/ABACUS.develop/source/src_pw/potential.h @@ -3,7 +3,7 @@ #include "tools.h" -class potential +class Potential { public: @@ -12,8 +12,8 @@ class potential friend class ELEC_scf; // constructor and deconstructor - potential(); - ~potential(); + Potential(); + ~Potential(); //========================================================== // start_pot : "atomic" or "file" diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h index 72318af3f1..c1d80e7eb1 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h +++ b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h @@ -25,7 +25,7 @@ class pseudopot_cell_vnl: public pseudopot_cell_vl friend class Stress_Func; friend class Forces; friend class Epsilon0_vasp; - friend class potential; + friend class Potential; friend class Hamilt_PW; friend class WF_atomic; friend class wavefunc; From 7e83012fc3a4fc165b53b9c91802567269e4e6cd Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 17 Mar 2021 21:26:26 +0800 Subject: [PATCH 218/233] add some notes in soc --- ABACUS.develop/source/src_pw/soc.cpp | 284 +++++++++++++++------------ ABACUS.develop/source/src_pw/soc.h | 4 +- 2 files changed, 161 insertions(+), 127 deletions(-) diff --git a/ABACUS.develop/source/src_pw/soc.cpp b/ABACUS.develop/source/src_pw/soc.cpp index b42dec8169..0b0f5cf938 100644 --- a/ABACUS.develop/source/src_pw/soc.cpp +++ b/ABACUS.develop/source/src_pw/soc.cpp @@ -37,108 +37,117 @@ void Fcoef::create(const int i1, const int i2, const int i3) Soc::Soc() { - m_loc = new Vector3 [1]; - angle1 = new double[1]; - angle2 = new double[1]; + m_loc = new Vector3 [1]; + angle1 = new double[1]; + angle2 = new double[1]; p_rot = new complex [1]; } Soc::~Soc() { - delete[] m_loc; - delete[] angle1; - delete[] angle2; + delete[] m_loc; + delete[] angle1; + delete[] angle2; delete[] p_rot; -// deallocate1(); } void Soc::init() { - return; } + double Soc::spinor(const int l, const double j, const int m, const int spin) { - double den; // denominator - double spinor0; - - if (spin!=0&&spin!=1) WARNING_QUIT("spinor","spin direction unknown"); - if (m<-l-1||m>l) WARNING_QUIT("spinor","m not allowed"); - - den = 1.0/(2.0*l+1.0); - if (fabs(j-l-0.50)<1e-8) { - //j == l+0.5 - if (spin==0) spinor0= sqrt((l+m+1.0)*den); - if (spin==1) spinor0= sqrt((l-m)*den); - } - else if (fabs(j-l+0.50)<1e-8){ - //j == l-0.5 - if (m<-l+1) - spinor0=0.0; - else - { - if (spin==0) spinor0= sqrt((l-m+1.0)*den); - if (spin==1) spinor0= -sqrt((l+m)*den); - } - } - else - { - WARNING_QUIT("soc::spinor","j and l not compatible"); - } - - return spinor0; + double den; // denominator + double spinor0; + + if (spin!=0&&spin!=1) WARNING_QUIT("spinor","spin direction unknown"); + if (m<-l-1||m>l) WARNING_QUIT("spinor","m not allowed"); + + den = 1.0/(2.0*l+1.0); + if (fabs(j-l-0.50)<1e-8) + { + //j == l+0.5 + if (spin==0) + { + spinor0= sqrt((l+m+1.0)*den); + } + if (spin==1) + { + spinor0= sqrt((l-m)*den); + } + } + else if (fabs(j-l+0.50)<1e-8){ + //j == l-0.5 + if (m<-l+1) + { + spinor0=0.0; + } + else + { + if (spin==0) spinor0= sqrt((l-m+1.0)*den); + if (spin==1) spinor0= -sqrt((l+m)*den); + } + } + else + { + WARNING_QUIT("soc::spinor","j and l not compatible"); + } + + return spinor0; } void Soc::rot_ylm(const int lmax) { int m,n,l; -// this->rotylm = new complex* [2*lmax +1]; -// for(int i=0;i< 2 * lmax + 1; i++){ -// this->rotylm[i] = new complex [2*lmax +1]; -// for(int j = 0;j< 2 * lmax + 1;j++){ -// this->rotylm[i][j] = complex(0.0,0.0) ; -// } -// } + // this->rotylm = new complex* [2*lmax +1]; + // for(int i=0;i< 2 * lmax + 1; i++){ + // this->rotylm[i] = new complex [2*lmax +1]; + // for(int j = 0;j< 2 * lmax + 1;j++){ + // this->rotylm[i][j] = complex(0.0,0.0) ; + // } + // } this->l_max = 2 * lmax + 1; delete[] p_rot; this->p_rot = new complex [this->l_max * this->l_max]; ZEROS(p_rot, this->l_max*this->l_max); - this->rotylm(0,lmax) = complex(1.0, 0.0); - - l = lmax; - for(int i=1;i<2*l+1;i += 2) - { - m = (i+1)/2; - n = l-m; - this->rotylm(i,n) = complex(pow(-1.0 , m) / sqrt(2) , 0.0); - this->rotylm(i+1,n) = complex(0.0,-pow(-1.0 , m)/sqrt(2)); - n = l+m; - this->rotylm(i,n) = complex(1.0/sqrt(2), 0.0); - this->rotylm(i+1,n) = complex(0.0, 1.0/sqrt(2)); - } - return; + this->rotylm(0,lmax) = complex(1.0, 0.0); + + l = lmax; + for(int i=1;i<2*l+1;i += 2) + { + m = (i+1)/2; + n = l-m; + this->rotylm(i,n) = complex(pow(-1.0 , m) / sqrt(2) , 0.0); + this->rotylm(i+1,n) = complex(0.0,-pow(-1.0 , m)/sqrt(2)); + n = l+m; + this->rotylm(i,n) = complex(1.0/sqrt(2), 0.0); + this->rotylm(i+1,n) = complex(0.0, 1.0/sqrt(2)); + } + return; } + /*void Soc::allocate_fcoef(const int nhm,const int nt) -{ - //allocate - fcoef = new complex ****[nt]; - for(int i=0;i ***[2]; - for(int j=0;j<2;j++){ - fcoef[i][j] = new complex **[2]; - for(int k=0;k *[nhm]; - for(int l=0;l [nhm]; - for(int m=0;m(0.0,0.0); - } - } - } - } - } - return; + { +//allocate +fcoef = new complex ****[nt]; +for(int i=0;i ***[2]; +for(int j=0;j<2;j++){ +fcoef[i][j] = new complex **[2]; +for(int k=0;k *[nhm]; +for(int l=0;l [nhm]; +for(int m=0;m(0.0,0.0); +} +} +} +} +} +return; }*/ int Soc::sph_ind(const int l, const double j, const int m, const int spin) @@ -149,69 +158,95 @@ int Soc::sph_ind(const int l, const double j, const int m, const int spin) // Spin selects the up (spin=1) or down (spin=2) coefficient. int sph_ind0; if (spin != 0 && spin!= 1) + { WARNING_QUIT("sph_ind","spin must be 0 1"); + } if (m< -l-1 || m> l) + { WARNING_QUIT("sph_ind","m not allowed"); - if (fabs(j-l-0.5)< 1e-8){ + } + if (fabs(j-l-0.5)< 1e-8) + { if(spin == 0) sph_ind0 = m; if(spin == 1) sph_ind0 = m+1; } - else if (fabs(j-l+0.5)<1e-8 ){ - if(m<-l+1) sph_ind0 = 0; - else { - if(spin ==0) sph_ind0 = m-1; - if(spin ==1) sph_ind0 = m; + else if (fabs(j-l+0.5)<1e-8 ) + { + if(m<-l+1) + { + sph_ind0 = 0; + } + else + { + if(spin ==0) + { + sph_ind0 = m-1; + } + if(spin ==1) + { + sph_ind0 = m; + } } } - else { - cout<<"l= "<l )sph_ind0 =0; + else + { + cout<<"l= "<l ) + { + sph_ind0 =0; + } return sph_ind0; } + void Soc::cal_ux(const int ntype) { - double amag, uxmod; - int starting_it; - bool is_paraller; - //do not sign feature in teh general case - lsign = false; - ZEROS(ux, 3); - - starting_it = 0; - for(int it = 0;it 1e-6) - { - ux[0] = m_loc[it].x; - ux[1] = m_loc[it].y; - ux[2] = m_loc[it].z; - starting_it = it; - lsign = true; - break; - } - } - //initial magnetizations should be parallel - for(int it = starting_it+1; it 1e-6) + { + ux[0] = m_loc[it].x; + ux[1] = m_loc[it].y; + ux[2] = m_loc[it].z; + starting_it = it; + lsign = true; + break; + } + } + //initial magnetizations should be parallel + for(int it = starting_it+1; it b) { bool jp=false; @@ -220,4 +255,3 @@ bool Soc::judge_parallel(double a[3], Vector3 b) jp = (fabs(cross)<1e-6); return jp; } - diff --git a/ABACUS.develop/source/src_pw/soc.h b/ABACUS.develop/source/src_pw/soc.h index 9bae52bcc2..953aef7255 100644 --- a/ABACUS.develop/source/src_pw/soc.h +++ b/ABACUS.develop/source/src_pw/soc.h @@ -23,7 +23,7 @@ class Fcoef void create(const int i1, const int i2, const int i3); -// void free(); +// void free(); private: @@ -48,7 +48,7 @@ class Soc int sph_ind(const int l, const double j, const int m, const int spin); void rot_ylm(const int lmax); - // complex **rotylm; + // complex **rotylm; complex *p_rot; From 139ab461c6c8d26c6ac0661dc3a599f4ecc3ee7e Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 17 Mar 2021 21:41:33 +0800 Subject: [PATCH 219/233] change hpw.init to hpw.allocate --- ABACUS.develop/source/run_pw.cpp | 3 ++- .../source/src_ions/variable_cell.cpp | 2 +- ABACUS.develop/source/src_pw/hamilt.cpp | 23 +------------------ ABACUS.develop/source/src_pw/hamilt_pw.cpp | 23 ++++++++++++------- ABACUS.develop/source/src_pw/wavefunc.cpp | 2 +- 5 files changed, 20 insertions(+), 33 deletions(-) diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp index d676a5cecf..d8a9a0a078 100644 --- a/ABACUS.develop/source/run_pw.cpp +++ b/ABACUS.develop/source/run_pw.cpp @@ -92,8 +92,9 @@ void Run_pw::plane_wave_line(void) //===================== // init hamiltonian + // only allocate in the beginning of ELEC LOOP! //===================== - hm.hpw.init(wf.npwx, NPOL, ppcell.nkb, pw.nrxx); + hm.hpw.allocate(wf.npwx, NPOL, ppcell.nkb, pw.nrxx); //================================= // initalize local pseudopotential diff --git a/ABACUS.develop/source/src_ions/variable_cell.cpp b/ABACUS.develop/source/src_ions/variable_cell.cpp index f8034f5e90..568b19b7e1 100644 --- a/ABACUS.develop/source/src_ions/variable_cell.cpp +++ b/ABACUS.develop/source/src_ions/variable_cell.cpp @@ -143,7 +143,7 @@ void Variable_Cell::final_calculation_after_vc(void) //===================== // init hamiltonian //===================== - hm.hpw.init(wf.npwx, NPOL, ppcell.nkb, pw.nrxx); + hm.hpw.allocate(wf.npwx, NPOL, ppcell.nkb, pw.nrxx); //================================= // initalize local pseudopotential diff --git a/ABACUS.develop/source/src_pw/hamilt.cpp b/ABACUS.develop/source/src_pw/hamilt.cpp index 4b4619eff2..2f65ea2319 100644 --- a/ABACUS.develop/source/src_pw/hamilt.cpp +++ b/ABACUS.develop/source/src_pw/hamilt.cpp @@ -4,13 +4,7 @@ #include "diago_david.h" Hamilt::Hamilt() {} -Hamilt::~Hamilt() -{ - if(test_deconstructor) - { - cout << " ~Hamilt()" << endl; - } -} +Hamilt::~Hamilt() {} void Hamilt::diago( @@ -50,21 +44,6 @@ void Hamilt::diago( { assert(NLOCAL >= NBANDS); this->cinitcgg(ik, NLOCAL, NBANDS, wf.wanf2[ik0], wf.evc[ik0], wf.ekb[ik]); - - // for tests - /* - cout << " Check evc unit of ik = " << ik0 << endl; - for(int ib=0; ib tmpn = ZERO; - for(int ig=0; ig 0); + assert(npol > 0); + assert(nkb >=0); + assert(nrxx > 0); delete[] hpsi; delete[] spsi; @@ -49,7 +54,6 @@ void Hamilt_PW::init(const int &npwx, const int &npol, const int &nkb, const int ZEROS(this->hpsi, npwx * npol); ZEROS(this->spsi, npwx * npol); ZEROS(this->GR_index, nrxx); -// ofs_running << "\n Hamiltonian allocate done."<npwx, NPOL, ppcell.nkb, pw.nrxx); + hm.hpw.allocate(this->npwx, NPOL, ppcell.nkb, pw.nrxx); hm.hpw.init_k(ik); //hm.cinitcgg(ik ,NLOCAL, NBANDS, wvf, wvf, ekb[ik]); From aa4802b2ae9278aeda60462846766c812d47b522 Mon Sep 17 00:00:00 2001 From: mohan Date: Wed, 17 Mar 2021 22:08:56 +0800 Subject: [PATCH 220/233] add notes in ppcell.init_vnl and stress --- ABACUS.develop/source/run_pw.cpp | 2 +- .../source/src_ions/variable_cell.cpp | 4 +- ABACUS.develop/source/src_pw/global.cpp | 3 +- ABACUS.develop/source/src_pw/hamilt_pw.h | 7 +- .../source/src_pw/pseudopot_cell_vnl.cpp | 42 +- .../source/src_pw/pseudopot_cell_vnl.h | 3 +- ABACUS.develop/source/src_pw/stress.cpp | 1213 +++++++++-------- 7 files changed, 655 insertions(+), 619 deletions(-) diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp index d8a9a0a078..dfab7248f8 100644 --- a/ABACUS.develop/source/run_pw.cpp +++ b/ABACUS.develop/source/run_pw.cpp @@ -105,7 +105,7 @@ void Run_pw::plane_wave_line(void) //====================================== // Initalize non local pseudopotential //====================================== - ppcell.init_vnl(); + ppcell.init_vnl(ucell); DONE(ofs_running,"NON-LOCAL POTENTIAL"); //========================================================= diff --git a/ABACUS.develop/source/src_ions/variable_cell.cpp b/ABACUS.develop/source/src_ions/variable_cell.cpp index 568b19b7e1..c9887a643e 100644 --- a/ABACUS.develop/source/src_ions/variable_cell.cpp +++ b/ABACUS.develop/source/src_ions/variable_cell.cpp @@ -54,7 +54,7 @@ void Variable_Cell::init_after_vc(void) //====================================== if(BASIS_TYPE=="pw") { - ppcell.init_vnl(); + ppcell.init_vnl(ucell); DONE(ofs_running,"NON-LOCAL POTENTIAL"); } @@ -155,7 +155,7 @@ void Variable_Cell::final_calculation_after_vc(void) //====================================== if(BASIS_TYPE=="pw") { - ppcell.init_vnl(); + ppcell.init_vnl(ucell); DONE(ofs_running,"NON-LOCAL POTENTIAL"); } //========================================================= diff --git a/ABACUS.develop/source/src_pw/global.cpp b/ABACUS.develop/source/src_pw/global.cpp index 2685fcc9dc..7c9a3c1871 100644 --- a/ABACUS.develop/source/src_pw/global.cpp +++ b/ABACUS.develop/source/src_pw/global.cpp @@ -38,5 +38,4 @@ Vdwd3 vdwd3(ucell); // jiyy add 2019-05-18 Soc soc; //added by zhengdy-soc -Restart restart; // Peize Lin add 2020.04.04 - +Restart restart; // Peize Lin add 2020.04.04 diff --git a/ABACUS.develop/source/src_pw/hamilt_pw.h b/ABACUS.develop/source/src_pw/hamilt_pw.h index 3e2e28af9b..6113c5ae32 100644 --- a/ABACUS.develop/source/src_pw/hamilt_pw.h +++ b/ABACUS.develop/source/src_pw/hamilt_pw.h @@ -13,8 +13,11 @@ class Hamilt_PW static int moved; - // mohan updated 2021-02-22 - void init(const int &npwx, const int &npol, const int &nkb, const int &nrxx); + void allocate( + const int &npwx, // number of plane wave (max) + const int &npol, // polarization + const int &nkb, // number of non-local pseudopotential projectors + const int &nrxx); // number of grids on this processor void cal_err ( diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.cpp b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.cpp index 49f6b10980..bc06304a20 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.cpp +++ b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.cpp @@ -235,7 +235,7 @@ void pseudopot_cell_vnl::getvnl(const int &ik) -void pseudopot_cell_vnl::init_vnl(void) +void pseudopot_cell_vnl::init_vnl(UnitCell_pseudo &cell) { TITLE("pseudopot_cell_vnl","init_vnl"); timer::tick("ppcell_vnl","init_vnl"); @@ -257,16 +257,16 @@ void pseudopot_cell_vnl::init_vnl(void) this->dvan.zero_out(); this->dvan_so.zero_out();//added by zhengdy-soc soc.rot_ylm(this->lmaxkb); - soc.fcoef.create(ucell.ntype, this->nhm, this->nhm); + soc.fcoef.create(cell.ntype, this->nhm, this->nhm); - for(int it=0;itnhtol(it,BetaIndex) = l; @@ -280,7 +280,7 @@ void pseudopot_cell_vnl::init_vnl(void) // From now on the only difference between KB and US pseudopotentials // is in the presence of the q and Q functions. // Here we initialize the D of the solid - if(ucell.atoms[it].has_so ) + if(cell.atoms[it].has_so ) { for(int ip=0; ipdvan_so(ijs,it,ip,ip2) = ucell.atoms[it].dion(ir, is) * soc.fcoef(it,is1,is2,ip,ip2); + this->dvan_so(ijs,it,ip,ip2) = cell.atoms[it].dion(ir, is) * soc.fcoef(it,is1,is2,ip,ip2); ++ijs; if(ir != is) soc.fcoef(it,is1,is2,ip,ip2) = complex(0.0,0.0); } @@ -348,12 +348,12 @@ void pseudopot_cell_vnl::init_vnl(void) const int is = static_cast( indv(it, ip2) ); if(LSPINORB) { - this->dvan_so(0,it,ip,ip2) = ucell.atoms[it].dion(ir, is); - this->dvan_so(3,it,ip,ip2) = ucell.atoms[it].dion(ir, is); + this->dvan_so(0,it,ip,ip2) = cell.atoms[it].dion(ir, is); + this->dvan_so(3,it,ip,ip2) = cell.atoms[it].dion(ir, is); } else { - this->dvan(it, ip, ip2) = ucell.atoms[it].dion(ir, is); + this->dvan(it, ip, ip2) = cell.atoms[it].dion(ir, is); } } } @@ -366,13 +366,13 @@ void pseudopot_cell_vnl::init_vnl(void) // fill the interpolation table tab ************************************************************/ - const double pref = FOUR_PI / sqrt(ucell.omega); + const double pref = FOUR_PI / sqrt(cell.omega); this->tab.zero_out(); ofs_running<<"\n Init Non-Local PseudoPotential table : "; - for (int it = 0;it < ucell.ntype;it++) + for (int it = 0;it < cell.ntype;it++) { - const int nbeta = ucell.atoms[it].nbeta; - int kkbeta = ucell.atoms[it].kkbeta; + const int nbeta = cell.atoms[it].nbeta; + int kkbeta = cell.atoms[it].kkbeta; //mohan modify 2008-3-31 //mohan add kkbeta>0 2009-2-27 @@ -386,19 +386,19 @@ void pseudopot_cell_vnl::init_vnl(void) for (int ib = 0;ib < nbeta;ib++) { - const int l = ucell.atoms[it].lll[ib]; + const int l = cell.atoms[it].lll[ib]; for (int iq=0; iqtab(it, ib, iq) = vqint * pref; } } diff --git a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h index c1d80e7eb1..4d69f64b0b 100644 --- a/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h +++ b/ABACUS.develop/source/src_pw/pseudopot_cell_vnl.h @@ -9,6 +9,7 @@ #include "pseudopot_cell_vl.h" #include "../src_lcao/ORB_gen_tables.h" #include "wavefunc_in_pw.h" +#include "unitcell_pseudo.h" //========================================================== // Calculate the non-local pseudopotential in reciprocal @@ -41,7 +42,7 @@ class pseudopot_cell_vnl: public pseudopot_cell_vl // NAME : lmaxkb(max angular momentum,(see pseudo_h)) int lmaxkb; - void init_vnl(void); + void init_vnl(UnitCell_pseudo &cell); private: diff --git a/ABACUS.develop/source/src_pw/stress.cpp b/ABACUS.develop/source/src_pw/stress.cpp index 95ee408595..4c5bc8c9d6 100644 --- a/ABACUS.develop/source/src_pw/stress.cpp +++ b/ABACUS.develop/source/src_pw/stress.cpp @@ -226,8 +226,10 @@ void Stress::printstress_total (bool ry) } -void Stress::stres_knl() +void Stress::stres_knl(void) { + TITLE("Stress","stres_nkl"); + double *kfac; double **gk; gk=new double* [3]; @@ -235,7 +237,6 @@ void Stress::stres_knl() int ik,l,m,i,j,ibnd,is; int npw; - tbsp=2.0/sqrt(PI); int npwx=0; @@ -388,266 +389,298 @@ void Stress::stres_knl() -void Stress::stres_har(){ - - double shart,g2; - const double eps=1e-8; - int is,ig,l,m,nspin0; - -/* for(l=0;l<3;l++){ - for(m=0;m<3;m++){ - sigmahar[l][m]=0.0; - } - }*/ - - - complex *Porter = UFFT.porter; - - // Hartree potential VH(r) from n(r) - ZEROS( Porter, pw.nrxx ); - for(int is=0; is( CHR.rho[is][ir], 0.0 ); - } - } - //============================= - // bring rho (aux) to G space - //============================= - pw.FFT_chg.FFT3D(Porter, -1); - - complex *psic = new complex [pw.nrxx]; - double *psic0 = new double[pw.nrxx]; - ZEROS( psic0, pw.nrxx); - for(int is=0; is(psic0[ir], 0.0); - } - } +void Stress::stres_har(void) +{ + TITLE("Stress","stres_har"); - pw.FFT_chg.FFT3D(psic, -1) ; + double shart,g2; + const double eps=1e-8; + int is,ig,l,m,nspin0; + /* for(l=0;l<3;l++){ + for(m=0;m<3;m++){ + sigmahar[l][m]=0.0; + } + }*/ - double charge; - if (pw.gstart == 1) - { - charge = ucell.omega * Porter[pw.ig2fftc[0]].real(); - } + complex *Porter = UFFT.porter; - complex *vh_g = new complex[pw.ngmc]; - ZEROS(vh_g, pw.ngmc); - - double g[3]; -//test - // int i=pw.gstart; - // cout<< "gstart " <= 1.0e-12) //LiuXh 20180410 - { - const double fac = e2 * FOUR_PI / (ucell.tpiba2 * pw.gg [ig]); - - ehart += ( conj( Porter[j] ) * Porter[j] ).real() * fac; -// vh_g[ig] = fac * Porter[j]; - shart= ( conj( Porter[j] ) * Porter[j] ).real()/(ucell.tpiba2 * pw.gg [ig]); - g[0]=pw.gcar[ig].x; - g[1]=pw.gcar[ig].y; - g[2]=pw.gcar[ig].z; - //test - - //cout<<"g "<( CHR.rho[is][ir], 0.0 ); + } + } + //============================= + // bring rho (aux) to G space + //============================= + pw.FFT_chg.FFT3D(Porter, -1); + + complex *psic = new complex [pw.nrxx]; + double *psic0 = new double[pw.nrxx]; + ZEROS( psic0, pw.nrxx); + for(int is=0; is(psic0[ir], 0.0); + } + } - } - Parallel_Reduce::reduce_double_pool( ehart ); - ehart *= 0.5 * ucell.omega; - //cout<<"ehart "< *vh_g = new complex[pw.ngmc]; + ZEROS(vh_g, pw.ngmc); + + double g[3]; + //test + // int i=pw.gstart; + // cout<< "gstart " <= 1.0e-12) //LiuXh 20180410 + { + const double fac = e2 * FOUR_PI / (ucell.tpiba2 * pw.gg [ig]); + + ehart += ( conj( Porter[j] ) * Porter[j] ).real() * fac; + // vh_g[ig] = fac * Porter[j]; + + shart= ( conj( Porter[j] ) * Porter[j] ).real()/(ucell.tpiba2 * pw.gg [ig]); + + g[0]=pw.gcar[ig].x; + g[1]=pw.gcar[ig].y; + g[2]=pw.gcar[ig].z; + //test + + //cout<<"g "< *Porter = UFFT.porter; - - ZEROS( Porter, pw.nrxx ); - for(int is=0; is(CHR.rho[is][ir], 0.0 ); - } - } - pw.FFT_chg.FFT3D(Porter, -1); - -/* complex *psic = new complex [pw.nrxx]; - double *psic0 = new double[pw.nrxx]; - ZEROS( psic0, pw.nrxx); - for(int is=0; is(psic0[ir], 0.0); - } - } + /* for(l=0;l<3;l++){ + for(m=0;m<3;m++){ + sigmaloc[l][m]=0; + } + }*/ - pw.FFT_chg.FFT3D(psic, -1) ; - */ - if(INPUT.gamma_only==1) fact=2.0; - else fact=1.0; + complex *Porter = UFFT.porter; - evloc=0.0; - double g[3]={0,0,0}; + ZEROS( Porter, pw.nrxx ); + for(int is=0; is(CHR.rho[is][ir], 0.0 ); + } + } + pw.FFT_chg.FFT3D(Porter, -1); + + /* complex *psic = new complex [pw.nrxx]; + double *psic0 = new double[pw.nrxx]; + ZEROS( psic0, pw.nrxx); + for(int is=0; is(psic0[ir], 0.0); + } + } + + pw.FFT_chg.FFT3D(psic, -1) ; + */ + + if(INPUT.gamma_only==1) fact=2.0; + else fact=1.0; + + evloc=0.0; + double g[3]={0,0,0}; + + complex *vg = new complex[pw.ngmc]; + ZEROS( vg, pw.ngmc ); + for (int it=0; itzv, dvloc); + } + else{ + // normal case: dvloc contains dV_loc(G)/dG + dvloc_of_g ( atom->msh, atom->rab, atom->r, + atom->vloc_at, atom->zv, dvloc); + } - complex *vg = new complex[pw.ngmc]; - ZEROS( vg, pw.ngmc ); - for (int it=0; itzv, dvloc); - // - } - else{ - // - // normal case: dvloc contains dV_loc(G)/dG - // - dvloc_of_g ( atom->msh, atom->rab, atom->r, - atom->vloc_at, atom->zv, dvloc); - // - } - - for( ng = 0;ng< pw.ngmc;ng++){ - const int j = pw.ig2fftc[ng]; - g[0]=pw.gcar[ng].x; - g[1]=pw.gcar[ng].y; - g[2]=pw.gcar[ng].z; - for (l = 0;l< 3;l++){ - for (m = 0; m ) - ComplexMatrix dbecp( nkb, NBANDS); - ComplexMatrix becp( nkb, NBANDS); + const int nkb = ppcell.nkb; + if(nkb == 0) return; - // vkb1: |Beta(nkb,npw)> - ComplexMatrix vkb1( nkb, wf.npwx ); - ComplexMatrix vkb0[3]; - for(int i=0;i<3;i++){ - vkb0[i].create(nkb, wf.npwx); - } - ComplexMatrix vkb2( nkb, wf.npwx ); - for (int ik = 0;ik < kv.nks;ik++) - { - for(int i=0;i<3;i++){ - vkb0[i].zero_out(); - } - vkb2.zero_out(); - - if (NSPIN==2) CURRENT_SPIN = kv.isk[ik]; - wf.npw = kv.ngk[ik]; - // generate vkb - if (ppcell.nkb > 0) - { - ppcell.getvnl(ik); - } + // dbecp: conj( -iG * ) + ComplexMatrix dbecp( nkb, NBANDS); + ComplexMatrix becp( nkb, NBANDS); - // get becp according to wave functions and vkb - // important here ! becp must set zero!! - // vkb: Beta(nkb,npw) - // becp(nkb,nbnd): - becp.zero_out(); - for (int ib=0; ib + ComplexMatrix vkb1( nkb, wf.npwx ); + ComplexMatrix vkb0[3]; + for(int i=0;i<3;i++){ + vkb0[i].create(nkb, wf.npwx); + } + ComplexMatrix vkb2( nkb, wf.npwx ); + for (int ik = 0;ik < kv.nks;ik++) + { + for(int i=0;i<3;i++){ + vkb0[i].zero_out(); + } + vkb2.zero_out(); - + if (NSPIN==2) CURRENT_SPIN = kv.isk[ik]; + wf.npw = kv.ngk[ik]; + // generate vkb + if (ppcell.nkb > 0) + { + ppcell.getvnl(ik); + } - for(int i=0;i<3;i++) { - get_dvnl1(vkb0[i],ik,i); - } - - get_dvnl2(vkb2,ik); - - Vector3 qvec; - double qvec0[3]; - - for (int ipol = 0; ipol<3; ipol++) - { - for(int jpol = 0; jpol < ipol+1; jpol++) - { - dbecp.zero_out(); - vkb1.zero_out(); - for (int i = 0;i < nkb;i++) - { - - for (int ig=0; ig + becp.zero_out(); + for (int ib=0; ib 1e-8) qm1 = 1.0 / qvec.norm(); - else qm1 = 0; - dbecp(i,ib) += -2.0 * wf.evc[ik](ib,ig) * conj(vkb2(i,ig)) * qvec0[ipol] * qvec0[jpol] * qm1 * ucell.tpiba; - }//end ig - }//end i - }//end ib - - -// don't need to reduce here, keep dbecp different in each processor, -// and at last sum up all the forces. -// Parallel_Reduce::reduce_complex_double_pool( dbecp.ptr, dbecp.ndata); - -// double *cf = new double[ucell.nat*3]; -// ZEROS(cf, ucell.nat); - for (int ib=0; ibprint(ofs_running, "nonlocal stress", stresnl); - timer::tick("Stress","stres_nl"); - return; + for(int i=0;i<3;i++) { + get_dvnl1(vkb0[i],ik,i); + } + + get_dvnl2(vkb2,ik); + + Vector3 qvec; + double qvec0[3]; + + for (int ipol = 0; ipol<3; ipol++) + { + for(int jpol = 0; jpol < ipol+1; jpol++) + { + dbecp.zero_out(); + vkb1.zero_out(); + for (int i = 0;i < nkb;i++) + { + + for (int ig=0; ig 1e-8) qm1 = 1.0 / qvec.norm(); + else qm1 = 0; + dbecp(i,ib) += -2.0 * wf.evc[ik](ib,ig) * conj(vkb2(i,ig)) * qvec0[ipol] * qvec0[jpol] * qm1 * ucell.tpiba; + }//end ig + }//end i + }//end ib + + + // don't need to reduce here, keep dbecp different in each processor, + // and at last sum up all the forces. + // Parallel_Reduce::reduce_complex_double_pool( dbecp.ptr, dbecp.ndata); + + // double *cf = new double[ucell.nat*3]; + // ZEROS(cf, ucell.nat); + for (int ib=0; ibprint(ofs_running, "nonlocal stress", stresnl); + timer::tick("Stress","stres_nl"); + return; } void Stress::get_dvnl1( - ComplexMatrix &vkb, - const int ik, - const int ipol) + ComplexMatrix &vkb, + const int ik, + const int ipol) { - if(test_pp) TITLE("Stress","get_dvnl1"); -// timer::tick("Stress","get_dvnl1"); + if(test_pp) TITLE("Stress","get_dvnl1"); + // timer::tick("Stress","get_dvnl1"); - const int lmaxkb = ppcell.lmaxkb; - if(lmaxkb < 0) - { - return; - } + const int lmaxkb = ppcell.lmaxkb; + if(lmaxkb < 0) + { + return; + } - const int npw = kv.ngk[ik]; - const int nhm = ppcell.nhm; - int ig, ia, nb, ih; - matrix vkb1(nhm, npw); - vkb1.zero_out(); - double *vq = new double[npw]; - const int x1= (lmaxkb + 1)*(lmaxkb + 1); - - matrix dylm(x1, npw); - Vector3 *gk = new Vector3[npw]; - for (ig = 0;ig < npw;ig++) - { - gk[ig] = wf.get_1qvec_cartesian(ik, ig); - } - - dylmr2(x1, npw, gk, dylm, ipol); + const int npw = kv.ngk[ik]; + const int nhm = ppcell.nhm; + int ig, ia, nb, ih; + matrix vkb1(nhm, npw); + vkb1.zero_out(); + double *vq = new double[npw]; + const int x1= (lmaxkb + 1)*(lmaxkb + 1); + + matrix dylm(x1, npw); + Vector3 *gk = new Vector3[npw]; + for (ig = 0;ig < npw;ig++) + { + gk[ig] = wf.get_1qvec_cartesian(ik, ig); + } - int jkb = 0; - for(int it = 0;it < ucell.ntype;it++) - { - if(test_pp>1) OUT("it",it); - // calculate beta in G-space using an interpolation table - const int nbeta = ucell.atoms[it].nbeta; - const int nh = ucell.atoms[it].nh; + dylmr2(x1, npw, gk, dylm, ipol); + + int jkb = 0; + for(int it = 0;it < ucell.ntype;it++) + { + if(test_pp>1) OUT("it",it); + // calculate beta in G-space using an interpolation table + const int nbeta = ucell.atoms[it].nbeta; + const int nh = ucell.atoms[it].nh; - if(test_pp>1) OUT("nbeta",nbeta); + if(test_pp>1) OUT("nbeta",nbeta); - for (nb = 0;nb < nbeta;nb++) - { - if(test_pp>1) OUT("ib",nb); - for (ig = 0;ig < npw;ig++) - { - const double gnorm = gk[ig].norm() * ucell.tpiba; + for (nb = 0;nb < nbeta;nb++) + { + if(test_pp>1) OUT("ib",nb); + for (ig = 0;ig < npw;ig++) + { + const double gnorm = gk[ig].norm() * ucell.tpiba; -// cout << "\n gk[ig] = " << gk[ig].x << " " << gk[ig].y << " " << gk[ig].z; -// cout << "\n gk.norm = " << gnorm; + // cout << "\n gk[ig] = " << gk[ig].x << " " << gk[ig].y << " " << gk[ig].z; + // cout << "\n gk.norm = " << gnorm; - vq [ig] = Mathzone::Polynomial_Interpolation( - ppcell.tab, it, nb, NQX, DQ, gnorm ); + vq [ig] = Mathzone::Polynomial_Interpolation( + ppcell.tab, it, nb, NQX, DQ, gnorm ); - } // enddo + } // enddo - // add spherical harmonic part - for (ih = 0;ih < nh;ih++) - { - if (nb == ppcell.indv(it, ih)) - { - const int lm = static_cast( ppcell.nhtolm(it, ih) ); - for (ig = 0;ig < npw;ig++) - { - vkb1(ih, ig) = dylm(lm, ig) * vq [ig]; - } + // add spherical harmonic part + for (ih = 0;ih < nh;ih++) + { + if (nb == ppcell.indv(it, ih)) + { + const int lm = static_cast( ppcell.nhtolm(it, ih) ); + for (ig = 0;ig < npw;ig++) + { + vkb1(ih, ig) = dylm(lm, ig) * vq [ig]; + } - } + } - } // end ih + } // end ih - } // end nbeta + } // end nbeta - // vkb1 contains all betas including angular part for type nt - // now add the structure factor and factor (-i)^l - for (ia=0; ia *sk = wf.get_sk(ik, it, ia); - for (ih = 0;ih < nh;ih++) - { - complex pref = pow( NEG_IMAG_UNIT, ppcell.nhtol(it, ih)); //? - for (ig = 0;ig < npw;ig++) - { - vkb(jkb, ig) = vkb1(ih, ig) * sk [ig] * pref; - } - ++jkb; - } // end ih - delete [] sk; - } // end ia - } // enddo - delete [] gk; - delete [] vq; - //timer::tick("Stress","get_dvnl1"); - return; + // vkb1 contains all betas including angular part for type nt + // now add the structure factor and factor (-i)^l + for (ia=0; ia *sk = wf.get_sk(ik, it, ia); + for (ih = 0;ih < nh;ih++) + { + complex pref = pow( NEG_IMAG_UNIT, ppcell.nhtol(it, ih)); //? + for (ig = 0;ig < npw;ig++) + { + vkb(jkb, ig) = vkb1(ih, ig) * sk [ig] * pref; + } + ++jkb; + } // end ih + delete [] sk; + } // end ia + } // enddo + delete [] gk; + delete [] vq; + //timer::tick("Stress","get_dvnl1"); + return; }//end get_dvnl1 -void Stress::get_dvnl2(ComplexMatrix &vkb, - const int ik) + +void Stress::get_dvnl2( + ComplexMatrix &vkb, + const int ik) { - if(test_pp) TITLE("Stress","get_dvnl2"); - timer::tick("Stress","get_dvnl2"); + if(test_pp) TITLE("Stress","get_dvnl2"); + timer::tick("Stress","get_dvnl2"); - const int lmaxkb = ppcell.lmaxkb; - if(lmaxkb < 0) - { - return; - } + const int lmaxkb = ppcell.lmaxkb; + if(lmaxkb < 0) + { + return; + } - const int npw = kv.ngk[ik]; - const int nhm = ppcell.nhm; - int ig, ia, nb, ih; - matrix vkb1(nhm, npw); - double *vq = new double[npw]; - const int x1= (lmaxkb + 1)*(lmaxkb + 1); + const int npw = kv.ngk[ik]; + const int nhm = ppcell.nhm; + int ig, ia, nb, ih; + matrix vkb1(nhm, npw); + double *vq = new double[npw]; + const int x1= (lmaxkb + 1)*(lmaxkb + 1); - matrix ylm(x1, npw); - Vector3 *gk = new Vector3[npw]; - for (ig = 0;ig < npw;ig++) - { - gk[ig] = wf.get_1qvec_cartesian(ik, ig); - } - Mathzone::Ylm_Real(x1, npw, gk, ylm); + matrix ylm(x1, npw); + Vector3 *gk = new Vector3[npw]; + for (ig = 0;ig < npw;ig++) + { + gk[ig] = wf.get_1qvec_cartesian(ik, ig); + } + Mathzone::Ylm_Real(x1, npw, gk, ylm); - int jkb = 0; - for(int it = 0;it < ucell.ntype;it++) - { - if(test_pp>1) OUT("it",it); - // calculate beta in G-space using an interpolation table - const int nbeta = ucell.atoms[it].nbeta; - const int nh = ucell.atoms[it].nh; + int jkb = 0; + for(int it = 0;it < ucell.ntype;it++) + { + if(test_pp>1) OUT("it",it); + // calculate beta in G-space using an interpolation table + const int nbeta = ucell.atoms[it].nbeta; + const int nh = ucell.atoms[it].nh; - if(test_pp>1) OUT("nbeta",nbeta); + if(test_pp>1) OUT("nbeta",nbeta); - for (nb = 0;nb < nbeta;nb++) - { - if(test_pp>1) OUT("ib",nb); - for (ig = 0;ig < npw;ig++) - { - const double gnorm = gk[ig].norm() * ucell.tpiba; - -// cout << "\n gk[ig] = " << gk[ig].x << " " << gk[ig].y << " " << gk[ig].z; -// cout << "\n gk.norm = " << gnorm; - vq [ig] = Polynomial_Interpolation_nl( - ppcell.tab, it, nb, DQ, gnorm ); - - } // enddo - - // add spherical harmonic part - for (ih = 0;ih < nh;ih++) - { - if (nb == ppcell.indv(it, ih)) - { - const int lm = static_cast( ppcell.nhtolm(it, ih) ); - for (ig = 0;ig < npw;ig++) - { - vkb1(ih, ig) = ylm(lm, ig) * vq [ig]; - } - } - } // end ih - } // end nbeta - - // vkb1 contains all betas including angular part for type nt - // now add the structure factor and factor (-i)^l - for (ia=0; ia *sk = wf.get_sk(ik, it, ia); - for (ih = 0;ih < nh;ih++) - { - complex pref = pow( NEG_IMAG_UNIT, ppcell.nhtol(it, ih)); //? - for (ig = 0;ig < npw;ig++) - { - vkb(jkb, ig) = vkb1(ih, ig) * sk [ig] * pref; - } - ++jkb; - } // end ih - delete [] sk; - - } // end ia - } // enddo - - delete [] gk; - delete [] vq; - timer::tick("Stress","get_dvnl2"); + for (nb = 0;nb < nbeta;nb++) + { + if(test_pp>1) OUT("ib",nb); + for (ig = 0;ig < npw;ig++) + { + const double gnorm = gk[ig].norm() * ucell.tpiba; - return; -} + // cout << "\n gk[ig] = " << gk[ig].x << " " << gk[ig].y << " " << gk[ig].z; + // cout << "\n gk.norm = " << gnorm; + vq [ig] = Polynomial_Interpolation_nl( + ppcell.tab, it, nb, DQ, gnorm ); + } // enddo + // add spherical harmonic part + for (ih = 0;ih < nh;ih++) + { + if (nb == ppcell.indv(it, ih)) + { + const int lm = static_cast( ppcell.nhtolm(it, ih) ); + for (ig = 0;ig < npw;ig++) + { + vkb1(ih, ig) = ylm(lm, ig) * vq [ig]; + } + } + } // end ih + } // end nbeta + + // vkb1 contains all betas including angular part for type nt + // now add the structure factor and factor (-i)^l + for (ia=0; ia *sk = wf.get_sk(ik, it, ia); + for (ih = 0;ih < nh;ih++) + { + complex pref = pow( NEG_IMAG_UNIT, ppcell.nhtol(it, ih)); //? + for (ig = 0;ig < npw;ig++) + { + vkb(jkb, ig) = vkb1(ih, ig) * sk [ig] * pref; + } + ++jkb; + } // end ih + delete [] sk; + + } // end ia + } // enddo + + delete [] gk; + delete [] vq; + timer::tick("Stress","get_dvnl2"); + + return; +} double Stress::Polynomial_Interpolation_nl From 40931448faad0431728d6c872f92b22556c7d8b6 Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 19 Mar 2021 00:06:51 +0800 Subject: [PATCH 221/233] updates for LOOP_ions --- .../source/src_ions/variable_cell.cpp | 43 ++----- ABACUS.develop/source/src_lcao/LOOP_ions.cpp | 85 +++++-------- ABACUS.develop/source/src_lcao/LOOP_ions.h | 12 -- ABACUS.develop/source/src_pw/charge.cpp | 16 ++- .../source/src_pw/stress_func_cc.cpp | 52 +++++--- ABACUS.develop/source/src_pw/wavefunc.cpp | 115 ++++++++---------- 6 files changed, 147 insertions(+), 176 deletions(-) diff --git a/ABACUS.develop/source/src_ions/variable_cell.cpp b/ABACUS.develop/source/src_ions/variable_cell.cpp index c9887a643e..009e700837 100644 --- a/ABACUS.develop/source/src_ions/variable_cell.cpp +++ b/ABACUS.develop/source/src_ions/variable_cell.cpp @@ -1,21 +1,10 @@ #include "variable_cell.h" #include "../src_pw/global.h" #include "../input.h" -//#include "src_pw/algorithms.h" -//#include "src_pw/pseudopot_cell_us.h" -//#include "src_pw/optical.h" -//#include "src_pw/cal_test.h" -//#include "src_lcao/dftu.h" //Quxin add for DFT+U on 20201029 -//#include "src_pw/winput.h" -//#include "src_lcao/sltk_atom_arrange.h" Variable_Cell::Variable_Cell(){} Variable_Cell::~Variable_Cell(){} - -//LiuXh add a new function here, -//which is used to do initialization after variable cell -//20180515 void Variable_Cell::init_after_vc(void) { TITLE("Variable_Cell","init_after_vc"); @@ -58,20 +47,10 @@ void Variable_Cell::init_after_vc(void) DONE(ofs_running,"NON-LOCAL POTENTIAL"); } -/* - pot.init_pot(0); - - ofs_running << " Setup the new wave functions?" << endl; - wf.wfcinit(); -*/ - return; } -//LiuXh add a new function here, -//which is used to do initialization after variable cell -//20180619 void Variable_Cell::final_calculation_after_vc(void) { TITLE("Variable_Cell","final_after_vc"); @@ -116,13 +95,15 @@ void Variable_Cell::final_calculation_after_vc(void) // init the grid, then the charge // on grid can be distributed. - Pgrid.init_final_scf(pw.ncx, pw.ncy, pw.ncz, pw.nczp, pw.nrxx, pw.nbz, pw.bz); // mohan add 2010-07-22, update 2011-05-04 + Pgrid.init_final_scf(pw.ncx, pw.ncy, pw.ncz, + pw.nczp, pw.nrxx, pw.nbz, pw.bz); // mohan add 2010-07-22, update 2011-05-04 //===================== // init potential //===================== CHR.init_final_scf(); pot.allocate(pw.nrxx); + //===================== // init wave functions //===================== @@ -139,7 +120,11 @@ void Variable_Cell::final_calculation_after_vc(void) //======================= // init pseudopotential //======================= - if(BASIS_TYPE=="pw") ppcell.init(ucell.ntype); + if(BASIS_TYPE=="pw") + { + ppcell.init(ucell.ntype); + } + //===================== // init hamiltonian //===================== @@ -163,18 +148,16 @@ void Variable_Cell::final_calculation_after_vc(void) //========================================================= pot.init_pot(0, pw.strucFac);//atomic_rho, v_of_rho, set_vrs - if(BASIS_TYPE=="pw") pot.newd();//once - DONE(ofs_running,"INIT POTENTIAL"); - - //================================================== - // create ppcell.tab_at , for trial wave functions. //================================================== - if(BASIS_TYPE=="pw") wf.init_at_1(); - //================================ + // Create ppcell.tab_at , for trial wave functions. // Initial start wave functions //================================ if(BASIS_TYPE=="pw") { + pot.newd(); + + wf.init_at_1(); + wf.wfcinit(); DONE(ofs_running,"INIT BASIS"); } diff --git a/ABACUS.develop/source/src_lcao/LOOP_ions.cpp b/ABACUS.develop/source/src_lcao/LOOP_ions.cpp index e16551168f..fe58593e29 100644 --- a/ABACUS.develop/source/src_lcao/LOOP_ions.cpp +++ b/ABACUS.develop/source/src_lcao/LOOP_ions.cpp @@ -197,12 +197,6 @@ void LOOP_ions::opt_ions(void) cout << endl; } -//#ifdef __MPI //2015-09-06, xiaohui - //2015-05-07, 2015-10-01 - //atom_arrange::delete_vector( SEARCH_RADIUS ); -//#endif //2015-09-06, xiaohui - -//2015-09-16 //#ifdef __MPI // MPI_Barrier(MPI_COMM_WORLD); // for (int i=0;izv) { OUT(ofs_warning,"charge should be",atom->zv); @@ -1010,7 +1020,7 @@ double Charge::check_ne(const double *rho_in) const //LiuXh add 20180619 void Charge::init_final_scf() { - if (test_charge) TITLE("Charge","init"); + TITLE("Charge","init_after_scf"); assert(allocate_rho_final_scf == false); diff --git a/ABACUS.develop/source/src_pw/stress_func_cc.cpp b/ABACUS.develop/source/src_pw/stress_func_cc.cpp index a38d0b0701..410c0d4bc1 100644 --- a/ABACUS.develop/source/src_pw/stress_func_cc.cpp +++ b/ABACUS.develop/source/src_pw/stress_func_cc.cpp @@ -1,24 +1,36 @@ #include "./stress_func.h" #include "./H_XC_pw.h" -//NLCC term, need to be test! +//NLCC term, need to be tested void Stress_Func::stress_cc(matrix& sigma, const bool is_pw) { timer::tick("Stress_Func","stress_cc",'F'); int nt,ng,l,m,ir; double fact=1.0; - if(is_pw&&INPUT.gamma_only) fact = 2.0; //is_pw:PW basis, gamma_only need to double. + + if(is_pw&&INPUT.gamma_only) + { + fact = 2.0; //is_pw:PW basis, gamma_only need to double. + } + complex sigmadiag; double* rhocg; double g[3]; - int judge=0; - for(nt=0;nt(vxc(0, ir), 0.0); } } - else{ - for(ir=0;irinit_at_1(); this->wfcinit_k(); en.demet = 0.0; @@ -205,11 +204,6 @@ int wavefunc::get_starting_nw(void)const -//void wavefunc::PAO_in_pw_k(const int &ik, ComplexMatrix &wvf) -//{ -// TITLE("wavefunc","PAO_in_pw_k"); -// this->atomic_wfc(ik, this->npw, ucell.lmax_ppwf, wvf, ppcell.tab_at, NQX, DQ); -//} void wavefunc::LCAO_in_pw_k(const int &ik, ComplexMatrix &wvf) { @@ -219,6 +213,7 @@ void wavefunc::LCAO_in_pw_k(const int &ik, ComplexMatrix &wvf) assert(BASIS_TYPE=="lcao_in_pw"); static bool ltable = false; + if(!ltable) { this->table_local.create(ucell.ntype, ucell.nmax_total, NQX); @@ -333,7 +328,10 @@ void wavefunc::wfcinit_k(void) { TITLE("wavefunc","wfcinit_k"); - if(mem_saver) return; + if(mem_saver) + { + return; + } for(int ik=0; ik //--------------------------------------------------- - /*cout <<"epsilon = "< r,r1,r2; - + for(int iw1=0; iw1>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + //~~~~~~~~~~~~~~~~~~~~~~ 3 ~~~~~~~~~~~~~~~~~~~~~~~~~ + // Read in numerical basis for descriptor. + //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + if (INPUT.out_descriptor && BASIS_TYPE == "lcao") //condition: descriptor in lcao line + { + this->Read_Descriptor(); + } timer::tick("LCAO_Orbitals","Read_Orbitals",'C'); return; @@ -951,3 +960,254 @@ void LCAO_Orbitals::set_nl_index(void) return; } + +//caoyu add 2021-3-16 +void LCAO_Orbitals::Read_Descriptor() //read descriptor basis +{ + TITLE("LCAO_Orbitals", "Read_Descriptor"); + + ifstream in; + ofs_running << " " << setw(12) << "DESCRIPTOR" << setw(3) << "L" + << setw(3) << "N" << setw(8) << "nr" << setw(8) << "dr" + << setw(8) << "RCUT" << setw(12) << "CHECK_UNIT" + << setw(12) << "NEW_UNIT" << endl; + + // check if the descriptor file exists. + bool open = false; + if (MY_RANK == 0) + { + in.open(this->descriptor_file.c_str()); + if (in) + { + open = true; + } + } +#ifdef __MPI + Parallel_Common::bcast_bool(open); +#endif + if (!open) + { + ofs_warning << " Orbital file : " << this->descriptor_file << endl; + WARNING_QUIT("LCAO_Orbitals::Read_Descriptor", "Couldn't find orbital files for descriptor"); +} + + //read lmax and nchi[l] + int lmax = 0; + int nchi[10]={0}; + char word[80]; + if (MY_RANK == 0) + { + while (in.good()) + { + in >> word; + if (std::strcmp(word, "Lmax") == 0) + { + in >> lmax; + break; + } + } + // allocate space + // number of chi for each L. + for (int l = 0; l <= lmax; l++) + { + in >> word >> word >> word >> nchi[l]; + this->nchimax_d = std::max(this->nchimax_d, nchi[l]); + } + } + +#ifdef __MPI + Parallel_Common::bcast_int(lmax); + Parallel_Common::bcast_int(nchi, lmax + 1); +#endif + this->lmax_d = lmax; + // calculate total number of chi + int total_nchi = 0; + for (int l = 0; l <= lmax; l++) + { + total_nchi += nchi[l]; + } + //OUT(ofs_running,"Total number of chi(l,n)",total_nchi); + this->Alpha.phiLN = new Numerical_Orbital_Lm[total_nchi]; + + int meshr; // number of mesh points + int meshr_read; + double dr; + + if (MY_RANK == 0) + { + while (in.good()) + { + in >> word; + if (std::strcmp(word, "END") == 0) // Peize Lin fix bug about strcmp 2016-08-02 + { + break; + } + } + CHECK_NAME(in, "Mesh"); + in >> meshr; + meshr_read = meshr; + if (meshr % 2 == 0) + { + ++meshr; + } + CHECK_NAME(in, "dr"); + in >> dr; + } + +#ifdef __MPI + Parallel_Common::bcast_int(meshr); + Parallel_Common::bcast_int(meshr_read); + Parallel_Common::bcast_double(dr); +#endif + + int count = 0; + string name1, name2; + int tmp_l, tmp_n; + + for (int L = 0; L <= lmax; L++) + { + for (int N = 0; N < nchi[L]; N++) + { + ofs_running << " " << setw(12) << count + 1 << setw(3) << L << setw(3) << N; + + double* radial; // radial mesh + double* psi; // radial local orbital + double* psir;// psi * r + double* rab;// dr + + // set the number of mesh and the interval distance. + ofs_running << setw(8) << meshr << setw(8) << dr; + + radial = new double[meshr]; + psi = new double[meshr]; + psir = new double[meshr]; + rab = new double[meshr]; + + ZEROS(radial, meshr); + ZEROS(psi, meshr); + ZEROS(psir, meshr); + ZEROS(rab, meshr); + + for (int ir = 0; ir < meshr; ir++) + { + rab[ir] = dr; + // plus one because we can't read in r = 0 term now. + // change ir+1 to ir, because we need psi(r==0) information. + radial[ir] = ir * dr; //mohan 2010-04-19 + } + + // set the length of orbital + ofs_running << setw(8) << radial[meshr - 1]; + + // mohan update 2010-09-07 + bool find = false; + if (MY_RANK == 0) + { + while (!find) + { + if (in.eof()) + { + ofs_warning << " Can't find l=" + << L << " n=" << N << " orbital." << endl; + break; + } + + in >> name1 >> name2; + in >> tmp_l >> tmp_n; + if (L == tmp_l && N == tmp_n) + { + // meshr_read is different from meshr if meshr is even number. + for (int ir = 0; ir < meshr_read; ir++) + { + in >> psi[ir]; + /* + double rl = pow (ir*dr, l); + psi[ir] *= rl; + */ + psir[ir] = psi[ir] * radial[ir]; + } + find = true; + } + else + { + double no_use; + for (int ir = 0; ir < meshr_read; ir++) + { + in >> no_use; + } + } + }//end find + } + +#ifdef __MPI + Parallel_Common::bcast_bool(find); +#endif + if (!find) + { + WARNING_QUIT("LCAO_Orbitals::Read_Descriptor", "Can't find descriptor orbitals."); + } + +#ifdef __MPI + Parallel_Common::bcast_double(psi, meshr_read); // mohan add 2010-06-24 + Parallel_Common::bcast_double(psir, meshr_read); +#endif + + // renormalize radial wave functions + double* inner = new double[meshr]; + for (int ir = 0; ir < meshr; ir++) + { + inner[ir] = psir[ir] * psir[ir]; + } + double unit = 0.0; + Mathzone::Simpson_Integral(meshr, inner, rab, unit); + + // check unit: \sum ( psi[r] * r )^2 = 1 + ofs_running << setprecision(3) << setw(12) << unit; + + for (int ir = 0; ir < meshr; ir++) + { + psi[ir] /= sqrt(unit); + psir[ir] /= sqrt(unit); + } + + for (int ir = 0; ir < meshr; ir++) + { + inner[ir] = psir[ir] * psir[ir]; + } + Mathzone::Simpson_Integral(meshr, inner, rab, unit); + delete[] inner; + ofs_running << setw(12) << unit << endl; + + this->Alpha.phiLN[count].set_orbital_info( + "H", //any type + 1, //any type + L, //angular momentum L + N, // number of orbitals of this L + meshr, // number of radial mesh + rab, + radial,// radial mesh value(a.u.) + Numerical_Orbital_Lm::Psi_Type::Psi,// psi type next + psi, // radial wave function + this->kmesh, + this->dk, + this->dr_uniform, + true, + true); // delta k mesh in reciprocal space + + delete[] radial; + delete[] rab; + delete[] psir; + delete[] psi; + + ++count; + } + } + in.close(); + this->Alpha.set_orbital_info( + 1, // any type + "H", // any label + lmax, + nchi, + total_nchi); //copy twice ! + return; +} diff --git a/ABACUS.develop/source/src_lcao/ORB_read.h b/ABACUS.develop/source/src_lcao/ORB_read.h index d987565b11..f2495936eb 100644 --- a/ABACUS.develop/source/src_lcao/ORB_read.h +++ b/ABACUS.develop/source/src_lcao/ORB_read.h @@ -37,6 +37,8 @@ class LCAO_Orbitals void set_nl_index(void); + void Read_Descriptor(void); //caoyu add 2020-3-16 + #ifdef __MPI void bcast_files(void); #endif @@ -47,7 +49,9 @@ class LCAO_Orbitals const double& get_dR(void) const {return dR;} const double& get_Rmax(void) const {return Rmax;} const int& get_lmax(void) const {return lmax;} + const int& get_lmax_d(void) const { return lmax_d; } //lmax of descriptor basis //caoyu add 2021-03-17 const int& get_nchimax(void) const {return nchimax;} + const int& get_nchimax_d(void) const { return nchimax_d; } //nchimax of descriptor basis //caoyu add 2021-03-17 const int& get_ntype(void) const {return ntype;} const double& get_dr_uniform(void) const {return dr_uniform;} @@ -57,6 +61,10 @@ class LCAO_Orbitals // nonlocal projectors (1-dimension array) Numerical_Nonlocal* Beta; + //caoyu add 2021-3-10 + // descriptor bases, saved as one-type atom orbital + Numerical_Orbital Alpha; + // initialized in input.cpp double ecutwfc; double dk; @@ -75,12 +83,15 @@ class LCAO_Orbitals bool read_in_flag; std::vector orbital_file; std::vector nonlocal_file; + string descriptor_file; //caoyu add 2020-3-16 private: int kmesh; int lmax; int nchimax; + int lmax_d; //caoyu add 2021-03-17 + int nchimax_d; //caoyu add 2021-03-17 int ntype; }; From f8981e7db1e66382e55ebbca4b0ec17dc940ec77 Mon Sep 17 00:00:00 2001 From: mohan Date: Fri, 19 Mar 2021 23:04:17 +0800 Subject: [PATCH 223/233] move four subroutines to cell LOOP --- ABACUS.develop/source/run_lcao.cpp | 21 ---- ABACUS.develop/source/src_lcao/LOOP_cell.cpp | 24 +++++ ABACUS.develop/source/src_lcao/run_md.cpp | 23 +++++ ABACUS.develop/source/src_ri/exx_lcao.cpp | 101 ++++++++++++++++++- 4 files changed, 147 insertions(+), 22 deletions(-) diff --git a/ABACUS.develop/source/run_lcao.cpp b/ABACUS.develop/source/run_lcao.cpp index f0f9c4cb05..8ac68eea46 100644 --- a/ABACUS.develop/source/run_lcao.cpp +++ b/ABACUS.develop/source/run_lcao.cpp @@ -97,27 +97,6 @@ void Run_lcao::lcao_line(void) } - // Initialize the local wave functions. - // npwx, eigenvalues, and weights - // npwx may change according to cell change - // this function belongs to cell LOOP - wf.allocate_ekb_wg(kv.nks); - - // Initialize the FFT. - // this function belongs to cell LOOP - UFFT.allocate(); - - // output is ppcell.vloc 3D local pseudopotentials - // this function belongs to cell LOOP - ppcell.init_vloc(pw.nggm, ppcell.vloc); - - // Initialize the sum of all local potentials. - // if ion_step==0, read in/initialize the potentials - // this function belongs to ions LOOP - int ion_step=0; - pot.init_pot(ion_step, pw.strucFac); - - if(CALCULATION=="md") { Run_MD run_md; diff --git a/ABACUS.develop/source/src_lcao/LOOP_cell.cpp b/ABACUS.develop/source/src_lcao/LOOP_cell.cpp index ed0c13fedf..003b9eb7a3 100644 --- a/ABACUS.develop/source/src_lcao/LOOP_cell.cpp +++ b/ABACUS.develop/source/src_lcao/LOOP_cell.cpp @@ -3,6 +3,9 @@ #include "src_lcao/dftu.h" //Quxin add for DFT+U on 20201029 +// delete in near future +#include "src_pw/global.h" + LOOP_cell::LOOP_cell(){} LOOP_cell::~LOOP_cell(){} @@ -10,6 +13,27 @@ void LOOP_cell::opt_cell(void) { TITLE("LOOP_cell","opt_cell"); + // Initialize the local wave functions. + // npwx, eigenvalues, and weights + // npwx may change according to cell change + // this function belongs to cell LOOP + wf.allocate_ekb_wg(kv.nks); + + // Initialize the FFT. + // this function belongs to cell LOOP + UFFT.allocate(); + + // output is ppcell.vloc 3D local pseudopotentials + // this function belongs to cell LOOP + ppcell.init_vloc(pw.nggm, ppcell.vloc); + + // Initialize the sum of all local potentials. + // if ion_step==0, read in/initialize the potentials + // this function belongs to ions LOOP + int ion_step=0; + pot.init_pot(ion_step, pw.strucFac); + + // Peize Lin 2016-12-03 if (CALCULATION=="scf" || CALCULATION=="relax" || CALCULATION=="cell-relax") { diff --git a/ABACUS.develop/source/src_lcao/run_md.cpp b/ABACUS.develop/source/src_lcao/run_md.cpp index fa78f17e7f..edba9c6f8e 100644 --- a/ABACUS.develop/source/src_lcao/run_md.cpp +++ b/ABACUS.develop/source/src_lcao/run_md.cpp @@ -25,6 +25,29 @@ void Run_MD::opt_cell(void) { TITLE("Run_MD","opt_cell"); + + + + // Initialize the local wave functions. + // npwx, eigenvalues, and weights + // npwx may change according to cell change + // this function belongs to cell LOOP + wf.allocate_ekb_wg(kv.nks); + + // Initialize the FFT. + // this function belongs to cell LOOP + UFFT.allocate(); + + // output is ppcell.vloc 3D local pseudopotentials + // this function belongs to cell LOOP + ppcell.init_vloc(pw.nggm, ppcell.vloc); + + // Initialize the sum of all local potentials. + // if ion_step==0, read in/initialize the potentials + // this function belongs to ions LOOP + int ion_step=0; + pot.init_pot(ion_step, pw.strucFac); + opt_ions(); return; diff --git a/ABACUS.develop/source/src_ri/exx_lcao.cpp b/ABACUS.develop/source/src_ri/exx_lcao.cpp index b8c5252c3b..b23367168e 100644 --- a/ABACUS.develop/source/src_ri/exx_lcao.cpp +++ b/ABACUS.develop/source/src_ri/exx_lcao.cpp @@ -195,7 +195,9 @@ void Exx_Lcao::init() { const string command0 = "test -d " + dir + " || mkdir " + dir; if(MY_RANK==0) + { system( command0.c_str() ); + } }; test_dir = {"test_exx/process/","test_exx/thread/","test_exx/matrix/"}; mkdir_one("test_exx"); @@ -210,7 +212,9 @@ void Exx_Lcao::init() { ofstream ofs(file); for( size_t i=0; i!=v.size(); ++i ) + { ofs<BvK_period( kv.nmp[0], kv.nmp[1], kv.nmp[2] ); vector> boxes; for( int x=0; x!=BvK_period.x; ++x ) + { for( int y=0; y!=BvK_period.y; ++y ) + { for( int z=0; z!=BvK_period.z; ++z ) + { boxes.push_back({x,y,z}); + } + } + } cout<<"boxes:"<>(boxes[i])<<"\t"; + } cout<>(boxes[i])) )<<"\t"; + } cout<>> abfs_same_atom = Exx_Abfs::Construct_Orbs::abfs_same_atom( lcaos, this->kmesh_times, info.pca_threshold ); // Peize Lin test if(info.files_abfs.empty()) + { this->abfs = abfs_same_atom; + } else + { this->abfs = Exx_Abfs::IO::construct_abfs( abfs_same_atom, ORB, info.files_abfs, this->kmesh_times ); + } // this->abfs = Exx_Abfs::Construct_Orbs::orth_orbs( abfs_origin ); // Peize Lin test ofs_mpi<<"TIME@ Exx_Abfs::Construct_Orbs::abfs\t"<(abfs[T].size())-1 ); + } ofs_mpi<<"Exx_Abfs::Lmax:\t"<,matrix>>>> Exx_Lcao::c { const Abfs::Vector3_Order & box2 = m_tmp3.first; if( matrix*const m_all_ptr = static_cast(MAP_EXIST( m_all[is], iat1, iat2, box2 )) ) + { *m_all_ptr += m_tmp3.second; + } else + { m_all[is][iat1][iat2][box2] = std::move(m_tmp3.second); + } } } } @@ -1421,7 +1518,9 @@ vector,matrix>>>> Exx_Lcao::c auto vector_empty = []( const vector,matrix>>>> & v ) -> bool { for( const auto &i : v ) + { if(!i.empty()) return false; + } return true; }; From 727a6425c0f0fe14f2c979d759825c1ff4173397 Mon Sep 17 00:00:00 2001 From: mohan Date: Sat, 20 Mar 2021 01:01:30 +0800 Subject: [PATCH 224/233] update snap_psibeta --- .../source/src_lcao/FORCE_gamma_tvnl.cpp | 29 +++-- .../source/src_lcao/ORB_gen_tables.cpp | 118 +++++++++--------- 2 files changed, 75 insertions(+), 72 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/FORCE_gamma_tvnl.cpp b/ABACUS.develop/source/src_lcao/FORCE_gamma_tvnl.cpp index 27140989e6..372d371b77 100644 --- a/ABACUS.develop/source/src_lcao/FORCE_gamma_tvnl.cpp +++ b/ABACUS.develop/source/src_lcao/FORCE_gamma_tvnl.cpp @@ -75,6 +75,9 @@ void Force_LCAO_gamma::cal_fvnl_dbeta( TITLE("Force_LCAO_gamma","cal_fvnl_dbeta"); timer::tick("Force_LCAO_gamma","cal_fvnl_dbeta",'G'); + double r0[3]; + double r1[3]; + for(int iat=0; iat tau0 = ucell.atoms[it].tau[ia]; //find ajacent atom of atom ia //GridD.Find_atom( ucell.atoms[it].tau[ia] ); - GridD.Find_atom( ucell.atoms[it].tau[ia] ,it, ia); + GridD.Find_atom( ucell.atoms[it].tau[ia] ,it, ia); + const double Rcut_Beta = ORB.Beta[it].get_rcut_max(); //FOLLOWING ARE CONTRIBUTIONS FROM //VNL DUE TO PROJECTOR'S DISPLACEMENT @@ -92,7 +96,8 @@ void Force_LCAO_gamma::cal_fvnl_dbeta( const Atom* atom1 = &ucell.atoms[T1]; const int I1 = GridD.getNatom (ad1); const int start1 = ucell.itiaiw2iwt(T1, I1, 0); - const Vector3 tau1 = GridD.getAdjacentTau (ad1); + const Vector3 tau1 = GridD.getAdjacentTau (ad1); + const double Rcut_AO1 = ORB.Phi[T1].getRcut(); for (int ad2 =0 ; ad2 < GridD.getAdjacentNum()+1; ad2++) { @@ -101,15 +106,10 @@ void Force_LCAO_gamma::cal_fvnl_dbeta( const int I2 = GridD.getNatom (ad2); const int start2 = ucell.itiaiw2iwt(T2, I2, 0); const Vector3 tau2 = GridD.getAdjacentTau (ad2); - - const double Rcut_Beta = ORB.Beta[it].get_rcut_max(); - const double Rcut_AO1 = ORB.Phi[T1].getRcut(); const double Rcut_AO2 = ORB.Phi[T2].getRcut(); const double dist1 = (tau1-tau0).norm() * ucell.lat0; const double dist2 = (tau2-tau0).norm() * ucell.lat0; - double r0[3]; - double r1[3]; if(isstress) { r1[0] = ( tau1.x - tau0.x) ; @@ -150,8 +150,12 @@ void Force_LCAO_gamma::cal_fvnl_dbeta( atom2->iw2m[kk], // m1 atom2->iw2n[kk], // n1 tau0, it); + double nlm1[3] = {0,0,0}; - if(isstress) UOT.snap_psibeta( + + if(isstress) + { + UOT.snap_psibeta( nlm1, 1, tau2, T2, atom2->iw2l[kk], // L2 @@ -162,6 +166,7 @@ void Force_LCAO_gamma::cal_fvnl_dbeta( atom1->iw2m[jj], // m1 atom1->iw2n[jj], // n1 tau0, it); + } const int index = mu * ParaO.ncol + nu; @@ -186,9 +191,10 @@ void Force_LCAO_gamma::cal_fvnl_dbeta( { for(int ipol=0;ipol<3;ipol++) { - svnl_dbeta(0,ipol) -= sum/2.0 * (nlm[0] * r0[ipol] + nlm1[0] * r1[ipol])* -1; - svnl_dbeta(1,ipol) -= sum/2.0 * (nlm[1] * r0[ipol] + nlm1[1] * r1[ipol])* -1; - svnl_dbeta(2,ipol) -= sum/2.0 * (nlm[2] * r0[ipol] + nlm1[2] * r1[ipol])* -1; + // mohan update 2021-03-19 + svnl_dbeta(0,ipol) += sum/2.0 * (nlm[0] * r0[ipol] + nlm1[0] * r1[ipol]); + svnl_dbeta(1,ipol) += sum/2.0 * (nlm[1] * r0[ipol] + nlm1[1] * r1[ipol]); + svnl_dbeta(2,ipol) += sum/2.0 * (nlm[2] * r0[ipol] + nlm1[2] * r1[ipol]); } } }//!kk @@ -196,6 +202,7 @@ void Force_LCAO_gamma::cal_fvnl_dbeta( }//!jj }//!ad1 }//!iat + if(isstress) { for(int i=0;i<3;i++) diff --git a/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp b/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp index cda7c3d225..eb66f3750d 100644 --- a/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp @@ -94,10 +94,15 @@ void ORB_gen_tables::snap_psibeta( const int is) const { //TITLE ("ORB_gen_tables","snap_psibeta"); - //timer::tick ("ORB_gen_tables","snap_psibeta"); //optimized by zhengdy-soc - if(NSPIN==4 && ORB.Beta[T0].get_count_soc(is)==0) return; + if(NSPIN==4 && ORB.Beta[T0].get_count_soc(is)==0) + { + return; + } + + timer::tick ("ORB_gen_tables","snap_psibeta",'X'); + bool has_so = 0; if(ORB.Beta[T0].get_count_soc(0)>0 ) has_so = 1; @@ -145,6 +150,7 @@ void ORB_gen_tables::snap_psibeta( delete[] calproj; delete[] rmesh1; delete[] rmesh2; + timer::tick ("ORB_gen_tables","snap_psibeta",'X'); return; } @@ -156,18 +162,6 @@ void ORB_gen_tables::snap_psibeta( double x0a,x1a,x2a,x3a,x123a,x120a,x032a,x031a; double x0b,x1b,x2b,x3b,x123b,x120b,x032b,x031b; - /* - const double position = x / table_interval; - const int iq = static_cast(position); - assert(iq < table_length-4); - const double x0 = position - static_cast(iq); - const double x1 = 1.0 - x0; - const double x2 = 2.0 - x0; - const double x3 = 3.0 - x0; - - return x1*x2*(table[iq]*x3+table[iq+3]*x0)/6.0 - + x0*x3*(table[iq+1]*x2-table[iq+2]*x1)/2.0; - */ psa = distance10 / tbeta.dr; iqa = static_cast(psa); x0a = psa - static_cast(iqa); @@ -205,6 +199,7 @@ void ORB_gen_tables::snap_psibeta( //special case for R = 0; const double tiny1 = 1e-12; const double tiny2 = 1e-10; + if(distance10 < tiny1) distance10 += tiny1; if(distance20 < tiny1) distance20 += tiny1; @@ -228,8 +223,14 @@ void ORB_gen_tables::snap_psibeta( vector> grlyb; Ylm::rl_sph_harm (T1_2Lplus1-1, dRa.x, dRa.y, dRa.z, rlya); - if (job == 0) Ylm::rl_sph_harm (T2_2Lplus1-1, dRb.x, dRb.y, dRb.z, rlyb); - else Ylm::grad_rl_sph_harm (T2_2Lplus1-1, dRb.x, dRb.y, dRb.z, rlyb, grlyb); + if (job == 0) + { + Ylm::rl_sph_harm (T2_2Lplus1-1, dRb.x, dRb.y, dRb.z, rlyb); + } + else + { + Ylm::grad_rl_sph_harm (T2_2Lplus1-1, dRb.x, dRb.y, dRb.z, rlyb, grlyb); + } //============================================================================== // Formula : T1 T0 T0 T2 // sum_{L0}sum_{m0} @@ -239,10 +240,15 @@ void ORB_gen_tables::snap_psibeta( // mohan update 2011-03-07 int n_projection =1; - if(has_so) n_projection = ORB.Beta[T0].get_nproj_soc(); + if(has_so) + { + n_projection = ORB.Beta[T0].get_nproj_soc(); + } + vector> term_a_nc(n_projection,{0,0}); // Peize Lin change ptr to vector at 2020.01.31 vector> term_b_nc(n_projection,{0,0}); // Peize Lin change ptr to vector at 2020.01.31 int ip = -1; + for(int nb=0; nb const int Opair1 = tbeta.NL_Opair(Tpair1, L1, N1, nb); // @@ -311,37 +324,6 @@ void ORB_gen_tables::snap_psibeta( } } //end L - - // for test - /* - if( abs(term_a)>1.0e-5 && NURSE) - { - if(R1.x==0 && R1.y==0 && R1.z==0) - { - // cout << endl; - // cout << " R1=" << R1.x << " " << R1.y << " " << R1.z << endl; - // cout << " R0=" << R0.x << " " << R0.y << " " << R0.z << endl; - stringstream label; - stringstream phi; - if(nb==0) label<<"s"<= rmesh2[nb]-4) Interp_Vnlb = 0.0; - else Interp_Vnlb = i_exp * (x123b*curr[iqb]+x120b*curr[iqb+3]+x032b*curr[iqb+1]-curr[iqb+2]*x031b); + if( iqb >= rmesh2[nb]-4) + { + Interp_Vnlb = 0.0; + } + else + { + Interp_Vnlb = i_exp * (x123b*curr[iqb]+x120b*curr[iqb+3]+x032b*curr[iqb+1]-curr[iqb+2]*x031b); + } Interp_Vnlb /= rl2; } @@ -379,9 +367,14 @@ void ORB_gen_tables::snap_psibeta( { curr = tbeta.Table_NR[1][Tpair2][Opair2][L]; - if( iqb >= rmesh2[nb]-4) Interp_Vnlc = 0.0; - else Interp_Vnlc = i_exp * (x123b*curr[iqb]+x120b*curr[iqb+3]+x032b*curr[iqb+1]-curr[iqb+2]*x031b); - + if( iqb >= rmesh2[nb]-4) + { + Interp_Vnlc = 0.0; + } + else + { + Interp_Vnlc = i_exp * (x123b*curr[iqb]+x120b*curr[iqb+3]+x032b*curr[iqb+1]-curr[iqb+2]*x031b); + } Interp_Vnlc = Interp_Vnlc / pow(distance20, L) - Interp_Vnlb * L / distance20; } else @@ -407,10 +400,13 @@ void ORB_gen_tables::snap_psibeta( } case 1: // calculate the derivative part. { + double tt1 = tmpGaunt * Interp_Vnlc * rlyb[lm] / distance20; + double tt2 = tmpGaunt * Interp_Vnlb; + for(int ir = 0; ir < 3; ir++) { - term_c[ir] += tmpGaunt * (Interp_Vnlc * rlyb[lm] * unit_vec_dRb[ir] / distance20 - + Interp_Vnlb * grlyb[lm][ir]); + term_c[ir] += tt1 * unit_vec_dRb[ir] + + tt2 * grlyb[lm][ir]; } break; @@ -436,7 +432,10 @@ void ORB_gen_tables::snap_psibeta( case 0://calculate the overlap part. { //nlm[0] += term_a * term_b * ORB.Beta[T0].getCoefficient_D(L0, L0);//LiuXh 2016-01-14 - if(!has_so) nlm[0] += term_a * term_b * ORB.Beta[T0].getCoefficient_D(nb, nb);//LiuXh 2016-01-14 + if(!has_so) + { + nlm[0] += term_a * term_b * ORB.Beta[T0].getCoefficient_D(nb, nb);//LiuXh 2016-01-14 + } break; } case 1: //calculate the derivative part. @@ -448,10 +447,6 @@ void ORB_gen_tables::snap_psibeta( { nlm[jr] += term_c[jr] * term_a * ORB.Beta[T0].getCoefficient_D(nb, nb);//LiuXh 2016-01-14 } - else - { - - } } break; } @@ -459,6 +454,7 @@ void ORB_gen_tables::snap_psibeta( } }//!m0 }//!L0 + //zhengdy-soc, calculate non-local term if(has_so) { @@ -493,7 +489,7 @@ void ORB_gen_tables::snap_psibeta( delete[] rmesh1; delete[] rmesh2; -// timer::tick("ORB_gen_tables","snap_psibeta"); + timer::tick ("ORB_gen_tables","snap_psibeta",'X'); return; } From 6f3155f97c5aeaeb5d8b5376a9cc2911a7295a6f Mon Sep 17 00:00:00 2001 From: mohan Date: Sat, 20 Mar 2021 23:48:06 +0800 Subject: [PATCH 225/233] add some notes in FORCE_STRESS, need further reconstructions --- .../source/src_lcao/FORCE_STRESS.cpp | 29 +++++++------- ABACUS.develop/source/src_lcao/FORCE_STRESS.h | 40 +++++++++---------- .../source/src_lcao/grid_meshball.h | 6 +-- .../source/src_lcao/grid_technique.cpp | 32 +++++++++++---- 4 files changed, 60 insertions(+), 47 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp b/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp index cbfd4ea799..770a3d4bf9 100644 --- a/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp +++ b/ABACUS.develop/source/src_lcao/FORCE_STRESS.cpp @@ -9,17 +9,13 @@ double Force_Stress_LCAO::force_invalid_threshold_ev = 0.00; double Force_Stress_LCAO::output_acc = 1.0e-8; -Force_Stress_LCAO::Force_Stress_LCAO () -{ -} +Force_Stress_LCAO::Force_Stress_LCAO (){} +Force_Stress_LCAO::~Force_Stress_LCAO (){} -Force_Stress_LCAO::~Force_Stress_LCAO () -{ -} void Force_Stress_LCAO::allocate(void) { - TITLE("Force_Stress_LCAO","init"); + TITLE("Force_Stress_LCAO","allocate"); // reduce memory occupy by vlocal delete[] ParaO.sender_local_index; @@ -39,15 +35,15 @@ void Force_Stress_LCAO::allocate(void) return; } + #include "../src_pw/efield.h" -// be called in : LOOP_ions::force_stress void Force_Stress_LCAO::getForceStress( const bool isforce, const bool isstress, const bool istestf, const bool istests, - matrix& fcs, - matrix& scs) + matrix &fcs, + matrix &scs) { TITLE("Force_Stress_LCAO","getForceStress"); timer::tick("Force_Stress_LCAO","getForceStress",'E'); @@ -67,7 +63,9 @@ void Force_Stress_LCAO::getForceStress( matrix fewalds; matrix fcc; matrix fscc; + fvl_dphi.create (nat, 3);//must do it now, update it later, noted by zhengdy + if(isforce) { fcs.create (nat, 3); @@ -92,6 +90,7 @@ void Force_Stress_LCAO::getForceStress( matrix stvnl_dphi; matrix svnl_dbeta; matrix svl_dphi; + if(isstress) { scs.create(3,3); @@ -506,7 +505,7 @@ void Force_Stress_LCAO::print_force(const string &name, matrix& f, const bool sc return; } -//print total force + void Force_Stress_LCAO::printforce_total (const bool ry, const bool istestf, matrix& fcs) { TITLE("Force_Stress_LCAO","printforce_total"); @@ -582,10 +581,10 @@ void Force_Stress_LCAO::printforce_total (const bool ry, const bool istestf, mat //local pseudopotential, ewald, core correction, scc terms in force void Force_Stress_LCAO::calForcePwPart( - matrix& fvl_dvl, - matrix& fewalds, - matrix& fcc, - matrix& fscc) + matrix &fvl_dvl, + matrix &fewalds, + matrix &fcc, + matrix &fscc) { //-------------------------------------------------------- // local pseudopotential force: diff --git a/ABACUS.develop/source/src_lcao/FORCE_STRESS.h b/ABACUS.develop/source/src_lcao/FORCE_STRESS.h index 3e1992b15e..d27cb86bcb 100644 --- a/ABACUS.develop/source/src_lcao/FORCE_STRESS.h +++ b/ABACUS.develop/source/src_lcao/FORCE_STRESS.h @@ -40,36 +40,36 @@ class Force_Stress_LCAO const bool isstress, const bool istestf, const bool istests, - matrix& fcs, - matrix& scs); + matrix &fcs, + matrix &scs); - void forceSymmetry(matrix& fcs); + void forceSymmetry(matrix &fcs); void calForcePwPart( - matrix& fvl_dvl, - matrix& fewalds, - matrix& fcc, - matrix& fscc); + matrix &fvl_dvl, + matrix &fewalds, + matrix &fcc, + matrix &fscc); void calForceStressIntegralPart( const bool isGammaOnly, const bool isforce, const bool isstress, - matrix& foverlap, - matrix& ftvnl_dphi, - matrix& fvnl_dbeta, - matrix& fvl_dphi, - matrix& soverlap, - matrix& stvnl_dphi, - matrix& svnl_dbeta, - matrix& svl_dphi); + matrix &foverlap, + matrix &ftvnl_dphi, + matrix &fvnl_dbeta, + matrix &fvl_dphi, + matrix &soverlap, + matrix &stvnl_dphi, + matrix &svnl_dbeta, + matrix &svl_dphi); void calStressPwPart( - matrix& sigmadvl, - matrix& sigmahar, - matrix& sigmaewa, - matrix& sigmacc, - matrix& sigmaxc); + matrix &sigmadvl, + matrix &sigmahar, + matrix &sigmaewa, + matrix &sigmacc, + matrix &sigmaxc); static double force_invalid_threshold_ev; static double output_acc; // control the accuracy diff --git a/ABACUS.develop/source/src_lcao/grid_meshball.h b/ABACUS.develop/source/src_lcao/grid_meshball.h index ebd1bb4357..67dd4b3cb4 100644 --- a/ABACUS.develop/source/src_lcao/grid_meshball.h +++ b/ABACUS.develop/source/src_lcao/grid_meshball.h @@ -16,9 +16,11 @@ class Grid_MeshBall : public Grid_BigCell // cartesian coordinates of meshball. double** meshball_positions; + bool flag_mp; protected: + Grid_MeshBall(); ~Grid_MeshBall(); @@ -35,8 +37,4 @@ class Grid_MeshBall : public Grid_BigCell double deal_with_atom_spillage(const double* pos); }; - #endif - - - diff --git a/ABACUS.develop/source/src_lcao/grid_technique.cpp b/ABACUS.develop/source/src_lcao/grid_technique.cpp index 746c66b3ee..6fddc38f0d 100644 --- a/ABACUS.develop/source/src_lcao/grid_technique.cpp +++ b/ABACUS.develop/source/src_lcao/grid_technique.cpp @@ -54,28 +54,41 @@ void Grid_Technique::set_pbc_grid( TITLE("Grid_Technique","init"); timer::tick("Grid_Technique","init",'D'); - //xiaohui add 'OUT_LEVEL' line, 2015-09-16 - if(OUT_LEVEL != "m") ofs_running << "\n SETUP EXTENDED REAL SPACE GRID FOR GRID INTEGRATION" << endl; + if(OUT_LEVEL != "m") + { + ofs_running << "\n SETUP EXTENDED REAL SPACE GRID FOR GRID INTEGRATION" << endl; + } // (1) init_meshcell cell and big cell. - this->set_grid_dim(ncx_in,ncy_in,ncz_in, - bx_in,by_in,bz_in,nbx_in,nby_in,nbz_in, - nbxx_in,nbzp_start_in,nbzp_in); + this->set_grid_dim( + ncx_in,ncy_in,ncz_in, + bx_in,by_in,bz_in, + nbx_in,nby_in,nbz_in, + nbxx_in,nbzp_start_in,nbzp_in); this->init_latvec(); + this->init_big_latvec(); + this->init_meshcell_pos(); + // (2) expand the grid this->init_grid_expansion(); + // (3) calculate the extended grid. this->cal_extended_cell(this->dxe, this->dye, this->dze); + this->init_tau_in_bigcell(); + // init meshball this->delete_meshball_positions(); //LiuXh add 2018-12-14 + this->init_meshball(); + this->init_atoms_on_grid(); this->cal_trace_lo(); + timer::tick("Grid_Technique","init",'D'); return; } @@ -441,9 +454,12 @@ void Grid_Technique::cal_trace_lo(void) // ofs_running << " i=" << i+1 << " trace_lo=" << trace_lo[i] << endl; // } - //xiaohui add 'OUT_LEVEL' line, 2015-09-16 - if(OUT_LEVEL != "m") OUT(ofs_running,"Atom number in sub-FFT-grid",lnat); - if(OUT_LEVEL != "m") OUT(ofs_running,"Local orbitals number in sub-FFT-grid",lgd); + if(OUT_LEVEL != "m") + { + OUT(ofs_running,"Atom number in sub-FFT-grid",lnat); + OUT(ofs_running,"Local orbitals number in sub-FFT-grid",lgd); + } + assert(iw_local == lgd); assert(iw_all == NLOCAL); return; From 67515729a5b209c9425be78be546283c2ebf5046 Mon Sep 17 00:00:00 2001 From: mohan Date: Sun, 21 Mar 2021 22:11:39 +0800 Subject: [PATCH 226/233] move HS_matrix to write_HS --- ABACUS.develop/source/Makefile.Objects | 4 ++-- .../source/src_io/{hs_matrix.cpp => write_HS.cpp} | 3 ++- .../source/src_io/{hs_matrix.h => write_HS.h} | 3 +++ ABACUS.develop/source/src_io/write_HS_R.cpp | 12 +----------- ABACUS.develop/source/src_io/write_dm.cpp | 6 +++++- ABACUS.develop/source/src_io/write_rho.cpp | 9 ++++++++- ABACUS.develop/source/src_lcao/LCAO_diago.cpp | 2 +- ABACUS.develop/source/src_lcao/LCAO_evolve.cpp | 2 +- ABACUS.develop/source/src_lcao/LOOP_ions.cpp | 2 +- ABACUS.develop/source/src_lcao/run_md.cpp | 2 +- 10 files changed, 25 insertions(+), 20 deletions(-) rename ABACUS.develop/source/src_io/{hs_matrix.cpp => write_HS.cpp} (99%) rename ABACUS.develop/source/src_io/{hs_matrix.h => write_HS.h} (99%) diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 4351fb43a6..17b49fd6f4 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -164,7 +164,6 @@ global_fp.o \ pdiag_double.o \ pdiag_basic.o \ pdiag_common.o \ -hs_matrix.o \ subgrid_oper.o \ GenELPA.o \ conv_coulomb_pot.o \ @@ -237,8 +236,9 @@ read_dm.o\ write_pot.o\ write_rho.o\ write_rho_dipole.o\ -write_dm.o\ +write_HS.o\ write_HS_R.o\ +write_dm.o\ potential_libxc.o \ efield.o \ magnetism.o\ diff --git a/ABACUS.develop/source/src_io/hs_matrix.cpp b/ABACUS.develop/source/src_io/write_HS.cpp similarity index 99% rename from ABACUS.develop/source/src_io/hs_matrix.cpp rename to ABACUS.develop/source/src_io/write_HS.cpp index fa698dd35b..86f20b2ef7 100644 --- a/ABACUS.develop/source/src_io/hs_matrix.cpp +++ b/ABACUS.develop/source/src_io/write_HS.cpp @@ -1,6 +1,7 @@ -#include "hs_matrix.h" +#include "write_HS.h" #include "../src_pw/global.h" + void HS_Matrix::saving_HS(const double *Hloc, const double* Sloc, bool bit, const int &out_hs) { if(out_hs==1) diff --git a/ABACUS.develop/source/src_io/hs_matrix.h b/ABACUS.develop/source/src_io/write_HS.h similarity index 99% rename from ABACUS.develop/source/src_io/hs_matrix.h rename to ABACUS.develop/source/src_io/write_HS.h index 7d814d22a8..0bc2a011f1 100644 --- a/ABACUS.develop/source/src_io/hs_matrix.h +++ b/ABACUS.develop/source/src_io/write_HS.h @@ -9,7 +9,9 @@ namespace HS_Matrix void saving_HS(const double *Hloc, const double* Sloc, bool bit, const int &out_hs); void save_HS(const double *H, const double *S, bool bit); + void save_HS_complex(const complex *H, const complex *S, bool bit); + void save_HSR_tr(const int current_spin); //LiuXh add 2019-07-15 // mohan comment out 2021-02-10 @@ -17,6 +19,7 @@ namespace HS_Matrix // const double *nzval_H, const double *nzval_S, bool bit); void saving_HS_complex(complex *Hloc, complex* Sloc, bool bit, const int &out_hs); //LiuXh, 2017-03-21 + void save_HS_complex(complex *H, complex *S, bool bit); //LiuXh, 2017-03-21 } diff --git a/ABACUS.develop/source/src_io/write_HS_R.cpp b/ABACUS.develop/source/src_io/write_HS_R.cpp index ccdff24458..4fa4d14102 100644 --- a/ABACUS.develop/source/src_io/write_HS_R.cpp +++ b/ABACUS.develop/source/src_io/write_HS_R.cpp @@ -1,18 +1,8 @@ #include "src_lcao/LOOP_ions.h" #include "src_io/cal_r_overlap_R.h" #include "src_pw/global.h" -#include "src_io/hs_matrix.h" +#include "src_io/write_HS.h" -/* -#include "src_parallel/parallel_orbitals.h" -#include "src_pdiag/pdiag_double.h" -#include "LCAO_nnr.h" -#include "FORCE_STRESS.h" -#include "src_global/global_function.h" -#include "src_ions/variable_cell.h" -#include "ELEC_scf.h" -#include "src_global/sltk_atom_arrange.h" -*/ void LOOP_ions::output_HS_R(void) { diff --git a/ABACUS.develop/source/src_io/write_dm.cpp b/ABACUS.develop/source/src_io/write_dm.cpp index 0a790cfef8..c354c8a0cf 100644 --- a/ABACUS.develop/source/src_io/write_dm.cpp +++ b/ABACUS.develop/source/src_io/write_dm.cpp @@ -36,7 +36,11 @@ // on other processors, this is why there is // a 'count' integer array in the code. // UPDATED BY MOHAN 2014-05-18 -void Local_Orbital_Charge::write_dm(const int &is, const int &iter, const string &fn, const int &precision) +void Local_Orbital_Charge::write_dm( + const int &is, + const int &iter, + const string &fn, + const int &precision) { TITLE("Local_Orbital_Charge","write_dm"); diff --git a/ABACUS.develop/source/src_io/write_rho.cpp b/ABACUS.develop/source/src_io/write_rho.cpp index 6eb4f0ae12..177129a5c1 100644 --- a/ABACUS.develop/source/src_io/write_rho.cpp +++ b/ABACUS.develop/source/src_io/write_rho.cpp @@ -1,7 +1,13 @@ #include "src_pw/charge.h" #include "src_pw/global.h" -void Charge::write_rho(const double* rho_save, const int &is, const int &iter, const string &fn, const int &precision, const bool for_plot) +void Charge::write_rho( + const double* rho_save, + const int &is, + const int &iter, + const string &fn, + const int &precision, + const bool for_plot) { TITLE("Charge","write_rho"); @@ -34,6 +40,7 @@ void Charge::write_rho(const double* rho_save, const int &is, const int &iter, c ofs << " " << ucell.latvec.e11 << " " << ucell.latvec.e12 << " " << ucell.latvec.e13 << endl; ofs << " " << ucell.latvec.e21 << " " << ucell.latvec.e22 << " " << ucell.latvec.e23 << endl; ofs << " " << ucell.latvec.e31 << " " << ucell.latvec.e32 << " " << ucell.latvec.e33 << endl; + for(int it=0; it //fuxiang add 2016-10-28 diff --git a/ABACUS.develop/source/src_lcao/LOOP_ions.cpp b/ABACUS.develop/source/src_lcao/LOOP_ions.cpp index fe58593e29..262de92c2a 100644 --- a/ABACUS.develop/source/src_lcao/LOOP_ions.cpp +++ b/ABACUS.develop/source/src_lcao/LOOP_ions.cpp @@ -5,7 +5,7 @@ #include "LCAO_nnr.h" #include "FORCE_STRESS.h" #include "src_global/global_function.h" -#include "src_io/hs_matrix.h" +#include "src_io/write_HS.h" #include "src_io/cal_r_overlap_R.h" #include "src_ions/variable_cell.h" // mohan add 2021-02-01 #include "src_ri/exx_abfs.h" diff --git a/ABACUS.develop/source/src_lcao/run_md.cpp b/ABACUS.develop/source/src_lcao/run_md.cpp index edba9c6f8e..e85f99ac2a 100644 --- a/ABACUS.develop/source/src_lcao/run_md.cpp +++ b/ABACUS.develop/source/src_lcao/run_md.cpp @@ -5,7 +5,7 @@ #include "LCAO_nnr.h" #include "FORCE_STRESS.h" #include "src_global/global_function.h" -#include "src_io/hs_matrix.h" +#include "src_io/write_HS.h" #include "src_io/cal_r_overlap_R.h" #include "src_ions/variable_cell.h" // mohan add 2021-02-01 #include "src_ri/exx_abfs.h" From 78bd06440ed9320bded188aa599242340864d740 Mon Sep 17 00:00:00 2001 From: maki49 <1579492865@qq.com> Date: Sun, 21 Mar 2021 22:38:56 +0800 Subject: [PATCH 227/233] output 5D overlap table between lcao and descriptor orbitals --- .../source/src_lcao/ORB_control.cpp | 4 + .../source/src_lcao/ORB_gen_tables.cpp | 212 ++++++++ .../source/src_lcao/ORB_gen_tables.h | 20 + ABACUS.develop/source/src_lcao/ORB_read.cpp | 17 +- ABACUS.develop/source/src_lcao/ORB_read.h | 2 +- .../source/src_lcao/ORB_table_alpha.cpp | 468 ++++++++++++++++++ .../source/src_lcao/ORB_table_alpha.h | 73 +++ 7 files changed, 791 insertions(+), 5 deletions(-) create mode 100644 ABACUS.develop/source/src_lcao/ORB_table_alpha.cpp create mode 100644 ABACUS.develop/source/src_lcao/ORB_table_alpha.h diff --git a/ABACUS.develop/source/src_lcao/ORB_control.cpp b/ABACUS.develop/source/src_lcao/ORB_control.cpp index 9be615436f..de445a7d32 100644 --- a/ABACUS.develop/source/src_lcao/ORB_control.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_control.cpp @@ -57,5 +57,9 @@ void ORB_control::clear_after_ions() TITLE("ORB_control","clear_after_ions"); UOT.MOT.Destroy_Table(); UOT.tbeta.Destroy_Table_Beta(); + //caoyu add 2021-03-18 + if (INPUT.out_descriptor && BASIS_TYPE == "lcao") { + UOT.talpha.Destroy_Table_Alpha(); + } return; } diff --git a/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp b/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp index cda7c3d225..043948466f 100644 --- a/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_gen_tables.cpp @@ -36,6 +36,17 @@ void ORB_gen_tables::gen_tables( const int &job0 ) ORB.get_dR(),// delta R, for making radial table ORB.get_dk() ); // delta k, for integration in k space + //caoyu add 2021-03-18 + if (INPUT.out_descriptor && BASIS_TYPE == "lcao") { + talpha.allocate( + ORB.get_ntype(),// number of atom types + ORB.get_lmax(),// max L used to calculate overlap + ORB.get_kmesh(), // kpoints, for integration in k space + ORB.get_Rmax(),// max value of radial table + ORB.get_dR(),// delta R, for making radial table + ORB.get_dk()); // delta k, for integration in k space + } + // OV: overlap MOT.init_OV_Tpair(); MOT.init_OV_Opair(); @@ -44,6 +55,12 @@ void ORB_gen_tables::gen_tables( const int &job0 ) tbeta.init_NL_Tpair(); tbeta.init_NL_Opair(); // add 2009-5-8 + //caoyu add 2021-03-18 + // DS: Descriptor + if (INPUT.out_descriptor && BASIS_TYPE == "lcao") { + talpha.init_DS_Opair(); + talpha.init_DS_2Lplus1(); + } //========================================= // (2) init Ylm Coef @@ -59,6 +76,12 @@ void ORB_gen_tables::gen_tables( const int &job0 ) MOT.init_Table(job0); tbeta.init_Table_Beta( MOT.pSB );// add 2009-5-8 + //caoyu add 2021-03-18 + if (INPUT.out_descriptor && BASIS_TYPE == "lcao") { + talpha.init_Table_Alpha(MOT.pSB); + talpha.print_Table_DSR(); + } + //========================================= // (3) make Gaunt coefficients table //========================================= @@ -792,4 +815,193 @@ double ORB_gen_tables::get_distance( const Vector3 &R1, const Vector3lat0; } +//caoyu add 2021-03-17 +void ORB_gen_tables::snap_psialpha( + double olm[], + const int& job, + const Vector3& R1, + const int& T1, + const int& L1, + const int& m1, + const int& N1, + const Vector3& R2, + const int& T2, + const int& L2, + const int& m2, + const int& N2, + complex* olm1, + const int is) const +{ + + if (job != 0 && job != 1) + { + WARNING_QUIT("ORB_gen_tables::snap_psialpha", "job must be equal to 0 or 1!"); + } + + Numerical_Orbital::set_position(R1, R2); + assert(this->lat0 > 0.0); + + // (1) get distance between R1 and R2 (a.u.) + // judge if there exist overlap + double distance = Numerical_Orbital::get_distance() * this->lat0; + + const double Rcut1 = ORB.Phi[T1].getRcut(); + const double Rcut2 = ORB.Alpha[0].getRcut(); + + if (job == 0) ZEROS(olm, 1); + else if (job == 1) ZEROS(olm, 3); + + if (distance > (Rcut1 + Rcut2)) return; + + //if distance == 0 + //\int psi(r) psi(r-R) dr independent of R if R == 0 + //distance += tiny1 avoid overflow during calculation + const double tiny1 = 1e-12; + const double tiny2 = 1e-10; + if (distance < tiny1) distance += tiny1; + + // (2) if there exist overlap, calculate the mesh number + // between two atoms + const int rmesh = this->talpha.get_rmesh(Rcut1, Rcut2); + + // (3) Find three dimension of 'Table_DS' + // dim1 : type pairs, equal to T1 here + // dim2 : radial orbital pairs, + // dim3 : find lmax between T1 and T2, and get lmax*2+1 + const int dim1 = T1; + int dim2 = this->talpha.DS_Opair(dim1, L1, L2, N1, N2); + int dim3 = this->talpha.DS_2Lplus1[T1]; + + //Gaunt Index + const int gindex1 = L1 * L1 + m1; + const int gindex2 = L2 * L2 + m2; + + // Peize Lin change rly, grly 2016-08-26 + vector rly; + vector> grly; + + double arr_dR[3]; + arr_dR[0] = Numerical_Orbital::getX() * this->lat0; + arr_dR[1] = Numerical_Orbital::getY() * this->lat0; + arr_dR[2] = Numerical_Orbital::getZ() * this->lat0; + + //double xdr = arr_dR[0] / distance; + //double ydr = arr_dR[1] / distance; + //double zdr = arr_dR[2] / distance; + + //======================= + // *r**l*Ylm_real + // include its derivations + //======================= + if (job == 0) + { + Ylm::rl_sph_harm(dim3 - 1, arr_dR[0], arr_dR[1], arr_dR[2], rly); + } + else + { + Ylm::grad_rl_sph_harm(dim3 - 1, arr_dR[0], arr_dR[1], arr_dR[2], rly, grly); + } + + for (int L = 0; L < dim3; L++) //maxL = dim3-1 + { + //=========================================================== + // triangle rule for L and sum of L, L1, L2 should be even + //=========================================================== + int AL = L1 + L2; + int SL = abs(L1 - L2); + + if ((L > AL) || (L < SL) || ((L - SL) % 2 == 1)) continue; + + double Interp_Slm = 0.0; + double Interp_dSlm = 0.0; + double tmpOlm0 = 0.0; + double tmpOlm1 = 0.0; + // prefactor + double i_exp = pow(-1.0, (L1 - L2 - L) / 2); + double rl = pow(distance, L); + + if (distance > tiny2) + { + Interp_Slm = i_exp * Mathzone::Polynomial_Interpolation( + talpha.Table_DSR[0][dim1][dim2][L], rmesh, MOT.dr, distance); + Interp_Slm /= rl; + } + else // distance = 0.0; + { + Interp_Slm = i_exp * talpha.Table_DSR[0][dim1][dim2][L][0]; + } + + if (job == 1)//calculate the derivative. + { + if (distance > tiny2) + { + Interp_dSlm = i_exp * Mathzone::Polynomial_Interpolation( + talpha.Table_DSR[1][dim1][dim2][L], rmesh, MOT.dr, distance); + Interp_dSlm = Interp_dSlm / pow(distance, L) - Interp_Slm * L / distance; + } + else + { + Interp_dSlm = 0.0; + } + } + + for (int m = 0; m < 2 * L + 1; m++) + { + int gindex = L * L + m; + // double tmpGaunt1 = MGT.Get_Gaunt_SH(L1, m1, L2, m2, L, m); + double tmpGaunt = MGT.Gaunt_Coefficients(gindex1, gindex2, gindex); + + tmpOlm0 = Interp_Slm * tmpGaunt; + + if (job == 1) + { + tmpOlm1 = Interp_dSlm * tmpGaunt; + } + + switch (job) + { + case 0: // calculate overlap. + { + if (NSPIN != 4) olm[0] += tmpOlm0 * rly[MGT.get_lm_index(L, m)]; + else if (olm1 != NULL) + { + olm1[0] += tmpOlm0 * rly[MGT.get_lm_index(L, m)]; + olm1[1] += 0;//tmpOlm0 * (tmp(0,0)+tmp(0,1)); + olm1[2] += 0;//tmpOlm0 * (tmp(1,0)+tmp(1,1)); + olm1[3] += tmpOlm0 * rly[MGT.get_lm_index(L, m)]; + + } + else + { + WARNING_QUIT("ORB_gen_tables::snap_psialpha", "something wrong!"); + + } + + /* + if( abs ( tmpOlm0 * rly[ MGT.get_lm_index(L, m) ] ) > 1.0e-3 ) + { + cout << " L=" << L << " m=" << m << " tmpOlm0=" << tmpOlm0 + << " rly=" << rly[ MGT.get_lm_index(L, m) ] + << " r=" << olm[0] + << endl; + } + */ + break; + } + case 1: // calculate gradient. + { + for (int ir = 0; ir < 3; ir++) + { + olm[ir] += tmpOlm0 * grly[MGT.get_lm_index(L, m)][ir] + + tmpOlm1 * rly[MGT.get_lm_index(L, m)] * arr_dR[ir] / distance; + } + break; + } + default: break; + } + }//!m + } + + return; +} diff --git a/ABACUS.develop/source/src_lcao/ORB_gen_tables.h b/ABACUS.develop/source/src_lcao/ORB_gen_tables.h index 8a257b88e6..2fe9619ee2 100644 --- a/ABACUS.develop/source/src_lcao/ORB_gen_tables.h +++ b/ABACUS.develop/source/src_lcao/ORB_gen_tables.h @@ -10,6 +10,7 @@ #include "src_global/ylm.h" #include "ORB_table_beta.h" #include "ORB_table_phi.h" +#include "ORB_table_alpha.h" //caoyu add 2020-3-18 //------------------------------------ // used to be 'Use_Overlap_Table', @@ -63,6 +64,24 @@ class ORB_gen_tables complex *nlm1=NULL, const int is=0)const; + //caoyu add 2021-03-17 + //job = 0 for vnl matrix elements + //job = 1 for its derivatives + void snap_psialpha( + double olm[], + const int& job, + const Vector3& R1, + const int& I1, + const int& l1, + const int& m1, + const int& n1, + const Vector3& R2, + const int& I2, + const int& l2, + const int& m2, + const int& n2, + complex* olm1 = NULL, + const int is = 0)const; // set as public because in hamilt_linear, // we need to destroy the tables: SR,TR,NR @@ -72,6 +91,7 @@ class ORB_gen_tables // if we want to add table for descriptors, // we should consider here -- mohan 2021-02-09 + ORB_table_alpha talpha; //caoyu add 2021-03-17 private: diff --git a/ABACUS.develop/source/src_lcao/ORB_read.cpp b/ABACUS.develop/source/src_lcao/ORB_read.cpp index e915d6ef2c..a33e946989 100644 --- a/ABACUS.develop/source/src_lcao/ORB_read.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_read.cpp @@ -12,6 +12,7 @@ LCAO_Orbitals::LCAO_Orbitals() this->nchimax = 0;// this initialzied must specified this->Phi = new Numerical_Orbital[1]; this->Beta = new Numerical_Nonlocal[1]; + this->Alpha = new Numerical_Orbital[1]; this->nproj = new int[1]; this->nprojmax = 0; @@ -28,6 +29,7 @@ LCAO_Orbitals::~LCAO_Orbitals() } delete[] Phi; delete[] Beta; + delete[] Alpha; delete[] nproj; } @@ -224,6 +226,10 @@ void LCAO_Orbitals::Read_Orbitals(void) //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> if (INPUT.out_descriptor && BASIS_TYPE == "lcao") //condition: descriptor in lcao line { + + delete[] this->Alpha; + this->Alpha = new Numerical_Orbital[1]; //not related to atom type -- remain to be discussed + this->Read_Descriptor(); } @@ -993,6 +999,7 @@ void LCAO_Orbitals::Read_Descriptor() //read descriptor basis //read lmax and nchi[l] int lmax = 0; + int nchimax = 0; int nchi[10]={0}; char word[80]; if (MY_RANK == 0) @@ -1011,15 +1018,17 @@ void LCAO_Orbitals::Read_Descriptor() //read descriptor basis for (int l = 0; l <= lmax; l++) { in >> word >> word >> word >> nchi[l]; - this->nchimax_d = std::max(this->nchimax_d, nchi[l]); + nchimax = std::max(nchimax, nchi[l]); } } #ifdef __MPI Parallel_Common::bcast_int(lmax); + Parallel_Common::bcast_int(nchimax); Parallel_Common::bcast_int(nchi, lmax + 1); #endif this->lmax_d = lmax; + this->nchimax_d = nchimax; // calculate total number of chi int total_nchi = 0; for (int l = 0; l <= lmax; l++) @@ -1027,7 +1036,7 @@ void LCAO_Orbitals::Read_Descriptor() //read descriptor basis total_nchi += nchi[l]; } //OUT(ofs_running,"Total number of chi(l,n)",total_nchi); - this->Alpha.phiLN = new Numerical_Orbital_Lm[total_nchi]; + this->Alpha[0].phiLN = new Numerical_Orbital_Lm[total_nchi]; int meshr; // number of mesh points int meshr_read; @@ -1178,7 +1187,7 @@ void LCAO_Orbitals::Read_Descriptor() //read descriptor basis delete[] inner; ofs_running << setw(12) << unit << endl; - this->Alpha.phiLN[count].set_orbital_info( + this->Alpha[0].phiLN[count].set_orbital_info( "H", //any type 1, //any type L, //angular momentum L @@ -1203,7 +1212,7 @@ void LCAO_Orbitals::Read_Descriptor() //read descriptor basis } } in.close(); - this->Alpha.set_orbital_info( + this->Alpha[0].set_orbital_info( 1, // any type "H", // any label lmax, diff --git a/ABACUS.develop/source/src_lcao/ORB_read.h b/ABACUS.develop/source/src_lcao/ORB_read.h index f2495936eb..d39e449f68 100644 --- a/ABACUS.develop/source/src_lcao/ORB_read.h +++ b/ABACUS.develop/source/src_lcao/ORB_read.h @@ -63,7 +63,7 @@ class LCAO_Orbitals //caoyu add 2021-3-10 // descriptor bases, saved as one-type atom orbital - Numerical_Orbital Alpha; + Numerical_Orbital* Alpha; // initialized in input.cpp double ecutwfc; diff --git a/ABACUS.develop/source/src_lcao/ORB_table_alpha.cpp b/ABACUS.develop/source/src_lcao/ORB_table_alpha.cpp new file mode 100644 index 0000000000..d0f639d28d --- /dev/null +++ b/ABACUS.develop/source/src_lcao/ORB_table_alpha.cpp @@ -0,0 +1,468 @@ +//caoyu add 2021-03-17 + +#include "ORB_table_alpha.h" +#include "ORB_read.h" +#include "../src_pw/global.h" +#include +#include "../src_ri/exx_abfs.h" +#include "../src_io/winput.h" + +double ORB_table_alpha::dr = -1.0; + +ORB_table_alpha::ORB_table_alpha() +{ + destroy_nr = false; + + ntype = 0; + lmax = 0; + kmesh = 0; + Rmax = 0.0; + dr = 0.0; + dk = 0.0; + + nlm = 0; + Rmesh = 0; + + kpoint = new double[1]; + r = new double[1]; + rab = new double[1]; + kab = new double[1]; + DS_2Lplus1 = new int[1]; +} + +ORB_table_alpha::~ORB_table_alpha() +{ + delete[] kpoint; + delete[] r; + delete[] rab; + delete[] kab; + delete[] DS_2Lplus1; +} + +void ORB_table_alpha::allocate +( + const int& ntype_in, + const int& lmax_in, + const int& kmesh_in, + const double& Rmax_in, + const double& dr_in, + const double& dk_in +) +{ + TITLE("ORB_table_alpha", "allocate"); + + this->ntype = ntype_in;// type of elements. + this->lmax = lmax_in; + this->kmesh = kmesh_in; + this->Rmax = Rmax_in; + this->dr = dr_in; + this->dk = dk_in; + + assert(ntype > 0); + assert(lmax >= 0); + assert(kmesh > 0.0); + assert(Rmax >= 0.0); + assert(dr > 0.0); + assert(dk > 0.0); + + // calculated from input parameters + this->nlm = (2 * lmax + 1) * (2 * lmax + 1); + this->Rmesh = static_cast(Rmax / dr) + 4; + if (Rmesh % 2 == 0) + { + ++Rmesh; + } + + // OUT(ofs_running,"lmax",lmax); + // OUT(ofs_running,"Rmax (Bohr)",Rmax); + // OUT(ofs_running,"dr (Bohr)",dr); + // OUT(ofs_running,"dk",dk); + // OUT(ofs_running,"nlm",nlm); + // OUT(ofs_running,"kmesh",kmesh); + + delete[] kpoint; + delete[] r; + kpoint = new double[kmesh]; + r = new double[Rmesh]; + + delete[] rab; + delete[] kab; + kab = new double[kmesh]; + rab = new double[Rmesh]; + + for (int ik = 0; ik < kmesh; ik++) + { + kpoint[ik] = ik * dk_in; + kab[ik] = dk_in; + } + + for (int ir = 0; ir < Rmesh; ir++) + { + r[ir] = ir * dr; + rab[ir] = dr; + } + + // OUT(ofs_running,"allocate kpoint, r, rab, kab","Done"); + return; +} + + +int ORB_table_alpha::get_rmesh(const double& R1, const double& R2) +{ + int rmesh = static_cast((R1 + R2) / ORB_table_alpha::dr) + 5; + //mohan update 2009-09-08 +1 ==> +5 + //considering interpolation or so on... + if (rmesh % 2 == 0) rmesh++; + + if (rmesh <= 0) + { + ofs_warning << "\n R1 = " << R1 << " R2 = " << R2; + ofs_warning << "\n rmesh = " << rmesh; + WARNING_QUIT("ORB_table_alpha::get_rmesh", "rmesh <= 0"); + } + return rmesh; +} + + + +void ORB_table_alpha::cal_S_PhiAlpha_R( + Sph_Bessel_Recursive::D2* pSB, // mohan add 2021-03-06 + const int& l, + const Numerical_Orbital_Lm& n1, + const Numerical_Orbital_Lm& n2, + const int& rmesh, + double* rs, + double* drs) +{ + timer::tick("ORB_table_alpha", "S_PhiAlpha_R"); + + assert(kmesh > 0); + + //start calc + double* k1_dot_k2 = new double[kmesh]; + + for (int ik = 0; ik < kmesh; ik++) + { + k1_dot_k2[ik] = n1.getPsi_k(ik) * n2.getPsi_k(ik); + } + + //previous version + double* integrated_func = new double[kmesh]; + + const vector>& jlm1 = pSB->get_jlx()[l - 1]; + const vector>& jl = pSB->get_jlx()[l]; + const vector>& jlp1 = pSB->get_jlx()[l + 1]; + for (int ir = 0; ir < rmesh; ir++) + { + ZEROS(integrated_func, kmesh); + double temp = 0.0; + + for (int ik = 0; ik < kmesh; ik++) + { + integrated_func[ik] = jl[ir][ik] * k1_dot_k2[ik]; + } + // Call simpson integration + Mathzone::Simpson_Integral(kmesh, integrated_func, kab, temp); + rs[ir] = temp * FOUR_PI; + + //drs + double temp1, temp2; + + if (l > 0) + { + for (int ik = 0; ik < kmesh; ik++) + { + integrated_func[ik] = jlm1[ir][ik] * k1_dot_k2[ik] * kpoint[ik]; + } + + Mathzone::Simpson_Integral(kmesh, integrated_func, kab, temp1); + } + + + for (int ik = 0; ik < kmesh; ik++) + { + integrated_func[ik] = jlp1[ir][ik] * k1_dot_k2[ik] * kpoint[ik]; + } + + Mathzone::Simpson_Integral(kmesh, integrated_func, kab, temp2); + + if (l == 0) + { + drs[ir] = -FOUR_PI * temp2; + } + else + { + drs[ir] = FOUR_PI * (temp1 * l - (l + 1) * temp2) / (2.0 * l + 1); + } + } + + //liaochen modify on 2010/4/22 + //special case for R=0 + //we store Slm(R) / R**l at the fisrt point, rather than Slm(R) + if (l > 0) + { + ZEROS(integrated_func, kmesh); + double temp = 0.0; + + for (int ik = 0; ik < kmesh; ik++) + { + integrated_func[ik] = k1_dot_k2[ik] * pow(kpoint[ik], l); + } + + // Call simpson integration + Mathzone::Simpson_Integral(kmesh, integrated_func, kab, temp); + rs[0] = FOUR_PI / Mathzone_Add1::dualfac(2 * l + 1) * temp; + } + + delete[] integrated_func; + + + delete[] k1_dot_k2; + timer::tick("ORB_table_alpha", "S_PhiAlpha_R"); + return; +} + + +void ORB_table_alpha::init_Table_Alpha(Sph_Bessel_Recursive::D2* pSB) +{ + TITLE("ORB_table_alpha", "init_Table_Alpha"); + timer::tick("ORB_table_alpha", "init_Table_Alpha", 'D'); + + // (1) allocate 1st dimension ( overlap, derivative) + this->Table_DSR = new double**** [2]; + // (2) allocate 2nd dimension ( overlap, derivative) + this->Table_DSR[0] = new double*** [this->ntype]; + this->Table_DSR[1] = new double*** [this->ntype]; + + // <1Phi|2Alpha> + for (int T1 = 0; T1 < ntype; T1++) // type 1 is orbital + { + const int Lmax1 = ORB.Phi[T1].getLmax(); + const int Lmax2 = ORB.Alpha[0].getLmax(); + const int lmax_now = std::max(Lmax1, Lmax2); + int L2plus1 = 2 * lmax_now + 1; + //------------------------------------------------------------- + // how many + // here we count all possible psi with (L,N) index for type T1. + //------------------------------------------------------------- + const int pairs_chi = ORB.Phi[T1].getTotal_nchi() * ORB.Alpha[0].getTotal_nchi(); + + if (pairs_chi == 0)continue; + + // init 2nd dimension + this->Table_DSR[0][T1] = new double** [pairs_chi]; + this->Table_DSR[1][T1] = new double** [pairs_chi]; + + const double Rcut1 = ORB.Phi[T1].getRcut(); + for (int L1 = 0; L1 < Lmax1 + 1; L1++) + { + for (int N1 = 0; N1 < ORB.Phi[T1].getNchi(L1); N1++) + { + for (int L2 = 0; L2 < Lmax2 + 1; L2++) + { + for (int N2 = 0; N2 < ORB.Alpha[0].getNchi(L2); N2++) + { + // get the second index. + const int Opair = this->DS_Opair(T1, L1, L2, N1, N2); + + // init 3rd dimension + this->Table_DSR[0][T1][Opair] = new double* [L2plus1]; + this->Table_DSR[1][T1][Opair] = new double* [L2plus1]; + + const double Rcut1 = ORB.Phi[T1].getRcut(); + const double Rcut2 = ORB.Alpha[0].getRcut(); + assert(Rcut1 > 0.0 && Rcut1 < 100); + assert(Rcut2 > 0.0 && Rcut2 < 100); + + const int rmesh = this->get_rmesh(Rcut1, Rcut2); + assert(rmesh < this->Rmesh); + + //L=|L1-L2|,|L1-L2|+2,...,L1+L2 + const int SL = abs(L1 - L2); + const int AL = L1 + L2; + + for (int L = 0; L < L2plus1; L++) + { + //Allocation + this->Table_DSR[0][T1][Opair][L] = new double[rmesh]; + this->Table_DSR[1][T1][Opair][L] = new double[rmesh]; + + Memory::record("ORB_table_alpha", "Table_DSR", + 2 * this->ntype * pairs_chi * rmesh, "double"); + + //for those L whose Gaunt Coefficients = 0, we + //assign every element in Table_DSR as zero + if ((L > AL) || (L < SL) || ((L - SL) % 2 == 1)) + { + ZEROS(Table_DSR[0][T1][Opair][L], rmesh); + ZEROS(Table_DSR[1][T1][Opair][L], rmesh); + + continue; + } + + this->cal_S_PhiAlpha_R( + pSB, // mohan add 2021-03-06 + L, + ORB.Phi[T1].PhiLN(L1, N1), + ORB.Alpha[0].PhiLN(L2, N2), // mohan update 2011-03-07 + rmesh, + this->Table_DSR[0][T1][Opair][L], + this->Table_DSR[1][T1][Opair][L]); + }// end L2plus1 + }// end N2 + }// end L2 + }// end N1 + }// end L1 + }// end T1 + destroy_nr = true; + + + // OUT(ofs_running,"allocate non-local potential matrix","Done"); + timer::tick("ORB_table_alpha", "init_Table_Alpha", 'D'); + return; +} + + +void ORB_table_alpha::Destroy_Table_Alpha(void) +{ + if (!destroy_nr) return; + + const int ntype = ORB.get_ntype(); + for (int ir = 0; ir < 2; ir++) + { + for (int T1 = 0; T1 < ntype; T1++) + { + const int Lmax1 = ORB.Phi[T1].getLmax(); + const int Lmax2 = ORB.Alpha[0].getLmax(); + const int lmax_now = std::max(Lmax1, Lmax2); + const int pairs = ORB.Phi[T1].getTotal_nchi() * ORB.Alpha[0].getTotal_nchi(); + + // mohan fix bug 2011-03-30 + if (pairs == 0) continue; + for (int dim2 = 0; dim2 < pairs; dim2++) + { + for (int L = 0; L < 2*lmax_now + 1; L++) + { + delete[] Table_DSR[ir][T1][dim2][L]; + } + delete[] Table_DSR[ir][T1][dim2]; + } + delete[] Table_DSR[ir][T1]; + } + delete[] Table_DSR[ir]; + } + delete[] Table_DSR; + return; +} + +void ORB_table_alpha::init_DS_2Lplus1(void) +{ + TITLE("Make_Overlap_Table", "init_DS_2Lplus1"); + assert(this->ntype > 0); + delete[] DS_2Lplus1; + DS_2Lplus1=new int[ntype]; // 2Lmax+1 for each T1 + + int index = 0; + for (int T1 = 0; T1 < ntype; T1++) + { + this->DS_2Lplus1[T1] = max(ORB.Phi[T1].getLmax(), ORB.Alpha[0].getLmax()) * 2 + 1; + } + return; +} + +void ORB_table_alpha::init_DS_Opair(void) +{ + const int lmax = ORB.get_lmax(); + const int nchimax = ORB.get_nchimax(); + const int lmax_d = ORB.get_lmax_d(); + const int nchimax_d = ORB.get_nchimax_d(); + assert(lmax + 1 > 0); + assert(lmax_d + 1 > 0); + assert(nchimax > 0); + assert(nchimax_d > 0); + + this->DS_Opair.create(this->ntype, lmax+1, lmax_d+1, nchimax, nchimax_d); + + // <1psi|2beta> + // 1. orbital + for (int T1 = 0; T1 < ntype; T1++) //alpha is not related to atom type ! + { + int index = 0; + for (int L1 = 0; L1 < ORB.Phi[T1].getLmax() + 1; L1++) + { + for (int N1 = 0; N1 < ORB.Phi[T1].getNchi(L1); N1++) + { + for (int L2 = 0; L2 < ORB.Alpha[0].getLmax() + 1; L2++) + { + for (int N2 = 0; N2 < ORB.Alpha[0].getNchi(L2); N2++) + { + this->DS_Opair(T1, L1, L2, N1, N2) = index; + ++index; + } + } + } + } + } + return; +} + +//caoyu add 2021-03-20 +void ORB_table_alpha::print_Table_DSR(void) +{ + TITLE("ORB_table_alpha", "print_Table_DSR"); + NEW_PART("Overlap table S between lcao orbital and descriptor basis : S_{I_mu_alpha}"); + + ofstream ofs; + stringstream ss; + // the parameter 'winput::spillage_outdir' is read from INPUTw. + ss << winput::spillage_outdir << "/" << "S_I_mu_alpha.dat"; + if (MY_RANK == 0) + { + ofs.open(ss.str().c_str()); + } + + for (int T1 = 0; T1 < this->ntype; T1++) //T1 + { + const int Lmax1 = ORB.Phi[T1].getLmax(); + const int Lmax2 = ORB.Alpha[0].getLmax(); + for (int L1 = 0; L1 < Lmax1 + 1; L1++) + { + for (int N1 = 0; N1 < ORB.Phi[T1].getNchi(L1); N1++) + { + for (int L2 = 0; L2 < Lmax2 + 1; L2++) + { + for (int N2 = 0; N2 < ORB.Alpha[0].getNchi(L2); N2++) + { + const int Opair = this->DS_Opair(T1, L1, L2, N1, N2); //Opair + ofs < Date: Mon, 22 Mar 2021 19:15:00 +0800 Subject: [PATCH 228/233] add ORB_table_alpha in Makefile.Objects --- ABACUS.develop/source/Makefile.Objects | 1 + 1 file changed, 1 insertion(+) diff --git a/ABACUS.develop/source/Makefile.Objects b/ABACUS.develop/source/Makefile.Objects index 17b49fd6f4..bed1c5618c 100644 --- a/ABACUS.develop/source/Makefile.Objects +++ b/ABACUS.develop/source/Makefile.Objects @@ -129,6 +129,7 @@ ORB_nonlocal_lm.o\ ORB_gaunt_table.o\ ORB_table_beta.o\ ORB_table_phi.o\ +ORB_table_alpha.o\ ORB_gen_tables.o\ local_orbital_wfc.o\ local_orbital_charge.o\ From d1a0869e4cbf5529305f0265cab53d10c39fb000 Mon Sep 17 00:00:00 2001 From: mohan Date: Tue, 23 Mar 2021 17:41:17 +0800 Subject: [PATCH 229/233] add comments for LCAO algorithms --- .../source/src_lcao/LCAO_gen_fixedH.cpp | 6 + ABACUS.develop/source/src_lcao/LOOP_ions.cpp | 5 +- ABACUS.develop/source/src_lcao/LOOP_ions.h | 10 ++ ABACUS.develop/source/src_lcao/ORB_read.cpp | 106 +++++++++++++----- ABACUS.develop/source/src_lcao/ORB_read.h | 2 + .../source/src_lcao/ORB_table_phi.cpp | 13 ++- 6 files changed, 112 insertions(+), 30 deletions(-) diff --git a/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.cpp b/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.cpp index 3457a8a11c..ae2b14d3fe 100644 --- a/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.cpp +++ b/ABACUS.develop/source/src_lcao/LCAO_gen_fixedH.cpp @@ -15,6 +15,12 @@ void LCAO_gen_fixedH::calculate_NL_no(void) { TITLE("LCAO_gen_fixedH","calculate_NL_no"); + // PLEASE rebuild the following two functions, + // 'build_Nonlocal_beta' and 'build_Nonlocal_mu', + // because the two functions are extremely time consuming + // for small systems, especially for multiple-k points + // mohan note 2021-03-23 + if(GAMMA_ONLY_LOCAL) { //for gamma only. diff --git a/ABACUS.develop/source/src_lcao/LOOP_ions.cpp b/ABACUS.develop/source/src_lcao/LOOP_ions.cpp index 262de92c2a..294b5d4519 100644 --- a/ABACUS.develop/source/src_lcao/LOOP_ions.cpp +++ b/ABACUS.develop/source/src_lcao/LOOP_ions.cpp @@ -225,7 +225,10 @@ void LOOP_ions::opt_ions(void) } -bool LOOP_ions::force_stress(const int &istep, int &force_step, int &stress_step) +bool LOOP_ions::force_stress( + const int &istep, + int &force_step, + int &stress_step) { TITLE("LOOP_ions","force_stress"); diff --git a/ABACUS.develop/source/src_lcao/LOOP_ions.h b/ABACUS.develop/source/src_lcao/LOOP_ions.h index ac7e0a92b7..cca164f460 100644 --- a/ABACUS.develop/source/src_lcao/LOOP_ions.h +++ b/ABACUS.develop/source/src_lcao/LOOP_ions.h @@ -25,6 +25,13 @@ class LOOP_ions Lattice_Change_Methods LCM; + + // PLEASE move 'force_stress()' function to other places, such as FORCE_STRESS.cpp or + // you might think to create a new file, it is because 'force_stress' do not + // belong to 'LOOP_ions', 'pot.init_pot' also do not belong to force_stress() + // the renew of structure factors, etc. should be ran in other places + // the 'IMM' and 'LCM' objects should be passed to force_stress() via parameters list + // mohan note 2021-03-23 bool force_stress(const int &istep, int &force_step, int &stress_step); int istep; @@ -32,6 +39,9 @@ class LOOP_ions // electron charge density extropolation method Charge_Extra CE; + // PLEASE move final_scf to other places, for example, now it can be put + // in 'src_ions/variable_cell.cpp' + // mohan note 2021-03-23 void final_scf(void); }; diff --git a/ABACUS.develop/source/src_lcao/ORB_read.cpp b/ABACUS.develop/source/src_lcao/ORB_read.cpp index a33e946989..bd85939faa 100644 --- a/ABACUS.develop/source/src_lcao/ORB_read.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_read.cpp @@ -5,6 +5,8 @@ //============================== // Define an object here! //============================== +// PLEASE avoid using 'ORB' as global variable +// mohan note 2021-03-23 LCAO_Orbitals ORB; LCAO_Orbitals::LCAO_Orbitals() @@ -56,6 +58,8 @@ void LCAO_Orbitals::bcast_files(void) string ofile; string nfile; +// PLEASE avoid using 'MY_RANK' as global variable +// mohan note 2021-03-23 if(MY_RANK==0) { ofile = orbital_file[it]; @@ -66,6 +70,8 @@ void LCAO_Orbitals::bcast_files(void) // nfile = nonlocal_file[it]; } +// PLEASE avoid using 'bcast_string' as global variable +// mohan note 2021-03-23 Parallel_Common::bcast_string(ofile); //----------------------------------- // Turn off the read in NONLOCAL file @@ -141,7 +147,6 @@ void LCAO_Orbitals::Read_Orbitals(void) OUT(ofs_running,"atom label",ucell.atoms[i].label); } - //------------------------------------------------- //(2) set the kmesh according to ecutwfc and dk. //------------------------------------------------- @@ -160,6 +165,8 @@ void LCAO_Orbitals::Read_Orbitals(void) this->kmesh = static_cast( sqrt(ecutwfc) / dk ) + 4; } +// PLEASE avoid using 'INPUT.' as global variable +// mohan note 2021-03-23 // jingan add for calculate r(R) matrix if(INPUT.out_r_matrix) kmesh = kmesh * 4; @@ -174,6 +181,10 @@ void LCAO_Orbitals::Read_Orbitals(void) // Read in numerical atomic orbitals for each atom type. //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> delete[] this->Phi; +// PLEASE avoid using 'ucell' as global variable +// if 'ntype' is really needed, the variable should be initialized +// as a parameter of this class +// mohan note 2021-03-23 this->Phi = new Numerical_Orbital[ucell.ntype]; for(int it=0; it>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + + +// PLEASE avoid using 'INPUT.' as global variable +// the descriptor parameter can be used as an input parameter +// mohan note 2021-03-23 if (INPUT.out_descriptor && BASIS_TYPE == "lcao") //condition: descriptor in lcao line { @@ -251,6 +267,10 @@ void LCAO_Orbitals::Set_NonLocal(const int &it, int &n_projectors) // get the number of non-local projectors n_projectors = atom->nbeta; + + +// PLEASE avoid using capital letters for local variables +// mohan note 2021-03-23 const int N_PROJECTORS = atom->nh;//zhengdy-soc //cout << " number of projectros " << N_PROJECTORS << endl; // cout << " number of projectros " << n_projectors << endl; @@ -309,8 +329,19 @@ void LCAO_Orbitals::Set_NonLocal(const int &it, int &n_projectors) } - WARNING("LCAO_Orbitals::Set_NonLocal","bug in line "+TO_STRING(__LINE__)+", matrix ic>=nc"); // Peize Lin add 2019-01-23 - this->Beta[it].set_type_info(it, atom->label, atom->pp_type, atom->lmax, Coefficient_D_in, Coefficient_D_in_so, n_projectors, 0, atom->lll, tmpBeta_lm, 0);//LiuXh 2016-01-14, 2016-07-19 + WARNING("LCAO_Orbitals::Set_NonLocal","bug in line "+TO_STRING(__LINE__)+", matrix ic>=nc"); + // Peize Lin add 2019-01-23 + this->Beta[it].set_type_info(it, + atom->label, + atom->pp_type, + atom->lmax, + Coefficient_D_in, + Coefficient_D_in_so, + n_projectors, + 0, + atom->lll, + tmpBeta_lm, + 0);//LiuXh 2016-01-14, 2016-07-19 } else//added by zhengdy-soc { @@ -319,8 +350,10 @@ void LCAO_Orbitals::Set_NonLocal(const int &it, int &n_projectors) { lmaxkb = max( lmaxkb, ucell.atoms[it].lll[ibeta]); } + soc.rot_ylm(lmaxkb); soc.fcoef.create(ucell.ntype, ucell.atoms[it].nh, ucell.atoms[it].nh); + int ip1=0; for(int p1 = 0; p1Beta[it].set_type_info(it, atom->label, atom->pp_type, atom->lmax, Coefficient_D_in, Coefficient_D_in_so, n_projectors, N_PROJECTORS, atom->lll, tmpBeta_lm, 1);//zhengdy-soc 2018-09-10 + + this->Beta[it].set_type_info( + it, + atom->label, + atom->pp_type, + atom->lmax, + Coefficient_D_in, + Coefficient_D_in_so, + n_projectors, + N_PROJECTORS, + atom->lll, + tmpBeta_lm, + 1);//zhengdy-soc 2018-09-10 + }//end if delete[] tmpBeta_lm; cout << " Set NonLocal Pseudopotential Projectors " << endl; - - return; } @@ -968,7 +1013,7 @@ void LCAO_Orbitals::set_nl_index(void) } //caoyu add 2021-3-16 -void LCAO_Orbitals::Read_Descriptor() //read descriptor basis +void LCAO_Orbitals::Read_Descriptor(void) //read descriptor basis { TITLE("LCAO_Orbitals", "Read_Descriptor"); @@ -995,7 +1040,7 @@ void LCAO_Orbitals::Read_Descriptor() //read descriptor basis { ofs_warning << " Orbital file : " << this->descriptor_file << endl; WARNING_QUIT("LCAO_Orbitals::Read_Descriptor", "Couldn't find orbital files for descriptor"); -} + } //read lmax and nchi[l] int lmax = 0; @@ -1043,30 +1088,30 @@ void LCAO_Orbitals::Read_Descriptor() //read descriptor basis double dr; if (MY_RANK == 0) + { + while (in.good()) { - while (in.good()) - { - in >> word; - if (std::strcmp(word, "END") == 0) // Peize Lin fix bug about strcmp 2016-08-02 - { - break; - } - } - CHECK_NAME(in, "Mesh"); - in >> meshr; - meshr_read = meshr; - if (meshr % 2 == 0) + in >> word; + if (std::strcmp(word, "END") == 0) // Peize Lin fix bug about strcmp 2016-08-02 { - ++meshr; + break; } - CHECK_NAME(in, "dr"); - in >> dr; } + CHECK_NAME(in, "Mesh"); + in >> meshr; + meshr_read = meshr; + if (meshr % 2 == 0) + { + ++meshr; + } + CHECK_NAME(in, "dr"); + in >> dr; + } #ifdef __MPI - Parallel_Common::bcast_int(meshr); - Parallel_Common::bcast_int(meshr_read); - Parallel_Common::bcast_double(dr); + Parallel_Common::bcast_int(meshr); + Parallel_Common::bcast_int(meshr_read); + Parallel_Common::bcast_double(dr); #endif int count = 0; @@ -1154,10 +1199,10 @@ void LCAO_Orbitals::Read_Descriptor() //read descriptor basis if (!find) { WARNING_QUIT("LCAO_Orbitals::Read_Descriptor", "Can't find descriptor orbitals."); - } + } #ifdef __MPI - Parallel_Common::bcast_double(psi, meshr_read); // mohan add 2010-06-24 + Parallel_Common::bcast_double(psi, meshr_read); Parallel_Common::bcast_double(psir, meshr_read); #endif @@ -1168,6 +1213,9 @@ void LCAO_Orbitals::Read_Descriptor() //read descriptor basis inner[ir] = psir[ir] * psir[ir]; } double unit = 0.0; + +// PLEASE make Simpson_Integral as input parameters? +// mohan note 2021-03-23 Mathzone::Simpson_Integral(meshr, inner, rab, unit); // check unit: \sum ( psi[r] * r )^2 = 1 @@ -1211,7 +1259,9 @@ void LCAO_Orbitals::Read_Descriptor() //read descriptor basis ++count; } } + in.close(); + this->Alpha[0].set_orbital_info( 1, // any type "H", // any label diff --git a/ABACUS.develop/source/src_lcao/ORB_read.h b/ABACUS.develop/source/src_lcao/ORB_read.h index d39e449f68..3010dc1efc 100644 --- a/ABACUS.develop/source/src_lcao/ORB_read.h +++ b/ABACUS.develop/source/src_lcao/ORB_read.h @@ -96,5 +96,7 @@ class LCAO_Orbitals }; +// PLEASE avoid using 'ORB' as global variable +// mohan note 2021-03-23 extern LCAO_Orbitals ORB; #endif diff --git a/ABACUS.develop/source/src_lcao/ORB_table_phi.cpp b/ABACUS.develop/source/src_lcao/ORB_table_phi.cpp index 03ff1e1060..a55f78d433 100644 --- a/ABACUS.develop/source/src_lcao/ORB_table_phi.cpp +++ b/ABACUS.develop/source/src_lcao/ORB_table_phi.cpp @@ -215,6 +215,8 @@ void ORB_table_phi::cal_ST_Phi12_R integrated_func[ik] = (jlp1_r[ik]-fac*jlm1_r[ik]) * k1_dot_k2_dot_kpoint[ik]; } } + // PLEASE try to make Simpson_Integral as input parameters + // mohan note 2021-03-23 Mathzone::Simpson_Integral(kmesh,integrated_func,dk,temp); drs[ir] = -FOUR_PI*(l+1)/(2.0*l+1) * temp; } @@ -233,7 +235,8 @@ void ORB_table_phi::cal_ST_Phi12_R integrated_func[ik] = k1_dot_k2[ik] * pow (kpoint[ik], l); } - // Call simpson integration + // PLEASE try to make Simpson_Integral as input parameters + // mohan note 2021-03-23 Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp); rs[0] = FOUR_PI / Mathzone_Add1::dualfac (2*l+1) * temp; } @@ -324,6 +327,8 @@ void ORB_table_phi::cal_ST_Phi12_R } double temp = 0.0; // Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp); + // PLEASE try to make Simpson_Integral as input parameters + // mohan note 2021-03-23 Mathzone::Simpson_Integral(kmesh,VECTOR_TO_PTR(integrated_func),dk,temp); rs[ir] = temp * FOUR_PI ; @@ -345,6 +350,8 @@ void ORB_table_phi::cal_ST_Phi12_R } } // Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp); + // PLEASE try to make Simpson_Integral as input parameters + // mohan note 2021-03-23 Mathzone::Simpson_Integral(kmesh,VECTOR_TO_PTR(integrated_func),dk,temp); drs[ir] = -FOUR_PI*(l+1)/(2.0*l+1) * temp; } @@ -360,7 +367,11 @@ void ORB_table_phi::cal_ST_Phi12_R } double temp = 0.0; // Mathzone::Simpson_Integral(kmesh,integrated_func,kab,temp); + // PLEASE try to make Simpson_Integral as input parameters + // mohan note 2021-03-23 Mathzone::Simpson_Integral(kmesh,VECTOR_TO_PTR(integrated_func),dk,temp); + // PLEASE try to make dualfac function as input parameters + // mohan note 2021-03-23 rs[0] = FOUR_PI / Mathzone_Add1::dualfac (2*l+1) * temp; } } From 76535809f31a74ebe31475b59aa9731a85877ce8 Mon Sep 17 00:00:00 2001 From: zdy Date: Tue, 23 Mar 2021 23:39:56 +0800 Subject: [PATCH 230/233] update some MD refactor files --- ABACUS.develop/source/src_pw/MD_func.cpp | 612 +++++++++++++++++++ ABACUS.develop/source/src_pw/MD_func.h | 33 + ABACUS.develop/source/src_pw/MD_parameters.h | 27 + ABACUS.develop/source/src_pw/MD_run.cpp | 540 ++++++++++++++++ ABACUS.develop/source/src_pw/MD_run.h | 24 + 5 files changed, 1236 insertions(+) create mode 100644 ABACUS.develop/source/src_pw/MD_func.cpp create mode 100644 ABACUS.develop/source/src_pw/MD_func.h create mode 100644 ABACUS.develop/source/src_pw/MD_parameters.h create mode 100644 ABACUS.develop/source/src_pw/MD_run.cpp create mode 100644 ABACUS.develop/source/src_pw/MD_run.h diff --git a/ABACUS.develop/source/src_pw/MD_func.cpp b/ABACUS.develop/source/src_pw/MD_func.cpp new file mode 100644 index 0000000000..9905f14eed --- /dev/null +++ b/ABACUS.develop/source/src_pw/MD_func.cpp @@ -0,0 +1,612 @@ +#include "MD_func.h" + + + +void MD_func::initMD(){ + //parameter from input file + mdtype=INPUT.md_mdtype; + Qmass=INPUT.md_qmass/6.02/9.109*1e5; + dt=INPUT.md_dt/fundamentalTime/1e15; + temperature=INPUT.md_tfirst/3.1577464e5; + rstMD=INPUT.md_rstmd; + dumpmdfreq=INPUT.md_dumpmdfred; + fixTemperature=INPUT.md_fixtemperature; + ediff=INPUT.md_ediff; + ediffg=INPUT.md_ediffg; + mdoutputpath=INPUT.md_mdoutpath; + NVT_control = INPUT.md_nvtcontrol; + NVT_tau = INPUT.md_nvttau; + MNHC = INPUT.md_mnhc; + + + //other parameter default + outputstressperiod = 1 ;// The period to output stress + numIon=ucell.nat; + ntype=ucell.ntype; + step_rst=0; + ionlatvec=ucell.latvec; + + mdenergy=en.etot/2; + + //allocate for MD + this->md_allocate(); + + //MD starting setup + if(rstMD==0){ + connection0(); + connection1(); + //A fresh new MD: Do not restart MD + InitVelocity() ; + // Initialize thermostat, and barostat + + } + else if ( rstMD>0 ){ + connection0(); + connection1(); + InitVelocity() ; + if(!RestartMD()){ + cout<<"error in restart MD!"<=1;j--){ + for(int k=0;k>xLogS; + file.get(); + file.ignore(7, '\n'); + // file>>vLogS; + file.get(); + file.ignore(23, '\n'); + for(i = 0;i>vell[i]; + } + /*file.get(); file.ignore(17, '\n'); + for(i=0;i>cart[i]; + } + file.get(); file.ignore(13, '\n'); + for(i=0;i>dira[i]; + }*/ + file.get(); + file.ignore(6, '\n'); + file>>step_rst; + file.close(); + } +//2015-09-05, xiaohui +#ifdef __MPI + MPI_Bcast(&step_rst,1,MPI_INT,0,MPI_COMM_WORLD); + MPI_Bcast(vell,numIon*3,MPI_DOUBLE,0,MPI_COMM_WORLD); +#endif + for(i=0;i echo_md_restart.dat, for debug purpose. "< 1&& step%dumpmdfreq==0 ) ) + pass =1; + if (!pass) return; + + if(!MY_RANK){ + stringstream ssc; + ssc << global_out_dir << "Restart_md.dat"; + ofstream file(ssc.str().c_str()); + file<<"MD_RESTART"< 0 ) + { + + // Change the temperature every 'fixTemperature' steps. + if( (step!=1)&&(step%fixTemperature == 1) ) + { + + // Read in new temperature from file. + ifstream file; + file.open("ChangeTemp.dat"); + if (!file){ + cout<<"ERROR IN OPENING ChangeTemp.dat, CODE STOP!"<> intemp; + sstep+=fixTemperature; + } + file.close(); + + // Renew information. + intemp = intemp * K_BOLTZMAN_AU; + if ( fabs(intemp-temperature) >1e-6 ) { + cout <<"(ReadNewTemp): Read in new temp:"<< intemp/K_BOLTZMAN_AU + <<" previous temp:"<< temperature/K_BOLTZMAN_AU<9999999999) return "error!"; + for(int j=9; j>-1; j--) + { + if(iter==0) continue; + if(iter>pow(10,j)-1) + { + i[k] = iter%10; + iter /= 10; + k++; + } + } + for(int j=k-1;j>-1;j--){ + path+=(i[j]+48); + } + return path; +} + +void MD_func::connection0(){ +//some prepared information +//mass and degree of freedom + int ion=0; + nfrozen=0; + for(int it=0;it=1.0) taudirac[ia].x -= 1.0; + if(taudirac[ia].y>=1.0) taudirac[ia].y -= 1.0; + if(taudirac[ia].z>=1.0) taudirac[ia].z -= 1.0; + + if(taudirac[ia].x<0 || taudirac[ia].y<0 + || taudirac[ia].z<0 || + taudirac[ia].x>=1.0 || + taudirac[ia].y>=1.0 || + taudirac[ia].z>=1.0) + { + cout << " ion: "<< ia << endl; + cout << "d=" << taudirac[ia].x << " " << + taudirac[ia].y << " " << taudirac[ia].z << endl; + WARNING_QUIT("md::moveatoms","the movement of atom is larger than the length of cell."); + } + + cartNoWrap[ia] = taudirac[ia] * ionlatvec*ucell.lat0; + } + return; +} + +void MD_func::printpos(string file,int iter) +{ +//intend to output the positions of atoms to ordered file + bool pass; + pass = 0; + + if (dumpmdfreq==1||iter==1||( dumpmdfreq > 1&& iter%dumpmdfreq==0 ) ) + pass =1; + if (!pass) return; + + string file1=file+".xyz"; + string file2=file+".cif"; + + //xiaohui add 'OUT_LEVEL', 2015-09-16 + if(OUT_LEVEL == "i"||OUT_LEVEL == "ie") ucell.print_tau(); + if(OUT_LEVEL == "i"||OUT_LEVEL == "ie") ucell.print_cell_xyz(file1); + ucell.print_cell_cif(file2); + stringstream ss; + + ss << global_out_dir << "STRU_MD"; + + //zhengdy modify 2015-05-06, outputfile "STRU_Restart" + ucell.print_stru_file(ss.str(),2); + + return; +} + +//rescale velocities to target temperature. +void MD_func::scalevel() +{ + double ke=GetAtomKE(); + if(ke>1e-9) + for(int i=0;i fracStep; + for(int ii=0;iimaxStep) + { + maxStep = pow(vel[ii].x,2)+pow(vel[ii].y,2)+pow(vel[ii].z,2); + } + Mathzone::Cartesian_to_Direct(vel[ii].x*dt/ucell.lat0,vel[ii].y*dt/ucell.lat0,vel[ii].z*dt/ucell.lat0, + ionlatvec.e11,ionlatvec.e12,ionlatvec.e13, + ionlatvec.e21,ionlatvec.e22,ionlatvec.e23, + ionlatvec.e31,ionlatvec.e32,ionlatvec.e33, + fracStep.x,fracStep.y,fracStep.z); + + taudirac[ii] = taudirac[ii] + fracStep; + } + + //save the atom position change to DFT module + moveatoms(step); + string t("md_pos_"); + t=intTurnTostring(step,t); + connection2(); + printpos(t,step); + maxStep = sqrt(maxStep)*dt; + + if (!MY_RANK){ + out<maxStep) + { + maxStep = pow(vel[i].x,2.0)+pow(vel[i].y,2.0)+pow(vel[i].z,2.0); + } + Mathzone::Cartesian_to_Direct(vel[i].x*dt/ucell.lat0,vel[i].y*dt/ucell.lat0,vel[i].z*dt/ucell.lat0, + ionlatvec.e11,ionlatvec.e12,ionlatvec.e13, + ionlatvec.e21,ionlatvec.e22,ionlatvec.e23, + ionlatvec.e31,ionlatvec.e32,ionlatvec.e33, + fracStep.x,fracStep.y,fracStep.z); + taudirac[i] = taudirac[i] + fracStep; + } + moveatoms(step); + string t("md_pos_"); + t=intTurnTostring(step,t); + connection2(); + printpos(t,step); + maxStep = sqrt(maxStep)*dt; + + + // calculate the conserved quantity during MD + hamiltonian = Conserved(twiceKE/2, mdenergy); + + cout<< setprecision (9)<maxStep) + { + maxStep = pow(vel[i].x,2.0)+pow(vel[i].y,2.0)+pow(vel[i].z,2.0); + } + Mathzone::Cartesian_to_Direct(vel[i].x*dt/ucell.lat0,vel[i].y*dt/ucell.lat0,vel[i].z*dt/ucell.lat0, + ionlatvec.e11,ionlatvec.e12,ionlatvec.e13, + ionlatvec.e21,ionlatvec.e22,ionlatvec.e23, + ionlatvec.e31,ionlatvec.e32,ionlatvec.e33, + fracStep.x,fracStep.y,fracStep.z); + taudirac[i] = taudirac[i] + fracStep; + } + + moveatoms(step); + string t("md_pos_"); + t=intTurnTostring(step,t); + connection2(); + printpos(t,step); + maxStep = sqrt(maxStep)*dt; + + hamiltonian = Conserved(twiceKE/2, mdenergy); + + + + + // Output the message to the screen. + oldEtot=mdenergy; + + cout<<"(NVE): this step finished."< Date: Wed, 24 Mar 2021 12:22:51 +0800 Subject: [PATCH 231/233] 1. In exx, when input cauchy or schwarz threshold = 0, set the flag of cauchy or schwarz to false. 2. set the default input newdm = 1 --- ABACUS.develop/source/input.cpp | 4 ++-- ABACUS.develop/source/src_io/write_input.cpp | 1 + .../source/src_ri/exx_abfs-screen-cauchy.cpp | 2 ++ .../source/src_ri/exx_abfs-screen-cauchy.h | 22 +++++++++---------- .../source/src_ri/exx_abfs-screen-schwarz.cpp | 18 --------------- .../source/src_ri/exx_abfs-screen-schwarz.h | 21 +++++++++++++++++- ABACUS.develop/source/src_ri/exx_lcao.cpp | 4 ++-- 7 files changed, 38 insertions(+), 34 deletions(-) diff --git a/ABACUS.develop/source/input.cpp b/ABACUS.develop/source/input.cpp index 6b08824743..6eb42a40ec 100644 --- a/ABACUS.develop/source/input.cpp +++ b/ABACUS.develop/source/input.cpp @@ -456,7 +456,7 @@ void Input::Default(void) cell_factor = 1.2; //LiuXh add 20180619 - newDM=0; // Shen Yu add 2019/5/9 + newDM=1; // Shen Yu add 2019/5/9 mulliken=0;// qi feng add 2019/9/10 //---------------------------------------------------------- //Peize Lin add 2020-04-04 @@ -2291,7 +2291,7 @@ void Input::Bcast() #endif - void Input::Check(void) +void Input::Check(void) { TITLE("Input","Check"); diff --git a/ABACUS.develop/source/src_io/write_input.cpp b/ABACUS.develop/source/src_io/write_input.cpp index 0b6f1a9fa9..a326192f9f 100644 --- a/ABACUS.develop/source/src_io/write_input.cpp +++ b/ABACUS.develop/source/src_io/write_input.cpp @@ -32,6 +32,7 @@ void Input::Print(const string &fn)const OUTP(ofs,"nche_sto",nche_sto,"number of orders for Chebyshev expansion in stochastic DFT"); OUTP(ofs,"symmetry",symmetry,"turn symmetry on or off"); OUTP(ofs,"nelec",nelec,"input number of electrons"); + OUTP(ofs,"newdm",newDM,""); ofs << "\n#Parameters (2.PW)" << endl; OUTP(ofs,"ecutwfc",ecutwfc,"#energy cutoff for wave functions"); diff --git a/ABACUS.develop/source/src_ri/exx_abfs-screen-cauchy.cpp b/ABACUS.develop/source/src_ri/exx_abfs-screen-cauchy.cpp index da8a7dc4bc..bdb3470033 100644 --- a/ABACUS.develop/source/src_ri/exx_abfs-screen-cauchy.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-screen-cauchy.cpp @@ -158,6 +158,8 @@ Exx_Abfs::Screen::Cauchy::Info_Step Exx_Abfs::Screen::Cauchy::input_info( const Abfs::Vector3_Order & box3, const Abfs::Vector3_Order & box4 ) const { + if(!flag_screen_cauchy) return Info_Step(); + Info_Step info_step; info_step.C1_norm4_max = C_norm4_outer_max.at(iat1).at(iat3).at(box3); diff --git a/ABACUS.develop/source/src_ri/exx_abfs-screen-cauchy.h b/ABACUS.develop/source/src_ri/exx_abfs-screen-cauchy.h index 3baa3ba737..0c27ec3752 100644 --- a/ABACUS.develop/source/src_ri/exx_abfs-screen-cauchy.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-screen-cauchy.h @@ -11,20 +11,20 @@ class Exx_Abfs::Screen::Cauchy public: struct Info_Step { - double C1_norm4_max; - double C3_norm4_max; - double C2_norm4_max; - double C4_norm4_max; + double C1_norm4_max = 0.0; + double C3_norm4_max = 0.0; + double C2_norm4_max = 0.0; + double C4_norm4_max = 0.0; - double C1_norm2_max; - double C3_norm2_max; + double C1_norm2_max = 0.0; + double C3_norm2_max = 0.0; - double V_norm4; + double V_norm4 = 0.0; - double D34_norm4_max; - double D32_norm4_max; - double D14_norm4_max; - double D12_norm4_max; + double D34_norm4_max = 0.0; + double D32_norm4_max = 0.0; + double D14_norm4_max = 0.0; + double D12_norm4_max = 0.0; }; public: diff --git a/ABACUS.develop/source/src_ri/exx_abfs-screen-schwarz.cpp b/ABACUS.develop/source/src_ri/exx_abfs-screen-schwarz.cpp index 748dd162c7..7b79bf8dd8 100644 --- a/ABACUS.develop/source/src_ri/exx_abfs-screen-schwarz.cpp +++ b/ABACUS.develop/source/src_ri/exx_abfs-screen-schwarz.cpp @@ -136,22 +136,4 @@ void Exx_Abfs::Screen::Schwarz::cal_max_pair_fock( pthread_rwlock_destroy(&rwlock_Vw); //test_screen("schwarz-max_pair_fock.dat",max_pair_fock); -} - -bool Exx_Abfs::Screen::Schwarz::screen( - const size_t iat1, const size_t iat2, const size_t iat3, const size_t iat4, - const Abfs::Vector3_Order & box3, const Abfs::Vector3_Order & box4 ) const -{ - if(!flag_screen_schwarz) - return false; - if( max_pair_fock.at(iat1).at(iat3).at(box3) * max_pair_fock.at(iat2).at(iat4).at(box4) > threshold ) - { -// num_cal += 1; - return false; - } - else - { -// num_screen += 1; - return true; - } } \ No newline at end of file diff --git a/ABACUS.develop/source/src_ri/exx_abfs-screen-schwarz.h b/ABACUS.develop/source/src_ri/exx_abfs-screen-schwarz.h index 948a72d337..722747bb62 100644 --- a/ABACUS.develop/source/src_ri/exx_abfs-screen-schwarz.h +++ b/ABACUS.develop/source/src_ri/exx_abfs-screen-schwarz.h @@ -24,7 +24,7 @@ class Exx_Abfs::Screen::Schwarz const Abfs::Vector3_Order &Born_von_Karman_period, map,weak_ptr>>> &Cws, map,weak_ptr>>> &Vws ); - bool screen( + inline bool screen( const size_t iat1, const size_t iat2, const size_t iat3, const size_t iat4, const Abfs::Vector3_Order & box3, const Abfs::Vector3_Order & box4 ) const; @@ -38,4 +38,23 @@ class Exx_Abfs::Screen::Schwarz // static double num_cal; }; + +bool Exx_Abfs::Screen::Schwarz::screen( + const size_t iat1, const size_t iat2, const size_t iat3, const size_t iat4, + const Abfs::Vector3_Order & box3, const Abfs::Vector3_Order & box4 ) const +{ + if(!flag_screen_schwarz) + return false; + if( max_pair_fock.at(iat1).at(iat3).at(box3) * max_pair_fock.at(iat2).at(iat4).at(box4) > threshold ) + { +// num_cal += 1; + return false; + } + else + { +// num_screen += 1; + return true; + } +} + #endif \ No newline at end of file diff --git a/ABACUS.develop/source/src_ri/exx_lcao.cpp b/ABACUS.develop/source/src_ri/exx_lcao.cpp index b23367168e..78f6b55085 100644 --- a/ABACUS.develop/source/src_ri/exx_lcao.cpp +++ b/ABACUS.develop/source/src_ri/exx_lcao.cpp @@ -863,11 +863,11 @@ gettimeofday( &t_start, NULL); ofs_mpi<<"TIME@ Abfs::cal_Cps\t"< Date: Wed, 24 Mar 2021 14:39:32 +0800 Subject: [PATCH 232/233] fixed time recording bug in pw line and jiyy input bug --- ABACUS.develop/source/input.cpp | 2 +- ABACUS.develop/source/run_pw.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ABACUS.develop/source/input.cpp b/ABACUS.develop/source/input.cpp index 6eb42a40ec..af16488f3f 100644 --- a/ABACUS.develop/source/input.cpp +++ b/ABACUS.develop/source/input.cpp @@ -1484,7 +1484,7 @@ bool Input::Read(const string &fn) else if (strcmp("ocp_set", word) == 0) { getline(ifs, ocp_set); - ifs.ignore(150, '\n'); +// ifs.ignore(150, '\n'); } // else if (strcmp("ocp_n", word) == 0) // { diff --git a/ABACUS.develop/source/run_pw.cpp b/ABACUS.develop/source/run_pw.cpp index dfab7248f8..11d5a834e7 100644 --- a/ABACUS.develop/source/run_pw.cpp +++ b/ABACUS.develop/source/run_pw.cpp @@ -206,6 +206,6 @@ void Run_pw::plane_wave_line(void) // compute density of states en.perform_dos(); - timer::tick("Run_Frag","plane_wave_line",'B'); + timer::tick("Run_pw","plane_wave_line",'B'); return; } From 23f54d91cb1e746f75958a623d722056d0556af7 Mon Sep 17 00:00:00 2001 From: zdy Date: Fri, 26 Mar 2021 00:22:11 +0800 Subject: [PATCH 233/233] update some notes in write_input.cpp --- ABACUS.develop/source/src_io/write_input.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ABACUS.develop/source/src_io/write_input.cpp b/ABACUS.develop/source/src_io/write_input.cpp index a326192f9f..c715edc478 100644 --- a/ABACUS.develop/source/src_io/write_input.cpp +++ b/ABACUS.develop/source/src_io/write_input.cpp @@ -62,7 +62,7 @@ void Input::Print(const string &fn)const OUTP(ofs,"nz",nz,"number of points along z axis for FFT grid"); ofs << "\n#Parameters (3.Relaxation)" << endl; - OUTP(ofs,"ks_solver",KS_SOLVER,"cg; david; lapack; genelpa; hpseps; scalapack_gvx"); + OUTP(ofs,"ks_solver",KS_SOLVER,"cg; dav; lapack; genelpa; hpseps; scalapack_gvx"); OUTP(ofs,"niter",niter,"#number of electron iterations"); OUTP(ofs,"force_set",force_set,"output the force_set or not"); OUTP(ofs,"nstep",nstep,"number of ion iteration steps"); @@ -108,11 +108,11 @@ void Input::Print(const string &fn)const OUTP(ofs,"bz",bz,"division of an element grid in FFT grid along z"); ofs << "\n#Parameters (5.Smearing)" << endl; - OUTP(ofs,"smearing",smearing,"type of smearing: gauss; fd; fixed; mp; mp2"); + OUTP(ofs,"smearing",smearing,"type of smearing: gauss; fd; fixed; mp; mp2; mv"); OUTP(ofs,"sigma",degauss,"energy range for smearing"); ofs << "\n#Parameters (6.Charge Mixing)" << endl; - OUTP(ofs,"mixing_type",mixing_mode,"plain; kerker; pulay; pulay-kerker"); + OUTP(ofs,"mixing_type",mixing_mode,"plain; kerker; pulay; pulay-kerker; broyden"); OUTP(ofs,"mixing_beta",mixing_beta,"mixing parameter: 0 means no new charge"); OUTP(ofs,"mixing_ndim",mixing_ndim,"mixing dimension in pulay"); OUTP(ofs,"mixing_gg0",mixing_gg0,"mixing parameter in kerker"); @@ -124,7 +124,7 @@ void Input::Print(const string &fn)const OUTP(ofs,"dos_sigma",b_coef,"gauss b coefficeinet(default=0.07)"); ofs << "\n#Parameters (8.Technique)" << endl; - OUTP(ofs,"gamma_only",gamma_only,"gamma only"); + OUTP(ofs,"gamma_only",gamma_only,"gamma only, only used in LCAO basis"); OUTP(ofs,"diago_proc",DIAGO_PROC,"number of proc used to diago"); OUTP(ofs,"npool",npool,"number of pools for k points, pw only"); OUTP(ofs,"mem_saver",mem_saver,"memory saver for many k points used");