Changeset fb73b8
- Timestamp:
- Oct 27, 2009, 5:16:31 PM (15 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- c0f6c6
- Parents:
- 776b64
- git-author:
- Frederik Heber <heber@…> (10/27/09 16:42:42)
- git-committer:
- Frederik Heber <heber@…> (10/27/09 17:16:31)
- Location:
- src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/bond.cpp
r776b64 rfb73b8 25 25 * \param number increasing index 26 26 */ 27 bond::bond(atom *left, atom *right, int degree,int number) : leftatom(left), rightatom(right), previous(NULL), next(NULL), HydrogenBond(0), BondDegree(degree), nr(number), Cyclic(false), Type(Undetermined), Used(white)27 bond::bond(atom *left, atom *right, const int degree, const int number) : leftatom(left), rightatom(right), previous(NULL), next(NULL), HydrogenBond(0), BondDegree(degree), nr(number), Cyclic(false), Type(Undetermined), Used(white) 28 28 { 29 29 if ((left != NULL) && (right != NULL)) { … … 47 47 }; 48 48 49 ostream & operator << (ostream &ost, const bond &b) 49 ostream & operator << (ostream &ost, const bond &b) 50 50 { 51 51 ost << "[" << b.leftatom->Name << " <" << b.BondDegree << "(H" << b.HydrogenBond << ")>" << b.rightatom->Name << "]"; … … 57 57 * \return pointer to the other atom in the bond, NULL if no match (indicates something's wrong with the bond) 58 58 */ 59 atom * bond::GetOtherAtom(const ParticleInfo * Atom) const59 atom * bond::GetOtherAtom(const ParticleInfo * const Atom) const 60 60 { 61 61 if(leftatom == Atom) … … 80 80 * \return true if it is either bond::leftatom or bond::rightatom, false otherwise 81 81 */ 82 bool bond::Contains(const ParticleInfo * ptr)82 bool bond::Contains(const ParticleInfo * const ptr) 83 83 { 84 84 return ((leftatom == ptr) || (rightatom == ptr)); … … 97 97 * \return bond::Used, false if bond was already marked used 98 98 */ 99 bool bond::MarkUsed( enum Shading color) {99 bool bond::MarkUsed(const enum Shading color) { 100 100 if (Used == black) { 101 101 cerr << "ERROR: Bond " << this << " was already marked black!." << endl; -
src/bond.hpp
r776b64 rfb73b8 44 44 enum EdgeType Type;//!< whether this is a tree or back edge 45 45 46 atom * GetOtherAtom(const ParticleInfo * Atom) const;46 atom * GetOtherAtom(const ParticleInfo * const Atom) const; 47 47 48 bool MarkUsed( enum Shading color);48 bool MarkUsed(const enum Shading color); 49 49 enum Shading IsUsed(); 50 50 void ResetUsed(); 51 bool Contains(const ParticleInfo * ptr);51 bool Contains(const ParticleInfo * const ptr); 52 52 bool Contains(const int nr); 53 53 54 54 bond(); 55 bond(atom *left, atom *right, int degree=1,int number=0);55 bond(atom *left, atom *right, const int degree=1, const int number=0); 56 56 ~bond(); 57 57 -
src/config.cpp
r776b64 rfb73b8 52 52 /** Constructor for ConfigFileBuffer class. 53 53 */ 54 ConfigFileBuffer::ConfigFileBuffer() 54 ConfigFileBuffer::ConfigFileBuffer() : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0) 55 55 { 56 NoLines = 0; 57 CurrentLine = 0; 58 buffer = NULL; 59 LineMapping = NULL; 60 } 56 }; 61 57 62 58 /** Constructor for ConfigFileBuffer class with filename to be parsed. 63 59 * \param *filename file name 64 60 */ 65 ConfigFileBuffer::ConfigFileBuffer(c har *filename)61 ConfigFileBuffer::ConfigFileBuffer(const char * const filename) : buffer(NULL), LineMapping(NULL), CurrentLine(0), NoLines(0) 66 62 { 67 NoLines = 0;68 CurrentLine = 0;69 buffer = NULL;70 LineMapping = NULL;71 63 ifstream *file = NULL; 72 64 char line[MAXSTRINGSIZE]; … … 141 133 * \param NoAtoms of subsequent lines to look at 142 134 */ 143 void ConfigFileBuffer::MapIonTypesInBuffer( int NoAtoms)135 void ConfigFileBuffer::MapIonTypesInBuffer(const int NoAtoms) 144 136 { 145 137 map<const char *, int, IonTypeCompare> LineList; … … 168 160 /** Constructor for config file class. 169 161 */ 170 config::config() 171 { 162 config::config() : PsiType(0), MaxPsiDouble(0), PsiMaxNoUp(0), PsiMaxNoDown(0), MaxMinStopStep(1), InitMaxMinStopStep(1), ProcPEGamma(8), ProcPEPsi(1), configpath(NULL), 163 configname(NULL), FastParsing(false), Deltat(0.01), basis(""), databasepath(NULL), DoConstrainedMD(0), MaxOuterStep(0), Thermostat(4), ThermostatImplemented(NULL), 164 ThermostatNames(NULL), TempFrequency(2.5), alpha(0.), HooverMass(0.), TargetTemp(0.00095004455), ScaleTempStep(25), mainname(NULL), defaultpath(NULL), pseudopotpath(NULL), 165 DoOutVis(0), DoOutMes(1), DoOutNICS(0), DoOutOrbitals(0), DoOutCurrent(0), DoFullCurrent(0), DoPerturbation(0), DoWannier(0), CommonWannier(0), SawtoothStart(0.01), 166 VectorPlane(0), VectorCut(0.), UseAddGramSch(1), Seed(1), OutVisStep(10), OutSrcStep(5), MaxPsiStep(0), EpsWannier(1e-7), MaxMinStep(100), RelEpsTotalEnergy(1e-7), 167 RelEpsKineticEnergy(1e-5), MaxMinGapStopStep(0), MaxInitMinStep(100), InitRelEpsTotalEnergy(1e-5), InitRelEpsKineticEnergy(1e-4), InitMaxMinGapStopStep(0), ECut(128.), 168 MaxLevel(5), RiemannTensor(0), LevRFactor(0), RiemannLevel(0), Lev0Factor(2), RTActualUse(0), AddPsis(0), RCut(20.), StructOpt(0), IsAngstroem(1), RelativeCoord(0), 169 MaxTypes(0) { 172 170 mainname = Malloc<char>(MAXSTRINGSIZE,"config constructor: mainname"); 173 171 defaultpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: defaultpath"); … … 176 174 configpath = Malloc<char>(MAXSTRINGSIZE,"config constructor: configpath"); 177 175 configname = Malloc<char>(MAXSTRINGSIZE,"config constructor: configname"); 178 ThermostatImplemented = Malloc<int>(MaxThermostats, "config constructor: *ThermostatImplemented");179 ThermostatNames = Malloc<char*>(MaxThermostats, "config constructor: *ThermostatNames");180 for (int j=0;j<MaxThermostats;j++)181 ThermostatNames[j] = Malloc<char>(12, "config constructor: ThermostatNames[]");182 Thermostat = 4;183 alpha = 0.;184 ScaleTempStep = 25;185 TempFrequency = 2.5;186 176 strcpy(mainname,"pcp"); 187 177 strcpy(defaultpath,"not specified"); … … 191 181 basis = "3-21G"; 192 182 193 strcpy(ThermostatNames[0],"None"); 194 ThermostatImplemented[0] = 1; 195 strcpy(ThermostatNames[1],"Woodcock"); 196 ThermostatImplemented[1] = 1; 197 strcpy(ThermostatNames[2],"Gaussian"); 198 ThermostatImplemented[2] = 1; 199 strcpy(ThermostatNames[3],"Langevin"); 200 ThermostatImplemented[3] = 1; 201 strcpy(ThermostatNames[4],"Berendsen"); 202 ThermostatImplemented[4] = 1; 203 strcpy(ThermostatNames[5],"NoseHoover"); 204 ThermostatImplemented[5] = 1; 205 206 FastParsing = false; 207 ProcPEGamma=8; 208 ProcPEPsi=1; 209 DoOutVis=0; 210 DoOutMes=1; 211 DoOutNICS=0; 212 DoOutOrbitals=0; 213 DoOutCurrent=0; 214 DoPerturbation=0; 215 DoFullCurrent=0; 216 DoWannier=0; 217 DoConstrainedMD=0; 218 CommonWannier=0; 219 SawtoothStart=0.01; 220 VectorPlane=0; 221 VectorCut=0; 222 UseAddGramSch=1; 223 Seed=1; 224 225 MaxOuterStep=0; 226 Deltat=0.01; 227 OutVisStep=10; 228 OutSrcStep=5; 229 TargetTemp=0.00095004455; 230 ScaleTempStep=25; 231 MaxPsiStep=0; 232 EpsWannier=1e-7; 233 234 MaxMinStep=100; 235 RelEpsTotalEnergy=1e-7; 236 RelEpsKineticEnergy=1e-5; 237 MaxMinStopStep=1; 238 MaxMinGapStopStep=0; 239 MaxInitMinStep=100; 240 InitRelEpsTotalEnergy=1e-5; 241 InitRelEpsKineticEnergy=1e-4; 242 InitMaxMinStopStep=1; 243 InitMaxMinGapStopStep=0; 244 245 //BoxLength[NDIM*NDIM]; 246 247 ECut=128.; 248 MaxLevel=5; 249 RiemannTensor=0; 250 LevRFactor=0; 251 RiemannLevel=0; 252 Lev0Factor=2; 253 RTActualUse=0; 254 PsiType=0; 255 MaxPsiDouble=0; 256 PsiMaxNoUp=0; 257 PsiMaxNoDown=0; 258 AddPsis=0; 259 260 RCut=20.; 261 StructOpt=0; 262 IsAngstroem=1; 263 RelativeCoord=0; 264 MaxTypes=0; 183 InitThermostats(); 265 184 }; 266 267 185 268 186 /** Destructor for config file class. … … 282 200 }; 283 201 202 /** Initialises variables in class config for Thermostats. 203 */ 204 void config::InitThermostats() 205 { 206 ThermostatImplemented = Malloc<int>(MaxThermostats, "config constructor: *ThermostatImplemented"); 207 ThermostatNames = Malloc<char*>(MaxThermostats, "config constructor: *ThermostatNames"); 208 for (int j=0;j<MaxThermostats;j++) 209 ThermostatNames[j] = Malloc<char>(12, "config constructor: ThermostatNames[]"); 210 211 strcpy(ThermostatNames[0],"None"); 212 ThermostatImplemented[0] = 1; 213 strcpy(ThermostatNames[1],"Woodcock"); 214 ThermostatImplemented[1] = 1; 215 strcpy(ThermostatNames[2],"Gaussian"); 216 ThermostatImplemented[2] = 1; 217 strcpy(ThermostatNames[3],"Langevin"); 218 ThermostatImplemented[3] = 1; 219 strcpy(ThermostatNames[4],"Berendsen"); 220 ThermostatImplemented[4] = 1; 221 strcpy(ThermostatNames[5],"NoseHoover"); 222 ThermostatImplemented[5] = 1; 223 }; 224 284 225 /** Readin of Thermostat related values from parameter file. 285 226 * \param *fb file buffer containing the config file 286 227 */ 287 void config:: InitThermostats(class ConfigFileBuffer *fb)228 void config::ParseThermostats(class ConfigFileBuffer * const fb) 288 229 { 289 char * thermo = Malloc<char>(12, "IonsInitRead: thermo");290 int verbose = 0;230 char * const thermo = Malloc<char>(12, "IonsInitRead: thermo"); 231 const int verbose = 0; 291 232 292 233 // read desired Thermostat from file along with needed additional parameters … … 354 295 Thermostat = None; 355 296 } 356 Free( &thermo);297 Free(thermo); 357 298 }; 358 299 … … 627 568 * \return 0 - old syntax, 1 - new syntax, -1 - unknown syntax 628 569 */ 629 int config::TestSyntax(c har *filename, periodentafel *periode, molecule *mol)570 int config::TestSyntax(const char * const filename, const periodentafel * const periode, const molecule * const mol) const 630 571 { 631 572 int test; … … 666 607 * \return *defaultpath 667 608 */ 668 void config::SetDefaultPath(const char * path)609 void config::SetDefaultPath(const char * const path) 669 610 { 670 611 strcpy(defaultpath, path); … … 674 615 * \param filename config file string 675 616 */ 676 void config::RetrieveConfigPathAndName( string filename)617 void config::RetrieveConfigPathAndName(const string filename) 677 618 { 678 619 char *ptr = NULL; … … 702 643 * \param *FileBuffer pointer to FileBuffer on return, should point to NULL 703 644 */ 704 void PrepareFileBuffer(c har *filename, struct ConfigFileBuffer *&FileBuffer)645 void PrepareFileBuffer(const char * const filename, struct ConfigFileBuffer *&FileBuffer) 705 646 { 706 647 if (FileBuffer != NULL) { … … 719 660 * \param FastParsing whether to parse trajectories or not 720 661 */ 721 void LoadMolecule(molecule * &mol, struct ConfigFileBuffer *&FileBuffer, periodentafel *periode,bool FastParsing)662 void LoadMolecule(molecule * const &mol, struct ConfigFileBuffer * const &FileBuffer, const periodentafel * const periode, const bool FastParsing) 722 663 { 723 664 int MaxTypes = 0; … … 893 834 * \param *mol pointer to molecule containing all atoms of the molecule 894 835 */ 895 void config::Load(c har *filename, periodentafel *periode, molecule *mol)836 void config::Load(const char * const filename, const periodentafel * const periode, molecule * const &mol) 896 837 { 897 838 ifstream *file = new ifstream(filename); … … 909 850 910 851 /* Oeffne Hauptparameterdatei */ 911 int di ;852 int di = 0; 912 853 double BoxLength[9]; 913 854 string zeile; … … 915 856 int verbose = 0; 916 857 917 InitThermostats(FileBuffer);858 ParseThermostats(FileBuffer); 918 859 919 860 /* Namen einlesen */ … … 1109 1050 * \param *mol pointer to molecule containing all atoms of the molecule 1110 1051 */ 1111 void config::LoadOld(c har *filename, periodentafel *periode, molecule *mol)1052 void config::LoadOld(const char * const filename, const periodentafel * const periode, molecule * const &mol) 1112 1053 { 1113 1054 ifstream *file = new ifstream(filename); … … 1120 1061 1121 1062 /* Oeffne Hauptparameterdatei */ 1122 int l, i, di; 1123 double a,b; 1063 int l = 0; 1064 int i = 0; 1065 int di = 0; 1066 double a = 0.; 1067 double b = 0.; 1124 1068 double BoxLength[9]; 1125 1069 string zeile; 1126 1070 string dummy; 1127 1071 element *elementhash[128]; 1128 int Z, No, AtomNo, found; 1072 int Z = -1; 1073 int No = -1; 1074 int AtomNo = -1; 1075 int found = 0; 1129 1076 int verbose = 0; 1130 1077 … … 1313 1260 * \param *mol pointer to molecule containing all atoms of the molecule 1314 1261 */ 1315 bool config::Save(const char * filename, periodentafel *periode, molecule *mol) const1262 bool config::Save(const char * const filename, const periodentafel * const periode, molecule * const mol) const 1316 1263 { 1317 1264 bool result = true; 1318 1265 // bring MaxTypes up to date 1319 1266 mol->CountElements(); 1320 ofstream *output = NULL; 1321 output = new ofstream(filename, ios::out); 1267 ofstream * const output = new ofstream(filename, ios::out); 1322 1268 if (output != NULL) { 1323 1269 *output << "# ParallelCarParinello - main configuration file - created with molecuilder" << endl; … … 1443 1389 * \param *mol pointer to molecule containing all atoms of the molecule 1444 1390 */ 1445 bool config::SaveMPQC(const char * filename, molecule *mol) const1391 bool config::SaveMPQC(const char * const filename, const molecule * const mol) const 1446 1392 { 1447 int AtomNo ;1393 int AtomNo = -1; 1448 1394 Vector *center = NULL; 1449 1395 ofstream *output = NULL; 1450 stringstream *fname = NULL;1451 1396 1452 1397 // first without hessian 1453 fname = new stringstream; 1454 *fname << filename << ".in"; 1455 output = new ofstream(fname->str().c_str(), ios::out); 1456 *output << "% Created by MoleCuilder" << endl; 1457 *output << "mpqc: (" << endl; 1458 *output << "\tsavestate = no" << endl; 1459 *output << "\tdo_gradient = yes" << endl; 1460 *output << "\tmole<MBPT2>: (" << endl; 1461 *output << "\t\tmaxiter = 200" << endl; 1462 *output << "\t\tbasis = $:basis" << endl; 1463 *output << "\t\tmolecule = $:molecule" << endl; 1464 *output << "\t\treference<CLHF>: (" << endl; 1465 *output << "\t\t\tbasis = $:basis" << endl; 1466 *output << "\t\t\tmolecule = $:molecule" << endl; 1467 *output << "\t\t)" << endl; 1468 *output << "\t)" << endl; 1469 *output << ")" << endl; 1470 *output << "molecule<Molecule>: (" << endl; 1471 *output << "\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl; 1472 *output << "\t{ atoms geometry } = {" << endl; 1473 center = mol->DetermineCenterOfAll(output); 1474 // output of atoms 1475 AtomNo = 0; 1476 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo ); 1477 delete(center); 1478 *output << "\t}" << endl; 1479 *output << ")" << endl; 1480 *output << "basis<GaussianBasisSet>: (" << endl; 1481 *output << "\tname = \"" << basis << "\"" << endl; 1482 *output << "\tmolecule = $:molecule" << endl; 1483 *output << ")" << endl; 1484 output->close(); 1485 delete(output); 1486 delete(fname); 1398 { 1399 stringstream * const fname = new stringstream;; 1400 *fname << filename << ".in"; 1401 output = new ofstream(fname->str().c_str(), ios::out); 1402 *output << "% Created by MoleCuilder" << endl; 1403 *output << "mpqc: (" << endl; 1404 *output << "\tsavestate = no" << endl; 1405 *output << "\tdo_gradient = yes" << endl; 1406 *output << "\tmole<MBPT2>: (" << endl; 1407 *output << "\t\tmaxiter = 200" << endl; 1408 *output << "\t\tbasis = $:basis" << endl; 1409 *output << "\t\tmolecule = $:molecule" << endl; 1410 *output << "\t\treference<CLHF>: (" << endl; 1411 *output << "\t\t\tbasis = $:basis" << endl; 1412 *output << "\t\t\tmolecule = $:molecule" << endl; 1413 *output << "\t\t)" << endl; 1414 *output << "\t)" << endl; 1415 *output << ")" << endl; 1416 *output << "molecule<Molecule>: (" << endl; 1417 *output << "\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl; 1418 *output << "\t{ atoms geometry } = {" << endl; 1419 center = mol->DetermineCenterOfAll(output); 1420 // output of atoms 1421 AtomNo = 0; 1422 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo ); 1423 delete(center); 1424 *output << "\t}" << endl; 1425 *output << ")" << endl; 1426 *output << "basis<GaussianBasisSet>: (" << endl; 1427 *output << "\tname = \"" << basis << "\"" << endl; 1428 *output << "\tmolecule = $:molecule" << endl; 1429 *output << ")" << endl; 1430 output->close(); 1431 delete(output); 1432 delete(fname); 1433 } 1487 1434 1488 1435 // second with hessian 1489 fname = new stringstream; 1490 *fname << filename << ".hess.in"; 1491 output = new ofstream(fname->str().c_str(), ios::out); 1492 *output << "% Created by MoleCuilder" << endl; 1493 *output << "mpqc: (" << endl; 1494 *output << "\tsavestate = no" << endl; 1495 *output << "\tdo_gradient = yes" << endl; 1496 *output << "\tmole<CLHF>: (" << endl; 1497 *output << "\t\tmaxiter = 200" << endl; 1498 *output << "\t\tbasis = $:basis" << endl; 1499 *output << "\t\tmolecule = $:molecule" << endl; 1500 *output << "\t)" << endl; 1501 *output << "\tfreq<MolecularFrequencies>: (" << endl; 1502 *output << "\t\tmolecule=$:molecule" << endl; 1503 *output << "\t)" << endl; 1504 *output << ")" << endl; 1505 *output << "molecule<Molecule>: (" << endl; 1506 *output << "\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl; 1507 *output << "\t{ atoms geometry } = {" << endl; 1508 center = mol->DetermineCenterOfAll(output); 1509 // output of atoms 1510 AtomNo = 0; 1511 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo ); 1512 delete(center); 1513 *output << "\t}" << endl; 1514 *output << ")" << endl; 1515 *output << "basis<GaussianBasisSet>: (" << endl; 1516 *output << "\tname = \"3-21G\"" << endl; 1517 *output << "\tmolecule = $:molecule" << endl; 1518 *output << ")" << endl; 1519 output->close(); 1520 delete(output); 1521 delete(fname); 1436 { 1437 stringstream * const fname = new stringstream; 1438 *fname << filename << ".hess.in"; 1439 output = new ofstream(fname->str().c_str(), ios::out); 1440 *output << "% Created by MoleCuilder" << endl; 1441 *output << "mpqc: (" << endl; 1442 *output << "\tsavestate = no" << endl; 1443 *output << "\tdo_gradient = yes" << endl; 1444 *output << "\tmole<CLHF>: (" << endl; 1445 *output << "\t\tmaxiter = 200" << endl; 1446 *output << "\t\tbasis = $:basis" << endl; 1447 *output << "\t\tmolecule = $:molecule" << endl; 1448 *output << "\t)" << endl; 1449 *output << "\tfreq<MolecularFrequencies>: (" << endl; 1450 *output << "\t\tmolecule=$:molecule" << endl; 1451 *output << "\t)" << endl; 1452 *output << ")" << endl; 1453 *output << "molecule<Molecule>: (" << endl; 1454 *output << "\tunit = " << (IsAngstroem ? "angstrom" : "bohr" ) << endl; 1455 *output << "\t{ atoms geometry } = {" << endl; 1456 center = mol->DetermineCenterOfAll(output); 1457 // output of atoms 1458 AtomNo = 0; 1459 mol->ActOnAllAtoms( &atom::OutputMPQCLine, output, (const Vector *)center, &AtomNo ); 1460 delete(center); 1461 *output << "\t}" << endl; 1462 *output << ")" << endl; 1463 *output << "basis<GaussianBasisSet>: (" << endl; 1464 *output << "\tname = \"3-21G\"" << endl; 1465 *output << "\tmolecule = $:molecule" << endl; 1466 *output << ")" << endl; 1467 output->close(); 1468 delete(output); 1469 delete(fname); 1470 } 1522 1471 1523 1472 return true; … … 1545 1494 * \note Routine is taken from the pcp project and hack-a-slack adapted to C++ 1546 1495 */ 1547 int ParseForParameter(int verbose, ifstream *file, const char *name, int sequential, int const xth, int const yth, int type, void *value, int repetition, int critical) { 1548 int i,j; // loop variables 1549 int length = 0, maxlength = -1; 1496 int ParseForParameter(const int verbose, ifstream * const file, const char * const name, const int sequential, const int xth, const int yth, const int type, void * value, const int repetition, const int critical) { 1497 int i = 0; 1498 int j = 0; // loop variables 1499 int length = 0; 1500 int maxlength = -1; 1550 1501 long file_position = file->tellg(); // mark current position 1551 char *dummy1, *dummy, *free_dummy; // pointers in the line that is read in per step 1552 dummy1 = free_dummy = Malloc<char>(256, "config::ParseForParameter: *free_dummy"); 1502 char *dummy1 = NULL; 1503 char *dummy = NULL; 1504 char * const free_dummy = Malloc<char>(256, "config::ParseForParameter: *free_dummy"); // pointers in the line that is read in per step 1505 dummy1 = free_dummy; 1553 1506 1554 1507 //fprintf(stderr,"Parsing for %s\n",name); … … 1565 1518 if (file->eof()) { 1566 1519 if ((critical) && (found == 0)) { 1567 Free( &free_dummy);1520 Free(free_dummy); 1568 1521 //Error(InitReading, name); 1569 1522 fprintf(stderr,"Error:InitReading, critical %s not found\n", name); … … 1573 1526 file->clear(); 1574 1527 file->seekg(file_position, ios::beg); // rewind to start position 1575 Free( &free_dummy);1528 Free(free_dummy); 1576 1529 return 0; 1577 1530 } … … 1625 1578 if (file->eof()) { 1626 1579 if ((critical) && (found == 0)) { 1627 Free( &free_dummy);1580 Free(free_dummy); 1628 1581 //Error(InitReading, name); 1629 1582 fprintf(stderr,"Error:InitReading, critical %s not found\n", name); … … 1633 1586 file->clear(); 1634 1587 file->seekg(file_position, ios::beg); // rewind to start position 1635 Free( &free_dummy);1588 Free(free_dummy); 1636 1589 return 0; 1637 1590 } … … 1674 1627 if (critical) { 1675 1628 if (verbose) fprintf(stderr,"Error: EoL at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name); 1676 Free( &free_dummy);1629 Free(free_dummy); 1677 1630 //return 0; 1678 1631 exit(255); … … 1682 1635 file->clear(); 1683 1636 file->seekg(file_position, ios::beg); // rewind to start position 1684 Free( &free_dummy);1637 Free(free_dummy); 1685 1638 return 0; 1686 1639 } … … 1695 1648 file->seekg(file_position, ios::beg); // rewind to start position 1696 1649 } 1697 Free( &free_dummy);1650 Free(free_dummy); 1698 1651 return 0; 1699 1652 } … … 1751 1704 if ((type >= row_int) && (verbose)) 1752 1705 fprintf(stderr,"\n"); 1753 Free( &free_dummy);1706 Free(free_dummy); 1754 1707 if (!sequential) { 1755 1708 file->clear(); … … 1783 1736 * \note Routine is taken from the pcp project and hack-a-slack adapted to C++ 1784 1737 */ 1785 int ParseForParameter(int verbose, struct ConfigFileBuffer *FileBuffer, const char *name, int sequential, int const xth, int const yth, int type, void *value, int repetition, int critical) { 1786 int i,j; // loop variables 1787 int length = 0, maxlength = -1; 1738 int ParseForParameter(const int verbose, struct ConfigFileBuffer * const FileBuffer, const char * const name, const int sequential, const int xth, const int yth, const int type, void * value, const int repetition, const int critical) { 1739 int i = 0; 1740 int j = 0; // loop variables 1741 int length = 0; 1742 int maxlength = -1; 1788 1743 int OldCurrentLine = FileBuffer->CurrentLine; 1789 char *dummy1, *dummy; // pointers in the line that is read in per step 1744 char *dummy1 = NULL; 1745 char *dummy = NULL; // pointers in the line that is read in per step 1790 1746 1791 1747 //fprintf(stderr,"Parsing for %s\n",name); -
src/config.hpp
r776b64 rfb73b8 35 35 36 36 ConfigFileBuffer(); 37 ConfigFileBuffer(c har *filename);37 ConfigFileBuffer(const char * const filename); 38 38 ~ConfigFileBuffer(); 39 39 40 40 void InitMapping(); 41 void MapIonTypesInBuffer( int NoAtoms);41 void MapIonTypesInBuffer(const int NoAtoms); 42 42 }; 43 43 … … 130 130 ~config(); 131 131 132 int TestSyntax(c har *filename, periodentafel *periode, molecule *mol);133 void Load(c har *filename, periodentafel *periode, molecule *mol);134 void LoadOld(c har *filename, periodentafel *periode, molecule *mol);135 void RetrieveConfigPathAndName( string filename);136 bool Save(const char * filename, periodentafel *periode, molecule *mol) const;137 bool SaveMPQC(const char * filename, molecule *mol) const;132 int TestSyntax(const char * const filename, const periodentafel * const periode, const molecule * const mol) const; 133 void Load(const char * const filename, const periodentafel * const periode, molecule * const &mol); 134 void LoadOld(const char * const filename, const periodentafel * const periode, molecule * const &mol); 135 void RetrieveConfigPathAndName(const string filename); 136 bool Save(const char * const filename, const periodentafel * const periode, molecule * const mol) const; 137 bool SaveMPQC(const char * const filename, const molecule * const mol) const; 138 138 void Edit(); 139 139 bool GetIsAngstroem() const; 140 140 char *GetDefaultPath() const; 141 void SetDefaultPath(const char *path); 142 void InitThermostats(class ConfigFileBuffer *fb); 141 void SetDefaultPath(const char * const path); 142 void InitThermostats(); 143 void ParseThermostats(class ConfigFileBuffer * const fb); 143 144 }; 144 145 145 int ParseForParameter( int verbose, ifstream *file, const char *name, int sequential, int const xth, int const yth, int type, void *value, int repetition,int critical);146 int ParseForParameter( int verbose, struct ConfigFileBuffer *FileBuffer, const char *name, int sequential, int const xth, int const yth, int type, void *value, int repetition,int critical);147 void LoadMolecule(molecule * &mol, struct ConfigFileBuffer *&FileBuffer, periodentafel *periode,bool FastParsing);148 void PrepareFileBuffer(c har *filename, struct ConfigFileBuffer *&FileBuffer);146 int ParseForParameter(const int verbose, ifstream * const file, const char * const name, const int sequential, const int xth, const int yth, const int type, void * value, const int repetition, const int critical); 147 int ParseForParameter(const int verbose, struct ConfigFileBuffer * const FileBuffer, const char * const name, const int sequential, const int xth, const int yth, const int type, void * value, const int repetition, const int critical); 148 void LoadMolecule(molecule * const &mol, struct ConfigFileBuffer * const &FileBuffer, const periodentafel * const periode, const bool FastParsing); 149 void PrepareFileBuffer(const char * const filename, struct ConfigFileBuffer *&FileBuffer); 149 150 150 151 #endif /* CONFIG_HPP_ */ -
src/memoryallocator.hpp
r776b64 rfb73b8 105 105 }; 106 106 107 /** Frees allocated memory range using free() .107 /** Frees allocated memory range using free(), NULL'ing \a **buffer. 108 108 * 109 * \param pointer to the allocated memory range to free; may be NULL, this function is a no-op then109 * \param **buffer to the allocated memory range to free; may be NULL, this function is a no-op then 110 110 * \param *msg optional error message 111 111 */ … … 120 120 }; 121 121 122 /** Frees allocated memory range using free() for ... * const \a buffer types. 123 * 124 * \param *buffer to the allocated memory range to free; may be NULL, this function is a no-op then 125 * \param *msg optional error message 126 */ 127 template <typename X> void Free(X* const buffer, const char *msg = NULL) 128 { 129 if ((buffer == NULL)) 130 return; 131 132 MemoryUsageObserver::getInstance()->removeMemory(buffer, msg); 133 free(buffer); 134 }; 135 122 136 #endif /*MEMORYALLOCATOR_HPP_*/ -
src/periodentafel.cpp
r776b64 rfb73b8 21 21 * Initialises start and end of list and resets periodentafel::checkliste to false. 22 22 */ 23 periodentafel::periodentafel() 24 { 25 start = new element; 26 end = new element; 23 periodentafel::periodentafel() : start(new element), end(new element) 24 { 27 25 start->previous = NULL; 28 26 start->next = end; … … 45 43 * \return true - succeeded, false - does not occur 46 44 */ 47 bool periodentafel::AddElement(element * pointer)45 bool periodentafel::AddElement(element * const pointer) 48 46 { 49 47 pointer->sort = &pointer->Z; … … 57 55 * \return true - succeeded, false - element not found 58 56 */ 59 bool periodentafel::RemoveElement(element * pointer)57 bool periodentafel::RemoveElement(element * const pointer) 60 58 { 61 59 return remove(pointer, start, end); … … 71 69 72 70 /** Finds an element by its atomic number. 73 * If element is not yet in list, datas are asked and stored in database.71 * If element is not yet in list, returns NULL. 74 72 * \param Z atomic number 75 * \return pointer to element 76 */ 77 element * periodentafel::FindElement(int Z)73 * \return pointer to element or NULL if not found 74 */ 75 element * const periodentafel::FindElement(const int Z) const 78 76 { 79 77 element *walker = find(&Z, start,end); 80 if (walker == NULL) { // not found: enter and put into db81 cout << Verbose(0) << "Element not found in database, please enter." << endl;82 walker = new element;83 cout << Verbose(0) << "Mass: " << endl;84 cin >> walker->mass;85 walker->Z = Z;86 cout << Verbose(0) << "Atomic number: " << walker->Z << endl;87 cout << Verbose(0) << "Name [max 64 chars]: " << endl;88 cin >> walker->name;89 cout << Verbose(0) << "Short form [max 3 chars]: " << endl;90 cin >> walker->symbol;91 periodentafel::AddElement(walker);92 }93 78 return(walker); 94 79 }; … … 99 84 * \return pointer to element 100 85 */ 101 element * periodentafel::FindElement(const char *shorthand) const86 element * const periodentafel::FindElement(const char * const shorthand) const 102 87 { 103 88 element *walker = periodentafel::start; … … 112 97 /** Asks for element number and returns pointer to element 113 98 */ 114 element * periodentafel::AskElement()99 element * const periodentafel::AskElement() const 115 100 { 116 101 element *walker = NULL; … … 124 109 }; 125 110 111 /** Asks for element and if not found, presents mask to enter info. 112 * \return pointer to either present or newly created element 113 */ 114 element * const periodentafel::EnterElement() 115 { 116 element *walker = NULL; 117 int Z = -1; 118 cout << Verbose(0) << "Atomic number: " << Z << endl; 119 cin >> Z; 120 walker = FindElement(Z); 121 if (walker == NULL) { 122 cout << Verbose(0) << "Element not found in database, please enter." << endl; 123 walker = new element; 124 walker->Z = Z; 125 cout << Verbose(0) << "Mass: " << endl; 126 cin >> walker->mass; 127 cout << Verbose(0) << "Name [max 64 chars]: " << endl; 128 cin >> walker->name; 129 cout << Verbose(0) << "Short form [max 3 chars]: " << endl; 130 cin >> walker->symbol; 131 periodentafel::AddElement(walker); 132 } 133 return(walker); 134 }; 135 126 136 /** Prints period table to given stream. 127 137 * \param output stream 128 138 */ 129 bool periodentafel::Output(ofstream * output) const139 bool periodentafel::Output(ofstream * const output) const 130 140 { 131 141 bool result = true; … … 145 155 * \param *checkliste elements table for this molecule 146 156 */ 147 bool periodentafel::Checkout(ofstream * output, const int *checkliste) const157 bool periodentafel::Checkout(ofstream * const output, const int * const checkliste) const 148 158 { 149 159 element *walker = start; -
src/periodentafel.hpp
r776b64 rfb73b8 34 34 ~periodentafel(); 35 35 36 bool AddElement(element * pointer);37 bool RemoveElement(element * pointer);36 bool AddElement(element * const pointer); 37 bool RemoveElement(element * const pointer); 38 38 bool CleanupPeriodtable(); 39 element * FindElement(int Z); 40 element * FindElement(const char *shorthand) const; 41 element * AskElement(); 42 bool Output(ofstream *output) const; 43 bool Checkout(ofstream *output, const int *checkliste) const; 44 bool LoadPeriodentafel(const char *path); 45 bool StorePeriodentafel(const char *path) const; 39 element * const FindElement(const int Z) const; 40 element * const FindElement(const char * const shorthand) const; 41 element * const AskElement() const; 42 element * const EnterElement(); 43 bool Output(ofstream * const output) const; 44 bool Checkout(ofstream * const output, const int * const checkliste) const; 45 bool LoadPeriodentafel(const char * const path); 46 bool StorePeriodentafel(const char * const path) const; 46 47 47 48 private: -
src/vector.hpp
r776b64 rfb73b8 27 27 28 28 Vector(); 29 Vector( double x1, double x2,double x3);29 Vector(const double x1, const double x2, const double x3); 30 30 ~Vector(); 31 31
Note:
See TracChangeset
for help on using the changeset viewer.