Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
1e0be3a
improved implementation of kerker preconditioner
WHUweiqingzhou Nov 1, 2023
bf442fa
fix bug in charge_mixing_test
WHUweiqingzhou Nov 2, 2023
6b8df34
Merge branch 'develop' into develop
WHUweiqingzhou Nov 2, 2023
7b3bf2d
make corresponding changes in Documentation after PR#3133
WHUweiqingzhou Nov 2, 2023
b56d62f
Merge branch 'deepmodeling:develop' into develop
WHUweiqingzhou Nov 2, 2023
44261f0
Merge branch 'develop' of github.com:WHUweiqingzhou/abacus-develop in…
WHUweiqingzhou Nov 2, 2023
d94421f
extra add
WHUweiqingzhou Nov 2, 2023
bf9c242
Merge branch 'deepmodeling:develop' into develop
WHUweiqingzhou Nov 6, 2023
1c625bc
new mixing method for nspin=2
WHUweiqingzhou Nov 9, 2023
8b46eb8
add some comment for gg=0
WHUweiqingzhou Nov 10, 2023
f749462
nspin2 mixing method for pw
WHUweiqingzhou Nov 16, 2023
4a66992
remove autoset and set default
WHUweiqingzhou Nov 17, 2023
9bf333e
fix charge_mixing_test & add some documentation of mixing_beta_mag/mi…
WHUweiqingzhou Nov 17, 2023
eaf6fff
resolve conflict in autoset
WHUweiqingzhou Nov 17, 2023
ea64b4d
use old mixing to support double_grid
WHUweiqingzhou Nov 17, 2023
e962da8
Merge branch 'develop' into develop
WHUweiqingzhou Nov 18, 2023
25ee340
Merge branch 'develop' of github.com:deepmodeling/abacus-develop into…
WHUweiqingzhou Nov 20, 2023
667bb93
fix fatal error in CI
WHUweiqingzhou Nov 20, 2023
e46aff1
Merge branch 'develop' of github.com:WHUweiqingzhou/abacus-develop in…
WHUweiqingzhou Nov 20, 2023
40a0659
recover Autotest.sh
WHUweiqingzhou Nov 20, 2023
806542f
108
WHUweiqingzhou Nov 20, 2023
53a77b6
108
WHUweiqingzhou Nov 20, 2023
671d7f0
revert 101_PW_15_lowz
WHUweiqingzhou Nov 21, 2023
ae5704a
revert 107_PW_OK
WHUweiqingzhou Nov 21, 2023
6472bea
revert 186_PW_KG_100
WHUweiqingzhou Nov 21, 2023
22957bf
revert 186_PW_SKG_10D10S
WHUweiqingzhou Nov 21, 2023
093729b
revert 201_NO_15_f_pseudopots
WHUweiqingzhou Nov 21, 2023
b95453d
revert 201_NO_KP_DJ_CF_CS_GaAs
WHUweiqingzhou Nov 21, 2023
d69f6fe
revert 204_NO_KP_AFM
WHUweiqingzhou Nov 21, 2023
72c7fcb
revert 207_NO_KP_OHS_SPIN4
WHUweiqingzhou Nov 21, 2023
a32f480
revert 207_NO_KP_OTdH
WHUweiqingzhou Nov 21, 2023
137021a
revert 207_NO_OK
WHUweiqingzhou Nov 21, 2023
c7b0f38
revert 220_NO_KP_MD_wfc_out
WHUweiqingzhou Nov 21, 2023
8320b78
revert 101_PW_15_pseudopots_LibxcLDA
WHUweiqingzhou Nov 21, 2023
cba4754
Autotest.sh
WHUweiqingzhou Nov 21, 2023
a36bfff
Merge branch 'develop' into develop
WHUweiqingzhou Nov 21, 2023
76d181b
fix bug in deepks_tests
WHUweiqingzhou Nov 22, 2023
6c61c0b
fix bugs in io_input_test
WHUweiqingzhou Nov 22, 2023
d40945b
Merge branch 'develop' of github.com:deepmodeling/abacus-develop into…
WHUweiqingzhou Nov 22, 2023
ccb4993
Merge branch 'develop' of github.com:WHUweiqingzhou/abacus-develop in…
WHUweiqingzhou Nov 22, 2023
58a3c2b
update ref of 260 and 360
WHUweiqingzhou Nov 22, 2023
62d4736
do not use renormalize_rho in pw calculations
WHUweiqingzhou Nov 22, 2023
cab997c
set mixing_gg0=0.0 for 601_TD_DFT tests
WHUweiqingzhou Nov 22, 2023
5940196
change mixing_type=plain to broyden
WHUweiqingzhou Nov 22, 2023
de5e905
add two_beta to replace NSPIN in mixing class
WHUweiqingzhou Nov 22, 2023
cd1b23e
add UnitTests of inner_product_recip_new1/2 & kerker_recip_new
WHUweiqingzhou Nov 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions docs/advanced/input_files/input-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -964,15 +964,21 @@ calculations.
- **Type**: Real
- **Description**: In general, the formula of charge mixing can be written as $\rho_{new} = \rho_{old} + \beta * \rho_{update}$, where $\rho_{new}$ represents the new charge density after charge mixing, $\rho_{old}$ represents the charge density in previous step, $\rho_{update}$ is obtained through various mixing methods, and $\beta$ is set by the parameter `mixing_beta`. A lower value of 'mixing_beta' results in less influence of $\rho_{update}$ on $\rho_{new}$, making the self-consistent field (SCF) calculation more stable. However, it may require more steps to achieve convergence.
We recommend the following options:
- **-10.0**: Program will auto set `mixing_beta` and `mixing_gg0` before charge mixing method starts.
- Default values of metal system (bandgap <= 1.0 eV) are `mixing_beta=0.2` and `mixing_gg0=1.0`;
- Default values of other systems (bandgap > 1.0eV) are `mixing_beta=0.7` and `mixing_gg0=1.0`.
- **0.8**: `nspin=1`
- **0.4**: `nspin=2`
- **0.2**: `nspin=4`
- **0**: keep charge density unchanged, usually used for restarting with `init_chg=file` or testing.
- **0.1 or less**: if convergence of SCF calculation is difficult to reach, please try `0 < mixing_beta < 0.1`.

Note: For low-dimensional large systems, the setup of `mixing_beta=0.1`, `mixing_ndim=20`, and `mixing_gg0=1.5` usually works well.
Note: For low-dimensional large systems, the setup of `mixing_beta=0.1`, `mixing_ndim=20`, and `mixing_gg0=1.0` usually works well.

- **Default**: -10.0
- **Default**: 0.8 for `nspin=1`, 0.4 for `nspin=2`, 0.2 for `nspin=4`.

### mixing_beta_mag

- **Type**: Real
- **Description**: Mixing parameter of magnetic density.
- **Default**: `4*mixing_beta`

### mixing_ndim

Expand All @@ -985,11 +991,18 @@ We recommend the following options:
### mixing_gg0

- **Type**: Real
- **Description**: Whether to perfom Kerker scaling.
- **Description**: Whether to perfom Kerker scaling for charge density.
- **>0**: The high frequency wave vectors will be suppressed by multiplying a scaling factor $\frac{k^2}{k^2+gg0^2}$. Setting `mixing_gg0 = 1.0` is normally a good starting point. Kerker preconditioner will be automatically turned off if `mixing_beta <= 0.1`.
- **0**: No Kerker scaling is performed.

For systems that are difficult to converge, particularly metallic systems, enabling Kerker scaling may aid in achieving convergence.
- **Default**: 1.0

### mixing_gg0_mag

- **Type**: Real
- **Description**: Whether to perfom Kerker preconditioner of magnetic density.
Note: we do not recommand to open Kerker preconditioner of magnetic density unless the system is too hard to converge.
- **Default**: 0.0

### mixing_tau
Expand Down
4 changes: 3 additions & 1 deletion source/module_base/global_variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ std::string of_kernel_file = "WTkernel.txt";
std::string MIXING_MODE = "broyden";
double MIXING_BETA = 0.7;
int MIXING_NDIM = 8;
double MIXING_GG0 = 0.0;
double MIXING_GG0 = 1.00;
double MIXING_BETA_MAG = 1.6;
double MIXING_GG0_MAG = 1.00;
bool MIXING_TAU = 0;

//==========================================================
Expand Down
2 changes: 2 additions & 0 deletions source/module_base/global_variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ extern double MIXING_BETA;
extern int MIXING_NDIM;
extern double MIXING_GG0;
extern bool MIXING_TAU;
extern double MIXING_BETA_MAG;
extern double MIXING_GG0_MAG;

//==========================================================
// device flags added by denghui
Expand Down
43 changes: 38 additions & 5 deletions source/module_base/module_mixing/broyden_mixing.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "module_base/memory.h"
#include "module_base/timer.h"
#include "module_base/tool_title.h"
#include "module_base/global_variable.h"

namespace Base_Mixing
{
Expand Down Expand Up @@ -36,6 +37,14 @@ class Broyden_Mixing : public Mixing
this->mixing_beta = mixing_beta;
this->coef = std::vector<double>(mixing_ndim + 1);
this->beta = ModuleBase::matrix(mixing_ndim, mixing_ndim, true);
if (GlobalV::NSPIN == 1 || GlobalV::NSPIN == 4)
{
this->two_beta = 0;
}
else if (GlobalV::NSPIN == 2)
{
this->two_beta = 1;
}
}
virtual ~Broyden_Mixing() override
{
Expand Down Expand Up @@ -125,21 +134,43 @@ class Broyden_Mixing : public Mixing
{
F_tmp[i] = data_out[i] - data_in[i];
}

// get screened F
if (screen != nullptr)
screen(F_tmp.data());

// container::Tensor data = data_in + mixing_beta * F;
std::vector<FPTYPE> data(length);
// mix density and magnetic density sperately
if (this->two_beta == 0)
{
// rho_tot
#ifdef _OPENMP
#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE))
#endif
for (int i = 0; i < length; ++i)
{
data[i] = data_in[i] + this->mixing_beta * F_tmp[i];
for (int i = 0; i < length; ++i)
{
data[i] = data_in[i] + this->mixing_beta * F_tmp[i];
}
}
else if (this->two_beta == 1)
{
// rho_tot
#ifdef _OPENMP
#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE))
#endif
for (int i = 0; i < length / 2; ++i)
{
data[i] = data_in[i] + this->mixing_beta * F_tmp[i];
}
// magnetism
#ifdef _OPENMP
#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE))
#endif
for (int i = length / 2; i < length; ++i)
{
data[i] = data_in[i] + GlobalV::MIXING_BETA_MAG * F_tmp[i];
}

}
mdata.push(data.data());

if (!need_calcoef)
Expand Down Expand Up @@ -312,6 +343,8 @@ class Broyden_Mixing : public Mixing
}
// the number of calculated dF
int ndim_cal_dF = 0;
// if we should considere two beta
int two_beta = 0;
};
} // namespace Base_Mixing
#endif
40 changes: 38 additions & 2 deletions source/module_base/module_mixing/plain_mixing.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "module_base/memory.h"
#include "module_base/timer.h"
#include "module_base/tool_title.h"
#include "module_base/global_variable.h"

namespace Base_Mixing
{
Expand All @@ -19,6 +20,14 @@ class Plain_Mixing : public Mixing
this->mixing_beta = mixing_beta;
this->data_ndim = 1;
this->coef = std::vector<double>(1, 1.0);
if (GlobalV::NSPIN == 1 || GlobalV::NSPIN == 4)
{
this->two_beta = 0;
}
else if (GlobalV::NSPIN == 2)
{
this->two_beta = 1;
}
}
virtual ~Plain_Mixing() override{};

Expand Down Expand Up @@ -108,16 +117,43 @@ class Plain_Mixing : public Mixing

// container::Tensor data = data_in + mixing_beta * F;
std::vector<FPTYPE> data(length);
if (this->two_beta == 0)
{
// rho_tot
#ifdef _OPENMP
#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE))
#endif
for (int i = 0; i < length; ++i)
for (int i = 0; i < length; ++i)
{
data[i] = data_in[i] + this->mixing_beta * F_tmp[i];
}
}
else if (this->two_beta == 1)
{
data[i] = data_in[i] + this->mixing_beta * F_tmp[i];
// rho_tot
#ifdef _OPENMP
#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE))
#endif
for (int i = 0; i < length / 2; ++i)
{
data[i] = data_in[i] + this->mixing_beta * F_tmp[i];
}
// magnetism
#ifdef _OPENMP
#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE))
#endif
for (int i = length / 2; i < length; ++i)
{
data[i] = data_in[i] + GlobalV::MIXING_BETA_MAG * F_tmp[i];
}

}

mdata.push(data.data());
};

// if we should considere two beta
int two_beta = 0;
};
} // namespace Base_Mixing
#endif
39 changes: 37 additions & 2 deletions source/module_base/module_mixing/pulay_mixing.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "module_base/memory.h"
#include "module_base/timer.h"
#include "module_base/tool_title.h"
#include "module_base/global_variable.h"

namespace Base_Mixing
{
Expand All @@ -30,6 +31,14 @@ class Pulay_Mixing : public Mixing
this->mixing_beta = mixing_beta;
this->coef = std::vector<double>(mixing_ndim);
this->beta = ModuleBase::matrix(mixing_ndim, mixing_ndim, true);
if (GlobalV::NSPIN == 1 || GlobalV::NSPIN == 4)
{
this->two_beta = 0;
}
else if (GlobalV::NSPIN == 2)
{
this->two_beta = 1;
}
}
virtual ~Pulay_Mixing() override
{
Expand Down Expand Up @@ -124,12 +133,36 @@ class Pulay_Mixing : public Mixing

// container::Tensor data = data_in + mixing_beta * F;
std::vector<FPTYPE> data(length);
if (this->two_beta == 0)
{
// rho_tot
#ifdef _OPENMP
#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE))
#endif
for (int i = 0; i < length; ++i)
for (int i = 0; i < length; ++i)
{
data[i] = data_in[i] + this->mixing_beta * F_tmp[i];
}
}
else if (this->two_beta == 1)
{
data[i] = data_in[i] + this->mixing_beta * F_tmp[i];
// rho_tot
#ifdef _OPENMP
#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE))
#endif
for (int i = 0; i < length / 2; ++i)
{
data[i] = data_in[i] + this->mixing_beta * F_tmp[i];
}
// magnetism
#ifdef _OPENMP
#pragma omp parallel for schedule(static, 4096 / sizeof(FPTYPE))
#endif
for (int i = length / 2; i < length; ++i)
{
data[i] = data_in[i] + GlobalV::MIXING_BETA_MAG * F_tmp[i];
}

}

mdata.push(data.data());
Expand Down Expand Up @@ -275,6 +308,8 @@ class Pulay_Mixing : public Mixing
int mixing_ndim = -1;
// start index for F
int start_F = 0;
// if we should considere two beta
int two_beta = 0;
};
} // namespace Base_Mixing
#endif
Loading