votca 2026-dev
Loading...
Searching...
No Matches
extended_hueckel.cc
Go to the documentation of this file.
1/*
2 * Copyright 2009-2026 The VOTCA Development Team
3 * (http://www.votca.org)
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License")
6 *
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
21
22namespace votca {
23namespace xtp {
24
25namespace {
26constexpr double ev_to_ha = 0.03674932217565499;
27}
28
30 auto add = [&](const std::string& el, int l, double ev) {
31 eps_[{el, l}] = ev * ev_to_ha;
32 };
33
34 // H
35 add("H", 0, -13.60);
36
37 // Second row
38 add("B", 0, -15.20);
39 add("B", 1, -8.50);
40
41 add("C", 0, -21.40);
42 add("C", 1, -11.40);
43
44 add("N", 0, -26.00);
45 add("N", 1, -13.40);
46
47 add("O", 0, -32.30);
48 add("O", 1, -14.80);
49
50 add("F", 0, -40.00);
51 add("F", 1, -18.10);
52
53 // Third row
54 add("Al", 0, -12.30);
55 add("Al", 1, -6.50);
56
57 add("Si", 0, -17.30);
58 add("Si", 1, -9.20);
59
60 add("P", 0, -18.60);
61 add("P", 1, -10.70);
62 add("P", 2, -14.00);
63
64 add("S", 0, -20.00);
65 add("S", 1, -11.00);
66 add("S", 2, -14.20);
67
68 add("Cl", 0, -30.00);
69 add("Cl", 1, -15.00);
70 add("Cl", 2, -18.00);
71
72 // Halogens often relevant in XTP
73 add("Br", 0, -28.00);
74 add("Br", 1, -14.00);
75 add("Br", 2, -16.00);
76
77 add("I", 0, -25.00);
78 add("I", 1, -12.00);
79 add("I", 2, -14.00);
80
81 // Optional: common heavier main-group
82 add("Ga", 0, -12.10);
83 add("Ga", 1, -6.70);
84
85 add("Ge", 0, -16.00);
86 add("Ge", 1, -8.90);
87
88 add("As", 0, -18.90);
89 add("As", 1, -11.00);
90 add("As", 2, -14.50);
91
92 add("Se", 0, -20.80);
93 add("Se", 1, -12.00);
94 add("Se", 2, -14.80);
95}
96
97bool ExtendedHuckelParameters::Has(const std::string& element, int l) const {
98 return eps_.find({element, l}) != eps_.end();
99}
100
101bool ExtendedHuckelParameters::HasElement(const std::string& element) const {
102 for (const auto& kv : eps_) {
103 if (kv.first.first == element) {
104 return true;
105 }
106 }
107 return false;
108}
109
110double ExtendedHuckelParameters::Get(const std::string& element, int l) const {
111 auto it = eps_.find({element, l});
112 if (it == eps_.end()) {
113 throw std::runtime_error("No exact EHT parameter for element " + element +
114 " and l=" + std::to_string(l));
115 }
116 return it->second;
117}
118
119double ExtendedHuckelParameters::GetWithFallback(const std::string& element,
120 int l, int* used_l) const {
121 // 1. Exact match
122 auto exact = eps_.find({element, l});
123 if (exact != eps_.end()) {
124 if (used_l != nullptr) {
125 *used_l = l;
126 }
127 return exact->second;
128 }
129
130 // 2. Element missing entirely
131 if (!HasElement(element)) {
132 throw std::runtime_error("No EHT parameters available for element " +
133 element);
134 }
135
136 // 3. Fallback logic
137 // For higher-l shells: prefer d, then p, then s
138 if (l >= 2) {
139 if (Has(element, 2)) {
140 if (used_l != nullptr) {
141 *used_l = 2;
142 }
143 return Get(element, 2);
144 }
145 if (Has(element, 1)) {
146 if (used_l != nullptr) {
147 *used_l = 1;
148 }
149 return Get(element, 1);
150 }
151 if (Has(element, 0)) {
152 if (used_l != nullptr) {
153 *used_l = 0;
154 }
155 return Get(element, 0);
156 }
157 }
158
159 // For p shells: fall back to s
160 if (l == 1) {
161 if (Has(element, 0)) {
162 if (used_l != nullptr) {
163 *used_l = 0;
164 }
165 return Get(element, 0);
166 }
167 }
168
169 // For completeness: if some weird lower-l case comes in
170 // choose the highest available shell on that element
171 for (int ll = 6; ll >= 0; --ll) {
172 if (Has(element, ll)) {
173 if (used_l != nullptr) {
174 *used_l = ll;
175 }
176 return Get(element, ll);
177 }
178 }
179
180 throw std::runtime_error("No usable EHT fallback parameter for element " +
181 element + " and l=" + std::to_string(l));
182}
183
184} // namespace xtp
185} // namespace votca
double Get(const std::string &element, int l) const
std::map< std::pair< std::string, int >, double > eps_
double GetWithFallback(const std::string &element, int l, int *used_l=nullptr) const
bool HasElement(const std::string &element) const
bool Has(const std::string &element, int l) const
Charge transport classes.
Definition ERIs.h:28
Provides a means for comparing floating point numbers.
Definition basebead.h:33