You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/advanced/input_files/input-main.md
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@
10
10
-[ntype](#ntype)
11
11
-[cell\_replica](#cell_replica)
12
12
-[calculation](#calculation)
13
+
-[socket\_driver](#socket_driver)
13
14
-[esolver\_type](#esolver_type)
14
15
-[symmetry](#symmetry)
15
16
-[symmetry\_prec](#symmetry_prec)
@@ -637,6 +638,20 @@
637
638
- test_neighbour: obtain information of neighboring atoms (for LCAO basis only), please specify a positive search_radius manually
638
639
-**Default**: scf
639
640
641
+
### socket_driver
642
+
643
+
-**Type**: Boolean
644
+
-**Description**: If set to True, ABACUS keeps the calculation type as scf and receives atomic positions from an external driver through the i-PI socket protocol.
645
+
646
+
> Note: Use calculation = scf with socket_driver = True. ABACUS connects to the external i-PI server selected by ABACUS_SOCKET_ADDRESS. If ABACUS_SOCKET_ADDRESS is unset, ABACUS uses localhost:31415. The value can use one of two forms:
647
+
648
+
- host:port, for example localhost:31415 or 127.0.0.1:31415, opens a TCP connection to that host and port. Use this when the i-PI server listens on a TCP port.
649
+
- path:UNIX, for example /tmp/ipi_abacus_si:UNIX, opens a Unix-domain socket at the given filesystem path. The :UNIX suffix tells ABACUS that the preceding value is a local socket path rather than a TCP host name. This form only works on the same machine.
650
+
When using the ASE AbacusSocketIO interface, this environment variable is set automatically from the port or unixsocket calculator argument.
651
+
652
+
Socket mode always computes energy. Force and stress extraction follows cal_force and cal_stress independently; disabled properties are sent as protocol padding and marked absent in the ABACUS i-PI extras metadata, not reported as physical zero values. This metadata extension is required for safe optional-property handling: a legacy response with empty extras is accepted only for energy-only use, while a generic client that ignores extras cannot distinguish padding from a computed zero. A non-converged SCF step is returned with scf_converged=false metadata so an external driver can choose its policy.
653
+
-**Default**: False
654
+
640
655
### esolver_type
641
656
642
657
-**Type**: String
@@ -686,6 +701,7 @@
686
701
687
702
-**Type**: Boolean
688
703
-**Description**: If set to True, calculate the force at the end of the electronic iteration.
704
+
In socket_driver mode, this flag controls whether the returned frame advertises forces; it is not forced on by the socket protocol.
689
705
-**Default**: False
690
706
691
707
### kpar
@@ -801,6 +817,7 @@
801
817
802
818
-**Type**: Boolean
803
819
-**Description**: If set to True, calculate the stress at the end of the electronic iteration.
820
+
In socket_driver mode, this flag independently controls whether the returned frame advertises stress/virial.
804
821
-**Default**: False
805
822
806
823
### diago_proc
@@ -899,7 +916,12 @@
899
916
### chg_extrap
900
917
901
918
-**Type**: String
902
-
-**Description**: Charge extrapolation method for MD and relaxation calculations.
919
+
-**Description**: Charge extrapolation method for MD, relaxation, and socket-driven calculations.
920
+
921
+
When set to default, ABACUS chooses second-order for md, first-order for
922
+
relax/cell-relax and socket_driver calculations, and atomic for other calculations. Socket-driven
923
+
molecular dynamics can explicitly set second-order if the external driver
924
+
updates structures smoothly enough for second-order extrapolation.
Copy file name to clipboardExpand all lines: docs/advanced/interface/ase.md
+105Lines changed: 105 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,6 +103,104 @@ In the new implementation, we limit the range of functionalties supported to mai
103
103
104
104
Please read the examples in `interfaces/ASE_interface/examples/` for more details.
105
105
106
+
### Socket I/O with ASE
107
+
108
+
#### When to use socket mode
109
+
110
+
`AbacusSocketIO` is designed for a sequence of electronic-structure
111
+
evaluations in which the atomic positions change while the simulation context
112
+
remains fixed. Reuse one socket calculator only when the cell and periodic
113
+
boundary conditions, atom count and species, pseudopotentials and orbitals,
114
+
k-point sampling, spin settings, and other electronic-structure parameters do
115
+
not change. The socket session can then keep one ABACUS process alive and
116
+
receive successive position updates.
117
+
118
+
This pattern is suitable for fixed-cell ASE optimization and molecular
119
+
dynamics, fixed-cell NEB (use an independent calculator/session for each image),
120
+
finite-displacement phonon or ASE finite-difference frequency calculations,
121
+
position-only P-RFO or transition-state searches, and repeated fixed-cell
122
+
force evaluations in larger workflows such as thermal-property or active-
123
+
learning data generation. These workflows can use the socket calculator only
124
+
when their driver calls the ASE calculator interface; the existing Phonopy,
125
+
ShengBTE, DP-GEN, or transition-state tools are not automatically converted
126
+
to socket workflows by installing abacuslite.
127
+
128
+
Use the regular `Abacus` FileIO calculator when the cell, composition, or
129
+
electronic-structure settings must change. Direct DFPT or dynamical-matrix
130
+
calculations, and external workflows that require properties beyond energy,
131
+
forces, and stress, also remain outside the current socket property interface.
132
+
133
+
For socket-driven ASE workflows, use the `AbacusSocketIO` calculator. ASE runs the i-PI socket server, while ABACUS keeps `calculation=scf` and is launched with `socket_driver=1` as the client. Energy, forces, and stress are independent properties controlled by `cal_force` and `cal_stress`; the fixed i-PI wire layout still contains padding fields, while extras metadata identifies which values were actually computed. See the [ASE socket I/O documentation](https://ase-lib.org/ase/calculators/socketio/socketio.html) and the i-PI reference paper, [Ceriotti et al., Comput. Phys. Commun. 185, 1019-1026 (2014)](https://doi.org/10.1016/j.cpc.2013.10.027), for the protocol background.
134
+
135
+
Build ABACUS as usual before using this interface. PW-only builds work with `basis_type=pw`; LCAO socket calculations require an LCAO-enabled executable. No extra socket library is required.
136
+
137
+
With CMake, choose the executable according to the basis:
With the ABACUS toolchain workflow, build the normal ABACUS executable with LCAO support when `basis_type=lcao` is needed, then pass that executable to `AbacusProfile(command=...)`. The command can include an MPI launcher, for example `mpirun -np 4 /path/to/abacus`; ABACUS rank 0 opens the socket connection and broadcasts the i-PI data to the other ranks internally. On managed clusters, keep scheduler-specific launch options outside the calculator when possible and test the exact launcher command on a compute node.
148
+
149
+
For PW calculations on CUDA/ROCm with multiple MPI ranks, use a k-point layout compatible with ABACUS' GPU parallelization. In practice, make sure each k-point pool contains one MPI rank; for example, a 4-rank PW GPU socket calculation should use at least four k-points so the default GPU `kpar` adjustment can assign one rank per pool. A one-k-point PW GPU job with several MPI ranks can fail in the PW GPU transform path; reduce the rank count or use a denser k-point mesh such as a smaller `kspacing`.
150
+
151
+
The ASE interface can be installed from this repository with:
152
+
153
+
```bash
154
+
cd interfaces/ASE_interface
155
+
pip install .
156
+
```
157
+
158
+
A minimal socket calculator setup is:
159
+
160
+
```python
161
+
from ase.optimize importBFGS
162
+
from abacuslite import AbacusProfile, AbacusSocketIO
`AbacusSocketIO` sets `socket_driver=1` automatically. The adapter enables properties requested through ASE, restarting the client if a later request expands the active property set. Set `inp={'cal_force': 1}` and/or `inp={'cal_stress': 1}` when a fixed-cell optimizer, MD integrator, or stress evaluation client needs those properties. Energy is always available. The interface selects the socket endpoint and passes it to ABACUS through `ABACUS_SOCKET_ADDRESS`, so users normally do not set this environment variable by hand when using abacuslite.
186
+
187
+
There are two endpoint styles:
188
+
189
+
-`unixsocket="abacus_si"` uses a local Unix-domain socket. ASE creates and listens on `/tmp/ipi_abacus_si`; abacuslite launches ABACUS with `ABACUS_SOCKET_ADDRESS=/tmp/ipi_abacus_si:UNIX`. The `:UNIX` suffix is part of ABACUS' address syntax and means that `/tmp/ipi_abacus_si` is a filesystem socket path, not a TCP host. This is usually the best choice when ASE and ABACUS run on the same node because it avoids TCP port conflicts.
190
+
-`port=31415` uses a TCP socket. abacuslite launches ABACUS with `ABACUS_SOCKET_ADDRESS=localhost:31415`, meaning host `localhost` and TCP port `31415`. Use this style when the socket server should listen on a TCP port. If ABACUS is launched manually instead of through `AbacusSocketIO`, set `ABACUS_SOCKET_ADDRESS` yourself to the same `host:port` or `path:UNIX` endpoint.
191
+
192
+
Calling `atoms.get_potential_energy()` does not force a force or stress calculation. If a requested property was disabled, ASE raises `PropertyNotImplementedError`; zero-filled i-PI padding is never treated as a physical result. When SCF does not converge, `AbacusSocketIO.last_scf_converged` is set to `False` and the caller decides whether to continue or stop.
193
+
194
+
The ABACUS metadata extension is required to expose force/stress presence safely. If a legacy client returns an empty extras field, the adapter accepts only an energy-only response and refuses to infer forces or stress from the fixed-wire padding. Generic i-PI/ASE clients that ignore ABACUS extras cannot distinguish mandatory padding from a computed zero; use `AbacusSocketIO` or another metadata-aware client when requesting optional properties. When launching ABACUS with a generic client, explicitly set `cal_force=1` for force-driven workflows and `cal_stress=1` for stress evaluation; an omitted switch defaults to disabled. Such clients also need their own policy for unconverged SCF results.
195
+
196
+
A socket calculator owns one ABACUS process initialized from one fixed `INPUT`/`STRU` setup. Reuse the same `AbacusSocketIO` instance only for position updates under the same electronic-structure settings and the same cell. Do not change `kpts`, `kspacing`, `nspin`, `basis_type`, `basissets`, pseudopotentials, species, atom count, cell, or other core `INPUT`/`STRU` parameters through an existing socket calculator; create a new `AbacusSocketIO` instance and a new ABACUS client process for those changes. `AbacusSocketIO` rejects cell changes before sending them to ABACUS, and the ABACUS socket driver also checks incoming POSDATA cells against the initial `STRU` cell and exits if they differ.
197
+
198
+
In socket mode, ABACUS keeps one client process alive. All SCF evaluations produced by the same `AbacusSocketIO` instance are appended to the same `OUT.ABACUS/running_scf.log`, because the ABACUS calculation type remains `scf`. The authoritative per-step energy and force results are returned through the i-PI socket to ASE. Use ASE trajectory and optimizer log files, such as `BFGS(atoms, trajectory="opt.traj", logfile="opt.log")`, when each optimizer or MD step should be saved separately. Treat `running_scf.log` mainly as the ABACUS diagnostic log for the socket client, not as one independent FileIO result per structure.
199
+
200
+
The i-PI protocol does not transmit element symbols. `AbacusSocketIO` therefore sorts the internal socket atoms with the same first-occurrence species grouping used when writing `STRU`, and maps returned forces back to the original ASE `Atoms` order. This avoids silent force/atom mismatches when structures are read from CIF, extxyz, POSCAR, or other formats whose atom order is not already grouped for ABACUS. Users should not manually reorder atoms for socket I/O; pass the physical ASE `Atoms` object directly to the calculator.
201
+
202
+
A complete fixed-cell validation and benchmark example is available in `interfaces/ASE_interface/examples/socketio.py`.
203
+
106
204
## SPAP Analysis
107
205
108
206
[SPAP](https://github.com/chuanxun/StructurePrototypeAnalysisPackage) (Structure Prototype Analysis Package) is written by Dr. Chuanxun Su to analyze symmetry and compare similarity of large amount of atomic structures. The coordination characterization function (CCF) is used to
@@ -114,3 +212,10 @@ If you use this program and method in your research, please read and cite the pu
114
212
`Su C, Lv J, Li Q, Wang H, Zhang L, Wang Y, Ma Y. Construction of crystal structure prototype database: methods and applications. J Phys Condens Matter. 2017 Apr 26;29(16):165901.`
115
213
116
214
and you should install it first with command `pip install spap`.
215
+
216
+
Socket results are read directly from the completed in-memory solver frame, not
217
+
parsed from output files. The client clears cached results and convergence
218
+
metadata before a new request and publishes them only after validating the full
219
+
response. A failed request therefore leaves no previous-frame result available
220
+
in the calculator cache. This protocol guarantee does not establish SCF
221
+
convergence or numerical agreement with independent single-point calculations.
Copy file name to clipboardExpand all lines: docs/parameters.yaml
+23-1Lines changed: 23 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,21 @@ parameters:
46
46
default_value: scf
47
47
unit: ""
48
48
availability: ""
49
+
- name: socket_driver
50
+
category: System variables
51
+
type: Boolean
52
+
description: |
53
+
If set to True, ABACUS keeps the calculation type as scf and receives atomic positions from an external driver through the i-PI socket protocol.
54
+
55
+
[NOTE] Use calculation = scf with socket_driver = True. ABACUS connects to the external i-PI server selected by ABACUS_SOCKET_ADDRESS. If ABACUS_SOCKET_ADDRESS is unset, ABACUS uses localhost:31415. The value can use one of two forms:
56
+
* host:port, for example localhost:31415 or 127.0.0.1:31415, opens a TCP connection to that host and port. Use this when the i-PI server listens on a TCP port.
57
+
* path:UNIX, for example /tmp/ipi_abacus_si:UNIX, opens a Unix-domain socket at the given filesystem path. The :UNIX suffix tells ABACUS that the preceding value is a local socket path rather than a TCP host name. This form only works on the same machine.
58
+
When using the ASE AbacusSocketIO interface, this environment variable is set automatically from the port or unixsocket calculator argument.
59
+
60
+
Socket mode always computes energy. Force and stress extraction follows cal_force and cal_stress independently; disabled properties are sent as protocol padding and marked absent in the ABACUS i-PI extras metadata, not reported as physical zero values. This metadata extension is required for safe optional-property handling: a legacy response with empty extras is accepted only for energy-only use, while a generic client that ignores extras cannot distinguish padding from a computed zero. A non-converged SCF step is returned with scf_converged=false metadata so an external driver can choose its policy.
61
+
default_value: "False"
62
+
unit: ""
63
+
availability: ""
49
64
- name: esolver_type
50
65
category: System variables
51
66
type: String
@@ -102,6 +117,7 @@ parameters:
102
117
type: Boolean
103
118
description: |
104
119
If set to True, calculate the force at the end of the electronic iteration.
120
+
In socket_driver mode, this flag controls whether the returned frame advertises forces; it is not forced on by the socket protocol.
105
121
default_value: "False"
106
122
unit: ""
107
123
availability: ""
@@ -230,6 +246,7 @@ parameters:
230
246
type: Boolean
231
247
description: |
232
248
If set to True, calculate the stress at the end of the electronic iteration.
249
+
In socket_driver mode, this flag independently controls whether the returned frame advertises stress/virial.
233
250
default_value: "False"
234
251
unit: ""
235
252
availability: ""
@@ -350,7 +367,12 @@ parameters:
350
367
category: System variables
351
368
type: String
352
369
description: |
353
-
Charge extrapolation method for MD and relaxation calculations.
370
+
Charge extrapolation method for MD, relaxation, and socket-driven calculations.
371
+
372
+
When set to default, ABACUS chooses second-order for md, first-order for
373
+
relax/cell-relax and socket_driver calculations, and atomic for other calculations. Socket-driven
374
+
molecular dynamics can explicitly set second-order if the external driver
375
+
updates structures smoothly enough for second-order extrapolation.
Copy file name to clipboardExpand all lines: interfaces/ASE_interface/README.md
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,15 +7,17 @@ abacuslite is a lightweight plugin for ABACUS (Atomic-orbital Based Ab-initio Co
7
7
### Key Features
8
8
9
9
-**Lightweight Design**: Implemented as a plugin, no need to modify ASE core code
10
-
-**Version Compatibility**: No longer restricted to specific ASE versions, works with most ASE versions
10
+
-**Version Compatibility**: Supports ASE versions satisfying the package requirement `ase>=3.22`
11
11
-**ASE Integration**: Uses ASE as the running platform, making ABACUS a callable calculator within it
12
-
-**Function Support**: Currently only supports SCF (Self-Consistent Field) functionality, returning energy, forces, stress, etc.
12
+
-**Function Support**: Provides SCF-based energy, force, and stress evaluations through ASE. ASE can use these evaluations for relaxation, molecular dynamics, NEB, band-structure, and density-of-states workflows.
13
+
-**Socket Support**: `AbacusSocketIO` provides fixed-cell i-PI socket calculations, with energy always available and forces/stress enabled independently when requested.
13
14
14
15
## Installation
15
16
16
-
Installation is very simple, just execute the following command in the project root directory:
17
+
Install the plugin from the ASE interface directory:
17
18
18
19
```bash
20
+
cd interfaces/ASE_interface
19
21
pip install .
20
22
```
21
23
@@ -32,8 +34,10 @@ Please refer to the example scripts in the `examples` folder. Recommended learni
11.**socketio.py** - Fixed-cell ASE optimization with `AbacusSocketIO`, running ABACUS as an i-PI socket client
35
39
36
-
More usage examples will be provided in future versions.
40
+
The regular `Abacus` calculator runs one ABACUS calculation for each ASE property evaluation. ASE controls the relaxation, molecular-dynamics, and other workflow steps. The socket calculator reuses one ABACUS process for position updates, while the cell and electronic-structure settings remain fixed for that calculator instance.
37
41
38
42
## Authors
39
43
@@ -48,10 +52,10 @@ Thanks to the ABACUS development team for their support and contributions.
48
52
49
53
## License
50
54
51
-
[Fill in according to the actual project license]
55
+
The applicable license terms are provided in the repository [LICENSE](../../LICENSE).
52
56
53
57
## Contact
54
58
55
59
If you have any questions or suggestions, please contact us through:
0 commit comments