Changeset 390248
- Timestamp:
- Jul 24, 2008, 2:00:19 PM (16 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:
- 958457
- Parents:
- c685eb
- Location:
- src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/analyzer.cpp
rc685eb r390248 25 25 periodentafel *periode = NULL; // and a period table of all elements 26 26 EnergyMatrix Energy; 27 EnergyMatrix Hcorrection; 27 28 ForceMatrix Force; 28 29 ForceMatrix Shielding; … … 30 31 MatrixContainer Time; 31 32 EnergyMatrix EnergyFragments; 33 EnergyMatrix HcorrectionFragments; 32 34 ForceMatrix ForceFragments; 33 35 ForceMatrix ShieldingFragments; … … 45 47 stringstream Orderxrange; 46 48 stringstream Fragmentxrange; 47 49 stringstream yrange; 50 char *dir = NULL; 51 bool Hcorrected = true; 52 double norm; 53 48 54 cout << "ANOVA Analyzer" << endl; 49 55 cout << "==============" << endl; … … 57 63 cout << "[elementsdb]\tpath to elements database, needed for shieldings." << endl; 58 64 return 1; 59 } 65 } else { 66 dir = (char *) Malloc(sizeof(char)*(strlen(argv[2])+2), "main: *dir"); 67 strcpy(dir, "/"); 68 strcat(dir, argv[2]); 69 } 70 60 71 if (argc > 4) { 61 72 cout << "Loading periodentafel." << endl; … … 71 82 72 83 // ------------- Parse through all Fragment subdirs -------- 73 if (!Energy.ParseMatrix(argv[1], argv[2], EnergySuffix,0,0)) return 1; 74 if (!Force.ParseMatrix(argv[1], argv[2], ForcesSuffix,0,0)) return 1; 75 if (!Time.ParseMatrix(argv[1], argv[2], TimeSuffix, 10,1)) return 1; 84 if (!Energy.ParseMatrix(argv[1], dir, EnergySuffix,0,0)) return 1; 85 Hcorrected = Hcorrection.ParseMatrix(argv[1], "", HCORRECTIONSUFFIX,0,0); 86 if (!Force.ParseMatrix(argv[1], dir, ForcesSuffix,0,0)) return 1; 87 //if (!Time.ParseMatrix(argv[1], dir, TimeSuffix, 10,1)) return 1; 76 88 if (periode != NULL) { // also look for PAS values 77 if (!Shielding.ParseMatrix(argv[1], argv[2], ShieldingSuffix, 1, 0)) return 1;78 if (!ShieldingPAS.ParseMatrix(argv[1], argv[2], ShieldingPASSuffix, 1, 0)) return 1;89 if (!Shielding.ParseMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1; 90 if (!ShieldingPAS.ParseMatrix(argv[1], dir, ShieldingPASSuffix, 1, 0)) return 1; 79 91 } 80 92 81 93 // ---------- Parse the TE Factors into an array ----------------- 82 94 if (!Energy.ParseIndices()) return 1; 95 if (Hcorrected) Hcorrection.ParseIndices(); 83 96 84 97 // ---------- Parse the Force indices into an array --------------- 85 98 if (!Force.ParseIndices(argv[1])) return 1; 99 if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return 1; 100 if (!ForceFragments.ParseIndices(argv[1])) return 1; 86 101 87 102 // ---------- Parse the shielding indices into an array --------------- … … 96 111 97 112 // ---------- Parse fragment files created by 'joiner' into an array ------------- 98 if (!EnergyFragments.ParseMatrix(argv[1], argv[2], EnergyFragmentSuffix,0,0)) return 1; 99 if (!ForceFragments.ParseMatrix(argv[1], argv[2], ForceFragmentSuffix,0,0)) return 1; 113 if (!EnergyFragments.ParseMatrix(argv[1], dir, EnergyFragmentSuffix,0,0)) return 1; 114 if (Hcorrected) HcorrectionFragments.ParseMatrix(argv[1], dir, HcorrectionFragmentSuffix,0,0); 115 if (!ForceFragments.ParseMatrix(argv[1], dir, ForceFragmentSuffix,0,0)) return 1; 100 116 if (periode != NULL) { // also look for PAS values 101 if (!ShieldingFragments.ParseMatrix(argv[1], argv[2], ShieldingSuffix, 1, 0)) return 1;102 if (!ShieldingPASFragments.ParseMatrix(argv[1], argv[2], ShieldingPASSuffix, 1, 0)) return 1;117 if (!ShieldingFragments.ParseMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1; 118 if (!ShieldingPASFragments.ParseMatrix(argv[1], dir, ShieldingPASSuffix, 1, 0)) return 1; 103 119 } 104 120 … … 143 159 } 144 160 145 output << endl << "Total Times" << endl << "===============" << endl << Time.Header << endl;146 Time.SetLastMatrix(0., 0);147 for (int BondOrder=KeySet.Order;BondOrder--;)148 for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;)149 for(int j=Time.RowCounter[Time.MatrixCounter];j--;)150 for(int k=Time.ColumnCounter;k--;) {151 Time.Matrix[ Time.MatrixCounter ][j][k] += Time.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];152 }153 for(int j=0;j<Time.RowCounter[Time.MatrixCounter];j++) {154 for(int k=0;k<Time.ColumnCounter;k++)155 output << scientific << Time.Matrix[ Time.MatrixCounter ][j][k] << "\t";156 output << endl;157 }158 output << endl;161 // output << endl << "Total Times" << endl << "===============" << endl << Time.Header << endl; 162 // Time.SetLastMatrix(0., 0); 163 // for (int BondOrder=KeySet.Order;BondOrder--;) 164 // for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) 165 // for(int j=Time.RowCounter[Time.MatrixCounter];j--;) 166 // for(int k=Time.ColumnCounter;k--;) { 167 // Time.Matrix[ Time.MatrixCounter ][j][k] += Time.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 168 // } 169 // for(int j=0;j<Time.RowCounter[Time.MatrixCounter];j++) { 170 // for(int k=0;k<Time.ColumnCounter;k++) 171 // output << scientific << Time.Matrix[ Time.MatrixCounter ][j][k] << "\t"; 172 // output << endl; 173 // } 174 // output << endl; 159 175 output.close(); 160 176 … … 165 181 // ======================================= Creating the data files ============================================================== 166 182 167 // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order168 if (!OpenOutputFile(output, argv[3], "SimTime-Order.dat" )) return false;169 Time.SetLastMatrix(0., 0);170 output << "#Order\tFrag.No.\t" << Time.Header << endl;171 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {172 for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;)173 for(int j=Time.RowCounter[Time.MatrixCounter];j--;)174 for(int k=Time.ColumnCounter;k--;) {175 Time.Matrix[ Time.MatrixCounter ][j][k] += Time.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];176 }177 output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder];178 for(int k=0;k<Time.ColumnCounter;k++)179 output << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][1][k];180 output << endl;181 }182 output.close();183 // // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order 184 // if (!OpenOutputFile(output, argv[3], "SimTime-Order.dat" )) return false; 185 // Time.SetLastMatrix(0., 0); 186 // output << "#Order\tFrag.No.\t" << Time.Header << endl; 187 // for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { 188 // for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) 189 // for(int j=Time.RowCounter[Time.MatrixCounter];j--;) 190 // for(int k=Time.ColumnCounter;k--;) { 191 // Time.Matrix[ Time.MatrixCounter ][j][k] += Time.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 192 // } 193 // output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder]; 194 // for(int k=0;k<Time.ColumnCounter;k++) 195 // output << "\t" << scientific << Time.Matrix[ Time.MatrixCounter ][1][k]; 196 // output << endl; 197 // } 198 // output.close(); 183 199 184 200 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM 185 if (!EnergyFragments.SetLastMatrix(Energy.Matrix[Energy.MatrixCounter],0)) return 1; 186 if (!CreateDataEnergyOrder(Energy, EnergyFragments, KeySet, argv[3], "DeltaEnergies-Order", "Plot of error between approximated and full energies energies versus the Bond Order", datum)) return 1; 201 if (!CreateDataDeltaEnergyOrder(Energy, EnergyFragments, KeySet, argv[3], "DeltaEnergies-Order", "Plot of error between approximated and full energies energies versus the Bond Order", datum)) return 1; 187 202 188 203 // +++++++++++++++++++++++++++++++++++Plotting Energies vs. Order 189 if (!EnergyFragments.SetLastMatrix(1.,0)) return 1; 190 if (!CreateDataEnergyOrder(Energy, EnergyFragments, KeySet, argv[3], "Energies-Order", "Plot of approximated energies versus the Bond Order", datum)) return 1; 204 if (!CreateDataEnergyOrder(EnergyFragments, KeySet, argv[3], "Energies-Order", "Plot of approximated energies versus the Bond Order", datum)) return 1; 191 205 192 206 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in forces to full QM 193 if (!ForceFragments.SetLastMatrix(Force.Matrix[Force.MatrixCounter],0)) return 1; 194 if (!OpenOutputFile(output, argv[3], "DeltaForces-Order.dat" )) return false; 195 if (!OpenOutputFile(output2, argv[3], "DeltaMinForces-Order.dat" )) return false; 196 if (!OpenOutputFile(output3, argv[3], "DeltaMeanForces-Order.dat" )) return false; 197 if (!OpenOutputFile(output4, argv[3], "DeltaMaxForces-Order.dat" )) return false; 198 cout << "Plot of per atom and min/mean/max error between approximated forces and full forces versus the Bond Order ... " << endl; 199 output << "# Plot of error between approximated forces and full forces versus the Bond Order, created on " << datum; 200 output << "# AtomNo" << Force.Header << endl; 201 output2 << "# Plot of min error between approximated forces and full forces versus the Bond Order, created on " << datum; 202 output2 << "# Order\tFrag.No.\t" << Force.Header << endl; 203 output3 << "# Plot of mean error between approximated forces and full forces versus the Bond Order, created on " << datum; 204 output3 << "# Order\tFrag.No.\t" << Force.Header << endl; 205 output4 << "# Plot of max error between approximated forces and full forces versus the Bond Order, created on " << datum; 206 output4 << "# Order\tFrag.No.\t" << Force.Header << endl; 207 int FragmentCounter = 0; 208 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { 209 for(int i=0;i<KeySet.FragmentsPerOrder[BondOrder];i++) { 210 for(int l=0;l<Force.RowCounter[ KeySet.OrderSet[BondOrder][i] ];l++) { 211 int j = Force.Indices[ KeySet.OrderSet[BondOrder][i] ][l]; 212 if (j > Force.RowCounter[Force.MatrixCounter]) { 213 cerr << "Current force index " << j << " is greater than " << Force.RowCounter[Force.MatrixCounter] << "!" << endl; 214 return 1; 215 } 216 if (j != -1) 217 for(int k=0;k<Force.ColumnCounter;k++) { 218 Force.Matrix[Force.MatrixCounter][j][k] -= ForceFragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][l][k]; 219 } 220 } 221 FragmentCounter++; 222 } 223 // errors per atom 224 output << "#Order\t" << BondOrder+1 << endl; 225 for(int j=0;j<Force.RowCounter[ Force.MatrixCounter ];j++) { 226 output << Force.Indices[Force.MatrixCounter][j] << "\t"; 227 for (int l=0;l<Force.ColumnCounter;l++) 228 if (fabs(ForceFragments.Matrix[ForceFragments.MatrixCounter][ j ][l]) < MYEPSILON) 229 output << scientific << Force.Matrix[Force.MatrixCounter][ j ][l] << "\t"; 230 else 231 output << scientific << (Force.Matrix[Force.MatrixCounter][ j ][l] / ForceFragments.Matrix[ForceFragments.MatrixCounter][ j ][l]) << "\t"; 232 output << endl; 233 } 234 output << endl; 235 236 // min error 237 output2 << BondOrder+1 << "\t" << FragmentCounter; 238 CreateMinimumForce(Force, Force.MatrixCounter); 239 for (int l=0;l<Force.ColumnCounter;l++) 240 if (fabs(ForceFragments.Matrix[ForceFragments.MatrixCounter][ ForceFragments.RowCounter[ForceFragments.MatrixCounter] ][l]) < MYEPSILON) 241 output2 << scientific << "\t" << Force.Matrix[Force.MatrixCounter][ Force.RowCounter[Force.MatrixCounter] ][l]; 242 else 243 output2 << scientific << "\t" << (Force.Matrix[Force.MatrixCounter][ Force.RowCounter[Force.MatrixCounter] ][l] / ForceFragments.Matrix[ForceFragments.MatrixCounter][ ForceFragments.RowCounter[ForceFragments.MatrixCounter] ][l]); 244 output2 << endl; 245 246 // mean error 247 output3 << BondOrder+1 << "\t" << FragmentCounter; 248 CreateMeanForce(Force, Force.MatrixCounter); 249 for (int l=0;l<Force.ColumnCounter;l++) 250 if (fabs(ForceFragments.Matrix[ForceFragments.MatrixCounter][ ForceFragments.RowCounter[ForceFragments.MatrixCounter] ][l]) < MYEPSILON) 251 output3 << scientific << "\t" << Force.Matrix[Force.MatrixCounter][ Force.RowCounter[Force.MatrixCounter] ][l]; 252 else 253 output3 << scientific << "\t" << (Force.Matrix[Force.MatrixCounter][ Force.RowCounter[Force.MatrixCounter] ][l] / ForceFragments.Matrix[ForceFragments.MatrixCounter][ ForceFragments.RowCounter[ForceFragments.MatrixCounter] ][l]); 254 output3 << endl; 255 256 // max error 257 output4 << BondOrder+1 << "\t" << FragmentCounter; 258 CreateMaximumForce(Force, Force.MatrixCounter); 259 for (int l=0;l<Force.ColumnCounter;l++) 260 if (fabs(ForceFragments.Matrix[ForceFragments.MatrixCounter][ ForceFragments.RowCounter[ForceFragments.MatrixCounter] ][l]) < MYEPSILON) 261 output4 << scientific << "\t" << Force.Matrix[Force.MatrixCounter][ Force.RowCounter[Force.MatrixCounter] ][l]; 262 else 263 output4 << scientific << "\t" << (Force.Matrix[Force.MatrixCounter][ Force.RowCounter[Force.MatrixCounter] ][l] / ForceFragments.Matrix[ForceFragments.MatrixCounter][ ForceFragments.RowCounter[ForceFragments.MatrixCounter] ][l]); 264 output4 << endl; 265 } 266 output.close(); 267 output2.close(); 268 output3.close(); 269 output4.close(); 207 if (!CreateDataDeltaForcesOrderPerAtom(Force, ForceFragments, KeySet, argv[3], "DeltaForces-Order", "Plot of error between approximated forces and full forces versus the Bond Order", datum)) return 1; 208 209 // min force 210 if (!CreateDataDeltaForcesOrder(Force, ForceFragments, KeySet, argv[3], "DeltaMinForces-Order", "Plot of min error between approximated forces and full forces versus the Bond Order", datum, CreateMinimumForce)) return 1; 211 212 // mean force 213 if (!CreateDataDeltaForcesOrder(Force, ForceFragments, KeySet, argv[3], "DeltaMeanForces-Order", "Plot of mean error between approximated forces and full forces versus the Bond Order", datum, CreateMeanForce)) return 1; 214 215 // max force 216 if (!CreateDataDeltaForcesOrder(Force, ForceFragments, KeySet, argv[3], "DeltaMaxForces-Order", "Plot of max error between approximated forces and full forces versus the Bond Order", datum, CreateMaximumForce)) return 1; 270 217 271 218 // ++++++++++++++++++++++++++++++++++++++Plotting Forces vs. Order 272 if(!OpenOutputFile(output, argv[3], "Forces-Order.dat")) return 1; 273 cout << "Plot of approximated forces versus the Bond Order ... " << endl; 274 output << "# Plot of approximated forces versus the Bond Order, created on " << datum; 275 output << "# AtomNo" << Force.Header << endl; 276 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { 277 for(int i=0;i<KeySet.FragmentsPerOrder[BondOrder];i++) { 278 for(int l=0;l<Force.RowCounter[ KeySet.OrderSet[BondOrder][i] ];l++) { 279 int j = Force.Indices[ KeySet.OrderSet[BondOrder][i] ][l]; 280 if (j > Force.RowCounter[Force.MatrixCounter]) { 281 cerr << "Current force index " << j << " is greater than " << Force.RowCounter[Force.MatrixCounter] << "!" << endl; 282 return 1; 283 } 284 if (j != -1) 285 for(int k=0;k<Force.ColumnCounter;k++) { 286 Force.Matrix[Force.MatrixCounter][j][k] -= ForceFragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][l][k]; 287 } 288 } 289 } 290 // errors per atom 291 output << "#Order\t" << BondOrder+1 << endl; 292 for(int j=0;j<Force.RowCounter[ Force.MatrixCounter ];j++) { 293 output << Force.Indices[Force.MatrixCounter][j] << "\t"; 294 for (int l=0;l<Force.ColumnCounter;l++) 295 output << Force.Matrix[Force.MatrixCounter][ j ][l] << "\t"; 296 output << endl; 297 } 298 output << endl; 299 } 300 output.close(); 301 302 // min force 303 if (!CreateDataForcesOrder(Force, ForceFragments, KeySet, argv[3], "MinForces-Order", "Plot of min approximated forces versus the Bond Order", datum, CreateMinimumForce)) return 1; 304 305 // mean force 306 if (!CreateDataForcesOrder(Force, ForceFragments, KeySet, argv[3], "MeanForces-Order", "Plot of mean approximated forces versus the Bond Order", datum, CreateMeanForce)) return 1; 307 308 // max force 309 if (!CreateDataForcesOrder(Force, ForceFragments, KeySet, argv[3], "MaxForces-Order", "Plot of max approximated forces versus the Bond Order", datum, CreateMaximumForce)) return 1; 219 if (!CreateDataForcesOrderPerAtom(ForceFragments, KeySet, argv[3], "Forces-Order", "Plot of approximated forces versus the Bond Order", datum)) return 1; 220 221 // min force 222 if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "MinForces-Order", "Plot of min approximated forces versus the Bond Order", datum, CreateMinimumForce)) return 1; 223 224 // mean force 225 if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "MeanForces-Order", "Plot of mean approximated forces versus the Bond Order", datum, CreateMeanForce)) return 1; 226 227 // max force 228 if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "MaxForces-Order", "Plot of max approximated forces versus the Bond Order", datum, CreateMaximumForce)) return 1; 310 229 311 230 // ++++++++++++++++++++++++++++++++++++++Plotting vector sum (should be 0) vs. bond order 312 if (!CreateDataForcesOrder(Force , ForceFragments, KeySet, argv[3], "VectorSum-Order", "Plot of vector sum of the approximated forces versus the Bond Order", datum, CreateVectorSumForce)) return 1;231 if (!CreateDataForcesOrder(ForceFragments, KeySet, argv[3], "VectorSum-Order", "Plot of vector sum of the approximated forces versus the Bond Order", datum, CreateVectorSumForce)) return 1; 313 232 314 233 // +++++++++++++++++++++++++++++++Plotting energyfragments vs. order … … 342 261 Orderxrange << "[1:" << KeySet.Order << "]"; 343 262 Fragmentxrange << "[0:" << KeySet.FragmentCounter+1 << "]"; 263 yrange.str("[1e-8:1e+1]"); 344 264 345 265 // +++++++++++++++++++++++++++++++++++++++ Plotting Simtime vs Bond Order 346 if (!CreatePlotOrder(Time, KeySet, argv[3], "SimTime-Order", 1, "below", "y", "", 1, 1, "bond order k", "Evaluation time [s]", Orderxrange.str().c_str(), "", "1" , "with linespoints", EnergyPlotLine)) return 1;266 //if (!CreatePlotOrder(Time, KeySet, argv[3], "SimTime-Order", 1, "below", "y", "", 1, 1, "bond order k", "Evaluation time [s]", Orderxrange.str().c_str(), "", "1" , "with linespoints", EnergyPlotLine)) return 1; 347 267 348 268 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in energy to full QM 349 if (!CreatePlotOrder(Energy, KeySet, argv[3], "DeltaEnergies-Order", 1, "outside", "y", "", 1, 1, "bond order k", "absolute error in energy [Ht]", Orderxrange.str().c_str(), "[1e-8:1e+1]", "1" , "with linespoints", AbsEnergyPlotLine)) return 1;269 if (!CreatePlotOrder(Energy, KeySet, argv[3], "DeltaEnergies-Order", 1, "outside", "y", "", 1, 1, "bond order k", "absolute error in energy [Ht]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", AbsEnergyPlotLine)) return 1; 350 270 351 271 // +++++++++++++++++++++++++++++++++++Plotting Energies vs. Order … … 353 273 354 274 // +++++++++++++++++++++++++++++++++++++++ Plotting deviation in forces to full QM 355 // min force 356 if (!CreatePlotOrder(Force, KeySet, argv[3], "DeltaMinForces-Order", 2, "top right", "y", "", 1, 1, "bond order k", "absolute error in min force [Ht/a.u.]", Orderxrange.str().c_str(), "[1e-8:1e+0]", "1" , "with linespoints", ForceMagnitudePlotLine)) return 1; 357 358 // mean force 359 if (!CreatePlotOrder(Force, KeySet, argv[3], "DeltaMeanForces-Order", 2, "top right", "y", "", 1, 1, "bond order k", "absolute error in mean force [Ht/a.u.]", Orderxrange.str().c_str(), "[1e-8:1e+0]", "1" , "with linespoints", AbsFirstForceValuePlotLine)) return 1; 360 361 // max force 362 if (!CreatePlotOrder(Force, KeySet, argv[3], "DeltaMaxForces-Order", 2, "top right", "y", "", 1, 1, "bond order k", "absolute error in max force [Ht/a.u.]", Orderxrange.str().c_str(), "[1e-8:1e+0]", "1" , "with linespoints", ForceMagnitudePlotLine)) return 1; 275 yrange.str("[1e-8:1e+0]"); 276 // min force 277 if (!CreatePlotOrder(Force, KeySet, argv[3], "DeltaMinForces-Order", 2, "top right", "y", "", 1, 1, "bond order k", "absolute error in min force [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", ForceMagnitudePlotLine)) return 1; 278 279 // mean force 280 if (!CreatePlotOrder(Force, KeySet, argv[3], "DeltaMeanForces-Order", 2, "top right", "y", "", 1, 1, "bond order k", "absolute error in mean force [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", AbsFirstForceValuePlotLine)) return 1; 281 282 // max force 283 if (!CreatePlotOrder(Force, KeySet, argv[3], "DeltaMaxForces-Order", 2, "top right", "y", "", 1, 1, "bond order k", "absolute error in max force [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", ForceMagnitudePlotLine)) return 1; 363 284 364 285 // min/mean/max comparison for total force … … 395 316 396 317 // +++++++++++++++++++++++++++++++Plotting energyfragments vs. order 397 if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "Energies-Fragment", 5, "below", "y", "", 1, 5, "fragment number", "Energies of each fragment [Ht]", Fragmentxrange.str().c_str(), "[1e-16:1e+1]", "2" , "with points", AbsEnergyPlotLine)) return 1; 398 if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "Energies-FragmentOrder", 5, "below", "y", "", 1, 1, "bond order", "Energies of each fragment [Ht]", Orderxrange.str().c_str(), "[1e-10:1e+1]", "1" , "with points", AbsEnergyPlotLine)) return 1; 399 if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "MaxEnergies-FragmentOrder", 5, "below", "y", "", 1, 1, "bond order", "Maximum fragment energy [Ht]", Orderxrange.str().c_str(), "[1e-6:1e+1]", "1" , "with linespoints", AbsEnergyPlotLine)) return 1; 400 if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "MinEnergies-FragmentOrder", 5, "below", "y", "", 1, 1, "bond order", "Minimum fragment energy [Ht]", Orderxrange.str().c_str(), "[1e-6:1e+1]", "1" , "with linespoints", AbsEnergyPlotLine)) return 1; 318 yrange.str(""); 319 yrange << "[" << EnergyFragments.FindMinValue() << ":" << EnergyFragments.FindMaxValue() << "]"; 320 if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "Energies-Fragment", 5, "below", "y", "", 1, 5, "fragment number", "Energies of each fragment [Ht]", Fragmentxrange.str().c_str(), yrange.str().c_str(), "2" , "with points", AbsEnergyPlotLine)) return 1; 321 if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "Energies-FragmentOrder", 5, "below", "y", "", 1, 1, "bond order", "Energies of each fragment [Ht]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with points", AbsEnergyPlotLine)) return 1; 322 if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "MaxEnergies-FragmentOrder", 5, "below", "y", "", 1, 1, "bond order", "Maximum fragment energy [Ht]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", AbsEnergyPlotLine)) return 1; 323 if (!CreatePlotOrder(EnergyFragments, KeySet, argv[3], "MinEnergies-FragmentOrder", 5, "below", "y", "", 1, 1, "bond order", "Minimum fragment energy [Ht]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with linespoints", AbsEnergyPlotLine)) return 1; 401 324 402 325 // +++++++++++++++++++++++++++++++=Ploting min/mean/max forces for each fragment 326 yrange.str(""); 327 yrange << "[" << ForceFragments.FindMinValue() << ":" << ForceFragments.FindMaxValue()<< "]"; 403 328 // min 404 if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MinForces-Fragment", 5, "below", "y", "set boxwidth 0.2", 1, 5, "fragment number", "minimum of approximated forces [Ht/a.u.]", Fragmentxrange.str().c_str(), "[1e-16:1e+1]", "2" , "with boxes fillcolor", BoxesForcePlotLine)) return 1;329 if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MinForces-Fragment", 5, "below", "y", "set boxwidth 0.2", 1, 5, "fragment number", "minimum of approximated forces [Ht/a.u.]", Fragmentxrange.str().c_str(), yrange.str().c_str(), "2" , "with boxes fillcolor", BoxesForcePlotLine)) return 1; 405 330 406 331 // mean 407 if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MeanForces-Fragment", 5, "below", "y", "set boxwidth 0.2", 1, 5, "fragment number", "mean of approximated forces [Ht/a.u.]", Fragmentxrange.str().c_str(), "[1e-16:1e+1]", "2" , "with boxes fillcolor", BoxesFirstForceValuePlotLine)) return 1;332 if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MeanForces-Fragment", 5, "below", "y", "set boxwidth 0.2", 1, 5, "fragment number", "mean of approximated forces [Ht/a.u.]", Fragmentxrange.str().c_str(), yrange.str().c_str(), "2" , "with boxes fillcolor", BoxesFirstForceValuePlotLine)) return 1; 408 333 409 334 // max 410 if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MaxForces-Fragment", 5, "below", "y", "set boxwidth 0.2", 1, 5, "fragment number", "maximum of approximated forces [Ht/a.u.]", Fragmentxrange.str().c_str(), "[1e-16:1e+1]", "2" , "with boxes fillcolor", BoxesForcePlotLine)) return 1;335 if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MaxForces-Fragment", 5, "below", "y", "set boxwidth 0.2", 1, 5, "fragment number", "maximum of approximated forces [Ht/a.u.]", Fragmentxrange.str().c_str(), yrange.str().c_str(), "2" , "with boxes fillcolor", BoxesForcePlotLine)) return 1; 411 336 412 337 // +++++++++++++++++++++++++++++++=Ploting min/mean/max forces for each fragment per bond order 413 338 // min 414 if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MinForces-FragmentOrder", 5, "below", "y", "set boxwidth 0.2", 1, 1, "bond order", "minimum of approximated forces [Ht/a.u.]", Orderxrange.str().c_str(), "[1e-16:1e+1]", "1" , "with boxes fillcolor", BoxesForcePlotLine)) return 1;339 if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MinForces-FragmentOrder", 5, "below", "y", "set boxwidth 0.2", 1, 1, "bond order", "minimum of approximated forces [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with boxes fillcolor", BoxesForcePlotLine)) return 1; 415 340 416 341 // mean 417 if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MeanForces-FragmentOrder", 5, "below", "y", "set boxwidth 0.2", 1, 1, "bond order", "mean of approximated forces [Ht/a.u.]", Orderxrange.str().c_str(), "[1e-16:1e+1]", "1" , "with boxes fillcolor", BoxesFirstForceValuePlotLine)) return 1;342 if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MeanForces-FragmentOrder", 5, "below", "y", "set boxwidth 0.2", 1, 1, "bond order", "mean of approximated forces [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with boxes fillcolor", BoxesFirstForceValuePlotLine)) return 1; 418 343 419 344 // max 420 if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MaxForces-FragmentOrder", 5, "below", "y", "set boxwidth 0.2", 1, 1, "bond order", "maximum of approximated forces [Ht/a.u.]", Orderxrange.str().c_str(), "[1e-16:1e+1]", "1" , "with boxes fillcolor", BoxesForcePlotLine)) return 1;345 if (!CreatePlotOrder(ForceFragments, KeySet, argv[3], "MaxForces-FragmentOrder", 5, "below", "y", "set boxwidth 0.2", 1, 1, "bond order", "maximum of approximated forces [Ht/a.u.]", Orderxrange.str().c_str(), yrange.str().c_str(), "1" , "with boxes fillcolor", BoxesForcePlotLine)) return 1; 421 346 422 347 // create Makefile … … 434 359 // ++++++++++++++++ exit ++++++++++++++++++++++++++++++++++ 435 360 delete(periode); 361 Free((void **)&dir, "main: *dir"); 436 362 cout << "done." << endl; 437 363 return 0; -
src/datacreator.cpp
rc685eb r390248 30 30 31 31 /** Plots an energy vs. order. 32 * \param Energy EnergyMatrix class containing matrix values (last matrix is created by summing over Fragments) 33 * \param EnergyFragments EnergyMatrix class containing matrix values 32 * \param &Fragments EnergyMatrix class containing matrix values 34 33 * \param KeySet KeySetContainer class holding bond KeySetContainer::Order 35 34 * \param *prefix prefix in filename (without ending) … … 37 36 * \return true if file was written successfully 38 37 */ 39 bool CreateDataEnergyOrder(class MatrixContainer &Energy, class MatrixContainer &EnergyFragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum)38 bool CreateDataEnergyOrder(class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) 40 39 { 41 40 stringstream filename; … … 46 45 cout << msg << endl; 47 46 output << "# " << msg << ", created on " << datum; 48 output << "#Order\tFrag.No.\t" << Energy.Header << endl;47 output << "#Order\tFrag.No.\t" << Fragments.Header << endl; 49 48 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { 50 49 for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) { 51 for(int j= Energy.RowCounter[ KeySet.OrderSet[BondOrder][i] ];j--;)52 for(int k= Energy.ColumnCounter;k--;)53 Energy.Matrix[Energy.MatrixCounter][j][k] -= EnergyFragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k];50 for(int j=Fragments.RowCounter[ KeySet.OrderSet[BondOrder][i] ];j--;) 51 for(int k=Fragments.ColumnCounter;k--;) 52 Fragments.Matrix[Fragments.MatrixCounter][j][k] += Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 54 53 } 55 54 output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder]; 56 for (int l=0;l<Energy.ColumnCounter;l++) 57 if (fabs(EnergyFragments.Matrix[EnergyFragments.MatrixCounter][ EnergyFragments.RowCounter[EnergyFragments.MatrixCounter]-1 ][l]) < MYEPSILON) 58 output << scientific << "\t" << Energy.Matrix[Energy.MatrixCounter][ Energy.RowCounter[Energy.MatrixCounter]-1 ][l]; 55 for (int l=0;l<Fragments.ColumnCounter;l++) 56 output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter]-1 ][l]; 57 output << endl; 58 } 59 output.close(); 60 return true; 61 }; 62 63 /** Plots an energy error vs. order. 64 * \param &Energy EnergyMatrix class containing reference values (in MatrixCounter matrix) 65 * \param &Fragments EnergyMatrix class containing matrix values 66 * \param KeySet KeySetContainer class holding bond KeySetContainer::Order 67 * \param *prefix prefix in filename (without ending) 68 * \param *msg message to be place in first line as a comment 69 * \return true if file was written successfully 70 */ 71 bool CreateDataDeltaEnergyOrder(class EnergyMatrix &Energy, class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) 72 { 73 stringstream filename; 74 ofstream output; 75 76 filename << prefix << ".dat"; 77 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 78 cout << msg << endl; 79 output << "# " << msg << ", created on " << datum; 80 output << "#Order\tFrag.No.\t" << Fragments.Header << endl; 81 Fragments.SetLastMatrix(Energy.Matrix[Energy.MatrixCounter],0); 82 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { 83 for(int i=KeySet.FragmentsPerOrder[BondOrder];i--;) { 84 for(int j=Fragments.RowCounter[ KeySet.OrderSet[BondOrder][i] ];j--;) 85 for(int k=Fragments.ColumnCounter;k--;) 86 Fragments.Matrix[Fragments.MatrixCounter][j][k] -= Fragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][j][k]; 87 } 88 output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder]; 89 for (int l=0;l<Fragments.ColumnCounter;l++) 90 if (fabs(Energy.Matrix[Energy.MatrixCounter][ Energy.RowCounter[Energy.MatrixCounter]-1 ][l]) < MYEPSILON) 91 output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter]-1 ][l]; 59 92 else 60 output << scientific << "\t" << ( Energy.Matrix[Energy.MatrixCounter][ Energy.RowCounter[Energy.MatrixCounter]-1 ][l] / EnergyFragments.Matrix[EnergyFragments.MatrixCounter][ EnergyFragments.RowCounter[EnergyFragments.MatrixCounter]-1 ][l]);93 output << scientific << "\t" << (Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter]-1 ][l] / Energy.Matrix[Energy.MatrixCounter][ Energy.RowCounter[Energy.MatrixCounter]-1 ][l]); 61 94 output << endl; 62 95 } … … 66 99 67 100 /** Plot forces vs. order. 68 */ 69 bool CreateDataForcesOrder(class MatrixContainer &Force, class MatrixContainer &ForceFragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateForce)(class MatrixContainer &, int)) 101 * \param &Fragments ForceMatrix class containing matrix values 102 * \param KeySet KeySetContainer class holding bond KeySetContainer::Order 103 * \param *prefix prefix in filename (without ending) 104 * \param *msg message to be place in first line as a comment 105 * \param *datum current date and time 106 * \return true if file was written successfully 107 */ 108 bool CreateDataForcesOrder(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateForce)(class MatrixContainer &, int)) 70 109 { 71 110 stringstream filename; … … 76 115 cout << msg << endl; 77 116 output << "# " << msg << ", created on " << datum; 78 output << "# Order\tFrag.No.\t" << Force.Header << endl; 79 for(int j=0;j<=Force.RowCounter[ Force.MatrixCounter ];j++) 80 for(int k=0;k<Force.ColumnCounter;k++) 81 Force.Matrix[Force.MatrixCounter][j][k] = 0.; 82 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { 83 for(int i=0;i<KeySet.FragmentsPerOrder[BondOrder];i++) { 84 for(int l=0;l<Force.RowCounter[ KeySet.OrderSet[BondOrder][i] ];l++) { 85 int j = Force.Indices[ KeySet.OrderSet[BondOrder][i] ][l]; 86 if (j > Force.RowCounter[Force.MatrixCounter]) { 87 cerr << "Current force index " << j << " is greater than " << Force.RowCounter[Force.MatrixCounter] << "!" << endl; 88 return 1; 89 } 90 if (j != -1) 91 for(int k=Force.ColumnCounter;k--;) { 92 Force.Matrix[Force.MatrixCounter][j][k] += ForceFragments.Matrix[ KeySet.OrderSet[BondOrder][i] ][l][k]; 93 } 117 output << "# Order\tFrag.No.\t" << Fragments.Header << endl; 118 Fragments.SetLastMatrix(0.,0); 119 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { 120 Fragments.SumSubForces(Fragments, KeySet, BondOrder, 1.); 121 output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder]; 122 CreateForce(Fragments, Fragments.MatrixCounter); 123 for (int l=0;l<Fragments.ColumnCounter;l++) 124 output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter] ][l]; 125 output << endl; 126 } 127 output.close(); 128 return true; 129 }; 130 131 /** Plot forces error vs. order. 132 * \param &Force ForceMatrix containing reference values (in MatrixCounter matrix) 133 * \param &Fragments ForceMatrix class containing matrix values 134 * \param KeySet KeySetContainer class holding bond KeySetContainer::Order 135 * \param *prefix prefix in filename (without ending) 136 * \param *msg message to be place in first line as a comment 137 * \param *datum current date and time 138 * \return true if file was written successfully 139 */ 140 bool CreateDataDeltaForcesOrder(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateForce)(class MatrixContainer &, int)) 141 { 142 stringstream filename; 143 ofstream output; 144 145 filename << prefix << ".dat"; 146 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 147 cout << msg << endl; 148 output << "# " << msg << ", created on " << datum; 149 output << "# Order\tFrag.No.\t" << Fragments.Header << endl; 150 Fragments.SetLastMatrix(Force.Matrix[Force.MatrixCounter],0); 151 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { 152 Fragments.SumSubForces(Fragments, KeySet, BondOrder, -1.); 153 output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder]; 154 CreateForce(Fragments, Fragments.MatrixCounter); 155 for (int l=0;l<Fragments.ColumnCounter;l++) 156 output << scientific << "\t" << Fragments.Matrix[Fragments.MatrixCounter][ Fragments.RowCounter[Fragments.MatrixCounter] ][l]; 157 output << endl; 158 } 159 output.close(); 160 return true; 161 }; 162 163 /** Plot forces error vs. vs atom vs. order. 164 * \param &Force ForceMatrix containing reference values (in MatrixCounter matrix) 165 * \param &Fragments ForceMatrix class containing matrix values 166 * \param KeySet KeySetContainer class holding bond KeySetContainer::Order 167 * \param *prefix prefix in filename (without ending) 168 * \param *msg message to be place in first line as a comment 169 * \param *datum current date and time 170 * \return true if file was written successfully 171 */ 172 bool CreateDataDeltaForcesOrderPerAtom(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) 173 { 174 stringstream filename; 175 ofstream output; 176 double norm = 0.; 177 178 filename << prefix << ".dat"; 179 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 180 cout << msg << endl; 181 output << "# " << msg << ", created on " << datum; 182 output << "# AtomNo\t" << Fragments.Header << endl; 183 Fragments.SetLastMatrix(Force.Matrix[Force.MatrixCounter], 0); 184 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { 185 //cout << "Current order is " << BondOrder << "." << endl; 186 Fragments.SumSubForces(Fragments, KeySet, BondOrder, -1.); 187 // errors per atom 188 output << "#Order\t" << BondOrder+1 << endl; 189 for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { 190 output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t"; 191 for (int l=0;l<Fragments.ColumnCounter;l++) { 192 if (((l+1) % 3) == 0) { 193 norm = 0.; 194 for (int m=0;m<NDIM;m++) 195 norm += Force.Matrix[Force.MatrixCounter][ j ][l+m]*Force.Matrix[Force.MatrixCounter][ j ][l+m]; 196 norm = sqrt(norm); 197 } 198 // if (norm < MYEPSILON) 199 output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t"; 200 // else 201 // output << scientific << (Fragments.Matrix[Fragments.MatrixCounter][ j ][l] / norm) << "\t"; 94 202 } 95 } 96 output << BondOrder+1 << "\t" << KeySet.FragmentsPerOrder[BondOrder]; 97 CreateForce(Force, Force.MatrixCounter); 98 for (int l=0;l<Force.ColumnCounter;l++) 99 output << scientific << "\t" << Force.Matrix[Force.MatrixCounter][ Force.RowCounter[Force.MatrixCounter] ][l]; 203 output << endl; 204 } 205 output << endl; 206 } 207 output.close(); 208 return true; 209 }; 210 211 /** Plot forces error vs. vs atom vs. order. 212 * \param &Fragments ForceMatrix class containing matrix values 213 * \param KeySet KeySetContainer class holding bond KeySetContainer::Order 214 * \param *prefix prefix in filename (without ending) 215 * \param *msg message to be place in first line as a comment 216 * \param *datum current date and time 217 * \return true if file was written successfully 218 */ 219 bool CreateDataForcesOrderPerAtom(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum) 220 { 221 stringstream filename; 222 ofstream output; 223 224 filename << prefix << ".dat"; 225 if (!OpenOutputFile(output, dir, filename.str().c_str())) return false; 226 cout << msg << endl; 227 output << "# " << msg << ", created on " << datum; 228 output << "# AtomNo\t" << Fragments.Header << endl; 229 for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) { 230 //cout << "Current order is " << BondOrder << "." << endl; 231 Fragments.SumSubForces(Fragments, KeySet, BondOrder, 1.); 232 // errors per atom 233 output << "#Order\t" << BondOrder+1 << endl; 234 for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) { 235 output << Fragments.Indices[Fragments.MatrixCounter][j] << "\t"; 236 for (int l=0;l<Fragments.ColumnCounter;l++) 237 output << scientific << Fragments.Matrix[Fragments.MatrixCounter][ j ][l] << "\t"; 238 output << endl; 239 } 100 240 output << endl; 101 241 } … … 286 426 }; 287 427 428 /** Leaves the Force.Matrix as it is. 429 * \param Force ForceMatrix class containing matrix values 430 * \param MatrixNumber the index for the ForceMatrix::matrix array 431 */ 432 void CreateSameForce(class MatrixContainer &Force, int MatrixNumber) 433 { 434 // does nothing 435 }; 436 288 437 /** Adds vectorwise all forces. 289 438 * Results are stored in the matrix ForceMatrix::MatrixCounter of \a Force. … … 295 444 for (int l=Force.ColumnCounter;l--;) 296 445 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] = 0.; 297 for (int l= 5;l<Force.ColumnCounter;l++) {446 for (int l=0;l<Force.ColumnCounter;l++) { 298 447 for (int k=Force.RowCounter[MatrixNumber];k--;) 299 448 Force.Matrix[MatrixNumber][ Force.RowCounter[MatrixNumber] ][l] += Force.Matrix[MatrixNumber][k][l]; … … 375 524 376 525 line >> item; 377 for (int i= 3; i<Energy.ColumnCounter;i++) {378 line >> item; 379 output << "'" << prefix << ".dat' title '" << item << "' using " << xargument << ":(abs($" << i+ 1<< ")) " << uses;380 if (i != (Energy.ColumnCounter -1))526 for (int i=2; i<= Energy.ColumnCounter;i++) { 527 line >> item; 528 output << "'" << prefix << ".dat' title '" << item << "' using " << xargument << ":(abs($" << i+2 << ")) " << uses; 529 if (i != (Energy.ColumnCounter)) 381 530 output << ", \\"; 382 531 output << endl; … … 397 546 398 547 line >> item; 399 for (int i= 3; i<Energy.ColumnCounter;i++) {400 line >> item; 401 output << "'" << prefix << ".dat' title '" << item << "' using " << xargument << ":" << i+ 1<< " " << uses;402 if (i != (Energy.ColumnCounter -1))548 for (int i=2; i<= Energy.ColumnCounter;i++) { 549 line >> item; 550 output << "'" << prefix << ".dat' title '" << item << "' using " << xargument << ":" << i+2 << " " << uses; 551 if (i != (Energy.ColumnCounter)) 403 552 output << ", \\"; 404 553 output << endl; -
src/datacreator.hpp
rc685eb r390248 19 19 bool OpenOutputFile(ofstream &output, const char *dir, const char *filename); 20 20 21 bool CreateDataEnergyOrder(class MatrixContainer &Energy, class MatrixContainer &EnergyFragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum); 22 bool CreateDataForcesOrder(class MatrixContainer &Force, class MatrixContainer &ForceFragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateForce)(class MatrixContainer &, int)); 21 bool CreateDataEnergyOrder(class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum); 22 bool CreateDataDeltaEnergyOrder(class EnergyMatrix &Energy, class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum); 23 bool CreateDataForcesOrder(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateForce)(class MatrixContainer &, int)); 24 bool CreateDataForcesOrderPerAtom(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum); 25 bool CreateDataDeltaForcesOrder(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateForce)(class MatrixContainer &, int)); 26 bool CreateDataDeltaForcesOrderPerAtom(class ForceMatrix &Force, class ForceMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum); 23 27 bool CreateDataFragment(class MatrixContainer &ForceFragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateForce)(class MatrixContainer &, int)); 24 28 bool CreateDataFragmentOrder(class MatrixContainer &Fragment, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum, void (*CreateFragmentOrder)(class MatrixContainer &, class KeySetsContainer &, int)); … … 30 34 void CreateMeanForce(class MatrixContainer &Force, int MatrixNumber); 31 35 void CreateMaximumForce(class MatrixContainer &Force, int MatrixNumber); 36 void CreateSameForce(class MatrixContainer &Force, int MatrixNumber); 32 37 void CreateVectorSumForce(class MatrixContainer &Force, int MatrixNumber); 33 38 -
src/defs.hpp
rc685eb r390248 49 49 #define TEFACTORSFILE "TE-Factors.dat" //!< default filename of BOSSANOVA total energy factors file 50 50 #define FORCESFILE "Forces-Factors.dat" //!< default filename of BOSSANOVA force factors file 51 #define HCORRECTIONSUFFIX "Hcorrection.dat" //!< default filename of BOSSANOVA H correction file (unwanted saturation interaction) 52 #define FITCONSTANTSUFFIX "FitConstant.dat" //!< suffix of default filename of BOSSANOVA fit constants file (unwanted saturation interaction) 51 53 #define SHIELDINGSUFFIX "sigma_all.csv" //!< default filename of BOSSANOVA shieldings file 52 54 #define SHIELDINGPASSUFFIX "sigma_all_PAS.csv" //!< default filename of BOSSANOVA shieldings PAS file -
src/joiner.cpp
rc685eb r390248 19 19 periodentafel *periode = NULL; // and a period table of all elements 20 20 EnergyMatrix Energy; 21 EnergyMatrix Hcorrection; 21 22 ForceMatrix Force; 22 23 EnergyMatrix EnergyFragments; 24 EnergyMatrix HcorrectionFragments; 23 25 ForceMatrix ForceFragments; 24 26 ForceMatrix Shielding; … … 28 30 KeySetsContainer KeySet; 29 31 stringstream prefix; 32 char *dir = NULL; 33 bool Hcorrected = true; 30 34 31 35 cout << "Joiner" << endl; … … 39 43 cout << "[elementsdb]\tpath to elements database, needed for shieldings." << endl; 40 44 return 1; 45 } else { 46 dir = (char *) Malloc(sizeof(char)*(strlen(argv[2])+2), "main: *dir"); 47 strcpy(dir, "/"); 48 strcat(dir, argv[2]); 41 49 } 42 50 if (argc > 3) { … … 52 60 53 61 // ------------- Parse through all Fragment subdirs -------- 54 if (!Energy.ParseMatrix(argv[1], argv[2], EnergySuffix, 0,0)) return 1; 55 if (!Force.ParseMatrix(argv[1], argv[2], ForcesSuffix, 0,0)) return 1; 62 if (!Energy.ParseMatrix(argv[1], dir, EnergySuffix, 0,0)) return 1; 63 Hcorrected = Hcorrection.ParseMatrix(argv[1], "", HCORRECTIONSUFFIX, 0,0); 64 if (!Force.ParseMatrix(argv[1], dir, ForcesSuffix, 0,0)) return 1; 56 65 if (periode != NULL) { // also look for PAS values 57 if (!Shielding.ParseMatrix(argv[1], argv[2], ShieldingSuffix, 1, 0)) return 1;58 if (!ShieldingPAS.ParseMatrix(argv[1], argv[2], ShieldingPASSuffix, 1, 0)) return 1;66 if (!Shielding.ParseMatrix(argv[1], dir, ShieldingSuffix, 1, 0)) return 1; 67 if (!ShieldingPAS.ParseMatrix(argv[1], dir, ShieldingPASSuffix, 1, 0)) return 1; 59 68 } 60 69 61 70 // ---------- Parse the TE Factors into an array ----------------- 62 71 if (!Energy.ParseIndices()) return 1; 72 if (Hcorrected) Hcorrection.ParseIndices(); 63 73 64 74 // ---------- Parse the Force indices into an array --------------- … … 76 86 if (!KeySet.ParseManyBodyTerms()) return 1; 77 87 if (!EnergyFragments.AllocateMatrix(Energy.Header, Energy.MatrixCounter, Energy.RowCounter, Energy.ColumnCounter)) return 1; 88 if (Hcorrected) HcorrectionFragments.AllocateMatrix(Hcorrection.Header, Hcorrection.MatrixCounter, Hcorrection.RowCounter, Hcorrection.ColumnCounter); 78 89 if (!ForceFragments.AllocateMatrix(Force.Header, Force.MatrixCounter, Force.RowCounter, Force.ColumnCounter)) return 1; 79 90 if (periode != NULL) { // also look for PAS values … … 86 97 if(!Force.SetLastMatrix(0., 2)) return 1; 87 98 if (periode != NULL) { // also look for PAS values 88 if(!Shielding.SetLastMatrix(0., 0)) return 1;99 if(!Shielding.SetLastMatrix(0., 2)) return 1; 89 100 if(!ShieldingPAS.SetLastMatrix(0., 2)) return 1; 90 101 } … … 97 108 cout << "Summing energy of order " << BondOrder+1 << " ..." << endl; 98 109 if (!EnergyFragments.SumSubManyBodyTerms(Energy, KeySet, BondOrder)) return 1; 99 if (!Energy.SumSubEnergy(EnergyFragments, KeySet, BondOrder)) return 1; 110 if (Hcorrected) { 111 HcorrectionFragments.SumSubManyBodyTerms(Hcorrection, KeySet, BondOrder); 112 if (!Energy.SumSubEnergy(EnergyFragments, &HcorrectionFragments, KeySet, BondOrder, 1.)) return 1; 113 if (Hcorrected) Hcorrection.SumSubEnergy(HcorrectionFragments, NULL, KeySet, BondOrder, 1.); 114 } else 115 if (!Energy.SumSubEnergy(EnergyFragments, NULL, KeySet, BondOrder, 1.)) return 1; 100 116 // --------- sum up Forces -------------------- 101 117 cout << "Summing forces of order " << BondOrder+1 << " ..." << endl; 102 118 if (!ForceFragments.SumSubManyBodyTerms(Force, KeySet, BondOrder)) return 1; 103 if (!Force.SumSubForces(ForceFragments, KeySet, BondOrder )) return 1;119 if (!Force.SumSubForces(ForceFragments, KeySet, BondOrder, 1.)) return 1; 104 120 if (periode != NULL) { // also look for PAS values 105 121 cout << "Summing shieldings of order " << BondOrder+1 << " ..." << endl; 106 122 if (!ShieldingFragments.SumSubManyBodyTerms(Shielding, KeySet, BondOrder)) return 1; 107 if (!Shielding.SumSubForces(ShieldingFragments, KeySet, BondOrder )) return 1;123 if (!Shielding.SumSubForces(ShieldingFragments, KeySet, BondOrder, 1.)) return 1; 108 124 if (!ShieldingPASFragments.SumSubManyBodyTerms(ShieldingPAS, KeySet, BondOrder)) return 1; 109 if (!ShieldingPAS.SumSubForces(ShieldingPASFragments, KeySet, BondOrder )) return 1;125 if (!ShieldingPAS.SumSubForces(ShieldingPASFragments, KeySet, BondOrder, 1.)) return 1; 110 126 } 111 127 112 128 // --------- write the energy and forces file -------------------- 113 129 prefix.str(" "); 114 prefix << argv[2]<< OrderSuffix << (BondOrder+1);130 prefix << dir << OrderSuffix << (BondOrder+1); 115 131 cout << "Writing files " << argv[1] << prefix.str() << ". ..." << endl; 116 132 // energy … … 126 142 // fragments 127 143 prefix.str(" "); 128 prefix << argv[2]<< EnergyFragmentSuffix;144 prefix << dir << EnergyFragmentSuffix; 129 145 if (!EnergyFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1; 146 if (Hcorrected) { 147 prefix.str(" "); 148 prefix << dir << HcorrectionFragmentSuffix; 149 if (!HcorrectionFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1; 150 } 130 151 prefix.str(" "); 131 prefix << argv[2]<< ForceFragmentSuffix;152 prefix << dir << ForceFragmentSuffix; 132 153 if (!ForceFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1; 133 154 if (!CreateDataFragment(EnergyFragments, KeySet, argv[1], FRAGMENTPREFIX ENERGYPERFRAGMENT, "fragment energy versus the Fragment No", "today", CreateEnergy)) return 1; 134 155 if (periode != NULL) { // also look for PAS values 135 156 prefix.str(" "); 136 prefix << argv[2]<< ShieldingFragmentSuffix;157 prefix << dir << ShieldingFragmentSuffix; 137 158 if (!ShieldingFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1; 138 159 prefix.str(" "); 139 prefix << argv[2]<< ShieldingPASFragmentSuffix;160 prefix << dir << ShieldingPASFragmentSuffix; 140 161 if (!ShieldingPASFragments.WriteTotalFragments(argv[1], (prefix.str()).c_str())) return 1; 141 162 } 142 163 143 164 // write last matrices as fragments into central dir (not subdir as above), for analyzer to know index bounds 144 if (!Energy.WriteLastMatrix(argv[1], argv[2], EnergyFragmentSuffix)) return 1; 145 if (!Force.WriteLastMatrix(argv[1], argv[2], ForceFragmentSuffix)) return 1; 165 if (!Energy.WriteLastMatrix(argv[1], dir, EnergyFragmentSuffix)) return 1; 166 if (Hcorrected) Hcorrection.WriteLastMatrix(argv[1], dir, HcorrectionFragmentSuffix); 167 if (!Force.WriteLastMatrix(argv[1], dir, ForceFragmentSuffix)) return 1; 146 168 if (periode != NULL) { // also look for PAS values 147 if (!Shielding.WriteLastMatrix(argv[1], argv[2], ShieldingFragmentSuffix)) return 1;148 if (!ShieldingPAS.WriteLastMatrix(argv[1], argv[2], ShieldingPASFragmentSuffix)) return 1;169 if (!Shielding.WriteLastMatrix(argv[1], dir, ShieldingFragmentSuffix)) return 1; 170 if (!ShieldingPAS.WriteLastMatrix(argv[1], dir, ShieldingPASFragmentSuffix)) return 1; 149 171 } 150 172 151 173 // exit 152 174 delete(periode); 175 Free((void **)&dir, "main: *dir"); 153 176 cout << "done." << endl; 154 177 return 0; -
src/moleculelist.cpp
rc685eb r390248 133 133 }; 134 134 135 /** Calculates necessary hydrogen correction due to unwanted interaction between saturated ones. 136 * If for a pair of two hydrogen atoms a and b, at least is a saturated one, and a and b are not 137 * bonded to the same atom, then we add for this pair a correction term constructed from a Morse 138 * potential function fit to QM calculations with respecting to the interatomic hydrogen distance. 139 * \param *out output stream for debugging 140 * \param *path path to file 141 */ 142 bool MoleculeListClass::AddHydrogenCorrection(ofstream *out, char *path) 143 { 144 atom *Walker = NULL; 145 atom *Runner = NULL; 146 double ***FitConstant = NULL, **correction = NULL; 147 int a,b; 148 ofstream output; 149 ifstream input; 150 string line; 151 stringstream zeile; 152 double distance; 153 char ParsedLine[1023]; 154 double tmp; 155 char *FragmentNumber = NULL; 156 157 cout << Verbose(1) << "Saving hydrogen saturation correction ... "; 158 // 0. parse in fit constant files that should have the same dimension as the final energy files 159 // 0a. find dimension of matrices with constants 160 line = path; 161 line.append("/"); 162 line += FRAGMENTPREFIX; 163 line += "1"; 164 line += FITCONSTANTSUFFIX; 165 input.open(line.c_str()); 166 if (input == NULL) { 167 cerr << endl << "Unable to open " << line << ", is the directory correct?" << endl; 168 return false; 169 } 170 a=0; 171 b=-1; // we overcount by one 172 while (!input.eof()) { 173 input.getline(ParsedLine, 1023); 174 zeile.str(ParsedLine); 175 int i=0; 176 while (!zeile.eof()) { 177 zeile >> distance; 178 i++; 179 } 180 if (i > a) 181 a = i; 182 b++; 183 } 184 cout << "I recognized " << a << " columns and " << b << " rows, "; 185 input.close(); 186 187 // 0b. allocate memory for constants 188 FitConstant = (double ***) Malloc(sizeof(double **)*3, "MoleculeListClass::AddHydrogenCorrection: ***FitConstant"); 189 for (int k=0;k<3;k++) { 190 FitConstant[k] = (double **) Malloc(sizeof(double *)*a, "MoleculeListClass::AddHydrogenCorrection: **FitConstant[]"); 191 for (int i=a;i--;) { 192 FitConstant[k][i] = (double *) Malloc(sizeof(double)*b, "MoleculeListClass::AddHydrogenCorrection: *FitConstant[][]"); 193 } 194 } 195 // 0c. parse in constants 196 for (int i=0;i<3;i++) { 197 line = path; 198 line.append("/"); 199 line += FRAGMENTPREFIX; 200 sprintf(ParsedLine, "%d", i+1); 201 line += ParsedLine; 202 line += FITCONSTANTSUFFIX; 203 input.open(line.c_str()); 204 if (input == NULL) { 205 cerr << endl << "Unable to open " << line << ", is the directory correct?" << endl; 206 return false; 207 } 208 int k = 0,l; 209 while ((!input.eof()) && (k < b)) { 210 input.getline(ParsedLine, 1023); 211 //cout << "Current Line: " << ParsedLine << endl; 212 zeile.str(ParsedLine); 213 zeile.clear(); 214 l = 0; 215 while ((!zeile.eof()) && (l < a)) { 216 zeile >> FitConstant[i][l][k]; 217 //cout << FitConstant[i][l][k] << "\t"; 218 l++; 219 } 220 //cout << endl; 221 k++; 222 } 223 input.close(); 224 } 225 for(int k=0;k<3;k++) { 226 cout << "Constants " << k << ":" << endl; 227 for (int j=0;j<b;j++) { 228 for (int i=0;i<a;i++) { 229 cout << FitConstant[k][i][j] << "\t"; 230 } 231 cout << endl; 232 } 233 cout << endl; 234 } 235 236 // 0d. allocate final correction matrix 237 correction = (double **) Malloc(sizeof(double *)*a, "MoleculeListClass::AddHydrogenCorrection: **correction"); 238 for (int i=a;i--;) 239 correction[i] = (double *) Malloc(sizeof(double)*b, "MoleculeListClass::AddHydrogenCorrection: *correction[]"); 240 241 // 1a. go through every molecule in the list 242 for(int i=NumberOfMolecules;i--;) { 243 // 1b. zero final correction matrix 244 for (int k=a;k--;) 245 for (int j=b;j--;) 246 correction[k][j] = 0.; 247 // 2. take every hydrogen that is a saturated one 248 Walker = ListOfMolecules[i]->start; 249 while (Walker->next != ListOfMolecules[i]->end) { 250 Walker = Walker->next; 251 //cout << Verbose(1) << "Walker: " << *Walker << " with first bond " << *ListOfMolecules[i]->ListOfBondsPerAtom[Walker->nr][0] << "." << endl; 252 if ((Walker->type->Z == 1) && ((Walker->father == NULL) || (Walker->father->type->Z != 1))) { // if it's a hydrogen 253 Runner = ListOfMolecules[i]->start; 254 while (Runner->next != ListOfMolecules[i]->end) { 255 Runner = Runner->next; 256 //cout << Verbose(2) << "Runner: " << *Runner << " with first bond " << *ListOfMolecules[i]->ListOfBondsPerAtom[Runner->nr][0] << "." << endl; 257 // 3. take every other hydrogen that is the not the first and not bound to same bonding partner 258 if ((Runner->type->Z == 1) && (Runner->nr > Walker->nr) && (ListOfMolecules[i]->ListOfBondsPerAtom[Runner->nr][0]->GetOtherAtom(Runner) != ListOfMolecules[i]->ListOfBondsPerAtom[Walker->nr][0]->GetOtherAtom(Walker))) { // (hydrogens have only one bonding partner!) 259 // 4. evaluate the morse potential for each matrix component and add up 260 distance = sqrt(Runner->x.Distance(&Walker->x)); 261 //cout << "Fragment " << i << ": " << *Runner << "<= " << distance << "=>" << *Walker << ":" << endl; 262 for(int k=0;k<a;k++) { 263 for (int j=0;j<b;j++) { 264 switch(k) { 265 case 1: 266 case 7: 267 case 11: 268 tmp = pow(FitConstant[0][k][j] * ( 1. - exp(-FitConstant[1][k][j] * (distance - FitConstant[2][k][j]) ) ),2); 269 break; 270 default: 271 tmp = FitConstant[0][k][j] * pow( distance, FitConstant[1][k][j]) + FitConstant[2][k][j]; 272 }; 273 correction[k][j] -= tmp; // ground state is actually lower (disturbed by additional interaction) 274 //cout << tmp << "\t"; 275 } 276 //cout << endl; 277 } 278 //cout << endl; 279 } 280 } 281 } 282 } 283 // 5. write final matrix to file 284 line = path; 285 line.append("/"); 286 line += FRAGMENTPREFIX; 287 FragmentNumber = FixedDigitNumber(NumberOfMolecules, i); 288 line += FragmentNumber; 289 delete(FragmentNumber); 290 line += HCORRECTIONSUFFIX; 291 output.open(line.c_str()); 292 output << "Time\t\tTotal\t\tKinetic\t\tNonLocal\tCorrelation\tExchange\tPseudo\t\tHartree\t\t-Gauss\t\tEwald\t\tIonKin\t\tETotal" << endl; 293 for (int j=0;j<b;j++) { 294 for(int i=0;i<a;i++) 295 output << correction[i][j] << "\t"; 296 output << endl; 297 } 298 output.close(); 299 } 300 line = path; 301 line.append("/"); 302 line += HCORRECTIONSUFFIX; 303 output.open(line.c_str()); 304 output << "Time\t\tTotal\t\tKinetic\t\tNonLocal\tCorrelation\tExchange\tPseudo\t\tHartree\t\t-Gauss\t\tEwald\t\tIonKin\t\tETotal" << endl; 305 for (int j=0;j<b;j++) { 306 for(int i=0;i<a;i++) 307 output << 0 << "\t"; 308 output << endl; 309 } 310 output.close(); 311 // 6. free memory of parsed matrices 312 FitConstant = (double ***) Malloc(sizeof(double **)*a, "MoleculeListClass::AddHydrogenCorrection: ***FitConstant"); 313 for (int k=0;k<3;k++) { 314 FitConstant[k] = (double **) Malloc(sizeof(double *)*a, "MoleculeListClass::AddHydrogenCorrection: **FitConstant[]"); 315 for (int i=a;i--;) { 316 FitConstant[k][i] = (double *) Malloc(sizeof(double)*b, "MoleculeListClass::AddHydrogenCorrection: *FitConstant[][]"); 317 } 318 } 319 cout << "done." << endl; 320 return true; 321 }; 135 322 136 323 /** Store force indices, i.e. the connection between the nuclear index in the total molecule config and the respective atom in fragment config. … … 224 411 outputFragment.open(FragmentName, ios::out); 225 412 *out << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter-1 << " as XYZ ..."; 226 if ( intermediateResult = ListOfMolecules[i]->OutputXYZ(&outputFragment))413 if ((intermediateResult = ListOfMolecules[i]->OutputXYZ(&outputFragment))) 227 414 *out << " done." << endl; 228 415 else … … 263 450 configuration->SetDefaultPath(FragmentName); 264 451 *out << Verbose(2) << "Saving bond fragment No. " << FragmentNumber << "/" << FragmentCounter-1 << " as config ..."; 265 if ( intermediateResult = configuration->Save(&outputFragment, ListOfMolecules[i]->elemente, ListOfMolecules[i]))452 if ((intermediateResult = configuration->Save(&outputFragment, ListOfMolecules[i]->elemente, ListOfMolecules[i]))) 266 453 *out << " done." << endl; 267 454 else -
src/molecules.cpp
rc685eb r390248 2707 2707 StoreAdjacencyToFile(out, configuration->configpath); 2708 2708 2709 // store Hydrogen saturation correction file 2710 BondFragments->AddHydrogenCorrection(out, configuration->configpath); 2711 2709 2712 // store adaptive orders into file 2710 2713 StoreOrderAtSiteFile(out, configuration->configpath); -
src/molecules.hpp
rc685eb r390248 289 289 290 290 /// Output configs. 291 bool AddHydrogenCorrection(ofstream *out, char *path); 291 292 bool StoreForcesFile(ofstream *out, char *path, int *SortIndex); 292 293 bool OutputConfigForListOfFragments(ofstream *out, config *configuration, int *SortIndex); -
src/parser.cpp
rc685eb r390248 146 146 file.str(" "); 147 147 if (i != MatrixCounter) 148 file << name << FRAGMENTPREFIX << FragmentNumber << "/" <<prefix << suffix;148 file << name << FRAGMENTPREFIX << FragmentNumber << prefix << suffix; 149 149 else 150 150 file << name << prefix << suffix; … … 265 265 }; 266 266 267 /** Scans all elements of MatrixContainer::Matrix for greatest absolute value. 268 * \return greatest value of MatrixContainer::Matrix 269 */ 270 double MatrixContainer::FindMaxValue() 271 { 272 double max = Matrix[0][0][0]; 273 for(int i=MatrixCounter+1;i--;) 274 for(int j=RowCounter[i]+1;j--;) 275 for(int k=ColumnCounter;k--;) 276 if (fabs(Matrix[i][j][k]) > max) 277 max = fabs(Matrix[i][j][k]); 278 if (fabs(max) < MYEPSILON) 279 max += MYEPSILON; 280 return max; 281 }; 282 283 /** Scans all elements of MatrixContainer::Matrix for smallest absolute value. 284 * \return smallest value of MatrixContainer::Matrix 285 */ 286 double MatrixContainer::FindMinValue() 287 { 288 double min = Matrix[0][0][0]; 289 for(int i=MatrixCounter+1;i--;) 290 for(int j=RowCounter[i]+1;j--;) 291 for(int k=ColumnCounter;k--;) 292 if (fabs(Matrix[i][j][k]) < min) 293 min = fabs(Matrix[i][j][k]); 294 if (fabs(min) < MYEPSILON) 295 min += MYEPSILON; 296 return min; 297 }; 298 267 299 /** Sets all values in the last of MatrixContainer::Matrix to \a value. 268 300 * \param value reset value … … 333 365 } 334 366 } 335 //if ((ColumnCounter>1) && (RowCounter[0]-1 >= 1))336 //cout << "Fragments[ KeySet.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySet.OrderSet[Order][CurrentFragment] << " ][" << RowCounter[0]-1 << "][" << 1 << "] = " << Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][RowCounter[0]-1][1] << endl;367 //if ((ColumnCounter>1) && (RowCounter[0]-1 >= 1)) 368 //cout << "Fragments[ KeySet.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySet.OrderSet[Order][CurrentFragment] << " ][" << RowCounter[0]-1 << "][" << 1 << "] = " << Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][RowCounter[0]-1][1] << endl; 337 369 } 338 370 } else { … … 341 373 } 342 374 } 343 375 //cout << "Final Fragments[ KeySet.OrderSet[" << Order << "][" << CurrentFragment << "]=" << KeySet.OrderSet[Order][CurrentFragment] << " ][" << KeySet.AtomCounter[0]-1 << "][" << 1 << "] = " << Matrix[ KeySet.OrderSet[Order][CurrentFragment] ][KeySet.AtomCounter[0]-1][1] << endl; 344 376 } 345 377 … … 428 460 * Sums over the "F"-terms in ANOVA decomposition. 429 461 * \param Matrix MatrixContainer with matrices (LevelCounter by ColumnCounter) with all the energies. 462 * \param CorrectionFragments MatrixContainer with hydrogen saturation correction per fragments 430 463 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order 431 464 * \param Order bond order 465 * \parsm sign +1 or -1 432 466 * \return true if summing was successful 433 467 */ 434 bool EnergyMatrix::SumSubEnergy(class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, int Order)468 bool EnergyMatrix::SumSubEnergy(class EnergyMatrix &Fragments, class EnergyMatrix *CorrectionFragments, class KeySetsContainer &KeySet, int Order, double sign) 435 469 { 436 470 // sum energy 437 for(int i=KeySet.FragmentsPerOrder[Order];i--;) 438 for(int j=RowCounter[ KeySet.OrderSet[Order][i] ];j--;) 439 for(int k=ColumnCounter;k--;) 440 Matrix[MatrixCounter][j][k] += Fragments.Matrix[ KeySet.OrderSet[Order][i] ][j][k]; 471 if (CorrectionFragments == NULL) 472 for(int i=KeySet.FragmentsPerOrder[Order];i--;) 473 for(int j=RowCounter[ KeySet.OrderSet[Order][i] ];j--;) 474 for(int k=ColumnCounter;k--;) 475 Matrix[MatrixCounter][j][k] += sign*Fragments.Matrix[ KeySet.OrderSet[Order][i] ][j][k]; 476 else 477 for(int i=KeySet.FragmentsPerOrder[Order];i--;) 478 for(int j=RowCounter[ KeySet.OrderSet[Order][i] ];j--;) 479 for(int k=ColumnCounter;k--;) 480 Matrix[MatrixCounter][j][k] += sign*(Fragments.Matrix[ KeySet.OrderSet[Order][i] ][j][k] + CorrectionFragments->Matrix[ KeySet.OrderSet[Order][i] ][j][k]); 441 481 return true; 442 482 }; … … 492 532 * \param KeySet KeySetContainer with bond Order and association mapping of each fragment to an order 493 533 * \param Order bond order 534 * \param sign +1 or -1 494 535 * \return true if summing was successful 495 536 */ 496 bool ForceMatrix::SumSubForces(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, int Order) 497 { 537 bool ForceMatrix::SumSubForces(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, int Order, double sign) 538 { 539 int FragmentNr; 498 540 // sum forces 499 for(int i=0;i<KeySet.FragmentsPerOrder[Order];i++) 500 for(int l=0;l<RowCounter[ KeySet.OrderSet[Order][i] ];l++) { 501 int j = Indices[ KeySet.OrderSet[Order][i] ][l]; 541 for(int i=0;i<KeySet.FragmentsPerOrder[Order];i++) { 542 FragmentNr = KeySet.OrderSet[Order][i]; 543 for(int l=0;l<RowCounter[ FragmentNr ];l++) { 544 int j = Indices[ FragmentNr ][l]; 502 545 if (j > RowCounter[MatrixCounter]) { 503 546 cerr << "Current force index " << j << " is greater than " << RowCounter[MatrixCounter] << "!" << endl; 504 547 return false; 505 548 } 506 if (j != -1) 549 if (j != -1) { 550 //if (j == 0) cout << "Summing onto ion 0, type 0 from fragment " << FragmentNr << ", ion " << l << "." << endl; 507 551 for(int k=2;k<ColumnCounter;k++) 508 Matrix[MatrixCounter][j][k] += Fragments.Matrix[ KeySet.OrderSet[Order][i] ][l][k]; 509 } 552 Matrix[MatrixCounter][j][k] += sign*Fragments.Matrix[ FragmentNr ][l][k]; 553 } 554 } 555 } 510 556 return true; 511 557 }; … … 571 617 KeySets[i][j] = -1; 572 618 FragmentNumber = FixedDigitNumber(FragmentCounter, i); 573 cout << FRAGMENTPREFIX << FragmentNumber << "[" << AtomCounter[i] << "]:";619 //cout << FRAGMENTPREFIX << FragmentNumber << "[" << AtomCounter[i] << "]:"; 574 620 Free((void **)&FragmentNumber, "KeySetsContainer::ParseKeySets: *FragmentNumber"); 575 621 input.getline(filename, 1023); … … 577 623 for(int j=0;(j<AtomCounter[i]) && (!line.eof());j++) { 578 624 line >> KeySets[i][j]; 579 cout << " " << KeySets[i][j];580 } 581 cout << endl;625 //cout << " " << KeySets[i][j]; 626 } 627 //cout << endl; 582 628 } 583 629 input.close(); -
src/parser.hpp
rc685eb r390248 19 19 20 20 #define EnergySuffix ".energy.all" 21 #define HcorrectionSuffix ".Hcorrection.all" 21 22 #define ForcesSuffix ".forces.all" 22 23 #define ShieldingSuffix ".sigma_all.csv" … … 26 27 #define TimeSuffix ".speed" 27 28 #define EnergyFragmentSuffix ".energyfragment.all" 29 #define HcorrectionFragmentSuffix ".Hcorrectionfragment.all" 28 30 #define ForceFragmentSuffix ".forcefragment.all" 29 31 #define OrderSuffix ".Order" … … 52 54 bool AllocateMatrix(char *GivenHeader, int MCounter, int *RCounter, int CCounter); 53 55 bool ResetMatrix(); 56 double FindMinValue(); 57 double FindMaxValue(); 54 58 bool SetLastMatrix(double value, int skipcolumns); 55 59 bool SetLastMatrix(double **values, int skipcolumns); … … 66 70 public: 67 71 bool ParseIndices(); 68 bool SumSubEnergy(class EnergyMatrix &Fragments, class KeySetsContainer &KeySet, int Order);72 bool SumSubEnergy(class EnergyMatrix &Fragments, class EnergyMatrix *CorrectionFragments, class KeySetsContainer &KeySet, int Order, double sign); 69 73 }; 70 74 … … 74 78 public: 75 79 bool ParseIndices(char *name); 76 bool SumSubForces(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, int Order );80 bool SumSubForces(class ForceMatrix &Fragments, class KeySetsContainer &KeySet, int Order, double sign); 77 81 }; 78 82
Note:
See TracChangeset
for help on using the changeset viewer.