Skip to content

Commit 5bec618

Browse files
committed
Merge deepmodeling/SDFT
2 parents 291ab1d + 8617aea commit 5bec618

File tree

18 files changed

+1339
-391
lines changed

18 files changed

+1339
-391
lines changed

docs/examples/band-struc.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pw_diag_thr 1.0e-7
2727
#Parameters (File)
2828
init_chg file
2929
out_band 1
30+
out_proj_band 1
3031
3132
#Parameters (Smearing)
3233
smearing_method gaussian
@@ -58,4 +59,35 @@ points.
5859
Run the program, and you will see a file named BANDS_1.dat in the output directory. Plot it
5960
to get energy band structure.
6061

61-
[back to top](#band-structure)
62+
If "out_proj_band" set 1, it will also produce the projected band structure in a file called PBAND_1 in xml format.
63+
64+
The PBAND_1 file starts with number of atomic orbitals in the system, the text contents of element <band structure> is the same as data in the BANDS_1.dat file, such as:
65+
```
66+
<pband>
67+
<nspin>1</nspin>
68+
<norbitals>153</norbitals>
69+
<band_structure nkpoints="96" nbands="50" units="eV">
70+
...
71+
72+
```
73+
74+
The rest of the files arranged in sections, each section with a header such as below:
75+
76+
```
77+
<orbital
78+
index=" 1"
79+
atom_index=" 1"
80+
species="Si"
81+
l=" 0"
82+
m=" 0"
83+
z=" 1"
84+
>
85+
<data>
86+
...
87+
</data>
88+
89+
```
90+
91+
The shape of text contents of element <data> is (Number of k-points, Number of bands)
92+
93+
[back to top](#band-structure)

docs/input-main.md

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
- [System variables](#system-variables)
1010

11-
[suffix](#suffix) | [ntype](#ntype) | [calculation](#calculation) | [symmetry](#symmetry) | [kpar](#kpar) | [latname](#latname) | [init_wfc](#init_wfc) | [init_chg](#init_chg) | [init_vel](#init_vel) | [nelec](#nelec) | [tot_magnetization](#tot-magnetization) | [dft_functional](#dft-functional) | [pseudo_type](#pseudo-type) | [pseudo_rcut](#pseudo-rcut) | [pseudo_mesh](#pseudo_mesh) | [mem_saver](#mem-saver) | [diago_proc](#diago_proc) | [nbspline](#nbspline)
11+
[suffix](#suffix) | [ntype](#ntype) | [calculation](#calculation) | [symmetry](#symmetry) | [kpar](#kpar) | [bndpar](#bndpar) | [latname](#latname) | [init_wfc](#init_wfc) | [init_chg](#init_chg) | [init_vel](#init_vel) | [nelec](#nelec) | [tot_magnetization](#tot-magnetization) | [dft_functional](#dft-functional) | [pseudo_type](#pseudo-type) | [pseudo_rcut](#pseudo-rcut) | [pseudo_mesh](#pseudo_mesh) | [mem_saver](#mem-saver) | [diago_proc](#diago_proc) | [nbspline](#nbspline)
1212

1313
- [Variables related to input files](#variables-related-to-input-files)
1414

@@ -24,15 +24,15 @@
2424

2525
- [Electronic structure](#electronic-structure)
2626

27-
[basis_type](#basis-type) | [ks_solver](#ks-solver) | [nbands](#nbands) | [nbands_istate](#nbands-istate) | [nspin](#nspin) | [occupations](#occupations) | [smearing_method](#smearing_method) | [smearing_sigma](#smearing_sigma) | [mixing_type](#mixing-type) | [mixing_beta](#mixing-beta) | [mixing_ndim](#mixing-ndim) | [mixing_gg0](#mixing-gg0) | [gamma_only](#gamma-only) | [printe](#printe) | [scf_nmax](#scf_nmax) | [scf_thr](#scf_thr) | [chg_extrap](#chg_extrap)
27+
[basis_type](#basis-type) | [ks_solver](#ks-solver) | [nbands](#nbands) | [nbands_sto](#nbands_sto) | [nbands_istate](#nbands-istate) | [nspin](#nspin) | [occupations](#occupations) | [smearing_method](#smearing_method) | [smearing_sigma](#smearing_sigma) | [mixing_type](#mixing-type) | [mixing_beta](#mixing-beta) | [mixing_ndim](#mixing-ndim) | [mixing_gg0](#mixing-gg0) | [gamma_only](#gamma-only) | [printe](#printe) | [scf_nmax](#scf_nmax) | [scf_thr](#scf_thr) | [chg_extrap](#chg_extrap) | [nche_sto](#nche_sto) | [emin_sto](#emin_sto) | [emax_sto](#emax_sto) | [seed_sto](#seed_sto)
2828

2929
- [Geometry relaxation](#geometry-relaxation)
3030

3131
[relax_nmax](#relax_nmax) | [relax_method](#relax_method) | [relax_cg_thr](#relax_cg_thr) | [relax_bfgs_w1](#bfgs-w1) | [relax_bfgs_w2](#bfgs-w2) | [relax_bfgs_rmax](#relax_bfgs_rmax) | [relax_bfgs_rmin](#relax_bfgs_rmin) | [relax_bfgs_init](#relax_bfgs_init) | [cal_force](#cal_force) | [force_thr](#force-thr) | [force_thr_ev](#force-thr-ev) | [cal_stress](#cal_stress) | [stress_thr](#stress-thr) | [press1, press2, press3](#press) | [fixed_axes](#fixed-axes) | [cell_factor](#cell-factor)
3232

3333
- [Variables related to output information](#variables-related-to-output-information)
3434

35-
[out_force](#out_force) | [out_mul](#out_mul) | [out_freq_elec](#out_freq_elec) | [out_freq_ion](#out_freq_ion) | [out_chg](#out_chg) | [out_pot](#out_pot) | [out_dm](#out-dm) | [out_wfc_pw](#out_wfc_pw) | [out_wfc_r](#out_wfc_r) | [out_wfc_lcao](#out_wfc_lcao) | [out_dos](#out-dos) | [out_band](#out-band) | [out_stru](#out-stru) | [out_level](#out_level) | [out_alllog](#out-alllog) | [out_mat_hs](#out_mat_hs) | [out_mat_r](#out_mat_r) | [out_mat_hs2](#out_mat_hs2) | [out_element_info](#out-element-info) | [restart_save](#restart_save) | [restart_load](#restart_load)
35+
[out_force](#out_force) | [out_mul](#out_mul) | [out_freq_elec](#out_freq_elec) | [out_freq_ion](#out_freq_ion) | [out_chg](#out_chg) | [out_pot](#out_pot) | [out_dm](#out-dm) | [out_wfc_pw](#out_wfc_pw) | [out_wfc_r](#out_wfc_r) | [out_wfc_lcao](#out_wfc_lcao) | [out_dos](#out-dos) | [out_band](#out-band) | [out_proj_band](#out-proj-band) | [out_stru](#out-stru) | [out_level](#out_level) | [out_alllog](#out-alllog) | [out_mat_hs](#out_mat_hs) | [out_mat_r](#out_mat_r) | [out_mat_hs2](#out_mat_hs2) | [out_element_info](#out-element-info) | [restart_save](#restart_save) | [restart_load](#restart_load)
3636

3737
- [Density of states](#density-of-states)
3838

@@ -150,6 +150,12 @@ This part of variables are used to control general system parameters.
150150
- **Description**: devide all processors into kpar groups, and k points will be distributed among each group. The value taken should be less than or equal to the number of k points as well as the number of MPI threads.
151151
- **Default**: 1
152152

153+
#### bndpar
154+
155+
- **Type**: Integer
156+
- **Description**: devide all processors into bndpar groups, and bands (only stochastic orbitals now) will be distributed among each group. It should be larger than 0.
157+
- **Default**: 1
158+
153159
#### latname
154160

155161
- **Type**: String
@@ -453,6 +459,14 @@ calculations.
453459
- nspin=1: 1.2\*occupied_bands, occupied_bands+10)
454460
- nspin=2: max(1.2\*nelec, nelec+20)
455461
462+
#### nbands_sto
463+
464+
- **Type**: Integer
465+
- **Description**:
466+
- nbands_sto>0: Number of stochastic orbitals to calculate in stochastic DFT (SDFT) or mix stochastic-deterministic (MDFT). More bands obtain more precise results or smaller stochastic errors ($ \propto 1/\sqrt{N_{\chi}}$);
467+
- nbands_sto=0: Complete basis will be used to replace stochastic orbitals with the Chebyshev method (CT) and it will get the results the same as KSDFT without stochastic errors.
468+
- **Default**: 0
469+
456470
#### nbands_istate
457471
458472
- **Type**: Integer
@@ -551,6 +565,32 @@ calculations.
551565
- second-order: second-order extrapolation
552566
- **Default**:atomic
553567
568+
#### nche_sto
569+
570+
- **Type**: Integer
571+
- **Description**: Chebyshev expansion orders for SDFT, MDFT, CT methods.
572+
- **Default**:5
573+
574+
#### emin_sto
575+
576+
- **Type**: Real
577+
- **Description**: Trial energy to guess the lower bound of eigen energies of the Hamitonian Operator $\hat{H}$. The unit is Ry.
578+
- **Default**:0.0
579+
580+
#### emax_sto
581+
582+
- **Type**: Real
583+
- **Description**: Trial energy to guess the upper bound of eigen energies of the Hamitonian Operator $\hat{H}$. The unit is Ry.
584+
- **Default**:0.0
585+
586+
#### seed_sto
587+
588+
- **Type**: Integer
589+
- **Description**: The random seed to generate stochastic orbitals.
590+
- seed_sto>=0: Stochastic orbitals have the form of $\exp(i2\pi\theta(G))$, where $\theta$ is a uniform distribution in $(0,1)$. If seed_sto=0, the seed is decided by time(NULL).
591+
- seed_sto<=-1: Stochastic orbitals have the form of $\pm1$ with the equal probability. If seed_sto=-1, the seed is decided by time(NULL).
592+
- **Default**:0
593+
554594
### Geometry relaxation
555595
556596
This part of variables are used to control the geometry relaxation.
@@ -735,6 +775,12 @@ This part of variables are used to control the output of properties.
735775
- **Description**: Controls whether to output the band structure. For mroe information, refer to the [worked example](examples/band-struc.md)
736776
- **Default**: 0
737777
778+
#### out_proj_band
779+
780+
- **Type**: Integer
781+
- **Description**: Controls whether to output the projected band structure. For mroe information, refer to the [worked example](examples/band-struc.md)
782+
- **Default**: 0
783+
738784
#### out_stru
739785
740786
- **Type**: Boolean

source/input.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void Input::Default(void)
138138
nbands_sto = 0;
139139
nbands_istate = 5;
140140
pw_seed = 1;
141-
nche_sto = 0;
141+
nche_sto = 5;
142142
seed_sto = 0;
143143
bndpar = 1;
144144
kpar = 1;
@@ -268,6 +268,7 @@ void Input::Default(void)
268268
out_wfc_r = 0;
269269
out_dos = 0;
270270
out_band = 0;
271+
out_proj_band = 0;
271272
out_mat_hs = 0;
272273
out_mat_hs2 = 0; // LiuXh add 2019-07-15
273274
out_mat_r = 0; // jingan add 2019-8-14
@@ -995,6 +996,10 @@ bool Input::Read(const std::string &fn)
995996
{
996997
read_value(ifs, out_band);
997998
}
999+
else if (strcmp("out_proj_band", word) == 0)
1000+
{
1001+
read_value(ifs, out_proj_band);
1002+
}
9981003

9991004
else if (strcmp("out_mat_hs", word) == 0)
10001005
{
@@ -1942,6 +1947,7 @@ void Input::Bcast()
19421947
Parallel_Common::bcast_int(out_wfc_r);
19431948
Parallel_Common::bcast_int(out_dos);
19441949
Parallel_Common::bcast_int(out_band);
1950+
Parallel_Common::bcast_int(out_proj_band);
19451951
Parallel_Common::bcast_int(out_mat_hs);
19461952
Parallel_Common::bcast_int(out_mat_hs2); // LiuXh add 2019-07-15
19471953
Parallel_Common::bcast_int(out_mat_r); // jingan add 2019-8-14
@@ -2228,6 +2234,7 @@ void Input::Check(void)
22282234
out_stru = 0;
22292235
out_dos = 0;
22302236
out_band = 0;
2237+
out_proj_band = 0;
22312238
cal_force = 0;
22322239
init_wfc = "file";
22332240
init_chg = "atomic"; // useless,
@@ -2249,6 +2256,7 @@ void Input::Check(void)
22492256
out_stru = 0;
22502257
out_dos = 0;
22512258
out_band = 0;
2259+
out_proj_band = 0;
22522260
cal_force = 0;
22532261
init_wfc = "file";
22542262
init_chg = "atomic";

source/input.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ class Input
206206
int out_wfc_r; // 0: no; 1: yes
207207
int out_dos; // dos calculation. mohan add 20090909
208208
int out_band; // band calculation pengfei 2014-10-13
209+
int out_proj_band; // projected band structure calculation jiyy add 2022-05-11
209210
int out_mat_hs; // output H matrix and S matrix in local basis.
210211
int out_mat_hs2; // LiuXh add 2019-07-16, output H(R) matrix and S(R) matrix in local basis.
211212
int out_mat_r; // jingan add 2019-8-14, output r(R) matrix.

source/input_conv.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ void Input_Conv::Convert(void)
435435
GlobalC::wf.out_wfc_r = INPUT.out_wfc_r;
436436
GlobalC::en.out_dos = INPUT.out_dos;
437437
GlobalC::en.out_band = INPUT.out_band;
438+
GlobalC::en.out_proj_band = INPUT.out_proj_band;
438439
#ifdef __LCAO
439440
Local_Orbital_Charge::out_dm = INPUT.out_dm;
440441
Pdiag_Double::out_mat_hs = INPUT.out_mat_hs;

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,19 @@ namespace ModuleESolver
143143
int ion_step = 0;
144144
GlobalC::pot.init_pot(ion_step, GlobalC::pw.strucFac);
145145

146+
//------------------init Basis_lcao----------------------
147+
// Init Basis should be put outside of Ensolver.
148+
// * reading the localized orbitals/projectors
149+
// * construct the interpolation tables.
150+
this->Init_Basis_lcao(this->orb_con, inp, ucell);
151+
//------------------init Basis_lcao----------------------
152+
153+
//------------------init Hamilt_lcao----------------------
154+
// * allocate H and S matrices according to computational resources
155+
// * set the 'trace' between local H/S and global H/S
156+
this->LM.divide_HS_in_frag(GlobalV::GAMMA_ONLY_LOCAL, orb_con.ParaV);
157+
//------------------init Hamilt_lcao----------------------
158+
146159
#ifdef __MPI
147160
// PLEASE simplify the Exx_Global interface
148161
// mohan add 2021-03-25
@@ -175,19 +188,7 @@ namespace ModuleESolver
175188

176189
if (INPUT.dft_plus_dmft) GlobalC::dmft.init(INPUT, ucell);
177190

178-
//------------------init Basis_lcao----------------------
179-
// Init Basis should be put outside of Ensolver.
180-
// * reading the localized orbitals/projectors
181-
// * construct the interpolation tables.
182-
this->Init_Basis_lcao(this->orb_con, inp, ucell);
183-
//------------------init Basis_lcao----------------------
184-
185-
//------------------init Hamilt_lcao----------------------
186-
// * allocate H and S matrices according to computational resources
187-
// * set the 'trace' between local H/S and global H/S
188-
this->LM.divide_HS_in_frag(GlobalV::GAMMA_ONLY_LOCAL, orb_con.ParaV);
189-
//------------------init Hamilt_lcao----------------------
190-
//init Psi
191+
//init Psi
191192
if (GlobalV::GAMMA_ONLY_LOCAL)
192193
this->LOWF.wfc_gamma.resize(GlobalV::NSPIN);
193194
else

source/module_orbital/ORB_gen_tables.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,18 @@ void ORB_gen_tables::snap_psibeta_half(
140140

141141
//find number of projectors on atom R0
142142
const int nproj = infoNL_.nproj[T0];
143-
assert(nproj>0); // mohan add 2021-04-25
143+
if(nproj==0)
144+
{
145+
if(calc_deri)
146+
{
147+
nlm.resize(4);
148+
}
149+
else
150+
{
151+
nlm.resize(1);
152+
}
153+
return;
154+
}
144155

145156
std::vector<bool> calproj;
146157
calproj.resize(nproj);

0 commit comments

Comments
 (0)