A potential that gets forces and energy from an NWChem server via a socket. More...
#include <SocketNWChemPot.h>
Public Member Functions | |
| SocketNWChemPot (const Parameters &p) | |
| ~SocketNWChemPot () override | |
| void | write_nwchem_template (const std::string &filename, long N, const std::vector< std::string > &atom_symbols) |
| Generates an NWChem input file (.nwi) configured to connect to this server. | |
| void | force (long N, const double *R, const int *atomicNrs, double *F, double *U, double *variance, const double *box) override |
| The method called to compute forces and energy. | |
| bool | requiresIsolatedMoleculeLayout () const noexcept override |
| NWChem socket SCF does not support PBC (#188). | |
| bool | isThreadSafe () const noexcept override |
| Whether this potential's force() can be called from multiple threads on the SAME instance. | |
| Public Member Functions inherited from eonc::Potential | |
| Potential (PotType a_ptype) | |
| Potential (PotType a_ptype, const Parameters &) | |
| Potential (const Parameters &a_params) | |
| virtual | ~Potential () |
| std::tuple< double, AtomMatrix > | get_ef (const AtomMatrix &pos, const VectorXi &atmnrs, const Matrix3d &box) |
| PotType | getType () const |
| virtual bool | isSurrogate () const noexcept |
| Whether this is a surrogate (GP) potential. | |
| virtual bool | isSharedInstanceThreadSafe () const noexcept |
| Conservative gate for sharing one Potential instance across threads. | |
| virtual bool | needsPerImageInstance () const noexcept |
| Whether NEB should create separate Potential instances per image for true parallel force evaluation. | |
| virtual bool | supportsBatchEvaluation () const noexcept |
| Whether this potential supports batched evaluation of N systems in a single call. | |
| virtual void | forceBatch (long nSystems, long nAtoms, const double *const *positions, const int *const *atomicNrs, double *const *forces, double *energies, double *variances, const double *const *boxes) |
| Evaluate forces for N systems in a single call. | |
Private Member Functions | |
| void | setup_server () |
| void | accept_connection () |
| void | send_header (const char *msg) |
| void | recv_header (char *buffer) |
| void | send_exact (const void *buffer, size_t n_bytes) |
| void | recv_exact (void *buffer, size_t n_bytes) |
Private Attributes | |
| bool | unix_socket_mode |
| std::string | server_address |
| std::string | unix_socket_basename |
| std::string | nwchem_settings |
| int | port |
| int | mem_in_gb |
| bool | make_template_input |
| int | listen_fd |
| int | conn_fd |
| bool | is_connected |
Static Private Attributes | |
| static constexpr int | MSG_LEN = 12 |
| static constexpr double | BOHR_IN_ANGSTROM = 0.529177210903 |
| static constexpr double | HARTREE_IN_EV = 27.211386245988 |
Additional Inherited Members | |
| Public Attributes inherited from eonc::Potential | |
| std::atomic< size_t > | forceCallCounter |
| Protected Attributes inherited from eonc::Potential | |
| PotType | ptype |
A potential that gets forces and energy from an NWChem server via a socket.
Implements the i-PI socket protocol to communicate with an NWChem executable that has been launched in server mode (e.g., using task scf optimize and the driver socket directive). This class manages a persistent connection to NWChem. Supports both TCP/IP and UNIX domain sockets.
Definition at line 27 of file SocketNWChemPot.h.
|
explicit |
Definition at line 32 of file SocketNWChemPot.cpp.
|
override |
Definition at line 74 of file SocketNWChemPot.cpp.
|
private |
Definition at line 295 of file SocketNWChemPot.cpp.
|
overridevirtual |
The method called to compute forces and energy.
This method implements the full i-PI handshake for a single geometry:
| N | The number of atoms. |
| R | Pointer to the beginning of the position array [x1, y1, z1, ...]. |
| atomicNrs | Pointer to the array of atomic numbers. |
| F | Pointer to the beginning of the force array to be populated. |
| U | Pointer to the potential energy value to be set. |
| variance | Not used by this potential. |
| box | Pointer to the 3x3 simulation box matrix. |
Implements eonc::Potential.
Definition at line 131 of file SocketNWChemPot.cpp.
|
inlinenodiscardoverridevirtualnoexcept |
Whether this potential's force() can be called from multiple threads on the SAME instance.
Python-based potentials return false. Potentials with internal mutex (MetatomicPotential) return true but serialize internally – use needsPerImageInstance() to check if separate instances would enable true parallelism.
Reimplemented from eonc::Potential.
Definition at line 66 of file SocketNWChemPot.h.
|
private |
Definition at line 331 of file SocketNWChemPot.cpp.
|
private |
Definition at line 310 of file SocketNWChemPot.cpp.
|
inlinenodiscardoverridevirtualnoexcept |
NWChem socket SCF does not support PBC (#188).
Reimplemented from eonc::Potential.
Definition at line 63 of file SocketNWChemPot.h.
|
private |
Definition at line 319 of file SocketNWChemPot.cpp.
|
private |
Definition at line 304 of file SocketNWChemPot.cpp.
|
private |
Definition at line 254 of file SocketNWChemPot.cpp.
| void SocketNWChemPot::write_nwchem_template | ( | const std::string & | filename, |
| long | N, | ||
| const std::vector< std::string > & | atom_symbols ) |
Generates an NWChem input file (.nwi) configured to connect to this server.
| filename | The path to the output file (e.g., "nwchem_socket.nwi"). |
| N | The number of atoms. |
| atom_symbols | A vector of atom symbols (e.g., {"O", "H", "H"}). |
Definition at line 96 of file SocketNWChemPot.cpp.
|
staticconstexprprivate |
Definition at line 98 of file SocketNWChemPot.h.
|
private |
Definition at line 92 of file SocketNWChemPot.h.
|
staticconstexprprivate |
Definition at line 99 of file SocketNWChemPot.h.
|
private |
Definition at line 93 of file SocketNWChemPot.h.
|
private |
Definition at line 91 of file SocketNWChemPot.h.
|
private |
Definition at line 88 of file SocketNWChemPot.h.
|
private |
Definition at line 86 of file SocketNWChemPot.h.
|
staticconstexprprivate |
Definition at line 96 of file SocketNWChemPot.h.
|
private |
Definition at line 85 of file SocketNWChemPot.h.
|
private |
Definition at line 86 of file SocketNWChemPot.h.
|
private |
Definition at line 81 of file SocketNWChemPot.h.
|
private |
Definition at line 83 of file SocketNWChemPot.h.
|
private |
Definition at line 79 of file SocketNWChemPot.h.