Loading...
Searching...
No Matches
SocketNWChemPot.h
Go to the documentation of this file.
1/*
2** This file is part of eOn.
3**
4** SPDX-License-Identifier: BSD-3-Clause
5**
6** Copyright (c) 2010--present, eOn Development Team
7** All rights reserved.
8**
9** Repo:
10** https://github.com/TheochemUI/eOn
11*/
12#pragma once
13
14#include "eon/Potential.h"
15#include <memory>
16#include <string>
17
27class SocketNWChemPot : public Potential {
28public:
29 explicit SocketNWChemPot(const Parameters &p);
30 ~SocketNWChemPot() override;
31
39 void write_nwchem_template(const std::string &filename, long N,
40 const std::vector<std::string> &atom_symbols);
41
59 void force(long N, const double *R, const int *atomicNrs, double *F,
60 double *U, double *variance, const double *box) override;
61
63 [[nodiscard]] bool requiresIsolatedMoleculeLayout() const noexcept override {
64 return true;
65 }
66 [[nodiscard]] bool isThreadSafe() const noexcept override { return false; }
67
68private:
69 // --- Private Methods ---
70 void setup_server();
71 void accept_connection();
72 void send_header(const char *msg);
73 void recv_header(char *buffer);
74 void send_exact(const void *buffer, size_t n_bytes);
75 void recv_exact(void *buffer, size_t n_bytes);
76
77 // --- Member Variables ---
78 // Socket configuration
80 // For TCP, the host; for UNIX, the full socket path.
81 std::string server_address;
82 // The original name for the .nwi file.
84 // File containing actual calculation parameters
85 std::string nwchem_settings;
87 // Generate a template input
89
90 // Socket state
91 int listen_fd; // Socket for listening
92 int conn_fd; // Socket for the active connection
94
95 // --- Constants for i-PI protocol and unit conversions ---
96 static constexpr int MSG_LEN = 12;
97 // From ASE units, values for eV and Angstrom
98 static constexpr double BOHR_IN_ANGSTROM = 0.529177210903;
99 static constexpr double HARTREE_IN_EV = 27.211386245988;
100};
std::string unix_socket_basename
~SocketNWChemPot() override
static constexpr int MSG_LEN
bool isThreadSafe() const noexcept override
Whether this potential's force() can be called from multiple threads on the SAME instance.
void send_header(const char *msg)
void recv_exact(void *buffer, size_t n_bytes)
void send_exact(const void *buffer, size_t n_bytes)
std::string server_address
static constexpr double BOHR_IN_ANGSTROM
void recv_header(char *buffer)
static constexpr double HARTREE_IN_EV
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.
std::string nwchem_settings
SocketNWChemPot(const Parameters &p)
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).
Potential(PotType a_ptype)
Definition Potential.h:35