flory
is a Python package for analyzing field theories of multicomponent mixtures.
In particular, the package provides routines to determine coexisting states numerically, which is a challenging problem since the thermodynamic coexistence conditions are many coupled non-linear equations.
flory
supports finding coexisting phases with an arbitrary number of components.
The associated average free energy density of the system reads
where
flory
supports different forms of interaction, entropy, ensemble, and constraints to describe the free energy of phases.
For example, with the commonly used Flory-Huggins free energy, the free energy density of each homogeneous phase reads
where flory
provides tools to find the coexisting phases in equilibrium.
flory
is available on pypi
, so you should be able to install it through pip
:
pip install flory
As an alternative, you can install flory
through conda using the conda-forge channel:
conda install -c conda-forge flory
The following example determines the coexisting phases of a binary mixture with Flory-Huggins free energy:
import flory
num_comp = 2 # Set number of components
chis = [[0, 4.0], [4.0, 0]] # Set the \chi matrix
phi_means = [0.5, 0.5] # Set the average volume fractions
# obtain coexisting phases
phases = flory.find_coexisting_phases(num_comp, chis, phi_means)
It is equivalent to a more advanced example:
import flory
num_comp = 2 # Set number of components
chis = [[0, 4.0], [4.0, 0]] # Set the \chi matrix
phi_means = [0.5, 0.5] # Set the average volume fractions
# create a free energy
fh = flory.FloryHuggins(num_comp, chis)
# create a ensemble
ensemble = flory.CanonicalEnsemble(num_comp, phi_means)
# construct a finder from interaction, entropy and ensemble
finder = flory.CoexistingPhasesFinder(fh.interaction, fh.entropy, ensemble)
# obtain phases by clustering compartments
phases = finder.run().get_clusters()
The free energy instance provides more tools for analysis, such as:
# calculate the chemical potentials of the coexisting phases
mus = fh.chemical_potentials(phases.fractions)
- See examples in examples folder
- Full documentation on readthedocs