Loading...
Searching...
No Matches
HelperFunctions.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#include "Eigen.h"
14#include "GeometryAnalysis.h"
15#include "Matter.h"
16#include "RandomNumbers.h"
17#include <optional>
18#include <string>
19#include <string_view>
20#include <vector>
21
22namespace eonc {
23
24/* Collection of supporting functions that handle arrays of doubles as vectors
25 * and different random number generators */
26namespace helpers {
27
28inline constexpr double pi = 3.14159265358979323846;
29
30// Backward-compatible wrappers delegating to eonc::rng
35
36// Backward-compatible wrappers delegating to eonc::geometry
52
54 const AtomMatrix v1,
55 const AtomMatrix v2); // return orthogonal component of v1 from v2
56bool relaxMatter(Matter &matter, const Parameters &params, bool quiet = false,
57 bool writeMovie = false, bool checkpoint = false,
58 std::string prefixMovie = std::string(),
59 std::string prefixCheckpoint = std::string(),
60 std::vector<readcon::ConFrame> *outFrames = nullptr);
61void getTime(double *real, double *user, double *sys);
62bool existsFile(std::string filename); // does filename exist
63std::string
64getRelevantFile(std::string filename); // return filename containing _checkpoint
65 // or _passed if such a file exists
66VectorXd loadMasses(std::string filename, int nAtoms);
67AtomMatrix loadMode(FILE *modeFile, int nAtoms);
68AtomMatrix loadMode(std::string filename, int nAtoms);
69// Load displacement.con, or synthesize initial + scale * unit(direction.dat)
70// (issue #79). scale is saddle_search.displace_magnitude (default 0.1).
71// Fixed-atom rows are always restored from initial. Returns false if neither
72// displacement nor mode file is usable, or mode has zero norm when
73// synthesizing.
74bool loadOrSynthesizeDisplacement(Matter &target, const Matter &initial,
75 const std::string &displacementPath,
76 const std::string &modePath, double scale);
78void saveMode(FILE *modeFile, std::shared_ptr<Matter> matter, AtomMatrix mode);
79void saveMode(const std::string &filename, std::shared_ptr<Matter> matter,
80 AtomMatrix mode);
81std::vector<int> split_string_int(std::string s, std::string delim);
82
87std::optional<std::string_view> convergenceMetricLabel(std::string_view metric);
91void requireKnownConvergenceMetric(std::string_view metric,
92 std::string_view context);
93
94} // namespace helpers
95
96} // namespace eonc
Eigen::Matrix< double, Eigen::Dynamic, 3, eOnStorageOrder > AtomMatrix
Definition Eigen.h:37
RotationMatrix rotationExtract(const AtomMatrix r1, const AtomMatrix r2)
AtomMatrix maxAtomMotionApplied(const AtomMatrix v1, double maxMotion)
long numAtomsMoved(const AtomMatrix v1, double cutoff)
double maxAtomMotion(const AtomMatrix v1)
void pushApart(std::shared_ptr< Matter > m1, double minDistance)
bool rotationMatch(const Matter &m1, const Matter &m2, const double max_diff)
VectorXd maxMotionAppliedV(const VectorXd v1, double maxMotion)
void projectOutRotTrans(Eigen::VectorXd &step, const AtomMatrix &positions)
bool identical(const Matter &m1, const Matter &m2, const double distanceDifference)
VectorXd maxAtomMotionAppliedV(const VectorXd v1, double maxMotion)
double maxAtomMotionV(const VectorXd v1)
bool sortedR(const Matter &m1, const Matter &m2, const double distanceDifference)
void rotationRemove(const AtomMatrix r1, std::shared_ptr< Matter > m2)
AtomMatrix maxMotionApplied(const AtomMatrix v1, double maxMotion)
void translationRemove(Matter &m1, const AtomMatrix r1)
VectorXd loadMasses(std::string filename, int nAtoms)
bool relaxMatter(Matter &matter, const Parameters &params, bool quiet=false, bool writeMovie=false, bool checkpoint=false, std::string prefixMovie=std::string(), std::string prefixCheckpoint=std::string(), std::vector< readcon::ConFrame > *outFrames=nullptr)
bool loadOrSynthesizeDisplacement(Matter &target, const Matter &initial, const std::string &displacementPath, const std::string &modePath, double scale)
AtomMatrix loadMode(FILE *modeFile, int nAtoms)
std::string getRelevantFile(std::string filename)
void saveMode(FILE *modeFile, std::shared_ptr< Matter > matter, AtomMatrix mode)
Write a mode; constrained axes are emitted as 0.
std::optional< std::string_view > convergenceMetricLabel(std::string_view metric)
Display label for a force-convergence metric, or nullopt when the name is none of the three the optim...
constexpr double pi
std::vector< int > split_string_int(std::string s, std::string delim)
void requireKnownConvergenceMetric(std::string_view metric, std::string_view context)
Throws std::invalid_argument naming context when metric is unrecognized.
void getTime(double *real, double *user, double *sys)
AtomMatrix makeOrthogonal(const AtomMatrix v1, const AtomMatrix v2)
bool existsFile(std::string filename)
double random(long newSeed=0)
long randomInt(int lower, int upper)
double randomDouble()
double gaussRandom(double avg, double std)
RAII resource manager for the ARTn C library with global synchronization.