def test_check(self): '''Can we validate a system object?''' types = ['A', 'B', 'C'] sys = pyPRISM.System(types) self.assertRaises(ValueError, sys.check) # These values make no sense but their sufficient # for this 'check' sys.domain = pyPRISM.Domain(dr=0.1, length=1024) sys.density[sys.types] = 1.0 sys.diameter[sys.types] = 1.0 sys.potential.setUnset(1.0) sys.closure.setUnset(1.0) sys.omega.setUnset(1.0) #test should fail if this raises try: sys.check() except ValueError: self.fail('Check failed when it should have passed...')
def test_createPRISM(self): '''Can we construct a simple but fully specified PRISM problem?''' sys = pyPRISM.System(['A', 'B']) sys.domain = pyPRISM.Domain(dr=0.1, length=1024) sys.density['A'] = 0.45 sys.density['B'] = 0.35 sys.diameter[sys.types] = 1.0 sys.closure.setUnset(pyPRISM.closure.PercusYevick()) sys.potential.setUnset(pyPRISM.potential.HardSphere(sigma=1.0)) sys.omega['A', 'A'] = pyPRISM.omega.SingleSite() sys.omega['A', 'B'] = pyPRISM.omega.NoIntra() sys.omega['B', 'B'] = pyPRISM.omega.Gaussian(sigma=1.0, length=100) PRISM = sys.createPRISM() self.assertIsInstance(PRISM, pyPRISM.core.PRISM.PRISM)
def setup(self): '''Construct a simple but fully specified PRISM problem''' sys = pyPRISM.System(['A', 'B']) sys.domain = pyPRISM.Domain(dr=0.1, length=1024) sys.density['A'] = 0.1 sys.density['B'] = 0.75 sys.diameter[sys.types] = 1.0 sys.closure.setUnset(pyPRISM.closure.PercusYevick()) sys.potential.setUnset(pyPRISM.potential.HardSphere(sigma=1.0)) sys.omega['A', 'A'] = pyPRISM.omega.SingleSite() sys.omega['A', 'B'] = pyPRISM.omega.NoIntra() sys.omega['B', 'B'] = pyPRISM.omega.Gaussian(sigma=1.0, length=10000) PRISM = sys.createPRISM() return PRISM
#sys.path.append(os.path.join(cwd,'pyPRISMpackage/pyPRISM')) import pyPRISM import pyPRISM print(pyPRISM.__file__) import numpy as np import matplotlib.pyplot as plt import scipy as sp sigma = 1. scale = 1 kbT = 1. dr = 0.003 power = 14 # 2**power == # grid points; therefore length = dr*2**power sys = pyPRISM.System(['A'], kT=kbT) sys.domain = pyPRISM.Domain(dr=dr, length=2**power) print('r =', sys.domain.r) print('k = ', sys.domain.k) sys.diameter['A'] = dr sys.omega['A', 'A'] = pyPRISM.omega.SingleSite() def cust_norm(_GammaIn, _GammaOut): _diff = np.subtract(_GammaOut, _GammaIn) _diff = np.sum(_diff**2) _diff = np.divide(_diff, np.sum(_GammaOut**2)) return _diff
def test_create(self): '''Can we create a system?''' types = ['A', 'B', 'C'] sys = pyPRISM.System(types)