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)

UNIFAC

An implementation of the group contribution method of the Dortmund modification of UNIFAC. Calculates the activity coeficients of species in a mixture based on functional group parameters

from HSPiT import Unifac_Dortmund

# Set system parameters
smiles_lst = ["CCO", "CC(=O)C","CC=CC"]     # NA
x_lst=[1/3, 1/3, 1/3]                       # NA
T=298                                       # K

mixture=Unifac_Dortmund(smiles_lst,x_lst,T)

# Returns activity coefficient of component 0 in the mixture, according to the order in which the components were passed.
print(mixture.gamma_singular(0))

# Returns activity coefficient of all components in the mixture according to the order in which componenets were passed
print(mixture.gamma_total())

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

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

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

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.2.tar.gz (129.7 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.2-py3-none-any.whl (128.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hspit-0.1.2.tar.gz
  • Upload date:
  • Size: 129.7 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.2.tar.gz
Algorithm Hash digest
SHA256 b9699b59bbeb6dbc59bcd0437b7345a1f3cb07bf57dd9bc87dd50fa68fd85505
MD5 4719b3726a6b140d2384faeadf5cc773
BLAKE2b-256 fb4cbde6a1b79f9421fa0e2cffa84595c3d2ba84d94e424a412c18e0cb33ac84

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hspit-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 128.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6ba233893ab6d6af6a273ed140371d086ffdc5d083a00d60aa662fd08e8325eb
MD5 de7085a440d21448df91eeb41b2d0e83
BLAKE2b-256 709c94d0155c5c6d4a09d04036bc41b969f9f558d04fac1a1c0c5458fb19a0d0

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.1

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