3 def test_constructor_getK_get_l_0_getR():
6 with pytest.raises(TypeError):
9 with pytest.raises(TypeError):
12 with pytest.raises(TypeError):
15 with pytest.raises(ValueError):
18 with pytest.raises(ValueError):
21 fene = FENE(1, 2.5, 3)
24 assert isinstance(fene.getK(), float)
25 assert fene.getK() == 1.0
27 assert isinstance(fene.get_l_0(), float)
28 assert fene.get_l_0() == 2.5
30 assert isinstance(fene.getR(), float)
31 assert fene.getR() == 3.0
34 def test_getPotential():
43 fene = FENE(K, l_0, R)
45 with pytest.raises(TypeError):
46 fene.getPotential([1])
47 with pytest.raises(ValueError):
50 with pytest.raises(ValueError):
51 fene.getPotential(Vector3DReal(l_0 + R, 0, 0))
52 with pytest.raises(ValueError):
53 fene.getPotential(l_0 + R)
54 with pytest.raises(ValueError):
55 fene.getPotential(Vector3DReal(l_0 + R + 0.1, 0, 0))
56 with pytest.raises(ValueError):
57 fene.getPotential(l_0 + R + 0.1)
59 r = Vector3DReal(0, 0, 0)
60 expected = -0.5 * K * R * R * math.log(1 - (l_0 / R) ** 2)
61 assert fene.getPotential(r) == expected
62 assert fene.getPotential(r.getLength()) == expected
64 for i
in range(0, 100):
65 r = Vector3DReal(-0.1 + i, i * 0.1, 2 * i)
66 frac = (r.getLength() - l_0) / R
69 with pytest.raises(ValueError):
73 expected = -0.5 * K * R * R * math.log(1 - frac ** 2);
74 assert fene.getPotential(r) == expected
75 assert fene.getPotential(r.getLength()) == expected