Skip to content

Commit ca42c57

Browse files
authored
Merge pull request #927 from YuLiu98/develop
feature : Dipole correction
2 parents ae3015c + 4728408 commit ca42c57

File tree

31 files changed

+588
-396
lines changed

31 files changed

+588
-396
lines changed

docs/input-main.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070

7171
[deepks_out_labels](#out-descriptor) | [deepks_descriptor_lmax](#lmax-descriptor) | [deepks_scf](#deepks-scf) | [deepks_model](#model-file)
7272

73+
- [Electric field and dipole correction](#Electric-field-and-dipole-correction)
74+
75+
[efield](#efield) | [dipole](#dipole) | [edir](#edir) | [emaxpos](#emaxpos) | [eopreg](#eopreg) | [eamp](#eamp)
76+
7377
[back to main page](../README.md)
7478

7579
## Structure of the file
@@ -910,6 +914,48 @@ Warning: this function is not robust enough for version 2.2.0. Please try these
910914
- **Description**: the path of the trained, traced NN model file (generated by deepks-kit). used when deepks_scf is set to 1.
911915
- **Default**: None
912916
917+
### Electric field and dipole correction
918+
919+
This part of variables are relevant to electric field and dipole correction
920+
921+
#### efield
922+
923+
- **Type**: Boolean
924+
- **Description**: If set to true, a saw-like potential simulating an electric field
925+
is added to the bare ionic potential.
926+
- **Default**: false
927+
928+
#### dipole
929+
930+
- **Type**: Boolean
931+
- **Description**: If dipole == true and efield == true, a dipole correction is also
932+
added to the bare ionic potential. If you want no electric field, parameter eamp should be zero. Must be used ONLY in a slab geometry for surface calculations, with the discontinuity FALLING IN THE EMPTY SPACE.
933+
- **Default**: false
934+
935+
#### edir
936+
937+
- **Type**: Integer
938+
- **Description**: The direction of the electric field or dipole correction is parallel to the reciprocal lattice vector, so the potential is constant in planes defined by FFT grid points, edir = 0, 1 or 2. Used only if efield == true.
939+
- **Default**: 2
940+
941+
#### emaxpos
942+
943+
- **Type**: Real
944+
- **Description**: Position of the maximum of the saw-like potential along crystal axis edir, within the unit cell, 0 < emaxpos < 1. Used only if efield == true.
945+
- **Default**: 0.5
946+
947+
#### eopreg
948+
949+
- **Type**: Real
950+
- **Description**: Zone in the unit cell where the saw-like potential decreases, 0 < eopreg < 1. Used only if efield == true.
951+
- **Default**: 0.1
952+
953+
#### eamp
954+
955+
- **Type**: Real
956+
- **Description**: Amplitude of the electric field, in ***Hartree*** a.u.; 1 a.u. = 51.4220632*10^10 V/m. Used only if efield == true. The saw-like potential increases with slope eamp in the region from (emaxpos+eopreg-1) to (emaxpos), then decreases until (emaxpos+eopreg), in units of the crystal vector edir. Important: the change of slope of this potential must be located in the empty region, or else unphysical forces will result.
957+
- **Default**: 0.0
958+
913959
### Exact Exchange
914960
915961
This part of variables are relevant when using hybrid functionals

source/Makefile.Objects

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ OBJS_SURCHEM=H_correction_pw.o\
243243
cal_vel.o\
244244
corrected_energy.o\
245245
minimize_cg.o\
246+
efield.o\
246247

247248
OBJS_XC=xc_funct_corr_gga.o \
248249
xc_funct_corr_lda.o \
@@ -293,7 +294,6 @@ write_HS.o\
293294
write_HS_R.o\
294295
write_dm.o\
295296
write_wfc_realspace.o\
296-
efield.o \
297297
magnetism.o\
298298
optical.o\
299299
Cell_PW.o\

source/input.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,15 @@ void Input::Default(void)
288288
lcao_dr = 0.01;
289289
lcao_rmax = 30; // (a.u.)
290290
//----------------------------------------------------------
291+
// efield and dipole correction Yu Liu add 2022-05-18
292+
//----------------------------------------------------------
293+
efield = false;
294+
dipole = false;
295+
edir = 2;
296+
emaxpos = 0.5;
297+
eopreg = 0.1;
298+
eamp = 0.0;
299+
//----------------------------------------------------------
291300
// vdw //jiyy add 2019-08-04
292301
//----------------------------------------------------------
293302
vdw_method = "none";
@@ -1155,6 +1164,34 @@ bool Input::Read(const std::string &fn)
11551164
read_value(ifs, mdp.md_damp);
11561165
}
11571166
//----------------------------------------------------------
1167+
// efield and dipole correction
1168+
// Yu Liu add 2022-05-18
1169+
//----------------------------------------------------------
1170+
else if (strcmp("efield", word) == 0)
1171+
{
1172+
read_value(ifs, efield);
1173+
}
1174+
else if (strcmp("dipole", word) == 0)
1175+
{
1176+
read_value(ifs, dipole);
1177+
}
1178+
else if (strcmp("edir", word) == 0)
1179+
{
1180+
read_value(ifs, edir);
1181+
}
1182+
else if (strcmp("emaxpos", word) == 0)
1183+
{
1184+
read_value(ifs, emaxpos);
1185+
}
1186+
else if (strcmp("eopreg", word) == 0)
1187+
{
1188+
read_value(ifs, eopreg);
1189+
}
1190+
else if (strcmp("eamp", word) == 0)
1191+
{
1192+
read_value(ifs, eamp);
1193+
}
1194+
//----------------------------------------------------------
11581195
// tddft
11591196
// Fuxiang He add 2016-10-26
11601197
//----------------------------------------------------------
@@ -1997,6 +2034,13 @@ void Input::Bcast()
19972034
Parallel_Common::bcast_double(mdp.msst_tscale);
19982035
Parallel_Common::bcast_double(mdp.md_tfreq);
19992036
Parallel_Common::bcast_double(mdp.md_damp);
2037+
// Yu Liu add 2022-05-18
2038+
Parallel_Common::bcast_bool(efield);
2039+
Parallel_Common::bcast_bool(dipole);
2040+
Parallel_Common::bcast_int(edir);
2041+
Parallel_Common::bcast_double(emaxpos);
2042+
Parallel_Common::bcast_double(eopreg);
2043+
Parallel_Common::bcast_double(eamp);
20002044
/* // Peize Lin add 2014-04-07
20012045
Parallel_Common::bcast_bool( vdwD2 );
20022046
Parallel_Common::bcast_double( vdwD2_scaling );

source/input.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,17 @@ class Input
255255
int md_msdstartTime; //choose which step that msd be calculated */
256256
MD_parameters mdp;
257257

258+
//==========================================================
259+
// efield and dipole correction
260+
// Yu Liu add 2022-05-18
261+
//==========================================================
262+
bool efield; // add electric field
263+
bool dipole; // dipole correction
264+
int edir; // the direction of the electric field or dipole correction
265+
double emaxpos; // position of the maximum of the saw-like potential along crystal axis edir
266+
double eopreg; // zone in the unit cell where the saw-like potential decreases
267+
double eamp; // amplitude of the electric field
268+
258269
//==========================================================
259270
// vdw
260271
// Peize Lin add 2014-03-31, jiyy update 2019-08-01

source/input_conv.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "src_io/epsilon0_vasp.h"
1313
#include "src_io/optical.h"
1414
#include "src_ions/ions_move_basic.h"
15-
#include "src_pw/efield.h"
1615
#include "src_pw/global.h"
1716
#include "src_pw/occupy.h"
1817
#ifdef __EXX
@@ -27,6 +26,7 @@
2726
#include "src_lcao/local_orbital_charge.h"
2827
#endif
2928
#include "module_base/timer.h"
29+
#include "module_surchem/efield.h"
3030

3131
void Input_Conv::Convert(void)
3232
{
@@ -210,6 +210,16 @@ void Input_Conv::Convert(void)
210210
GlobalV::NPOL = 1;
211211
}
212212

213+
//----------------------------------------------------------
214+
// Yu Liu add 2022-05-18
215+
//----------------------------------------------------------
216+
GlobalV::EFIELD = INPUT.efield;
217+
GlobalV::DIPOLE = INPUT.dipole;
218+
Efield::edir = INPUT.edir;
219+
Efield::emaxpos = INPUT.emaxpos;
220+
Efield::eopreg = INPUT.eopreg;
221+
Efield::eamp = INPUT.eamp;
222+
213223
//----------------------------------------------------------
214224
// Fuxiang He add 2016-10-26
215225
//----------------------------------------------------------

source/module_surchem/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ add_library(
99
cal_vel.cpp
1010
corrected_energy.cpp
1111
minimize_cg.cpp
12+
efield.cpp
1213
)

0 commit comments

Comments
 (0)