Changeset 6a465e
- Timestamp:
- Feb 24, 2011, 7:47:41 PM (14 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:
- fcac72
- Parents:
- 03c77c
- git-author:
- Frederik Heber <heber@…> (02/24/11 11:20:52)
- git-committer:
- Frederik Heber <heber@…> (02/24/11 19:47:41)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ConfigFileBuffer.cpp
r03c77c r6a465e 20 20 #include "CodePatterns/MemDebug.hpp" 21 21 22 #include <iostream> 23 #include <boost/tokenizer.hpp> 24 #include <string> 25 22 26 #include "ConfigFileBuffer.hpp" 23 27 #include "Helpers/helpers.hpp" … … 31 35 */ 32 36 struct IonTypeCompare { 33 bool operator()(const char* s1, const char *s2) const { 34 char number1[8]; 35 char number2[8]; 36 const char *dummy1, *dummy2; 37 //Log() << Verbose(0) << s1 << " " << s2 << endl; 38 dummy1 = strchr(s1, '_')+sizeof(char)*5; // go just after "Ion_Type" 39 dummy2 = strchr(dummy1, '_'); 40 strncpy(number1, dummy1, dummy2-dummy1); // copy the number 41 number1[dummy2-dummy1]='\0'; 42 dummy1 = strchr(s2, '_')+sizeof(char)*5; // go just after "Ion_Type" 43 dummy2 = strchr(dummy1, '_'); 44 strncpy(number2, dummy1, dummy2-dummy1); // copy the number 45 number2[dummy2-dummy1]='\0'; 46 if (atoi(number1) != atoi(number2)) 47 return (atoi(number1) < atoi(number2)); 37 bool operator()(std::string s1, std::string s2) const { 38 ConvertTo<int> toInt; 39 boost::char_separator<char> sep("_"); 40 tokenizer tokens1(s1,sep); 41 tokenizer tokens2(s2,sep); 42 tokenizer::iterator tok_iter1 = tokens1.begin(); 43 tokenizer::iterator tok_iter2 = tokens2.begin(); 44 ++tok_iter1; 45 ++tok_iter2; 46 47 std::string element1(*tok_iter1++); 48 std::string element2(*tok_iter2++); 49 int elementno1 = toInt(element1.substr(4,string::npos)); 50 int elementno2 = toInt(element2.substr(4,string::npos)); 51 if (elementno1 != elementno2) 52 return elementno1 < elementno2; 48 53 else { 49 dummy1 = strchr(s1, '_')+sizeof(char); 50 dummy1 = strchr(dummy1, '_')+sizeof(char); 51 dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t'); 52 strncpy(number1, dummy1, dummy2-dummy1); // copy the number 53 number1[dummy2-dummy1]='\0'; 54 dummy1 = strchr(s2, '_')+sizeof(char); 55 dummy1 = strchr(dummy1, '_')+sizeof(char); 56 dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t'); 57 strncpy(number2, dummy1, dummy2-dummy1); // copy the number 58 number2[dummy2-dummy1]='\0'; 59 return (atoi(number1) < atoi(number2)); 54 std::string atom1(*tok_iter1); 55 std::string atom2(*tok_iter2); 56 int atomno1 = toInt(atom1); 57 int atomno2 = toInt(atom2); 58 return atomno1 < atomno2; 60 59 } 61 } 60 61 // char number1[8]; 62 // char number2[8]; 63 // const char *dummy1 = s1.c_str(); 64 // const char *dummy2 = s2.c_str(); 65 // //Log() << Verbose(0) << s1 << " " << s2 << endl; 66 // dummy1 = strchr(s1, '_')+sizeof(char)*5; // go just after "Ion_Type" 67 // dummy2 = strchr(dummy1, '_'); 68 // strncpy(number1, dummy1, dummy2-dummy1); // copy the number 69 // number1[dummy2-dummy1]='\0'; 70 // dummy1 = strchr(s2, '_')+sizeof(char)*5; // go just after "Ion_Type" 71 // dummy2 = strchr(dummy1, '_'); 72 // strncpy(number2, dummy1, dummy2-dummy1); // copy the number 73 // number2[dummy2-dummy1]='\0'; 74 // if (atoi(number1) != atoi(number2)) 75 // return (atoi(number1) < atoi(number2)); 76 // else { 77 // dummy1 = strchr(s1, '_')+sizeof(char); 78 // dummy1 = strchr(dummy1, '_')+sizeof(char); 79 // dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t'); 80 // strncpy(number1, dummy1, dummy2-dummy1); // copy the number 81 // number1[dummy2-dummy1]='\0'; 82 // dummy1 = strchr(s2, '_')+sizeof(char); 83 // dummy1 = strchr(dummy1, '_')+sizeof(char); 84 // dummy2 = strchr(dummy1, ' ') < strchr(dummy1, '\t') ? strchr(dummy1, ' ') : strchr(dummy1, '\t'); 85 // strncpy(number2, dummy1, dummy2-dummy1); // copy the number 86 // number2[dummy2-dummy1]='\0'; 87 // return (atoi(number1) < atoi(number2)); 88 // } 89 } 90 91 typedef boost::tokenizer<boost::char_separator<char> > tokenizer; 62 92 }; 93 63 94 64 95 /** Constructor for ConfigFileBuffer class. … … 182 213 void ConfigFileBuffer::MapIonTypesInBuffer(const int NoAtoms) 183 214 { 184 map<const char *, int, IonTypeCompare> IonTypeLineMap;215 std::multimap<std::string, int, IonTypeCompare> IonTypeLineMap; 185 216 if (!MappingAllocated) { 186 217 InitMapping(); 187 218 } 188 219 220 typedef boost::tokenizer<boost::char_separator<char> > 221 tokenizer; 222 boost::char_separator<char> sep("\t "); 223 189 224 // put all into hashed map 190 for (int i=0; i<NoAtoms; ++i) { 191 IonTypeLineMap.insert(pair<const char *, int> (buffer[CurrentLine+i], CurrentLine+i)); 192 } 193 194 // fill map 225 for (int i=CurrentLine; i<NoLines; ++i) { 226 std::string line(buffer[i]); 227 tokenizer tokens(line, sep); 228 if (tokens.begin() != tokens.end()) { 229 const std::string token = *tokens.begin(); 230 if (token.find("Ion_Type") != string::npos) { 231 IonTypeLineMap.insert(pair<std::string, int> (token, i)); 232 } 233 } 234 } 235 236 // fill map (aka IonType1_1, IonType1_1, IonType1_1, IonType1_2, IonType1_2, IonType1_2, ... 237 // ..., IonType2_1, IonType2_1, IonType2_1, ...) 195 238 int nr=0; 196 for (map< const char *, int, IonTypeCompare>::iterator runner = IonTypeLineMap.begin(); runner != IonTypeLineMap.end(); ++runner) {239 for (map<std::string, int, IonTypeCompare>::iterator runner = IonTypeLineMap.begin(); runner != IonTypeLineMap.end(); ++runner) { 197 240 if (CurrentLine+nr < NoLines) 198 241 LineMapping[CurrentLine+(nr++)] = runner->second; 199 242 else { 200 DoeLog(0) && (eLog()<< Verbose(0) << "config::MapIonTypesInBuffer - No Atoms is wrong: We are past the end of the file!" << endl);243 DoeLog(0) && (eLog()<< Verbose(0) << "config::MapIonTypesInBuffer - NoLines is wrong: We are past the end of the file!" << endl); 201 244 performCriticalExit(); 202 245 } -
src/Parser/unittests/ParserPcpUnitTest.cpp
r03c77c r6a465e 111 111 Ion_Type2\t1\t8\t1.0\t3\t3\t15.999\tOxygen\tO\n\ 112 112 #Ion_TypeNr._Nr.R[0]\tR[1]\tR[2]\tMoveType (0 MoveIon, 1 FixedIon)\n\ 113 Ion_Type2_1\t 0.000000000\t0.000000000\t0.000000000\t0 # molecule nr 0\n\113 Ion_Type2_1\t1.000000000\t0.000000000\t0.000000000\t0 # molecule nr 0\n\ 114 114 Ion_Type1_1\t0.758602\t0.000000000\t0.504284\t0 # molecule nr 1\n\ 115 115 Ion_Type1_2\t0.758602\t0.000000000\t-0.504284\t0 # molecule nr 2\n"; -
src/config.cpp
r03c77c r6a465e 21 21 #include <stdio.h> 22 22 #include <cstring> 23 #include <iostream> 24 #include <boost/tokenizer.hpp> 25 #include <string> 23 26 24 27 //#include "Actions/FragmentationAction/SubgraphDissectionAction.hpp" … … 457 460 int MaxTypes = 0; 458 461 const element *elementhash[MAX_ELEMENTS]; 459 char name[MAX _ELEMENTS];460 char keyword[MAX _ELEMENTS];462 char name[MAXSTRINGSIZE]; 463 char keyword[MAXSTRINGSIZE]; 461 464 int Z = -1; 462 465 int No[MAX_ELEMENTS]; 463 int verbose = 0; 464 Vector tempVector; 465 int _fixedion; 466 int verbose = DoLog(4); 466 467 double value[3]; 467 468 … … 487 488 NoAtoms += No[i]; 488 489 } 489 int repetition = 0; // which repeated keyword shall be read490 int repetition = -1; // which repeated keyword shall be read 490 491 491 492 // sort the lines via the LineMapping … … 499 500 //Log() << Verbose(0) << FileBuffer->buffer[ FileBuffer->LineMapping[FileBuffer->CurrentLine]]; 500 501 FileBuffer->MapIonTypesInBuffer(NoAtoms); 501 //for (int i=0; i<(NoAtoms < 100 ? NoAtoms : 100 < 100 ? NoAtoms : 100);++i) {502 // Log() << Verbose(0) << FileBuffer->buffer[ FileBuffer->LineMapping[FileBuffer->CurrentLine+i]];503 //}502 for (int i=FileBuffer->CurrentLine; i<FileBuffer->NoLines;++i) { 503 Log() << Verbose(0) << FileBuffer->buffer[ FileBuffer->LineMapping[i] ]; 504 } 504 505 505 506 map<int, atom *> AtomList[MaxTypes]; 506 507 map<int, atom *> LinearList; 507 508 atom *neues = NULL; 508 Vector position; 509 if (!FastParsing) { 510 // parse in trajectories 511 bool status = true; 512 while (status) { 513 DoLog(0) && (Log() << Verbose(0) << "Currently parsing MD step " << repetition << "." << endl); 514 for (int i=0; i < MaxTypes; i++) { 515 sprintf(name,"Ion_Type%i",i+1); 516 for(int j=0;j<No[i];j++) { 517 sprintf(keyword,"%s_%i",name, j+1); 518 if (repetition == 0) { 519 neues = World::getInstance().createAtom(); 520 AtomList[i][j] = neues; 521 LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues; 522 neues->setType(elementhash[i]); // find element type 523 } else 524 neues = AtomList[i][j]; 525 status = (status && 526 ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &position[0], 1, (repetition == 0) ? critical : optional) && 527 ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &position[1], 1, (repetition == 0) ? critical : optional) && 528 ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &position[2], 1, (repetition == 0) ? critical : optional) && 529 ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &_fixedion, 1, (repetition == 0) ? critical : optional)); 530 if (!status) 509 Vector tempVector; 510 int _fixedion; 511 512 typedef boost::tokenizer<boost::char_separator<char> > 513 tokenizer; 514 boost::char_separator<char> sep("\t "); 515 ConvertTo<double> toDouble; 516 ConvertTo<int> toInt; 517 518 for (int i=0; i < MaxTypes; i++) { 519 for(int j=0;j<No[i];j++) { 520 int step = 0; 521 std::stringstream keyword_stream; 522 keyword_stream << "Ion_Type" << i+1 << "_" << j+1; 523 const std::string keyword = keyword_stream.str(); 524 DoLog(3) && (Log() << Verbose(3) << "INFO: Parsing for " << keyword << "." << std::endl); 525 while (true) { 526 const std::string line(FileBuffer->buffer[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ]); 527 const std::string line_without_comment = line.substr(0,line.find("#")); 528 tokenizer tokens(line_without_comment, sep); 529 if (tokens.begin() != tokens.end()) { 530 tokenizer::iterator tok_iter = tokens.begin(); 531 const std::string token = *tok_iter++; 532 if (token == keyword) { 533 DoLog(3) && (Log() << Verbose(3) << "INFO: Found keyword " << keyword << " in line " << FileBuffer->CurrentLine << std::endl); 534 if (step == 0) { 535 neues = World::getInstance().createAtom(); 536 AtomList[i][j] = neues; 537 std::cout << "filling LinearList [ (FileBuffer->LineMapping[" << FileBuffer->CurrentLine << "]) = " << FileBuffer->LineMapping[FileBuffer->CurrentLine] << " with " << neues << endl; 538 LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues; 539 neues->setType(elementhash[i]); // find element type 540 } else 541 neues = AtomList[i][j]; 542 543 // count tokens 544 size_t tokens_size = 0; 545 for (tokenizer::iterator tokiter = tokens.begin(); tokiter != tokens.end(); ++tokiter) 546 ++tokens_size; 547 DoLog(3) && (Log() << Verbose(3) << "INFO: Line contains " << tokens_size << " tokens." << std::endl); 548 // and parse 549 if (tokens_size >= 5) { // only AtomicPosition and FixedIon 550 DoLog(3) && (Log() << Verbose(3) << "INFO: Parsing AtomicPosition and FixedIon" << std::endl); 551 for (int i=0;i<NDIM;++i) 552 tempVector[i] = toDouble(*tok_iter++); 553 neues->setPositionAtStep(step, tempVector); 554 _fixedion = toInt(*tok_iter++); 555 neues->setFixedIon(_fixedion == 1); 556 } 557 if (tokens_size >= 8) { // AtomicVelocity 558 DoLog(3) && (Log() << Verbose(3) << "INFO: Parsing AtomicVelocity" << std::endl); 559 for (int i=0;i<NDIM;++i) 560 tempVector[i] = toDouble(*tok_iter++); 561 neues->setAtomicVelocityAtStep(step, tempVector); 562 } 563 if (tokens_size >= 11) { // AtomicForce 564 DoLog(3) && (Log() << Verbose(3) << "INFO: Parsing AtomicForce" << std::endl); 565 for (int i=0;i<NDIM;++i) 566 tempVector[i] = toDouble(*tok_iter++); 567 neues->setAtomicForceAtStep(step, tempVector); 568 } 569 std::stringstream output; 570 output << "Parsed position of step " << (step+1) << ": "; 571 output << neues->getPositionAtStep(step); // next step 572 output << "\t"; 573 output << (neues->getFixedIon() ? "true" : "false"); 574 output << "\t"; 575 output << neues->getAtomicVelocityAtStep(step); // next step 576 output << "\t"; 577 output << neues->getAtomicForceAtStep(step); // next step 578 DoLog(2) && (Log() << Verbose(2) << output.str() << endl); 579 580 step++; 581 } else { 582 if ((repetition > step) || (repetition == -1)) 583 repetition = step; 531 584 break; 532 533 // check size of vectors534 if (neues->getTrajectorySize() <= (unsigned int)(repetition)) {535 //Log() << Verbose(0) << "Increasing size for trajectory array of " << keyword << " to " << (repetition+10) << "." << endl;536 neues->ResizeTrajectory(repetition+1);537 neues->ResizeTrajectory(repetition+1);538 neues->ResizeTrajectory(repetition+1);539 585 } 540 neues->setFixedIon(_fixedion);541 neues->setPositionAtStep(repetition,position);542 543 // parse velocities if present544 tempVector.Zero();545 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &tempVector[0], 1,optional))546 tempVector[0] = 0.;547 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &tempVector[1], 1,optional))548 tempVector[1] = 0.;549 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &tempVector[2], 1,optional))550 tempVector[2] = 0.;551 neues->setAtomicVelocityAtStep(repetition, tempVector);552 553 // parse forces if present554 tempVector.Zero();555 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 8, 1, double_type, &tempVector[0], 1,optional))556 tempVector[0] = 0.;557 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 9, 1, double_type, &tempVector[1], 1,optional))558 tempVector[1] = 0.;559 if(!ParseForParameter(verbose,FileBuffer, keyword, 1, 10, 1, double_type, &tempVector[2], 1,optional))560 tempVector[2] = 0.;561 neues->setAtomicForceAtStep(repetition, tempVector);562 563 // Log() << Verbose(0) << "Parsed position of step " << (repetition) << ": (";564 // Log() << Verbose(0) << neues->getPosition(repetition) << " "; // next step565 // Log() << Verbose(0) << neues->getAtomicVelocity(repetition) << " "; // next step566 // Log() << Verbose(0) << neues->getAtomicForce(repetition) << " "; // next step567 // Log() << Verbose(0) << ")" << endl;568 586 } 569 } 570 repetition++; 571 } 572 repetition--; 573 DoLog(0) && (Log() << Verbose(0) << "Found " << repetition << " trajectory steps." << endl); 574 if (repetition <= 1) // if onyl one step, desactivate use of trajectories 575 mol->MDSteps = 0; 576 else 577 mol->MDSteps = repetition; 578 } else { 579 // find the maximum number of MD steps so that we may parse last one (Ion_Type1_1 must always be present, because is the first atom) 580 repetition = 0; 581 while ( ParseForParameter(verbose,FileBuffer, "Ion_Type1_1", 0, 1, 1, double_type, &value[0], repetition, (repetition == 0) ? critical : optional) && 582 ParseForParameter(verbose,FileBuffer, "Ion_Type1_1", 0, 2, 1, double_type, &value[1], repetition, (repetition == 0) ? critical : optional) && 583 ParseForParameter(verbose,FileBuffer, "Ion_Type1_1", 0, 3, 1, double_type, &value[2], repetition, (repetition == 0) ? critical : optional)) 584 repetition++; 585 DoLog(0) && (Log() << Verbose(0) << "I found " << repetition << " times the keyword Ion_Type1_1." << endl); 586 // parse in molecule coordinates 587 for (int i=0; i < MaxTypes; i++) { 588 sprintf(name,"Ion_Type%i",i+1); 589 for(int j=0;j<No[i];j++) { 590 sprintf(keyword,"%s_%i",name, j+1); 591 if (repetition == 0) { 592 neues = World::getInstance().createAtom(); 593 AtomList[i][j] = neues; 594 LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues; 595 neues->setType(elementhash[i]); // find element type 596 } else 597 neues = AtomList[i][j]; 598 // then parse for each atom the coordinates as often as present 599 tempVector.Zero(); 600 ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &tempVector[0], repetition,critical); 601 ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &tempVector[1], repetition,critical); 602 ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &tempVector[2], repetition,critical); 603 neues->setPosition(tempVector); 604 // fixed ion 605 ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &_fixedion, repetition,critical); 606 neues->setFixedIon(_fixedion); 607 // and velocity 608 tempVector.Zero(); 609 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &tempVector[0], repetition,optional)) 610 tempVector[0] = 0.; 611 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &tempVector[1], repetition,optional)) 612 tempVector[1] = 0.; 613 if(!ParseForParameter(verbose,FileBuffer, keyword, 0, 7, 1, double_type, &tempVector[2], repetition,optional)) 614 tempVector[2] = 0.; 615 neues->setAtomicVelocity(tempVector); 616 // here we don't care if forces are present (last in trajectories is always equal to current position) 617 neues->setType(elementhash[i]); // find element type 618 mol->AddAtom(neues); 587 FileBuffer->CurrentLine++; 619 588 } 620 589 } 621 590 } 591 592 if (repetition <= 1) // if onyl one step, desactivate use of trajectories 593 mol->MDSteps = 0; 594 else { 595 DoLog(0) && (Log() << Verbose(0) << "Found " << repetition << " trajectory step(s)." << endl); 596 mol->MDSteps = repetition; 597 } 598 599 // if (!FastParsing) { 600 // // parse in trajectories 601 // bool status = true; 602 // while (status) { 603 // DoLog(0) && (Log() << Verbose(0) << "Currently checking on MD step " << repetition+1 << "." << endl); 604 // for (int i=0; i < MaxTypes; i++) { 605 // sprintf(name,"Ion_Type%i",i+1); 606 // for(int j=0;j<No[i];j++) { 607 // sprintf(keyword,"%s_%i",name, j+1); 608 // DoLog(3) && (Log() << Verbose(3) << "Looking for " << keyword << " of " << (repetition) << " repetition." << std::endl); 609 // DoLog(3) && (Log() << Verbose(3) << "INFO: Parsing AtomicPosition." << std::endl); 610 // for (int k=0;k<NDIM;++k) { // repetition=1 is correct, as we advance eventually by sequential=1! 611 // status = status && ParseForParameter(verbose,FileBuffer, (const char*)keyword, 0, 1+k, 1, double_type, &tempVector[k], 1, (repetition == 0) ? critical : optional); 612 // } 613 // if (!status) 614 // break; 615 // 616 // if (repetition == 0) { 617 // neues = World::getInstance().createAtom(); 618 // AtomList[i][j] = neues; 619 // std::cout << "filling LinearList [ (FileBuffer->LineMapping[" << FileBuffer->CurrentLine << "]) = " << FileBuffer->LineMapping[FileBuffer->CurrentLine] << " with " << neues << endl; 620 // LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues; 621 // neues->setType(elementhash[i]); // find element type 622 // } else 623 // neues = AtomList[i][j]; 624 // 625 // DoLog(3) && (Log() << Verbose(3) << "INFO: Parsing FixedIon." << std::endl); 626 // status = status && ParseForParameter(verbose,FileBuffer, (const char*)keyword, 0, 4, 1, int_type, &_fixedion, 1, (repetition == 0) ? critical : optional); 627 // neues->setFixedIon(_fixedion == 1); 628 // 629 // // check size of vectors 630 // if (neues->getTrajectorySize() <= (unsigned int)(repetition)) { 631 // neues->ResizeTrajectory(repetition+10); 632 // //Log() << Verbose(0) << "Increasing size for trajectory array of " << keyword << " to " << (repetition+10) << "." << endl; 633 // } 634 // 635 // // put into trajectories list 636 // neues->setPosition(repetition, tempVector); 637 // 638 // // parse velocities if present 639 // DoLog(3) && (Log() << Verbose(3) << "INFO: Parsing AtomicVelocity." << std::endl); 640 // bool velocityStatus = true; 641 // for (int k=0;k<NDIM;++k) 642 // velocityStatus = velocityStatus && ParseForParameter(verbose,FileBuffer, (const char*)keyword, 0, 5+k, 1, double_type, &tempVector[k], 1,optional); 643 // if (!velocityStatus) { 644 // neues->setAtomicVelocity(repetition, zeroVec); 645 // } else 646 // neues->setAtomicVelocity(repetition, tempVector); 647 // 648 // // parse forces if present 649 // DoLog(3) && (Log() << Verbose(3) << "INFO: Parsing AtomicForce." << std::endl); 650 // bool forceStatus = true; 651 // for (int k=0;k<NDIM;++k) 652 // forceStatus = forceStatus && ParseForParameter(verbose,FileBuffer, (const char*)keyword, (k==(NDIM-1)) ? 1 : 0, 8+k, 1, double_type, &tempVector[k], 1,optional); 653 // if (!forceStatus) { 654 // ++FileBuffer->CurrentLine; // as above sequential=1 did not apply due to end of file 655 // neues->setAtomicForce(repetition, zeroVec); 656 // } else { 657 // neues->setAtomicForce(repetition, tempVector); 658 // } 659 // 660 // std::stringstream output; 661 // output << "Parsed position of step " << (repetition+1) << ": "; 662 // output << neues->getPosition(repetition); // next step 663 // output << "\t"; 664 // output << (neues->getFixedIon() ? "true" : "false"); 665 // output << "\t"; 666 // output << neues->getAtomicVelocity(repetition); // next step 667 // output << "\t"; 668 // output << neues->getAtomicForce(repetition); // next step 669 // DoLog(2) && (Log() << Verbose(2) << output.str() << endl); 670 // } 671 // } 672 // repetition++; 673 // } 674 // repetition--; 675 // if (repetition <= 1) // if onyl one step, desactivate use of trajectories 676 // mol->MDSteps = 0; 677 // else { 678 // DoLog(0) && (Log() << Verbose(0) << "Found " << repetition+1 << " trajectory step(s)." << endl); 679 // mol->MDSteps = repetition; 680 // } 681 // } else { 682 // // find the maximum number of MD steps so that we may parse last one (Ion_Type1_1 must always be present, because is the first atom) 683 // repetition = 0; 684 // while ( ParseForParameter(verbose,FileBuffer, "Ion_Type1_1", 0, 1, 1, double_type, &value[0], repetition, (repetition == 0) ? critical : optional) && 685 // ParseForParameter(verbose,FileBuffer, "Ion_Type1_1", 0, 2, 1, double_type, &value[1], repetition, (repetition == 0) ? critical : optional) && 686 // ParseForParameter(verbose,FileBuffer, "Ion_Type1_1", 0, 3, 1, double_type, &value[2], repetition, (repetition == 0) ? critical : optional)) 687 // repetition++; 688 // DoLog(0) && (Log() << Verbose(0) << "I found " << repetition << " times the keyword Ion_Type1_1." << endl); 689 // // parse in molecule coordinates 690 // for (int i=0; i < MaxTypes; i++) { 691 // sprintf(name,"Ion_Type%i",i+1); 692 // for(int j=0;j<No[i];j++) { 693 // sprintf(keyword,"%s_%i",name, j+1); 694 // if (repetition == 0) { 695 // neues = World::getInstance().createAtom(); 696 // AtomList[i][j] = neues; 697 // LinearList[ FileBuffer->LineMapping[FileBuffer->CurrentLine] ] = neues; 698 // neues->setType(elementhash[i]); // find element type 699 // } else 700 // neues = AtomList[i][j]; 701 // // then parse for each atom the coordinates as often as present 702 // ParseForParameter(verbose,FileBuffer, keyword, 0, 1, 1, double_type, &tempVector[0], repetition,critical); 703 // ParseForParameter(verbose,FileBuffer, keyword, 0, 2, 1, double_type, &tempVector[1], repetition,critical); 704 // ParseForParameter(verbose,FileBuffer, keyword, 0, 3, 1, double_type, &tempVector[2], repetition,critical); 705 // neues->setPosition(tempVector); 706 // bool _fixedion; 707 // ParseForParameter(verbose,FileBuffer, keyword, 0, 4, 1, int_type, &_fixedion, repetition,critical); 708 // neues->setFixedIon(_fixedion); 709 // bool velocityStatus = true; 710 // velocityStatus = velocityStatus && 711 // ParseForParameter(verbose,FileBuffer, keyword, 0, 5, 1, double_type, &tempVector[0], repetition,optional) && 712 // ParseForParameter(verbose,FileBuffer, keyword, 0, 6, 1, double_type, &tempVector[1], repetition,optional) && 713 // ParseForParameter(verbose,FileBuffer, keyword, 1, 7, 1, double_type, &tempVector[2], repetition,optional); 714 // if (!velocityStatus) 715 // neues->setAtomicVelocity(zeroVec); 716 // else 717 // neues->setAtomicVelocity(tempVector); 718 // 719 // // here we don't care if forces are present (last in trajectories is always equal to current position) 720 // neues->setType(elementhash[i]); // find element type 721 // mol->AddAtom(neues); 722 // } 723 // } 724 // } 622 725 // put atoms into the molecule in their original order 623 726 for(map<int, atom*>::iterator runner = LinearList.begin(); runner != LinearList.end(); ++runner) { … … 1458 1561 char *dummy1 = NULL; 1459 1562 char *dummy = NULL; // pointers in the line that is read in per step 1460 1461 //fprintf(stderr,"Parsing for %s\n",name); 1563 char *free_dummy = NULL; 1564 1565 if (verbose) fprintf(stderr,"Begin of Parsing for %s\n",name); 1462 1566 if (repetition == 0) 1463 1567 //Error(SomeError, "ParseForParameter(): argument repetition must not be 0!"); 1464 1568 return 0; 1465 1569 1466 int line = 0; // marks line where parameter was found1467 1570 int found = (type >= grid) ? 0 : (-yth + 1); // marks if yth parameter name was found 1468 1571 while((found != repetition)) { 1469 1572 dummy1 = dummy = NULL; 1470 1573 do { 1471 dummy1 = FileBuffer->buffer[ FileBuffer->LineMapping[FileBuffer->CurrentLine++] ];1574 free_dummy = dummy1 = FileBuffer->buffer[ FileBuffer->LineMapping[FileBuffer->CurrentLine++] ]; 1472 1575 if (FileBuffer->CurrentLine >= FileBuffer->NoLines) { 1473 1576 if ((critical) && (found == 0)) { … … 1476 1579 exit(255); 1477 1580 } else { 1581 //fprintf(stdout,"Rewinding to OldCurrentLine due to search till end of file.\n"); 1478 1582 FileBuffer->CurrentLine = OldCurrentLine; // rewind to start position 1479 1583 return 0; … … 1481 1585 } 1482 1586 if (dummy1 == NULL) { 1483 if (verbose) fprintf(stderr,"Error reading line %i\n", line);1587 if (verbose) fprintf(stderr,"Error reading line %i\n",FileBuffer->CurrentLine); 1484 1588 } else { 1485 //fprintf(stderr,"Now parsing the line %i: %s\n", line, dummy1);1589 if (verbose) fprintf(stderr,"Now parsing the line %i: %s\n", FileBuffer->CurrentLine, dummy1); 1486 1590 } 1487 line++;1591 //FileBuffer->CurrentLine++; 1488 1592 } while (dummy1 != NULL && ((dummy1[0] == '#') || (dummy1[0] == '\0'))); // skip commentary and empty lines 1489 1593 … … 1501 1605 //Error(FileOpenParams, NULL); 1502 1606 } else { 1503 //fprintf(stderr,"found tab at %i\n",(char *)dummy-(char *)dummy1);1607 if (verbose) fprintf(stderr,"found tab at line %i at position %li\n",FileBuffer->CurrentLine, (char *)dummy-(char *)dummy1); 1504 1608 } 1505 1609 } else dummy = dummy1; … … 1508 1612 if ((name == NULL) || (((dummy-dummy1 >= 3) && (strncmp(dummy1, name, strlen(name)) == 0)) && ((unsigned int)(dummy-dummy1) == strlen(name)))) { 1509 1613 found++; // found the parameter! 1510 //fprintf(stderr,"found %s at line %i between %i and %i\n", name, line, dummy1,dummy);1614 if (verbose) fprintf(stderr,"found %s at line %i between %li and %li\n", name, FileBuffer->CurrentLine, (unsigned long)dummy1, (unsigned long)dummy); 1511 1615 1512 1616 if (found == repetition) { … … 1523 1627 exit(255); 1524 1628 } else { 1629 //fprintf(stdout,"Rewinding to OldCurrentLine due to search till end of line.\n"); 1525 1630 FileBuffer->CurrentLine = OldCurrentLine; // rewind to start position 1526 1631 return 0; … … 1528 1633 } 1529 1634 if (dummy1 == NULL) { 1530 if (verbose) fprintf(stderr,"Error reading line %i\n", line);1635 if (verbose) fprintf(stderr,"Error reading line %i\n", FileBuffer->CurrentLine); 1531 1636 } else { 1532 //fprintf(stderr,"Reading next line %i: %s\n", line, dummy1);1637 if (verbose) fprintf(stderr,"Reading next line %i: %s\n", FileBuffer->CurrentLine, dummy1); 1533 1638 } 1534 line++;1639 //FileBuffer->CurrentLine++; 1535 1640 } while ((dummy1 != NULL) && ((dummy1[0] == '#') || (dummy1[0] == '\n'))); 1536 1641 dummy = dummy1; … … 1557 1662 if ((j < yth-1) && (type < 4)) { // check if xth value or not yet 1558 1663 if (critical) { 1559 if (verbose) fprintf(stderr,"Error: EoL at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name);1664 if (verbose) fprintf(stderr,"Error: EoL at %i and still missing %i value(s) for parameter %s\n", FileBuffer->CurrentLine, yth-j, name); 1560 1665 //return 0; 1561 1666 exit(255); … … 1563 1668 } else { 1564 1669 if (!sequential) { // here we need it! 1670 //fprintf(stdout,"Rewinding to OldCurrentLine due to end of line and sequential %d.\n", sequential); 1565 1671 FileBuffer->CurrentLine = OldCurrentLine; // rewind to start position 1566 1672 } … … 1569 1675 } 1570 1676 } else { 1571 //fprintf(stderr,"found tab at %i\n",(char *)dummy-(char *)free_dummy);1677 if (verbose) fprintf(stderr,"found tab at line %i at position %li\n",FileBuffer->CurrentLine, (char *)dummy-(char *)free_dummy); 1572 1678 } 1573 1679 if (*dummy1 == '#') { … … 1575 1681 //if (verbose) fprintf(stderr,"Error: '#' at %i and still missing %i value(s) for parameter %s\n", line, yth-j, name); 1576 1682 if (!sequential) { // here we need it! 1683 //fprintf(stdout,"Rewinding to OldCurrentLine due to comment and sequential %d.\n", sequential); 1577 1684 FileBuffer->CurrentLine = OldCurrentLine; // rewind to start position 1578 1685 } 1579 1686 return 0; 1580 1687 } 1581 //fprintf(stderr,"value from %i to %i\n",(char *)dummy1-(char *)free_dummy,(char *)dummy-(char *)free_dummy);1688 if (verbose) fprintf(stderr,"value from %li to %li\n",(char *)dummy1-(char *)free_dummy,(char *)dummy-(char *)free_dummy); 1582 1689 switch(type) { 1583 1690 case (row_int): … … 1632 1739 if ((type >= row_int) && (verbose)) fprintf(stderr,"\n"); 1633 1740 if (!sequential) { 1741 //fprintf(stdout,"Rewinding to OldCurrentLine due to sequential %d.\n", sequential); 1634 1742 FileBuffer->CurrentLine = OldCurrentLine; // rewind to start position 1635 1743 } 1636 //fprintf(stderr, "End of Parsing\n\n");1744 if (verbose) fprintf(stderr, "End of Parsing for %s\n\n",name); 1637 1745 1638 1746 return (found); // true if found, false if not -
tests/regression/Molecules/SaveTemperature/post/test.ekin
r03c77c r6a465e 1 1 # Step Temperature [K] Temperature [a.u.] 2 2 0 139247 0.44097 3 1 25464.1 0.080643 1 139247 0.44097 4 4 2 0 0 5 3 0 0
Note:
See TracChangeset
for help on using the changeset viewer.