Scripting Examples

Example: COSMO result files

Download COSMO_files.run

#! /bin/sh

# This example tries to do the same as in the COSMO-RS GUI Tutorial: COSMO result files,
# using scripts.
#
# In the first part of the example you will find how to use amsprep to construct 
# an ADF COSMO results file.
# The template ADFCRS will perform a gas phase geometry optimization (for water, in this case),
# and next a COSMO calculation at the gas phase optimized geometry.
# The result file adfwater.coskf, which is an ADF COSMO result file, can be used as input for
# a COSMO-RS calculation. amsreport is used to extract data from the resulting .coskf file.

echo "Results"

rm -f water.xyz
rm -f job.sh
cat << eor > water.xyz
3

H       0.00000000       0.77121000       0.18071000
O       0.00000000      -0.00000000      -0.36142000
H       0.00000000      -0.77121000       0.18071000
eor

"$AMSBIN/amsprep" -t GO -runtype "COSMO-RS Compound" -m water.xyz -j adfwater >job.sh
chmod +x job.sh
./job.sh

echo "ADF"
"$AMSBIN/amsreport" adfwater.results geometry-a*
cp adfwater.coskf adffile.coskf
"$AMSBIN/amsreport" adffile.coskf energies

# The template ADFCRS can also be used for generating an "average monomer" COSMO result file.
# The calculation could take up quite some time.

echo "POLYMER"
$AMSBIN/amsprep -t GO -runtype "COSMO-RS Compound" -smiles "C{-}C{n+}(c1ccccc1)" -j adfpolystyrene >job3.sh
grep -i coskfatoms job3.sh |wc -w


# A MOPAC COSMO result file can also be constructed.
# Note that the syntax for MOPAC is not the same as in ADF2018.
# The template MOPAC-GO will perform a COSMO geometry optimization, 
# if -g "mopac.solvation.enabled 1" -g "mopac.solvation.solvent.name CRS" is included.
# If -g "mopac.solvation.nspa 362" is included the maximum number of COSMO surface points
# is 362, which is more than the default 42.
# The result file mopacwaterresults/mopac.coskf is a MOPAC COSMO result file,
# which can be used as input for a COSMO-RS calculation.

"$AMSBIN/amsprep" -t MOPAC-GO -m water.xyz -g "mopac.solvation.enabled 1" \
                  -g "mopac.solvation.solvent.name CRS" -g "mopac.solvation.nspa 362" \
                  -j mopacwater >job2.sh
chmod +x job2.sh
./job2.sh

echo "MOPAC"
"$AMSBIN/amsreport" mopacwater.results geometry-a*
"$AMSBIN/amsreport" mopacwater.results/mopac.coskf energies

# Fast Sigma can provide estimates of COSMO-RS sigma profiles in milliseconds.

echo "FAST SIGMA"
"$AMSBIN/fast_sigma" --smiles "CC(Cc1ccc(cc1)[C@@H](C(=O)O)C)C" -o ibuprofen.compkf
"$AMSBIN/amsreport" ibuprofen.compkf formula
"$AMSBIN/amsreport" ibuprofen.compkf energies

echo "Ready"

Example: COSMO-RS parameters and analysis

Download Parameters_and_Analysis.run

#! /bin/sh

# This example tries to part of the COSMO-RS GUI Tutorial: parameters and analysis using scripts.
#
# First some .coskf files are copied to the location where the scripts are running.

cp $AMSHOME/examples/COSMO-RS/Parameters_and_Analysis/benzene.coskf .
cp $AMSHOME/examples/COSMO-RS/Parameters_and_Analysis/ethanol.coskf .
cp $AMSHOME/examples/COSMO-RS/Parameters_and_Analysis/methanol.coskf .
cp $AMSHOME/examples/COSMO-RS/Parameters_and_Analysis/water.coskf .

# Set pure compound parameters
# ----------------------------

# In the first part of the example you will find how to use crsprep to set pure compound parameters,
# in this case to set the number of ring atoms for the benzene molecule, which has 6 ring atoms.
# The file benzene.coskf is changed, such that it contains the value "6" for the number of ring compounds.

"$AMSBIN/crsprep" -c benzene.coskf -nring 6 -savecompound

# The sigma profile and the sigma potential
# -----------------------------------------
# 
# Next for convenience a file tutorial2.compoundlist is made that consists of 4 coskf files.


rm -f tutorial2.compoundlist
rm -f job
cat << eor > tutorial2.compoundlist
benzene.coskf
ethanol.coskf
methanol.coskf
water.coskf
eor

# In the second part of the example sigma profiles are calculated for the four compounds
# (result file step6.crskf), and next the sigma potentials of the four pure compounds
# (result file step7.crskf).
# With *amsreport* one can get the calculated sigma profile or sigma potential from
# the .crskf file on standard output.


"$AMSBIN/crsprep" -t PURESIGMAPROFILE -c tutorial2.compoundlist -j step6 > job.sh
"$AMSBIN/crsprep" -t PURESIGMAPOTENTIAL -c tutorial2.compoundlist -j step7 >> job.sh
chmod +x job.sh
./job.sh
echo "Results"
"$AMSBIN/amsreport" step6.crskf sigma
"$AMSBIN/amsreport" step6.crskf sigma-profile
"$AMSBIN/amsreport" step6.crskf sigma-profile-hb
"$AMSBIN/amsreport" step7.crskf sigma-potential
echo "Ready"

Example: COSMO-RS properties

Download Properties.run

#! /bin/sh

# This example tries to do the same as COSMO-RS GUI Tutorial: Properties, using scripts.

echo "Results"

# This example starts with copying 4 coskf files to the current directory,
# and modifying the benzene.coskf file such that the number of ring atoms is 6,
# like in the previous example.

rm -f job.sh
cp $AMSHOME/examples/COSMO-RS/Parameters_and_Analysis/benzene.coskf .
cp $AMSHOME/examples/COSMO-RS/Parameters_and_Analysis/ethanol.coskf .
cp $AMSHOME/examples/COSMO-RS/Parameters_and_Analysis/methanol.coskf .
cp $AMSHOME/examples/COSMO-RS/Parameters_and_Analysis/water.coskf .

"$AMSBIN/crsprep" -c benzene.coskf -nring 6 -savecompound

# Step 2: Vapor pressure
# ----------------------

# In step 2 of the example the vapor pressure of methanol is calculated at the
# default temperature of 298.15 K (result file step2a.crskf),
# and next for a series of temperatures ranging from 273.15 K to 373.15 K
# in 10 steps (result file step2b.crskf).


touch job.sh
chmod +x job.sh
"$AMSBIN/crsprep" -t PUREVAPORPRESSURE -j step2a \
                  -c methanol.coskf > job.sh
"$AMSBIN/crsprep" -t PUREVAPORPRESSURE -temperature 273.15 -temperature 373.15 -j step2b \
                  -c methanol.coskf >> job.sh
./job.sh
echo "Step 2a"
"$AMSBIN/amsreport" step2a.crskf temperature
"$AMSBIN/amsreport" step2a.crskf pressure
"$AMSBIN/amsreport" step2a.crskf enthalpy-vaporization
echo "Step 2b"
"$AMSBIN/amsreport" step2b.crskf temperature
"$AMSBIN/amsreport" step2b.crskf pressure
"$AMSBIN/amsreport" step2b.crskf enthalpy-vaporization


# Step 3: Boiling point
# ---------------------

# In step 3 of the example the boiling point of a mixture of methanol and ethanol
# is calculated, for a series of pressures ranging from 0.101325 to 1.01325 bar
# in 10 steps (result file step3.crskf).
# This mixture consist of 50% mole fraction methanol and 50% mole fraction ethanol.

"$AMSBIN/crsprep" -t BOILINGPOINT -pressure 0.101325 -pressure 1.01325 -j step3 \
                  -c methanol.coskf -frac1 0.5 \
                  -c ethanol.coskf -frac1 0.5 > job.sh
./job.sh
echo "Step 3"
"$AMSBIN/amsreport" step3.crskf temperature
"$AMSBIN/amsreport" step3.crskf pressure


# Step 4: Flash point
# -------------------

# In step 4 of the example the flash point of a mixture of ethanol and water
# is calculated (result file step4.crskf).
# This mixture consist of 44.2% mass fraction methanol and 55.8% mass fraction ethanol.
# For a flash point calculation the pure compound flash points are needed as input,
# since COSMO-RS does not predict pure compound flash points.
# For pure ethanol a flash point of 286 K is saved in the file ethanol.coskf.


"$AMSBIN/crsprep" -c ethanol.coskf -flashpoint 286 -savecompound

"$AMSBIN/crsprep" -t FLASHPOINT -massfraction -j step4 \
                  -c ethanol.coskf -frac1 0.442 \
                  -c water.coskf -frac1 0.558 > job.sh
./job.sh
echo "Step 4 flash point"
$AMSBIN/amsreport step4.crskf temperature

# Step 5: Activity coefficients, Henry coefficients, Solvation free energies
# --------------------------------------------------------------------------

# In step 5 of the example the infinite diluted solutes benzene, methanol,and
# ethanol are calculated in the solvent water (result file step5.crskf).
# Activity coefficients, Henry coefficients and solvation free energies
# will be calculated.
# One one should include -s flag for water, since it is the solvent,
# and considered here to be a special compound.


"$AMSBIN/crsprep" -t ACTIVITYCOEF -j step5 \
                  -s water.coskf \
                  -c benzene.coskf -c ethanol.coskf -c methanol.coskf > job.sh
./job.sh
echo "Step 5 Activity coefficients, Henry's law constants, Solvation energy"
"$AMSBIN/amsreport" step5.crskf Activity-Coefficient
"$AMSBIN/amsreport" step5.crskf Henry
"$AMSBIN/amsreport" step5.crskf Gibbs-energy-solvation

# Step 6: Partition coefficients (log P)
# --------------------------------------

# In step 6 of the example the partition coefficients of infinitely diluted
# solutes in a mixture of two immiscible solvents are calculated.
# In step 6a the default Octanol/Water partition coefficients are calculated
# (default -preset 2) (result file step6a.crskf).
# In step 6b a user defined (-preset 0) Benzene/Water partition coefficients
# are calculated (result file step6b.crskf).
# In this case one should include -s flag for benzene and water, since these
# are the two immiscible solvents, and considered here to be the special compounds.
# The order of the compounds benzene and water is important, because the
# molar volume of phase 1 (benzene) divided by the the molar volume of phase 2
# (water) is given with the flag -volumequotient.


"$AMSBIN/crsprep" -t LOGP -j step6a \
                  -c benzene.coskf -c ethanol.coskf -c methanol.coskf > job.sh
"$AMSBIN/crsprep" -t LOGP -preset 0 -volumequotient 4.93 -j step6b \
                  -s benzene.coskf -s water.coskf \
                  -c ethanol.coskf -c methanol.coskf >> job.sh
./job.sh
echo "Step 6a octanol/water"
"$AMSBIN/amsreport" step6a.crskf logp
echo "Step 6b benzene/water"
"$AMSBIN/amsreport" step6b.crskf logp

# Step 7: Solubility
# ------------------

# In step 7 of the example the solubility of a compound is calculated.
# The solute can either be a liquid, solid, or gas.
# First some pure compound properties for benzene are set: the melting point,
# enthalpy of fusion, and the boiling point (file benzene.coskf).


"$AMSBIN/crsprep" -c benzene.coskf -meltingpoint 278.7 -hfusion 2.37 -savecompound
"$AMSBIN/crsprep" -c benzene.coskf -tvap 353.3 -pvap 1.01325 -savecompound

# In step 7a the solubility of benzene in water is calculated for a range of
# temperatures ranging from 273.15 K to 373.15 K in 10 steps (result file step7a.crskf).
# If the template PURESOLUBILITY is used, the special compound is the solute,
# benzene in this case.
# Below 278.7 K, benzene is a solid. This will be taken into account, since the
# melting point and enthalpy of fusion are present on the file benzene.coskf.
# At higher temperatures benzene is assumed to be a liquid.
# Note that tn this calcuation above the normal boiling point of benzene
# the vapor pressure of benzene will be higher than 1.01325 bar.

"$AMSBIN/crsprep" -t PURESOLUBILITY -temperature 273.15 -temperature 373.15 -j step7a \
                  -s benzene.coskf \
                  -c water.coskf > job.sh

# In step 7b again the solubility of benzene in water is calculated for a (different)
# range of temperatures (result file step7b.crs) using the template SOLUBILITY.
# If the template SOLUBILITY is used, the special compound is the solvent,
# water in this case.
# For the density of the solvent water 1.0 kg/L is used.
# Below 278.7 K benzene is a solid. This will be taken into account, since the melting
# point and enthalpy of fusion are present on the file benzene.coskf.
# At higher temperatures benzene is assumed to be a liquid.

"$AMSBIN/crsprep" -t SOLUBILITY -temperature 273.15 -temperature 283.15 \
                   -densitysolvent 1.0 -j step7b \
                  -s water.coskf \
                  -c benzene.coskf >> job.sh
# In step 7c again the solubility of benzene in water is calculated for a range
# of temperatures above the boiling point of benzene (result file step7c.crs)
# using the template SOLUBILITY.
# If the template SOLUBILITY is used, the special compound is the solvent,
# water in this case.
# For the density of water 1.0 kg/L is used.
# For the vapor pressure of benzene 1.01325 bar is used.

"$AMSBIN/crsprep" -t SOLUBILITY -temperature 353.3 -temperature 373.15 \
                  -densitysolvent 1.0 -solphase Gas -pressure 1.01325 -j step7c \
                  -s water.coskf \
                  -c benzene.coskf >> job.sh

# The solubility of a gas in a solvent can also be calculated using Henry's law,
# which is valid for ideal dilute solutions.
# Henry coefficients can be calculated with the template ACTIVITYCOEF.
# In step 7d of the example the infinite diluted solutes benzene is calculated
# in the solvent water (result file step7d.crskf)
# at a temperature of 363.15 K.
# If the template ACTIVITYCOEF is used, the special compound is the solvent,
# water in this case.
# For the density of water 1.0 kg/L is used.

"$AMSBIN/crsprep" -t ACTIVITYCOEF -temperature 363.15 -densitysolvent 1.0 -j step7d \
                  -s water.coskf \
                  -c benzene.coskf >> job.sh

# Next the job.sh is run which will produce the crskf files,
# and a report is made for all calculations in step 7.

./job.sh
echo "Step 7a"
"$AMSBIN/amsreport" step7a.crskf solubility-x
echo "Step 7b"
"$AMSBIN/amsreport" step7b.crskf solubility-g
echo "Step 7c"
"$AMSBIN/amsreport" step7c.crskf solubility-m
echo "Step 7d"
"$AMSBIN/amsreport" step7d.crskf henry


# Step 8: Binary mixtures VLE/LLE
# -------------------------------

# In step 8 phase diagrams of a mixture of two components are be calculated
# with the template BINMIXCOEF.
# Exactly two compound should be given.
# In step 8a of the example a binary mixture of water and methanol
# is calculated at 298.14 K (result file step8a.crskf).

"$AMSBIN/crsprep" -t BINMIXCOEF -temperature 298.14 -j step8a \
                  -s water.coskf \
                  -s methanol.coskf > job.sh

# In step 8b of the example a binary mixture of water and ethanol is calculated
# at 322.45 K (result file step8b.crskf).
# Pure compound vapor pressures are given with -tvap (temperature in K)
# and -pvap (vapor pressure in bar).
# Preferably both -tvap and -pvap should be included for both compounds.
# If only one -tvap and one -pvap is given, it is assumed to be for the first compound.
# Note that these pure compound values are not saved to water.coskf or
# ethanol.coskf in this case.


"$AMSBIN/crsprep" -t BINMIXCOEF -temperature 322.45 -j step8b \
                  -s water.coskf -tvap 322.45 -pvap 0.123416 \
                  -s ethanol.coskf -tvap 322.45 -pvap 0.294896 >> job.sh

# In step 8c of the example a binary mixture of water and benzene
# is calculated at 323.15 K (result file step8c.crskf).
# Water and benzene do not mix very well. In this case a
# liquid-liquid equilibrium (LLE) will be calculated.
# The number of mixtures for which the binary mixture is calculated should be not too small,
# otherwise the properties of the 2 immiscible liquid phases will not be so accurate.
# In this case for the number of mixtures 100 is chosen.
# The actual number of mixtures is 5 more, thus 105 in this case.

"$AMSBIN/crsprep" -t BINMIXCOEF -temperature 323.15 -n 100 -j step8c \
                  -s water.coskf \
                  -s benzene.coskf >> job.sh

# In step 8d of the example a binary mixture of methanol and ethanol is calculated
# at a constant total vapor pressure (-iso isobar) of 1.01325 bar (result file step8d.crskf).
# Pure compound vapor pressures are given with -tvap (temperature in K)
# and -pvap (vapor pressure in bar).
# Preferably both -tvap and -pvap should be included for both compounds.
# If only one -tvap and one -pvap is given, it is assumed to be for the first compound.
# Note that these pure compound values are not saved to methanol.coskf
# or ethanol.coskf in this case.

"$AMSBIN/crsprep" -t BINMIXCOEF -iso isobar -pressure 1.01325 -j step8d \
                  -s methanol.coskf -tvap 338 -pvap 1.01325 \
                  -s ethanol.coskf -tvap 351 -pvap 1.01325 >> job.sh

# Next the job.sh is run which will produce the crskf files,
# and a report is made for all calculations in step 8.

./job.sh
echo "Step 8a"
"$AMSBIN/amsreport" step8a.crskf molar-fraction
"$AMSBIN/amsreport" step8a.crskf excess-g
"$AMSBIN/amsreport" step8a.crskf excess-h
echo "Step 8b"
"$AMSBIN/amsreport" step8b.crskf vapor-pressure
echo "Step 8c"
"$AMSBIN/amsreport" step8c.crskf miscibility-gap
"$AMSBIN/amsreport" step8c.crskf miscibility-gap-x
"$AMSBIN/amsreport" step8c.crskf miscibility-gap-a
echo "Step 8d"
"$AMSBIN/amsreport" step8d.crskf temperature


# Step 9: Ternary mixtures VLE/LLE
# --------------------------------
# 
# In step 9 phase diagrams of a mixture of three components are be calculated
# with the template TERNARYMIX.
# Exactly three compound should be given.
# For convenience first some pure compound properties (normal boiling points)
# are saved to the .coskf files.


"$AMSBIN/crsprep" -c water.coskf    -tvap 373.15 -pvap 1.01325 -savecompound
"$AMSBIN/crsprep" -c methanol.coskf -tvap 338    -pvap 1.01325 -savecompound
"$AMSBIN/crsprep" -c ethanol.coskf  -tvap 351    -pvap 1.01325 -savecompound
"$AMSBIN/crsprep" -c benzene.coskf  -tvap 353.3  -pvap 1.01325 -savecompound

# In step 9a of the example a ternary mixture of methanol, ethanol, and benzene
# is calculated at 343.15 K (result file step9a.crskf).
# In step 9b of the example a ternary mixture of water, ethanol, and benzene is calculated
# at a constant total vapor pressure (-iso isobar) of 1.01325 bar (result file step9b.crskf).
# In step 9b a miscibility gap of the ternary mixture will be calculated.
# In this case, within the miscibility gap there are two immiscible phases of
# the liquid in equilibrium.
# The composition of the two phases, which are in equilibrium,
# can be found at the end points of the tie lines, that are calculated.

"$AMSBIN/crsprep" -t TERNARYMIX -temperature 343.15 -j step9a \
                  -s methanol.coskf -s ethanol.coskf -s benzene.coskf  > job.sh
"$AMSBIN/crsprep" -t TERNARYMIX -iso isobar -pressure 1.01325 -j step9b \
                  -s water.coskf -s ethanol.coskf -s benzene.coskf >> job.sh
./job.sh
echo "Step 9a"
"$AMSBIN/amsreport" step9a.crskf molar-fraction
"$AMSBIN/amsreport" step9a.crskf pressure
"$AMSBIN/amsreport" step9a.crskf miscibility-gap
echo "Step 9b"
"$AMSBIN/amsreport" step9b.crskf miscibility-gap
echo "First 4 tie-lines"
"$AMSBIN/amsreport" step9b.crskf -r "TERNARYMIX%xll#1:24#12.4f##6"
"$AMSBIN/amsreport" step9b.crskf temperature

# Note that for printing all tie-lines that are calculated in step9b one can simply use
# "$AMSBIN/amsreport" step9b.crskf tie-lines-x
# instead of the more complicated
# "$AMSBIN/amsreport" step9b.crskf -r "TERNARYMIX%xll#1:24#12.4f##6"
# which also only reports the first 4 tie-lines

# Step 10: A composition line between solvents s1 and s2
# ------------------------------------------------------

# In step 10 a phase diagram of a mixture of two solvents, which both are mixtures,
# is calculated with the template COMPOSITIONLINE.
# In this step one of the tie lines of the ternary mixture of water, ethanol, and benzene
# of step 9b will be investigated in more detail.
# Note that here the .coskf files are used in which the normal boiling points were saved to (in step 9).
# The mixture will be calculated for a list of molar (or mass) fractions of the solvents
# between zero and one, and the compositions of solvent 1 and solvent 2 are linearly interpolated.
# In this case solvent 1 consists of 0.3 molar fraction ethanol and 0.7 molar fraction benzene, and
# solvent 2 consists of 0.9 molar fraction water and 0.1 molar fraction ethanol.
# In step 10a of the example this mixture is calculated at a constant total vapor pressure (-iso isobar)
# of 1.01325 bar (result file step10a.crskf).
# In step 10b of the example this mixture is calculated at 341.05 K (result file step10b.crskf).
# Why this temperature was chosen can be found in step 10 of COSMO-RS GUI Tutorial: Properties.

"$AMSBIN/crsprep" -t COMPOSITIONLINE -iso isobar -pressure 1.01325 -n 100 -j step10a \
                  -s water.coskf   -frac1 0.0 -frac2 0.9 \
                  -s ethanol.coskf -frac1 0.3 -frac2 0.1 \
                  -s benzene.coskf -frac1 0.7 -frac2 0.0 > job.sh
"$AMSBIN/crsprep" -t COMPOSITIONLINE -temperature 341.05 -n 100 -j step10b \
                  -s water.coskf   -frac1 0.0 -frac2 0.9 \
                  -s ethanol.coskf -frac1 0.3 -frac2 0.1 \
                  -s benzene.coskf -frac1 0.7 -frac2 0.0 >> job.sh
./job.sh
echo "Step 10a"
$AMSBIN/amsreport step10a.crskf ncomp
$AMSBIN/amsreport step10a.crskf frac1
$AMSBIN/amsreport step10a.crskf frac2
$AMSBIN/amsreport step10a.crskf solvent-fraction
$AMSBIN/amsreport step10a.crskf molar-fraction
$AMSBIN/amsreport step10a.crskf activity-coefficient

echo "Step 10b"
$AMSBIN/amsreport step10b.crskf Gibbs-energy-mixing

# Step 11: Pure Compound Properties
# ---------------------------------

# In step 11 a QSPR (Quantitative Structure-Property Relationship) method is used
# to estimate some pure compound properties. 
# This QSPR method needs a SMILES string as input.

echo "Step 11"
"$AMSBIN"/prop_prediction --smiles "c1ccccc1" --boilingpoint -d

# Step 12: Solvent Optimizations: Optimize Solubility
# ---------------------------------------------------

# In this step a solvent is optimized in order to maximize or minimize
# the mole fraction solubility of a solid solute in the liquid mixture.

echo "Step 12"
"$AMSBIN"/solvent_opt -t SOLUBILITY -method COSMO-RS -temperature 273.15 -max \
                      -c "benzene.coskf" -solute -meltingpoint 278.7 -hfusion 2.37 \
                      -c "ethanol.coskf" -c "methanol.coskf" -c "water.coskf" -d > max_solubility
grep benzene.coskf max_solubility
grep " ethanol.coskf" max_solubility
"$AMSBIN"/solvent_opt -t SOLUBILITY -method COSMO-RS -temperature 273.15 -min \
                      -c "benzene.coskf" -solute -meltingpoint 278.7 -hfusion 2.37 \
                      -c "ethanol.coskf" -c "methanol.coskf" -c "water.coskf" -d > min_solubility
grep benzene.coskf min_solubility
grep water.coskf min_solubility

# Step 13: Solvent Optimizations: Optimize Liquid-Liquid Extraction
# -----------------------------------------------------------------

# In this step a mixture of immiscible solvents is optimized in order to maximize or minimize
# the distribution ratio (D) of two solutes between the two liquid phases. 

"$AMSBIN"/solvent_opt -t LLEXTRACTION -method COSMO-RS -multistart 5 -temperature 298.15 -max -warmstart \
                      -c "ethanol.coskf" -solute  -c "methanol.coskf" -solute \
                      -c "benzene.coskf" -c "water.coskf" -d > max_lle

echo "Step 13"
"$AMSBIN/amsreport" CRSKF -r "OPT_LLEXTRACTION%obj#8.3f"

echo "Ready"

Example: The COSMO-RS compound database

Download Database.run

#! /bin/sh

# This example tries to do the same as in the COSMO-RS GUI Tutorial: The COSMO-RS compound database,
# using scripts.
# In many of the next examples fewer compounds are included than in the COSMO-RS GUI Tutorial.


# First some .coskf files are copied to the location where the scripts are running.
# These .coskf files are a sample of the full database.

echo "Results"

cp $AMSHOME/examples/COSMO-RS/Database/*coskf .

rm -f job.sh
touch job.sh
chmod +x job.sh

# 4.2 Octanol-Water partition coefficients (log P_OW)
# ---------------------------------------------------

"$AMSBIN/crsprep" -t LOGP -j t4.2 \
                  -c Methanol.coskf > job.sh
./job.sh
echo "4.2"
"$AMSBIN/amsreport" t4.2.crskf compounds-name
"$AMSBIN/amsreport" t4.2.crskf logp



# 4.3: Henry's law constants
# --------------------------

"$AMSBIN/crsprep" -t ACTIVITYCOEF -temperature 293.15 -densitysolvent 0.998 -j t4.3a \
                  -s Water.coskf \
                  -c Acetone.coskf -c Benzene.coskf -c Ethanol.coskf -c Methanol.coskf > job.sh
./job.sh
echo "4.3a"
"$AMSBIN/amsreport" t4.3a.crskf compounds-name
"$AMSBIN/amsreport" t4.3a.crskf henry

"$AMSBIN/crsprep" -s Acetone.coskf  -pvap 0.246 -tvap 293.15 -savecompound
"$AMSBIN/crsprep" -s Benzene.coskf  -pvap 0.100 -tvap 293.15 -savecompound
"$AMSBIN/crsprep" -s Ethanol.coskf  -pvap 0.059 -tvap 293.15 -savecompound
"$AMSBIN/crsprep" -s Methanol.coskf -pvap 0.129 -tvap 293.15 -savecompound
"$AMSBIN/crsprep" -s Water.coskf    -pvap 0.02536 -tvap 293.15 -savecompound

"$AMSBIN/crsprep" -t ACTIVITYCOEF -temperature 293.15 -densitysolvent 0.998 -j t4.3b \
                  -s Water.coskf \
                  -c Benzene.coskf -c Ethanol.coskf -c Methanol.coskf > job.sh
./job.sh
echo "4.3b"
"$AMSBIN/amsreport" t4.3b.crskf henry


# 4.4: Solubility of Vanillin in organic solvents
# -----------------------------------------------

"$AMSBIN/crsprep" -s Vanillin.coskf -meltingpoint 355 -hfusion 5.35 -savecompound
"$AMSBIN/crsprep" -t PURESOLUBILITY -j t4.4 \
                  -s Vanillin.coskf \
                  -c Ethanol.coskf -c Methanol.coskf -c Water.coskf > job.sh
./job.sh
echo "4.4"
"$AMSBIN/amsreport" t4.4.crskf compounds-name
"$AMSBIN/amsreport" t4.4.crskf solubility-x
"$AMSBIN/amsreport" t4.4.crskf solubility-m

# 4.5: Binary mixture of Methanol and Hexane
# ------------------------------------------

"$AMSBIN/crsprep" -s Methanol.coskf -pvap 0.845 -tvap 333.15 -savecompound
"$AMSBIN/crsprep" -s Hexane.coskf   -pvap 0.77  -tvap 333.15 -savecompound
"$AMSBIN/crsprep" -t BINMIXCOEF -temperature 333.15 -n 100 -j t4.5a \
                  -s Methanol.coskf \
                  -s Hexane.coskf > job.sh
./job.sh
echo "4.5a"
"$AMSBIN/amsreport" t4.5a.crskf compounds-name
"$AMSBIN/amsreport" t4.5a.crskf molar-fraction
"$AMSBIN/amsreport" t4.5a.crskf pressure
"$AMSBIN/amsreport" t4.5a.crskf miscibility-gap
"$AMSBIN/amsreport" t4.5a.crskf miscibility-gap-x
"$AMSBIN/amsreport" t4.5a.crskf miscibility-gap-a

"$AMSBIN/crsprep" -s Methanol.coskf -pvap 1.01325 -tvap 337.8 -savecompound
"$AMSBIN/crsprep" -s Hexane.coskf   -pvap 1.01325 -tvap 342   -savecompound
"$AMSBIN/crsprep" -t BINMIXCOEF -pressure 1.01325 -iso isobar -n 100 -j t4.5b \
                  -s Methanol.coskf \
                  -s Hexane.coskf > job.sh
./job.sh
echo "4.5b"
"$AMSBIN/amsreport" t4.5b.crskf molar-fraction
"$AMSBIN/amsreport" t4.5b.crskf temperature
"$AMSBIN/amsreport" t4.5b.crskf miscibility-gap
"$AMSBIN/amsreport" t4.5b.crskf miscibility-gap-x
"$AMSBIN/amsreport" t4.5b.crskf miscibility-gap-a

# 4.6: Large infinite dilution activity coefficients in Water
# -----------------------------------------------------------

"$AMSBIN/crsprep" -t ACTIVITYCOEF -temperature 298.15 -j t4.6 \
                  -s Water.coskf \
                  -c Benzene.coskf > job.sh
./job.sh
echo "4.6"
"$AMSBIN/amsreport" t4.6.crskf compounds-name
"$AMSBIN/amsreport" t4.6.crskf activity-coefficient


# 4.7: Parametrization of ADF COSMO-RS: solvation energies,
# vapor pressures, partition coefficients
# ---------------------------------------------------------

cat << eor > small.compoundlist
Hexane.coskf
Methanol.coskf
Ethanol.coskf
Acetone.coskf
Benzene.coskf
Water.coskf
eor

"$AMSBIN/crsprep" -t ACTIVITYCOEF -temperature 298.15 -densitysolvent 0.997 -j t4.7a \
                  -inputpurevap 0 \
                  -s Water.coskf \
                  -c small.compoundlist > job.sh
./job.sh
echo "4.7a"
"$AMSBIN/amsreport" t4.7a.crskf compounds-name
"$AMSBIN/amsreport" t4.7a.crskf gibbs-energy-solvation

"$AMSBIN/crsprep" -t PUREVAPORPRESSURE -temperature 298.15 -j t4.7b \
                  -c small.compoundlist -inputpurevap 0 > job.sh
./job.sh
echo "4.7b"
"$AMSBIN/amsreport" t4.7b.crskf compounds-name
"$AMSBIN/amsreport" t4.7b.crskf vapor-pressure

"$AMSBIN/crsprep" -t LOGP -j t4.7c -c small.compoundlist > job.sh
./job.sh
echo "4.7c Octanol/Water"
"$AMSBIN/amsreport" t4.7c.crskf compounds-name
"$AMSBIN/amsreport" t4.7c.crskf logp

"$AMSBIN/crsprep" -t LOGP -preset 5 -j t4.7d -c small.compoundlist > job.sh
./job.sh
echo "4.7d Hexane/Water"
"$AMSBIN/amsreport" t4.7d.crskf logp

"$AMSBIN/crsprep" -t LOGP -preset 3 -j t4.7e -c small.compoundlist > job.sh
./job.sh
echo "4.7e Benzene/Water"
"$AMSBIN/amsreport" t4.7e.crskf logp

"$AMSBIN/crsprep" -t LOGP -preset 4 -j t4.7f -c small.compoundlist > job.sh
./job.sh
echo "4.7f Ether/Water"
"$AMSBIN/amsreport" t4.7f.crskf logp


# 4.8: COSMO-SAC 2013-ADF
# -----------------------

"$AMSBIN/crsprep" -t PURESIGMAPROFILE -method COSMOSAC2013 -c Water.coskf \
                  -c Ethanol.coskf -j t4.8a > job.sh
./job.sh
echo "4.8a"
"$AMSBIN/amsreport" t4.8a.crskf sigma
"$AMSBIN/amsreport" t4.8a.crskf sigma-profile
"$AMSBIN/amsreport" t4.8a.crskf sigma-profile-hb

"$AMSBIN/crsprep" -s Methanol.coskf -density 0.7918  -savecompound
"$AMSBIN/crsprep" -s Ethanol.coskf  -density 0.789  -savecompound
"$AMSBIN/crsprep" -s Acetone.coskf  -density 0.791  -savecompound

"$AMSBIN/crsprep" -t LOGP -method COSMOSAC2013 -j t4.8b \
                  -c Methanol.coskf -c Ethanol.coskf -c Acetone.coskf > job.sh
./job.sh
echo "4.8b Octanol/Water"
"$AMSBIN/amsreport" t4.8b.crskf compounds-name
"$AMSBIN/amsreport" t4.8b.crskf logp

"$AMSBIN/crsprep" -t LOGP -method COSMOSAC2013 -preset 5 -j t4.8c \
                  -c Methanol.coskf -c Ethanol.coskf -c Acetone.coskf > job.sh
./job.sh
echo "4.8c Hexane/Water"
"$AMSBIN/amsreport" t4.8c.crskf logp

"$AMSBIN/crsprep" -t LOGP -method COSMOSAC2013 -preset 3 -j t4.8d \
                  -c Methanol.coskf -c Ethanol.coskf -c Acetone.coskf > job.sh
./job.sh
echo "4.8d Benzene/Water"
"$AMSBIN/amsreport" t4.8d.crskf logp

"$AMSBIN/crsprep" -t LOGP -method COSMOSAC2013 -preset 4 -j t4.8e \
                  -c Methanol.coskf -c Ethanol.coskf -c Acetone.coskf > job.sh
./job.sh
echo "4.8e Ether/Water"
"$AMSBIN/amsreport" t4.8e.crskf logp

"$AMSBIN/crsprep" -s Acetone.coskf -density 0.791 -pvap 3.7     -tvap 373.15 -savecompound
"$AMSBIN/crsprep" -s Water.coskf   -density 0.997 -pvap 1.01325 -tvap 373.15 -savecompound

"$AMSBIN/crsprep" -t BINMIXCOEF -method COSMOSAC2013 -temperature 373.15 -n 20 -j t4.8f \
                  -s Acetone.coskf \
                  -s Water.coskf > job.sh
./job.sh
echo "4.8f"
"$AMSBIN/amsreport" t4.8f.crskf molar-fraction
"$AMSBIN/amsreport" t4.8f.crskf vapor-pressure
"$AMSBIN/amsreport" t4.8f.crskf pressure

echo "Ready"

Example: pKa values

Download pKa.run

#! /bin/sh

# This example tries to do the same as in the COSMO-RS GUI Tutorial: pKa values,
# using scripts
# First some .coskf files are copied to the location where the scripts are running,
# next the jobs are prepared and the reports are made.
# Check the COSMO-RS GUI Tutorial: pKa values to see what to do with the results.

echo "Results"

rm -f job.sh
cp $AMSHOME/examples/COSMO-RS/pKa/*.coskf .
cp $AMSHOME/examples/COSMO-RS/pKa/*compoundlist .

touch job.sh
chmod +x job.sh

echo "Acids"
"$AMSBIN/crsprep" -t ACTIVITYCOEF -j t5.1a \
                  -c tutoral5.1_acid.compoundlist > job.sh
./job.sh
"$AMSBIN/amsreport" t5.1a.crskf compounds-name
"$AMSBIN/amsreport" t5.1a.crskf Activity-Coefficient
"$AMSBIN/amsreport" t5.1a.crskf Gibbs-energy-solvation
"$AMSBIN/amsreport" t5.1a.crskf Gibbs-energy-solute

"$AMSBIN/crsprep" -t ACTIVITYCOEF -j t5.1b \
                  -c tutoral5.1_base.compoundlist > job.sh
./job.sh
"$AMSBIN/amsreport" t5.1b.crskf compounds-name
"$AMSBIN/amsreport" t5.1b.crskf Activity-Coefficient
"$AMSBIN/amsreport" t5.1b.crskf Gibbs-energy-solvation
"$AMSBIN/amsreport" t5.1b.crskf Gibbs-energy-solute

echo "Ready"

Example: Polymers

Download Polymers.run

#! /bin/sh

# This example tries to do the same as in the COSMO-RS GUI Tutorial: Polymers,
# using scripts.

# First some .coskf files are copied to the location where the scripts are running.
# Some of the .coskf files are a sample of the full polymer database ADFCRS-POLYMERS-2019.
# In the first part of the example crsprep is used to set pure compound parameters.
# Pure compound densities are required for every species in a calculation involving any polymers.
# For some pure compounds the VPM1 vapor pressure equation is set including vapor pressure coefficients.

echo "Results"

cp $AMSHOME/examples/COSMO-RS/Database/*coskf .
cp $AMSHOME/examples/COSMO-RS/Polymers/*coskf .

"$AMSBIN/crsprep" -c Benzene.coskf -density 0.876 -savecompound
"$AMSBIN/crsprep" -c Water.coskf -density 1.0 -savecompound
"$AMSBIN/crsprep" -c Methanol.coskf -density 0.792 -savecompound \
                  -vp_equation VPM1 -vp_params "-7057.597287 -9.936895562 0.00608530790 77.10002032 0"
"$AMSBIN/crsprep" -c Hexane.coskf -density 0.655 -savecompound \
                  -vp_equation VPM1 -vp_params "-5575.417318 -6.612402250 0.00437376138 53.36969532 0"

rm -f job.sh
touch job.sh
chmod +x job.sh

"$AMSBIN/crsprep" -t ACTIVITYCOEF -j Polymers.1 \
                  -s "Poly(ethylene).coskf" -frac1 0.5 -s Benzene.coskf -frac1 0.5 \
                  -massfraction > job.sh
./job.sh
echo "Polymers.1"
"$AMSBIN/amsreport" Polymers.1.crskf compounds-name Flory-Huggins WF-activity-coefficient

"$AMSBIN/crsprep" -t VAPORPRESSURE -temperature 298.15 -temperature 398.15 -n 10 -j Polymers.2 \
                  -s "Poly(dimethylsiloxane).coskf" -frac1 0.5 -s Methanol.coskf -frac1 0.25 \
                  -s Hexane.coskf -frac1 0.25 \
                  -massfraction > job.sh
./job.sh
echo "Polymers.2"
"$AMSBIN/amsreport" Polymers.2.crskf compounds-name temperature pressure

"$AMSBIN/crsprep" -t LOGP -preset 0 -j Polymers.3 \
                  -s "Poly(ethylene).coskf" -s Water.coskf \
                  -c Methanol.coskf > job.sh
./job.sh
echo "Polymers.3"
"$AMSBIN/amsreport" Polymers.3.crskf logp

"$AMSBIN/crsprep" -t PURESOLUBILITY -temperature 398.15 -temperature 498.15 -n 10 -j Polymers.4 \
                  -s Hexane.coskf -solphase Gas -pressure 1.01325 \
                  -c "Poly(styrene).coskf" > job.sh
./job.sh
echo "Polymers.4"
"$AMSBIN/amsreport" Polymers.4.crskf solubility-g

"$AMSBIN/crsprep" -t BINMIXCOEF -method COSMOSAC2013 -j Polymers.5 \
                  -s "Poly(ethyl_ethylene).coskf" -s Benzene.coskf \
                  -massfraction > job.sh
./job.sh
echo "Polymers.5"
"$AMSBIN/amsreport" Polymers.5.crskf polymer-fraction Flory-Huggins

echo "Ready"