sandlerchemeq package

class Component[source]

Bases: Compound

A chemical component with thermochemical and system properties based on the Compound class of sandlerprops.

T: Quantity

Temperature

P: Quantity

Pressure

Tref: Quantity

Reference temperature

classmethod from_compound(compound, **kwargs)[source]

Create a Component instance from a Compound instance

Parameters:

compound (Compound) – An instance of the Compound class

Returns:

component – An instance of the Component class

Return type:

Component

Cp_polynomial_as_tex()[source]

Returns a LaTeX-formatted string for the compound’s heat capacity polynomial

Returns:

retstr – LaTeX formatted heat capacity polynomial string

Return type:

str

CpInt_polynomial_as_tex()[source]

Returns a LaTeX-formatted string for the integral of the compound’s heat capacity polynomial

Returns:

retstr – LaTeX formatted integral of heat capacity polynomial string

Return type:

str

property dGf_T: Quantity

Ideal-gas Gibbs energy of formation at temperature T

__eq__(other)[source]

Compounds are equal if their empirical formulas are identical

Parameters:

other (Compound)

__hash__()[source]

Hash based on object id

__init__(No=0, Formula='', Name='', Molwt=<factory>, Tfp=<factory>, Tb=<factory>, Tc=<factory>, Pc=<factory>, Vc=<factory>, Zc=0.0, Omega=0.0, Dipm=<factory>, CpA=0.0, CpB=0.0, CpC=0.0, CpD=0.0, dHf=<factory>, dGf=<factory>, Eq=0, VpA=0.0, VpB=0.0, VpC=0.0, VpD=0.0, Tmin=<factory>, Tmax=<factory>, Lden=0.0, Tden=<factory>, charge=0, atomset=<factory>, atomdict=<factory>, metadata=<factory>, T=<factory>, P=<factory>, Tref=<factory>)
Parameters:
Return type:

None

countAtoms(a)[source]

Returns the count of atom a in the compound

Parameters:

a (str) – atom name

Returns:

count – Number of atoms of type a in the compound

Return type:

int

class Reaction[source]

Bases: object

A chemical reaction consisting of reactant and product Components. Automatically balances the reaction upon initialization.

components: list[Component]

List of all components in the reaction (reactants + products)

nu: ndarray

Stoichiometric coefficients (negative for reactants, positive for products)

stoProps: dict

Dictionary of stoichiometric property sums

stosum(propname)[source]

compute stoichiometric sum of property named propname

Parameters:

propname (str)

Return type:

float | ndarray

__init__(components=<factory>, nu=<factory>, stoProps=<factory>)
Parameters:
Return type:

None

__str__()[source]

spoof nu if reaction is not yet balanced

show()[source]
class ChemEqSystem[source]

Bases: object

Chemical equilibrium system solver using either explicit reactions with equilibrium constants or implicit Lagrange multiplier method.

Pstdst: Quantity = <Quantity(1.0, 'bar')>

Standard state pressure

T0: Quantity = <Quantity(298.15, 'kelvin')>

Standard state temperature

P: Quantity

System pressure

T: Quantity

System temperature

components: list[Component]

List of all components in the system

N0: ndarray

Initial moles of each component

__init__(P=<factory>, T=<factory>, components=<factory>, N0=<factory>, reactions=<factory>, N=<factory>, ys=<factory>)
Parameters:
Return type:

None

reactions: list[Reaction]

List of explicit reactions in the system

N: ndarray

Moles of each component at equilibrium

ys: ndarray

Mole fractions of each component at equilibrium

solve_implicit(Xinit=None, ideal=True, simplified=False)[source]

Implicit solution of M equations using equilibrium constants. Solutions are stored in attributes Xeq, N, and ys.

Parameters:
  • Xinit (list, optional) – Initial guess for extent of reaction (default is zeros)

  • ideal (bool, optional) – Whether to assume ideal behavior (default is True)

  • simplified (bool, optional) – Whether to use simplified van’t Hoff equation (default is False). Use False (full van’t Hoff with Cp correction) to match the Lagrange solver. True omits the heat-capacity correction and is provided for educational comparison only.

solve_lagrange(ideal=True, zInit=[])[source]

Implicit solution of chemical equilibrium system using Lagrange multipliers. Solutions are stored in attributes N and ys.

Parameters:
  • ideal (bool, optional) – Whether to assume ideal behavior (default is True) (NOT USED)

  • zInit (np.ndarray, optional) – Initial guess for mole numbers and Lagrange multipliers (default is [])

report()[source]

Generates a textual report of the chemical equilibrium system.

Returns:

Textual report of reactions and mole fractions at equilibrium

Return type:

str

Submodules