1 /*
2  * Copyright 2009-2021 The VOTCA Development Team (http://www.votca.org)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #define BOOST_TEST_MAIN
19 
20 #define BOOST_TEST_MODULE beadtriple_test
21 
22 // Standard includes
23 #include <string>
24 #include <tuple>
25 
26 // Third party includes
27 #include <boost/test/unit_test.hpp>
28 
29 // Local VOTCA includes
30 #include "votca/csg/bead.h"
31 #include "votca/csg/beadtriple.h"
32 #include "votca/csg/topology.h"
33 
34 using namespace std;
35 using namespace votca::csg;
36 
37 BOOST_AUTO_TEST_SUITE(beadtriple_test)
38 
BOOST_AUTO_TEST_CASE(test_beadtriple_constructor)39 BOOST_AUTO_TEST_CASE(test_beadtriple_constructor) {
40 
41   Topology top;
42 
43   string bead_type_name = "CG";
44 
45   string name = "dummy1";
46   votca::Index resnr = 0;
47   double mass = 1.0;
48   double charge = -1.0;
49 
50   top.CreateBead(Bead::spherical, name, bead_type_name, resnr, mass, charge);
51 
52   name = "dummy2";
53   resnr = 0;
54   mass = 1.0;
55   charge = -1.0;
56 
57   top.CreateBead(Bead::spherical, name, bead_type_name, resnr, mass, charge);
58 
59   name = "dummy3";
60   resnr = 0;
61   mass = 1.0;
62   charge = -1.0;
63 
64   top.CreateBead(Bead::spherical, name, bead_type_name, resnr, mass, charge);
65 
66   Eigen::Vector3d dist12(0.1, 0.2, 0.3);
67   Eigen::Vector3d dist13(0.2, 0.4, 0.3);
68   Eigen::Vector3d dist23(0.1, 0.2, 0.0);
69 
70   BeadTriple testtriple(top.getBead(0), top.getBead(1), top.getBead(2), dist12,
71                         dist13, dist23);
72 
73   double d12ref = 0.3741657;
74   double d13ref = 0.5385165;
75   double d23ref = 0.2236068;
76 
77   double d12 = testtriple.dist12();
78   double d13 = testtriple.dist13();
79   double d23 = testtriple.dist23();
80 
81   BOOST_CHECK_CLOSE(d12, d12ref, 1e-4);
82   BOOST_CHECK_CLOSE(d13, d13ref, 1e-4);
83   BOOST_CHECK_CLOSE(d23, d23ref, 1e-4);
84 }
85 
86 BOOST_AUTO_TEST_SUITE_END()
87