Mixture#

class cosmolayer.cosmosac.Mixture(components, min_sigma=-0.025, max_sigma=0.025, num_points=51, area_per_segment=7.25, averaging_radius=np.float64(1.5191269449366247), f_decay=3.57, sigma_0=0.007, merge_profiles=False, interaction_matrix_generator=<function create_cosmo_sac_2010_matrices>, temperature_exponents=(1, 3))[source]#

Mixture of molecular components for COSMO-SAC calculations.

This class manages a collection of molecular components, each defined by a COSMO output file from quantum mechanical calculations.

Note

The default parameters correspond to the COSMO-SAC 2010 model [1].

Parameters:
  • components (dict[str, str]) – Dictionary mapping component names to COSMO strings (i.e., contents of COSMO output files from quantum mechanical calculations).

  • min_sigma (float, optional) – Minimum screening charge density in e/Ų. Default is -0.025 e/Ų.

  • max_sigma (float, optional) – Maximum screening charge density in e/Ų. Default is 0.025 e/Ų.

  • num_points (int, optional) – Number of discrete points in the sigma profile. Default is 51.

  • area_per_segment (float, optional) – Reference area in Ų. Default is 7.25 Ų.

  • averaging_radius (float, optional) – Effective radius for distance-weighted sigma averaging in Å. Default is √(7.25 / π) Å.

  • f_decay (float, optional) – Decay factor for exponential distance weighting. Default is 3.57.

  • sigma_0 (float or None, optional) – Standard deviation of the Gaussian probability of a segment to form a hydrogen bond in e/Ų. Set to None to disable hydrogen-bond splitting (all surface area is assigned to the NHB class). Default is 0.007 e/Ų.

  • merge_profiles (bool, optional) – Whether to merge segment groups (NHB, OH, OT) into a single profile when accessing probabilities and sigma_profiles. Default is False.

  • regularize (float, optional) – Minimum value for clipping probabilities. Default is 1e-10.

  • interaction_matrix_generator (Callable, optional) – Function to generate the interaction matrix for the mixture at a given temperature. Default is create_cosmo_sac_2010_matrices with default parameters.

  • temperature_exponents (tuple[float, ...], optional) – Temperature exponents for the interaction matrices. Must be the same length as the tuple returned by interaction_matrix_generator. Default is (1, 3).

Raises:

Examples

>>> from importlib.resources import files
>>> from cosmolayer.cosmosac import Mixture
>>> source = files("cosmolayer.data")
>>> components = {
...     "1-aminoethenol": (source / "C=C(N)O.cosmo").read_text(),
...     "2-aminoethanol": (source / "NCCO.cosmo").read_text(),
... }
>>> mixture = Mixture(components)
>>> len(mixture)
2
>>> mixture["1-aminoethenol"].area
97.34554...
>>> mixture["2-aminoethanol"].area
103.51765...
>>> mixture.component_names
('1-aminoethenol', '2-aminoethanol')
>>> areas = mixture.areas
>>> areas.shape
(2,)
>>> float(areas[0])
97.34554...

Attributes

area_per_segment#

Reference area per segment used by the COSMO-SAC model, in Ų.

areas#

(n_components,).

Type:

Cavity surface areas for all components in Ų. Shape

component_names#

Names of all components in the order they were provided.

merge_profiles#

Whether segment groups (NHB, OH, OT) are merged for sigma_profiles and probabilities.

probabilities#

Normalized segment-type probabilities for each component.

Stack of each component’s Component.probabilities. Shape is (n_components, num_points) if merge_profiles is True, else (n_components, 3*num_points).

Returns:

Probabilities; each row sums to 1.0.

Return type:

np.ndarray

sigma_profiles#

Per-component sigma profiles (surface area vs. charge density), in Ų.

Stack of each component’s Component.sigma_profile. Shape is (n_components, num_points) when merge_profiles is True, (n_components, 3, num_points) when False (NHB, OH, OT).

Returns:

Sigma profile array; last dimension is the sigma grid.

Return type:

np.ndarray

temperature_exponents#

Exponents used to scale each interaction matrix with temperature.

Each entry scales the corresponding matrix from interaction_matrices as T^exponent (e.g. 1 and 3 for the COSMO-SAC 2010 model).

Returns:

One exponent per interaction matrix.

Return type:

tuple of float

volumes#

(n_components,).

Type:

Cavity volumes for all components in ų. Shape

Methods

add_component(name, cosmo_string)[source]#

Add a component to the mixture.

Parameters:
  • name (str) – Component name.

  • cosmo_string (str) – Contents of a COSMO output file.

interaction_matrices(temperature)[source]#

COSMO-SAC interaction matrices for the mixture at the given temperature.

Parameters:

temperature (float) – Temperature in K; used to scale the matrices.

Returns:

Matrices used in the COSMO-SAC activity coefficient calculation. Length and shapes match the generator (e.g. sigma–sigma and sigma’–sigma’ for the 2010 model).

Return type:

tuple of np.ndarray

remove_component(name)[source]#

Remove a component from the mixture.

Parameters:

name (str) – Component name.

replace_component(old_name, new_name, cosmo_string)[source]#

Replace a component in the mixture.

The new name must not already exist in the mixture, unless it is the same as the old name. In this case, the component data is updated using the new COSMO string.

Parameters:
  • old_name (str) – Name of the component to replace.

  • new_name (str) – Name of the new component.

  • cosmo_string (str) – Contents of the new component’s COSMO output file.

Raises:

ValueError – If the old name is not found in the mixture. If the new name already exists in the mixture and is not the same as the old name.