Skip to content
\n

2. Initializing the substances, equation of state and thermodynamic conditions

\n

For this example and the above functions, we assume that the solvent is always component at index 0 and the two ions are 1 and 2.
\nIf you initialize your substances in a different order, you have to adjust the code accordingly.

\n
# parameters\nparameters = ElectrolytePcSaftParameters.from_json(\n    substances=['water', 'sodium ion', 'chloride ion'],\n    pure_path='../parameters/epcsaft/held2014_w_permittivity_added.json',\n    binary_path='../parameters/epcsaft/held2014_binary.json'\n)\nmolarweight_water = parameters.pure_records[0].molarweight * si.GRAM / si.MOL\n\n# equation of state\neos = EquationOfState.epcsaft(parameters, epcsaft_variant=ElectrolytePcSaftVariants.Advanced)\n\n# thermodynamic conditions\ntemperature = 298.15 * si.KELVIN\npressure = si.BAR\n# stoichiometric coefficients for [Na+] and [Cl-]\nnu = np.array([1.0, 1.0])
\n

3. Calculating the MIAC's and plotting the results

\n
# mean ionic activity coefficients\nmolality_salt = si.linspace(0 * si.MOL / si.KILOGRAM, 6.0 * si.MOL / si.KILOGRAM, 100) \ngammas = np.array([\n    mean_ionic_activity_coefficient(eos, temperature, pressure, b, molarweight_solvent=molarweight_water, stoichiometric_coefficients=nu) \n    for b in molality_salt\n])\n\n# plot results\nplt.plot(molality_salt / si.MOL * si.KILOGRAM, gammas, clip_on=False)\nplt.xlabel(r'Molality $m_\\text{salt}$ / mol / kg')\nplt.ylabel(r'$\\gamma^{*, x}_\\pm$')\nplt.xlim(0, 6)\nplt.ylim(0.7, 1.2)\nsns.despine(offset=10);
\n

I hope that helps - let us know if there are any more questions.

","upvoteCount":1,"url":"https://github.com/feos-org/feos/discussions/270#discussioncomment-12083231"}}}
Discussion options

You must be logged in to vote

Hi Sven,

here is an example for MIAC of NaCl (modeled as two components) in water. The paths used assume that you work inside the "examples" folder. I cut it into three parts.

1. Imports and helper functions

Imports for FeOs, SI units and plotting and helper functions to calculate the mean ionic activity coefficient:

from feos.eos import *
from feos.epcsaft import *
import si_units as si
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

sns.set_context('notebook')
sns.set_palette('Dark2')
sns.set_style('ticks')

def molality_to_mole_fraction(
    molality_solute: si.SIObject, 
    molarweight_solvent: si.SIObject
) -> float:
    """Calculate mole fraction of solute…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by svenpohl1991
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants