chempy.thermodynamics package¶
Submodules¶
chempy.thermodynamics.expressions module¶
-
class
chempy.thermodynamics.expressions.
EqExpr
(*args, **kwargs)[source]¶ Bases:
chempy.thermodynamics.expressions.EqExpr
EqExpr is deprecated. Use MassActionEq instead.
Baseclass for equilibrium expressions
- Attributes
- argument_defaults
- argument_names
- nargs
- trivially_zero
Methods
__call__
(self, variables[, backend])Call self as a function.
arg
(self, variables, index[, backend, evaluate])- Parameters
args_dimensionality
(self, \*\*kwargs)return tuple of dicts mapping str to int (‘length’, ‘mass’, ‘time’, ‘current’, ‘temperature’, ‘luminous_intensity’, ‘amount’)
dedimensionalisation
(self, unit_registry[, …])Create an instance with consistent units from a unit_registry
fk
(\*args)Alternative constructor “from keys”, *args is used as
unique_keys
.from_callback
(callback[, attr])Factory of subclasses
latex
(self[, variables, backend, default])- Parameters
all_args
all_parameter_keys
all_params
all_unique_keys
string
-
class
chempy.thermodynamics.expressions.
GibbsEqConst
(args=None, unique_keys=None)[source]¶ Bases:
chempy.thermodynamics.expressions.MassActionEq
- Attributes
- argument_defaults
- nargs
- trivially_zero
Methods
__call__
(self, \*args, \*\*kwargs)Call self as a function.
arg
(self, variables, index[, backend, evaluate])- Parameters
args_dimensionality
(self, \*\*kwargs)return tuple of dicts mapping str to int (‘length’, ‘mass’, ‘time’, ‘current’, ‘temperature’, ‘luminous_intensity’, ‘amount’)
dedimensionalisation
(self, unit_registry[, …])Create an instance with consistent units from a unit_registry
fk
(\*args)Alternative constructor “from keys”, *args is used as
unique_keys
.from_callback
(callback[, attr])Factory of subclasses
latex
(self[, variables, backend, default])- Parameters
active_conc_prod
all_args
all_parameter_keys
all_params
all_unique_keys
eq_const
equilibrium_equation
string
-
argument_names
= ('dH_over_R', 'dS_over_R')¶
-
eq_const
(self, variables, backend=<module 'math' from '/opt/cpython-3.7/lib/python3.7/lib-dynload/math.cpython-37m-x86_64-linux-gnu.so'>, **kwargs)[source]¶
-
parameter_keys
= ('temperature',)¶
-
class
chempy.thermodynamics.expressions.
MassActionEq
(args=None, unique_keys=None)[source]¶ Bases:
chempy.util._expr.Expr
- Attributes
- argument_defaults
- nargs
- trivially_zero
Methods
__call__
(self, \*args, \*\*kwargs)Call self as a function.
arg
(self, variables, index[, backend, evaluate])- Parameters
args_dimensionality
(self, \*\*kwargs)return tuple of dicts mapping str to int (‘length’, ‘mass’, ‘time’, ‘current’, ‘temperature’, ‘luminous_intensity’, ‘amount’)
dedimensionalisation
(self, unit_registry[, …])Create an instance with consistent units from a unit_registry
fk
(\*args)Alternative constructor “from keys”, *args is used as
unique_keys
.from_callback
(callback[, attr])Factory of subclasses
latex
(self[, variables, backend, default])- Parameters
active_conc_prod
all_args
all_parameter_keys
all_params
all_unique_keys
eq_const
equilibrium_equation
string
-
active_conc_prod
(self, variables, backend=<module 'math' from '/opt/cpython-3.7/lib/python3.7/lib-dynload/math.cpython-37m-x86_64-linux-gnu.so'>, equilibrium=None)[source]¶
-
argument_names
= ('equilibrium_constant',)¶
-
eq_const
(self, variables, backend=<module 'math' from '/opt/cpython-3.7/lib/python3.7/lib-dynload/math.cpython-37m-x86_64-linux-gnu.so'>, **kwargs)[source]¶
-
equilibrium_equation
(self, variables, backend=<module 'math' from '/opt/cpython-3.7/lib/python3.7/lib-dynload/math.cpython-37m-x86_64-linux-gnu.so'>, equilibrium=None, **kwargs)[source]¶
-
classmethod
from_callback
(callback, attr='eq_const', **kwargs)[source]¶ Factory of subclasses
- Parameters
- callbackcallable
signature: *args, backend=math
- attrstr
What attribute to override
- argument_namestuple of str, optional
- argument_defaultstuple of floats, optional
- parameter_keystuple of str, optional,
- nargsint, optional
Examples
>>> from operator import add; from functools import reduce >>> def poly(args, x, backend=math): ... x0 = args[0] ... return reduce(add, [c*(x-x0)**i for i, c in enumerate(args[1:])]) ... >>> Poly = Expr.from_callback(poly, parameter_keys=('x',), argument_names=('x0', Ellipsis)) >>> p = Poly([1, 3, 2, 5]) >>> p({'x': 7}) == 3 + 2*(7-1) + 5*(7-1)**2 True >>> q = Poly([1, 3, 2, 5], unique_keys=('x0_q',)) >>> q({'x': 7, 'x0_q': 0}) == 3 + 2*7 + 5*7**2 True