flory.entropy.ideal_gas
Module for ideal gas entropic energy of mixture.
Classes
Class for entropic energy of mixture of ideal gas. |
|
Compiled class for the entropic energy of mixture of ideal gas. |
- class IdealGasEntropy(num_comp, sizes=None)[source]
Bases:
EntropyBaseClass for entropic energy of mixture of ideal gas.
The particular form of dimensionless entropic energy reads
\[f_\mathrm{entropy}(\{\phi_i\}) = \sum_{i=1}^{N_\mathrm{C}} \frac{\nu}{\nu_i}\phi_i \ln(\phi_i),\]where \(\phi_i\) is the fraction of component \(i\). All components are assumed to have the same molecular volume \(\nu\) by default. The relative molecular sizes \(l_i=\nu_i/\nu\) can be changed by setting the optional parameter
sizes. Note that no implicit solvent is assumed.- Parameters:
Public Data Attributes:
The relative molecule volumes \(l_i = \nu_i/\nu\).
Public Methods:
Inherited from
EntropyBase:compiled(**kwargs_full)Make a compiled entropy instance for
CoexistingPhasesFinder.Private Methods:
Implementation of creating a compiled entropy instance.
_energy_impl(phis)Implementation of calculating entropic energy \(f_\mathrm{entropy}\).
_jacobian_impl(phis)Implementation of calculating Jacobian \(\partial f_\mathrm{entropy}/\partial \phi_i\).
_hessian_impl(phis)Implementation of calculating Hessian \(\partial^2 f_\mathrm{entropy}/\partial \phi_i^2\).
Inherited from
EntropyBase:_compiled_impl(**kwargs)Implementation of creating a compiled entropy instance (Interface).
_energy_impl(phis)Implementation of calculating entropic energy \(f_\mathrm{entropy}\) (Interface).
_jacobian_impl(phis)Implementation of calculating Jacobian \(\partial f_\mathrm{entropy}/\partial \phi_i\) (Interface).
_hessian_impl(phis)Implementation of calculating Hessian \(\partial^2 f_\mathrm{entropy}/\partial \phi_i^2\) (Interface).
- _compiled_impl()[source]
Implementation of creating a compiled entropy instance.
This method overwrites the interface
_compiled_impl()inEntropyBase.- Returns:
Instance of
IdealGasEntropyCompiled.- Return type:
- _energy_impl(phis)[source]
Implementation of calculating entropic energy \(f_\mathrm{entropy}\).
This method overwrites the interface
_energy_impl()inEntropyBase.
- _jacobian_impl(phis)[source]
Implementation of calculating Jacobian \(\partial f_\mathrm{entropy}/\partial \phi_i\).
This method overwrites the interface
_jacobian_impl()inEntropyBase.
- compiled(**kwargs_full)
Make a compiled entropy instance for
CoexistingPhasesFinder.This function requires the implementation of
_compiled_impl(). The entropy instance is a compiled class, which must implement a list of methods or properties. SeeEntropyBaseCompiledfor the list and the detailed information.Note that the compiled entropy instance acts as the bridge between the component-based description and the feature-based description of the system’s states. In contrast, compiled classes in
ensembleshould be only aware of component-based description, compiled classes ininteractionandconstraintshould be only aware of feature-based description.See
IdealGasEntropyCompiledfor an example.- Parameters:
kwargs_full¶ – The keyword arguments for
_compiled_impl()but allowing redundant arguments.- Returns:
The compiled entropy instance.
- Return type:
- _hessian_impl(phis)[source]
Implementation of calculating Hessian \(\partial^2 f_\mathrm{entropy}/\partial \phi_i^2\).
This method overwrites the interface
_hessian_impl()inEntropyBase.
- class IdealGasEntropyCompiled(sizes)[source]
Bases:
EntropyBaseCompiledCompiled class for the entropic energy of mixture of ideal gas.
For ideal gas, the Boltzmann factor \(p_i^{(m)}\) is determined by the relative volumes of the molecules \(l_i = \nu_i/\nu\) and the mean fields it feel, \(w_r^{(m)}\),
\[p_i^{(m)} = \exp(-l_i w_r^{(m)}).\]Note that this class assumes that there’s no degeneracy of the components’ features, in other words all components have their own mean fields, such that the component index is the same as the feature id, \(i=r\). Therefore the number of features \(N_\mathrm{S}\) are the same as the number of components \(N_\mathrm{C}\).
- Parameters:
sizes¶ (
ndarray) – 1D array with the size of \(N_\mathrm{C}\), containing the relative molecule volumes \(l_i = \nu_i/\nu\). The number of components \(N_\mathrm{C}\) is inferred from this array. The number of features \(N_\mathrm{S}\) is set to be same as \(N_\mathrm{C}\).
Public Data Attributes:
Number of components \(N_\mathrm{C}\).
Number of features \(N_\mathrm{S}\).
Inherited from
EntropyBaseCompiled:Number of components \(N_\mathrm{C}\).
Number of features \(N_\mathrm{S}\).
Public Methods:
partition(phis_comp, omegas, Js)Calculate the partition function and Boltzmann factors.
comp_to_feat(phis_feat, phis_comp)Convert the fractions of components into features.
volume_derivative(phis_comp)Calculate the volume derivatives of entropic energy.
Inherited from
EntropyBaseCompiled:partition(phis_comp, omegas, Js)Calculate the partition function and Boltzmann factors.
comp_to_feat(phis_feat, phis_comp)Convert the fractions of components into features.
volume_derivative(phis_comp)Calculate the volume derivatives of entropic energy.
- partition(phis_comp, omegas, Js)[source]
Calculate the partition function and Boltzmann factors.
This method calculates the Boltzmann factors \(p_i^{(m)}\) of the components under the mean fields
omegasand stores them inphis_compas the volume fractions of components before normalization. This method must return the single molecule partition functions of the components \(Q_i\), which is the sum of the Boltzmann factors weighted by the volumes of compartments \(J_m\) inJs. Note thatomegascontains the mean fields for the features \(w_r^{(m)}\) instead of components. For example when we have polydispersity of the molecule sizes, all the polydispersed components of the same kind share the same external fields, but with different volume fractions. In such cases the number of features \(N_\mathrm{S}\) can be much smaller than number of components \(N_\mathrm{C}\). This method acts as the mapping from feature-based description of the system to the component-based description of the system. Note that this method should modifyphis_compdirectly.- Parameters:
phis_comp¶ (
ndarray) – Output. The 2D array with the size of \(N_\mathrm{C} \times N_\mathrm{M}\), containing Boltzmann factors \(p_i^{(m)}\), namely the volume fractions of components before normalization.omegas¶ (
ndarray) – Constant. The 2D array with the size of \(N_\mathrm{S} \times N_\mathrm{M}\), containing the mean field felt by the features \(\phi_r^{(m)}\).Js¶ (
ndarray) – Constant. The 1D array with the size of \(N_\mathrm{M}\), containing the relative volumes of compartments \(J_m\).
- Returns:
The single molecule partition functions of components \(Q_i\).
- Return type:
- comp_to_feat(phis_feat, phis_comp)[source]
Convert the fractions of components into features.
This method converts the volume fractions of components \(\phi_i^{(m)}\) in
phis_compto the volume fractions of features \(\phi_r^{(m)}\) inphis_feat. Note that this method should modifyphis_featdirectly.- Parameters:
phis_feat¶ (
ndarray) – Output. The 2D array with the size of \(N_\mathrm{S} \times N_\mathrm{M}\), containing the volume fractions of features \(\phi_r^{(m)}\).phis_comp¶ (
ndarray) – Constant. The 2D array with the size of \(N_\mathrm{C} \times N_\mathrm{M}\), containing the volume fractions of components \(\phi_i^{(m)}\).
- Return type:
- volume_derivative(phis_comp)[source]
Calculate the volume derivatives of entropic energy.
This method calculates the partial derivative of partition function part of the free energy with respect to the volumes of the compartments \(\partial f_\mathrm{entropy}/\partial J_m\).
In most of the cases, this is equivalent to the negative sum of the volume fractions of the components \(\phi_i^{(m)}\) divided by the relative volumes of the molecules \(l_i\). Note that this module is separated from the iteration algorithm to remove from it any explicit dependence of the molecule parameters such as \(l_i\).
- Returns:
The volume derivatives.
- Return type: