Skip to content

Commit 9ac5750

Browse files
linpeizePeizeLin
andauthored
add write_libxc_r (#6293)
* add write_libxc_r * 1. chage file_name of write_xc_r according to v3.9.0.7 2. fix bug of write_xc_r when compiled without Libxc 3. add description in input-main.md --------- Co-authored-by: linpz <[email protected]>
1 parent 9efc3e9 commit 9ac5750

File tree

8 files changed

+567
-1
lines changed

8 files changed

+567
-1
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
- [Output Variables](#variables-related-to-output-information)
135135
- [out\_freq\_elec](#out_freq_elec)
136136
- [out\_chg](#out_chg)
137+
- [out\_xc\_r](#out_xc_r)
137138
- [out\_pot](#out_pot)
138139
- [out\_dm](#out_dmk)
139140
- [out\_dm1](#out_dmr)
@@ -1652,6 +1653,25 @@ These variables are used to control the output of properties.
16521653
- **Default**: 0 3
16531654
- **Note**: In the 3.10-LTS version, the file names are SPIN1_CHG.cube and SPIN1_CHG_INI.cube, etc.
16541655

1656+
### out_xc_r
1657+
1658+
- **Type**: Integer \[Integer\](optional)
1659+
- **Description**:
1660+
The first integer controls whether to output the exchange-correlation (in Bohr^-3) on real space grids using Libxc to folder `OUT.${suffix}`:
1661+
- 0: rho, amag, sigma, exc
1662+
- 1: vrho, vsigma
1663+
- 2: v2rho2, v2rhosigma, v2sigma2
1664+
- 3: v3rho3, v3rho2sigma, v3rhosigma2, v3sigma3
1665+
- 4: v4rho4, v4rho3sigma, v4rho2sigma2, v4rhosigma3, v4sigma4
1666+
The meaning of the files is presented in [Libxc](https://libxc.gitlab.io/manual/libxc-5.1.x/)
1667+
1668+
The second integer controls the precision of the charge density output, if not given, will use `3` as default.
1669+
1670+
---
1671+
The circle order of the charge density on real space grids is: x is the outer loop, then y and finally z (z is moving fastest).
1672+
1673+
- **Default**: -1 3
1674+
16551675
### out_pot
16561676

16571677
- **Type**: Integer

source/Makefile.Objects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ OBJS_IO=input_conv.o\
539539
write_dipole.o\
540540
td_current_io.o\
541541
write_wfc_r.o\
542+
write_libxc_r.o\
542543
output_log.o\
543544
output_mat_sparse.o\
544545
ctrl_output_lcao.o\

source/module_io/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ list(APPEND objects
3131
write_mlkedf_descriptors.cpp
3232
td_current_io.cpp
3333
write_wfc_r.cpp
34+
write_libxc_r.cpp
3435
output_log.cpp
3536
para_json.cpp
3637
parse_args.cpp

source/module_io/read_input_item_output.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,27 @@ void ReadInput::item_output()
514514
add_intvec_bcast(input.out_wfc_re_im, para.input.out_wfc_re_im.size(), 0);
515515
this->add_item(item);
516516
}
517+
{
518+
Input_Item item("out_xc_r");
519+
item.annotation = "if >=0, output the derivatives of exchange correlation in realspace, second parameter controls the precision";
520+
item.read_value = [](const Input_Item& item, Parameter& para) {
521+
size_t count = item.get_size();
522+
std::vector<int> out_xc_r(count); // create a placeholder vector
523+
std::transform(item.str_values.begin(), item.str_values.end(), out_xc_r.begin(), [](std::string s) { return std::stoi(s); });
524+
// assign non-negative values to para.input.out_xc_r
525+
std::copy(out_xc_r.begin(), out_xc_r.end(), para.input.out_xc_r.begin());
526+
};
527+
item.check_value = [](const Input_Item& item, const Parameter& para) {
528+
if (para.input.out_xc_r[0] >= 0)
529+
{
530+
#ifndef USE_LIBXC
531+
ModuleBase::WARNING_QUIT("ReadInput", "INPUT out_xc_r is only aviailable with Libxc");
532+
#endif
533+
}
534+
};
535+
sync_intvec(input.out_xc_r, 2, -1);
536+
this->add_item(item);
537+
}
517538
{
518539
Input_Item item("if_separate_k");
519540
item.annotation = "specify whether to write the partial charge densities for all k-points to individual files "

0 commit comments

Comments
 (0)