forked from ReactionMechanismGenerator/RMG-Py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexceptions.py
355 lines (273 loc) · 10.5 KB
/
exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
#!/usr/bin/env python3
###############################################################################
# #
# RMG - Reaction Mechanism Generator #
# #
# Copyright (c) 2002-2020 Prof. William H. Green ([email protected]), #
# Prof. Richard H. West ([email protected]) and the RMG Team ([email protected]) #
# #
# Permission is hereby granted, free of charge, to any person obtaining a #
# copy of this software and associated documentation files (the 'Software'), #
# to deal in the Software without restriction, including without limitation #
# the rights to use, copy, modify, merge, publish, distribute, sublicense, #
# and/or sell copies of the Software, and to permit persons to whom the #
# Software is furnished to do so, subject to the following conditions: #
# #
# The above copyright notice and this permission notice shall be included in #
# all copies or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE #
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
# DEALINGS IN THE SOFTWARE. #
# #
###############################################################################
"""
This module contains classes which extend Exception for usage in the RMG module
"""
class ActionError(Exception):
"""
An exception class for errors that occur while applying reaction recipe
actions. Pass a string describing the circumstances that caused the
exceptional behavior.
"""
pass
class AtomTypeError(Exception):
"""
An exception to be raised when an error occurs while working with atom
types. Pass a string describing the circumstances that caused the
exceptional behavior.
"""
pass
class ChemicallySignificantEigenvaluesError(Exception):
"""
An exception raised when the chemically significant eigenvalue method is
unsuccessful for any reason.
Pass a string describing the cause of the exceptional behavior.
"""
pass
class ChemkinError(Exception):
"""
An exception class for exceptional behavior involving Chemkin files. Pass a
string describing the circumstances that caused the exceptional behavior.
"""
pass
class CollisionError(Exception):
"""
An exception class for when RMG is unable to calculate collision efficiencies
for the single exponential down pressure dependent solver.
Pass a string describing the circumstances that caused the exceptional behavior.
"""
pass
class DatabaseError(Exception):
"""
A exception that occurs when working with an RMG database. Pass a string
giving specifics about the exceptional behavior.
"""
pass
class DependencyError(Exception):
"""
An exception that occurs when an error is encountered with a dependency.
Pass a string describing the circumstances that caused the exception.
"""
pass
class ElementError(Exception):
"""
An exception class for errors that occur while working with elements.
Pass a string describing the circumstances that caused the
exceptional behavior.
"""
pass
class ForbiddenStructureException(Exception):
"""
An exception passed when RMG encounters a forbidden structure. These are usually
caught and the reaction that created it is ignored.
"""
pass
class ILPSolutionError(Exception):
"""
An exception to be raised when solving an integer linear programming problem if a solution
could not be found or the solution is not valid. Can pass a string to indicate the reason
that the solution is invalid.
"""
pass
class ImplicitBenzeneError(Exception):
"""
An exception class when encountering a group with too many implicit benzene
atoms. These groups are hard to create sample molecules and hard for users
to interpret. Pass a string describing the limitation.
"""
pass
class InchiException(Exception):
"""
An exception used when encountering a non-valid Inchi expression are encountered.
Pass a string describing the error.
"""
pass
class InputError(Exception):
"""
An exception raised when parsing an input file for any module in RMG:
mechanism generation, Arkane, conformer creation, etc.
Pass a string describing the error.
"""
pass
class InvalidActionError(Exception):
"""
An exception to be raised when an invalid action is encountered in a
reaction recipe.
"""
pass
class InvalidAdjacencyListError(Exception):
"""
An exception used to indicate that an RMG-style adjacency list is invalid.
Pass a string describing the reason the adjacency list is invalid
"""
pass
class KekulizationError(Exception):
"""
An exception to be raised when encountering an error while kekulizing an aromatic molecule.
Can pass a string to indicate the reason for failure.
"""
pass
class KineticsError(Exception):
"""
An exception class for problems with kinetics. This can be used when finding
degeneracy in reaction generation, modifying KineticsData objects, or finding the
kinetics of reactions. Unable Pass a string describing the problem.
"""
pass
class ModifiedStrongCollisionError(Exception):
"""
An exception raised when the modified strong collision method is unsuccessful
for any reason. Pass a string describing the cause of the exceptional
behavior.
"""
pass
class NegativeBarrierException(Exception):
""" This Exception occurs when the energy barrier for a hindered Rotor is negative.
This can occur if the scan or fourier fit is poor. """
pass
class NetworkError(Exception):
"""
Raised when an error occurs while working with a pressure-dependent reaction network
"""
pass
class OutputError(Exception):
"""
This exception is raised whenever an error occurs while saving output
information. Pass a string describing the circumstances of the exceptional
behavior.
"""
pass
class PressureDependenceError(Exception):
"""
An exception class to use when an error involving pressure dependence is
encountered. Pass a string describing the circumstances of the exceptional
behavior.
"""
pass
class QuantityError(Exception):
"""
An exception to be raised when an error occurs while working with physical
quantities in RMG. Pass a string describing the circumstances of the
exceptional behavior.
"""
pass
class ReactionError(Exception):
"""
An exception class for exceptional behavior involving :class:`Reaction`
objects. Pass a string describing the circumstances that caused the
exceptional behavior.
"""
pass
class ReactionPairsError(Exception):
"""
An exception to be raised when an error occurs while working with reaction
pairs.
"""
pass
class ReservoirStateError(Exception):
"""
An exception raised when the reservoir state method is unsuccessful for
any reason. Pass a string describing the cause of the exceptional behavior.
"""
pass
class SettingsError(Exception):
"""
An exception raised when dealing with settings.
"""
pass
class SpeciesError(Exception):
"""
An exception class for exceptional behavior that occurs while working with
chemical species. Pass a string describing the circumstances that caused the
exceptional behavior.
"""
pass
class StatmechError(Exception):
"""
An exception used when an error occurs in estimating Statmech.
"""
class StatmechFitError(StatmechError):
"""
An exception used when attempting to fit molecular degrees of freedom to
heat capacity data. Pass a string describing the circumstances of the
exceptional behavior.
"""
pass
class UnexpectedChargeError(Exception):
"""
An exception class when encountering a group/molecule with unexpected charge
Curently in RMG, we never expect to see -2/+2 or greater magnitude charge,
we only except +1/-1 charges on nitrogen, oxygen, sulfur or specifically
carbon monoxide/monosulfide.
Attributes:
`graph` is the molecule or group object with the unexpected charge
"""
def __init__(self, graph):
self.graph = graph
class VF2Error(Exception):
"""
An exception raised if an error occurs within the VF2 graph isomorphism
algorithm. Pass a string describing the error.
"""
pass
class CoreError(Exception):
"""
An exception raised if there is a problem within the model core
"""
pass
class ResonanceError(Exception):
"""
An exception class for when RMG is unable to generate resonance structures.
"""
pass
################################################################################
# move classes that extend off previous exceptions here
class InvalidMicrocanonicalRateError(NetworkError):
"""
Used in pressure dependence when the k(E) calculation does not give
the correct kf(T) or Kc(T)
"""
def __init__(self, message, k_ratio=1.0, Keq_ratio=1.0):
self.message = message
self.k_ratio = k_ratio
self.Keq_ratio = Keq_ratio
def badness(self):
"""
How bad is the error?
Returns the max of the absolute logarithmic errors of kf and Kc
"""
import math
return max(abs(math.log10(self.k_ratio)), abs(math.log10(self.Keq_ratio)))
class UndeterminableKineticsError(ReactionError):
"""
An exception raised when attempts to estimate appropriate kinetic parameters
for a chemical reaction are unsuccessful.
"""
def __init__(self, reaction, message=''):
new_message = 'Kinetics could not be determined. ' + message
ReactionError.__init__(self, reaction, new_message)