Changeset d067d45 for src/datacreator.cpp
- Timestamp:
- Jul 23, 2009, 1:45:24 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:
- 51c910
- Parents:
- ce5ac3 (diff), 437922 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Frederik Heber <heber@…> (07/23/09 12:34:47)
- git-committer:
- Frederik Heber <heber@…> (07/23/09 13:45:24)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/datacreator.cpp
rce5ac3 rd067d45 1 1 /** \file datacreator.cpp 2 2 * 3 * Declarations of assisting functions in creating data and plot files. 4 * 3 * Declarations of assisting functions in creating data and plot files. 4 * 5 5 */ 6 6 … … 27 27 } 28 28 return true; 29 }; 29 }; 30 30 31 31 /** Opens a file for appending with \a *filename in \a *dir. … … 45 45 } 46 46 return true; 47 }; 47 }; 48 48 49 49 /** Plots an energy vs. order. … … 54 54 * \return true if file was written successfully 55 55 */ 56 bool CreateDataEnergyOrder(class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) 57 { 58 stringstream filename; 59 ofstream output; 60 61 filename << prefix << ".dat"; 62 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 56 bool CreateDataEnergyOrder(class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) 57 { 58 stringstream filename; 59 ofstream output; 60 61 filename << prefix << ".dat"; 62 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 63 63 cout << msg << endl; 64 64 output << "# " << msg << ", created on " << datum; … … 87 87 * \return true if file was written successfully 88 88 */ 89 bool CreateDataDeltaEnergyOrder(class EnergyMatrix &Energy, class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) 90 { 91 stringstream filename; 92 ofstream output; 93 94 filename << prefix << ".dat"; 95 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 89 bool CreateDataDeltaEnergyOrder(class EnergyMatrix &Energy, class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) 90 { 91 stringstream filename; 92 ofstream output; 93 94 filename << prefix << ".dat"; 95 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 96 96 cout << msg << endl; 97 97 output << "# " << msg << ", created on " << datum; … … 130 130 131 131 filename << prefix << ".dat"; 132 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 132 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 133 133 cout << msg << endl; 134 134 output << "# " << msg << ", created on " << datum; … … 162 162 163 163 filename << prefix << ".dat"; 164 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 164 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 165 165 cout << msg << endl; 166 166 output << "# " << msg << ", created on " << datum; … … 188 188 * \return true if file was written successfully 189 189 */ 190 bool CreateDataDeltaForcesOrderPerAtom(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) 190 bool CreateDataDeltaForcesOrderPerAtom(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) 191 191 { 192 192 stringstream filename; … … 195 195 196 196 filename << prefix << ".dat"; 197 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 197 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 198 198 cout << msg << endl; 199 199 output << "# " << msg << ", created on " << datum; … … 205 205 // errors per atom 206 206 output << endl << "#Order\t" << BondOrder+1 << endl; 207 for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { 207 for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { 208 208 output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t"; 209 209 for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) { … … 213 213 norm += Force.Matrix[Force.MatrixCounter][ j ][l+m]*Force.Matrix[Force.MatrixCounter][ j ][l+m]; 214 214 norm = sqrt(norm); 215 } 215 } 216 216 // if (norm < MYEPSILON) 217 217 output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t"; … … 235 235 * \return true if file was written successfully 236 236 */ 237 bool CreateDataForcesOrderPerAtom(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) 238 { 239 stringstream filename; 240 ofstream output; 241 242 filename << prefix << ".dat"; 243 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 237 bool CreateDataForcesOrderPerAtom(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) 238 { 239 stringstream filename; 240 ofstream output; 241 242 filename << prefix << ".dat"; 243 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 244 244 cout << msg << endl; 245 245 output << "# " << msg << ", created on " << datum; … … 250 250 // errors per atom 251 251 output << endl << "#Order\t" << BondOrder+1 << endl; 252 for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { 252 for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { 253 253 output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t"; 254 254 for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) … … 390 390 391 391 filename << prefix << ".dat"; 392 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 392 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 393 393 cout << msg << endl; 394 394 output << "# " << msg << ", created on " << datum << endl; … … 411 411 * \param &KeySet KeySetsContainer with associations of each fragment to a bond order 412 412 * \param BondOrder current bond order 413 */ 413 */ 414 414 void CreateMaxFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySet, int BondOrder) 415 415 { … … 420 420 Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 421 421 } 422 } 422 } 423 423 } 424 424 }; … … 428 428 * \param &KeySet KeySetsContainer with associations of each fragment to a bond order 429 429 * \param BondOrder current bond order 430 */ 430 */ 431 431 void CreateMinFragmentOrder(class MatrixContainer &Fragments, class KeySetsContainer &KeySet, int BondOrder) 432 432 { … … 443 443 Fragments.Matrix[ Fragments.MatrixCounter ][j][k] = Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 444 444 } 445 } 445 } 446 446 } 447 447 }; … … 455 455 456 456 filename << prefix << ".dat"; 457 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 457 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 458 458 cout << msg << endl; 459 459 output << "# " << msg << ", created on " << datum; … … 496 496 do { 497 497 for (int m=NDIM;m--;) { 498 stored += Force.Matrix[MatrixNumber][ k ][l+m] 498 stored += Force.Matrix[MatrixNumber][ k ][l+m] 499 499 * Force.Matrix[MatrixNumber][ k ][l+m]; 500 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m] = Force.Matrix[MatrixNumber][ k ][l+m]; 500 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m] = Force.Matrix[MatrixNumber][ k ][l+m]; 501 501 } 502 502 k++; … … 505 505 double tmp = 0; 506 506 for (int m=NDIM;m--;) 507 tmp += Force.Matrix[MatrixNumber][ k ][l+m] 507 tmp += Force.Matrix[MatrixNumber][ k ][l+m] 508 508 * Force.Matrix[MatrixNumber][ k ][l+m]; 509 509 if ((fabs(tmp) > MYEPSILON) && (tmp < stored)) { // current force is greater than stored 510 510 for (int m=NDIM;m--;) 511 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m] = Force.Matrix[MatrixNumber][ k ][l+m]; 511 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m] = Force.Matrix[MatrixNumber][ k ][l+m]; 512 512 stored = tmp; 513 513 } … … 531 531 double norm = 0.; 532 532 for (int m=NDIM;m--;) 533 norm += Force.Matrix[MatrixNumber][ k ][l+m] 533 norm += Force.Matrix[MatrixNumber][ k ][l+m] 534 534 * Force.Matrix[MatrixNumber][ k ][l+m]; 535 535 tmp += sqrt(norm); … … 553 553 double tmp = 0; 554 554 for (int m=NDIM;m--;) 555 tmp += Force.Matrix[MatrixNumber][ k ][l+m] 555 tmp += Force.Matrix[MatrixNumber][ k ][l+m] 556 556 * Force.Matrix[MatrixNumber][ k ][l+m]; 557 557 if (tmp > stored) { // current force is greater than stored 558 558 for (int m=NDIM;m--;) 559 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m] = Force.Matrix[MatrixNumber][ k ][l+m]; 559 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l+m] = Force.Matrix[MatrixNumber][ k ][l+m]; 560 560 stored = tmp; 561 561 } … … 592 592 * \param *key position of key 593 593 * \param *logscale axis for logscale 594 * \param *extraline extra set lines if desired 594 * \param *extraline extra set lines if desired 595 595 * \param mxtics small tics at ... 596 596 * \param xtics large tics at ... 597 * \param *xlabel label for x axis 597 * \param *xlabel label for x axis 598 598 * \param *ylabel label for y axis 599 */ 599 */ 600 600 void CreatePlotHeader(ofstream &output, const char *prefix, const int keycolumns, const char *key, const char *logscale, const char *extraline, const int mxtics, const int xtics, const char *xlabel, const char *ylabel) 601 601 { … … 626 626 * \param mxtics small tics at ... 627 627 * \param xtics large tics at ... 628 * \param xlabel label for x axis 628 * \param xlabel label for x axis 629 629 * \param xlabel label for x axis 630 630 * \param *xrange xrange … … 634 634 * \param (*CreatePlotLines) function reference that writes a single plot line 635 635 * \return true if file was written successfully 636 */ 636 */ 637 637 bool CreatePlotOrder(class MatrixContainer &Matrix, const class KeySetsContainer &KeySet, const char *dir, const char *prefix, const int keycolumns, const char *key, const char *logscale, const char *extraline, const int mxtics, const int xtics, const char *xlabel, const char *ylabel, const char *xrange, const char *yrange, const char *xargument, const char *uses, void (*CreatePlotLines)(ofstream &, class MatrixContainer &, const char *, const char *, const char *)) 638 638 { … … 641 641 642 642 filename << prefix << ".pyx"; 643 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 643 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 644 644 CreatePlotHeader(output, prefix, keycolumns, key, logscale, extraline, mxtics, xtics, xlabel, ylabel); 645 645 output << "plot " << xrange << " " << yrange << " \\" << endl; 646 646 CreatePlotLines(output, Matrix, prefix, xargument, uses); 647 output.close(); 647 output.close(); 648 648 return true; 649 649 };
Note:
See TracChangeset
for help on using the changeset viewer.