Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
21 changes: 10 additions & 11 deletions docs/advanced/input_files/input-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
- [bessel\_descriptor\_smooth](#bessel_descriptor_smooth)
- [bessel\_descriptor\_sigma](#bessel_descriptor_sigma)
- [deepks\_bandgap](#deepks_bandgap)
- [deepks\_bandgap\_range](#deepks_bandgap_range)
- [deepks\_band\_range](#deepks_band_range)
- [deepks\_v\_delta](#deepks_v_delta)
- [deepks\_out\_unittest](#deepks_out_unittest)
- [OFDFT: orbital free density functional theory](#ofdft-orbital-free-density-functional-theory)
Expand Down Expand Up @@ -2149,20 +2149,19 @@ Warning: this function is not robust enough for the current version. Please try
- **Availability**: numerical atomic orbital basis and `deepks_scf` is true
- **Description**: include bandgap label for DeePKS training
- 0: Don't include bandgap label
- 1: Include HOMO and LOMO for bandgap label
- 2: Include multiple bandgap label (see [deepks\_bandgap\_range](#deepks_bandgap_range) for more details)
- 3: Include target bandgap label (see [deepks\_bandgap\_range](#deepks_bandgap_range) for more details)
- 4: For systems containing H atoms only, HOMO is defined as the max occupation expect H atoms and the bandgap label is the energy between (HOMO, HOMO + 1)
- 1: Include target bandgap label (see [deepks\_bandgap\_range](#deepks_band_range) for more details)
- 2: Include multiple bandgap label (see [deepks\_bandgap\_range](#deepks_band_range) for more details)
- 3: For systems containing H atoms only, HOMO is defined as the max occupation expect H atoms and the bandgap label is the energy between HOMO and (HOMO + 1)
- **Default**: 0

### deepks_bandgap_range
### deepks_band_range

- **Type**: Int*2
- **Availability**: numerical atomic orbital basis, `deepks_scf` is true, and `deepks_bandgap` is 2 or 3
- **Description**:
- `deepks_bandgap` is 2: Bandgap labels are energies between (LUMO + deepks_bandgap_range[0], HOMO), (LUMO + deepks_bandgap_range[0] + 1, HOMO), ..., (LUMO + deepks_bandgap_range[1], HOMO) except (HOMO, HOMO)
- `deepks_bandgap` is 3: Bandgap label is the energy between (LUMO + deepks_bandgap_range[0], LUMO + deepks_bandgap_range[1])
- **Default**: 0 0
- **Availability**: numerical atomic orbital basis, `deepks_scf` is true, and `deepks_bandgap` is 1 or 2
- **Description**: The first value should not be larger than the second one and the meaning differs in different cases below
- `deepks_bandgap` is 1: Bandgap label is the energy between `LUMO + deepks_band_range[0]` and `LUMO + deepks_band_range[1]`. If not set, it will calculate energy between HOMO and LUMO states.
- `deepks_bandgap` is 2: Bandgap labels are energies between HOMO and all states in range [`LUMO + deepks_band_range[0]`, `LUMO + deepks_band_range[1]`] (Thus there are `deepks_band_range[1] - deepks_band_range[0] + 1` bandgaps in total). If HOMO is included in the setting range, it will be ignored since it will always be zero and has no valuable messages (`deepks_band_range[1] - deepks_band_range[0]` bandgaps in this case). *NOTICE: The set range can be greater than, less than, or include the value of HOMO. In the bandgap label, we always calculate the energy of the state in the set range minus the energy of HOMO state, so the bandgap can be negative if the state is lower than HOMO.*
- **Default**: -1 0

### deepks_v_delta

Expand Down
343 changes: 80 additions & 263 deletions source/module_hamilt_lcao/module_deepks/LCAO_deepks_interface.cpp

Large diffs are not rendered by default.

29 changes: 26 additions & 3 deletions source/module_io/read_input_item_deepks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ void ReadInput::item_deepks()
read_sync_bool(input.deepks_scf);
item.check_value = [](const Input_Item& item, const Parameter& para) {
#ifndef __DEEPKS
if (PARAM.inp.deepks_scf || PARAM.inp.deepks_out_labels || PARAM.inp.deepks_bandgap
|| PARAM.inp.deepks_v_delta)
if (para.input.deepks_scf || para.input.deepks_out_labels || para.input.deepks_bandgap
|| para.input.deepks_v_delta)
{
ModuleBase::WARNING_QUIT("Input_conv", "please compile with DeePKS");
}
#endif
// if (!PARAM.inp.deepks_scf && PARAM.inp.deepks_out_labels == 1)
// if (!para.input.deepks_scf && para.input.deepks_out_labels == 1)
// {
// ModuleBase::WARNING_QUIT("Input_conv", "deepks_out_labels = 1 requires deepks_scf = 1");
// }
Expand Down Expand Up @@ -58,6 +58,29 @@ void ReadInput::item_deepks()
para.input.deepks_band_range[1] = std::stod(item.str_values[1]);
};
sync_intvec(input.deepks_band_range, 2, 0);
item.check_value = [](const Input_Item& item, const Parameter& para) {
if (para.input.deepks_bandgap == 1)
{
if (para.input.deepks_band_range[0] >= para.input.deepks_band_range[1])
{
ModuleBase::WARNING_QUIT("ReadInput", "deepks_band_range[0] must be smaller than deepks_band_range[1] for deepks_bandgap = 1.");
}
}
else if (para.input.deepks_bandgap == 2)
{
if (para.input.deepks_band_range[0] > para.input.deepks_band_range[1])
{
ModuleBase::WARNING_QUIT("ReadInput", "deepks_band_range[0] must be no more than deepks_band_range[1] for deepks_bandgap = 2.");
}
}
else
{
if (para.input.deepks_band_range[0] != -1 || para.input.deepks_band_range[1] != 0)
{
ModuleBase::WARNING("ReadInput", "deepks_band_range is used for deepks_bandgap = 1/2. Ignore its setting for other cases.");
}
}
};
this->add_item(item);
}
{
Expand Down
2 changes: 1 addition & 1 deletion source/module_parameter/input_parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ struct Input_para
bool deepks_scf = false; ///< (need libnpy and libtorch) if set to true, a trained model
///< would be needed to calculate V_delta and F_delta
int deepks_bandgap = 0; ///< for bandgap label. QO added 2021-12-15
std::vector<int> deepks_band_range = {0, 0}; ///< the range of bands to calculate bandgap
std::vector<int> deepks_band_range = {-1, 0}; ///< the range of bands to calculate bandgap
int deepks_v_delta = 0; ///< for v_delta label. xuan added
bool deepks_equiv = false; ///< whether to use equivariant version of DeePKS
bool deepks_out_unittest = false; ///< if set to true, prints intermediate quantities that shall
Expand Down
1 change: 1 addition & 0 deletions tests/09_DeePKS/103_NO_GO_deepks_bandgap/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ deepks_scf 1
deepks_model ../Model_ProjOrb/model_lda_pbe_18.ptg
deepks_out_labels 1
deepks_bandgap 1
deepks_band_range -1 0
1 change: 0 additions & 1 deletion tests/09_DeePKS/103_NO_GO_deepks_bandgap_3/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ deepks_scf 1
deepks_model ../Model_ProjOrb/model_lda_pbe_18.ptg
deepks_out_labels 1
deepks_bandgap 3
deepks_band_range -1 0
23 changes: 0 additions & 23 deletions tests/09_DeePKS/103_NO_GO_deepks_bandgap_4/INPUT

This file was deleted.

4 changes: 0 additions & 4 deletions tests/09_DeePKS/103_NO_GO_deepks_bandgap_4/KPT

This file was deleted.

1 change: 0 additions & 1 deletion tests/09_DeePKS/103_NO_GO_deepks_bandgap_4/README

This file was deleted.

32 changes: 0 additions & 32 deletions tests/09_DeePKS/103_NO_GO_deepks_bandgap_4/STRU

This file was deleted.

10 changes: 0 additions & 10 deletions tests/09_DeePKS/103_NO_GO_deepks_bandgap_4/result.ref

This file was deleted.

1 change: 1 addition & 0 deletions tests/09_DeePKS/103_NO_KP_deepks_bandgap/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ cal_stress 0
deepks_scf 1
deepks_out_labels 1
deepks_bandgap 1
deepks_band_range -1 0
deepks_model ../Model_ProjOrb/model_lda_pbe_18.ptg
symmetry_prec 1e-5
1 change: 0 additions & 1 deletion tests/09_DeePKS/103_NO_KP_deepks_bandgap_3/INPUT
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ cal_stress 0
deepks_scf 1
deepks_out_labels 1
deepks_bandgap 3
deepks_band_range -1 0
deepks_model ../Model_ProjOrb/model_lda_pbe_18.ptg
symmetry_prec 1e-5
24 changes: 0 additions & 24 deletions tests/09_DeePKS/103_NO_KP_deepks_bandgap_4/INPUT

This file was deleted.

4 changes: 0 additions & 4 deletions tests/09_DeePKS/103_NO_KP_deepks_bandgap_4/KPT

This file was deleted.

1 change: 0 additions & 1 deletion tests/09_DeePKS/103_NO_KP_deepks_bandgap_4/README

This file was deleted.

32 changes: 0 additions & 32 deletions tests/09_DeePKS/103_NO_KP_deepks_bandgap_4/STRU

This file was deleted.

10 changes: 0 additions & 10 deletions tests/09_DeePKS/103_NO_KP_deepks_bandgap_4/result.ref

This file was deleted.

2 changes: 0 additions & 2 deletions tests/09_DeePKS/CASES_CPU.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
103_NO_GO_deepks_bandgap
103_NO_GO_deepks_bandgap_2
103_NO_GO_deepks_bandgap_3
103_NO_GO_deepks_bandgap_4
103_NO_KP_deepks_bandgap
103_NO_KP_deepks_bandgap_2
103_NO_KP_deepks_bandgap_3
103_NO_KP_deepks_bandgap_4
103_NO_GO_deepks_vdelta_1
103_NO_KP_deepks_vdelta_1
103_NO_GO_deepks_vdelta_2
Expand Down
Loading