Skip to content

Commit 2dea783

Browse files
author
jianrui geng
committed
Add fixed-cell i-PI socket driver
1 parent a02d7c7 commit 2dea783

10 files changed

Lines changed: 829 additions & 9 deletions

File tree

docs/advanced/input_files/input-main.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@
583583
- relax: perform structure relaxation calculations, the relax_nmax parameter depicts the maximal number of ionic iterations
584584
- cell-relax: perform cell relaxation calculations
585585
- md: perform molecular dynamics simulations
586+
- socket: run as a socket client for external drivers using the i-PI protocol
586587
- get_pchg: obtain partial (band-decomposed) charge densities (for LCAO basis only). See out_pchg for more information
587588
- get_wf: obtain real space wave functions (for LCAO basis only). See out_wfc_norm and out_wfc_re_im for more information
588589
- 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
@@ -814,7 +815,12 @@
814815
### chg_extrap
815816

816817
- **Type**: String
817-
- **Description**: Charge extrapolation method for MD and relaxation calculations.
818+
- **Description**: Charge extrapolation method for MD, relaxation, and socket-driven calculations.
819+
820+
When set to default, ABACUS chooses second-order for md, first-order for
821+
relax/cell-relax/socket, and atomic for other calculations. Socket-driven
822+
molecular dynamics can explicitly set second-order if the external driver
823+
updates structures smoothly enough for second-order extrapolation.
818824
- **Default**: default
819825

820826
### nb2d

docs/parameters.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ parameters:
2828
* relax: perform structure relaxation calculations, the relax_nmax parameter depicts the maximal number of ionic iterations
2929
* cell-relax: perform cell relaxation calculations
3030
* md: perform molecular dynamics simulations
31+
* socket: run as a socket client for external drivers using the i-PI protocol
3132
* get_pchg: obtain partial (band-decomposed) charge densities (for LCAO basis only). See out_pchg for more information
3233
* get_wf: obtain real space wave functions (for LCAO basis only). See out_wfc_norm and out_wfc_re_im for more information
3334
* 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
@@ -314,7 +315,12 @@ parameters:
314315
category: System variables
315316
type: String
316317
description: |
317-
Charge extrapolation method for MD and relaxation calculations.
318+
Charge extrapolation method for MD, relaxation, and socket-driven calculations.
319+
320+
When set to default, ABACUS chooses second-order for md, first-order for
321+
relax/cell-relax/socket, and atomic for other calculations. Socket-driven
322+
molecular dynamics can explicitly set second-order if the external driver
323+
updates structures smoothly enough for second-order extrapolation.
318324
default_value: default
319325
unit: ""
320326
availability: ""

source/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,9 @@ add_library(
477477
driver
478478
OBJECT
479479
source_main/driver.cpp
480-
source_main/driver_run.cpp)
480+
source_main/driver_run.cpp
481+
source_main/driver_ipi.cpp
482+
source_main/ipi_socket.cpp)
481483

482484
list(APPEND device_srcs
483485
source_pw/module_pwdft/kernels/nonlocal_op.cpp

source/source_io/module_parameter/read_input_item_system.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void ReadInput::item_system()
7575
}
7676
{
7777
Input_Item item("calculation");
78-
item.annotation = "scf; relax; md; cell-relax; nscf; get_s; get_wf; get_pchg; gen_bessel; gen_opt_abfs; test_memory; test_neighbour";
78+
item.annotation = "scf; relax; md; socket; cell-relax; nscf; get_s; get_wf; get_pchg; gen_bessel; gen_opt_abfs; test_memory; test_neighbour";
7979
item.category = "System variables";
8080
item.type = "String";
8181
item.description = R"(Specify the type of calculation.
@@ -85,6 +85,7 @@ void ReadInput::item_system()
8585
* relax: perform structure relaxation calculations, the relax_nmax parameter depicts the maximal number of ionic iterations
8686
* cell-relax: perform cell relaxation calculations
8787
* md: perform molecular dynamics simulations
88+
* socket: run as a socket client for external drivers using the i-PI protocol
8889
* get_pchg: obtain partial (band-decomposed) charge densities (for LCAO basis only). See out_pchg for more information
8990
* get_wf: obtain real space wave functions (for LCAO basis only). See out_wfc_norm and out_wfc_re_im for more information
9091
* 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
@@ -102,6 +103,7 @@ void ReadInput::item_system()
102103
std::vector<std::string> callist = {"scf",
103104
"relax",
104105
"md",
106+
"socket",
105107
"cell-relax",
106108
"nscf",
107109
"get_s",
@@ -266,7 +268,7 @@ void ReadInput::item_system()
266268
item.description = "If set to True, calculate the force at the end of the electronic iteration.";
267269
item.default_value = "False";
268270
item.reset_value = [](const Input_Item& item, Parameter& para) {
269-
std::vector<std::string> use_force = {"cell-relax", "relax", "md"};
271+
std::vector<std::string> use_force = {"cell-relax", "relax", "md", "socket"};
270272
std::vector<std::string> not_use_force = {"get_wf", "get_pchg", "get_s"};
271273
if (std::find(use_force.begin(), use_force.end(), para.input.calculation) != use_force.end())
272274
{
@@ -873,7 +875,12 @@ Available options are:
873875
item.annotation = "atomic; first-order; second-order; dm:coefficients of SIA";
874876
item.category = "System variables";
875877
item.type = "String";
876-
item.description = "Charge extrapolation method for MD and relaxation calculations.";
878+
item.description = R"(Charge extrapolation method for MD, relaxation, and socket-driven calculations.
879+
880+
When set to default, ABACUS chooses second-order for md, first-order for
881+
relax/cell-relax/socket, and atomic for other calculations. Socket-driven
882+
molecular dynamics can explicitly set second-order if the external driver
883+
updates structures smoothly enough for second-order extrapolation.)";
877884
item.default_value = "default";
878885
read_sync_string(input.chg_extrap);
879886
item.reset_value = [](const Input_Item& item, Parameter& para) {
@@ -882,7 +889,7 @@ Available options are:
882889
para.input.chg_extrap = "second-order";
883890
}
884891
else if (para.input.chg_extrap == "default"
885-
&& (para.input.calculation == "relax" || para.input.calculation == "cell-relax"))
892+
&& (para.input.calculation == "relax" || para.input.calculation == "cell-relax" || para.input.calculation == "socket"))
886893
{
887894
para.input.chg_extrap = "first-order";
888895
}

source/source_io/test_serial/read_input_item_test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,11 @@ TEST_F(InputTest, Item_test)
362362
it->second.reset_value(it->second, param);
363363
EXPECT_EQ(param.input.chg_extrap, "first-order");
364364

365+
param.input.chg_extrap = "default";
366+
param.input.calculation = "socket";
367+
it->second.reset_value(it->second, param);
368+
EXPECT_EQ(param.input.chg_extrap, "first-order");
369+
365370
param.input.chg_extrap = "default";
366371
param.input.calculation = "none";
367372
it->second.reset_value(it->second, param);

source/source_main/driver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Driver
3636

3737
// the actual calculations
3838
void driver_run();
39+
void driver_ipi_run();
3940

4041
// Init harewares according to Input parameters
4142
void init_hardware();

0 commit comments

Comments
 (0)