Skip to content

Commit

Permalink
Documented new interface to prop/T integrals
Browse files Browse the repository at this point in the history
  • Loading branch information
CalebBell committed Jul 3, 2016
1 parent 8f71b07 commit 88a622b
Showing 1 changed file with 48 additions and 1 deletion.
49 changes: 48 additions & 1 deletion thermo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1397,11 +1397,58 @@ def T_dependent_property_integral(self, T1, T2):
pass
return None


def calculate_integral_over_T(self, T1, T2, method):
r'''Method to calculate the integral of a property over temperature
with respect to temperature, using a specified method. Uses SciPy's
`quad` function to perform the integral, with no options.
This method can be overwritten by subclasses who may perfer to add
analytical methods for some or all methods as this is much faster.
If the calculation does not succeed, returns the actual error
encountered.
Parameters
----------
T1 : float
Lower limit of integration, [K]
T2 : float
Upper limit of integration, [K]
method : str
Method for which to find the integral
Returns
-------
integral : float
Calculated integral of the property over the given range,
[`units`]
'''
return float(quad(lambda T: self.calculate(T, method)/T, T1, T2)[0])

def T_dependent_property_integral_over_T(self, T1, T2):
r'''Method to calculate the integral of a property over temperature
with respect to temperature, using a specified method. Methods found
valid by `select_valid_methods` are attempted until a method succeeds.
If no methods are valid and succeed, None is returned.
Calls `calculate_integral_over_T` internally to perform the actual
calculation.
Parameters
----------
T1 : float
Lower limit of integration, [K]
T2 : float
Upper limit of integration, [K]
method : str
Method for which to find the integral
Returns
-------
integral : float
Calculated integral of the property over the given range,
[`units`]
'''
sorted_valid_methods = self.select_valid_methods(T1)
for method in sorted_valid_methods:
try:
Expand Down

0 comments on commit 88a622b

Please sign in to comment.