[1bef07] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
[d103d3] | 4 | * Copyright (C) 2010-2011 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 |
|
---|
[360c8b] | 28 | #include "CodePatterns/Assert.hpp"
|
---|
| 29 |
|
---|
[6f0841] | 30 | #include "Atom/atom.hpp"
|
---|
[1bef07] | 31 | #include "Descriptors/AtomTypeDescriptor.hpp"
|
---|
[360c8b] | 32 | #include "Element/element.hpp"
|
---|
| 33 | #include "Element/periodentafel.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();
|
---|
| 145 | World::purgeInstance();
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | /************************************ tests ***********************************/
|
---|
| 149 |
|
---|
| 150 | void ParserPsi3UnitTest::ParameterDefaultTest() {
|
---|
| 151 | // check default values
|
---|
[154a45] | 152 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::labelParam) == std::string("unknown job"));
|
---|
| 153 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::jobtypeParam) == params->ValidJobtypes[Psi3Parser_Parameters::SP]);
|
---|
| 154 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::wavefunctionParam) == params->ValidWavefunction[Psi3Parser_Parameters::SCF]);
|
---|
| 155 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::maxiterParam) == std::string("80"));
|
---|
| 156 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::referenceParam) == params->ValidReference[Psi3Parser_Parameters::RHF]);
|
---|
| 157 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::basisParam) == std::string("cc-pVTZ"));
|
---|
| 158 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::freeze_coreParam) == params->ValidFreezeCore[Psi3Parser_Parameters::YES]);
|
---|
| 159 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::unitsParam) == params->ValidUnits[Psi3Parser_Parameters::angstrom]);
|
---|
| 160 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::dertypeParam) == params->ValidDerivativeType[Psi3Parser_Parameters::NONE]);
|
---|
| 161 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::originParam) == std::string("(0.0\t0.0\t0.0)"));
|
---|
[a67cf0] | 162 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::multiplicityParam) == std::string("1"));
|
---|
[154a45] | 163 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::chargeParam) == std::string("0"));
|
---|
| 164 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::soccParam) == std::string("()"));
|
---|
| 165 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::doccParam) == std::string("()"));
|
---|
| 166 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::subgroupParam) == std::string(""));
|
---|
| 167 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::unique_axisParam) == params->ValidUniqueAxis[Psi3Parser_Parameters::X]);
|
---|
[1bef07] | 168 | }
|
---|
| 169 |
|
---|
| 170 | void ParserPsi3UnitTest::ParameterCloneTest() {
|
---|
[154a45] | 171 | FormatParser_Parameters *clone = params->clone();
|
---|
| 172 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::jobtypeParam) == params->ValidJobtypes[Psi3Parser_Parameters::SP]);
|
---|
| 173 | std::stringstream setvalue(params->ParamNames[Psi3Parser_Parameters::jobtypeParam]+"="+params->ValidJobtypes[Psi3Parser_Parameters::OPT]);
|
---|
| 174 | setvalue >> *params;
|
---|
| 175 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::jobtypeParam) == params->ValidJobtypes[Psi3Parser_Parameters::OPT]);
|
---|
| 176 | params->makeClone(*clone);
|
---|
| 177 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::jobtypeParam) == params->ValidJobtypes[Psi3Parser_Parameters::SP]);
|
---|
[1bef07] | 178 | }
|
---|
| 179 |
|
---|
| 180 | void ParserPsi3UnitTest::ParameterSetterTest() {
|
---|
[f758dd] | 181 | // test a jobtype
|
---|
| 182 | {
|
---|
| 183 | std::stringstream setvalue(
|
---|
| 184 | params->ParamNames[Psi3Parser_Parameters::jobtypeParam]
|
---|
| 185 | +" = "+params->ValidJobtypes[Psi3Parser_Parameters::OPT]
|
---|
| 186 | );
|
---|
| 187 | setvalue >> *params;
|
---|
| 188 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::jobtypeParam) == params->ValidJobtypes[Psi3Parser_Parameters::OPT]);
|
---|
| 189 | }
|
---|
| 190 | // test a wavefunction
|
---|
| 191 | {
|
---|
| 192 | std::stringstream setvalue(
|
---|
| 193 | params->ParamNames[Psi3Parser_Parameters::wavefunctionParam]
|
---|
| 194 | +" = "+params->ValidWavefunction[Psi3Parser_Parameters::MP2]
|
---|
| 195 | );
|
---|
| 196 | setvalue >> *params;
|
---|
| 197 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::wavefunctionParam) == params->ValidWavefunction[Psi3Parser_Parameters::MP2]);
|
---|
| 198 | }
|
---|
| 199 | // test a reference
|
---|
| 200 | {
|
---|
| 201 | std::stringstream setvalue(
|
---|
| 202 | params->ParamNames[Psi3Parser_Parameters::referenceParam]
|
---|
| 203 | +" = "+params->ValidReference[Psi3Parser_Parameters::ROHF]
|
---|
| 204 | );
|
---|
| 205 | setvalue >> *params;
|
---|
| 206 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::referenceParam) == params->ValidReference[Psi3Parser_Parameters::ROHF]);
|
---|
| 207 | }
|
---|
| 208 | // test a unique_axis
|
---|
| 209 | {
|
---|
| 210 | std::stringstream setvalue(
|
---|
| 211 | params->ParamNames[Psi3Parser_Parameters::unique_axisParam]
|
---|
| 212 | +" = "+params->ValidUniqueAxis[Psi3Parser_Parameters::Y]
|
---|
| 213 | );
|
---|
| 214 | setvalue >> *params;
|
---|
| 215 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::unique_axisParam) == params->ValidUniqueAxis[Psi3Parser_Parameters::Y]);
|
---|
| 216 | }
|
---|
| 217 | // test a units
|
---|
| 218 | {
|
---|
| 219 | std::stringstream setvalue(
|
---|
| 220 | params->ParamNames[Psi3Parser_Parameters::unitsParam]
|
---|
| 221 | +" = "+params->ValidUnits[Psi3Parser_Parameters::bohr]
|
---|
| 222 | );
|
---|
| 223 | setvalue >> *params;
|
---|
| 224 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::unitsParam) == params->ValidUnits[Psi3Parser_Parameters::bohr]);
|
---|
| 225 | }
|
---|
| 226 | // test a dertype
|
---|
| 227 | {
|
---|
| 228 | std::stringstream setvalue(
|
---|
| 229 | params->ParamNames[Psi3Parser_Parameters::dertypeParam]
|
---|
| 230 | +" = "+params->ValidDerivativeType[Psi3Parser_Parameters::NONE]
|
---|
| 231 | );
|
---|
| 232 | setvalue >> *params;
|
---|
| 233 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::dertypeParam) == params->ValidDerivativeType[Psi3Parser_Parameters::NONE]);
|
---|
| 234 | }
|
---|
| 235 | // test a freeze_core
|
---|
| 236 | {
|
---|
| 237 | std::stringstream setvalue(
|
---|
| 238 | params->ParamNames[Psi3Parser_Parameters::freeze_coreParam]
|
---|
| 239 | +" = "+params->ValidFreezeCore[Psi3Parser_Parameters::LARGE]
|
---|
| 240 | );
|
---|
| 241 | setvalue >> *params;
|
---|
| 242 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::freeze_coreParam) == params->ValidFreezeCore[Psi3Parser_Parameters::LARGE]);
|
---|
| 243 | }
|
---|
| 244 | // test int
|
---|
| 245 | {
|
---|
| 246 | std::stringstream setvalue(
|
---|
| 247 | params->ParamNames[Psi3Parser_Parameters::maxiterParam]
|
---|
| 248 | +" = 500"
|
---|
| 249 | );
|
---|
| 250 | setvalue >> *params;
|
---|
| 251 | // std::cout << "maxiter is "
|
---|
| 252 | // << params->getString(Psi3Parser_Parameters::maxiterParam) << std::endl;
|
---|
| 253 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::maxiterParam) == std::string("500"));
|
---|
| 254 | }
|
---|
| 255 | // test whether unknown key fails
|
---|
| 256 | std::cout << "The following Assertion warning is desired and does not indicate a failure of the test." << std::endl;
|
---|
| 257 | {
|
---|
| 258 | std::stringstream setvalue("sd = no");
|
---|
| 259 | #ifndef NDEBUG
|
---|
| 260 | ASSERT_DO(Assert::Throw);
|
---|
| 261 | CPPUNIT_ASSERT_THROW(setvalue >> *params, Assert::AssertionFailure);
|
---|
| 262 | #else
|
---|
| 263 | setvalue >> *params;
|
---|
| 264 | #endif
|
---|
| 265 | // std::cout << "Hessian is still "
|
---|
| 266 | // << params->getString(Psi3Parser_Parameters::hessianParam) << std::endl;
|
---|
| 267 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::jobtypeParam) == params->ValidJobtypes[Psi3Parser_Parameters::OPT]);
|
---|
| 268 | }
|
---|
[1bef07] | 269 | }
|
---|
| 270 |
|
---|
| 271 | void ParserPsi3UnitTest::readPsi3Test() {
|
---|
[032f31] | 272 | stringstream input(hydrogenPsi3_RHF);
|
---|
| 273 | // set some other parameter for jobtype
|
---|
| 274 | params->setParameter(
|
---|
| 275 | Psi3Parser_Parameters::jobtypeParam,
|
---|
| 276 | params->ValidJobtypes[Psi3Parser_Parameters::OPT]
|
---|
| 277 | );
|
---|
| 278 | parser->load(&input);
|
---|
| 279 |
|
---|
| 280 | // check for jobtype from file
|
---|
| 281 | CPPUNIT_ASSERT(params->getParameter(Psi3Parser_Parameters::jobtypeParam) == params->ValidJobtypes[Psi3Parser_Parameters::SP]);
|
---|
| 282 | // check for 2 hydrogens
|
---|
| 283 | CPPUNIT_ASSERT_EQUAL(2, World::getInstance().numAtoms());
|
---|
| 284 | // check that positions are right
|
---|
| 285 | Vector PositionSum;
|
---|
| 286 | std::vector<atom *> atoms = World::getInstance().getAllAtoms();
|
---|
| 287 | for (std::vector<atom *>::const_iterator iter = atoms.begin();
|
---|
| 288 | iter != atoms.end();
|
---|
| 289 | ++iter)
|
---|
| 290 | PositionSum += (*iter)->getPosition();
|
---|
[d640ea] | 291 | CPPUNIT_ASSERT_EQUAL( PositionSum, Vector(0.,0.,0.) );
|
---|
[1bef07] | 292 | }
|
---|
| 293 |
|
---|
| 294 | void ParserPsi3UnitTest::writePsi3Test() {
|
---|
[d640ea] | 295 | // build up hydrogen molecule
|
---|
| 296 | string first;
|
---|
| 297 | string second;
|
---|
| 298 | atom *Walker = NULL;
|
---|
| 299 | Walker = World::getInstance().createAtom();
|
---|
| 300 | Walker->setType(1);
|
---|
| 301 | Walker->setPosition(Vector(0.,0.,0.));
|
---|
| 302 | Walker = World::getInstance().createAtom();
|
---|
| 303 | Walker->setType(1);
|
---|
| 304 | Walker->setPosition(Vector(0.,0,0.74));
|
---|
| 305 | CPPUNIT_ASSERT_EQUAL(2, World::getInstance().numAtoms());
|
---|
| 306 |
|
---|
| 307 | // set general parameters: label and freeze_core
|
---|
| 308 | params->setParameter(
|
---|
| 309 | Psi3Parser_Parameters::labelParam,
|
---|
| 310 | "cc-pVTZ SCF H2"
|
---|
| 311 | );
|
---|
| 312 | params->setParameter(
|
---|
| 313 | Psi3Parser_Parameters::freeze_coreParam,
|
---|
| 314 | params->ValidFreezeCore[Psi3Parser_Parameters::NO]
|
---|
| 315 | );
|
---|
| 316 | params->setParameter(
|
---|
| 317 | Psi3Parser_Parameters::unitsParam,
|
---|
| 318 | params->ValidUnits[Psi3Parser_Parameters::angstrom]
|
---|
| 319 | );
|
---|
| 320 |
|
---|
| 321 | // create two stringstreams, one stored, one created
|
---|
| 322 | std::vector<atom *> atoms = World::getInstance().getAllAtoms();
|
---|
| 323 | {
|
---|
| 324 | // compare both configs for RHF
|
---|
| 325 | stringstream output;
|
---|
| 326 | params->setParameter(
|
---|
| 327 | Psi3Parser_Parameters::referenceParam,
|
---|
| 328 | params->ValidReference[Psi3Parser_Parameters::RHF]
|
---|
| 329 | );
|
---|
| 330 | parser->save(&output, atoms);
|
---|
| 331 | stringstream input(hydrogenPsi3_RHF);
|
---|
| 332 | // check for non-empty streams
|
---|
| 333 | input.peek();
|
---|
| 334 | output.peek();
|
---|
| 335 | CPPUNIT_ASSERT(input.good() && output.good());
|
---|
| 336 | // check equality of streams per line (for debugging)
|
---|
| 337 | for (; std::getline(input, first) && std::getline(output, second); ) {
|
---|
| 338 | //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
|
---|
| 339 | CPPUNIT_ASSERT(first == second);
|
---|
| 340 | }
|
---|
| 341 | }
|
---|
| 342 | {
|
---|
| 343 | // compare both configs for ROHF
|
---|
| 344 | stringstream output;
|
---|
| 345 | params->setParameter(
|
---|
| 346 | Psi3Parser_Parameters::referenceParam,
|
---|
| 347 | params->ValidReference[Psi3Parser_Parameters::ROHF]
|
---|
| 348 | );
|
---|
| 349 | parser->save(&output, atoms);
|
---|
| 350 | stringstream input(hydrogenPsi3_ROHF);
|
---|
| 351 | // check for non-empty streams
|
---|
| 352 | input.peek();
|
---|
| 353 | output.peek();
|
---|
| 354 | CPPUNIT_ASSERT(input.good() && output.good());
|
---|
| 355 | // check equality of streams per line (for debugging)
|
---|
| 356 | for (; std::getline(input, first) && std::getline(output, second); ) {
|
---|
| 357 | //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
|
---|
| 358 | CPPUNIT_ASSERT(first == second);
|
---|
| 359 | }
|
---|
| 360 | }
|
---|
| 361 | {
|
---|
| 362 | params->setParameter(Psi3Parser_Parameters::multiplicityParam, "2");
|
---|
| 363 | params->setParameter(Psi3Parser_Parameters::chargeParam, "2");
|
---|
| 364 | // compare both configs for UHF
|
---|
| 365 | stringstream output;
|
---|
| 366 | params->setParameter(
|
---|
| 367 | Psi3Parser_Parameters::referenceParam,
|
---|
| 368 | params->ValidReference[Psi3Parser_Parameters::UHF]
|
---|
| 369 | );
|
---|
| 370 | parser->save(&output, atoms);
|
---|
| 371 | params->setParameter(Psi3Parser_Parameters::chargeParam, "0");
|
---|
| 372 | params->setParameter(Psi3Parser_Parameters::multiplicityParam, "1");
|
---|
| 373 | stringstream input(hydrogenPsi3_UHF);
|
---|
| 374 | // check for non-empty streams
|
---|
| 375 | input.peek();
|
---|
| 376 | output.peek();
|
---|
| 377 | CPPUNIT_ASSERT(input.good() && output.good());
|
---|
| 378 | // check equality of streams per line (for debugging)
|
---|
| 379 | for (; std::getline(input, first) && std::getline(output, second); ) {
|
---|
| 380 | //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
|
---|
| 381 | CPPUNIT_ASSERT(first == second);
|
---|
| 382 | }
|
---|
| 383 | }
|
---|
| 384 | {
|
---|
| 385 | params->setParameter(Psi3Parser_Parameters::multiplicityParam, "1");
|
---|
| 386 | params->setParameter(Psi3Parser_Parameters::chargeParam, "2");
|
---|
| 387 | params->setParameter(Psi3Parser_Parameters::soccParam, "( 1 1 0 0 0 0 0 0 )");
|
---|
| 388 | params->setParameter(Psi3Parser_Parameters::doccParam, "( 0 0 0 0 0 0 0 0 )");
|
---|
| 389 | params->setParameter(Psi3Parser_Parameters::subgroupParam, "c2v");
|
---|
| 390 | params->setParameter(Psi3Parser_Parameters::unique_axisParam, "x");
|
---|
| 391 | // compare both configs for TWOCON
|
---|
| 392 | stringstream output;
|
---|
| 393 | params->setParameter(
|
---|
| 394 | Psi3Parser_Parameters::referenceParam,
|
---|
| 395 | params->ValidReference[Psi3Parser_Parameters::TWOCON]
|
---|
| 396 | );
|
---|
| 397 | parser->save(&output, atoms);
|
---|
| 398 | params->setParameter(Psi3Parser_Parameters::multiplicityParam, "1");
|
---|
| 399 | params->setParameter(Psi3Parser_Parameters::chargeParam, "0");
|
---|
| 400 | stringstream input(hydrogenPsi3_TWOCON);
|
---|
| 401 | // check for non-empty streams
|
---|
| 402 | input.peek();
|
---|
| 403 | output.peek();
|
---|
| 404 | CPPUNIT_ASSERT(input.good() && output.good());
|
---|
| 405 | // check equality of streams per line (for debugging)
|
---|
| 406 | for (; std::getline(input, first) && std::getline(output, second); ) {
|
---|
| 407 | //std::cout << "Comparing '" << first << "' to '" << second << "'" << std::endl;
|
---|
| 408 | CPPUNIT_ASSERT(first == second);
|
---|
| 409 | }
|
---|
| 410 | }
|
---|
[1bef07] | 411 | }
|
---|