def format_kinetics(self, rate = False, precision = 3):
"""Convert the kinetic parameter or rate to string.
If rate = True, return a string representing the rate,
otherwise one representing the kinetic parameter.
If the kinetic parameter is a float, use exponent notation,
with a number of digits equal to precision (3 is the default).
If the reaction has no defined rate, return None."""
k = None
if self.rate:
if isinstance(self.kinetic_param, sp.Float):
k = "{:.{}e}".format(self.kinetic_param, precision)
if rate:
k = k + "*" + str(self.reactant.ma())
else:
if rate:
k = str(self.rate)
else:
k = str(self.kinetic_param)
return k
评论列表
文章目录