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
Noneto 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
probabilitiesandsigma_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_matriceswith 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:
ValueError – If no components are provided.
FileNotFoundError – If any of the specified files do not exist.
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_profilesandprobabilities.
- probabilities#
Normalized segment-type probabilities for each component.
Stack of each component’s
Component.probabilities. Shape is(n_components, num_points)ifmerge_profilesis 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)whenmerge_profilesis 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_matricesas T^exponent (e.g. 1 and 3 for the COSMO-SAC 2010 model).
- volumes#
(n_components,).
- Type:
Cavity volumes for all components in ų. Shape
Methods
- interaction_matrices(temperature)[source]#
COSMO-SAC interaction matrices for the mixture at the given temperature.
- 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:
- 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.