The Solution Class

class ionize.Solution(ions=[], concentrations=[])[source]

Represent an aqueous Solution.

Solutions automatically compute their equilibrium state, and store it as pH and ionic_strength.

Parameters:ions – An iterable of ion objects, or strings. Each string is

converted to an ion object using the ionize database. If ion objects are used, new copies are stored inside the Solution. Each ion inside the Solution has the Solution as their context by default. However, the original version of the ion retains its original context.

Parameters:concentrations – An iterable of concentrations, in moles per liter.
Example:

``sol = ionize.Solution([‘chloride’, ‘tris’], [0.02, 0.05]) sol.pH, sol.ionic_strength ‘tris’ in sol # True sol.concentration(‘chloride’) # 0.02 with sol.temperature(35):

sol.conductivity()

sol.serialize() sol[‘tris’] # Ion(‘tris’)``

alberty()

Return the Alberty conservation function value of a solution.

Throw a warning if the ions are not univalent, or if water dissociation cannot be neglected.

buffering_capacity()

Return the buffering capacity of the solution.

This function generates an approximate solution to the buffering capacity by finding the derivative of the pH with respect to the addition of an acid insult at small concentration.

concentration(ion)[source]

Return the concentration of the ion.

The input may be an ion object or an ion name as a string.

concentrations

Return a numpy array of the ion concentrations in the solution.

conductivity()

Return the electrical conductivity of the solution, in Seimens/meter.

debye()

Return the Debye length of the solution.

Uses the Debye-Huckel approximation for the calculation.

displace(receding, advancing=None, guess=None)

Electrophoretically displace an ion.

equilibrate_CO2(partial_pressure=0.0004)

Titrate the CO2 in solution to equilibrium with the atmosphere.

Parameters:partial_pressure – The partial pressure of CO2 in the atmosphere,

in bar. Defaults to the typical value of Earth’s atmosphere.

gas()

Return the Gas conservation function value of the solution.

There are two Gas conservation function values, one that depends on the mobility of hydronium, the other depending on the mobility of hydroxide. Each of these is only valid when the concentration of the other ion is negligable. When this assumption is broken, this function returns NaN for one value and a float for the other.

hydronium_conductivity()

Return the conductivity of protons in solution, in Seimens/meter.

hydroxide_conductivity()

Return the conductivity of hydroxyls in solution, in Seimens/meter.

ionic_strength

The ionic strength of the solution.

ions

Return a tuple of the ions in the solution.

jovin()

Return the Jovin conservation function value of a solution.

Throw a warning if the ions are not univalent, or if water dissociation cannot be neglected.

kohlrausch()

Return the Kohlrausch regulating function (KRF) value of a solution.

The Kohlrausch regulating function is only valid if ions are near full ionization. This function will deliver a warning where this is not the case.

moderate()[source]

Return True if the solution has a moderate pH.

We define moderate pH as the regime in which the sum of charge contributed by H+ and OH- is less than 10% the sum of charge contributed by other ions.

pH

The pH of the solution.

safe()[source]

Return True if the solution has a safe pH.

We define moderate pH as the regime in which the conductivity contributed by H+ and OH- is less than 10% the sum of charge contributed by other ions.

save(filename)[source]

Save the solution to file.

serialize(nested=False, compact=False)[source]

Return a JSON-formatted serialization of the object.

temperature(temperature=None)[source]

Set or get the temperature of the solution.

Parameters:temperature – The new temperature. If temperature is None, return

the current temperature. Otherwise, sets the temperature and returns a context manager that reverts to the original temperature.

titrate(titrant, target, titration_property='pH')

Return a Solution titrated to the target pH using the titrant.

Titrate uses root finding to determine the concentration of titrant to add to achieve the desired pH. If the desired pH cannot be achieved by addition of the titrant, titrate raises an error.

To titrate to a target property other than pH, simply set the property to a property of the Solution class.

transference(ion)

Return the fraction of charge carried by each of the ions as a list.

Should not precisely add to 1, because some charge is carried by dissociated water.

zone_transfer(ion)

Return the zone transfer ion in the solution, in Coulombs/liter.