Ejemplo n.º 1
0
    def test_infinity_dilution(self):
        myparam = parameters.Parameters()
        sigma1 = sigma.Sigma(mol1, myparam)
        sigma1.write_sigma_file = False
        sigma1.kernel()
        sigma2 = sigma.Sigma(mol2, myparam)
        sigma2.write_sigma_file = False
        sigma2.kernel()

        myac = ac.AC([mol1, mol2], x, T, [sigma1, sigma2], myparam)
        myac.solve_gamma_thresh = 1e-6
        myac.solve_gamma_maxiter = 500
        self.assertTrue(
            np.allclose(myac.kernel(), np.asarray([10.05122252, 0.0])))
Ejemplo n.º 2
0
 def test_infinity_dilution3(self):
     myparam = parameters.Parameters(data.Hsieh_2010)
     sigma1 = sigma.Sigma(mol1, myparam)
     sigma1.write_sigma_file = False
     sigma1.split_sigma = True
     sigma1.kernel()
     sigma2 = sigma.Sigma(mol2, myparam)
     sigma2.write_sigma_file = False
     sigma2.split_sigma = True
     sigma2.kernel()
     myac = ac.AC([mol1, mol2], x, T, [sigma1, sigma2], myparam)
     myac.solve_gamma_thresh = 1e-6
     myac.solve_gamma_maxiter = 500
     self.assertTrue(
         np.allclose(myac.kernel(), np.asarray([8.81631154, 0.0])))
Ejemplo n.º 3
0
 def test_dispersion(self):
     myparam = parameters.Parameters(data.Hsieh_2010)
     sigma1 = sigma.Sigma(mol1, myparam)
     sigma1.write_sigma_file = False
     sigma1.split_sigma = True
     sigma1.kernel()
     sigma2 = sigma.Sigma(mol2, myparam)
     sigma2.write_sigma_file = False
     sigma2.split_sigma = True
     sigma2.kernel()
     myac = ac.AC([mol1, mol2], x, T, [sigma1, sigma2], myparam)
     myac.solve_gamma_thresh = 1e-6
     myac.solve_gamma_maxiter = 500
     myac.dispersion = True
     self.assertTrue(
         np.allclose(myac.kernel(), np.asarray([9.55918891, 0.])))
Ejemplo n.º 4
0
from pycosmosac.sigma import sigma
from pycosmosac.ac import ac
from pycosmosac.utils import thermo
'''
An example to compute hydration free energy of carbofuran
'''

path = os.path.abspath(os.path.dirname(__file__)) + "/"

#load parameters
myparam = parameters.Parameters(parameters=data.BIOSAC_SVP_GEPOL)

#compute sigma profile for solute
solute = "carbofuran"
mol1 = cosmo.Cosmo().load(path + solute + ".cosmo")
sigma1 = sigma.Sigma(mol1, myparam)
#whether or not to write the sigma file
sigma1.write_sigma_file = False
sigma1.sigma_filename = solute + ".sigma"
#default bounds for the grid; if "bounds too narrow" error occures, increase the numbers
sigma1.bounds = [-0.025, 0.025]
sigma1.kernel()

#compute sigma profile for solvent
solvent = "h2o"
mol2 = cosmo.Cosmo().load(path + solvent + ".cosmo")
sigma2 = sigma.Sigma(mol2, myparam)
sigma2.write_sigma_file = False
sigma2.sigma_filename = solvent + ".sigma"
#bounds should be consistent for every component in the solution
sigma2.bounds = [-0.025, 0.025]
Ejemplo n.º 5
0
import os
import unittest
import numpy as np
from pycosmosac.param import parameters, data
from pycosmosac.cosmo import cosmo
from pycosmosac.sigma import sigma
from pycosmosac.utils import misc

here = os.path.abspath(os.path.dirname(__file__))

mycosmo = cosmo.Cosmo()
mol = mycosmo.load(here+"/h2o.cosmo")

param1 = parameters.Parameters()
sigma1 = sigma.Sigma(mol, param1)
sigma1.write_sigma_file = False
sigma1.kernel()

param3 = parameters.Parameters(data.Hsieh_2010)
sigma3 = sigma.Sigma(mol, param3)
sigma3.split_sigma = True
sigma3.write_sigma_file = False
sigma3.kernel()

class KnownValues(unittest.TestCase):
    def test_sigma(self):
        self.assertAlmostEqual(misc.fp(sigma1.pA), -1.917622937152116, 8)

    def test_sigma3(self):
        self.assertTrue(np.allclose(sigma3.pA, sigma3.pA_nhb + sigma3.pA_oh + sigma3.pA_ot))
        self.assertAlmostEqual(misc.fp(sigma3.pA_nhb), 0.049856600131970685, 8)