Welcome to COSMOpy’s documentation!

Introduction

COSMOpy is a Python interface to the BIOVIA Solvation Chemistry software.

COSMOlogic is now part of Dassault Systèmes the 3DEXPERIENCE (R) Company, and its BIOVIA brand.

  • BIOVIA COSMOtherm - Predictive property calculation of liquids by the COSMO-RS theory

  • BIOVIA COSMObase - High quality collections of pre-calculated compound information

  • BIOVIA COSMOconf - Flexible conformer generation toolbox for the most relevant conformers

  • BIOVIA COSMOquick - Quick and powerful toolbox removing the need for costly quantum chemistry

  • TURBOMOLE - General purpose, fast and robust quantum chemistry program package

Note: Not to be confused with the astronomy related theoretical cosmology module called CosmoPy: http://ifa.hawaii.edu/cosmopy/

Indices and tables

Download and installation

The Python library COSMOpy and installation instructions are available on request. Contact us and support

Pre-requisites:

  • COSMOthermX installation

  • Python 3 (Python 2.7 libraries exist, but not being updated any more, starting with August 2019)

  • RDkit (optional)

Getting started

The general module to handle all COSMOpy objects is the module COSMOpy and its class CosmoPy

  • Dealing with compounds and mixtures

    • Supports conformer sets, ionic liquids and mixture compositions

    • Storage of compound or mixture properties

  • Handling of COSMOtherm, COSMObase, COSMOconf, COSMOquick, MOPAC and TURBOMOLE

    • Search compounds in the COSMObase

    • Compute new compounds by COSMOconf and TURBOMOLE

    • Predict thermodynamic values by COSMOtherm: activity coefficients, vapor pressures, partitioning, … etc.

    • Apply COSMOquick models

  • Open compound files

    • .sdf, .smi, .xyz, …

    • .cosmo files and conformer sets

  • Chemoinformatics routines (using RDKit or CDK), e.g.,

    • Generate 3D structures from SMILES

    • Substructure searches

Initialize CosmoPy object

The CosmoPy object is a general class to handle COSMOlogic software. It is initialized in the following way (more details on the initialition see COSMOpy.COSMOpy.CosmoPy):

Example

>>> from COSMOpy import *
>>> cp = CosmoPy()  # Initialize CosmoPy main object

Working with COSMOlogic software

The following example shows how to:

  • Search the COSMObase at TZVP level

  • Define COSMOtherm job types and compute jobs

  • Get properties from COSMOtherm calculations

Example

>>> cp.cosmotherm.setLevel("TZVP")                            # Set level of calculation "SVP", "TZVP", "TZVPD-FINE"
>>> ethanol = cp.cosmotherm.searchName("ethanol")[0]          # Search name in the COSMObase used for COSMOtherm calculations - index 0 returns 1st compound in list
>>> cp.cosmotherm.define(ethanol, "Henry constant")           # Define a calculation type - here: "Henry constant" (= equivalent to panel name in COSMOthermX)
>>> cp.cosmotherm.compute()                                   # Run COSMOtherm calculations
>>> ethanol.getProperty("H")                                  # Henry constant (the property name is parsed from the .tab result file)
0.051
>>> cp.cosmotherm.define(ethanol, "Henry constant", T = 350)  # Now, define a temperature
>>> cp.cosmotherm.compute()                                   # Run COSMOtherm calculations
>>> ethanol.getProperty("H", "log(kPa)", T = 350)             # Return Henry constant in unit of interest (automatic unit conversion!)
4.11

In addition to the cosmotherm instance, there are also cosmoconf, cosmoquick, turbomole etc. instances to the CosmoPy object. More details on accessing the COSMOlogic software packages from Python is presented in the documentation to the individual calculation classes:

Functions: Unit conversion

A general unit conversion function is part of the COSMOpy library, the conversion factors based on NIST or IUPAC recommendations:

  • convertUnit: COSMOcompound.convertUnit()

  • convertConcentration: COSMOcompound.convertConcentration()

Example

>>> convertUnit(5, "kcal/mol", "kJ/mol")
20.92
>>> convertUnit(5, "kcal/mol", "kJ/kg", mol_weight = 88.0)  # Conversion of mol --> kg units
237.73
>>> convertUnit(5, "bar", "log(kPa)")  # Logarithmic units (note: log = log10; ln = ln)
2.70
>>> convertConcentration(0.5, "mol/l")  # Conversion of 0.5 mol/l (solute/water) to molar fraction in water
[0.0089, 0.9911]
>>> convertConcentration(14, "mg/ml", mol_weight = 151.06, T = 293)  # Water solubility of paracetamol (at 293 K) = 14 mg/ml 
[0.0017, 0.9983]

Objects: Compound handling

The COSMOpy library works with different objects related to compounds and mixtures:

Type

Class

Explanation

Compound

COSMOpy.COSMOcompound.Compound

Single conformer

ConformerSet

COSMOpy.COSMOcompound.ConformerSet

Conformer set

CompoundList

COSMOpy.COSMOcompound.CompoundList

Collection of compounds or conformer sets

IonicLiquid

COSMOpy.COSMOcompound.IonicLiquid

Ionic liquids composite of cations and antions

Mixture

COSMOpy.COSMOcompound.Mixture

Mixtures of compounds or conformer sets of a defined composition

Micelle

COSMOpy.COSMOcompound.Micelle

Micelle or membrane including components and specific properties

Example

>>> isopropanol = Compound("iso-Propanol", "CC(O)C")  # Compound (defined by compound name and SMILES)
>>>
>>> mixture = Mixture("Alcohols")  # Mixture (mixture name will be used by COSMOtherm as input file name)
>>> mixture.addCompound(ethanol, x = 0.3)
>>> mixture.addCompound(isopropanol, x = 0.7)

Objects: Opening .sdf .smi or .cosmo files

Type

Class

Explanation

CompoundReader

COSMOpy.COSMOcompound.CompoundReader

.sdf, .smi, .xyz, .cosmo

ConformerSetReader

COSMOpy.COSMOcompound.ConformerSetReader

_c0.cosmo, _c1.cosmo, …

MicelleReader

COSMOpy.COSMOcompound.MicelleReader

.mic

Example

>>> cosmo = ConformerSetReader("/home/somewhere/ethanol_c0.cosmo")  # Read cosmo conformer sets (specify first conformer _c0 here) 
>>> ethanol = cosmo.getCompound() # Reads all conformers for ethanol (_c0.cosmo, _c1.cosmo, ...)
>>> cosmo.close()
>>> 
>>> sdf = CompoundReader("/home/somewhere/solutes.sdf")  # Read sdf files
>>> solute = sdf.getCompound(0) # Multi-SMI/SDF: compound 1,2,3,...
>>> sdf.close()
>>>
>>> mic = CompoundReader("/home/somewhere/dmpc.mic")  # Read mic micelle or membrane files
>>> dmpc = mic.getMicelle(0) # Get dmpc system and all components
>>> mic.close()

Cheminformatics

Example

>>> ethanol = Compound("ethanol", "CCO")
>>> ethanol.cheminf.getFormalCharge()
0
>>> ethanol.cheminf.getCoordinates()
[[0.00, 0.00, 0.00], [-0.68, 0.87, -0.09], ...]
>>> ethanol.cheminf.getSmartsCount("[CH2,H3]")
2