Skip to content

Commit 42b9cae

Browse files
committed
If a pdep network causes problems, improve logging for debugging.
If a pdep network is going to cause the job to crash with an InvalidMicrocanonicalRateError, then report a summary of the troublesome network and draw a PDF of it before crashing, to make it easier to figure out what's wrong.
1 parent 0410a56 commit 42b9cae

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

rmgpy/pdep/network.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ def set_conditions(self, T, P, ymB=None):
408408
logging.error("Increasing number of grains did not decrease error enough "
409409
"(Current badness: {0:.1f}, previous {1:.1f}). Something must be wrong with "
410410
"network {2}".format(badness, previous_error.badness(), self.label))
411+
self.log_summary()
411412
raise error
412413
previous_error = error
413414
success = False

rmgpy/rmg/pdep.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import rmgpy.reaction
4545
from rmgpy.constants import R
4646
from rmgpy.data.kinetics.library import LibraryReaction
47-
from rmgpy.exceptions import PressureDependenceError, NetworkError
47+
from rmgpy.exceptions import PressureDependenceError, NetworkError, InvalidMicrocanonicalRateError
4848
from rmgpy.pdep import Configuration
4949
from rmgpy.rmg.react import react_species
5050
from rmgpy.statmech import Conformer
@@ -876,7 +876,13 @@ def update(self, reaction_model, pdep_settings, requires_rms=False):
876876
# Calculate the rate coefficients
877877
self.initialize(Tmin, Tmax, Pmin, Pmax, maximum_grain_size, minimum_grain_count, active_j_rotor, active_k_rotor,
878878
rmgmode)
879-
K = self.calculate_rate_coefficients(Tlist, Plist, method)
879+
try:
880+
K = self.calculate_rate_coefficients(Tlist, Plist, method)
881+
except InvalidMicrocanonicalRateError:
882+
if output_directory:
883+
job.draw(output_directory, file_format='pdf')
884+
logging.info(f"Network {self.index} has been drawn and saved as a pdf in {output_directory}.")
885+
raise
880886

881887
# Generate PDepReaction objects
882888
configurations = []

0 commit comments

Comments
 (0)