Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into diag
  • Loading branch information
root committed Jan 6, 2025
2 parents 9825563 + e25db6e commit 83e1ebf
Show file tree
Hide file tree
Showing 440 changed files with 13,567 additions and 12,546 deletions.
24 changes: 16 additions & 8 deletions docs/advanced/input_files/input-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- [ndx, ndy, ndz](#ndx-ndy-ndz)
- [pw\_seed](#pw_seed)
- [pw\_diag\_thr](#pw_diag_thr)
- [diago\_smooth\_ethr](#diago_smooth_ethr)
- [pw\_diag\_nmax](#pw_diag_nmax)
- [pw\_diag\_ndim](#pw_diag_ndim)
- [diag\_subspace](#diag_subspace)
Expand Down Expand Up @@ -791,6 +792,12 @@ These variables are used to control the plane wave related parameters.
- **Description**: Only used when you use `ks_solver = cg/dav/dav_subspace/bpcg`. It indicates the threshold for the first electronic iteration, from the second iteration the pw_diag_thr will be updated automatically. **For nscf calculations with planewave basis set, pw_diag_thr should be <= 1e-3.**
- **Default**: 0.01

### diago_smooth_ethr

- **Type**: bool
- **Description**: If `TRUE`, the smooth threshold strategy, which applies a larger threshold (10e-5) for the empty states, will be implemented in the diagonalization methods. (This strategy should not affect total energy, forces, and other ground-state properties, but computational efficiency will be improved.) If `FALSE`, the smooth threshold strategy will not be applied.
- **Default**: false

### pw_diag_nmax

- **Type**: Integer
Expand Down Expand Up @@ -1391,6 +1398,7 @@ These variables are used to control the geometry relaxation.
- **Description**: The methods to do geometry optimization.
- cg: using the conjugate gradient (CG) algorithm. Note that there are two implementations of the conjugate gradient (CG) method, see [relax_new](#relax_new).
- bfgs: using the Broyden–Fletcher–Goldfarb–Shanno (BFGS) algorithm.
- bfgs_trad: using the traditional Broyden–Fletcher–Goldfarb–Shanno (BFGS) algorithm.
- cg_bfgs: using the CG method for the initial steps, and switching to BFGS method when the force convergence is smaller than [relax_cg_thr](#relax_cg_thr).
- sd: using the steepest descent (SD) algorithm.
- fire: the Fast Inertial Relaxation Engine method (FIRE), a kind of molecular-dynamics-based relaxation algorithm, is implemented in the molecular dynamics (MD) module. The algorithm can be used by setting [calculation](#calculation) to `md` and [md_type](#md_type) to `fire`. Also ionic velocities should be set in this case. See [fire](../md.md#fire) for more details.
Expand Down Expand Up @@ -1569,10 +1577,8 @@ These variables are used to control the output of properties.
### out_freq_elec

- **Type**: Integer
- **Description**: The output frequency of the charge density (controlled by [out_chg](#out_chg)), wavefunction (controlled by [out_wfc_pw](#out_wfc_pw) or [out_wfc_r](#out_wfc_r)), and density matrix of localized orbitals (controlled by [out_dm](#out_dm)).
- \>0: Output them every `out_freq_elec` iteration numbers in electronic iterations.
- 0: Output them when the electronic iteration is converged or reaches the maximal iteration number.
- **Default**: 0
- **Description**: Output the charge density (only binary format, controlled by [out_chg](#out_chg)), wavefunction (controlled by [out_wfc_pw](#out_wfc_pw) or [out_wfc_r](#out_wfc_r)) per `out_freq_elec` electronic iterations. Note that they are always output when converged or reach the maximum iterations [scf_nmax](#scf_nmax).
- **Default**: [scf_nmax](#scf_nmax)

### out_chg

Expand Down Expand Up @@ -2068,7 +2074,7 @@ Warning: this function is not robust enough for the current version. Please try
- **Type**: int
- **Availability**: numerical atomic orbital basis
- **Description**: Include V_delta label for DeePKS training. When `deepks_out_labels` is true and `deepks_v_delta` > 0, ABACUS will output h_base.npy, v_delta.npy and h_tot.npy(h_tot=h_base+v_delta).
Meanwhile, when `deepks_v_delta` equals 1, ABACUS will also output v_delta_precalc.npy, which is used to calculate V_delta during DeePKS training. However, when the number of atoms grows, the size of v_delta_precalc.npy will be very large. In this case, it's recommended to set `deepks_v_delta` as 2, and ABACUS will output psialpha.npy and grad_evdm.npy but not v_delta_precalc.npy. These two files are small and can be used to calculate v_delta_precalc in the procedure of training DeePKS.
Meanwhile, when `deepks_v_delta` equals 1, ABACUS will also output v_delta_precalc.npy, which is used to calculate V_delta during DeePKS training. However, when the number of atoms grows, the size of v_delta_precalc.npy will be very large. In this case, it's recommended to set `deepks_v_delta` as 2, and ABACUS will output phialpha.npy and grad_evdm.npy but not v_delta_precalc.npy. These two files are small and can be used to calculate v_delta_precalc in the procedure of training DeePKS.
- **Default**: 0

### deepks_out_unittest
Expand Down Expand Up @@ -2454,10 +2460,11 @@ These variables are relevant when using hybrid functionals.
### exx_ccp_rmesh_times

- **Type**: Real
- **Description**: This parameter determines how many times larger the radial mesh required for calculating Columb potential is to that of atomic orbitals. For HSE, setting it to 1 is enough. But for PBE0, a much larger number must be used.
- **Description**: This parameter determines how many times larger the radial mesh required for calculating Columb potential is to that of atomic orbitals. The value should be at least 1. Reducing this value can effectively increase the speed of self-consistent calculations using hybrid functionals.
- **Default**:
- 1.5: if *[dft_functional](#dft_functional)==hse*
- 5: else
- 5: if *[dft_functional](#dft_functional)==hf/pbe0/scan0/muller/power/wp22*
- 1.5: if *[dft_functional](#dft_functional)==hse/cwp22*
- 1: else

### exx_distribute_type

Expand Down Expand Up @@ -2496,6 +2503,7 @@ These variables are relevant when using hybrid functionals.
- **Description**:
- True: Enforce LibRI to use `double` data type.
- False: Enforce LibRI to use `complex` data type.
Setting it to True can effectively improve the speed of self-consistent calculations with hybrid functionals.
- **Default**: depends on the [gamma_only](#gamma_only) option
- True: if gamma_only
- False: else
Expand Down
4 changes: 3 additions & 1 deletion docs/advanced/opt.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ In the nested procedure mentioned above, we used CG method to perform cell relax

The [BFGS method](https://en.wikipedia.org/wiki/Broyden%E2%80%93Fletcher%E2%80%93Goldfarb%E2%80%93Shanno_algorithm) is a quasi-Newton method for solving nonlinear optimization problem. It belongs to the class of quasi-Newton method where the Hessian matrix is approximated during the optimization process. If the initial point is not far from the extrema, BFGS tends to work better than gradient-based methods.

In ABACUS, we implemented the BFGS method for doing fixed-cell structural relaxation.
There is an alternative traditional BFGS method, which can be called by using the keyword 'bfgs_trad'. The bfgs_trad method is a quasi-Newton method that substitute an approximate matrix B for the Hessian matrix. The main difference between 'bfgs' and 'bfgs_trad' is that 'bfgs' updates the inverse of matrix B while 'bfgs_trad' updates matrix B and obtains the inverse of B by solving the matrix eigenvalues and taking the reciprocal of the eigenvalues. Both methods are mathematically equivalent, but in some cases, 'bfgs_trad' performs better.

In ABACUS, we implemented the BFGS method for doing fixed-cell structural relaxation. Users can choose which implementation of BFGS to call by adding the 'bfgs_trad' or 'bfgs' parameter.

### SD method

Expand Down
35 changes: 18 additions & 17 deletions docs/quick_start/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ The `INPUT` file contains parameters that control the type of calculation as wel

Below is an example `INPUT` file with some of the most important parameters that need to be set:

```
```plaintext
INPUT_PARAMETERS
suffix MgO
ntype 2
pseudo_dir ./
orbital_dir ./
ecutwfc 100 # Rydberg
scf_thr 1e-4 # Rydberg
basis_type lcao
calculation scf # this is the key parameter telling abacus to do a scf calculation
out_chg True
orbital_dir ./
ecutwfc 100 # in Rydberg
scf_thr 1e-4 # Rydberg
basis_type lcao
calculation scf # this is the key parameter telling abacus to do a scf calculation
out_chg True
```

The parameter list always starts with key word `INPUT_PARAMETERS`. Any content before `INPUT_PARAMETERS` will be ignored.
Expand All @@ -40,22 +40,23 @@ In the above example, the meanings of the parameters are:
- `ntype` : how many types of elements in the unit cell
- `pseudo_dir` : the directory where pseudopotential files are provided
- `orbital_dir` : the directory where orbital files are provided
- `ecutwfc` : the plane-wave energy cutoff for the wave function expansion (UNIT: Rydberg)
- `scf_thr` : the threshold for the convergence of charge density (UNIT: Rydberg)
- `ecutwfc` : the plane-wave energy cutoff for the wave function expansion (UNIT: Rydberg)
- `scf_thr` : the threshold for the convergence of charge density (UNIT: Rydberg)
- `basis_type` : the type of basis set for expanding the electronic wave functions
- `calculation` : the type of calculation to be performed by ABACUS
- `out_chg` : if true, output thee charge density oon real space grid
- `out_chg` : if true, output the charge density on real space grid

For a complete list of input parameters, please consult this [instruction](../advanced/input_files/input-main.md).

> **Note:** Users cannot change the filename “INPUT” to other names. Boolean paramerters such as `out_chg` can be set by using `True` and `False`, `1` and `0`, or `T` and `F`. It is case insensitive so that other preferences such as `true` and `false`, `TRUE` and `FALSE`, and `t` and `f` for setting boolean values are also supported.
> **Note:** Users cannot change the filename “INPUT” to other names. Boolean paramerters such as `out_chg` can be set by using `True` and `False`, `1` and `0`, or `T` and `F`. It is case insensitive so that other preferences such as `true` and `false`, `TRUE` and `FALSE`, and `t` and `f` for setting boolean values are also supported. Specifically for the `out_chg`, `-1` option is also available, which means turn off the checkpoint of charge density in binary (always dumped in `OUT.{suffix}`, whose name ends with `CHARGE-DENSITY.restart`). Some parameters controlling the output also support a second option to control the output precision, e.g., `out_chg True 8` will output the charge density on realspace grid with 8 digits after the decimal point.
## *STRU*

The structure file contains structural information about the system, e.g., lattice constant, lattice vectors, and positions of the atoms within a unit cell. The positions can be given either in direct or Cartesian coordinates.
The structure file contains structural information about the system, e.g., lattice constant, lattice vectors, and positions of the atoms within a unit cell. The positions can be given either in direct or Cartesian coordinates.

An example of the `STRU` file is given as follows :
```

```plaintext
#This is the atom file containing all the information
#about the lattice structure.
Expand All @@ -68,7 +69,7 @@ Mg_gga_8au_100Ry_4s2p1d.orb
O_gga_8au_100Ry_2s2p1d.orb
LATTICE_CONSTANT
1.8897259886 # 1.8897259886 Bohr = 1.0 Angstrom
1.8897259886 # 1.8897259886 Bohr = 1.0 Angstrom
LATTICE_VECTORS
4.25648 0.00000 0.00000
Expand Down Expand Up @@ -100,9 +101,10 @@ For a more detailed description of STRU file, please consult [here](../advanced/
## *KPT*

This file contains information of the kpoint grid setting for the Brillouin zone sampling.

An example of the `KPT` file is given below:
```

```plaintext
K_POINTS
0
Gamma
Expand All @@ -111,7 +113,6 @@ Gamma

> **Note:** users may choose a different name for their k-point file using keyword `kpoint_file`

For a more detailed description, please consult [here](../advanced/input_files/kpt.md).

- The pseudopotential files
Expand Down
3 changes: 3 additions & 0 deletions examples/lr-tddft/lcao_H2O/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ orbital_dir ../../../tests/PP_ORB
calculation scf
nbands 23
symmetry -1
nspin 2

#Parameters (2.Iteration)
ecutwfc 60 ###Energy cutoff needs to be tested to ensure your calculation is reliable.[1]
Expand All @@ -30,6 +31,7 @@ xc_kernel lda
lr_solver dav
lr_thr 1e-2
pw_diag_ndim 2
# lr_unrestricted 1 ### use this to do TDUKS calculation for closeshell systems (openshell system will force TDUKS)

esolver_type ks-lr
out_alllog 1
Expand All @@ -39,6 +41,7 @@ out_alllog 1
nvirt 19
abs_wavelen_range 40 180
abs_broadening 0.01
abs_gauge length

### [1] Energy cutoff determines the quality of numerical quadratures in your calculations.
### So it is strongly recommended to test whether your result (such as converged SCF energies) is
Expand Down
5 changes: 4 additions & 1 deletion examples/lr-tddft/lcao_Si2/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ pseudo_dir ../../../tests/PP_ORB
orbital_dir ../../../tests/PP_ORB
calculation scf
nbands 23
symmetry 0
symmetry -1
nspin 2

#Parameters (2.Iteration)
ecutwfc 60 ###Energy cutoff needs to be tested to ensure your calculation is reliable.[1]
Expand Down Expand Up @@ -37,6 +38,8 @@ out_alllog 1

nvirt 19
abs_wavelen_range 100 175
abs_broadening 0.01 # in Ry
abs_gauge velocity ### velocity gauge is recommended for periodic systems


### [1] Energy cutoff determines the quality of numerical quadratures in your calculations.
Expand Down
21 changes: 11 additions & 10 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -187,25 +187,26 @@ OBJS_CELL=atom_pseudo.o\
klist.o\
cell_index.o\
check_atomic_stru.o\
update_cell.o\
bcast_cell.o\

OBJS_DEEPKS=LCAO_deepks.o\
deepks_fgamma.o\
deepks_fk.o\
LCAO_deepks_odelta.o\
deepks_force.o\
deepks_descriptor.o\
deepks_orbital.o\
deepks_orbpre.o\
deepks_vdpre.o\
deepks_hmat.o\
LCAO_deepks_io.o\
LCAO_deepks_mpi.o\
LCAO_deepks_pdm.o\
LCAO_deepks_psialpha.o\
LCAO_deepks_phialpha.o\
LCAO_deepks_torch.o\
LCAO_deepks_vdelta.o\
deepks_hmat.o\
LCAO_deepks_interface.o\
orbital_precalc.o\
cal_gdmx.o\
cal_gdmepsl.o\
cal_gedm.o\
cal_gvx.o\
cal_descriptor.o\
v_delta_precalc.o\


OBJS_ELECSTAT=elecstate.o\
Expand Down Expand Up @@ -370,7 +371,6 @@ OBJS_MD=fire.o\

OBJS_NEIGHBOR=sltk_atom.o\
sltk_atom_arrange.o\
sltk_atom_input.o\
sltk_grid.o\
sltk_grid_driver.o\

Expand Down Expand Up @@ -734,6 +734,7 @@ OBJS_TENSOR=tensor.o\
xc_kernel.o\
pot_hxc_lrtd.o\
lr_spectrum.o\
lr_spectrum_velocity.o\
hamilt_casida.o\
esolver_lrtd_lcao.o\

Expand Down
5 changes: 1 addition & 4 deletions source/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ void Driver::init()
// (4) close all of the running logs
ModuleBase::Global_File::close_all_log(GlobalV::MY_RANK, PARAM.inp.out_alllog,PARAM.inp.calculation);

// (5) output the json file
// Json::create_Json(&GlobalC::ucell.symm,GlobalC::ucell.atoms,&INPUT);
Json::create_Json(&GlobalC::ucell, PARAM);
}

void Driver::print_start_info()
Expand Down Expand Up @@ -180,7 +177,7 @@ void Driver::atomic_world()
//--------------------------------------------------

// where the actual stuff is done
this->driver_run(GlobalC::ucell);
this->driver_run();

ModuleBase::timer::finish(GlobalV::ofs_running);
ModuleBase::Memory::print_all(GlobalV::ofs_running);
Expand Down
2 changes: 1 addition & 1 deletion source/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Driver
void atomic_world();

// the actual calculations
void driver_run(UnitCell& ucell);
void driver_run();
};

#endif
12 changes: 10 additions & 2 deletions source/driver_run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
* the configuration-changing subroutine takes force and stress and updates the
* configuration
*/
void Driver::driver_run(UnitCell& ucell)
void Driver::driver_run()
{
ModuleBase::TITLE("Driver", "driver_line");
ModuleBase::timer::tick("Driver", "driver_line");

//! 1: setup cell and atom information

// this warning should not be here, mohan 2024-05-22
#ifndef __LCAO
if (PARAM.inp.basis_type == "lcao_in_pw" || PARAM.inp.basis_type == "lcao") {
Expand All @@ -40,6 +39,13 @@ void Driver::driver_run(UnitCell& ucell)
#endif

// the life of ucell should begin here, mohan 2024-05-12
UnitCell ucell;
ucell.setup(PARAM.inp.latname,
PARAM.inp.ntype,
PARAM.inp.lmaxmax,
PARAM.inp.init_vel,
PARAM.inp.fixed_axes);

ucell.setup_cell(PARAM.globalv.global_in_stru, GlobalV::ofs_running);
Check_Atomic_Stru::check_atomic_stru(ucell, PARAM.inp.min_dist_coef);

Expand Down Expand Up @@ -86,6 +92,8 @@ void Driver::driver_run(UnitCell& ucell)

ModuleESolver::clean_esolver(p_esolver);

//! 6: output the json file
Json::create_Json(&ucell, PARAM);
ModuleBase::timer::tick("Driver", "driver_line");
return;
}
Loading

0 comments on commit 83e1ebf

Please sign in to comment.