flory.interaction.flory_huggins_block

Module for Flory-Huggins block interaction energy of mixture.

The Flory-Huggins block interaction means that several components may have exactly same interactions. Equivalently, the matrix \(\chi_{ij}\) has blocked structure.

Classes

FloryHugginsBlockInteraction

Class for Flory-Huggins block interaction energy of mixture.

class FloryHugginsBlockInteraction(num_feat, chis_feat, num_comp_per_feat=1)[source]

Bases: FloryHugginsInteractionBase

Class for Flory-Huggins block interaction energy of mixture.

The particular form of interaction energy density reads

\[f_\mathrm{interaction}(\{\phi_i\}) = \sum_{i,j=1}^{N_\mathrm{C}} \frac{\chi_{ij}}{2} \phi_i\phi_j\]

where \(\phi_i\) is the fraction of component \(i\), \(\chi_{ij}\) is the Flory-Huggins interaction matrix. The blocked structure of \(\chi_{ij}\) is defined as

\[\chi_{ij} = \chi_{rs} \qquad : \qquad i \in B_r, j \in B_s \;,\]

where \(B_r\) and \(B_s\) are the set of index of components that belong to feature \(r\) and \(s\), respectively.

Parameters:
  • num_feat (int) – Number of features \(N_\mathrm{S}\).

  • chis_feat (ndarray | float) – The Flory-Huggins interaction matrix of features \(\chi_{rs}\).

  • num_comp_per_feat (ndarray | int, default: 1) – The number of components in each feature. An integer indicates that this value is the same for all features.

Public Data Attributes:

num_comp_per_feat

Number of components in each feature.

chis

The Flory-Huggins interaction matrix of components \(\chi_{ij}\).

chis_feat

The Flory-Huggins interaction matrix of features \(\chi_{rs}\).

Public Methods:

Inherited from InteractionBase:

compiled(**kwargs_full)

Make a compiled interaction instance for CoexistingPhasesFinder.

Private Methods:

_compiled_impl(*[, additional_chis_shift])

Implementation of creating a compiled interaction instance.

Inherited from FloryHugginsInteractionBase:

_compiled_impl(*[, additional_chis_shift])

Implementation of creating a compiled interaction instance.

_energy_impl(phis)

Implementation of calculating interaction energy.

_jacobian_impl(phis)

Implementation of calculating Jacobian \(\partial f_\mathrm{interaction}/\partial \phi_i\).

_hessian_impl(phis)

Implementation of calculating Hessian \(\partial^2 f_\mathrm{interaction}/\partial \phi_i^2\).

Inherited from InteractionBase:

_compiled_impl(**kwargs)

Implementation of creating a compiled interaction instance (Interface).

_energy_impl(phis)

Implementation of calculating interaction energy \(f_\mathrm{interaction}\) (Interface).

_jacobian_impl(phis)

Implementation of calculating Jacobian \(\partial f_\mathrm{interaction}/\partial \phi_i\) (Interface).

_hessian_impl(phis)

Implementation of calculating Hessian \(\partial^2 f_\mathrm{interaction}/\partial \phi_i^2\) (Interface).


property num_comp_per_feat: ndarray

Number of components in each feature.

property chis: ndarray

The Flory-Huggins interaction matrix of components \(\chi_{ij}\).

This property should not be modified directly. Consider property chis_feat instead.

property chis_feat: ndarray

The Flory-Huggins interaction matrix of features \(\chi_{rs}\).

_compiled_impl(*, additional_chis_shift=1.0)[source]

Implementation of creating a compiled interaction instance.

This method overwrites the interface _compiled_impl() in InteractionBase.

Parameters:

additional_chis_shift (float, default: 1.0) – Shift of the entire chis matrix to improve the convergence by evolving towards incompressible system faster. This value should be larger than 0. This value only affects the numerics, not the actual physical system. Note that with very large value, the convergence will be slowed down, since the algorithm no longer have enough ability to temporarily relax the incompressibility.

Returns:

Instance of FloryHugginsInteractionCompiled.

Return type:

FloryHugginsInteractionCompiled

_energy_impl(phis)

Implementation of calculating interaction energy.

This method overwrites the interface _energy_impl() in InteractionBase.

Parameters:

phis (ndarray) – The volume fractions of the phase(s) \(\phi_{p,i}\). if multiple phases are included, the index of the components must be the last dimension.

Returns:

The interaction energy density

Return type:

ndarray

_hessian_impl(phis)

Implementation of calculating Hessian \(\partial^2 f_\mathrm{interaction}/\partial \phi_i^2\).

This method overwrites the interface _hessian_impl() in InteractionBase.

Parameters:

phis (ndarray) – The volume fractions of the phase(s) \(\phi_{p,i}\). if multiple phases are included, the index of the components must be the last dimension.

Returns:

The full Hessian

Return type:

ndarray

_jacobian_impl(phis)

Implementation of calculating Jacobian \(\partial f_\mathrm{interaction}/\partial \phi_i\).

This method overwrites the interface _jacobian_impl() in InteractionBase.

Parameters:

phis (ndarray) – The volume fractions of the phase(s) \(\phi_{p,i}\). if multiple phases are included, the index of the components must be the last dimension.

Returns:

The full Jacobian

Return type:

ndarray

compiled(**kwargs_full)

Make a compiled interaction instance for CoexistingPhasesFinder.

This function requires the implementation of _compiled_impl(). The interaction instance is a compiled class, which must implement a list of methods or properties. See InteractionBaseCompiled for the list and the detailed information. See also FloryHugginsInteractionCompiled for an example. Note that different from the class InteractionBase itself, the returned compiled class use the feature-based description, and can consider the degeneracy of components.

Parameters:

kwargs_full – The keyword arguments for _compiled_impl() but allowing redundant arguments.

Returns:

The compiler interaction instance.

Return type:

InteractionBaseCompiled