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
ElementPairParameters.h
Go to the documentation of this file.
1 
8 #ifndef SPARROW_ELEMENTPAIRPARAMETERS_H
9 #define SPARROW_ELEMENTPAIRPARAMETERS_H
10 
11 #include "PM6DiatomicParameters.h"
15 #include <algorithm>
16 #include <array>
17 #include <cassert>
18 #include <memory>
19 
20 namespace Scine {
21 namespace Sparrow {
22 
23 namespace nddo {
24 
30  public:
31  using PM6DiatomicParametersPtr = std::unique_ptr<PM6DiatomicParameters>;
32  using ParameterContainer = std::array<PM6DiatomicParametersPtr, 110>;
33  using PPContainer = std::array<ParameterContainer, 110>;
34 
36  void clear() {
37  parameters_ = PPContainer{};
38  }
39 
40  bool isSet(Utils::ElementType e1, Utils::ElementType e2) const {
41  unsigned z1, z2;
42  std::tie(z1, z2) = std::minmax(Utils::ElementInfo::Z(e1), Utils::ElementInfo::Z(e2));
43  return parameters_[z2][z1] != nullptr;
44  }
45  void set(Utils::ElementType e1, Utils::ElementType e2, std::unique_ptr<PM6DiatomicParameters>&& parameters) {
46  unsigned z1, z2;
47  std::tie(z1, z2) = std::minmax(Utils::ElementInfo::Z(e1), Utils::ElementInfo::Z(e2));
48  parameters_[z2][z1] = std::move(parameters);
49  }
50  const PM6DiatomicParameters& get(Utils::ElementType e1, Utils::ElementType e2) const {
51  if (isSet(e1, e2)) {
52  unsigned z1, z2;
53  std::tie(z1, z2) = std::minmax(Utils::ElementInfo::Z(e1), Utils::ElementInfo::Z(e2));
54  return *parameters_[z2][z1];
55  }
56  throw Utils::Methods::ParametersDoNotExistForElementPairException(e1, e2);
57  }
58 
59  private:
60  PPContainer parameters_;
61 };
62 
63 } // namespace nddo
64 
65 } // namespace Sparrow
66 } // namespace Scine
67 #endif // SPARROW_ELEMENTPAIRPARAMETERS_H
Definition: ElementPairParameters.h:29
static constexpr unsigned Z(const ElementType e) noexcept
void clear()
Definition: ElementPairParameters.h:36