def test_good_init(self): if (self.__dnacc): fail = False try: potential.DNACC(**self.__params) except: fail = True self.assertFalse(fail)
def test_reduce(self): if (self.__dnacc): res = potential.DNACC(**self.__params) red = res.__reduce__() x = dict(zip(res.__pnames__(), red[1])) red[0](**x) fail = False try: red[0](**x) except: fail = True self.assertFalse(fail)
def test_potential_1(self): if (self.__dnacc): try: import dnacc from dnacc.units import nm except: pass else: self.__params = { "r1": 500, "r2": 500, "lengths": { "A": 20, "B": 20 }, "sigma1": { "A": 1 / 20.**2 }, "sigma2": { "B": 1 / 20.**2 }, "beta_DeltaG0": { ("A", "A"): 0, ("A", "B"): -8, ("B", "B"): 0 } } res = potential.DNACC(**self.__params) r = numpy.linspace(41 / 1000., 41, 1000) + 500. + 500. u, f = res.evaluate_array(r) # Example from documentation plates = dnacc.PlatesMeanField() plates.add_tether_type(plate='lower', sticky_end='alpha', L=20 * nm, sigma=1 / (20 * nm)**2) plates.add_tether_type(plate='upper', sticky_end='alphap', L=20 * nm, sigma=1 / (20 * nm)**2) plates.beta_DeltaG0['alpha', 'alphap'] = -8 plates.at(41 * nm).set_reference_now() V_plate_arr = [ plates.at(rv - 1000.).free_energy_density for rv in r ] R = 500 * nm V_sphere_arr = dnacc.calc_spheres_potential( r - 1000., V_plate_arr, R) # Compare results over the domain of the theory self.assertTrue(numpy.allclose(V_sphere_arr, u)) # Check that potential is zero beyond cutoff self.assertEqual(res.evaluate(r[-1] + 0.00001), (0.0, 0.0)) # Check that WCA-esque potential wall is used at contact and below rep_wallu, rep_wallf = res.evaluate_array( numpy.linspace(0, r[0], 1000)) # Wall is monotonically decreasing self.assertEqual(res.evaluate(0), (numpy.inf, numpy.inf)) self.assertTrue( numpy.all(rep_wallu[1:] < numpy.inf) and numpy.all(rep_wallu[1:] > 0)) self.assertTrue( numpy.all(x > y for x, y in zip(rep_wallu, rep_wallu[1:]))) self.assertTrue( numpy.all(rep_wallf[1:] < numpy.inf) and numpy.all(rep_wallf[1:] > 0)) self.assertTrue( numpy.all(x > y for x, y in zip(rep_wallf, rep_wallf[1:]))) # Wall connects continuously self.assertTrue(numpy.isclose(rep_wallu[-1], u[0])) self.assertTrue(numpy.isclose(rep_wallf[-1], f[0]))
def test_bad_init_beta(self): if (self.__dnacc): self.__params["beta"] = -1.0 with self.assertRaises(ValueError) as result: potential.DNACC(**self.__params)
def test_bad_init_beta_DeltaG0_excess(self): if (self.__dnacc): self.__params["beta_DeltaG0"][("A", "C")] = -1.0 with self.assertRaises(Exception) as result: potential.DNACC(**self.__params)
def test_bad_init_beta_DeltaG0_symm(self): if (self.__dnacc): self.__params["beta_DeltaG0"][("B", "A")] = -4.0 with self.assertRaises(ValueError) as result: potential.DNACC(**self.__params)
def test_bad_init_sigma2_construct(self): if (self.__dnacc): self.__params["sigma2"]["C"] = 1.0 with self.assertRaises(Exception) as result: potential.DNACC(**self.__params)
def test_bad_init_sigma2(self): if (self.__dnacc): self.__params["sigma2"]["A"] = -1 with self.assertRaises(ValueError) as result: potential.DNACC(**self.__params)