[1bef07] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
[0aa122] | 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
[1bef07] | 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | /*
|
---|
| 9 | * ParserPsi3UnitTest.cpp
|
---|
| 10 | *
|
---|
| 11 | * Created on: Mar 3, 2010
|
---|
| 12 | * Author: metzler
|
---|
| 13 | */
|
---|
| 14 |
|
---|
| 15 | // include config.h
|
---|
| 16 | #ifdef HAVE_CONFIG_H
|
---|
| 17 | #include <config.h>
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
| 20 | #include "ParserPsi3UnitTest.hpp"
|
---|
| 21 |
|
---|
| 22 | #include <cppunit/CompilerOutputter.h>
|
---|
| 23 | #include <cppunit/extensions/TestFactoryRegistry.h>
|
---|
| 24 | #include <cppunit/ui/text/TestRunner.h>
|
---|
| 25 |
|
---|
| 26 | #include <boost/any.hpp>
|
---|
| 27 |
|
---|
[6f0841] | 28 | #include "Atom/atom.hpp"
|
---|
[006e1e] | 29 | #include "Atom/AtomObserver.hpp"
|
---|
[360c8b] | 30 | #include "Element/element.hpp"
|
---|
| 31 | #include "Element/periodentafel.hpp"
|
---|
[006e1e] | 32 | #include "CodePatterns/Assert.hpp"
|
---|
| 33 | #include "Descriptors/AtomTypeDescriptor.hpp"
|
---|
[1bef07] | 34 | #include "Parser/ChangeTracker.hpp"
|
---|
| 35 | #include "Parser/Psi3Parser.hpp"
|
---|
[360c8b] | 36 | #include "World.hpp"
|
---|
[1bef07] | 37 |
|
---|
| 38 | #ifdef HAVE_TESTRUNNER
|
---|
| 39 | #include "UnitTestMain.hpp"
|
---|
| 40 | #endif /*HAVE_TESTRUNNER*/
|
---|
| 41 |
|
---|
| 42 | using namespace std;
|
---|
| 43 |
|
---|
| 44 | // Registers the fixture into the 'registry'
|
---|
| 45 | CPPUNIT_TEST_SUITE_REGISTRATION( ParserPsi3UnitTest );
|
---|
| 46 |
|
---|
| 47 | static string hydrogenPsi3_RHF ="% Created by MoleCuilder\n\
|
---|
| 48 | psi: (\n\
|
---|
| 49 | \tlabel = \"cc-pVTZ SCF H2\"\n\
|
---|
| 50 | \tjobtype = sp\n\
|
---|
| 51 | \twfn = scf\n\
|
---|
| 52 | \tmaxiter = 80\n\
|
---|
| 53 | \treference = rhf\n\
|
---|
| 54 | \tbasis = \"cc-pVTZ\"\n\
|
---|
| 55 | \tfreeze_core = no\n\
|
---|
[d640ea] | 56 | \tunits = angstrom\n\
|
---|
[1bef07] | 57 | \tgeometry = (\n\
|
---|
[d640ea] | 58 | \t( H\t0\t0\t-0.37 )\n\
|
---|
| 59 | \t( H\t0\t0\t0.37 )\n\
|
---|
[1bef07] | 60 | \t)\n\
|
---|
[d640ea] | 61 | \torigin = (0.0\t0.0\t0.0)\n\
|
---|
[1bef07] | 62 | )\n"; // tested with ???
|
---|
| 63 |
|
---|
| 64 | static string hydrogenPsi3_ROHF ="% Created by MoleCuilder\n\
|
---|
| 65 | psi: (\n\
|
---|
| 66 | \tlabel = \"cc-pVTZ SCF H2\"\n\
|
---|
| 67 | \tjobtype = sp\n\
|
---|
| 68 | \twfn = scf\n\
|
---|
| 69 | \tmaxiter = 80\n\
|
---|
| 70 | \treference = rohf\n\
|
---|
| 71 | \tbasis = \"cc-pVTZ\"\n\
|
---|
| 72 | \tfreeze_core = no\n\
|
---|
[d640ea] | 73 | \tunits = angstrom\n\
|
---|
[1bef07] | 74 | \tgeometry = (\n\
|
---|
[d640ea] | 75 | \t( H\t0\t0\t-0.37 )\n\
|
---|
| 76 | \t( H\t0\t0\t0.37 )\n\
|
---|
[1bef07] | 77 | \t)\n\
|
---|
[d640ea] | 78 | \torigin = (0.0\t0.0\t0.0)\n\
|
---|
[1bef07] | 79 | )\n"; // tested with ???
|
---|
| 80 |
|
---|
| 81 | static string hydrogenPsi3_UHF ="% Created by MoleCuilder\n\
|
---|
| 82 | psi: (\n\
|
---|
| 83 | \tlabel = \"cc-pVTZ SCF H2\"\n\
|
---|
| 84 | \tjobtype = sp\n\
|
---|
| 85 | \twfn = scf\n\
|
---|
| 86 | \tmaxiter = 80\n\
|
---|
| 87 | \treference = uhf\n\
|
---|
| 88 | \tbasis = \"cc-pVTZ\"\n\
|
---|
| 89 | \tmultp = 2\n\
|
---|
[d640ea] | 90 | \tcharge = 2\n\
|
---|
[1bef07] | 91 | \tfreeze_core = no\n\
|
---|
[d640ea] | 92 | \tunits = angstrom\n\
|
---|
[1bef07] | 93 | \tgeometry = (\n\
|
---|
[d640ea] | 94 | \t( H\t0\t0\t-0.37 )\n\
|
---|
| 95 | \t( H\t0\t0\t0.37 )\n\
|
---|
[1bef07] | 96 | \t)\n\
|
---|
[d640ea] | 97 | \torigin = (0.0\t0.0\t0.0)\n\
|
---|
[1bef07] | 98 | )\n"; // tested with ???
|
---|
| 99 |
|
---|
| 100 | static string hydrogenPsi3_TWOCON ="% Created by MoleCuilder\n\
|
---|
| 101 | psi: (\n\
|
---|
| 102 | \tlabel = \"cc-pVTZ SCF H2\"\n\
|
---|
| 103 | \tjobtype = sp\n\
|
---|
| 104 | \twfn = scf\n\
|
---|
| 105 | \tmaxiter = 80\n\
|
---|
[d640ea] | 106 | \treference = twocon\n\
|
---|
[1bef07] | 107 | \tbasis = \"cc-pVTZ\"\n\
|
---|
| 108 | \tmultp = 1\n\
|
---|
[d640ea] | 109 | \tcharge = 2\n\
|
---|
| 110 | \tsocc = ( 1 1 0 0 0 0 0 0 )\n\
|
---|
| 111 | \tdocc = ( 0 0 0 0 0 0 0 0 )\n\
|
---|
| 112 | \tsubgroup = c2v\n\
|
---|
| 113 | \tunique_axis = x\n\
|
---|
[1bef07] | 114 | \tfreeze_core = no\n\
|
---|
[d640ea] | 115 | \tunits = angstrom\n\
|
---|
[1bef07] | 116 | \tgeometry = (\n\
|
---|
[d640ea] | 117 | \t( H\t0\t0\t-0.37 )\n\
|
---|
| 118 | \t( H\t0\t0\t0.37 )\n\
|
---|
[1bef07] | 119 | \t)\n\
|
---|
[d640ea] | 120 | \torigin = (0.0\t0.0\t0.0)\n\
|
---|
[1bef07] | 121 | )\n"; // tested with ???
|
---|
| 122 |
|
---|
| 123 | void ParserPsi3UnitTest::setUp()
|
---|
| 124 | {
|
---|
| 125 | // failing asserts should be thrown
|
---|
| 126 | ASSERT_DO(Assert::Throw);
|
---|
| 127 |
|
---|
| 128 | parser = new FormatParser<psi3>();
|
---|
| 129 |
|
---|
[154a45] | 130 | params = &parser->getParams();
|
---|
| 131 |
|
---|
[1bef07] | 132 | World::getInstance();
|
---|
| 133 |
|
---|
| 134 | setVerbosity(2);
|
---|
| 135 |
|
---|
| 136 | // we need hydrogens and oxygens in the following tests
|
---|
| 137 | CPPUNIT_ASSERT(World::getInstance().getPeriode()->FindElement(1) != NULL);
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | void ParserPsi3UnitTest::tearDown()
|
---|
| 141 | {
|
---|
[154a45] | 142 | params = NULL;
|
---|
[1bef07] | 143 | delete parser;
|
---|
| 144 | ChangeTracker::purgeInstance();
|
---|
[006e1e] | 145 | AtomObserver::purgeInstance();
|
---|
[1bef07] | 146 | World::purgeInstance();
|
---|
| 147 | }
|
---|
| 148 |
|
---|
| 149 | /************************************ tests ***********************************/
|
---|
| 150 |
|
---|
| 151 | void ParserPsi3UnitTest::ParameterDefaultTest() {
|
---|
| 152 | // check default values
|
---|
[154a45] | 153 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::labelParam) == std::string("unknown job"));
|
---|
| 154 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::jobtypeParam) == params->ValidJobtypes[Psi3Parser_Parameters::SP]);
|
---|
| 155 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::wavefunctionParam) == params->ValidWavefunction[Psi3Parser_Parameters::SCF]);
|
---|
| 156 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::maxiterParam) == std::string("80"));
|
---|
| 157 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::referenceParam) == params->ValidReference[Psi3Parser_Parameters::RHF]);
|
---|
| 158 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::basisParam) == std::string("cc-pVTZ"));
|
---|
| 159 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::freeze_coreParam) == params->ValidFreezeCore[Psi3Parser_Parameters::YES]);
|
---|
| 160 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::unitsParam) == params->ValidUnits[Psi3Parser_Parameters::angstrom]);
|
---|
| 161 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::dertypeParam) == params->ValidDerivativeType[Psi3Parser_Parameters::NONE]);
|
---|
| 162 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::originParam) == std::string("(0.0\t0.0\t0.0)"));
|
---|
[a67cf0] | 163 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::multiplicityParam) == std::string("1"));
|
---|
[154a45] | 164 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::chargeParam) == std::string("0"));
|
---|
| 165 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::soccParam) == std::string("()"));
|
---|
| 166 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::doccParam) == std::string("()"));
|
---|
| 167 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::subgroupParam) == std::string(""));
|
---|
| 168 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::unique_axisParam) == params->ValidUniqueAxis[Psi3Parser_Parameters::X]);
|
---|
[1bef07] | 169 | }
|
---|
| 170 |
|
---|
| 171 | void ParserPsi3UnitTest::ParameterCloneTest() {
|
---|
[154a45] | 172 | FormatParser_Parameters *clone = params->clone();
|
---|
| 173 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::jobtypeParam) == params->ValidJobtypes[Psi3Parser_Parameters::SP]);
|
---|
| 174 | std::stringstream setvalue(params->ParamNames[Psi3Parser_Parameters::jobtypeParam]+"="+params->ValidJobtypes[Psi3Parser_Parameters::OPT]);
|
---|
| 175 | setvalue >> *params;
|
---|
| 176 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::jobtypeParam) == params->ValidJobtypes[Psi3Parser_Parameters::OPT]);
|
---|
| 177 | params->makeClone(*clone);
|
---|
| 178 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::jobtypeParam) == params->ValidJobtypes[Psi3Parser_Parameters::SP]);
|
---|
[1bef07] | 179 | }
|
---|
| 180 |
|
---|
| 181 | void ParserPsi3UnitTest::ParameterSetterTest() {
|
---|
[f758dd] | 182 | // test a jobtype
|
---|
| 183 | {
|
---|
| 184 | std::stringstream setvalue(
|
---|
| 185 | params->ParamNames[Psi3Parser_Parameters::jobtypeParam]
|
---|
| 186 | +" = "+params->ValidJobtypes[Psi3Parser_Parameters::OPT]
|
---|
| 187 | );
|
---|
| 188 | setvalue >> *params;
|
---|
| 189 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::jobtypeParam) == params->ValidJobtypes[Psi3Parser_Parameters::OPT]);
|
---|
| 190 | }
|
---|
| 191 | // test a wavefunction
|
---|
| 192 | {
|
---|
| 193 | std::stringstream setvalue(
|
---|
| 194 | params->ParamNames[Psi3Parser_Parameters::wavefunctionParam]
|
---|
| 195 | +" = "+params->ValidWavefunction[Psi3Parser_Parameters::MP2]
|
---|
| 196 | );
|
---|
| 197 | setvalue >> *params;
|
---|
| 198 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::wavefunctionParam) == params->ValidWavefunction[Psi3Parser_Parameters::MP2]);
|
---|
| 199 | }
|
---|
| 200 | // test a reference
|
---|
| 201 | {
|
---|
| 202 | std::stringstream setvalue(
|
---|
| 203 | params->ParamNames[Psi3Parser_Parameters::referenceParam]
|
---|
| 204 | +" = "+params->ValidReference[Psi3Parser_Parameters::ROHF]
|
---|
| 205 | );
|
---|
| 206 | setvalue >> *params;
|
---|
| 207 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::referenceParam) == params->ValidReference[Psi3Parser_Parameters::ROHF]);
|
---|
| 208 | }
|
---|
| 209 | // test a unique_axis
|
---|
| 210 | {
|
---|
| 211 | std::stringstream setvalue(
|
---|
| 212 | params->ParamNames[Psi3Parser_Parameters::unique_axisParam]
|
---|
| 213 | +" = "+params->ValidUniqueAxis[Psi3Parser_Parameters::Y]
|
---|
| 214 | );
|
---|
| 215 | setvalue >> *params;
|
---|
| 216 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::unique_axisParam) == params->ValidUniqueAxis[Psi3Parser_Parameters::Y]);
|
---|
| 217 | }
|
---|
| 218 | // test a units
|
---|
| 219 | {
|
---|
| 220 | std::stringstream setvalue(
|
---|
| 221 | params->ParamNames[Psi3Parser_Parameters::unitsParam]
|
---|
| 222 | +" = "+params->ValidUnits[Psi3Parser_Parameters::bohr]
|
---|
| 223 | );
|
---|
| 224 | setvalue >> *params;
|
---|
| 225 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::unitsParam) == params->ValidUnits[Psi3Parser_Parameters::bohr]);
|
---|
| 226 | }
|
---|
| 227 | // test a dertype
|
---|
| 228 | {
|
---|
| 229 | std::stringstream setvalue(
|
---|
| 230 | params->ParamNames[Psi3Parser_Parameters::dertypeParam]
|
---|
| 231 | +" = "+params->ValidDerivativeType[Psi3Parser_Parameters::NONE]
|
---|
| 232 | );
|
---|
| 233 | setvalue >> *params;
|
---|
| 234 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::dertypeParam) == params->ValidDerivativeType[Psi3Parser_Parameters::NONE]);
|
---|
| 235 | }
|
---|
| 236 | // test a freeze_core
|
---|
| 237 | {
|
---|
| 238 | std::stringstream setvalue(
|
---|
| 239 | params->ParamNames[Psi3Parser_Parameters::freeze_coreParam]
|
---|
| 240 | +" = "+params->ValidFreezeCore[Psi3Parser_Parameters::LARGE]
|
---|
| 241 | );
|
---|
| 242 | setvalue >> *params;
|
---|
| 243 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::freeze_coreParam) == params->ValidFreezeCore[Psi3Parser_Parameters::LARGE]);
|
---|
| 244 | }
|
---|
| 245 | // test int
|
---|
| 246 | {
|
---|
| 247 | std::stringstream setvalue(
|
---|
| 248 | params->ParamNames[Psi3Parser_Parameters::maxiterParam]
|
---|
| 249 | +" = 500"
|
---|
| 250 | );
|
---|
| 251 | setvalue >> *params;
|
---|
| 252 | // std::cout << "maxiter is "
|
---|
| 253 | // << params->getString(Psi3Parser_Parameters::maxiterParam) << std::endl;
|
---|
| 254 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::maxiterParam) == std::string("500"));
|
---|
| 255 | }
|
---|
| 256 | // test whether unknown key fails
|
---|
| 257 | std::cout << "The following Assertion warning is desired and does not indicate a failure of the test." << std::endl;
|
---|
| 258 | {
|
---|
| 259 | std::stringstream setvalue("sd = no");
|
---|
| 260 | #ifndef NDEBUG
|
---|
| 261 | ASSERT_DO(Assert::Throw);
|
---|
| 262 | CPPUNIT_ASSERT_THROW(setvalue >> *params, Assert::AssertionFailure);
|
---|
| 263 | #else
|
---|
| 264 | setvalue >> *params;
|
---|
| 265 | #endif
|
---|
| 266 | // std::cout << "Hessian is still "
|
---|
| 267 | // << params->getString(Psi3Parser_Parameters::hessianParam) << std::endl;
|
---|
| 268 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::jobtypeParam) == params->ValidJobtypes[Psi3Parser_Parameters::OPT]);
|
---|
| 269 | }
|
---|
[1bef07] | 270 | }
|
---|
| 271 |
|
---|
| 272 | void ParserPsi3UnitTest::readPsi3Test() {
|
---|
[032f31] | 273 | stringstream input(hydrogenPsi3_RHF);
|
---|
| 274 | // set some other parameter for jobtype
|
---|
| 275 | params->setParameter(
|
---|
| 276 | Psi3Parser_Parameters::jobtypeParam,
|
---|
| 277 | params->ValidJobtypes[Psi3Parser_Parameters::OPT]
|
---|
| 278 | );
|
---|
| 279 | parser->load(&input);
|
---|
| 280 |
|
---|
| 281 | // check for jobtype from file
|
---|
| 282 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::jobtypeParam) == params->ValidJobtypes[Psi3Parser_Parameters::SP]);
|
---|
| 283 | // check for 2 hydrogens
|
---|
| 284 | CPPUNIT_ASSERT_EQUAL(2, World::getInstance().numAtoms());
|
---|
| 285 | // check that positions are right
|
---|
| 286 | Vector PositionSum;
|
---|
| 287 | std::vector<atom *> atoms = World::getInstance().getAllAtoms();
|
---|
| 288 | for (std::vector<atom *>::const_iterator iter = atoms.begin();
|
---|
| 289 | iter != atoms.end();
|
---|
| 290 | ++iter)
|
---|
| 291 | PositionSum += (*iter)->getPosition();
|
---|
[d640ea] | 292 | CPPUNIT_ASSERT_EQUAL( PositionSum, Vector(0.,0.,0.) );
|
---|
[1bef07] | 293 | }
|
---|
| 294 |
|
---|
| 295 | void ParserPsi3UnitTest::writePsi3Test() {
|
---|
[d640ea] | 296 | // build up hydrogen molecule
|
---|
| 297 | string first;
|
---|
| 298 | string second;
|
---|
| 299 | atom *Walker = NULL;
|
---|
| 300 | Walker = World::getInstance().createAtom();
|
---|
| 301 | Walker->setType(1);
|
---|
| 302 | Walker->setPosition(Vector(0.,0.,0.));
|
---|
| 303 | Walker = World::getInstance().createAtom();
|
---|
| 304 | Walker->setType(1);
|
---|
| 305 | Walker->setPosition(Vector(0.,0,0.74));
|
---|
| 306 | CPPUNIT_ASSERT_EQUAL(2, World::getInstance().numAtoms());
|
---|
| 307 |
|
---|
| 308 | // set general parameters: label and freeze_core
|
---|
| 309 | params->setParameter(
|
---|
| 310 | Psi3Parser_Parameters::labelParam,
|
---|
| 311 | "cc-pVTZ SCF H2"
|
---|
| 312 | );
|
---|
| 313 | params->setParameter(
|
---|
| 314 | Psi3Parser_Parameters::freeze_coreParam,
|
---|
| 315 | params->ValidFreezeCore[Psi3Parser_Parameters::NO]
|
---|
| 316 | );
|
---|
| 317 | params->setParameter(
|
---|
| 318 | Psi3Parser_Parameters::unitsParam,
|
---|
| 319 | params->ValidUnits[Psi3Parser_Parameters::angstrom]
|
---|
| 320 | );
|
---|
| 321 |
|
---|
| 322 | // create two stringstreams, one stored, one created
|
---|
| 323 | std::vector<atom *> atoms = World::getInstance().getAllAtoms();
|
---|
| 324 | {
|
---|
| 325 | // compare both configs for RHF
|
---|
| 326 | stringstream output;
|
---|
| 327 | params->setParameter(
|
---|
| 328 | Psi3Parser_Parameters::referenceParam,
|
---|
| 329 | params->ValidReference[Psi3Parser_Parameters::RHF]
|
---|
| 330 | );
|
---|
| 331 | parser->save(&output, atoms);
|
---|
| 332 | stringstream input(hydrogenPsi3_RHF);
|
---|
| 333 | // check for non-empty streams
|
---|
| 334 | input.peek();
|
---|
| 335 | output.peek();
|
---|
| 336 | CPPUNIT_ASSERT(input.good() && output.good());
|
---|
| 337 | // check equality of streams per line (for debugging)
|
---|
| 338 | for (; std::getline(input, first) && std::getline(output, second); ) {
|
---|
| 339 | //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
|
---|
| 340 | CPPUNIT_ASSERT(first == second);
|
---|
| 341 | }
|
---|
| 342 | }
|
---|
| 343 | {
|
---|
| 344 | // compare both configs for ROHF
|
---|
| 345 | stringstream output;
|
---|
| 346 | params->setParameter(
|
---|
| 347 | Psi3Parser_Parameters::referenceParam,
|
---|
| 348 | params->ValidReference[Psi3Parser_Parameters::ROHF]
|
---|
| 349 | );
|
---|
| 350 | parser->save(&output, atoms);
|
---|
| 351 | stringstream input(hydrogenPsi3_ROHF);
|
---|
| 352 | // check for non-empty streams
|
---|
| 353 | input.peek();
|
---|
| 354 | output.peek();
|
---|
| 355 | CPPUNIT_ASSERT(input.good() && output.good());
|
---|
| 356 | // check equality of streams per line (for debugging)
|
---|
| 357 | for (; std::getline(input, first) && std::getline(output, second); ) {
|
---|
| 358 | //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
|
---|
| 359 | CPPUNIT_ASSERT(first == second);
|
---|
| 360 | }
|
---|
| 361 | }
|
---|
| 362 | {
|
---|
| 363 | params->setParameter(Psi3Parser_Parameters::multiplicityParam, "2");
|
---|
| 364 | params->setParameter(Psi3Parser_Parameters::chargeParam, "2");
|
---|
| 365 | // compare both configs for UHF
|
---|
| 366 | stringstream output;
|
---|
| 367 | params->setParameter(
|
---|
| 368 | Psi3Parser_Parameters::referenceParam,
|
---|
| 369 | params->ValidReference[Psi3Parser_Parameters::UHF]
|
---|
| 370 | );
|
---|
| 371 | parser->save(&output, atoms);
|
---|
| 372 | params->setParameter(Psi3Parser_Parameters::chargeParam, "0");
|
---|
| 373 | params->setParameter(Psi3Parser_Parameters::multiplicityParam, "1");
|
---|
| 374 | stringstream input(hydrogenPsi3_UHF);
|
---|
| 375 | // check for non-empty streams
|
---|
| 376 | input.peek();
|
---|
| 377 | output.peek();
|
---|
| 378 | CPPUNIT_ASSERT(input.good() && output.good());
|
---|
| 379 | // check equality of streams per line (for debugging)
|
---|
| 380 | for (; std::getline(input, first) && std::getline(output, second); ) {
|
---|
| 381 | //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
|
---|
| 382 | CPPUNIT_ASSERT(first == second);
|
---|
| 383 | }
|
---|
| 384 | }
|
---|
| 385 | {
|
---|
| 386 | params->setParameter(Psi3Parser_Parameters::multiplicityParam, "1");
|
---|
| 387 | params->setParameter(Psi3Parser_Parameters::chargeParam, "2");
|
---|
| 388 | params->setParameter(Psi3Parser_Parameters::soccParam, "( 1 1 0 0 0 0 0 0 )");
|
---|
| 389 | params->setParameter(Psi3Parser_Parameters::doccParam, "( 0 0 0 0 0 0 0 0 )");
|
---|
| 390 | params->setParameter(Psi3Parser_Parameters::subgroupParam, "c2v");
|
---|
| 391 | params->setParameter(Psi3Parser_Parameters::unique_axisParam, "x");
|
---|
| 392 | // compare both configs for TWOCON
|
---|
| 393 | stringstream output;
|
---|
| 394 | params->setParameter(
|
---|
| 395 | Psi3Parser_Parameters::referenceParam,
|
---|
| 396 | params->ValidReference[Psi3Parser_Parameters::TWOCON]
|
---|
| 397 | );
|
---|
| 398 | parser->save(&output, atoms);
|
---|
| 399 | params->setParameter(Psi3Parser_Parameters::multiplicityParam, "1");
|
---|
| 400 | params->setParameter(Psi3Parser_Parameters::chargeParam, "0");
|
---|
| 401 | stringstream input(hydrogenPsi3_TWOCON);
|
---|
| 402 | // check for non-empty streams
|
---|
| 403 | input.peek();
|
---|
| 404 | output.peek();
|
---|
| 405 | CPPUNIT_ASSERT(input.good() && output.good());
|
---|
| 406 | // check equality of streams per line (for debugging)
|
---|
| 407 | for (; std::getline(input, first) && std::getline(output, second); ) {
|
---|
| 408 | //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
|
---|
| 409 | CPPUNIT_ASSERT(first == second);
|
---|
| 410 | }
|
---|
| 411 | }
|
---|
[1bef07] | 412 | }
|
---|