namespace rgpot::ipi::detail¶
Overview¶
namespace detail {
// typedefs
typedef std::array<char, kHeaderLen> Header;
typedef std::chrono::steady_clock Clock;
// structs
struct Address;
struct Deadline;
struct Link;
// global variables
int kHeaderLen = 12;
int32_t kMaxAtoms = 10’000’000;
int32_t kMaxString = 1<<20;
const char* kUnixPrefix = “/tmp/ipi_”;
// global functions
Header header(std::string_view text);
bool sameHeader(const char* got, const Header& want);
std::string headerText(const char* got);
double cellVolume(const double* box);
void fail(const char* who, const std::string& message);
void failErrno(const char* who, const std::string& what);
void waitFd(const Link& link, short event, const Deadline& deadline, const char* what);
void writeFull(const Link& link, const void* data, size_t n, const Deadline& deadline);
void readFull(const Link& link, void* data, size_t n, const Deadline& deadline);
bool readFullOrEof(const Link& link, void* data, size_t n, const Deadline& deadline);
void setCloexec(int fd);
void setNonblock(int fd);
void disableSigpipe(int fd);
void setNodelay(int fd);
Address parseAddress(const std::string& address, const char* who, const std::string& unix_prefix);
void rowsToIpiCell(const double* box_angstrom, double h[9], double ih[9], const char* who);
void ipiCellToRows(const double h[9], double box_angstrom[9]);
} // namespace detail
Detailed Documentation¶
Global Functions¶
Header header(std::string_view text)
Space-padded header; text longer than 12 bytes is cut.
std::string headerText(const char* got)
Printable form of a received header, trailing spaces removed.
double cellVolume(const double* box)
Absolute volume of a row-major 3x3 cell. A null or singular cell is 0.
Waits for event (POLLIN or POLLOUT). Throws “timed out <what>” or “<peer> disconnected”.
readFull, except that a peer that closes before the first byte returns false instead of throwing.
Address parseAddress(const std::string& address, const char* who, const std::string& unix_prefix)
Throws std::invalid_argument, prefixed with who.
void rowsToIpiCell(const double* box_angstrom, double h[9], double ih[9], const char* who)
rgpot cell (lattice vectors in rows, Angstrom) to the i-PI cell (vectors in columns, bohr) and its inverse. Throws std::invalid_argument for a singular cell.
void ipiCellToRows(const double h[9], double box_angstrom[9])
i-PI cell (vectors in columns, bohr) to rgpot rows in Angstrom.