Skip to main content

HSPiT Library

Hansen Solubility Parameters in Theory (HSPiT) — a Python library for modeling solvent/solute miscibility, mixture stability, and solvent selection among other features, using Hansen Solubility Parameters (HSPs).

Install

HSPiT is pip installable, simply run in a terminal:

pip install HSPiT

HSP based activity coefficient model

Computes the activity coefficients of species in a mixture based on diffirences in HSPs

from HSPiT import Regula

# Set system parameters
x_lst=[1/3,1/3,1/3]                         # NA
hsp_lst=[(10,10,10),(15,15,15),(20,20,20)]  # MPa^0.5
mvol_lst=[50,50,50]                         # cm^3/mol
T=298                                       #K

# Define mixture
mixture=Regula(x_lst, hsp_lst, mvol_lst,T)


# Get Hansen distance between components 0 and 1
mixture.ra(0,1)

# Get activity coefficient of all components in mixture
mixture.gamma_v()

Stability analysis

The HSP-based activity coefficient can be used to perform a stability analysis of a mixture

from HSPiT import Regula

# Set system parameters
x_lst=[1/3,1/3,1/3]                         # NA
hsp_lst=[(10,10,10),(15,15,15),(20,20,20)]  # MPa^0.5
mvol_lst=[50,50,50]                         # cm^3/mol
T=298                                       #K

# Define mixture
mixture=Regula(x_lst, hsp_lst, mvol_lst,T)

# Stability analysis
mixture.is_stable_local() # computes local stability (spinodal)

mixture.is_stable_global() # computes global stability (binodal)

mixture.is_stable()  # computes local stability first (cheap), and only if that is True does it proceed to calculate global stability (expensive)


Solvent optimizer for stable mixtures

Methods for obtaining the HSP parameters of an additive that is likely to stabilize a given mixture. Method 1 is based on the activity coefficient model, and method 2 is based purely on geometric arguments in HSP+mvol space.

from HSPiT import Regula
from HSPiT import Nexus

# Set system parameters
x_lst=[1/3,1/3,1/3]                         # NA
hsp_lst=[(10,10,10),(15,15,15),(20,20,20)]  # MPa^0.5
mvol_lst=[50,50,50]                         # cm^3/mol
T=298                                       #K
N_max =1                                    # number of additives
phi_max=0.05                                # total volume fraction for all additives

# Define systems
mixture1=Regula(x_lst, hsp_lst, mvol_lst,T)   # Method 1
mixture2=Nexus(x_lst, hsp_lst, mvol_lst)      # Method 2

# Find optimal additive parameters
dd_add1,dp_add1,dh_add1, phi_add1 =           mixture1.optimize_additive(phi_max, N_max) # Method 1
dd_add2,dp_add2,dh_add2,mvol_add2, phi_add2 = mixture2.optimize_additive(phi_max, N_max) # Method 2

print(f"method 1: {dd_add1,dp_add1,dh_add1, phi_add1}")           # Method 1
print(f"method 2: {dd_add2,dp_add2,dh_add2,mvol_add2, phi_add2}") # Method 2

Surrogate formulator

Forming surrogates with a reduced number of components representative of an original mixture. A factor k is used to indicate the degree of prioritization for representation of outlying or isolated components in solubility space, as these are likely to have the greatest influence on mixture stability. k=1 gives equal priority, and k>1 leads to increasingly higher priority in representing isolated components.

from HSPiT import surrogate

# Define system parameters
hsp_lst=[...]  # list with original HSP
mvol_lst=[...] # list with original molar volumes
phi_lst=[...]  # list with original volume fractions
k=...          # prioritization factor for isolated components
N_max=...      # number of surrogate representative points

# Returns parameters for surrogate formulation
hsp_lst,mvol_lst,phi_lst=surrogate(hsp_lst, mvol_lst, phi_lst, k, N_max)

HSP predictor

Group contribution method

This includes an implementation of the Stefanis-Panayiotou group contribution method. The functional group data is embedded in the function. One needs only pass a SMILES string, and the function will automatically dissect it into its constituent functional groups and access the parameter values for use in the model. Additionally, it will automatically trigger either the low or the high path discussed in the original publication.

from HSPiT import stefanis_gc

smiles="CCO"

dd,dp,dh=stefanis_gc(smiles)

Fitting based on activity coefficients

This method utilizes the HSP-based activity coefficient model along with UNIFAC-Dortmund to fit the HSP for a target compound. The HSP is the argument that minimizes the discrepancy between the two activity coefficient models, across a set of binary mixtures.

from HSPiT import hsp_fit

smiles = "CCO" # NA
mvol = 58.4    # cm^3/mol

# Returns the fitted HSP parameters
dd,dp,dh=hsp_fit(smiles,mvol)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hspit-0.1.1.tar.gz (119.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hspit-0.1.1-py3-none-any.whl (117.7 kB view details)

Uploaded Python 3

File details

Details for the file hspit-0.1.1.tar.gz.

File metadata

  • Download URL: hspit-0.1.1.tar.gz
  • Upload date:
  • Size: 119.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for hspit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7eb556e01a8ee81eba90404f8b641b8caa138f460f80c587fa7feb1da16aee73
MD5 39886d57b30040de67ac6b0cab8de034
BLAKE2b-256 6c9e9319ff5a8e6aeff90b5ab8adb8d5ca1247f8a43a0c0eb6fa2667e21e3c02

See more details on using hashes here.

File details

Details for the file hspit-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: hspit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 117.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for hspit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a33b23d4c3cbc1ab0058e24f7f6d5675acc20d8a56384e0d6eda3e7b041e35dd
MD5 8ad3e2f5fb81d47e0539e6ba8b24d58b
BLAKE2b-256 0067222417c1c58d6b33004137fc99e60e8a38524faa378fdbb599dd1002742b

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.2

2 files

This release

0.1.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page