forked from jmwoll/goccs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
paccs_test.go
170 lines (156 loc) · 5.05 KB
/
paccs_test.go
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
package main
// Copyright (C) 2017-2018 Jan Wollschläger <[email protected]>
// This file is part of goccs.
//
// goccs is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import (
"math"
"testing"
)
func TestPACCSRotamerSimple(t *testing.T) {
logTestName("TestPACCSRotamerSimple")
mol := Loadxyzstring("C 0 0 1")
ccs := PACCSRotamer(mol, 100000, PAParametersforname("mobcal"))
logTest("given the single rotamer")
logTestInline(mol)
logTest("")
assertTrue(math.Abs(ccs-23) < 0.3,
"the single-rotamer-ccs should be 23 +- 0.3", t)
}
func TestPACCSSimple(t *testing.T) {
logTestName("TestPACCSSimple")
mol := Loadxyzstring("C 0 0 1")
ccs := PACCS(mol, 10000, 1000, PAParametersforname("mobcal"))
logTest("given the molecule")
logTest(mol)
assertTrue(math.Abs(ccs-23) < 0.3,
"the ccs should be 23 +- 0.3", t)
}
func TestPACCSMethane(t *testing.T) {
logTestName("TestPACCSMethane")
delta_ccs := 0.3
mol := Loadxyzfile("xyz/methane.xyz")
exp_ccs := 27.5 // calculated with mobcal
ccs := PACCS(mol, 10000, 1000, PAParametersforname("mobcal"))
logTest("given the molecule methane")
logTest(mol)
assertTrue(math.Abs(ccs-exp_ccs) < delta_ccs,
"the ccs should be 27.5 +- 0.3", t)
}
func TestPACCSEthane(t *testing.T) {
logTestName("TestPACCSEthane")
delta_ccs := 0.3
mol := Loadxyzfile("xyz/ethane.xyz")
exp_ccs := 35.81 // calculated with mobcal
ccs := PACCS(mol, 10000, 1000, PAParametersforname("mobcal"))
logTest("given the molecule ethane")
logTest(mol)
assertTrue(math.Abs(ccs-exp_ccs) < delta_ccs,
"the ccs should be 35.81 +- 0.3", t)
}
func TestPACCSPropane(t *testing.T) {
logTestName("TestPACCSPropane")
delta_ccs := 0.3
mol := Loadxyzfile("xyz/propane.xyz")
exp_ccs := 42.46 // calculated with mobcal
ccs := PACCS(mol, 10000, 1000, PAParametersforname("mobcal"))
logTest("given the molecule propane")
logTest(mol)
assertTrue(math.Abs(ccs-exp_ccs) < delta_ccs,
"the ccs should be 42.46 +- 0.3", t)
}
func TestPACCSButane(t *testing.T) {
logTestName("TestPACCSButane")
delta_ccs := 0.3
mol := Loadxyzfile("xyz/butane.xyz")
exp_ccs := 50.11 // calculated with mobcal
ccs := PACCS(mol, 10000, 1000, PAParametersforname("mobcal"))
logTest("given the molecule butane")
logTest(mol)
assertTrue(math.Abs(ccs-exp_ccs) < delta_ccs,
"the ccs should be 50.11 +- 0.3", t)
}
func TestRotateMolecule(t *testing.T) {
logTestName("TestRotateMolecule")
floatDelta := 0.00001
mol := Loadxyzstring("C 0 0 1\nN 0 0 -1")
rotmol := RotateMolecule(mol, math.Pi, 0, 0) // 90
logTest("rotating the molecule")
logTest(mol)
logTest("180 degrees around x axis results in the molecule")
logTest(rotmol)
assertTrue(rotmol.xs[0]-mol.xs[0] < floatDelta && //
rotmol.ys[0]-mol.ys[0] < floatDelta && //
rotmol.xs[1]-mol.xs[1] < floatDelta && //
rotmol.ys[1]-mol.ys[1] < floatDelta, //
"the x and y coordinates should not change", t)
assertTrue(rotmol.zs[0]+mol.zs[0] < floatDelta && //
rotmol.zs[1]+mol.zs[1] < floatDelta, //
"the z coordinate should be inverted", t)
}
func TestLoadxyzstring(t *testing.T) {
logTestName("TestLoadxyzstring")
var labels []string
var xs []float64
var ys []float64
var zs []float64
mol := Loadxyzstring("C 0 0 1\n")
labels = mol.atom_labels
xs = mol.xs
ys = mol.ys
zs = mol.zs
logTest("Loadxyzstring(C 0 0 1\\n):")
logTest(labels)
logTest(xs)
logTest(ys)
logTest(zs)
if labels == nil {
t.Errorf("Loadxyzstring('C 0 0 1\n') should not be null!")
}
if len(labels) != len([]string{"C"}) {
t.Errorf("len(Loadxyzstring('C 0 0 1\n')) should be 1!")
}
mol = Loadxyzstring("C 0 0 1\nN 0 0 2\n")
labels = mol.atom_labels
xs = mol.xs
ys = mol.ys
zs = mol.zs
logTest("Loadxyzstring(C 0 0 1\\nN 0 0 2\\n):")
logTest(labels)
logTest(xs)
logTest(ys)
logTest(zs)
if labels == nil {
t.Errorf("Loadxyzstring('C 0 0 1\nN 0 0 2\n') should not be null!")
}
if len(labels) != len([]string{"C", "N"}) {
t.Errorf("len(Loadxyzstring('C 0 0 1\nN 0 0 2\n')) should be 2!")
}
mol = Loadxyzstring("3\nA test xyzfile\nC 0 0 1\nN 0 0 2\nBr 11.1 -22.2 -33.3\n")
labels = mol.atom_labels
xs = mol.xs
ys = mol.ys
zs = mol.zs
logTest("Loadxyzstring('3\\nA test xyzfile\\nC 0 0 1\\nN 0 0 2\\nBr 11.1 -22.2 -33.3\\n'):")
logTest(labels)
logTest(xs)
logTest(ys)
logTest(zs)
if labels == nil {
t.Errorf("Loadxyzstring('3\\nA test xyzfile\\nC 0 0 1\\nN 0 0 2\\nBr 11.1 -22.2 -33.3\\n') should not be null!")
}
if len(labels) != len([]string{"C", "N", "Br"}) {
t.Errorf("len(Loadxyzstring('3\\nA test xyzfile\\nC 0 0 1\\nN 0 0 2\\nBr 11.1 -22.2 -33.3\\n')) should be 3!")
}
}