Skip to content

Feature: support list input parse and multiple values for bessel_nao_rcut#3454

Merged
kirk0830 merged 6 commits intodeepmodeling:developfrom
kirk0830:bessel_nao_rcut-1
Jan 10, 2024
Merged

Feature: support list input parse and multiple values for bessel_nao_rcut#3454
kirk0830 merged 6 commits intodeepmodeling:developfrom
kirk0830:bessel_nao_rcut-1

Conversation

@kirk0830
Copy link
Collaborator

@kirk0830 kirk0830 commented Jan 9, 2024

Feature

Present implementation

Under project of ABACUS Pseudopot-Nao Square (APNS), for quick generation of numerical orbitals and corresponding quick tests in batch, the orbital generation procedure needs to be fast as much as possible. I find present workflow of orbital generation will run identical SCF (differs only with bessel_nao_rcut) for times as many as rcut requested by user. Therefore I make ABACUS support mutiple values of bessel_nao_rcut.
For example, If only one value is given to keyword bessel_nao_rcut in INPUT:

...
bessel_nao_rcut     7
...

One can still find the overlap matrices calculated and named in original way:

root@legion:~/documents/simulation/abacus/test_bessel_nao_rcut/OUT.Er-STRU1-8-2.8# ll
total 28880
drwxr-xr-x 2 root root     4096 Jan  9 11:24 ./
drwxr-xr-x 4 root root     4096 Jan  9 11:24 ../
-rw-r--r-- 1 root root 14778818 Jan  9 11:24 orb_matrix.0.dat
-rw-r--r-- 1 root root 14779187 Jan  9 11:24 orb_matrix.1.dat

If four values given, which means in INPUT it is:

...
bessel_nao_rcut     7 8 9 10
...

Then stdout wil be like:

                                                                                     
                              ABACUS v3.5.0

               Atomic-orbital Based Ab-initio Computation at UStc                    

                     Website: http://abacus.ustc.edu.cn/                             
               Documentation: https://abacus.deepmodeling.com/                       
                  Repository: https://github.com/abacusmodeling/abacus-develop       
                              https://github.com/deepmodeling/abacus-develop         
                      Commit: 8afa4d05d (Tue Jan 9 10:57:24 2024 +0800)

 Tue Jan  9 11:43:18 2024
 MAKE THE DIR         : OUT.Er-STRU1-8-2.8/
 RUNNING WITH DEVICE  : CPU / Intel(R)%Xeon(R)%Platinum
 UNIFORM GRID DIM        : 128 * 128 * 128
 UNIFORM GRID DIM(BIG)   : 128 * 128 * 128
 DONE(0.0601203  SEC) : SETUP UNITCELL
 DONE(0.0604865  SEC) : INIT K-POINTS
 ---------------------------------------------------------
 Self-consistent calculations for electrons
 ---------------------------------------------------------
 SPIN    KPOINTS         PROCESSORS  
 1       1               16          
 ---------------------------------------------------------
 Use plane wave basis
 ---------------------------------------------------------
 ELEMENT NATOM       XC          
 Er      2           
 ---------------------------------------------------------
 Initial plane wave basis and FFT box
 ---------------------------------------------------------
 DONE(0.0734675  SEC) : INIT PLANEWAVE
 MEMORY FOR PSI (MB)  : 4.24988
 DONE(0.173127   SEC) : LOCAL POTENTIAL
 DONE(0.23356    SEC) : NON-LOCAL POTENTIAL
 DONE(0.390492   SEC) : INIT BASIS
 -------------------------------------------
 SELF-CONSISTENT : 
 -------------------------------------------
 START CHARGE      : atomic
 DONE(0.708638   SEC) : INIT SCF
 ITER   ETOT(eV)       EDIFF(eV)      DRHO       TIME(s)    
 CG1    -2.448479e+03  0.000000e+00   4.493e-01  1.959e+00  
 CG2    -2.449854e+03  -1.374351e+00  2.098e-01  1.336e+00  
 CG3    -2.450345e+03  -4.913768e-01  3.520e-03  1.030e+00  
 CG4    -2.450357e+03  -1.196023e-02  1.163e-03  2.260e+00  
 CG5    -2.450359e+03  -1.459728e-03  2.785e-04  1.256e+00  
 CG6    -2.450359e+03  -5.938095e-04  1.842e-04  1.465e+00  
 CG7    -2.450360e+03  -8.549907e-04  5.625e-05  1.024e+00  
 CG8    -2.450361e+03  -5.595582e-04  3.645e-05  1.481e+00  
 CG9    -2.450361e+03  -4.486177e-04  1.996e-05  1.287e+00  
 CG10   -2.450361e+03  -3.566487e-04  1.292e-05  1.585e+00  
 CG11   -2.450361e+03  -1.622941e-04  5.167e-07  1.731e+00  
 CG12   -2.450362e+03  -3.426222e-05  4.295e-07  2.575e+00  
 CG13   -2.450362e+03  -1.644875e-05  5.872e-08  1.714e+00  
update value: bessel_nao_rcut <- 7.000 a.u.
 DONE(26.973     SEC) : cal_overlap_Q
 DONE(39.772     SEC) : cal_overlap_Sq
 DONE(43.926     SEC) : cal_overlap_Q
 DONE(57.017     SEC) : cal_overlap_Sq
update value: bessel_nao_rcut <- 8.000 a.u.
 DONE(61.169     SEC) : cal_overlap_Q
 DONE(74.182     SEC) : cal_overlap_Sq
 DONE(78.270     SEC) : cal_overlap_Q
 DONE(91.244     SEC) : cal_overlap_Sq
update value: bessel_nao_rcut <- 9.000 a.u.
 DONE(95.460     SEC) : cal_overlap_Q
 DONE(108.472    SEC) : cal_overlap_Sq
 DONE(112.553    SEC) : cal_overlap_Q
 DONE(125.577    SEC) : cal_overlap_Sq
update value: bessel_nao_rcut <- 10.000 a.u.
 DONE(129.774    SEC) : cal_overlap_Q
 DONE(142.820    SEC) : cal_overlap_Sq
 DONE(147.045    SEC) : cal_overlap_Q
 DONE(160.081    SEC) : cal_overlap_Sq
 DONE(161.197    SEC) : BASIS OVERLAP (Q and S) GENERATION.

One can find four groups of files in OUT.${suffix}:

root@legion:~/documents/simulation/abacus/test_bessel_nao_rcut/OUT.Er-STRU1-8-2.8# ll
total 115496
drwxr-xr-x 2 root root     4096 Jan  9 11:28 ./
drwxr-xr-x 4 root root     4096 Jan  9 11:28 ../
-rw-r--r-- 1 root root 14778818 Jan  9 11:28 orb_matrix_rcut10deriv0.dat
-rw-r--r-- 1 root root 14779187 Jan  9 11:28 orb_matrix_rcut10deriv1.dat
-rw-r--r-- 1 root root 14778818 Jan  9 11:28 orb_matrix_rcut7deriv0.dat
-rw-r--r-- 1 root root 14779187 Jan  9 11:28 orb_matrix_rcut7deriv1.dat
-rw-r--r-- 1 root root 14778818 Jan  9 11:28 orb_matrix_rcut8deriv0.dat
-rw-r--r-- 1 root root 14779187 Jan  9 11:28 orb_matrix_rcut8deriv1.dat
-rw-r--r-- 1 root root 14778818 Jan  9 11:28 orb_matrix_rcut9deriv0.dat
-rw-r--r-- 1 root root 14779187 Jan  9 11:28 orb_matrix_rcut9deriv1.dat

For python-end the PTG_dpsi, I will submit PR to repo ABACUS-orbitals: https://github.com/abacusmodeling/ABACUS-orbitals

Future heterogeneous container demand

Present implementation suggests use std::vector<std::string> to get value from input, then cast values one-by-one and case-by-case to values in datatype required.

Reminder

  • Have you linked an issue with this pull request?
  • Have you noticed possible changes of behavior below or in the linked issue?
  • Have you explained the changes of codes in core modules of ESolver, HSolver, ElecState, Hamilt, Operator or Psi? (ignore if not applicable)

Linked Issue

Fix #3334

What's changed?

  • Add template function template <typename T> read_value2stdvector(std::ifstream& ifs, std::vector<T>& var) in module_io/input, Input class, along with two instantiation for int and double.
  • Add corresponding unittest.
  • Add variable std::vector<double> bessel_nao_rcuts
  • Support multiple values input of bessel_nao_rcut, save the first value to INPUT.bessel_nao_rcut and all values to INPUT.bessel_nao_rcuts by read_value2stdvector.
  • Therefore support a external loop over calculation of OVERLAP_Q and OVERLAP_S by numerical basis instance in esolver_ks_pw.cpp.
  • still compatible with the old one, if only one value is given to keyword bessel_nao_rcut

Any changes of core modules? (ignore if not applicable)

  • expand the behavior of numerical basis

Copy link
Collaborator

@WHUweiqingzhou WHUweiqingzhou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR offers a new function Input::read_value2stdvector to read a vector<T> from one line. For heterogeneous vector, you can use string first, and cast which type you want.

@kirk0830 kirk0830 merged commit 3ac28ab into deepmodeling:develop Jan 10, 2024
@kirk0830 kirk0830 deleted the bessel_nao_rcut-1 branch January 10, 2024 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bessel_nao_rcut can support multiple parameter input to reduce orbital generation time cost

4 participants