Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion docs/advanced/input_files/input-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@
- relax: perform structure relaxation calculations, the relax_nmax parameter depicts the maximal number of ionic iterations
- cell-relax: perform cell relaxation calculations
- md: perform molecular dynamics simulations
- socket: run as a socket client for external drivers using the i-PI protocol
- get_pchg: obtain partial (band-decomposed) charge densities (for LCAO basis only). See out_pchg for more information
- get_wf: obtain real space wave functions (for LCAO basis only). See out_wfc_norm and out_wfc_re_im for more information
- get_s: obtain the overlap matrix formed by localized orbitals (for LCAO basis with multiple k points). the file name is SR.csr with file format being the same as that generated by out_mat_hs2
Expand Down Expand Up @@ -840,7 +841,12 @@
### chg_extrap

- **Type**: String
- **Description**: Charge extrapolation method for MD and relaxation calculations.
- **Description**: Charge extrapolation method for MD, relaxation, and socket-driven calculations.

When set to default, ABACUS chooses second-order for md, first-order for
relax/cell-relax/socket, and atomic for other calculations. Socket-driven
molecular dynamics can explicitly set second-order if the external driver
updates structures smoothly enough for second-order extrapolation.
- **Default**: default

### nb2d
Expand Down
8 changes: 7 additions & 1 deletion docs/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ parameters:
* relax: perform structure relaxation calculations, the relax_nmax parameter depicts the maximal number of ionic iterations
* cell-relax: perform cell relaxation calculations
* md: perform molecular dynamics simulations
* socket: run as a socket client for external drivers using the i-PI protocol
* get_pchg: obtain partial (band-decomposed) charge densities (for LCAO basis only). See out_pchg for more information
* get_wf: obtain real space wave functions (for LCAO basis only). See out_wfc_norm and out_wfc_re_im for more information
* get_s: obtain the overlap matrix formed by localized orbitals (for LCAO basis with multiple k points). the file name is SR.csr with file format being the same as that generated by out_mat_hs2
Expand Down Expand Up @@ -328,7 +329,12 @@ parameters:
category: System variables
type: String
description: |
Charge extrapolation method for MD and relaxation calculations.
Charge extrapolation method for MD, relaxation, and socket-driven calculations.

When set to default, ABACUS chooses second-order for md, first-order for
relax/cell-relax/socket, and atomic for other calculations. Socket-driven
molecular dynamics can explicitly set second-order if the external driver
updates structures smoothly enough for second-order extrapolation.
default_value: default
unit: ""
availability: ""
Expand Down
15 changes: 11 additions & 4 deletions source/source_io/module_parameter/read_input_item_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void ReadInput::item_system()
}
{
Input_Item item("calculation");
item.annotation = "scf; relax; md; cell-relax; nscf; get_s; get_wf; get_pchg; gen_bessel; gen_opt_abfs; test_memory; test_neighbour";
item.annotation = "scf; relax; md; socket; cell-relax; nscf; get_s; get_wf; get_pchg; gen_bessel; gen_opt_abfs; test_memory; test_neighbour";
item.category = "System variables";
item.type = "String";
item.description = R"(Specify the type of calculation.
Expand All @@ -85,6 +85,7 @@ void ReadInput::item_system()
* relax: perform structure relaxation calculations, the relax_nmax parameter depicts the maximal number of ionic iterations
* cell-relax: perform cell relaxation calculations
* md: perform molecular dynamics simulations
* socket: run as a socket client for external drivers using the i-PI protocol

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have an example to demonstrate how to use this feature?

* get_pchg: obtain partial (band-decomposed) charge densities (for LCAO basis only). See out_pchg for more information
* get_wf: obtain real space wave functions (for LCAO basis only). See out_wfc_norm and out_wfc_re_im for more information
* get_s: obtain the overlap matrix formed by localized orbitals (for LCAO basis with multiple k points). the file name is SR.csr with file format being the same as that generated by out_mat_hs2
Expand All @@ -102,6 +103,7 @@ void ReadInput::item_system()
std::vector<std::string> callist = {"scf",
"relax",
"md",
"socket",
"cell-relax",
"nscf",
"get_s",
Expand Down Expand Up @@ -266,7 +268,7 @@ void ReadInput::item_system()
item.description = "If set to True, calculate the force at the end of the electronic iteration.";
item.default_value = "False";
item.reset_value = [](const Input_Item& item, Parameter& para) {
std::vector<std::string> use_force = {"cell-relax", "relax", "md"};
std::vector<std::string> use_force = {"cell-relax", "relax", "md", "socket"};
std::vector<std::string> not_use_force = {"get_wf", "get_pchg", "get_s"};
if (std::find(use_force.begin(), use_force.end(), para.input.calculation) != use_force.end())
{
Expand Down Expand Up @@ -873,7 +875,12 @@ Available options are:
item.annotation = "atomic; first-order; second-order; dm:coefficients of SIA";
item.category = "System variables";
item.type = "String";
item.description = "Charge extrapolation method for MD and relaxation calculations.";
item.description = R"(Charge extrapolation method for MD, relaxation, and socket-driven calculations.

When set to default, ABACUS chooses second-order for md, first-order for
relax/cell-relax/socket, and atomic for other calculations. Socket-driven
molecular dynamics can explicitly set second-order if the external driver
updates structures smoothly enough for second-order extrapolation.)";
item.default_value = "default";
read_sync_string(input.chg_extrap);
item.reset_value = [](const Input_Item& item, Parameter& para) {
Expand All @@ -882,7 +889,7 @@ Available options are:
para.input.chg_extrap = "second-order";
}
else if (para.input.chg_extrap == "default"
&& (para.input.calculation == "relax" || para.input.calculation == "cell-relax"))
&& (para.input.calculation == "relax" || para.input.calculation == "cell-relax" || para.input.calculation == "socket"))
{
para.input.chg_extrap = "first-order";
}
Expand Down
5 changes: 5 additions & 0 deletions source/source_io/test_serial/read_input_item_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ TEST_F(InputTest, Item_test)
it->second.reset_value(it->second, param);
EXPECT_EQ(param.input.chg_extrap, "first-order");

param.input.chg_extrap = "default";
param.input.calculation = "socket";
it->second.reset_value(it->second, param);
EXPECT_EQ(param.input.chg_extrap, "first-order");

param.input.chg_extrap = "default";
param.input.calculation = "none";
it->second.reset_value(it->second, param);
Expand Down
17 changes: 12 additions & 5 deletions source/source_main/driver_run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,33 @@ void Driver::driver_run()
unitcell::check_atomic_stru(ucell, PARAM.inp.min_dist_coef);

//! 2: initialize the ESolver (depends on a set-up ucell after `setup_cell`)
Input_para socket_esolver_inp = PARAM.inp;
const bool socket_mode = (socket_esolver_inp.calculation == "socket");
if (socket_mode)
{
socket_esolver_inp.calculation = "scf";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, but here it seems not appropriate to set the calculation as 'socket' first and then change it to 'scf', it may better to design another variable other than calculation

}
const Input_para& esolver_inp = socket_mode ? socket_esolver_inp : PARAM.inp;

this->init_hardware();

ModuleESolver::ESolver* p_esolver = ModuleESolver::init_esolver(PARAM.inp, ucell);
ModuleESolver::ESolver* p_esolver = ModuleESolver::init_esolver(esolver_inp, ucell);

//! 3: initialize Esolver and fill json-structure
p_esolver->before_all_runners(ucell, PARAM.inp);
p_esolver->before_all_runners(ucell, esolver_inp);

// this Json part should be moved to before_all_runners, mohan 2024-05-12
#ifdef __RAPIDJSON
Json::gen_stru_wrapper(&ucell);
#endif

const std::string cal = PARAM.inp.calculation;

//! 4: different types of calculations
const std::string cal = PARAM.inp.calculation;
if (cal == "md")
{
Run_MD::md_line(ucell, p_esolver, PARAM);
}
else if (cal == "scf" || cal == "relax" || cal == "cell-relax" || cal == "nscf")
else if (cal == "scf" || cal == "relax" || cal == "cell-relax" || cal == "nscf" || cal == "socket")
{
Relax_Driver rl_driver;
rl_driver.relax_driver(p_esolver, ucell, PARAM.inp, GlobalV::ofs_running);
Expand Down
2 changes: 2 additions & 0 deletions source/source_relax/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ add_library(
relax
OBJECT
relax_data.cpp
ipi_socket.cpp

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems better to name the file name as socket_ipi.cpp, consistent with the socket_driver.cpp

socket_driver.cpp
cg_base.cpp
relax_driver.cpp
relax_sync.cpp
Expand Down
Loading
Loading