Changeset 84fc91 for src/datacreator.cpp


Ignore:
Timestamp:
Oct 29, 2008, 2:54:54 PM (16 years ago)
Author:
Frederik Heber <heber@…>
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:
234af2
Parents:
eeec8f
Message:

Implemented Frobenius norm calculation for class HessianMatrix

HessianMatrix::CreateDataDeltaFrobeniusOrderPerAtom() - New data creator that calculates the frobenius norm (with 1/N prefactor), to estimate the accuracy of the approximated HessianMatrix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/datacreator.cpp

    reeec8f r84fc91  
    298298    output << endl;
    299299  }
     300  output.close();
     301  return true;
     302};
     303
     304/** Plot hessian error vs. vs atom vs. order in the frobenius norm.
     305 * \param &Hessian HessianMatrix containing reference values (in MatrixCounter matrix)
     306 * \param &Fragments HessianMatrix class containing matrix values
     307 * \param KeySet KeySetContainer class holding bond KeySetContainer::Order
     308 * \param *prefix prefix in filename (without ending)
     309 * \param *msg message to be place in first line as a comment
     310 * \param *datum current date and time
     311 * \return true if file was written successfully
     312 */
     313bool CreateDataDeltaFrobeniusOrderPerAtom(class HessianMatrix &Hessian, class HessianMatrix &Fragments, class KeySetsContainer &KeySet, char *dir, char *prefix, char *msg, char *datum)
     314{
     315  stringstream filename;
     316  ofstream output;
     317  double norm = 0;
     318  double tmp;
     319
     320  filename << prefix << ".dat";
     321  if (!OpenOutputFile(output, dir, filename.str().c_str())) return false;
     322  cout << msg << endl;
     323  output << "# " << msg << ", created on " << datum;
     324  output << "# AtomNo\t";
     325  Fragments.SetLastMatrix(Hessian.Matrix[Hessian.MatrixCounter], 0);
     326  for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
     327    output << "Order" << BondOrder+1 << "\t";
     328  }
     329  output << endl;
     330  output << Fragments.RowCounter[ Fragments.MatrixCounter ] << "\t";
     331  for (int BondOrder=0;BondOrder<KeySet.Order;BondOrder++) {
     332    //cout << "Current order is " << BondOrder << "." << endl;
     333    Fragments.SumSubHessians(Fragments, KeySet, BondOrder, -1.);
     334    // frobenius norm of errors per atom
     335    norm = 0.;
     336    for(int j=0;j<Fragments.RowCounter[ Fragments.MatrixCounter ];j++) {
     337      for (int l=0;l<Fragments.ColumnCounter[ Fragments.MatrixCounter ];l++) {
     338        tmp = Fragments.Matrix[Fragments.MatrixCounter][ j ][l];
     339        norm += tmp*tmp;
     340      }
     341    }
     342    output << scientific << sqrt(norm)/(Fragments.RowCounter[ Fragments.MatrixCounter ]*Fragments.ColumnCounter[ Fragments.MatrixCounter] ) << "\t";
     343  }
     344  output << endl;
    300345  output.close();
    301346  return true;
Note: See TracChangeset for help on using the changeset viewer.