Scine::Sparrow  5.0.0
Library for fast and agile quantum chemical calculations with semiempirical methods.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
CalculationHandler.h
Go to the documentation of this file.
1 
7 #ifndef SPARROW_CALCULATIONHANDLER_H
8 #define SPARROW_CALCULATIONHANDLER_H
9 
10 #include <Core/Interfaces/CalculatorWithReference.h>
12 #include <exception>
13 #include <memory>
14 #include <ostream>
15 
16 namespace Scine {
17 namespace Utils {
18 class Settings;
19 } // namespace Utils
20 
21 namespace Core {
22 class Calculator;
23 } // namespace Core
24 namespace Sparrow {
25 
26 class CommandLineOptions;
27 
31 class MethodNotAvailableException : public std::exception {
32  public:
33  explicit MethodNotAvailableException(std::string methodName)
34  : methodName_("Method " + std::move(methodName) + " is not available.\n" + "\nSparrow flies away...") {
35  }
36 
37  const char* what() const noexcept final {
38  return methodName_.c_str();
39  }
40 
41  private:
42  std::string methodName_;
43 };
44 
45 struct FileInaccessibleException final : public std::exception {
46  public:
47  explicit FileInaccessibleException(std::string fileName)
48  : description_("File " + std::move(fileName) + " non accessible.") {
49  }
50  const char* what() const noexcept final {
51  return description_.c_str();
52  }
53 
54  private:
55  std::string description_;
56 };
62  public:
64  CalculationHandler() = delete;
73  void calculate(std::ostream& out);
74 
75  private:
76  bool isNDDO() const;
77  bool isDFTB() const;
78  void assignPropertiesToCalculate();
79  void assignSettings();
80  void printCalculationConverged(std::ostream& out);
81  void printSettings(std::ostream& out, const Utils::Settings& settings, const std::string& commentChar = "") const;
82  void printHeader(std::ostream& out, const std::string& commenChar = "") const;
83  void printFooter(std::ostream& out) const;
84  void printTime(std::ostream& out) const;
85  void printResultsToFile() const;
86  void printPrettyResults(std::ostream& out) const;
87  void printFrequencyAnalysis(std::ostream& out, const Utils::HessianMatrix& matrix) const;
88  void printExcitedStates(std::ostream& out, const Utils::SpinAdaptedElectronicTransitionResult& matrix) const;
89  void printWavefunction() const;
90  CommandLineOptions& commandLineOptions_;
91  std::shared_ptr<Core::Calculator> methodWrapper_;
92  std::shared_ptr<Core::CalculatorWithReference> excitedStatesCalculator_;
93  std::shared_ptr<Core::CalculatorWithReference> orbitalSteerer_;
94  Utils::Results results_, excitedStatesResults_;
95  mutable double groundStateTime_{0.}, hessianDiagTime_{0.}, excitedStateTime_{0.};
96 };
97 
98 } // namespace Sparrow
99 } // namespace Scine
100 
101 #endif // SPARROW_CALCULATIONHANDLER_H
Exception thrown if a non available method is requested.
Definition: CalculationHandler.h:31
void calculate(std::ostream &out)
start a calculation with the options and description read by the command line.
Definition: CalculationHandler.cpp:202
Definition: CalculationHandler.h:45
Class to parse the command line options for non-default options and passes them to a Util::Settings c...
Definition: CommandLineOptions.h:26
Class handling the main calculation routines.
Definition: CalculationHandler.h:61
CalculationHandler()=delete
deleted default constructor;