Functions Module

pyEQL functions that take Solution objects as inputs or return Solution objects.

copyright:

2013-2023 by Ryan S. Kingsbury

license:

LGPL, see LICENSE for more details.

pyEQL.functions.autogenerate(solution='')[source]

This method provides a quick way to create Solution objects representing commonly-encountered solutions, such as seawater, rainwater, and wastewater.

Parameters:

solution (str) – String representing the desired solution Valid entries are ‘seawater’, ‘rainwater’, ‘wastewater’,and ‘urine’

Returns:

A pyEQL Solution object.

Return type:

Solution

Notes

The following sections explain the different solution options:

  • ‘’ - empty solution, equivalent to pyEQL.Solution()

  • ‘rainwater’ - pure water in equilibrium with atmospheric CO2 at pH 6

  • ‘seawater’ or ‘SW’- Standard Seawater. See Table 4 of the Reference for Composition [1]_

  • ‘wastewater’ or ‘WW’ - medium strength domestic wastewater. See Table 3-18 of [2]_

  • ‘urine’ - typical human urine. See Table 3-15 of [2]_

  • ‘normal saline’ or ‘NS’ - normal saline solution used in medicine [3]_

  • ‘Ringers lacatate’ or ‘RL’ - Ringer’s lactate solution used in medicine [4]_

References:

pyEQL.functions.donnan_eql(solution, fixed_charge)[source]

Return a solution object in equilibrium with fixed_charge.

Parameters:
  • solution (Solution object) – The external solution to be brought into equilibrium with the fixed charges

  • fixed_charge (str quantity) – String representing the concentration of fixed charges, including sign. May be specified in mol/L or mol/kg units. e.g. ‘1 mol/kg’

Returns:

A solution that has established Donnan equilibrium with the external (input) Solution

Return type:

Solution

Notes

The general equation representing the equilibrium between an external electrolyte solution and an ion-exchange medium containing fixed charges is

\[\frac{a_{-}}{\bar a_{-}}^{\frac{1}{z_{-}} \frac{\bar a_{+}}{a_{+}}^{\frac{1}{z_{+}} = exp(\frac{\Delta \pi \bar V}{{RT z_{+} \nu_{+}}})\]

Where subscripts \(+\) and \(-\) indicate the cation and anion, respectively, the overbar indicates the membrane phase, \(a\) represents activity, \(z\) represents charge, \(\nu\) represents the stoichiometric coefficient, \(V\) represents the partial molar volume of the salt, and \(\Delta \pi\) is the difference in osmotic pressure between the membrane and the solution phase.

In addition, electroneutrality must prevail within the membrane phase:

\[\bar C_{+} z_{+} + \bar X + \bar C_{-} z_{-} = 0\]

Where \(C\) represents concentration and \(X\) is the fixed charge concentration in the membrane or ion exchange phase.

This function solves these two equations simultaneously to arrive at the concentrations of the cation and anion in the membrane phase. It returns a solution equal to the input solution except that the concentrations of the predominant cation and anion have been adjusted according to this equilibrium.

NOTE that this treatment is only capable of equilibrating a single salt. This salt is identified by the get_salt() method.

References

Strathmann, Heiner, ed. Membrane Science and Technology vol. 9, 2004. Chapter 2, p. 51.

http://dx.doi.org/10.1016/S0927-5193(04)80033-0

See Also:

get_salt()

pyEQL.functions.entropy_mix(Solution1, Solution2)[source]

Return the ideal mixing entropy associated with mixing two solutions.

Parameters:
  • Solution1 (Solution objects) – The two solutions to be mixed.

  • Solution2 (Solution objects) – The two solutions to be mixed.

Returns:

The ideal mixing entropy associated with complete mixing of the Solutions, in Joules.

Return type:

Quantity

Notes

The ideal entropy of mixing is calculated as follows

\[\begin{split}\\Delta_{mix} S = \\sum_i (n_c + n_d) R T \\ln x_b - \\sum_i n_c R T \\ln x_c - \\sum_i n_d R T \\ln x_d\end{split}\]

Where \(n\) is the number of moles of substance, \(T\) is the temperature in kelvin, and subscripts \(b\), \(c\), and \(d\) refer to the concentrated, dilute, and blended Solutions, respectively.

Note that dissociated ions must be counted as separate components, so a simple salt dissolved in water is a three component solution (cation, anion, and water).

References

Koga, Yoshikata, 2007. *Solution Thermodynamics and its Application to Aqueous Solutions:

A differential approach.* Elsevier, 2007, pp. 23-37.

pyEQL.functions.gibbs_mix(Solution1, Solution2)[source]

Return the Gibbs energy change associated with mixing two solutions.

Parameters:
  • Solution1 (Solution objects) – The two solutions to be mixed.

  • Solution2 (Solution objects) – The two solutions to be mixed.

Returns:

The change in Gibbs energy associated with complete mixing of the Solutions, in Joules.

Return type:

Quantity

Notes

The Gibbs energy of mixing is calculated as follows

\[\begin{split}\\Delta_{mix} G = \\sum_i (n_c + n_d) R T \\ln a_b - \\sum_i n_c R T \\ln a_c - \\sum_i n_d R T \\ln a_d\end{split}\]

Where \(n\) is the number of moles of substance, \(T\) is the temperature in kelvin, and subscripts \(b\), \(c\), and \(d\) refer to the concentrated, dilute, and blended Solutions, respectively.

Note that dissociated ions must be counted as separate components, so a simple salt dissolved in water is a three component solution (cation, anion, and water).

References

Koga, Yoshikata, 2007. *Solution Thermodynamics and its Application to Aqueous Solutions:

A differential approach.* Elsevier, 2007, pp. 23-37.

pyEQL.functions.mix(Solution1, Solution2)[source]

Mix two solutions together.

Returns a new Solution object that results from the mixing of Solution1 and Solution2

Parameters:
  • Solution1 (Solution objects) – The two solutions to be mixed.

  • Solution2 (Solution objects) – The two solutions to be mixed.

Returns:

A Solution object representing the mixed solution.

Return type:

Solution