flory.ensemble.grandcanonical
Module for grand canonical ensemble of mixture.
Classes
Class for an grand canonical ensemble that the chemical potentials are fixed. |
|
Compiled class for grand canonical ensemble. |
- class GrandCanonicalEnsemble(num_comp, scaled_activity)[source]
Bases:
EnsembleBaseClass for an grand canonical ensemble that the chemical potentials are fixed.
- Parameters:
Public Data Attributes:
The scaled activities of the components \(l_i e^{l_i \mu_i}\).
Public Methods:
from_chemical_potential(num_comp, mus[, sizes])Create grand canonical ensemble from chemical potentials by volume.
Inherited from
EnsembleBase:compiled(**kwargs_full)Make a compiled ensemble instance for
CoexistingPhasesFinder.Private Methods:
Implementation of creating a compiled ensemble instance.
Inherited from
EnsembleBase:_compiled_impl(**kwargs)Implementation of creating a compiled ensemble instance (Interface).
- classmethod from_chemical_potential(num_comp, mus, sizes=None)[source]
Create grand canonical ensemble from chemical potentials by volume.
- _compiled_impl()[source]
Implementation of creating a compiled ensemble instance.
This method overwrites the interface
_compiled_impl()inEnsembleBase.- Returns:
Instance of
GrandCanonicalEnsembleCompiled.- Return type:
- compiled(**kwargs_full)
Make a compiled ensemble instance for
CoexistingPhasesFinder.This function requires the implementation of
_compiled_impl(). The ensemble instance is a compiled class, which must implement a list of methods or properties. SeeEnsembleBaseCompiledfor the list and the detailed information. Also seeCanonicalEnsembleCompiledfor an example.- Parameters:
kwargs_full¶ – The keyword arguments for
_compiled_impl()but allowing redundant arguments.- Returns:
The compiled ensemble instance.
- Return type:
- class GrandCanonicalEnsembleCompiled(scaled_activity)[source]
Bases:
EnsembleBaseCompiledCompiled class for grand canonical ensemble.
In grand canonical ensemble, the original chemical potentials of the components are fixed. Therefore, the volume fractions distribution of the components in compartments can be obtained by scaling the Boltzmann factors according to the scaled activity,
\[\begin{split}\phi_i^{(m)} &= l_i e^{l_i \mu_i} p_i^{(m)} \\\end{split}\]where \(l_i e^{l_i \mu_i}\) is the scaled activity, \(l_i\) is the relative volumes of molecules and \(\mu_i\) is the chemical potentials of the components by volume. Since (translational) entropy is always defined for each component, this class is only aware of the component-based description of the system.
- Parameters:
scaled_activity¶ (
ndarray) – 1D array with the size of \(N_\mathrm{C}\), containing the scaled activities of the components, \(l_i e^{l_i \mu_i}\). The number of components \(N_\mathrm{C}\) is inferred from this array.
Public Data Attributes:
Number of components \(N_\mathrm{C}\).
Inherited from
EnsembleBaseCompiled:Number of components \(N_\mathrm{C}\).
Public Methods:
normalize(phis_comp, Qs, masks)Normalize the volume fractions of components.
Inherited from
EnsembleBaseCompiled:normalize(phis_comp, Qs, masks)Normalize the volume fractions of components.
- property num_comp
Number of components \(N_\mathrm{C}\).
- normalize(phis_comp, Qs, masks)[source]
Normalize the volume fractions of components.
This method normalizes the Boltzmann factor stored in
phis_compinto volume fractions of all components \(\phi_i^{(m)}\) and save it back tophis_comp, making use of the single molecule partition function inQs. The exact form of such normalization depends on the emsemble. This method must report the incompressibility \(\sum_i \phi_i^{(m)} -1\). Note that this function is only aware of the number of components \(N_\mathrm{C}\). Mapping from/to features are handled byentropy.- Parameters:
phis_comp¶ (
ndarray) – Mutable. The 2D array with the size of \(N_\mathrm{C} \times N_\mathrm{M}\), containing Boltzmann factors of the components, which are proportional to resulting volume fractions.Qs¶ (
ndarray) – Constant. The 1D array with the size of \(N_\mathrm{C}\), containing single molecule partition functions of the components.masks¶ (
ndarray) – Constant. The 1D array with the size of \(N_\mathrm{M}\), containing the masks to mark whether the compartment is living or not.
- Returns:
The incompressibility.
- Return type: