eOn 3.2.0
Long-timescale dynamics: aKMC, NEB, parallel replica
☾
Toggle main menu visibility
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
27
class
SocketNWChemPot
:
public
eonc::Potential
{
28
public
:
29
explicit
SocketNWChemPot
(
const
eonc::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
; }
69
[[nodiscard]]
bool
needsPerImageInstance
() const noexcept
override
{
70
return
false
;
71
}
72
73
[[nodiscard]]
bool
computesStress
() const noexcept
override
{
74
return
haveStress_
;
75
}
76
77
[[nodiscard]]
Matrix3d
cauchyStress
()
const override
{
return
stress_
; }
78
79
private
:
80
// --- Private Methods ---
81
void
setup_server
();
82
void
accept_connection
();
83
void
drop_connection
();
84
void
forceOnce
(
long
N,
const
double
*R,
const
int
*atomicNrs,
double
*F,
85
double
*U,
double
*variance,
const
double
*box);
86
void
send_header
(
const
char
*msg);
87
void
recv_header
(
char
*buffer);
88
void
send_exact
(
const
void
*buffer,
size_t
n_bytes);
89
void
recv_exact
(
void
*buffer,
size_t
n_bytes);
90
91
// --- Member Variables ---
92
// Socket configuration
93
bool
unix_socket_mode
;
94
// For TCP, the host; for UNIX, the full socket path.
95
std::string
server_address
;
96
// The original name for the .nwi file.
97
std::string
unix_socket_basename
;
98
// File containing actual calculation parameters
99
std::string
nwchem_settings
;
100
int
port
,
mem_in_gb
;
101
// Generate a template input
102
bool
make_template_input
;
103
104
// Socket state
105
int
listen_fd
{-1};
106
int
conn_fd
{-1};
107
bool
is_connected
{
false
};
108
109
// --- Constants for i-PI protocol and unit conversions ---
110
static
constexpr
int
MSG_LEN
= 12;
111
// From ASE units, values for eV and Angstrom
112
static
constexpr
double
BOHR_IN_ANGSTROM
= 0.529177210903;
113
static
constexpr
double
HARTREE_IN_EV
= 27.211386245988;
114
115
Matrix3d
stress_
{Matrix3d::Zero()};
116
bool
haveStress_
{
false
};
117
};
Matrix3d
Eigen::Matrix< double, 3, 3, eOnStorageOrder > Matrix3d
Definition
Eigen.h:35
Potential.h
SocketNWChemPot::setup_server
void setup_server()
Definition
SocketNWChemPot.cpp:284
SocketNWChemPot::unix_socket_basename
std::string unix_socket_basename
Definition
SocketNWChemPot.h:97
SocketNWChemPot::~SocketNWChemPot
~SocketNWChemPot() override
Definition
SocketNWChemPot.cpp:58
SocketNWChemPot::MSG_LEN
static constexpr int MSG_LEN
Definition
SocketNWChemPot.h:110
SocketNWChemPot::computesStress
bool computesStress() const noexcept override
True when force() leaves a Cauchy stress that cauchyStress() can read until the next force() on this ...
Definition
SocketNWChemPot.h:73
SocketNWChemPot::isThreadSafe
bool isThreadSafe() const noexcept override
Whether this potential's force() can be called from multiple threads on the SAME instance.
Definition
SocketNWChemPot.h:66
SocketNWChemPot::send_header
void send_header(const char *msg)
Definition
SocketNWChemPot.cpp:360
SocketNWChemPot::recv_exact
void recv_exact(void *buffer, size_t n_bytes)
Definition
SocketNWChemPot.cpp:390
SocketNWChemPot::port
int port
Definition
SocketNWChemPot.h:100
SocketNWChemPot::is_connected
bool is_connected
Definition
SocketNWChemPot.h:107
SocketNWChemPot::send_exact
void send_exact(const void *buffer, size_t n_bytes)
Definition
SocketNWChemPot.cpp:377
SocketNWChemPot::server_address
std::string server_address
Definition
SocketNWChemPot.h:95
SocketNWChemPot::BOHR_IN_ANGSTROM
static constexpr double BOHR_IN_ANGSTROM
Definition
SocketNWChemPot.h:112
SocketNWChemPot::recv_header
void recv_header(char *buffer)
Definition
SocketNWChemPot.cpp:367
SocketNWChemPot::haveStress_
bool haveStress_
Definition
SocketNWChemPot.h:116
SocketNWChemPot::HARTREE_IN_EV
static constexpr double HARTREE_IN_EV
Definition
SocketNWChemPot.h:113
SocketNWChemPot::make_template_input
bool make_template_input
Definition
SocketNWChemPot.h:102
SocketNWChemPot::cauchyStress
Matrix3d cauchyStress() const override
Cauchy stress in eV/Angstrom^3.
Definition
SocketNWChemPot.h:77
SocketNWChemPot::stress_
Matrix3d stress_
Definition
SocketNWChemPot.h:115
SocketNWChemPot::conn_fd
int conn_fd
Definition
SocketNWChemPot.h:106
SocketNWChemPot::write_nwchem_template
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.
Definition
SocketNWChemPot.cpp:80
SocketNWChemPot::nwchem_settings
std::string nwchem_settings
Definition
SocketNWChemPot.h:99
SocketNWChemPot::unix_socket_mode
bool unix_socket_mode
Definition
SocketNWChemPot.h:93
SocketNWChemPot::listen_fd
int listen_fd
Definition
SocketNWChemPot.h:105
SocketNWChemPot::force
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.
Definition
SocketNWChemPot.cpp:115
SocketNWChemPot::drop_connection
void drop_connection()
Definition
SocketNWChemPot.cpp:352
SocketNWChemPot::accept_connection
void accept_connection()
Definition
SocketNWChemPot.cpp:343
SocketNWChemPot::needsPerImageInstance
bool needsPerImageInstance() const noexcept override
One listening socket and one NWChem client.
Definition
SocketNWChemPot.h:69
SocketNWChemPot::requiresIsolatedMoleculeLayout
bool requiresIsolatedMoleculeLayout() const noexcept override
NWChem socket SCF does not support PBC (#188).
Definition
SocketNWChemPot.h:63
SocketNWChemPot::SocketNWChemPot
SocketNWChemPot(const eonc::Parameters &p)
Definition
SocketNWChemPot.cpp:24
SocketNWChemPot::forceOnce
void forceOnce(long N, const double *R, const int *atomicNrs, double *F, double *U, double *variance, const double *box)
Definition
SocketNWChemPot.cpp:127
SocketNWChemPot::mem_in_gb
int mem_in_gb
Definition
SocketNWChemPot.h:100
eonc::Parameters
Definition
Parameters.h:35
eonc::Potential
Definition
Potential.h:42
include
eon
potentials
SocketNWChem
SocketNWChemPot.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf