Exemple #1
0
 def test_dsp(self):
     mycosmo = cosmo.Cosmo()
     mycosmo.load(filename)
     mol = mycosmo.mol
     disp_eps, disp_type = mol.get_dispersion_type()
     self.assertAlmostEqual(disp_eps, 97.15234615384617, 9)
     self.assertEqual(disp_type, "COOH")
Exemple #2
0
import os
import unittest
import numpy as np
from pycosmosac.cosmo import cosmo
from pycosmosac.utils import misc

here = os.path.abspath(os.path.dirname(__file__))
filename = here + "/h2o.cosmo"
mycosmo = cosmo.Cosmo()


class KnownValues(unittest.TestCase):
    def test_load(self):
        mycosmo.load(filename)
        mol = mycosmo.mol
        xyz = mol.geometry["xyz"]
        atom = mol.geometry["atom"]
        self.assertAlmostEqual(misc.fp(xyz), -1.3049969366762706, 8)
        self.assertEqual(atom, ['O', 'H', 'H'])
        cavity = mol.cavity
        total_area = cavity.area
        self.assertAlmostEqual(total_area, 43.223568, 8)
        total_volume = cavity.volume
        self.assertAlmostEqual(total_volume, 25.661981, 8)
        segments = cavity.segments
        charge = segments["charge"]
        area = segments["area"]
        self.assertAlmostEqual(np.sum(area), total_area, 6)
        sigma = charge / area
        sigma0 = segments["sigma"]
        self.assertTrue(np.allclose(sigma, sigma0) == True)
Exemple #3
0
from pycosmosac.cosmo import cosmo
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
Exemple #4
0
            lngamma += lngamma_r(self.mols, self.sigmas, self.x, self.T, self.parameters.parameters, self.solve_gamma_thresh, self.solve_gamma_maxiter)
        else:
            lngamma += lngamma_r3(self.mols, self.sigmas, self.x, self.T, self.parameters.parameters, self.solve_gamma_thresh, self.solve_gamma_maxiter)
        if self.dispersion:
            lngamma += lngamma_dsp(self.mols, self.sigmas, self.x, self.parameters.parameters)
        return lngamma


if __name__ == "__main__":
    from pycosmosac.param import parameters, data
    from pycosmosac.cosmo import cosmo
    from pycosmosac.sigma import sigma

    myparam = parameters.Parameters()

    mol1 = cosmo.Cosmo().load("./test/butane.cosmo")
    sigma1 = sigma.Sigma(mol1, myparam)
    sigma1.write_sigma_file = False
    sigma1.kernel()

    mol2 = cosmo.Cosmo().load("./test/h2o.cosmo")
    sigma2 = sigma.Sigma(mol2, myparam)
    sigma2.write_sigma_file = False
    sigma2.kernel()

    x = [0., 1.]
    T = 298.15
    myac = AC([mol1,mol2], x, T, [sigma1,sigma2], myparam)
    print(myac.kernel() - np.asarray([10.05271196, 0.0]))

    myparam = parameters.Parameters(data.Hsieh_2010)
Exemple #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.ac import ac

here = os.path.abspath(os.path.dirname(__file__))
mol1 = cosmo.Cosmo().load(here + "/butane.cosmo")
mol2 = cosmo.Cosmo().load(here + "/h2o.cosmo")
x = [0., 1.]
T = 298.15


class KnownValues(unittest.TestCase):
    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])))