flory.ensemble.base
Module for a general ensemble of mixture.
Classes
Base class for a general ensemble of mixture. |
|
Abstract base class for a general compiled ensemble. |
- class EnsembleBase(num_comp)[source]
Bases:
objectBase class for a general ensemble of mixture.
Public Data Attributes:
Component count
Public Methods:
compiled(**kwargs_full)Make a compiled ensemble instance for
CoexistingPhasesFinder.Private Methods:
_compiled_impl(**kwargs)Implementation of creating a compiled ensemble instance (Interface).
- _compiled_impl(**kwargs)[source]
Implementation of creating a compiled ensemble instance (Interface).
This interface is meant to be overridden in derived classes. See
compiled()for more information on the compiled ensemble instance.- Return type:
- compiled(**kwargs_full)[source]
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 EnsembleBaseCompiled[source]
Bases:
objectAbstract base class for a general compiled ensemble.
This abstract class defines the necessary members of a compiled constraint instance. This abstract class does not inherit from
abc.ABC, since thenumba.experimental.jitclass()currently does not support some members ofabc.ABC. A compiled class derived fromEnsembleBaseCompiledis in general stateless. In other words, the compiled ensemble instance never managers its own data. Note that the methods may change the input arrays inplace to avoid creating them each time.Public Data Attributes:
Number of components \(N_\mathrm{C}\).
Public Methods:
normalize(phis_comp, Qs, masks)Normalize the volume fractions of components.
- 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: