Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvements to pdep logging #1765

Merged
merged 1 commit into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions rmgpy/pdep/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ def set_conditions(self, T, P, ymB=None):
# Update parameters that depend on temperature and pressure if necessary
if temperature_changed or pressure_changed:
self.calculate_collision_model()
logging.debug('Finished setting conditions for network {0}.'.format(self.label))
logging.debug('The network now has values of {0}'.format(repr(self)))
logging.debug('Finished setting conditions for network %s.', self.label)
logging.debug('The network now has values of %r', self)

def _get_energy_grains(self, Emin, Emax, grain_size=0.0, grain_count=0):
"""
Expand Down Expand Up @@ -781,17 +781,18 @@ def calculate_microcanonical_rates(self):
# If the k(E) values are invalid (in that they give the wrong
# kf(T) or kr(T) when integrated), then raise an exception
if error or warning:
logging.warning('For path reaction {0!s}:'.format(rxn))
logging.warning(' Expected kf({0:g} K) = {1:g}'.format(temperature, kf_expected))
logging.warning(' Actual kf({0:g} K) = {1:g}'.format(temperature, kf_actual))
logging.warning(' Expected Keq({0:g} K) = {1:g}'.format(temperature, Keq_expected))
logging.warning(' Actual Keq({0:g} K) = {1:g}'.format(temperature, Keq_actual))
level = logging.WARNING if error else logging.DEBUG
logging.log(level, 'For path reaction %s:', rxn)
logging.log(level, ' Expected kf(%g K) = %g', temperature, kf_expected)
logging.log(level, ' Actual kf(%g K) = %g', temperature, kf_actual)
logging.log(level, ' Expected Keq(%g K) = %g', temperature, Keq_expected)
logging.log(level, ' Actual Keq(%g K) = %g', temperature, Keq_actual)
if error:
raise InvalidMicrocanonicalRateError(
'Invalid k(E) values computed for path reaction "{0}".'.format(rxn), k_ratio, Keq_ratio)
else:
logging.warning('Significant corrections to k(E) to be consistent with high-pressure limit for '
'path reaction "{0}".'.format(rxn))
'path reaction "%s".', rxn)

# import pylab
# for prod in range(n_isom):
Expand Down
22 changes: 11 additions & 11 deletions rmgpy/pdep/reaction.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def calculate_microcanonical_rate_coefficient(reaction,

# We've been provided with molecular degree of freedom data for the
# transition state, so let's use the more accurate RRKM theory
logging.debug('Calculating microcanonical rate coefficient using RRKM theory for {0}...'.format(reaction))
logging.debug('Calculating microcanonical rate coefficient using RRKM theory for %s...', reaction)
if reactant_states_known and (reaction.is_isomerization() or reaction.is_dissociation()):
kf = apply_rrkm_theory(reaction.transition_state, e_list, j_list, reac_dens_states)
kf *= c0_inv ** (len(reaction.reactants) - 1)
Expand All @@ -121,7 +121,7 @@ def calculate_microcanonical_rate_coefficient(reaction,
elif reaction.kinetics is not None:
# We've been provided with high-pressure-limit rate coefficient data,
# so let's use the less accurate inverse Laplace transform method
logging.debug('Calculating microcanonical rate coefficient using ILT method for {0}...'.format(reaction))
logging.debug('Calculating microcanonical rate coefficient using ILT method for %s...', reaction)
if reactant_states_known:
kinetics = reaction.kinetics if reaction.network_kinetics is None else reaction.network_kinetics
kf = apply_inverse_laplace_transform_method(reaction.transition_state, kinetics, e_list, j_list, reac_dens_states, T)
Expand Down Expand Up @@ -169,8 +169,8 @@ def calculate_microcanonical_rate_coefficient(reaction,
if reac_dens_states[r, s] != 0:
kf[r, s] = kr[r, s] * prod_dens_states[r, s] / reac_dens_states[r, s]
kf *= c0_inv ** (len(reaction.reactants) - len(reaction.products))
logging.debug('Finished finding microcanonical rate coefficients for path reaction {}'.format(reaction))
logging.debug('The forward and reverse rates are found to be {0} and {1} respectively.'.format(kf, kr))
logging.debug('Finished finding microcanonical rate coefficients for path reaction %s', reaction)
logging.debug('The forward and reverse rates are found to be %g and %g respectively.', kf, kr)

return kf, kr

Expand Down Expand Up @@ -231,8 +231,8 @@ def apply_rrkm_theory(transition_state,
for r in range(n_grains):
if sum_states[r, s] > 0 and dens_states[r, s] > 0:
k[r, s] = sum_states[r, s] / dens_states[r, s] * d_e
logging.debug('Finished applying RRKM for path transition state {}'.format(transition_state))
logging.debug('The rate constant is found to be {}'.format(k))
logging.debug('Finished applying RRKM for path transition state %s', transition_state)
logging.debug('The rate constant is found to be %s', k)
return k

@cython.boundscheck(False)
Expand Down Expand Up @@ -330,8 +330,8 @@ def apply_inverse_laplace_transform_method(transition_state,

else:
raise PressureDependenceError('Unable to use inverse Laplace transform method for non-Arrhenius kinetics or for n < 0.')
logging.debug('Finished applying inverse lapace transform for path transition state {}'.format(transition_state))
logging.debug('The rate constant is found to be {}'.format(k))
logging.debug('Finished applying inverse lapace transform for path transition state %s', transition_state)
logging.debug('The rate constant is found to be %s', k)

return k

Expand Down Expand Up @@ -396,7 +396,7 @@ def fit_interpolation_model(reaction, Tlist, Plist, K, model, Tmin, Tmax, Pmin,
log_rms += (log_k_model - log_k_data) * (log_k_model - log_k_data)
log_rms = sqrt(log_rms / len(Tlist) / len(Plist))
if log_rms > 0.5:
logging.warning('RMS error for k(T,P) fit = {0:g} for reaction {1}.'.format(log_rms, reaction))
logging.debug('Finished fitting model for path reaction {}'.format(reaction))
logging.debug('The kinetics fit is {0!r}'.format(kinetics))
logging.warning('RMS error for k(T,P) fit = %g for reaction %s.', log_rms, reaction)
logging.debug('Finished fitting model for path reaction %s', reaction)
logging.debug('The kinetics fit is %r', kinetics)
return kinetics