flory.ensemble.canonical
Module for canonical ensemble of mixture.
Classes
Class for an canonical ensemble that the average volume fractions are conserved. |
|
Compiled class for canonical ensemble. |
- class CanonicalEnsemble(num_comp, phi_means=None)[source]
Bases:
EnsembleBaseClass for an canonical ensemble that the average volume fractions are conserved.
The particular form of the conservation law reads
\[\bar{\phi}_i = \frac{\sum_m \phi_i^{(m)} J_m }{\sum_m J_m}.\]- Parameters:
Public Data Attributes:
The average volume fractions of the components \(\bar{\phi}_i\).
Inherited from
EnsembleBase:Component count
Public Methods:
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).
- 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:
- _compiled_impl()[source]
Implementation of creating a compiled ensemble instance.
This method overwrites the interface
_compiled_impl()inEnsembleBase.- Returns:
Instance of
CanonicalEnsembleCompiled.- Return type:
- class CanonicalEnsembleCompiled(phi_means)[source]
Bases:
EnsembleBaseCompiledCompiled class for canonical ensemble.
In canonical ensemble, the average volume fractions of the components are fixed. Therefore, the volume fractions distribution of the components in compartments can be obtained by normalizing the Boltzmann factors according to the average volume fractions,
\[\begin{split}\phi_i^{(m)} &= \frac{\bar{\phi}_i}{Q_i} p_i^{(m)} \\ Q_i &= \sum_m p_i^{(m)} J_m .\end{split}\]Since (translational) entropy is always defined for each component, this class is only aware of the component-based description of the system.
- Parameters:
phi_means¶ (
ndarray) – 1D array with the size of \(N_\mathrm{C}\), containing the mean volume fractions of the components, \(\bar{\phi}_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: