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