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