-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathtest_hti_ff_spring.py
More file actions
71 lines (62 loc) · 2.45 KB
/
test_hti_ff_spring.py
File metadata and controls
71 lines (62 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import textwrap
import unittest
from context import dpti
class TestHtiFfSpring(unittest.TestCase):
def setUp(self):
self.maxDiff = None
def test_spring_not_var_spring(self):
input = {"lamb": 0.075, "m_spring_k": [118.71], "var_spring": False}
ret1 = textwrap.dedent(
"""\
group type_1 type 1
fix l_spring_1 type_1 spring/self 1.1871000000e+02
fix_modify l_spring_1 energy yes
variable l_spring equal f_l_spring_1
"""
)
ret2 = dpti.hti._ff_spring(**input)
self.assertEqual(ret1, ret2)
def test_spring_var_spring(self):
input = {"lamb": 0.075, "m_spring_k": [118.71], "var_spring": True}
ret1 = textwrap.dedent(
"""\
group type_1 type 1
fix l_spring_1 type_1 spring/self 1.0980675000e+02
fix_modify l_spring_1 energy yes
variable l_spring equal f_l_spring_1
"""
)
ret2 = dpti.hti._ff_spring(**input)
self.assertEqual(ret1, ret2)
def test_spring_multiple_element(self):
input = {"lamb": 0.075, "m_spring_k": [118.71, 207.2], "var_spring": False}
ret1 = textwrap.dedent(
"""\
group type_1 type 1
group type_2 type 2
fix l_spring_1 type_1 spring/self 1.1871000000e+02
fix_modify l_spring_1 energy yes
fix l_spring_2 type_2 spring/self 2.0720000000e+02
fix_modify l_spring_2 energy yes
variable l_spring equal f_l_spring_1+f_l_spring_2
"""
)
ret2 = dpti.hti._ff_spring(**input)
self.assertEqual(ret1, ret2)
def test_spring_var_spring_multiple_element(self):
input = {"lamb": 0.20, "m_spring_k": [118.71, 207.2], "var_spring": False}
ret1 = textwrap.dedent(
"""\
group type_1 type 1
group type_2 type 2
fix l_spring_1 type_1 spring/self 1.1871000000e+02
fix_modify l_spring_1 energy yes
fix l_spring_2 type_2 spring/self 2.0720000000e+02
fix_modify l_spring_2 energy yes
variable l_spring equal f_l_spring_1+f_l_spring_2
"""
)
ret2 = dpti.hti._ff_spring(**input)
self.assertEqual(ret1, ret2)
if __name__ == "__main__":
unittest.main()