Skip to content

Commit 19a1b13

Browse files
dyzhengdyzheng
andauthored
Feature: add nbands_mul for setting multiply for default nbands and fix initial mag for SOC (#5946)
* Feature: add nbands_mul for setting multiply for default nbands * Fix: not autoset atomic mag with lspinorb only * Fix: reference in tests with initial magnetization changed --------- Co-authored-by: dyzheng <[email protected]>
1 parent 84dfe33 commit 19a1b13

File tree

13 files changed

+56
-33
lines changed

13 files changed

+56
-33
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
- [basis\_type](#basis_type)
6161
- [ks\_solver](#ks_solver)
6262
- [nbands](#nbands)
63+
- [nbands_mul](#nbands_mul)
6364
- [nelec](#nelec)
6465
- [nelec\_delta](#nelec_delta)
6566
- [nupdown](#nupdown)
@@ -967,9 +968,15 @@ calculations.
967968
- **Type**: Integer
968969
- **Description**: The number of Kohn-Sham orbitals to calculate. It is recommended to setup this value, especially when smearing techniques are utilized, more bands should be included.
969970
- **Default**:
970-
- nspin=1: max(1.2\*occupied_bands, occupied_bands + 10)
971-
- nspin=2: max(1.2\*nelec_spin, nelec_spin + 10), in which nelec_spin = max(nelec_spin_up, nelec_spin_down)
972-
- nspin=4: max(1.2\*nelec, nelec + 20)
971+
- nspin=1: max(`nbands_mul`\*occupied_bands, occupied_bands + 10)
972+
- nspin=2: max(`nbands_mul`\*nelec_spin, nelec_spin + 10), in which nelec_spin = max(nelec_spin_up, nelec_spin_down)
973+
- nspin=4: max(`nbands_mul`\*nelec, nelec + 20)
974+
975+
### nbands_mul
976+
977+
- **Type**: Real
978+
- **Description**: the multiply value of default formular of `nbands`. It is recommended that the user set a larger default multiplier for systems with complex electron levels near the Fermi surface, such as `2.0`.
979+
- **Default**: 1.2
973980

974981
### nelec
975982

source/module_cell/read_atoms.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,9 @@ bool UnitCell::read_atom_positions(std::ifstream &ifpos, std::ofstream &ofs_runn
862862
}
863863
}
864864
}
865-
if (autoset_mag)
865+
// atomic initial magnetism will be autoset if user set zero for every atom
866+
// one exception is `lspinorb 1` with `noncolin 0`, this setting imply no-mag material but SOC included
867+
if (autoset_mag && !PARAM.inp.lspinorb || PARAM.inp.noncolin)
866868
{
867869
if(PARAM.inp.nspin==4)
868870
{

source/module_elecstate/cal_nelec_nband.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void cal_nbands(const int& nelec, const int& nlocal, const std::vector<double>&
8484
if (PARAM.inp.nspin == 1)
8585
{
8686
const int nbands1 = static_cast<int>(occupied_bands) + 10;
87-
const int nbands2 = static_cast<int>(1.2 * occupied_bands) + 1;
87+
const int nbands2 = static_cast<int>(PARAM.inp.nbands_mul * occupied_bands) + 1;
8888
nbands = std::max(nbands1, nbands2);
8989
if (PARAM.inp.basis_type != "pw") {
9090
nbands = std::min(nbands, nlocal);
@@ -93,7 +93,7 @@ void cal_nbands(const int& nelec, const int& nlocal, const std::vector<double>&
9393
else if (PARAM.inp.nspin == 4)
9494
{
9595
const int nbands3 = nelec + 20;
96-
const int nbands4 = static_cast<int>(1.2 * nelec) + 1;
96+
const int nbands4 = static_cast<int>(PARAM.inp.nbands_mul * nelec) + 1;
9797
nbands = std::max(nbands3, nbands4);
9898
if (PARAM.inp.basis_type != "pw") {
9999
nbands = std::min(nbands, nlocal);
@@ -103,7 +103,7 @@ void cal_nbands(const int& nelec, const int& nlocal, const std::vector<double>&
103103
{
104104
const double max_occ = std::max(nelec_spin[0], nelec_spin[1]);
105105
const int nbands3 = static_cast<int>(max_occ) + 11;
106-
const int nbands4 = static_cast<int>(1.2 * max_occ) + 1;
106+
const int nbands4 = static_cast<int>(PARAM.inp.nbands_mul * max_occ) + 1;
107107
nbands = std::max(nbands3, nbands4);
108108
if (PARAM.inp.basis_type != "pw") {
109109
nbands = std::min(nbands, nlocal);

source/module_io/read_input_item_elec_stru.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,18 @@ void ReadInput::item_elec_stru()
205205
};
206206
this->add_item(item);
207207
}
208+
{
209+
Input_Item item("nbands_mul");
210+
item.annotation = "value to multiply the number of bands";
211+
read_sync_double(input.nbands_mul);
212+
item.check_value = [](const Input_Item& item, const Parameter& para) {
213+
if (para.input.nbands_mul < 1.0)
214+
{
215+
ModuleBase::WARNING_QUIT("ReadInput", "nbands_mul should be greater than 1.0");
216+
}
217+
};
218+
this->add_item(item);
219+
}
208220
{
209221
Input_Item item("nelec");
210222
item.annotation = "input number of electrons";

source/module_parameter/input_parameter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ struct Input_para
7575
std::string basis_type = "pw"; ///< xiaohui add 2013-09-01, for structural adjustment
7676
bool use_paw = false; ///< whether to use PAW in pw calculation
7777
int nbands = 0; ///< number of bands
78+
double nbands_mul = 1.2; ///< multiplier for nbands
7879
double nelec = 0.0; ///< total number of electrons
7980
double nelec_delta = 0.0; ///< change in the number of total electrons
8081
double nupdown = 0.0;
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
etotref -6156.9375288900891974
2-
etotperatomref -3078.4687644450
3-
totalforceref 2.221910
4-
totalstressref 76009.325784
5-
totaltimeref 13.66
1+
etotref -6156.9375268152816716
2+
etotperatomref -3078.4687634076
3+
totalforceref 2.210980
4+
totalstressref 76010.262300
5+
totaltimeref 3.16

tests/integrate/140_PW_15_SO/README

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This test for:
44
*kpoints 2*2*2
55
*sg15 pseudopotential
66
*smearing_method gauss
7-
*ks_solver cg
7+
*ks_solver dav_subspace
88
*mixing_type broyden-kerker
99
*mixing_beta 0.4
10+
*initial magnetic won't be autoset with SOC only
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
etotref -1678.3650981686614614
2-
etotperatomref -839.1825490843
3-
totalforceref 1.739332
4-
totalstressref 34372.194072
5-
totaltimeref 0.99
1+
etotref -1678.3523145468475377
2+
etotperatomref -839.1761572734
3+
totalforceref 2.046010
4+
totalstressref 34365.396224
5+
totaltimeref 0.89

tests/integrate/140_PW_15_SO_wfcinit/STRU

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ ATOMIC_POSITIONS
1313
Direct //Cartesian or Direct coordinate.
1414

1515
As
16-
0
16+
1.0
1717
1
1818
0.2500000 0.2500000 0.25000000 0 0 0
1919

2020
Ga //Element Label
21-
0
21+
1.0
2222
1 //number of atom
2323
0.00000 0.00000 0.000000 0 0 0

tests/integrate/204_NO_KP_NC/INPUT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ smearing_sigma 0.02
2323

2424
#Parameters (5.Mixing)
2525
mixing_type broyden
26-
mixing_beta 0.7
26+
mixing_beta 0.2
2727
mixing_ndim 15
2828
mixing_gg0 1.0
2929

0 commit comments

Comments
 (0)