2 Highly Optimized Object-oriented Many-particle Dynamics -- Blue Edition
3 (HOOMD-blue) Open Source Software License Copyright 2009-2014 The Regents of
4 the University of Michigan All rights reserved.
6 HOOMD-blue may contain modifications ("Contributions") provided, and to which
7 copyright is held, by various Contributors who have granted The Regents of the
8 University of Michigan the right to modify and/or distribute such Contributions.
10 You may redistribute, use, and create derivate works of HOOMD-blue, in source
11 and binary forms, provided you abide by the following conditions:
13 * Redistributions of source code must retain the above copyright notice, this
14 list of conditions, and the following disclaimer both in the code and
15 prominently in any materials provided with the distribution.
17 * Redistributions in binary form must reproduce the above copyright notice, this
18 list of conditions, and the following disclaimer in the documentation and/or
19 other materials provided with the distribution.
21 * All publications and presentations based on HOOMD-blue, including any reports
22 or published results obtained, in whole or in part, with HOOMD-blue, will
23 acknowledge its use according to the terms posted at the time of submission on:
24 http://codeblue.umich.edu/hoomd-blue/citations.html
26 * Any electronic documents citing HOOMD-Blue will link to the HOOMD-Blue website:
27 http://codeblue.umich.edu/hoomd-blue/
29 * Apart from the above required attributions, neither the name of the copyright
30 holder nor the names of HOOMD-blue's contributors may be used to endorse or
31 promote products derived from this software without specific prior written
36 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' AND
37 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND/OR ANY
39 WARRANTIES THAT THIS SOFTWARE IS FREE OF INFRINGEMENT ARE DISCLAIMED.
41 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
42 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
43 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
44 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
45 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
46 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
47 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 #pragma warning( push )
53 #pragma warning( disable : 4103 4244 )
57 #include "HOOMDDumpWriter.h"
58 #include "HOOMDInitializer.h"
59 #include "BondedGroupData.h"
63 #include <boost/filesystem/operations.hpp>
64 #include <boost/filesystem/convenience.hpp>
65 using namespace boost::filesystem
;
66 #include <boost/shared_ptr.hpp>
67 using namespace boost
;
72 //! Name the unit test module
73 #define BOOST_TEST_MODULE XMLReaderWriterTest
74 #include "boost_utf_configure.h"
76 /*! \file xml_reader_writer_test.cc
77 \brief Unit tests for HOOMDDumpWriter and HOOMDumpReader
81 //! Performs low level tests of HOOMDDumpWriter
82 BOOST_AUTO_TEST_CASE( HOOMDDumpWriterBasicTests
)
86 // start by creating a single particle system: see it the correct file is written
87 BoxDim
box(Scalar(35), Scalar(55), Scalar(125));
89 // set some tilt factors
90 box
.setTiltFactors(Scalar(1.0),Scalar(0.5),Scalar(0.25));
93 int n_angle_types
= 1;
94 int n_dihedral_types
= 1;
95 int n_improper_types
= 1;
97 boost::shared_ptr
<SystemDefinition
> sysdef(new SystemDefinition(4, box
, n_types
, n_bond_types
, n_angle_types
, n_dihedral_types
, n_improper_types
));
98 boost::shared_ptr
<ParticleData
> pdata
= sysdef
->getParticleData();
100 // set recognizable values for the particle
102 ArrayHandle
<Scalar4
> h_pos(pdata
->getPositions(), access_location::host
, access_mode::readwrite
);
103 ArrayHandle
<Scalar4
> h_vel(pdata
->getVelocities(), access_location::host
, access_mode::readwrite
);
104 ArrayHandle
<Scalar3
> h_accel(pdata
->getAccelerations(), access_location::host
, access_mode::readwrite
);
105 ArrayHandle
<int3
> h_image(pdata
->getImages(), access_location::host
, access_mode::readwrite
);
106 ArrayHandle
<unsigned int> h_body(pdata
->getBodies(), access_location::host
, access_mode::readwrite
);
107 ArrayHandle
<unsigned int> h_tag(pdata
->getTags(), access_location::host
, access_mode::readwrite
);
108 ArrayHandle
<unsigned int> h_rtag(pdata
->getRTags(), access_location::host
, access_mode::readwrite
);
109 ArrayHandle
<Scalar
> h_charge(pdata
->getCharges(), access_location::host
, access_mode::readwrite
);
110 ArrayHandle
<Scalar
> h_diameter(pdata
->getDiameters(), access_location::host
, access_mode::readwrite
);
113 h_pos
.data
[0].x
= Scalar(1.5);
114 h_pos
.data
[0].y
= Scalar(2.5);
115 h_pos
.data
[0].z
= Scalar(-5.5);
117 h_image
.data
[0].x
= -1;
118 h_image
.data
[0].y
= -5;
119 h_image
.data
[0].z
= 6;
121 h_vel
.data
[0].x
= Scalar(-1.5);
122 h_vel
.data
[0].y
= Scalar(-10.5);
123 h_vel
.data
[0].z
= Scalar(56.5);
125 h_vel
.data
[0].w
= Scalar(1.5); //mass
127 h_diameter
.data
[0] = Scalar(3.5);
129 h_pos
.data
[0].w
= __int_as_scalar(3); //type
131 h_body
.data
[0] = NO_BODY
;
133 I
.set(0, 1, 2, 3, 4, 5);
134 pdata
->setInertiaTensor(0, I
);
136 h_pos
.data
[1].x
= Scalar(1.5);
137 h_pos
.data
[1].y
= Scalar(2.5);
138 h_pos
.data
[1].z
= Scalar(-3.5);
140 h_image
.data
[1].x
= 10;
141 h_image
.data
[1].y
= 500;
142 h_image
.data
[1].z
= 900;
144 h_vel
.data
[1].x
= Scalar(-1.5);
145 h_vel
.data
[1].y
= Scalar(-10.5);
146 h_vel
.data
[1].z
= Scalar(5.5);
148 h_vel
.data
[1].w
= Scalar(2.5); /// mass
150 h_diameter
.data
[1] = Scalar(4.5);
152 h_pos
.data
[1].w
= __int_as_scalar(0);
156 I
.set(5, 4, 3, 2, 1, 0);
157 pdata
->setInertiaTensor(1, I
);
159 h_pos
.data
[2].x
= Scalar(-1.5);
160 h_pos
.data
[2].y
= Scalar(2.5);
161 h_pos
.data
[2].z
= Scalar(3.5);
163 h_image
.data
[2].x
= 10;
164 h_image
.data
[2].y
= 500;
165 h_image
.data
[2].z
= 900;
167 h_vel
.data
[2].x
= Scalar(-1.5);
168 h_vel
.data
[2].y
= Scalar(-10.5);
169 h_vel
.data
[2].z
= Scalar(5.5);
171 h_vel
.data
[2].w
= Scalar(2.5);
173 h_diameter
.data
[2] = Scalar(4.5);
175 h_pos
.data
[2].w
= __int_as_scalar(1);
179 I
.set(1, 11, 21, 31, 41, 51);
180 pdata
->setInertiaTensor(2, I
);
182 h_pos
.data
[3].x
= Scalar(-1.5);
183 h_pos
.data
[3].y
= Scalar(2.5);
184 h_pos
.data
[3].z
= Scalar(3.5);
186 h_image
.data
[3].x
= 105;
187 h_image
.data
[3].y
= 5005;
188 h_image
.data
[3].z
= 9005;
190 h_vel
.data
[3].x
= Scalar(-1.5);
191 h_vel
.data
[3].y
= Scalar(-10.5);
192 h_vel
.data
[3].z
= Scalar(5.5);
194 h_vel
.data
[3].w
= Scalar(2.5);
196 h_diameter
.data
[3] = Scalar(4.5);
198 h_pos
.data
[3].w
= __int_as_scalar(1);
202 I
.set(51, 41, 31, 21, 11, 1);
203 pdata
->setInertiaTensor(3, I
);
207 // add a couple walls for fun
208 sysdef
->getWallData()->addWall(Wall(1,0,0, 0,1,0));
209 sysdef
->getWallData()->addWall(Wall(0,1,0, 0,0,1));
210 sysdef
->getWallData()->addWall(Wall(0,0,1, 1,0,0));
212 // add a few bonds too
213 sysdef
->getBondData()->addBondedGroup(Bond(0, 0, 1));
214 sysdef
->getBondData()->addBondedGroup(Bond(1, 1, 0));
216 // and angles as well
217 sysdef
->getAngleData()->addBondedGroup(Angle(0, 0, 1, 2));
218 sysdef
->getAngleData()->addBondedGroup(Angle(0, 1, 2, 0));
221 sysdef
->getDihedralData()->addBondedGroup(Dihedral(0, 0, 1, 2, 3));
224 sysdef
->getImproperData()->addBondedGroup(Dihedral(0, 3, 2, 1, 0));
227 boost::shared_ptr
<HOOMDDumpWriter
> writer(new HOOMDDumpWriter(sysdef
, "test"));
229 writer
->setOutputPosition(false);
233 // make sure the first output file is deleted
234 remove_all("test.0000000000.xml");
235 BOOST_REQUIRE(!exists("test.0000000000.xml"));
237 // write the first output
240 // make sure the file was created
241 BOOST_REQUIRE(exists("test.0000000000.xml"));
243 // check the output line by line
244 ifstream
f("test.0000000000.xml");
247 BOOST_CHECK_EQUAL(line
, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
248 BOOST_REQUIRE(!f
.bad());
251 BOOST_CHECK_EQUAL(line
, "<hoomd_xml version=\"1.5\">");
252 BOOST_REQUIRE(!f
.bad());
255 BOOST_CHECK_EQUAL(line
, "<configuration time_step=\"0\" dimensions=\"3\" natoms=\"4\" >");
256 BOOST_REQUIRE(!f
.bad());
259 BOOST_CHECK_EQUAL(line
, "<box lx=\"35\" ly=\"55\" lz=\"125\" xy=\"1\" xz=\"0.5\" yz=\"0.25\"/>");
260 BOOST_REQUIRE(!f
.bad());
263 BOOST_CHECK_EQUAL(line
, "</configuration>");
264 BOOST_REQUIRE(!f
.bad());
267 BOOST_CHECK_EQUAL(line
, "</hoomd_xml>");
268 BOOST_REQUIRE(!f
.bad());
272 // second test: test position
274 writer
->setOutputPosition(true);
276 // make sure the first output file is deleted
277 remove_all("test.0000000010.xml");
278 BOOST_REQUIRE(!exists("test.0000000010.xml"));
283 // make sure the file was created
284 BOOST_REQUIRE(exists("test.0000000010.xml"));
286 // assume that the first lines tested in the first case are still OK and skip them
287 ifstream
f("test.0000000010.xml");
289 getline(f
, line
); // <?xml
290 getline(f
, line
); // <HOOMD_xml
291 getline(f
, line
); // <Configuration
292 getline(f
, line
); // <Box
295 BOOST_CHECK_EQUAL(line
, "<position num=\"4\">");
296 BOOST_REQUIRE(!f
.bad());
299 BOOST_CHECK_EQUAL(line
, "1.5 2.5 -5.5");
300 BOOST_REQUIRE(!f
.bad());
303 BOOST_CHECK_EQUAL(line
, "1.5 2.5 -3.5");
304 BOOST_REQUIRE(!f
.bad());
307 BOOST_CHECK_EQUAL(line
, "-1.5 2.5 3.5");
308 BOOST_REQUIRE(!f
.bad());
311 BOOST_CHECK_EQUAL(line
, "-1.5 2.5 3.5");
312 BOOST_REQUIRE(!f
.bad());
315 BOOST_CHECK_EQUAL(line
, "</position>");
317 getline(f
, line
); // </configuration
318 getline(f
, line
); // </HOOMD_xml
322 // third test: test velocity
324 writer
->setOutputPosition(false);
325 writer
->setOutputVelocity(true);
327 // make sure the first output file is deleted
328 remove_all("test.0000000020.xml");
329 BOOST_REQUIRE(!exists("test.0000000020.xml"));
334 // assume that the first lines tested in the first case are still OK and skip them
335 ifstream
f("test.0000000020.xml");
337 getline(f
, line
); // <?xml
338 getline(f
, line
); // <HOOMD_xml
339 getline(f
, line
); // <Configuration
340 getline(f
, line
); // <Box
343 BOOST_CHECK_EQUAL(line
, "<velocity num=\"4\">");
344 BOOST_REQUIRE(!f
.bad());
347 BOOST_CHECK_EQUAL(line
, "-1.5 -10.5 56.5");
348 BOOST_REQUIRE(!f
.bad());
351 BOOST_CHECK_EQUAL(line
, "-1.5 -10.5 5.5");
352 BOOST_REQUIRE(!f
.bad());
355 BOOST_CHECK_EQUAL(line
, "-1.5 -10.5 5.5");
356 BOOST_REQUIRE(!f
.bad());
359 BOOST_CHECK_EQUAL(line
, "-1.5 -10.5 5.5");
360 BOOST_REQUIRE(!f
.bad());
363 BOOST_CHECK_EQUAL(line
, "</velocity>");
367 // fourth test: the type array
369 writer
->setOutputVelocity(false);
370 writer
->setOutputType(true);
372 // make sure the first output file is deleted
373 remove_all("test.0000000030.xml");
374 BOOST_REQUIRE(!exists("test.0000000030.xml"));
379 // assume that the first lines tested in the first case are still OK and skip them
380 ifstream
f("test.0000000030.xml");
382 getline(f
, line
); // <?xml
383 getline(f
, line
); // <HOOMD_xml
384 getline(f
, line
); // <Configuration
385 getline(f
, line
); // <Box
388 BOOST_CHECK_EQUAL(line
, "<type num=\"4\">");
389 BOOST_REQUIRE(!f
.bad());
392 BOOST_CHECK_EQUAL(line
, "D");
393 BOOST_REQUIRE(!f
.bad());
396 BOOST_CHECK_EQUAL(line
, "A");
397 BOOST_REQUIRE(!f
.bad());
400 BOOST_CHECK_EQUAL(line
, "B");
401 BOOST_REQUIRE(!f
.bad());
404 BOOST_CHECK_EQUAL(line
, "B");
405 BOOST_REQUIRE(!f
.bad());
408 BOOST_CHECK_EQUAL(line
, "</type>");
412 // fifth test: the wall array
414 writer
->setOutputType(false);
415 writer
->setOutputWall(true);
417 // make sure the first output file is deleted
418 remove_all("test.0000000040.xml");
419 BOOST_REQUIRE(!exists("test.0000000040.xml"));
424 // assume that the first lines tested in the first case are still OK and skip them
425 ifstream
f("test.0000000040.xml");
427 getline(f
, line
); // <?xml
428 getline(f
, line
); // <HOOMD_xml
429 getline(f
, line
); // <Configuration
430 getline(f
, line
); // <Box
433 BOOST_CHECK_EQUAL(line
, "<wall>");
434 BOOST_REQUIRE(!f
.bad());
437 BOOST_CHECK_EQUAL(line
, "<coord ox=\"1\" oy=\"0\" oz=\"0\" nx=\"0\" ny=\"1\" nz=\"0\" />");
438 BOOST_REQUIRE(!f
.bad());
441 BOOST_CHECK_EQUAL(line
, "<coord ox=\"0\" oy=\"1\" oz=\"0\" nx=\"0\" ny=\"0\" nz=\"1\" />");
442 BOOST_REQUIRE(!f
.bad());
445 BOOST_CHECK_EQUAL(line
, "<coord ox=\"0\" oy=\"0\" oz=\"1\" nx=\"1\" ny=\"0\" nz=\"0\" />");
446 BOOST_REQUIRE(!f
.bad());
449 BOOST_CHECK_EQUAL(line
, "</wall>");
453 // sixth test: the bond array
455 writer
->setOutputWall(false);
456 writer
->setOutputBond(true);
458 // make sure the first output file is deleted
459 remove_all("test.0000000050.xml");
460 BOOST_REQUIRE(!exists("test.0000000050.xml"));
465 // assume that the first lines tested in the first case are still OK and skip them
466 ifstream
f("test.0000000050.xml");
468 getline(f
, line
); // <?xml
469 getline(f
, line
); // <HOOMD_xml
470 getline(f
, line
); // <Configuration
471 getline(f
, line
); // <Box
474 BOOST_CHECK_EQUAL(line
, "<bond num=\"2\">");
475 BOOST_REQUIRE(!f
.bad());
478 BOOST_CHECK_EQUAL(line
, "bondA 0 1");
479 BOOST_REQUIRE(!f
.bad());
482 BOOST_CHECK_EQUAL(line
, "bondB 1 0");
483 BOOST_REQUIRE(!f
.bad());
486 BOOST_CHECK_EQUAL(line
, "</bond>");
490 // seventh test: the angle array
492 writer
->setOutputBond(false);
493 writer
->setOutputAngle(true);
495 // make sure the first output file is deleted
496 remove_all("test.0000000060.xml");
497 BOOST_REQUIRE(!exists("test.0000000060.xml"));
502 // assume that the first lines tested in the first case are still OK and skip them
503 ifstream
f("test.0000000060.xml");
505 getline(f
, line
); // <?xml
506 getline(f
, line
); // <HOOMD_xml
507 getline(f
, line
); // <Configuration
508 getline(f
, line
); // <Box
511 BOOST_CHECK_EQUAL(line
, "<angle num=\"2\">");
512 BOOST_REQUIRE(!f
.bad());
515 BOOST_CHECK_EQUAL(line
, "angleA 0 1 2");
516 BOOST_REQUIRE(!f
.bad());
519 BOOST_CHECK_EQUAL(line
, "angleA 1 2 0");
520 BOOST_REQUIRE(!f
.bad());
523 BOOST_CHECK_EQUAL(line
, "</angle>");
527 // eighth test: test image
529 writer
->setOutputAngle(false);
530 writer
->setOutputImage(true);
532 // make sure the first output file is deleted
533 remove_all("test.0000000070.xml");
534 BOOST_REQUIRE(!exists("test.0000000070.xml"));
539 // assume that the first lines tested in the first case are still OK and skip them
540 ifstream
f("test.0000000070.xml");
542 getline(f
, line
); // <?xml
543 getline(f
, line
); // <HOOMD_xml
544 getline(f
, line
); // <Configuration
545 getline(f
, line
); // <Box
548 BOOST_CHECK_EQUAL(line
, "<image num=\"4\">");
549 BOOST_REQUIRE(!f
.bad());
552 BOOST_CHECK_EQUAL(line
, "-1 -5 6");
553 BOOST_REQUIRE(!f
.bad());
556 BOOST_CHECK_EQUAL(line
, "10 500 900");
557 BOOST_REQUIRE(!f
.bad());
560 BOOST_CHECK_EQUAL(line
, "10 500 900");
561 BOOST_REQUIRE(!f
.bad());
564 BOOST_CHECK_EQUAL(line
, "105 5005 9005");
565 BOOST_REQUIRE(!f
.bad());
568 BOOST_CHECK_EQUAL(line
, "</image>");
572 // nineth test: test mass
574 writer
->setOutputImage(false);
575 writer
->setOutputMass(true);
577 // make sure the first output file is deleted
578 remove_all("test.0000000080.xml");
579 BOOST_REQUIRE(!exists("test.0000000080.xml"));
584 // assume that the first lines tested in the first case are still OK and skip them
585 ifstream
f("test.0000000080.xml");
587 getline(f
, line
); // <?xml
588 getline(f
, line
); // <HOOMD_xml
589 getline(f
, line
); // <Configuration
590 getline(f
, line
); // <Box
593 BOOST_CHECK_EQUAL(line
, "<mass num=\"4\">");
594 BOOST_REQUIRE(!f
.bad());
597 BOOST_CHECK_EQUAL(line
, "1.5");
598 BOOST_REQUIRE(!f
.bad());
601 BOOST_CHECK_EQUAL(line
, "2.5");
602 BOOST_REQUIRE(!f
.bad());
605 BOOST_CHECK_EQUAL(line
, "2.5");
606 BOOST_REQUIRE(!f
.bad());
609 BOOST_CHECK_EQUAL(line
, "2.5");
610 BOOST_REQUIRE(!f
.bad());
613 BOOST_CHECK_EQUAL(line
, "</mass>");
617 // tenth test: test diameter
619 writer
->setOutputMass(false);
620 writer
->setOutputDiameter(true);
622 // make sure the first output file is deleted
623 remove_all("test.0000000090.xml");
624 BOOST_REQUIRE(!exists("test.0000000090.xml"));
629 // assume that the first lines tested in the first case are still OK and skip them
630 ifstream
f("test.0000000090.xml");
632 getline(f
, line
); // <?xml
633 getline(f
, line
); // <HOOMD_xml
634 getline(f
, line
); // <Configuration
635 getline(f
, line
); // <Box
638 BOOST_CHECK_EQUAL(line
, "<diameter num=\"4\">");
639 BOOST_REQUIRE(!f
.bad());
642 BOOST_CHECK_EQUAL(line
, "3.5");
643 BOOST_REQUIRE(!f
.bad());
646 BOOST_CHECK_EQUAL(line
, "4.5");
647 BOOST_REQUIRE(!f
.bad());
650 BOOST_CHECK_EQUAL(line
, "4.5");
651 BOOST_REQUIRE(!f
.bad());
654 BOOST_CHECK_EQUAL(line
, "4.5");
655 BOOST_REQUIRE(!f
.bad());
658 BOOST_CHECK_EQUAL(line
, "</diameter>");
662 // eleventh test: the dihedral array
664 writer
->setOutputDiameter(false);
665 writer
->setOutputDihedral(true);
667 // make sure the first output file is deleted
668 remove_all("test.0000000100.xml");
669 BOOST_REQUIRE(!exists("test.0000000100.xml"));
672 writer
->analyze(100);
674 // assume that the first lines tested in the first case are still OK and skip them
675 ifstream
f("test.0000000100.xml");
677 getline(f
, line
); // <?xml
678 getline(f
, line
); // <HOOMD_xml
679 getline(f
, line
); // <Configuration
680 getline(f
, line
); // <Box
683 BOOST_CHECK_EQUAL(line
, "<dihedral num=\"1\">");
684 BOOST_REQUIRE(!f
.bad());
687 BOOST_CHECK_EQUAL(line
, "dihedralA 0 1 2 3");
688 BOOST_REQUIRE(!f
.bad());
691 BOOST_CHECK_EQUAL(line
, "</dihedral>");
696 // twelfth test: the improper array
698 writer
->setOutputDihedral(false);
699 writer
->setOutputImproper(true);
701 // make sure the first output file is deleted
702 remove_all("test.0000000110.xml");
703 BOOST_REQUIRE(!exists("test.0000000110.xml"));
706 writer
->analyze(110);
708 // assume that the first lines tested in the first case are still OK and skip them
709 ifstream
f("test.0000000110.xml");
711 getline(f
, line
); // <?xml
712 getline(f
, line
); // <HOOMD_xml
713 getline(f
, line
); // <Configuration
714 getline(f
, line
); // <Box
717 BOOST_CHECK_EQUAL(line
, "<improper num=\"1\">");
718 BOOST_REQUIRE(!f
.bad());
721 BOOST_CHECK_EQUAL(line
, "improperA 3 2 1 0");
722 BOOST_REQUIRE(!f
.bad());
725 BOOST_CHECK_EQUAL(line
, "</improper>");
729 // thirteenth test: the body array
731 writer
->setOutputImproper(false);
732 writer
->setOutputBody(true);
734 // make sure the first output file is deleted
735 remove_all("test.0000000120.xml");
736 BOOST_REQUIRE(!exists("test.0000000120.xml"));
739 writer
->analyze(120);
741 // assume that the first lines tested in the first case are still OK and skip them
742 ifstream
f("test.0000000120.xml");
744 getline(f
, line
); // <?xml
745 getline(f
, line
); // <HOOMD_xml
746 getline(f
, line
); // <Configuration
747 getline(f
, line
); // <Box
750 BOOST_CHECK_EQUAL(line
, "<body num=\"4\">");
751 BOOST_REQUIRE(!f
.bad());
754 BOOST_CHECK_EQUAL(line
, "-1");
755 BOOST_REQUIRE(!f
.bad());
758 BOOST_CHECK_EQUAL(line
, "1");
759 BOOST_REQUIRE(!f
.bad());
762 BOOST_CHECK_EQUAL(line
, "1");
763 BOOST_REQUIRE(!f
.bad());
766 BOOST_CHECK_EQUAL(line
, "0");
767 BOOST_REQUIRE(!f
.bad());
770 BOOST_CHECK_EQUAL(line
, "</body>");
774 // fourteenth test: the moment_inertia array
776 writer
->setOutputBody(false);
777 writer
->setOutputMomentInertia(true);
779 // make sure the first output file is deleted
780 remove_all("test.0000000130.xml");
781 BOOST_REQUIRE(!exists("test.0000000130.xml"));
784 writer
->analyze(130);
786 // assume that the first lines tested in the first case are still OK and skip them
787 ifstream
f("test.0000000130.xml");
789 getline(f
, line
); // <?xml
790 getline(f
, line
); // <HOOMD_xml
791 getline(f
, line
); // <Configuration
792 getline(f
, line
); // <Box
795 BOOST_CHECK_EQUAL(line
, "<moment_inertia num=\"4\">");
796 BOOST_REQUIRE(!f
.bad());
799 BOOST_CHECK_EQUAL(line
, "0 1 2 3 4 5");
800 BOOST_REQUIRE(!f
.bad());
803 BOOST_CHECK_EQUAL(line
, "5 4 3 2 1 0");
804 BOOST_REQUIRE(!f
.bad());
807 BOOST_CHECK_EQUAL(line
, "1 11 21 31 41 51");
808 BOOST_REQUIRE(!f
.bad());
811 BOOST_CHECK_EQUAL(line
, "51 41 31 21 11 1");
812 BOOST_REQUIRE(!f
.bad());
815 BOOST_CHECK_EQUAL(line
, "</moment_inertia>");
819 remove_all("test.0000000000.xml");
820 remove_all("test.0000000010.xml");
821 remove_all("test.0000000020.xml");
822 remove_all("test.0000000030.xml");
823 remove_all("test.0000000040.xml");
824 remove_all("test.0000000050.xml");
825 remove_all("test.0000000060.xml");
826 remove_all("test.0000000070.xml");
827 remove_all("test.0000000080.xml");
828 remove_all("test.0000000090.xml");
829 remove_all("test.0000000100.xml");
830 remove_all("test.0000000110.xml");
831 remove_all("test.0000000120.xml");
832 remove_all("test.0000000130.xml");
835 //! Tests the ability of HOOMDDumpWriter to handle tagged and reordered particles
836 BOOST_AUTO_TEST_CASE( HOOMDDumpWriter_tag_test
)
838 // start by creating a single particle system: see it the correct file is written
839 BoxDim
box(Scalar(100.5), Scalar(120.5), Scalar(130.5));
841 boost::shared_ptr
<SystemDefinition
> sysdef(new SystemDefinition(6, box
, n_types
));
842 boost::shared_ptr
<ParticleData
> pdata
= sysdef
->getParticleData();
844 // this is the shuffle order of the particles
845 unsigned int tags
[6] = { 5, 2, 3, 1, 0, 4 };
846 unsigned int rtags
[6] = { 4, 3, 1, 2, 5, 0 };
849 // set recognizable values for the particle
850 ArrayHandle
<Scalar4
> h_pos(pdata
->getPositions(), access_location::host
, access_mode::readwrite
);
851 ArrayHandle
<Scalar4
> h_vel(pdata
->getVelocities(), access_location::host
, access_mode::readwrite
);
852 ArrayHandle
<Scalar3
> h_accel(pdata
->getAccelerations(), access_location::host
, access_mode::readwrite
);
853 ArrayHandle
<int3
> h_image(pdata
->getImages(), access_location::host
, access_mode::readwrite
);
854 ArrayHandle
<unsigned int> h_body(pdata
->getBodies(), access_location::host
, access_mode::readwrite
);
855 ArrayHandle
<unsigned int> h_tag(pdata
->getTags(), access_location::host
, access_mode::readwrite
);
856 ArrayHandle
<unsigned int> h_rtag(pdata
->getRTags(), access_location::host
, access_mode::readwrite
);
857 ArrayHandle
<Scalar
> h_charge(pdata
->getCharges(), access_location::host
, access_mode::readwrite
);
858 ArrayHandle
<Scalar
> h_diameter(pdata
->getDiameters(), access_location::host
, access_mode::readwrite
);
860 for (int i
= 0; i
< 6; i
++)
862 h_tag
.data
[i
] = tags
[i
];
863 unsigned int tag
= tags
[i
];
865 h_pos
.data
[i
].x
= Scalar(tag
)+Scalar(0.5);
866 h_pos
.data
[i
].y
= Scalar(tag
)+Scalar(1.5);
867 h_pos
.data
[i
].z
= Scalar(tag
)+Scalar(2.5);
869 h_image
.data
[i
].x
= tag
- 10;
870 h_image
.data
[i
].y
= tag
- 11;
871 h_image
.data
[i
].z
= tag
+ 50;
873 h_vel
.data
[i
].x
= Scalar(tag
)*Scalar(10.0);
874 h_vel
.data
[i
].y
= Scalar(tag
)*Scalar(11.0);
875 h_vel
.data
[i
].z
= Scalar(tag
)*Scalar(12.0);
877 h_pos
.data
[i
].w
=__int_as_scalar(tag
+ 2);
878 h_rtag
.data
[i
] = rtags
[i
];
883 boost::shared_ptr
<HOOMDDumpWriter
> writer(new HOOMDDumpWriter(sysdef
, "test"));
885 // write the file with all outputs enabled
886 writer
->setOutputPosition(true);
887 writer
->setOutputVelocity(true);
888 writer
->setOutputType(true);
889 writer
->setOutputImage(true);
891 // now the big mess: check the file line by line
893 // make sure the first output file is deleted
894 remove_all("test.0000000100.xml");
895 BOOST_REQUIRE(!exists("test.0000000100.xml"));
897 // write the first output
898 writer
->analyze(100);
900 // make sure the file was created
901 BOOST_REQUIRE(exists("test.0000000100.xml"));
903 // check the output line by line
904 ifstream
f("test.0000000100.xml");
907 BOOST_CHECK_EQUAL(line
, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
908 BOOST_REQUIRE(!f
.bad());
911 BOOST_CHECK_EQUAL(line
, "<hoomd_xml version=\"1.5\">");
912 BOOST_REQUIRE(!f
.bad());
915 BOOST_CHECK_EQUAL(line
, "<configuration time_step=\"100\" dimensions=\"3\" natoms=\"6\" >");
916 BOOST_REQUIRE(!f
.bad());
919 BOOST_CHECK_EQUAL(line
, "<box lx=\"100.5\" ly=\"120.5\" lz=\"130.5\" xy=\"0\" xz=\"0\" yz=\"0\"/>");
920 BOOST_REQUIRE(!f
.bad());
923 BOOST_CHECK_EQUAL(line
, "<position num=\"6\">");
924 BOOST_REQUIRE(!f
.bad());
926 // check all the positions
928 BOOST_CHECK_EQUAL(line
, "0.5 1.5 2.5");
929 BOOST_REQUIRE(!f
.bad());
932 BOOST_CHECK_EQUAL(line
, "1.5 2.5 3.5");
933 BOOST_REQUIRE(!f
.bad());
936 BOOST_CHECK_EQUAL(line
, "2.5 3.5 4.5");
937 BOOST_REQUIRE(!f
.bad());
940 BOOST_CHECK_EQUAL(line
, "3.5 4.5 5.5");
941 BOOST_REQUIRE(!f
.bad());
944 BOOST_CHECK_EQUAL(line
, "4.5 5.5 6.5");
945 BOOST_REQUIRE(!f
.bad());
948 BOOST_CHECK_EQUAL(line
, "5.5 6.5 7.5");
949 BOOST_REQUIRE(!f
.bad());
952 BOOST_CHECK_EQUAL(line
, "</position>");
953 BOOST_REQUIRE(!f
.bad());
955 // check all the images
957 BOOST_CHECK_EQUAL(line
, "<image num=\"6\">");
958 BOOST_REQUIRE(!f
.bad());
961 BOOST_CHECK_EQUAL(line
, "-10 -11 50");
962 BOOST_REQUIRE(!f
.bad());
965 BOOST_CHECK_EQUAL(line
, "-9 -10 51");
966 BOOST_REQUIRE(!f
.bad());
969 BOOST_CHECK_EQUAL(line
, "-8 -9 52");
970 BOOST_REQUIRE(!f
.bad());
973 BOOST_CHECK_EQUAL(line
, "-7 -8 53");
974 BOOST_REQUIRE(!f
.bad());
977 BOOST_CHECK_EQUAL(line
, "-6 -7 54");
978 BOOST_REQUIRE(!f
.bad());
981 BOOST_CHECK_EQUAL(line
, "-5 -6 55");
982 BOOST_REQUIRE(!f
.bad());
985 BOOST_CHECK_EQUAL(line
, "</image>");
986 BOOST_REQUIRE(!f
.bad());
988 // check all velocities
990 BOOST_CHECK_EQUAL(line
, "<velocity num=\"6\">");
991 BOOST_REQUIRE(!f
.bad());
994 BOOST_CHECK_EQUAL(line
, "0 0 0");
995 BOOST_REQUIRE(!f
.bad());
998 BOOST_CHECK_EQUAL(line
, "10 11 12");
999 BOOST_REQUIRE(!f
.bad());
1002 BOOST_CHECK_EQUAL(line
, "20 22 24");
1003 BOOST_REQUIRE(!f
.bad());
1006 BOOST_CHECK_EQUAL(line
, "30 33 36");
1007 BOOST_REQUIRE(!f
.bad());
1010 BOOST_CHECK_EQUAL(line
, "40 44 48");
1011 BOOST_REQUIRE(!f
.bad());
1014 BOOST_CHECK_EQUAL(line
, "50 55 60");
1015 BOOST_REQUIRE(!f
.bad());
1018 BOOST_CHECK_EQUAL(line
, "</velocity>");
1022 BOOST_CHECK_EQUAL(line
, "<type num=\"6\">");
1023 BOOST_REQUIRE(!f
.bad());
1026 BOOST_CHECK_EQUAL(line
, "C");
1027 BOOST_REQUIRE(!f
.bad());
1030 BOOST_CHECK_EQUAL(line
, "D");
1031 BOOST_REQUIRE(!f
.bad());
1034 BOOST_CHECK_EQUAL(line
, "E");
1035 BOOST_REQUIRE(!f
.bad());
1038 BOOST_CHECK_EQUAL(line
, "F");
1039 BOOST_REQUIRE(!f
.bad());
1042 BOOST_CHECK_EQUAL(line
, "G");
1043 BOOST_REQUIRE(!f
.bad());
1046 BOOST_CHECK_EQUAL(line
, "H");
1047 BOOST_REQUIRE(!f
.bad());
1050 BOOST_CHECK_EQUAL(line
, "</type>");
1053 BOOST_CHECK_EQUAL(line
, "</configuration>");
1054 BOOST_REQUIRE(!f
.bad());
1057 BOOST_CHECK_EQUAL(line
, "</hoomd_xml>");
1058 BOOST_REQUIRE(!f
.bad());
1060 remove_all("test.0000000100.xml");
1064 //! Test basic functionality of HOOMDInitializer
1065 BOOST_AUTO_TEST_CASE( HOOMDInitializer_basic_tests
)
1067 // create a test input file
1068 ofstream
f("test_input.xml");
1069 f
<< "<?xml version =\"1.0\" encoding =\"UTF-8\" ?>\n\
1070 <hoomd_xml version=\"1.3\">\n\
1071 <configuration time_step=\"150000000\" dimensions=\"2\">\n\
1072 <box lx=\"20.05\" ly= \"32.12345\" lz=\"45.098\" xy=\".12\" xz=\".23\" yz=\".34\"/>\n\
1074 1.4 2.567890 3.45\n\
1075 2.4 3.567890 4.45\n\
1076 3.4 4.567890 5.45\n\
1077 4.4 5.567890 6.45\n\
1078 5.4 6.567890 7.45\n\
1079 6.4 7.567890 8.45\n\
1090 10.12 12.1567 1.056\n\
1091 20.12 22.1567 2.056\n\
1092 30.12 32.1567 3.056\n\
1093 40.12 42.1567 4.056\n\
1094 50.12 52.1567 5.056\n\
1095 60.12 62.1567 6.056\n\
1139 10 11 12 13 14 15\n\
1140 20 21 22 23 24 25\n\
1141 30 31 32 33 34 35\n\
1142 40 41 42 43 44 45\n\
1143 50 51 52 53 54 55\n\
1144 </moment_inertia>\n\
1146 <coord ox=\"1.0\" oy=\"2.0\" oz=\"3.0\" nx=\"4.0\" ny=\"5.0\" nz=\"6.0\"/>\n\
1147 <coord ox=\"7.0\" oy=\"8.0\" oz=\"9.0\" nx=\"10.0\" ny=\"11.0\" nz=\"-12.0\"/>\n\
1169 </hoomd_xml>" << endl
;
1172 // now that we have created a test file, load it up into a pdata
1173 boost::shared_ptr
<ExecutionConfiguration
> exec_conf(new ExecutionConfiguration(ExecutionConfiguration::CPU
));
1174 HOOMDInitializer
init(exec_conf
,"test_input.xml");
1175 boost::shared_ptr
<SnapshotSystemData
> snapshot
;
1176 snapshot
= init
.getSnapshot();
1177 boost::shared_ptr
<SystemDefinition
> sysdef(new SystemDefinition(snapshot
));
1178 boost::shared_ptr
<ParticleData
> pdata
= sysdef
->getParticleData();
1180 // verify all parameters
1181 BOOST_CHECK_EQUAL(init
.getTimeStep(), (unsigned int)150000000);
1182 BOOST_CHECK_EQUAL(sysdef
->getNDimensions(), (unsigned int)2);
1183 BOOST_CHECK_EQUAL(pdata
->getN(), (unsigned int)6);
1184 BOOST_CHECK_EQUAL(pdata
->getNTypes(), (unsigned int)6);
1185 MY_BOOST_CHECK_CLOSE(pdata
->getGlobalBox().getL().x
, 20.05, tol
);
1186 MY_BOOST_CHECK_CLOSE(pdata
->getGlobalBox().getL().y
, 32.12345, tol
);
1187 MY_BOOST_CHECK_CLOSE(pdata
->getGlobalBox().getL().z
, 45.098, tol
);
1188 MY_BOOST_CHECK_CLOSE(pdata
->getGlobalBox().getTiltFactorXY(), 0.12, tol
);
1189 MY_BOOST_CHECK_CLOSE(pdata
->getGlobalBox().getTiltFactorXZ(), 0.23, tol
);
1190 MY_BOOST_CHECK_CLOSE(pdata
->getGlobalBox().getTiltFactorYZ(), 0.34, tol
);
1193 ArrayHandle
<Scalar4
> h_pos(pdata
->getPositions(), access_location::host
, access_mode::read
);
1194 ArrayHandle
<Scalar4
> h_vel(pdata
->getVelocities(), access_location::host
, access_mode::read
);
1195 ArrayHandle
<Scalar3
> h_accel(pdata
->getAccelerations(), access_location::host
, access_mode::read
);
1196 ArrayHandle
<int3
> h_image(pdata
->getImages(), access_location::host
, access_mode::read
);
1197 ArrayHandle
<unsigned int> h_body(pdata
->getBodies(), access_location::host
, access_mode::read
);
1198 ArrayHandle
<unsigned int> h_tag(pdata
->getTags(), access_location::host
, access_mode::read
);
1199 ArrayHandle
<unsigned int> h_rtag(pdata
->getRTags(), access_location::host
, access_mode::read
);
1200 ArrayHandle
<Scalar
> h_charge(pdata
->getCharges(), access_location::host
, access_mode::read
);
1201 ArrayHandle
<Scalar
> h_diameter(pdata
->getDiameters(), access_location::host
, access_mode::read
);
1203 for (int i
= 0; i
< 6; i
++)
1205 MY_BOOST_CHECK_CLOSE(h_pos
.data
[i
].x
, Scalar(i
) + Scalar(1.4), tol
);
1206 MY_BOOST_CHECK_CLOSE(h_pos
.data
[i
].y
, Scalar(i
) + Scalar(2.567890), tol
);
1207 MY_BOOST_CHECK_CLOSE(h_pos
.data
[i
].z
, Scalar(i
) + Scalar(3.45), tol
);
1209 BOOST_CHECK_EQUAL(h_image
.data
[i
].x
, 10 + i
);
1210 BOOST_CHECK_EQUAL(h_image
.data
[i
].y
, 20 + i
);
1211 BOOST_CHECK_EQUAL(h_image
.data
[i
].z
, 30 + i
);
1213 MY_BOOST_CHECK_CLOSE(h_vel
.data
[i
].x
, Scalar(i
+1)*Scalar(10.0) + Scalar(0.12), tol
);
1214 MY_BOOST_CHECK_CLOSE(h_vel
.data
[i
].y
, Scalar(i
+1)*Scalar(10.0) + Scalar(2.1567), tol
);
1215 MY_BOOST_CHECK_CLOSE(h_vel
.data
[i
].z
, Scalar(i
+1) + Scalar(0.056), tol
);
1217 MY_BOOST_CHECK_CLOSE(h_vel
.data
[i
].w
, Scalar(i
+1), tol
); // mass
1219 MY_BOOST_CHECK_CLOSE(h_diameter
.data
[i
], Scalar(i
+7), tol
);
1221 MY_BOOST_CHECK_CLOSE(h_charge
.data
[i
], Scalar(i
)*Scalar(10.0), tol
);
1223 BOOST_CHECK_EQUAL(h_body
.data
[i
], (unsigned int)(i
-1));
1225 // checking that the type is correct becomes tricky because types are identified by
1227 ostringstream type_name
;
1228 type_name
<< 5-i
; // the expected type is the integer 5-i
1229 BOOST_CHECK_EQUAL((unsigned int)__scalar_as_int(h_pos
.data
[i
].w
), pdata
->getTypeByName(type_name
.str()));
1230 BOOST_CHECK_EQUAL(h_tag
.data
[i
], (unsigned int)i
);
1231 BOOST_CHECK_EQUAL(h_rtag
.data
[i
], (unsigned int)i
);
1233 // check the moment_inertia values
1235 I
= pdata
->getInertiaTensor(i
);
1236 for (unsigned int c
= 0; c
< 6; c
++)
1238 MY_BOOST_CHECK_CLOSE(I
.components
[c
], i
*10 + c
, tol
);
1244 BOOST_REQUIRE_EQUAL(sysdef
->getWallData()->getNumWalls(), (unsigned int)2);
1245 Wall wall1
= sysdef
->getWallData()->getWall(0);
1246 MY_BOOST_CHECK_CLOSE(wall1
.origin_x
, 1.0, tol
);
1247 MY_BOOST_CHECK_CLOSE(wall1
.origin_y
, 2.0, tol
);
1248 MY_BOOST_CHECK_CLOSE(wall1
.origin_z
, 3.0, tol
);
1249 // normals are made unit length when loaded, so these values differ from the ones in the file
1250 MY_BOOST_CHECK_CLOSE(wall1
.normal_x
, 0.455842306, tol
);
1251 MY_BOOST_CHECK_CLOSE(wall1
.normal_y
, 0.569802882, tol
);
1252 MY_BOOST_CHECK_CLOSE(wall1
.normal_z
, 0.683763459, tol
);
1254 Wall wall2
= sysdef
->getWallData()->getWall(1);
1255 MY_BOOST_CHECK_CLOSE(wall2
.origin_x
, 7.0, tol
);
1256 MY_BOOST_CHECK_CLOSE(wall2
.origin_y
, 8.0, tol
);
1257 MY_BOOST_CHECK_CLOSE(wall2
.origin_z
, 9.0, tol
);
1258 // normals are made unit length when loaded, so these values differ from the ones in the file
1259 MY_BOOST_CHECK_CLOSE(wall2
.normal_x
, 0.523423923, tol
);
1260 MY_BOOST_CHECK_CLOSE(wall2
.normal_y
, 0.575766315, tol
);
1261 MY_BOOST_CHECK_CLOSE(wall2
.normal_z
, -0.628108707, tol
);
1264 boost::shared_ptr
<BondData
> bond_data
= sysdef
->getBondData();
1266 // 4 bonds should have been read in
1267 BOOST_REQUIRE_EQUAL(bond_data
->getN(), (unsigned int)4);
1269 // check that the types have been named properly
1270 BOOST_REQUIRE_EQUAL(bond_data
->getNTypes(), (unsigned int)3);
1271 BOOST_CHECK_EQUAL(bond_data
->getTypeByName("bond_a"), (unsigned int)0);
1272 BOOST_CHECK_EQUAL(bond_data
->getTypeByName("bond_b"), (unsigned int)1);
1273 BOOST_CHECK_EQUAL(bond_data
->getTypeByName("bond_c"), (unsigned int)2);
1275 BOOST_CHECK_EQUAL(bond_data
->getNameByType(0), string("bond_a"));
1276 BOOST_CHECK_EQUAL(bond_data
->getNameByType(1), string("bond_b"));
1277 BOOST_CHECK_EQUAL(bond_data
->getNameByType(2), string("bond_c"));
1280 Bond b
= bond_data
-> getGroupByTag(0);
1281 BOOST_CHECK_EQUAL(b
.a
, (unsigned int)0);
1282 BOOST_CHECK_EQUAL(b
.b
, (unsigned int)1);
1283 BOOST_CHECK_EQUAL(b
.type
, (unsigned int)0);
1285 b
= bond_data
-> getGroupByTag(1);
1286 BOOST_CHECK_EQUAL(b
.a
, (unsigned int)1);
1287 BOOST_CHECK_EQUAL(b
.b
, (unsigned int)2);
1288 BOOST_CHECK_EQUAL(b
.type
, (unsigned int)1);
1290 b
= bond_data
-> getGroupByTag(2);
1291 BOOST_CHECK_EQUAL(b
.a
, (unsigned int)2);
1292 BOOST_CHECK_EQUAL(b
.b
, (unsigned int)3);
1293 BOOST_CHECK_EQUAL(b
.type
, (unsigned int)0);
1295 b
= bond_data
-> getGroupByTag(3);
1296 BOOST_CHECK_EQUAL(b
.a
, (unsigned int)3);
1297 BOOST_CHECK_EQUAL(b
.b
, (unsigned int)4);
1298 BOOST_CHECK_EQUAL(b
.type
, (unsigned int)2);
1301 boost::shared_ptr
<AngleData
> angle_data
= sysdef
->getAngleData();
1303 // 3 angles should have been read in
1304 BOOST_REQUIRE_EQUAL(angle_data
->getN(), (unsigned int)3);
1306 // check that the types have been named properly
1307 BOOST_REQUIRE_EQUAL(angle_data
->getNTypes(), (unsigned int)2);
1308 BOOST_CHECK_EQUAL(angle_data
->getTypeByName("angle_a"), (unsigned int)0);
1309 BOOST_CHECK_EQUAL(angle_data
->getTypeByName("angle_b"), (unsigned int)1);
1311 BOOST_CHECK_EQUAL(angle_data
->getNameByType(0), string("angle_a"));
1312 BOOST_CHECK_EQUAL(angle_data
->getNameByType(1), string("angle_b"));
1314 // verify each angle
1315 Angle a
= angle_data
->getGroupByTag(0);
1316 BOOST_CHECK_EQUAL(a
.a
, (unsigned int)0);
1317 BOOST_CHECK_EQUAL(a
.b
, (unsigned int)1);
1318 BOOST_CHECK_EQUAL(a
.c
, (unsigned int)2);
1319 BOOST_CHECK_EQUAL(a
.type
, (unsigned int)0);
1321 a
= angle_data
->getGroupByTag(1);
1322 BOOST_CHECK_EQUAL(a
.a
, (unsigned int)1);
1323 BOOST_CHECK_EQUAL(a
.b
, (unsigned int)2);
1324 BOOST_CHECK_EQUAL(a
.c
, (unsigned int)3);
1325 BOOST_CHECK_EQUAL(a
.type
, (unsigned int)1);
1327 a
= angle_data
->getGroupByTag(2);
1328 BOOST_CHECK_EQUAL(a
.a
, (unsigned int)2);
1329 BOOST_CHECK_EQUAL(a
.b
, (unsigned int)3);
1330 BOOST_CHECK_EQUAL(a
.c
, (unsigned int)4);
1331 BOOST_CHECK_EQUAL(a
.type
, (unsigned int)0);
1333 // check the dihedrals
1334 boost::shared_ptr
<DihedralData
> dihedral_data
= sysdef
->getDihedralData();
1336 // 2 dihedrals should have been read in
1337 BOOST_REQUIRE_EQUAL(dihedral_data
->getN(), (unsigned int)2);
1339 // check that the types have been named properly
1340 BOOST_REQUIRE_EQUAL(dihedral_data
->getNTypes(), (unsigned int)2);
1341 BOOST_CHECK_EQUAL(dihedral_data
->getTypeByName("di_a"), (unsigned int)0);
1342 BOOST_CHECK_EQUAL(dihedral_data
->getTypeByName("di_b"), (unsigned int)1);
1344 BOOST_CHECK_EQUAL(dihedral_data
->getNameByType(0), string("di_a"));
1345 BOOST_CHECK_EQUAL(dihedral_data
->getNameByType(1), string("di_b"));
1347 // verify each dihedral
1348 Dihedral d
= dihedral_data
->getGroupByTag(0);
1349 BOOST_CHECK_EQUAL(d
.a
, (unsigned int)0);
1350 BOOST_CHECK_EQUAL(d
.b
, (unsigned int)1);
1351 BOOST_CHECK_EQUAL(d
.c
, (unsigned int)2);
1352 BOOST_CHECK_EQUAL(d
.d
, (unsigned int)3);
1353 BOOST_CHECK_EQUAL(d
.type
, (unsigned int)0);
1355 d
= dihedral_data
->getGroupByTag(1);
1356 BOOST_CHECK_EQUAL(d
.a
, (unsigned int)1);
1357 BOOST_CHECK_EQUAL(d
.b
, (unsigned int)2);
1358 BOOST_CHECK_EQUAL(d
.c
, (unsigned int)3);
1359 BOOST_CHECK_EQUAL(d
.d
, (unsigned int)4);
1360 BOOST_CHECK_EQUAL(d
.type
, (unsigned int)1);
1363 // check the impropers
1364 boost::shared_ptr
<ImproperData
> improper_data
= sysdef
->getImproperData();
1366 // 2 dihedrals should have been read in
1367 BOOST_REQUIRE_EQUAL(improper_data
->getN(), (unsigned int)2);
1369 // check that the types have been named properly
1370 BOOST_REQUIRE_EQUAL(improper_data
->getNTypes(), (unsigned int)2);
1371 BOOST_CHECK_EQUAL(improper_data
->getTypeByName("im_a"), (unsigned int)0);
1372 BOOST_CHECK_EQUAL(improper_data
->getTypeByName("im_b"), (unsigned int)1);
1374 BOOST_CHECK_EQUAL(improper_data
->getNameByType(0), string("im_a"));
1375 BOOST_CHECK_EQUAL(improper_data
->getNameByType(1), string("im_b"));
1377 // verify each dihedral
1378 d
= improper_data
->getGroupByTag(0);
1379 BOOST_CHECK_EQUAL(d
.a
, (unsigned int)3);
1380 BOOST_CHECK_EQUAL(d
.b
, (unsigned int)2);
1381 BOOST_CHECK_EQUAL(d
.c
, (unsigned int)1);
1382 BOOST_CHECK_EQUAL(d
.d
, (unsigned int)0);
1383 BOOST_CHECK_EQUAL(d
.type
, (unsigned int)0);
1385 d
= improper_data
->getGroupByTag(1);
1386 BOOST_CHECK_EQUAL(d
.a
, (unsigned int)5);
1387 BOOST_CHECK_EQUAL(d
.b
, (unsigned int)4);
1388 BOOST_CHECK_EQUAL(d
.c
, (unsigned int)3);
1389 BOOST_CHECK_EQUAL(d
.d
, (unsigned int)2);
1390 BOOST_CHECK_EQUAL(d
.type
, (unsigned int)1);
1392 // clean up after ourselves
1393 remove_all("test_input.xml");
1397 #pragma warning( pop )