Changes in / [c73e35:d8821e]
- Files:
-
- 44 added
- 306 deleted
- 81 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile.am
rc73e35 rd8821e 18 18 m4/cppunit.m4 19 19 20 .PHONY: doc 20 .PHONY: doc extracheck installextracheck 21 21 doc: 22 22 mkdir -p ${DX_DOCDIR} 23 23 cd doc && make doxygen-doc 24 24 25 extracheck: 26 cd tests && make extracheck 27 installextracheck: 28 cd tests && make installextracheck 29 25 30 unity: 26 31 cd src && make unity -
configure.ac
rc73e35 rd8821e 235 235 AC_MSG_RESULT($enable_jobmarket) 236 236 AS_IF([test x"$enable_jobmarket" != x"no"],[ 237 # JobMarket library (needs priorizing of jobs)238 AM_PATH_JOBMARKET([1.1. 4], $have_debug,[237 # JobMarket library (needs SystemCommandJob with suffix) 238 AM_PATH_JOBMARKET([1.1.5], $have_debug,[ 239 239 # the following is only required if we have JobMarket 240 240 BOOST_ASIO … … 409 409 tests/Makefile]) 410 410 411 AC_CONFIG_TESTDIR(tests/Calculations) 412 AC_CONFIG_FILES([ 413 tests/Calculations/atlocal 414 tests/Calculations/Makefile]) 415 AC_CONFIG_FILES([tests/Calculations/molecuilder], [chmod +x tests/Calculations/molecuilder]) 416 411 417 AC_CONFIG_TESTDIR(tests/CodeChecks) 412 418 AC_CONFIG_FILES([ … … 418 424 tests/Fragmentations/atlocal 419 425 tests/Fragmentations/Makefile]) 420 AC_CONFIG_FILES([tests/Fragmentations/analyzer], [chmod +x tests/Fragmentations/analyzer])421 AC_CONFIG_FILES([tests/Fragmentations/joiner], [chmod +x tests/Fragmentations/joiner])422 426 AC_CONFIG_FILES([tests/Fragmentations/molecuilder], [chmod +x tests/Fragmentations/molecuilder]) 423 427 -
src/Actions/ActionQueue.cpp
rc73e35 rd8821e 58 58 AR(new ActionRegistry()), 59 59 history(new ActionHistory), 60 CurrentAction(0), 60 61 #ifndef HAVE_ACTION_THREAD 61 CurrentAction(0)62 lastActionOk(true) 62 63 #else 63 CurrentAction(0),64 lastActionOk(true), 64 65 run_thread(boost::bind(&ActionQueue::run, this)), 65 66 run_thread_isIdle(true) … … 99 100 try { 100 101 newaction->call(); 102 lastActionOk = true; 101 103 } catch(ActionFailureException &e) { 102 104 std::cerr << "Action " << *boost::get_error_info<ActionNameString>(e) << " has failed." << std::endl; 103 105 World::getInstance().setExitFlag(5); 106 actionqueue.clear(); 107 tempqueue.clear(); 108 lastActionOk = false; 109 std::cerr << "ActionQueue cleared." << std::endl; 104 110 } 105 111 #else … … 157 163 actionqueue[CurrentAction]->call(); 158 164 pushStatus("SUCCESS: Action "+actionqueue[CurrentAction]->getName()+" successful."); 165 lastActionOk = true; 159 166 } catch(ActionFailureException &e) { 160 167 pushStatus("FAIL: Action "+*boost::get_error_info<ActionNameString>(e)+" has failed."); 161 168 World::getInstance().setExitFlag(5); 169 actionqueue.clear(); 170 tempqueue.clear(); 171 lastActionOk = false; 172 std::cerr << "ActionQueue cleared." << std::endl; 173 CurrentAction = (size_t)-1; 162 174 } 163 175 // access actionqueue, hence using mutex -
src/Actions/ActionQueue.hpp
rc73e35 rd8821e 123 123 void redoLast(); 124 124 125 /** Return status of last executed action. 126 * 127 * \return true - action executed correctly, false - else 128 */ 129 bool getLastActionOk() const 130 { return lastActionOk; } 131 125 132 #ifdef HAVE_ACTION_THREAD 126 133 boost::thread &getRunThread() … … 221 228 ActionQueue_t tempqueue; 222 229 230 //!> indicates that the last action has failed 231 bool lastActionOk; 232 223 233 #ifdef HAVE_ACTION_THREAD 224 234 //!> internal thread to call Actions -
src/Actions/CommandAction/ElementDbAction.cpp
rc73e35 rd8821e 41 41 #include "config.hpp" 42 42 #include "Element/element.hpp" // we need element because of serialization! 43 #include "Element/ion.hpp" // we need element because of serialization! 43 44 #include "Element/periodentafel.hpp" 44 45 #include "CodePatterns/Log.hpp" -
src/Actions/FragmentationAction/AnalyseFragmentationResultsAction.cpp
rc73e35 rd8821e 63 63 #include "Descriptors/AtomIdDescriptor.hpp" 64 64 #include "Fragmentation/Summation/Containers/FragmentationChargeDensity.hpp" 65 #include "Fragmentation/Summation/Containers/FragmentationLongRangeResults.hpp"66 65 #include "Fragmentation/Summation/Containers/FragmentationResultContainer.hpp" 67 66 #include "Fragmentation/Summation/Containers/FragmentationShortRangeResults.hpp" … … 78 77 #include "Fragmentation/Summation/writeIndexedTable.hpp" 79 78 #include "Fragmentation/Summation/writeTable.hpp" 80 #ifdef HAVE_VMG 79 #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) 80 #include "Fragmentation/Summation/Containers/FragmentationLongRangeResults.hpp" 81 81 #include "Fragmentation/Summation/Containers/VMGData.hpp" 82 82 #include "Fragmentation/Summation/Containers/VMGDataFused.hpp" … … 232 232 233 233 234 #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) 234 235 /** Print long range energy from received results. 235 236 * … … 261 262 } 262 263 } 264 #endif 263 265 264 266 void appendToHomologies( 265 267 const FragmentationShortRangeResults &shortrangeresults, 268 #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) 266 269 const FragmentationLongRangeResults &longrangeresults, 270 #endif 267 271 const bool storeGrids 268 272 ) … … 311 315 // only store sampled grids if desired 312 316 if (storeGrids) { 317 #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) 313 318 // obtain charge distribution 314 319 std::map<IndexSet::ptr, std::pair< MPQCDataGridMap_t, MPQCDataGridMap_t> >::const_iterator chargeiter … … 338 343 // ++iter) 339 344 // *iter -= offset; 345 #else 346 ELOG(1, "Long-range information in homology desired but long-range analysis capability not compiled in."); 347 #endif 340 348 } 341 349 values.insert( std::make_pair( graph, value) ); … … 362 370 << ", associated energy " << iter->second.energy; 363 371 if (iter->second.containsGrids) 372 #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) 364 373 output << ", and sampled grid integral " << iter->second.charge_distribution.integral(); 374 #else 375 output << ", and there are sampled grids but capability not compiled in"; 376 #endif 365 377 output << "."; 366 378 LOG(2, output.str()); … … 610 622 } 611 623 612 #if def HAVE_VMG624 #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) 613 625 if (DoLongrange) { 614 626 if ( World::getInstance().getAllAtoms().size() == 0) { … … 651 663 } 652 664 #else 653 if (DoLongrange) 665 if (DoLongrange) { 654 666 ELOG(2, "File contains long-range information but long-range analysis capability not compiled in."); 667 } 655 668 656 669 // append all keysets to homology file with short-range info only (without grids) 657 { 658 std::map<JobId_t, VMGData> longrangeData; 659 FragmentationLongRangeResults longrangeresults( 660 shortrangedata,longrangeData,keysets, forcekeysets); 661 appendToHomologies(shortrangeresults, longrangeresults, false); 662 } 670 appendToHomologies(shortrangeresults, false); 663 671 #endif 664 672 -
src/Actions/FragmentationAction/FragmentationAction.cpp
rc73e35 rd8821e 41 41 #include "Descriptors/AtomSelectionDescriptor.hpp" 42 42 #include "Fragmentation/Exporters/ExportGraph_ToFiles.hpp" 43 #ifdef HAVE_JOBMARKET44 43 #include "Fragmentation/Exporters/ExportGraph_ToJobs.hpp" 45 #endif46 44 #include "Fragmentation/Fragmentation.hpp" 47 45 #include "Fragmentation/Graph.hpp" … … 273 271 exporter(); 274 272 } else { 275 #ifdef HAVE_JOBMARKET276 273 // store molecule's fragment in FragmentJobQueue 277 274 ExportGraph_ToJobs exporter(TotalGraph, treatment, saturation); 278 275 exporter.setLevel(params.level.get()); 279 276 exporter(); 280 #else281 STATUS("No output file types specified and JobMarket support is not compiled in.");282 return Action::failure;283 #endif284 277 } 285 278 } -
src/Actions/FragmentationAction/FragmentationAutomationAction.cpp
rc73e35 rd8821e 53 53 #include "CodePatterns/Info.hpp" 54 54 #include "CodePatterns/Log.hpp" 55 56 #ifdef HAVE_JOBMARKET 55 57 #include "JobMarket/Jobs/FragmentJob.hpp" 58 #else 59 #include "Jobs/JobMarket/FragmentJob.hpp" 60 #endif 56 61 57 62 #include "Fragmentation/Automation/FragmentJobQueue.hpp" 63 #ifdef HAVE_JOBMARKET 58 64 #include "Fragmentation/Automation/MPQCFragmentController.hpp" 65 #else 66 #include "Fragmentation/Automation/MPQCCommandFragmentController.hpp" 67 #endif 59 68 #include "Fragmentation/Summation/Containers/FragmentationChargeDensity.hpp" 60 69 #include "Fragmentation/Summation/Containers/FragmentationLongRangeResults.hpp" … … 63 72 #include "Fragmentation/Summation/Containers/MPQCData.hpp" 64 73 #include "Fragmentation/KeySetsContainer.hpp" 65 #if def HAVE_VMG74 #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) 66 75 #include "Fragmentation/Automation/VMGDebugGridFragmentController.hpp" 67 76 #include "Fragmentation/Automation/VMGFragmentController.hpp" … … 99 108 } 100 109 110 #ifdef HAVE_JOBMARKET 101 111 static void updateSteps(Process &p, const size_t step, const size_t total) 102 112 { … … 104 114 p.setCurrStep(step); 105 115 } 116 #endif 106 117 107 118 ActionState::ptr FragmentationFragmentationAutomationAction::performCall() { … … 117 128 size_t Exitflag = 0; 118 129 std::map<JobId_t, MPQCData> shortrangedata; 130 #ifdef HAVE_JOBMARKET 119 131 { 120 132 const size_t NumberJobs = FragmentJobQueue::getInstance().size(); … … 126 138 127 139 // Phase Two: add MPQCJobs and send 128 const size_t NoJobs = mpqccontroller.addJobsFromQueue(140 const bool AddJobsStatus = mpqccontroller.addJobsFromQueue( 129 141 params.DoLongrange.get() ? MPQCData::DoSampleDensity : MPQCData::DontSampleDensity, 130 142 params.DoValenceOnly.get() ? MPQCData::DoSampleValenceOnly : MPQCData::DontSampleValenceOnly 131 143 ); 132 LOG(1, "INFO: Added " << NoJobs << " from FragmentJobsQueue."); 144 if (AddJobsStatus) 145 LOG(1, "INFO: Added jobs from FragmentJobsQueue."); 146 else { 147 ELOG(1, "Adding jobs failed."); 148 return Action::failure; 149 } 133 150 mpqccontroller.run(); 134 151 … … 148 165 Exitflag += mpqccontroller.getExitflag(); 149 166 } 150 151 #ifdef HAVE_VMG 167 #else 168 { 169 const size_t NumberJobs = FragmentJobQueue::getInstance().size(); 170 MPQCCommandFragmentController mpqccontroller; 171 // Phase One: obtain ids: not needed, we have infinite pool 172 173 // Phase Two: add MPQCJobs and send 174 const size_t NoJobs = mpqccontroller.addJobsFromQueue( 175 params.DoLongrange.get() ? MPQCData::DoSampleDensity : MPQCData::DontSampleDensity, 176 params.DoValenceOnly.get() ? MPQCData::DoSampleValenceOnly : MPQCData::DontSampleValenceOnly, 177 params.executable.get().string() 178 ); 179 LOG(1, "INFO: Added " << NoJobs << " from FragmentJobsQueue."); 180 mpqccontroller.run(); 181 182 // get back the results and place them in shortrangedata 183 mpqccontroller.getResults(shortrangedata); 184 ASSERT( shortrangedata.size() == NumberJobs, 185 "FragmentationFragmentationAutomationAction::performCall() - number of converted results " 186 +toString(shortrangedata.size())+" and number of jobs "+toString(NumberJobs)+ " differ."); 187 188 Exitflag += mpqccontroller.getExitflag(); 189 } 190 #endif 191 192 #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) 152 193 if (params.DoLongrange.get()) { 153 194 if ( World::getInstance().getAllAtoms().size() == 0) { -
src/Actions/GlobalListOfActions.hpp
rc73e35 rd8821e 122 122 (SelectionNotShapeByName) \ 123 123 (FragmentationAnalyseFragmentationResults) \ 124 (FragmentationFragmentationAutomation) \ 124 125 (FragmentationClearFragmentationResults) \ 125 126 (FragmentationFragmentation) \ 127 (FragmentationMolecularDynamics) \ 128 (FragmentationParseFragmentJobs) \ 126 129 (FragmentationStoreSaturatedFragment) \ 127 130 (PotentialFitParticleCharges) \ … … 137 140 (ShapeTranslateShape) 138 141 139 // we need to append the automation action in case we have the JobMarket 140 #ifdef HAVE_JOBMARKET 141 #define GLOBALLISTOFACTIONS_JOBMARKET \ 142 BOOST_PP_SEQ_PUSH_BACK( \ 143 BOOST_PP_SEQ_PUSH_BACK( \ 144 BOOST_PP_SEQ_PUSH_BACK( \ 145 GLOBALLISTOFACTIONS_initial, \ 146 FragmentationFragmentationAutomation \ 147 ), \ 148 FragmentationMolecularDynamics \ 149 ), \ 150 FragmentationParseFragmentJobs \ 151 ) 152 #else 153 #define GLOBALLISTOFACTIONS_JOBMARKET \ 154 GLOBALLISTOFACTIONS_initial 155 #endif /* HAVE_JOBMARKET */ 156 142 // extend list of actions in case levmar is available 157 143 #ifdef HAVE_LEVMAR 158 144 #define GLOBALLISTOFACTIONS_LEVMAR \ 159 145 BOOST_PP_SEQ_PUSH_BACK( \ 160 GLOBALLISTOFACTIONS_ JOBMARKET, \146 GLOBALLISTOFACTIONS_initial, \ 161 147 PotentialFitPotential \ 162 148 ) 163 149 #else 164 150 #define GLOBALLISTOFACTIONS_LEVMAR \ 165 GLOBALLISTOFACTIONS_ JOBMARKET151 GLOBALLISTOFACTIONS_initial 166 152 #endif /* HAVE_LEVMAR */ 167 153 -
src/Actions/Makefile.am
rc73e35 rd8821e 228 228 Actions/FragmentationAction/ClearFragmentationResultsAction.cpp \ 229 229 Actions/FragmentationAction/FragmentationAction.cpp \ 230 Actions/FragmentationAction/FragmentationAutomationAction.cpp \ 231 Actions/FragmentationAction/MolecularDynamicsAction.cpp \ 232 Actions/FragmentationAction/ParseFragmentJobsAction.cpp \ 230 233 Actions/FragmentationAction/StoreSaturatedFragmentAction.cpp 231 234 FRAGMENTATIONACTIONHEADER = \ … … 233 236 Actions/FragmentationAction/ClearFragmentationResultsAction.hpp \ 234 237 Actions/FragmentationAction/FragmentationAction.hpp \ 238 Actions/FragmentationAction/FragmentationAutomationAction.hpp \ 239 Actions/FragmentationAction/MolecularDynamicsAction.hpp \ 240 Actions/FragmentationAction/ParseFragmentJobsAction.hpp \ 235 241 Actions/FragmentationAction/StoreSaturatedFragmentAction.hpp 236 242 FRAGMENTATIONACTIONDEFS = \ … … 238 244 Actions/FragmentationAction/ClearFragmentationResultsAction.def \ 239 245 Actions/FragmentationAction/FragmentationAction.def \ 240 Actions/FragmentationAction/StoreSaturatedFragmentAction.def241 242 if CONDJOBMARKET243 FRAGMENTATIONACTIONSOURCE += \244 Actions/FragmentationAction/FragmentationAutomationAction.cpp \245 Actions/FragmentationAction/MolecularDynamicsAction.cpp \246 Actions/FragmentationAction/ParseFragmentJobsAction.cpp247 FRAGMENTATIONACTIONHEADER += \248 Actions/FragmentationAction/FragmentationAutomationAction.hpp \249 Actions/FragmentationAction/MolecularDynamicsAction.hpp \250 Actions/FragmentationAction/ParseFragmentJobsAction.hpp251 FRAGMENTATIONACTIONDEFS += \252 246 Actions/FragmentationAction/FragmentationAutomationAction.def \ 253 247 Actions/FragmentationAction/MolecularDynamicsAction.def \ 254 Actions/FragmentationAction/ParseFragmentJobsAction.def 255 endif248 Actions/FragmentationAction/ParseFragmentJobsAction.def \ 249 Actions/FragmentationAction/StoreSaturatedFragmentAction.def 256 250 257 251 GRAPHACTIONSOURCE = \ -
src/Actions/PotentialAction/FitParticleChargesAction.cpp
rc73e35 rd8821e 47 47 #include <boost/foreach.hpp> 48 48 #include <algorithm> 49 #include <functional> 49 50 #include <iostream> 50 51 #include <string> … … 128 129 return Action::failure; 129 130 } 131 132 // average partial charges over all fragments 130 133 HomologyContainer::const_iterator iter = range.first; 131 134 if (!iter->second.containsGrids) { … … 133 136 return Action::failure; 134 137 } 135 const Fragment &fragment = iter->second.fragment; 136 // const double &energy = iter->second.energy; 137 // const SamplingGrid &charge = iter->second.charge_distribution; 138 const SamplingGrid &potential = iter->second.potential_distribution; 139 140 // then we extract positions from fragment 141 PartialNucleiChargeFitter::positions_t positions; 142 Fragment::positions_t fragmentpositions = fragment.getPositions(); 143 positions.reserve(fragmentpositions.size()); 144 BOOST_FOREACH( Fragment::position_t pos, fragmentpositions) { 145 positions.push_back( Vector(pos[0], pos[1], pos[2]) ); 146 } 147 PartialNucleiChargeFitter fitter(potential, positions, params.radius.get()); 148 fitter(); 149 PartialNucleiChargeFitter::charges_t return_charges = fitter.getSolutionAsCharges_t(); 138 PartialNucleiChargeFitter::charges_t averaged_charges; 139 averaged_charges.resize(iter->second.fragment.getCharges().size(), 0.); 140 size_t NoFragments = 0; 141 for (; 142 iter != range.second; ++iter, ++NoFragments) { 143 if (!iter->second.containsGrids) { 144 ELOG(2, "This HomologyGraph does not contain sampled grids,\ndid you forget to add '--store-grids 1' to AnalyseFragmentResults."); 145 return Action::failure; 146 } 147 const Fragment &fragment = iter->second.fragment; 148 // const double &energy = iter->second.energy; 149 // const SamplingGrid &charge = iter->second.charge_distribution; 150 const SamplingGrid &potential = iter->second.potential_distribution; 151 if ((potential.level == 0) 152 || ((potential.begin[0] == potential.end[0]) 153 && (potential.begin[1] == potential.end[1]) 154 && (potential.begin[2] == potential.end[2]))) { 155 ELOG(1, "Sampled grid contains grid made of zero points."); 156 return Action::failure; 157 } 158 159 // then we extract positions from fragment 160 PartialNucleiChargeFitter::positions_t positions; 161 Fragment::positions_t fragmentpositions = fragment.getPositions(); 162 positions.reserve(fragmentpositions.size()); 163 BOOST_FOREACH( Fragment::position_t pos, fragmentpositions) { 164 positions.push_back( Vector(pos[0], pos[1], pos[2]) ); 165 } 166 PartialNucleiChargeFitter fitter(potential, positions, params.radius.get()); 167 fitter(); 168 PartialNucleiChargeFitter::charges_t return_charges = fitter.getSolutionAsCharges_t(); 169 std::transform( 170 return_charges.begin(), return_charges.end(), 171 averaged_charges.begin(), 172 averaged_charges.begin(), 173 std::plus<PartialNucleiChargeFitter::charge_t>()); 174 } 175 std::transform(averaged_charges.begin(),averaged_charges.end(), 176 averaged_charges.begin(), 177 std::bind1st(std::multiplies<PartialNucleiChargeFitter::charge_t>(),1./NoFragments) 178 ); 179 150 180 151 181 // output fitted charges 152 LOG(0, "STATUS: We have fitted the following charges " << return_charges << "."); 182 LOG(0, "STATUS: We have fitted the following charges " << averaged_charges 183 << ", averaged over " << NoFragments << " fragments."); 153 184 154 185 return Action::success; -
src/Actions/PotentialAction/FitPotentialAction.cpp
rc73e35 rd8821e 113 113 } 114 114 115 SerializablePotential::ParticleTypes_t getNumbersFromElements( 116 const std::vector<const element *> &fragment) 117 { 118 SerializablePotential::ParticleTypes_t fragmentnumbers; 119 std::transform(fragment.begin(), fragment.end(), std::back_inserter(fragmentnumbers), 120 boost::bind(&element::getAtomicNumber, _1)); 121 return fragmentnumbers; 122 } 123 124 115 125 ActionState::ptr PotentialFitPotentialAction::performCall() { 116 126 // fragment specifies the homology fragment to use 117 SerializablePotential::ParticleTypes_t fragmentnumbers; 118 { 119 const std::vector<const element *> &fragment = params.fragment.get(); 120 std::transform(fragment.begin(), fragment.end(), std::back_inserter(fragmentnumbers), 121 boost::bind(&element::getAtomicNumber, _1)); 122 } 127 SerializablePotential::ParticleTypes_t fragmentnumbers = 128 getNumbersFromElements(params.fragment.get()); 123 129 124 130 // either charges and a potential is specified or a file … … 158 164 } else { 159 165 // charges specify the potential type 160 SerializablePotential::ParticleTypes_t chargenumbers; 161 { 162 const std::vector<const element *> &charges = params.charges.get(); 163 std::transform(charges.begin(), charges.end(), std::back_inserter(chargenumbers), 164 boost::bind(&element::getAtomicNumber, _1)); 165 } 166 SerializablePotential::ParticleTypes_t chargenumbers = 167 getNumbersFromElements(params.charges.get()); 166 168 167 169 LOG(0, "STATUS: I'm training now a " << params.potentialtype.get() … … 240 242 size_t counter=1; 241 243 if (DoLog(3)) { 242 const FunctionModel::arguments_t &inputs = data.get TrainingInputs()[0];244 const FunctionModel::arguments_t &inputs = data.getAllArguments()[0]; 243 245 for (FunctionModel::arguments_t::const_iterator iter = inputs.begin(); 244 246 iter != inputs.end(); ++iter) { … … 265 267 } 266 268 269 if ((params.threshold.get() < 1) && (params.best_of_howmany.isSet())) 270 ELOG(2, "threshold parameter always overrules max_runs, both are specified."); 267 271 // now perform the function approximation by optimizing the model function 268 272 FunctionApproximation approximator(data, *model); … … 304 308 305 309 // create a map of each fragment with error. 306 typedef std::multimap< double, size_t > WorseFragmentMap_t;307 WorseFragmentMap_t WorseFragmentMap;308 310 HomologyContainer::range_t fragmentrange = homologies.getHomologousGraphs(graph); 309 // fragments make it into the container in reversed order, hence count from top down 310 size_t index= std::distance(fragmentrange.first, fragmentrange.second)-1; 311 for (HomologyContainer::const_iterator iter = fragmentrange.first; 312 iter != fragmentrange.second; 313 ++iter) { 314 const Fragment& fragment = iter->second.fragment; 315 const double &energy = iter->second.energy; 316 317 // create arguments from the fragment 318 FunctionModel::extractor_t extractor = model->getSpecificExtractor(); 319 FunctionModel::arguments_t args = extractor(fragment, 1); 320 321 // calculate value from potential 322 const double fitvalue = (*model)(args)[0]; 323 324 // insert difference into map 325 const double error = fabs(energy - fitvalue); 326 WorseFragmentMap.insert( std::make_pair( error, index-- ) ); 327 328 { 329 // give only the distances in the debugging text 330 std::stringstream streamargs; 331 BOOST_FOREACH (argument_t arg, args) { 332 streamargs << " " << arg.distance*AtomicLengthToAngstroem; 333 } 334 LOG(2, "DEBUG: frag.#" << index+1 << "'s error is |" << energy << " - " << fitvalue 335 << "| = " << error << " for args " << streamargs.str() << "."); 336 } 337 } 311 TrainingData::L2ErrorConfigurationIndexMap_t WorseFragmentMap = 312 data.getWorstFragmentMap(*model, fragmentrange); 338 313 LOG(0, "RESULT: WorstFragmentMap " << WorseFragmentMap << "."); 339 314 -
src/Element/Makefile.am
rc73e35 rd8821e 4 4 ELEMENTSOURCE = \ 5 5 Element/element.cpp \ 6 Element/ion.cpp \ 6 7 Element/periodentafel.cpp \ 7 8 Element/elements_db.cpp … … 9 10 ELEMENTHEADER = \ 10 11 Element/element.hpp \ 12 Element/ion.hpp \ 11 13 Element/periodentafel.hpp \ 12 14 Element/elements_db.hpp -
src/Element/element.hpp
rc73e35 rd8821e 25 25 26 26 class periodentafel; 27 class IonTest; 27 28 28 29 /********************************************** declarations *******************************/ … … 33 34 class element { 34 35 friend class periodentafel; 36 friend class IonTest; 35 37 public: 36 38 element(); 37 39 element(const element&); 38 ~element();40 virtual ~element(); 39 41 40 42 element &operator=(const element&); … … 47 49 double getVanDerWaalsRadius() const; 48 50 atomicNumber_t getAtomicNumber() const; 49 double getValence() const; 50 int getNoValenceOrbitals() const; 51 virtual double getCharge() const 52 { return 0.; } 53 virtual double getValence() const; 54 virtual int getNoValenceOrbitals() const; 51 55 double getHBondDistance(const size_t i) const; 52 56 double getHBondAngle(const size_t i) const; … … 87 91 } 88 92 93 protected: 94 89 95 double mass; //!< mass in g/mol 90 96 double CovalentRadius; //!< covalent radius -
src/Element/periodentafel.cpp
rc73e35 rd8821e 45 45 #include "elements_db.hpp" 46 46 #include "Helpers/defs.hpp" 47 #include "ion.hpp" 47 48 #include "periodentafel.hpp" 48 49 … … 120 121 return res!=elements.end()?((*res).second):0; 121 122 }; 123 124 /** Returns the desired ion to a specific element. 125 * 126 * If the respective element is not in the list, we return 127 * NULL. 128 * \return pointer to an element or NULL if not found 129 */ 130 const element * periodentafel::FindElement(atomicNumber_t Z, const int ionization) 131 { 132 // if not ionization given, fall back to other function 133 if (ionization == 0) { 134 return FindElement(Z); 135 } 136 // element present? 137 const_iterator elementiter = elements.find(Z); 138 if (elementiter == elements.end()) 139 return NULL; 140 const element & element_base = *(elementiter->second); 141 142 // element has already got ions? 143 IonsPerElement::iterator setiter = 144 ions.find(Z); 145 if (setiter != ions.end()) { 146 // yes, found ion list 147 ionSet::const_iterator res = setiter->second.find(ionization); 148 149 if (res != setiter->second.end()) { 150 // ion present already 151 element * const _ion = res->second; 152 return _ion; 153 } else { 154 // ion not present yet 155 ion * const _ion = new ion(element_base, ionization); 156 // insert ion 157 setiter->second.insert( std::make_pair( ionization, _ion) ); 158 return _ion; 159 } 160 } else { 161 // no ions yet, create map 162 ion * const _ion = new ion(element_base, ionization); 163 std::pair<IonsPerElement::iterator,bool> inserter = 164 ions.insert( std::make_pair(Z, ionSet()) ); 165 // insert ion 166 ASSERT( inserter.second, 167 "periodentafel::FindElement() - could not insert new ionSet to element."); 168 inserter.first->second.insert( std::make_pair( ionization, _ion) ); 169 return _ion; 170 } 171 return NULL; 172 } 122 173 123 174 /** Finds an element by its atomic number. -
src/Element/periodentafel.hpp
rc73e35 rd8821e 22 22 23 23 class element; 24 class ion; 24 25 25 26 /********************************************** declarations *******************************/ … … 33 34 private: 34 35 typedef std::map<atomicNumber_t,element*> elementSet; 36 typedef std::map<int,ion*> ionSet; 37 typedef std::map<atomicNumber_t,ionSet> IonsPerElement; 35 38 public: 36 39 typedef elementSet::iterator iterator; … … 48 51 void CleanupPeriodtable(); 49 52 const element * FindElement(atomicNumber_t) const; 53 const element * FindElement(atomicNumber_t, const int); 50 54 const element * FindElement(const std::string &shorthand) const; 51 55 const element * AskElement() const; … … 76 80 ar & boost::serialization::make_array<char>(header2, MAXSTRINGSIZE); 77 81 ar & elements; 82 ar & ions; 78 83 } 79 84 … … 93 98 94 99 elementSet elements; 100 IonsPerElement ions; 95 101 }; 96 102 -
src/Element/unittests/ElementUnitTest.cpp
rc73e35 rd8821e 105 105 CPPUNIT_ASSERT_EQUAL( 0., testelement->getElectronegativity() ); 106 106 CPPUNIT_ASSERT_EQUAL( 0., testelement->getVanDerWaalsRadius() ); 107 CPPUNIT_ASSERT_EQUAL( 0., testelement->getCharge() ); 107 108 CPPUNIT_ASSERT_EQUAL( 0., testelement->getValence() ); 108 109 CPPUNIT_ASSERT_EQUAL( 0, testelement->getNoValenceOrbitals() ); … … 172 173 boost::archive::text_iarchive ia(stream); 173 174 // read class state from archive 174 element * newelement ;175 element * newelement = NULL; 175 176 176 177 ia >> newelement; -
src/Element/unittests/Makefile.am
rc73e35 rd8821e 4 4 ELEMENTTESTSSOURCES = \ 5 5 ../Element/unittests/ElementUnitTest.cpp \ 6 ../Element/unittests/PeriodentafelUnitTest.cpp 6 ../Element/unittests/IonUnitTest.cpp \ 7 ../Element/unittests/PeriodentafelUnitTest.cpp 7 8 8 9 ELEMENTTESTSHEADERS = \ 9 ../Element/unittests/ElementUnitTest.hpp \ 10 ../Element/unittests/PeriodentafelUnitTest.hpp 10 ../Element/unittests/ElementUnitTest.hpp \ 11 ../Element/unittests/IonUnitTest.hpp \ 12 ../Element/unittests/PeriodentafelUnitTest.hpp 11 13 12 14 ELEMENTTESTS = \ 13 15 ElementUnitTest \ 16 IonUnitTest \ 14 17 PeriodentafelUnitTest 15 18 … … 24 27 ${CodePatterns_LIBS} 25 28 26 ElementUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \27 28 29 ElementUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 30 ../Element/unittests/ElementUnitTest.cpp \ 31 ../Element/unittests/ElementUnitTest.hpp 29 32 ElementUnitTest_LDADD = $(ELEMENTLIBS) 33 34 IonUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 35 ../Element/unittests/IonUnitTest.cpp \ 36 ../Element/unittests/IonUnitTest.hpp 37 IonUnitTest_LDADD = $(ELEMENTLIBS) 30 38 31 39 PeriodentafelUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ -
src/Element/unittests/PeriodentafelUnitTest.cpp
rc73e35 rd8821e 45 45 46 46 #include "Element/element.hpp" 47 #include "Element/ion.hpp" 47 48 #include "Element/elements_db.hpp" 48 49 #include "Element/periodentafel.hpp" -
src/Fragmentation/Automation/MPQCFragmentController.cpp
rc73e35 rd8821e 57 57 ) 58 58 { 59 bool status = true; 59 60 // give them all valid ids 60 61 std::vector<FragmentJob::ptr> newjobs = FragmentJobQueue::getInstance().getJobs(); … … 65 66 job->DoLongrange = _DoLongrange; 66 67 job->DoValenceOnly = _DoValenceOnly; 67 changeJobId((*jobiter), getAvailableId()); 68 JobId_t id = getAvailableId(); 69 if (id == FragmentJob::IllegalJob) { 70 status = false; 71 break; 72 } 73 changeJobId((*jobiter), id); 68 74 } 69 75 // add the jobs 70 76 addJobs(newjobs); 77 status &= (newjobs.size() != 0); 71 78 72 return (newjobs.size() != 0);79 return status; 73 80 } 74 81 -
src/Fragmentation/Automation/MPQCFragmentController.hpp
rc73e35 rd8821e 70 70 private: 71 71 //!> type-specific result container 72 SpecificFragmentController::Re sultContainer<MPQCData> results;72 SpecificFragmentController::ReceiveResultContainer<MPQCData> results; 73 73 }; 74 74 -
src/Fragmentation/Automation/Makefile.am
rc73e35 rd8821e 4 4 FRAGMENTATIONAUTOMATIONSOURCE = \ 5 5 Fragmentation/Automation/FragmentJobQueue.cpp \ 6 Fragmentation/Automation/MPQCCommandFragmentController.cpp 7 8 if CONDJOBMARKET 9 FRAGMENTATIONAUTOMATIONSOURCE += \ 6 10 Fragmentation/Automation/MPQCFragmentController.cpp \ 7 11 Fragmentation/Automation/SpecificFragmentController.cpp … … 13 17 endif 14 18 19 endif 20 15 21 FRAGMENTATIONAUTOMATIONHEADER = \ 16 22 Fragmentation/Automation/FragmentJobQueue.hpp \ 23 Fragmentation/Automation/MPQCCommandFragmentController.hpp \ 24 Fragmentation/Automation/ResultContainer.hpp \ 25 Fragmentation/Automation/ResultContainer_impl.hpp 26 27 if CONDJOBMARKET 28 FRAGMENTATIONAUTOMATIONHEADER += \ 17 29 Fragmentation/Automation/MPQCFragmentController.hpp \ 18 30 Fragmentation/Automation/SpecificFragmentController.hpp \ 19 Fragmentation/Automation/SpecificFragmentController_Re sultContainer_impl.hpp31 Fragmentation/Automation/SpecificFragmentController_ReceiveResultContainer_impl.hpp 20 32 21 33 if CONDVMG … … 23 35 Fragmentation/Automation/VMGDebugGridFragmentController.hpp \ 24 36 Fragmentation/Automation/VMGFragmentController.hpp 37 endif 25 38 endif 26 39 -
src/Fragmentation/Automation/SpecificFragmentController.hpp
rc73e35 rd8821e 23 23 #include <string> 24 24 #include <vector> 25 26 #include "Fragmentation/Automation/ResultContainer.hpp" 25 27 26 28 /** This class extends FragmentController by some commodity functions used … … 58 60 * This struct takes of the waiting. 59 61 * 62 * We extend ResultContainer by functions to receive results from a 63 * JobMarket server. 64 * 60 65 */ 61 66 template <typename T> 62 struct Re sultContainer{67 struct ReceiveResultContainer : public ResultContainer<T> { 63 68 /** cycle to wait for results 64 69 * … … 78 83 */ 79 84 size_t receiveResults(SpecificFragmentController &callback); 80 81 /** Extracts specific Data type from received vector of FragmentResults.82 *83 * @param results results to extract specific Data type from84 * @param fragmentData on return array filled with extracted specific Data type85 */86 void ConvertFragmentResultTo(87 const std::vector<FragmentResult::ptr> &results,88 std::vector<T> &fragmentData);89 90 /** Clears all internally stored results.91 *92 */93 void clear()94 { IdData.clear(); }95 96 //!> internal container for the received data97 std::map<JobId_t, T> IdData;98 85 }; 99 86 … … 109 96 }; 110 97 111 #include "SpecificFragmentController_Re sultContainer_impl.hpp"98 #include "SpecificFragmentController_ReceiveResultContainer_impl.hpp" 112 99 113 100 #endif /* SPECIFICFRAGMENTCONTROLLER_HPP_ */ -
src/Fragmentation/Automation/VMGDebugGridFragmentController.hpp
rc73e35 rd8821e 55 55 private: 56 56 //!> type-specific result container 57 SpecificFragmentController::Re sultContainer<std::string> results;57 SpecificFragmentController::ReceiveResultContainer<std::string> results; 58 58 }; 59 59 -
src/Fragmentation/Automation/VMGFragmentController.hpp
rc73e35 rd8821e 89 89 private: 90 90 //!> type-specific result container 91 SpecificFragmentController::Re sultContainer<VMGData> results;91 SpecificFragmentController::ReceiveResultContainer<VMGData> results; 92 92 }; 93 93 -
src/Fragmentation/Exporters/ExportGraph_ToJobs.cpp
rc73e35 rd8821e 46 46 #include "Fragmentation/KeySet.hpp" 47 47 #include "Fragmentation/Automation/FragmentJobQueue.hpp" 48 #include "Fragmentation/Automation/MPQCFragmentController.hpp"49 48 #include "Helpers/defs.hpp" 49 #ifdef HAVE_JOBMARKET 50 50 #include "Jobs/MPQCJob.hpp" 51 #else 52 #include "Jobs/MPQCCommandJob.hpp" 53 #endif 51 54 #include "LinearAlgebra/RealSpaceMatrix.hpp" 52 55 #include "Parser/FormatParserStorage.hpp" … … 93 96 CurrentFragment->OutputConfig(output, jobtype); 94 97 // create job and insert 95 FragmentJob::ptr testJob( new MPQCJob(JobId::IllegalJob, output.str(), begin, end, level) ); 98 FragmentJob::ptr testJob( 99 #ifdef HAVE_JOBMARKET 100 new MPQCJob(JobId::IllegalJob, output.str(), begin, end, level) 101 #else 102 new MPQCCommandJob(output.str(), JobId::IllegalJob) 103 #endif 104 ); 96 105 testJob->setPriority(CurrentFragment->getKeySet().size()); 97 106 jobs.push_back(testJob); -
src/Fragmentation/Makefile.am
rc73e35 rd8821e 4 4 FRAGMENTATIONSOURCE = \ 5 5 Fragmentation/Exporters/ExportGraph_ToFiles.cpp \ 6 Fragmentation/Exporters/ExportGraph_ToJobs.cpp \ 6 7 Fragmentation/Exporters/ExportGraph.cpp \ 7 8 Fragmentation/Exporters/HydrogenPool.cpp \ … … 29 30 FRAGMENTATIONHEADER = \ 30 31 Fragmentation/Exporters/ExportGraph_ToFiles.hpp \ 32 Fragmentation/Exporters/ExportGraph_ToJobs.hpp \ 31 33 Fragmentation/Exporters/ExportGraph.hpp \ 32 34 Fragmentation/Exporters/HydrogenPool.hpp \ … … 57 59 Fragmentation/SortIndex.hpp \ 58 60 Fragmentation/UniqueFragments.hpp 59 60 if CONDJOBMARKET61 FRAGMENTATIONSOURCE += \62 Fragmentation/Exporters/ExportGraph_ToJobs.cpp63 FRAGMENTATIONHEADER += \64 Fragmentation/Exporters/ExportGraph_ToJobs.hpp65 endif66 61 67 62 lib_LTLIBRARIES += \ -
src/Fragmentation/Summation/Containers/FragmentationResultContainer.cpp
rc73e35 rd8821e 41 41 #include "CodePatterns/Singleton_impl.hpp" 42 42 43 #if def HAVE_VMG43 #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) 44 44 void FragmentationResultContainer::addFullResults( 45 45 const KeySetsContainer &_keysets, … … 51 51 OBSERVE; 52 52 ASSERT( ResultsType == BothRanges, 53 "FragmentationResultContainer:: getLongRangeResults() - mixing full and short range is not in the cards.");53 "FragmentationResultContainer::addFullResults() - mixing full and short range is not in the cards."); 54 54 ASSERT( _keysets.KeySets.size() == _forcekeysets.KeySets.size(), 55 55 "FragmentationResultContainer::addFullResults() - keysets (" … … 80 80 OBSERVE; 81 81 ASSERT( (ResultsType == ShortRangeOnly) || (keysets.KeySets.empty()) , 82 "FragmentationResultContainer:: getLongRangeResults() - mixing full and short range is not in the cards.");82 "FragmentationResultContainer::addFullResults() - mixing full and short range is not in the cards."); 83 83 ASSERT( _keysets.KeySets.size() == _forcekeysets.KeySets.size(), 84 84 "FragmentationResultContainer::addFullResults() - keysets (" … … 104 104 } 105 105 106 #if def HAVE_VMG106 #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) 107 107 const FragmentationResultContainer::longrangedata_t& 108 108 FragmentationResultContainer::getLongRangeResults() const -
src/Fragmentation/Summation/Containers/FragmentationResultContainer.hpp
rc73e35 rd8821e 36 36 #include "Fragmentation/Summation/Containers/MPQCData.hpp" 37 37 #include "Fragmentation/Summation/Containers/MPQCDataMap.hpp" 38 #if def HAVE_VMG38 #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) 39 39 #include "Fragmentation/Summation/Containers/VMGData.hpp" 40 40 #endif … … 63 63 //!> typedef for short range data container 64 64 typedef std::map<JobId_t, MPQCData> shortrangedata_t; 65 #if def HAVE_VMG65 #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) 66 66 //!> typedef for long range data container 67 67 typedef std::map<JobId_t, VMGData> longrangedata_t; 68 68 #endif 69 69 70 #if def HAVE_VMG70 #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) 71 71 /** Adds a a set of both short and long range results. 72 72 * … … 128 128 shortrangedata.clear(); 129 129 summedshortrange.clear(); 130 #if def HAVE_VMG130 #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) 131 131 longrangedata.clear(); 132 132 #endif … … 139 139 const shortrangedata_t& getShortRangeResults() const { return shortrangedata; } 140 140 const FragmentationShortRangeResults::summedshortrange_t& getShortRangeSummedResults() const { return summedshortrange; } 141 #if def HAVE_VMG141 #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) 142 142 const longrangedata_t& getLongRangeResults() const; 143 143 #endif … … 162 162 FragmentationShortRangeResults::summedshortrange_t summedshortrange; 163 163 164 #if def HAVE_VMG164 #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) 165 165 //!> container for all long-range results 166 166 std::map<JobId_t, VMGData> longrangedata; … … 181 181 if (version > 1) 182 182 ar & summedshortrange; 183 #if def HAVE_VMG183 #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) 184 184 ar & longrangedata; 185 185 #endif … … 196 196 if (version > 1) 197 197 ar & summedshortrange; 198 #if def HAVE_VMG198 #if defined(HAVE_JOBMARKET) && defined(HAVE_VMG) 199 199 ar & longrangedata; 200 200 #endif -
src/Fragmentation/Summation/Containers/Makefile.am
rc73e35 rd8821e 5 5 Fragmentation/Summation/Containers/createMatrixNrLookup.cpp \ 6 6 Fragmentation/Summation/Containers/FragmentationChargeDensity.cpp \ 7 Fragmentation/Summation/Containers/FragmentationLongRangeResults.cpp \8 7 Fragmentation/Summation/Containers/FragmentationResultContainer.cpp \ 9 8 Fragmentation/Summation/Containers/FragmentationShortRangeResults.cpp \ 10 9 Fragmentation/Summation/Containers/MPQCData.cpp 11 10 11 if CONDJOBMARKET 12 12 if CONDVMG 13 13 FRAGMENTATIONCONTAINERSOURCE += \ 14 Fragmentation/Summation/Containers/FragmentationLongRangeResults.cpp \ 14 15 Fragmentation/Summation/Containers/VMGData.cpp 16 endif 15 17 endif 16 18 … … 19 21 Fragmentation/Summation/Containers/extractJobIds.hpp \ 20 22 Fragmentation/Summation/Containers/FragmentationChargeDensity.hpp \ 21 Fragmentation/Summation/Containers/FragmentationLongRangeResults.hpp \22 23 Fragmentation/Summation/Containers/FragmentationResultContainer.hpp \ 23 24 Fragmentation/Summation/Containers/FragmentationShortRangeResults.hpp \ … … 26 27 Fragmentation/Summation/Containers/MPQCDataMap.hpp \ 27 28 Fragmentation/Summation/Containers/MPQCData_printKeyNames.hpp 28 29 30 if CONDJOBMARKET 29 31 if CONDVMG 30 32 FRAGMENTATIONCONTAINERHEADER += \ 33 Fragmentation/Summation/Containers/FragmentationLongRangeResults.hpp \ 31 34 Fragmentation/Summation/Containers/VMGData.hpp \ 32 35 Fragmentation/Summation/Containers/VMGDataFused.hpp \ 33 36 Fragmentation/Summation/Containers/VMGDataMap.hpp \ 34 37 Fragmentation/Summation/Containers/VMGData_printKeyNames.hpp 38 endif 35 39 endif 36 40 -
src/FunctionApproximation/Extractors.cpp
rc73e35 rd8821e 532 532 } 533 533 534 FunctionModel::arguments_t Extractors::reorderArgumentsByIncreasingDistance( 535 const FunctionModel::arguments_t &args 536 ) 537 { 538 FunctionModel::arguments_t returnargs(args); 539 std::sort(returnargs.begin(), returnargs.end(), argument_t::DistanceComparator); 534 FunctionModel::list_of_arguments_t Extractors::reorderArgumentsByIncreasingDistance( 535 const FunctionModel::list_of_arguments_t &listargs 536 ) 537 { 538 FunctionModel::list_of_arguments_t returnargs; 539 for (FunctionModel::list_of_arguments_t::const_iterator iter = listargs.begin(); 540 iter != listargs.end(); ++iter) { 541 const FunctionModel::arguments_t &args = *iter; 542 FunctionModel::arguments_t sortedargs(args); 543 std::sort(sortedargs.begin(), sortedargs.end(), argument_t::DistanceComparator); 544 returnargs.push_back(sortedargs); 545 } 540 546 return returnargs; 541 547 } … … 587 593 } 588 594 589 FunctionModel::arguments_t Extractors::reorderArgumentsByParticleTypes( 595 FunctionModel::list_of_arguments_t Extractors::reorderArgumentsByParticleTypes( 596 const FunctionModel::list_of_arguments_t &listargs, 597 const ParticleTypes_t &_types 598 ) 599 { 600 FunctionModel::list_of_arguments_t returnargs; 601 for (FunctionModel::list_of_arguments_t::const_iterator iter = listargs.begin(); 602 iter != listargs.end(); ++iter) { 603 const FunctionModel::arguments_t &args = *iter; 604 /// We place all arguments into multimap according to particle type pair. 605 // here, we need a special comparator such that types in key pair are always 606 // properly ordered. 607 typedef std::multimap< 608 argument_t::types_t, 609 argument_t, 610 ParticleTypesComparator> TypePair_Argument_Map_t; 611 TypePair_Argument_Map_t argument_map; 612 for(FunctionModel::arguments_t::const_iterator iter = args.begin(); 613 iter != args.end(); ++iter) { 614 argument_map.insert( std::make_pair(iter->types, *iter) ); 615 } 616 LOG(4, "DEBUG: particle_type map is " << argument_map << "."); 617 618 /// Then, we create the desired unique keys 619 typedef std::vector<argument_t::types_t> UniqueTypes_t; 620 UniqueTypes_t UniqueTypes; 621 for (ParticleTypes_t::const_iterator firstiter = _types.begin(); 622 firstiter != _types.end(); 623 ++firstiter) { 624 for (ParticleTypes_t::const_iterator seconditer = firstiter; 625 seconditer != _types.end(); 626 ++seconditer) { 627 if (seconditer == firstiter) 628 continue; 629 UniqueTypes.push_back( std::make_pair(*firstiter, *seconditer) ); 630 } 631 } 632 LOG(4, "DEBUG: Created unique types as keys " << UniqueTypes << "."); 633 634 /// Finally, we use the unique key list to pick corresponding arguments from the map 635 FunctionModel::arguments_t sortedargs; 636 sortedargs.reserve(args.size()); 637 while (!argument_map.empty()) { 638 // note that particle_types_t may be flipped, i.e. 1,8 is equal to 8,1, but we 639 // must maintain the correct order in indices in accordance with the order 640 // in _types, i.e. 1,8,1 must match with e.g. ids 1,0,2 where 1 has type 1, 641 // 0 has type 8, and 2 has type 2. 642 // In other words: We do not want to flip/modify arguments such that they match 643 // with the specific type pair we seek but then this comes at the price that we 644 // have flip indices when the types in a pair are flipped. 645 646 typedef std::vector<size_t> indices_t; 647 //!> here, we gather the indices as we discover them 648 indices_t indices; 649 indices.resize(_types.size(), (size_t)-1); 650 651 // these are two iterators that create index pairs in the same way as we have 652 // created type pairs. If a -1 is still present in indices, then the index is 653 // still arbitrary but is then set by the next found index 654 indices_t::iterator firstindex = indices.begin(); 655 indices_t::iterator secondindex = firstindex+1; 656 657 //!> here, we gather the current bunch of arguments as we find them 658 FunctionModel::arguments_t argumentbunch; 659 argumentbunch.reserve(UniqueTypes.size()); 660 661 for (UniqueTypes_t::const_iterator typeiter = UniqueTypes.begin(); 662 typeiter != UniqueTypes.end(); ++typeiter) { 663 // have all arguments to same type pair as list within the found range 664 std::pair< 665 TypePair_Argument_Map_t::iterator, 666 TypePair_Argument_Map_t::iterator> range_t = 667 argument_map.equal_range(*typeiter); 668 LOG(4, "DEBUG: Set of arguments to current key [" << typeiter->first << "," 669 << typeiter->second << "] is " << std::list<argument_t>( 670 MapValueIterator<TypePair_Argument_Map_t::iterator>(range_t.first), 671 MapValueIterator<TypePair_Argument_Map_t::iterator>(range_t.second) 672 ) << "."); 673 // the first key is always easy and is pivot which the rest has to be associated to 674 if (typeiter == UniqueTypes.begin()) { 675 const argument_t & arg = range_t.first->second; 676 if ((typeiter->first == arg.types.first) && (typeiter->second == arg.types.second)) { 677 // store in correct order 678 *firstindex = arg.indices.first; 679 *secondindex = arg.indices.second; 680 } else { 681 // store in flipped order 682 *firstindex = arg.indices.second; 683 *secondindex = arg.indices.first; 684 } 685 argumentbunch.push_back(arg); 686 argument_map.erase(range_t.first); 687 LOG(4, "DEBUG: Gathered first argument " << arg << "."); 688 } else { 689 // go through the range and pick the first argument matching the index constraints 690 for (TypePair_Argument_Map_t::iterator argiter = range_t.first; 691 argiter != range_t.second; ++argiter) { 692 // seconditer may be -1 still 693 const argument_t &arg = argiter->second; 694 if (arg.indices.first == *firstindex) { 695 if ((arg.indices.second == *secondindex) || (*secondindex == (size_t)-1)) { 696 if (*secondindex == (size_t)-1) 697 *secondindex = arg.indices.second; 698 argumentbunch.push_back(arg); 699 argument_map.erase(argiter); 700 LOG(4, "DEBUG: Gathered another argument " << arg << "."); 701 break; 702 } 703 } else if ((arg.indices.first == *secondindex) || (*secondindex == (size_t)-1)) { 704 if (arg.indices.second == *firstindex) { 705 if (*secondindex == (size_t)-1) 706 *secondindex = arg.indices.first; 707 argumentbunch.push_back(arg); 708 argument_map.erase(argiter); 709 LOG(4, "DEBUG: Gathered another (flipped) argument " << arg << "."); 710 break; 711 } 712 } 713 } 714 } 715 // move along in indices and check bounds 716 ++secondindex; 717 if (secondindex == indices.end()) { 718 ++firstindex; 719 if (firstindex != indices.end()-1) 720 secondindex = firstindex+1; 721 } 722 } 723 ASSERT( (firstindex == indices.end()-1) && (secondindex == indices.end()), 724 "Extractors::reorderArgumentsByParticleTypes() - we have not gathered enough arguments."); 725 ASSERT( argumentbunch.size() == UniqueTypes.size(), 726 "Extractors::reorderArgumentsByParticleTypes() - we have not gathered enough arguments."); 727 // place bunch of arguments in return args 728 LOG(3, "DEBUG: Given types " << _types << " and found indices " << indices << "."); 729 LOG(3, "DEBUG: Final bunch of arguments is " << argumentbunch << "."); 730 sortedargs.insert(sortedargs.end(), argumentbunch.begin(), argumentbunch.end()); 731 } 732 returnargs.push_back(sortedargs); 733 } 734 735 return returnargs; 736 } 737 738 FunctionModel::list_of_arguments_t Extractors::filterArgumentsByParticleTypes( 590 739 const FunctionModel::arguments_t &args, 591 740 const ParticleTypes_t &_types 592 741 ) 593 742 { 594 /// We place all arguments into multimap according to particle type pair. 595 // here, we need a special comparator such that types in key pair are always 596 // properly ordered. 597 typedef std::multimap< 598 argument_t::types_t, 599 argument_t, 600 ParticleTypesComparator> TypePair_Argument_Map_t; 601 TypePair_Argument_Map_t argument_map; 602 for(FunctionModel::arguments_t::const_iterator iter = args.begin(); 603 iter != args.end(); ++iter) { 604 argument_map.insert( std::make_pair(iter->types, *iter) ); 605 } 606 LOG(4, "DEBUG: particle_type map is " << argument_map << "."); 607 608 /// Then, we create the desired unique keys 609 typedef std::vector<argument_t::types_t> UniqueTypes_t; 610 UniqueTypes_t UniqueTypes; 743 typedef std::list< argument_t > ListArguments_t; 744 ListArguments_t availableList(args.begin(), args.end()); 745 LOG(2, "DEBUG: Initial list of args is " << args << "."); 746 747 748 // TODO: fill a lookup map such that we don't have O(M^3) scaling, if M is number 749 // of types (and we always must have M(M-1)/2 args) but O(M^2 log(M)). However, as 750 // M is very small (<=3), this is not necessary fruitful now. 751 // typedef ParticleTypes_t firsttype; 752 // typedef ParticleTypes_t secondtype; 753 // typedef std::map< firsttype, std::map< secondtype, boost::ref(args) > > ArgsLookup_t; 754 // ArgsLookup_t ArgsLookup; 755 756 // basically, we have two choose any two pairs out of types but only those 757 // where the first is less than the latter. Hence, we start the second 758 // iterator at the current position of the first one and skip the equal case. 759 FunctionModel::arguments_t allargs; 760 allargs.reserve(args.size()); 611 761 for (ParticleTypes_t::const_iterator firstiter = _types.begin(); 612 762 firstiter != _types.end(); … … 617 767 if (seconditer == firstiter) 618 768 continue; 619 UniqueTypes.push_back( std::make_pair(*firstiter, *seconditer) ); 620 } 621 } 622 LOG(4, "DEBUG: Created unique types as keys " << UniqueTypes << "."); 623 624 /// Finally, we use the unique key list to pick corresponding arguments from the map 625 FunctionModel::arguments_t returnargs; 626 returnargs.reserve(args.size()); 627 while (!argument_map.empty()) { 628 // note that particle_types_t may be flipped, i.e. 1,8 is equal to 8,1, but we 629 // must maintain the correct order in indices in accordance with the order 630 // in _types, i.e. 1,8,1 must match with e.g. ids 1,0,2 where 1 has type 1, 631 // 0 has type 8, and 2 has type 2. 632 // In other words: We do not want to flip/modify arguments such that they match 633 // with the specific type pair we seek but then this comes at the price that we 634 // have flip indices when the types in a pair are flipped. 635 636 typedef std::vector<size_t> indices_t; 637 //!> here, we gather the indices as we discover them 638 indices_t indices; 639 indices.resize(_types.size(), (size_t)-1); 640 641 // these are two iterators that create index pairs in the same way as we have 642 // created type pairs. If a -1 is still present in indices, then the index is 643 // still arbitrary but is then set by the next found index 644 indices_t::iterator firstindex = indices.begin(); 645 indices_t::iterator secondindex = firstindex+1; 646 647 //!> here, we gather the current bunch of arguments as we find them 648 FunctionModel::arguments_t argumentbunch; 649 argumentbunch.reserve(UniqueTypes.size()); 650 651 for (UniqueTypes_t::const_iterator typeiter = UniqueTypes.begin(); 652 typeiter != UniqueTypes.end(); ++typeiter) { 653 // have all arguments to same type pair as list within the found range 654 std::pair< 655 TypePair_Argument_Map_t::iterator, 656 TypePair_Argument_Map_t::iterator> range_t = 657 argument_map.equal_range(*typeiter); 658 LOG(4, "DEBUG: Set of arguments to current key [" << typeiter->first << "," 659 << typeiter->second << "] is " << std::list<argument_t>( 660 MapValueIterator<TypePair_Argument_Map_t::iterator>(range_t.first), 661 MapValueIterator<TypePair_Argument_Map_t::iterator>(range_t.second) 662 ) << "."); 663 // the first key is always easy and is pivot which the rest has to be associated to 664 if (typeiter == UniqueTypes.begin()) { 665 const argument_t & arg = range_t.first->second; 666 if ((typeiter->first == arg.types.first) && (typeiter->second == arg.types.second)) { 667 // store in correct order 668 *firstindex = arg.indices.first; 669 *secondindex = arg.indices.second; 670 } else { 671 // store in flipped order 672 *firstindex = arg.indices.second; 673 *secondindex = arg.indices.first; 674 } 675 argumentbunch.push_back(arg); 676 argument_map.erase(range_t.first); 677 LOG(4, "DEBUG: Gathered first argument " << arg << "."); 678 } else { 679 // go through the range and pick the first argument matching the index constraints 680 for (TypePair_Argument_Map_t::iterator argiter = range_t.first; 681 argiter != range_t.second; ++argiter) { 682 // seconditer may be -1 still 683 const argument_t &arg = argiter->second; 684 if (arg.indices.first == *firstindex) { 685 if ((arg.indices.second == *secondindex) || (*secondindex == (size_t)-1)) { 686 if (*secondindex == (size_t)-1) 687 *secondindex = arg.indices.second; 688 argumentbunch.push_back(arg); 689 argument_map.erase(argiter); 690 LOG(4, "DEBUG: Gathered another argument " << arg << "."); 691 break; 692 } 693 } else if ((arg.indices.first == *secondindex) || (*secondindex == (size_t)-1)) { 694 if (arg.indices.second == *firstindex) { 695 if (*secondindex == (size_t)-1) 696 *secondindex = arg.indices.first; 697 argumentbunch.push_back(arg); 698 argument_map.erase(argiter); 699 LOG(4, "DEBUG: Gathered another (flipped) argument " << arg << "."); 700 break; 701 } 702 } 703 } 704 } 705 // move along in indices and check bounds 706 ++secondindex; 707 if (secondindex == indices.end()) { 708 ++firstindex; 709 if (firstindex != indices.end()-1) 710 secondindex = firstindex+1; 711 } 712 } 713 ASSERT( (firstindex == indices.end()-1) && (secondindex == indices.end()), 714 "Extractors::reorderArgumentsByParticleTypes() - we have not gathered enough arguments."); 715 ASSERT( argumentbunch.size() == UniqueTypes.size(), 716 "Extractors::reorderArgumentsByParticleTypes() - we have not gathered enough arguments."); 717 // place bunch of arguments in return args 718 LOG(3, "DEBUG: Given types " << _types << " and found indices " << indices << "."); 719 LOG(3, "DEBUG: Final bunch of arguments is " << argumentbunch << "."); 720 returnargs.insert(returnargs.end(), argumentbunch.begin(), argumentbunch.end()); 721 } 722 723 return returnargs; 724 } 725 726 FunctionModel::arguments_t Extractors::filterArgumentsByParticleTypes( 727 const FunctionModel::arguments_t &args, 728 const ParticleTypes_t &_types 729 ) 730 { 731 typedef std::list< argument_t > ListArguments_t; 732 ListArguments_t availableList(args.begin(), args.end()); 733 LOG(2, "DEBUG: Initial list of args is " << args << "."); 734 735 736 // TODO: fill a lookup map such that we don't have O(M^3) scaling, if M is number 737 // of types (and we always must have M(M-1)/2 args) but O(M^2 log(M)). However, as 738 // M is very small (<=3), this is not necessary fruitful now. 739 // typedef ParticleTypes_t firsttype; 740 // typedef ParticleTypes_t secondtype; 741 // typedef std::map< firsttype, std::map< secondtype, boost::ref(args) > > ArgsLookup_t; 742 // ArgsLookup_t ArgsLookup; 743 744 // basically, we have two choose any two pairs out of types but only those 745 // where the first is less than the latter. Hence, we start the second 746 // iterator at the current position of the first one and skip the equal case. 747 FunctionModel::arguments_t returnargs; 748 returnargs.reserve(args.size()); 749 for (ParticleTypes_t::const_iterator firstiter = _types.begin(); 750 firstiter != _types.end(); 751 ++firstiter) { 752 for (ParticleTypes_t::const_iterator seconditer = firstiter; 753 seconditer != _types.end(); 754 ++seconditer) { 755 if (seconditer == firstiter) 756 continue; 769 LOG(3, "DEBUG: Looking for (" << *firstiter << "," << *seconditer << ") in all args."); 757 770 758 771 // search the right one in _args (we might allow switching places of … … 760 773 ListArguments_t::iterator iter = availableList.begin(); 761 774 while (iter != availableList.end()) { 762 LOG( 3, "DEBUG: Current args is " << *iter << ".");775 LOG(4, "DEBUG: Current args is " << *iter << "."); 763 776 if ((iter->types.first == *firstiter) 764 777 && (iter->types.second == *seconditer)) { 765 returnargs.push_back( *iter );778 allargs.push_back( *iter ); 766 779 iter = availableList.erase(iter); 767 780 LOG(4, "DEBUG: Accepted argument."); 768 781 } else if ((iter->types.first == *seconditer) 769 782 && (iter->types.second == *firstiter)) { 770 returnargs.push_back( *iter );783 allargs.push_back( *iter ); 771 784 iter = availableList.erase(iter); 772 785 LOG(4, "DEBUG: Accepted (flipped) argument."); … … 778 791 } 779 792 } 780 LOG(2, "DEBUG: Final list of args is " << returnargs << "."); 793 LOG(2, "DEBUG: Final list of args is " << allargs << "."); 794 795 // first, we bring together tuples of distances that belong together 796 FunctionModel::list_of_arguments_t singlelist_allargs; 797 singlelist_allargs.push_back(allargs); 798 FunctionModel::list_of_arguments_t sortedargs = 799 reorderArgumentsByParticleTypes(singlelist_allargs, _types); 800 ASSERT( sortedargs.size() == (size_t)1, 801 "Extractors::filterArgumentsByParticleTypes() - reordering did not generate a single list."); 802 // then we split up the tuples of arguments and place each into single list 803 FunctionModel::list_of_arguments_t returnargs; 804 FunctionModel::arguments_t::const_iterator argiter = sortedargs.begin()->begin(); 805 const size_t num_types = _types.size(); 806 const size_t args_per_tuple = num_types * (num_types-1) / 2; 807 while (argiter != sortedargs.begin()->end()) { 808 FunctionModel::arguments_t currenttuple(args_per_tuple); 809 const FunctionModel::arguments_t::const_iterator startiter = argiter; 810 std::advance(argiter, args_per_tuple); 811 #ifndef NDEBUG 812 FunctionModel::arguments_t::const_iterator endoutiter = 813 #endif 814 std::copy(startiter, argiter, currenttuple.begin()); 815 ASSERT( endoutiter == currenttuple.end(), 816 "Extractors::filterArgumentsByParticleTypes() - currenttuple not initialized to right size."); 817 returnargs.push_back(currenttuple); 818 } 819 820 LOG(2, "DEBUG: We have generated " << returnargs.size() << " tuples of distances."); 781 821 782 822 return returnargs; … … 807 847 } 808 848 849 FunctionModel::list_of_arguments_t Extractors::concatenateListOfArguments( 850 const FunctionModel::list_of_arguments_t &firstlistargs, 851 const FunctionModel::list_of_arguments_t &secondlistargs) 852 { 853 FunctionModel::list_of_arguments_t listargs(firstlistargs); 854 listargs.insert(listargs.end(), secondlistargs.begin(), secondlistargs.end()); 855 return listargs; 856 } -
src/FunctionApproximation/Extractors.hpp
rc73e35 rd8821e 22 22 23 23 /** Namespace containing all simple extractor functions. 24 * 25 * Extractor functions extract distances from a given fragment matching with 26 * a given set of particle types (i.e. elements, e.h. H2O). 27 * Filter functions extract a subset of distances from a given set of distances 28 * to be used with a specific model. 29 * 30 * To this end, each FunctionModel has both a filter and an extractor function. 31 * 32 * The functions in this namespace act as helpers or basic building blocks in 33 * constructing such filters and extractors. 24 34 * 25 35 */ … … 294 304 /** Reorder arguments by increasing distance. 295 305 * 296 * \param args arguments to reorder306 * \param listargs list of arguments to reorder each 297 307 * \return reordered args 298 308 */ 299 FunctionModel:: arguments_t reorderArgumentsByIncreasingDistance(300 const FunctionModel:: arguments_t &args309 FunctionModel::list_of_arguments_t reorderArgumentsByIncreasingDistance( 310 const FunctionModel::list_of_arguments_t &listargs 301 311 ); 302 312 … … 308 318 * \sa filterArgumentsByParticleTypes() 309 319 * 320 * \param listargs list of arguments to reorder each 321 * \param _types particle type vector 322 * \return reordered args 323 */ 324 FunctionModel::list_of_arguments_t reorderArgumentsByParticleTypes( 325 const FunctionModel::list_of_arguments_t &eachargs, 326 const ParticleTypes_t &_types 327 ); 328 329 /** Filter arguments according to types, allowing multiples. 330 * 331 * If particle types is (0,1,2) and three arguments, each with a pair of types, 332 * are given, then the alignment will be: (0,1), (0,2), and (1,2). 333 * 310 334 * \param args arguments to reorder 311 335 * \param _types particle type vector 312 * \return reordered args 313 */ 314 FunctionModel::arguments_t reorderArgumentsByParticleTypes( 315 const FunctionModel::arguments_t &args, 316 const ParticleTypes_t &_types 317 ); 318 319 /** Filter arguments according to types. 320 * 321 * If particle types is (0,1,2) and three arguments, each with a pair of types, 322 * are given, then the alignment will be: (0,1), (0,2), and (1,2). 323 * 324 * \param args arguments to reorder 325 * \param _types particle type vector 326 * \return filtered args 327 */ 328 FunctionModel::arguments_t filterArgumentsByParticleTypes( 336 * \return filtered list of args 337 */ 338 FunctionModel::list_of_arguments_t filterArgumentsByParticleTypes( 329 339 const FunctionModel::arguments_t &args, 330 340 const ParticleTypes_t &_types … … 351 361 const FunctionModel::arguments_t &secondargs); 352 362 363 /** Combines two argument lists by concatenation. 364 * 365 * @param firstlistargs first list of argument tuples 366 * @param secondlistargs second list of argument tuples 367 * @return concatenated lists 368 */ 369 FunctionModel::list_of_arguments_t concatenateListOfArguments( 370 const FunctionModel::list_of_arguments_t &firstlistargs, 371 const FunctionModel::list_of_arguments_t &secondlistargs); 372 353 373 }; /* namespace Extractors */ 354 374 -
src/FunctionApproximation/FunctionApproximation.cpp
rc73e35 rd8821e 64 64 {} 65 65 66 void FunctionApproximation::setTrainingData(const inputs_t &input, const outputs_t &output)66 void FunctionApproximation::setTrainingData(const filtered_inputs_t &input, const outputs_t &output) 67 67 { 68 68 ASSERT( input.size() == output.size(), … … 334 334 +" outputs but we provide "+toString(output_data.size())+"."); 335 335 if (!output_data.empty()) { 336 inputs_t::const_iterator initer = input_data.begin();336 filtered_inputs_t::const_iterator initer = input_data.begin(); 337 337 outputs_t::const_iterator outiter = output_data.begin(); 338 338 size_t index = 0; … … 362 362 +" outputs but we provide "+toString(output_data.size())+"."); 363 363 if (!output_data.empty()) { 364 inputs_t::const_iterator initer = input_data.begin();364 filtered_inputs_t::const_iterator initer = input_data.begin(); 365 365 outputs_t::const_iterator outiter = output_data.begin(); 366 366 size_t index = 0; -
src/FunctionApproximation/FunctionApproximation.hpp
rc73e35 rd8821e 41 41 * package. 42 42 * 43 * \section FunctionApproximation-details Details on the inner workings. 44 * 45 * FunctionApproximation::operator() is the main function that performs the 46 * non-linear regression. It consists of the following steps: 47 * -# hand given (initial) parameters over to model. 48 * -# convert output vector to format suitable to levmar 49 * -# allocate memory for levmar to work in 50 * -# depending on whether the model is constrained or not and whether we 51 * have a derivative, we make use of various levmar functions with prepared 52 * parameters. 53 * -# memory is free'd and some final infos is given. 54 * 55 * levmar needs to evaluate the model. To this end, FunctionApproximation has 56 * two functions whose signatures is such as to match with the one required 57 * by the levmar package. Hence, 58 * -# FunctionApproximation::LevMarCallback() 59 * -# FunctionApproximation::LevMarDerivativeCallback() 60 * are used as callbacks by levmar only. 61 * These hand over the current set of parameters to the model, then both bind 62 * FunctionApproximation::evaluate() and 63 * FunctionApproximation::evaluateDerivative(), respectively, and execute 64 * FunctionModel::operator() or FunctionModel::parameter_derivative(), 65 * respectively. 66 * 43 67 */ 44 68 class FunctionApproximation … … 47 71 //!> typedef for a vector of input arguments 48 72 typedef std::vector<FunctionModel::arguments_t> inputs_t; 73 //!> typedef for a vector of input arguments 74 typedef std::vector<FunctionModel::list_of_arguments_t> filtered_inputs_t; 49 75 //!> typedef for a vector of output values 50 76 typedef std::vector<FunctionModel::results_t> outputs_t; … … 86 112 * FunctionApproximation::output_dimension size 87 113 */ 88 void setTrainingData(const inputs_t &input, const outputs_t &output);114 void setTrainingData(const filtered_inputs_t &input, const outputs_t &output); 89 115 90 116 /** Setter for the model function to be used in the approximation. … … 167 193 168 194 //!> current input set of training data 169 inputs_t input_data;195 filtered_inputs_t input_data; 170 196 //!> current output set of training data 171 197 outputs_t output_data; -
src/FunctionApproximation/FunctionModel.hpp
rc73e35 rd8821e 15 15 16 16 #include <boost/function.hpp> 17 #include <list> 17 18 #include <vector> 18 19 … … 58 59 //!> typedef for the whole set of parameters of the function 59 60 typedef std::vector<parameter_t> parameters_t; 60 //!> typedef for the argument vector as input to the function 61 //!> typedef for the argument vector as input to the function (subset of distances) 61 62 typedef std::vector<argument_t> arguments_t; 63 //!> typedef for a list of argument vectors as input to the function (list of subsets) 64 typedef std::list<arguments_t> list_of_arguments_t; 62 65 //!> typedef for a single result degree of freedom 63 66 typedef double result_t; … … 65 68 typedef std::vector<result_t> results_t; 66 69 //!> typedef for a function containing how to extract required information from a Fragment. 67 typedef boost::function< arguments_t (const Fragment &, const size_t)> extractor_t;70 typedef boost::function< list_of_arguments_t (const Fragment &, const size_t)> extractor_t; 68 71 //!> typedef for a function containing how to filter required distances from a full argument list. 69 typedef boost::function< arguments_t (const arguments_t &)> filter_t;72 typedef boost::function< list_of_arguments_t (const arguments_t &)> filter_t; 70 73 //!> typedef for the magic triple function that gets the other two distances for a given argument 71 74 typedef boost::function< std::vector<arguments_t>(const argument_t &, const double)> triplefunction_t; … … 114 117 * \return result of the function 115 118 */ 116 virtual results_t operator()(const arguments_t &arguments) const=0;119 virtual results_t operator()(const list_of_arguments_t &arguments) const=0; 117 120 118 121 /** Evaluates the derivative of the function with the given \a arguments … … 124 127 * input 125 128 */ 126 virtual results_t parameter_derivative(const arguments_t &arguments, const size_t index) const=0;129 virtual results_t parameter_derivative(const list_of_arguments_t &arguments, const size_t index) const=0; 127 130 128 131 /** States whether lower and upper boundaries should be used to constraint … … 152 155 * \return bound function extracting distances from a fragment 153 156 */ 154 virtual extractor_t getSpecificExtractor() const=0;155 156 /** Returns a bound function to be used with TrainingData, extracting distances157 * from a Fragment.158 *159 * \return bound function extracting distances from a fragment160 */161 157 virtual filter_t getSpecificFilter() const=0; 162 158 -
src/FunctionApproximation/TrainingData.cpp
rc73e35 rd8821e 41 41 #include <algorithm> 42 42 #include <boost/bind.hpp> 43 #include <boost/foreach.hpp> 43 44 #include <boost/lambda/lambda.hpp> 44 45 #include <iostream> 46 #include <sstream> 45 47 46 48 #include "CodePatterns/Assert.hpp" … … 49 51 50 52 #include "Fragmentation/Summation/SetValues/Fragment.hpp" 53 #include "FunctionApproximation/FunctionArgument.hpp" 51 54 #include "FunctionApproximation/FunctionModel.hpp" 52 55 #include "FunctionApproximation/Extractors.hpp" … … 65 68 EnergyVector.push_back( FunctionModel::results_t(1, energy) ); 66 69 // filter distances out of list of all arguments 67 FunctionModel:: arguments_t args = filter(all_args);70 FunctionModel::list_of_arguments_t args = filter(all_args); 68 71 LOG(3, "DEBUG: Filtered arguments are " << args << "."); 69 72 ArgumentVector.push_back( args ); … … 75 78 double L2sum = 0.; 76 79 77 F unctionApproximation::inputs_t::const_iterator initer = ArgumentVector.begin();78 FunctionApproximation::outputs_t::const_iterator outiter = EnergyVector.begin();80 FilteredInputVector_t::const_iterator initer = ArgumentVector.begin(); 81 OutputVector_t::const_iterator outiter = EnergyVector.begin(); 79 82 for (; initer != ArgumentVector.end(); ++initer, ++outiter) { 80 83 const FunctionModel::results_t result = model((*initer)); … … 89 92 double Lmax = 0.; 90 93 // size_t maxindex = -1; 91 F unctionApproximation::inputs_t::const_iterator initer = ArgumentVector.begin();92 FunctionApproximation::outputs_t::const_iterator outiter = EnergyVector.begin();94 FilteredInputVector_t::const_iterator initer = ArgumentVector.begin(); 95 OutputVector_t::const_iterator outiter = EnergyVector.begin(); 93 96 for (; initer != ArgumentVector.end(); ++initer, ++outiter) { 94 97 const FunctionModel::results_t result = model((*initer)); … … 105 108 } 106 109 110 const TrainingData::L2ErrorConfigurationIndexMap_t 111 TrainingData::getWorstFragmentMap( 112 const FunctionModel &model, 113 const range_t &range) const 114 { 115 L2ErrorConfigurationIndexMap_t WorseFragmentMap; 116 // fragments make it into the container in reversed order, hence count from top down 117 size_t index= std::distance(range.first, range.second)-1; 118 InputVector_t::const_iterator distanceiter = DistanceVector.begin(); 119 FilteredInputVector_t::const_iterator initer = ArgumentVector.begin(); 120 OutputVector_t::const_iterator outiter = EnergyVector.begin(); 121 for (; initer != ArgumentVector.end(); ++initer, ++outiter, ++distanceiter) { 122 // calculate value from potential 123 const FunctionModel::list_of_arguments_t &args = *initer; 124 const FunctionModel::results_t result = model(args); 125 const double energy = (*outiter)[0]; 126 127 // insert difference into map 128 const double error = fabs(energy - result[0]); 129 WorseFragmentMap.insert( std::make_pair( error, index-- ) ); 130 131 { 132 // give only the distances in the debugging text 133 std::stringstream streamargs; 134 BOOST_FOREACH (argument_t arg, *distanceiter) { 135 streamargs << " " << arg.distance; 136 } 137 LOG(2, "DEBUG: frag.#" << index+1 << "'s error is |" << energy << " - " << result[0] 138 << "| = " << error << " for args " << streamargs.str() << "."); 139 } 140 } 141 142 return WorseFragmentMap; 143 } 144 107 145 const TrainingData::DistanceEnergyTable_t TrainingData::getDistanceEnergyTable() const 108 146 { … … 111 149 /// extract distance member variable from argument_t and first value from results_t 112 150 OutputVector_t::const_iterator ergiter = EnergyVector.begin(); 113 for (InputVector_t::const_iterator iter = ArgumentVector.begin();114 iter != ArgumentVector.end(); ++iter, ++ergiter) {151 for (InputVector_t::const_iterator iter = DistanceVector.begin(); 152 iter != DistanceVector.end(); ++iter, ++ergiter) { 115 153 ASSERT( ergiter != EnergyVector.end(), 116 154 "TrainingData::getDistanceEnergyTable() - less output than input values."); -
src/FunctionApproximation/TrainingData.hpp
rc73e35 rd8821e 27 27 * Fragment. 28 28 * 29 * In TrainingData::operator() we construct first all pair-wise distances as30 * list of all arguments. Then, these are filtered depending on the specific31 * FunctionModel's Filter and only these are handed to down to evaluate it.29 * TrainingData::operator() takes the set of all possible pair-wise distances 30 * (InputVector_t) and transforms it via the given filter into a list of subsets 31 * of distances (FilteredInputVector_t) that is feedable to the model. 32 32 * 33 33 */ … … 41 41 //!> Training tuple input vector pair 42 42 typedef FunctionApproximation::inputs_t InputVector_t; 43 //!> Training tuple modified input vector pair 44 typedef FunctionApproximation::filtered_inputs_t FilteredInputVector_t; 43 45 //!> Training tuple output vector pair 44 46 typedef FunctionApproximation::outputs_t OutputVector_t; 45 47 //!> Typedef for a table with columns of all distances and the energy 46 48 typedef std::vector< std::vector<double> > DistanceEnergyTable_t; 49 //!> Typedef for a map of each fragment with error. 50 typedef std::multimap< double, size_t > L2ErrorConfigurationIndexMap_t; 47 51 48 52 public: … … 72 76 * \return const ref to training tuple of input vector 73 77 */ 74 const InputVector_t& getTrainingInputs() const {78 const FilteredInputVector_t& getTrainingInputs() const { 75 79 return ArgumentVector; 76 80 } … … 114 118 const double getLMaxError(const FunctionModel &model) const; 115 119 120 /** Calculate the Lmax error of a given \a model against the stored training data. 121 * 122 * \param model model whose Lmax error to calculate 123 * \param range given range within a HomologyContainer of homologous fragments 124 * \return map with L2 error per configuration 125 */ 126 const L2ErrorConfigurationIndexMap_t getWorstFragmentMap( 127 const FunctionModel &model, 128 const range_t &range) const; 129 116 130 /** Creates a table of columns with all distances and the energy. 117 131 * … … 129 143 OutputVector_t EnergyVector; 130 144 //!> list of all filtered arguments over all tuples 131 InputVector_t ArgumentVector;145 FilteredInputVector_t ArgumentVector; 132 146 //!> function to be used for training input data extraction from a fragment 133 147 const FunctionModel::filter_t filter; -
src/FunctionApproximation/unittests/ExtractorsUnitTest.cpp
rc73e35 rd8821e 182 182 args.push_back(arg); 183 183 CPPUNIT_ASSERT_EQUAL( (size_t)3, args.size() ); 184 FunctionModel::list_of_arguments_t listargs(1, args); 184 185 185 186 // reorder 186 FunctionModel::arguments_t args_sorted = 187 Extractors::reorderArgumentsByIncreasingDistance(args); 187 FunctionModel::list_of_arguments_t listargs_sorted = 188 Extractors::reorderArgumentsByIncreasingDistance(listargs); 189 CPPUNIT_ASSERT_EQUAL( (size_t)1, listargs_sorted.size() ); 190 FunctionModel::arguments_t args_sorted = *(listargs_sorted.begin()); 188 191 CPPUNIT_ASSERT_EQUAL( (size_t)3, args_sorted.size() ); 189 192 CPPUNIT_ASSERT_EQUAL( args[0].distance, args_sorted[0].distance ); -
src/Jobs/MPQCCommandJob.hpp
rc73e35 rd8821e 18 18 #include <string> 19 19 20 #ifdef HAVE_JOBMARKET 20 21 #include "JobMarket/Results/FragmentResult.hpp" 21 22 #include "JobMarket/Jobs/SystemCommandJob.hpp" 23 #else 24 #include "Jobs/JobMarket/FragmentResult.hpp" 25 #include "Jobs/JobMarket/SystemCommandJob.hpp" 26 #endif 22 27 23 28 #include "Fragmentation/Summation/Containers/MPQCData.hpp" 24 29 25 30 class MPQCCommandJobTest; 31 class MPQCCommandFragmentController; 26 32 27 33 /** This class calls mpqc for solving a specific Hartree Fock problem. … … 32 38 //!> grant unit test access 33 39 friend class MPQCCommandJobTest; 40 //!> grant access to controller 41 friend class MPQCCommandFragmentController; 34 42 public: 35 43 MPQCCommandJob(const std::string &_inputfile, const JobId_t _JobId, const std::string &_command = std::string("mpqc")); … … 43 51 44 52 private: 53 //!> Allow controller access to changing the commands 54 void setCommand(const std::string &_command) 55 { command = _command; } 56 57 //!> Allow controller access to changing the suffix 58 void setSuffix(const std::string &_suffix) 59 { suffix = _suffix; } 60 45 61 //!> private default cstor only for serializatio 46 62 MPQCCommandJob(); -
src/Jobs/MPQCJob.hpp
rc73e35 rd8821e 17 17 #include "boost/serialization/export.hpp" 18 18 19 #ifdef HAVE_JOBMARKET 19 20 #include "JobMarket/Jobs/FragmentJob.hpp" 21 #else 22 #include "Jobs/JobMarket/FragmentJob.hpp" 23 #endif 20 24 21 25 #include "Fragmentation/Summation/SetValues/SamplingGridProperties.hpp" -
src/Jobs/Makefile.am
rc73e35 rd8821e 2 2 # Also indentation by a single tab 3 3 4 JOBSSOURCE = \ 4 JOBSSOURCE = 5 if CONDJOBMARKET 6 else 7 JOBSSOURCE += \ 8 Jobs/JobMarket/FragmentJob.cpp \ 9 Jobs/JobMarket/FragmentResult.cpp \ 10 Jobs/JobMarket/JobId.cpp \ 11 Jobs/JobMarket/SystemCommandJob.cpp 12 endif 13 JOBSSOURCE += \ 5 14 Jobs/MPQCCommandJob.cpp \ 6 15 Jobs/MPQCJob.cpp 16 if CONDJOBMARKET 7 17 if CONDVMG 8 18 JOBSSOURCE += \ … … 13 23 Jobs/WindowGrid_converter.cpp 14 24 endif 25 endif 15 26 16 JOBSHEADER = \ 27 JOBSHEADER = 28 if CONDJOBMARKET 29 else 30 JOBSHEADER += \ 31 Jobs/JobMarket/FragmentJob.hpp \ 32 Jobs/JobMarket/FragmentResult.hpp \ 33 Jobs/JobMarket/JobId.hpp \ 34 Jobs/JobMarket/SystemCommandJob.hpp \ 35 Jobs/JobMarket/types.hpp 36 endif 37 JOBSHEADER += \ 17 38 Jobs/MPQCCommandJob.hpp \ 18 39 Jobs/MPQCCommandJob_binding.hpp \ 19 40 Jobs/MPQCJob.hpp \ 20 41 Jobs/MPQCJob_binding.hpp 42 if CONDJOBMARKET 21 43 if CONDVMG 22 44 JOBSHEADER += \ … … 29 51 Jobs/WindowGrid_converter.hpp 30 52 endif 53 endif 31 54 32 55 lib_LTLIBRARIES += libMolecuilderJobs.la … … 35 58 libMolecuilderJobs_la_CPPFLAGS = ${BOOST_CPPFLAGS} ${CodePatterns_CFLAGS} ${JobMarket_CFLAGS} -Dvmg_float=double -Dvmg_int=int $(VMG_CFLAGS) 36 59 libMolecuilderJobs_la_LDFLAGS = $(AM_LDFLAGS) \ 60 $(BOOST_IOSTREAMS_LDFLAGS) \ 37 61 $(BOOST_SERIALIZATION_LDFLAGS) \ 38 $(BOOST_SYSTEM_LDFLAGS) \ 39 $(JobMarket_LDFLAGS) \ 62 $(BOOST_SYSTEM_LDFLAGS) 63 if CONDJOBMARKET 64 libMolecuilderJobs_la_LDFLAGS += \ 65 $(JobMarket_LDFLAGS) 66 endif 67 68 libMolecuilderJobs_la_LDFLAGS += \ 40 69 $(CodePatterns_LDFLAGS) 41 70 libMolecuilderJobs_la_LIBADD = \ 42 71 libMolecuilderFragmentationSummation.la 72 if CONDJOBMARKET 43 73 if CONDVMG 44 74 libMolecuilderJobs_la_LIBADD += \ 45 75 $(VMG_LIBS) 46 76 endif 77 endif 78 79 if CONDJOBMARKET 47 80 libMolecuilderJobs_la_LIBADD += \ 48 $(JobMarket_LIBS) \ 81 $(JobMarket_LIBS) 82 endif 83 libMolecuilderJobs_la_LIBADD += \ 84 $(BOOST_IOSTREAMS_LIBS) \ 49 85 $(BOOST_SERIALIZATION_LIBS) \ 50 86 $(BOOST_SYSTEM_LIBS) \ … … 91 127 #pkgconfigdir = $(libdir)/pkgconfig 92 128 #pkgconfig_DATA = $(top_builddir)/MoleCuilder.pc 93 129 -
src/Makefile.am
rc73e35 rd8821e 16 16 include Filling/Makefile.am 17 17 include Fragmentation/Makefile.am 18 include Fragmentation/Automation/Makefile.am 18 19 include Fragmentation/Summation/Containers/Makefile.am 19 20 include Fragmentation/Summation/Converter/Makefile.am … … 23 24 include Graph/Makefile.am 24 25 include Helpers/Makefile.am 25 26 if CONDJOBMARKET27 include Fragmentation/Automation/Makefile.am28 26 include Jobs/Makefile.am 29 endif30 27 31 28 if CONDPYTHON … … 57 54 58 55 DESCRIPTORSOURCE = \ 59 56 Descriptors/AtomDescriptor.cpp \ 60 57 Descriptors/AtomIdDescriptor.cpp \ 61 58 Descriptors/AtomOfMoleculeDescriptor.cpp \ … … 288 285 -I$(top_srcdir)/LinearAlgebra/src 289 286 290 bin_PROGRAMS += molecuilder joiner analyzer287 bin_PROGRAMS += molecuilder 291 288 EXTRA_PROGRAMS = unity 292 289 … … 313 310 Actions/GlobalListOfActions.hpp \ 314 311 Actions/ActionHistory.hpp 315 pyMoleCuilder_la_CPPFLAGS = ${BOOST_CPPFLAGS} ${CodePatterns_CFLAGS} -I$(PYTHON_INCLUDE_DIR)312 pyMoleCuilder_la_CPPFLAGS = ${BOOST_CPPFLAGS} ${CodePatterns_CFLAGS} $(JobMarket_CFLAGS) -I$(PYTHON_INCLUDE_DIR) 316 313 pyMoleCuilder_la_LDFLAGS = -module -avoid-version -shared $(BOOST_PYTHON_LDFLAGS) 317 314 pyMoleCuilder_la_LIBADD = \ … … 403 400 endif 404 401 405 joiner_SOURCES = Fragmentation/joiner.cpp Fragmentation/datacreator.cpp Fragmentation/datacreator.hpp406 joiner_CPPFLAGS = $(AM_CPPFLAGS)407 joiner_LDFLAGS = $(AM_LDFLAGS) $(BOOST_THREAD_LDFLAGS)408 joiner_LDADD = \409 libMolecuilderFragmentation.la \410 libMolecuilderFragmentation_KeysetsContainer.la \411 libMolecuilderHelpers.la \412 libMolecuilderElement.la \413 $(top_builddir)/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la \414 ${CodePatterns_LIBS} \415 $(BOOST_THREAD_LIBS)416 417 analyzer_SOURCES = Fragmentation/analyzer.cpp Fragmentation/datacreator.cpp Fragmentation/datacreator.hpp418 analyzer_CPPFLAGS = $(AM_CPPFLAGS)419 analyzer_LDFLAGS = $(AM_LDFLAGS) $(BOOST_THREAD_LDFLAGS)420 analyzer_LDADD = \421 libMolecuilderFragmentation.la \422 libMolecuilderFragmentation_KeysetsContainer.la \423 libMolecuilderHelpers.la \424 libMolecuilderElement.la \425 $(top_builddir)/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la \426 ${CodePatterns_LIBS} \427 $(BOOST_THREAD_LIBS)428 429 402 if CONDJOBMARKET 430 403 CONTROLLERSOURCE = \ -
src/Potentials/CompoundPotential.cpp
rc73e35 rd8821e 228 228 { 229 229 arguments_by_model_t partial_args; 230 // go through each model and have it filter out its arguments 230 // go through each model and have it filter out its arguments, this already 231 // returns a list of tuples associated with the specific model 231 232 for(models_t::const_iterator modeliter = models.begin(); 232 233 modeliter != models.end(); ++modeliter) { 233 234 FunctionModel::filter_t filterfunction = (*modeliter)->getSpecificFilter(); 234 arguments_t tempargs = filterfunction(arguments);235 list_of_arguments_t tempargs = filterfunction(arguments); 235 236 // then split up all the bunches, too. 236 arguments_t::const_iterator advanceiter = tempargs.begin(); 237 for (arguments_t::const_iterator argiter = tempargs.begin(); 238 argiter != tempargs.end(); argiter = advanceiter) { 239 advanceiter += (*modeliter)->getSpecificArgumentCount(); 237 for (list_of_arguments_t::const_iterator argiter = tempargs.begin(); 238 argiter != tempargs.end(); ++argiter) { 239 const arguments_t &args = *argiter; 240 240 partial_args.push_back( 241 241 std::make_pair( 242 242 *modeliter, 243 arg uments_t(argiter, advanceiter)243 args 244 244 ) 245 245 ); … … 251 251 252 252 CompoundPotential::arguments_by_model_t CompoundPotential::splitUpArgumentsByModels( 253 const arguments_t &arguments) const253 const list_of_arguments_t &listarguments) const 254 254 { 255 255 arguments_by_model_t partial_args; 256 arguments_t::const_iterator argiter = arguments.begin();257 256 particletypes_per_model_t::const_iterator typesiter = particletypes_per_model.begin(); 258 257 models_t::const_iterator modeliter = models.begin(); 259 258 260 // add constant model (which is always first model) with empty args if present259 /// add constant model (which is always first model) with empty args if present 261 260 if (typesiter->empty()) { 262 261 partial_args.push_back( … … 266 265 ++typesiter; 267 266 } 267 268 268 // then check other models 269 while (argiter != arguments.end()) { 269 /// we only have to check whether the current model still matches or whether 270 /// have to use the next model. 271 for (list_of_arguments_t::const_iterator argiter = listarguments.begin(); 272 argiter != listarguments.end(); ++argiter) { 273 const arguments_t &arguments = *argiter; 270 274 if (typesiter+1 != particletypes_per_model.end()) { 271 275 // check whether next argument bunch is for same model or different one … … 275 279 276 280 // we always expect N(N-1)/2 distances for N particle types 277 arguments_t::const_iterator enditer = argiter+(types.size()*(types.size()-1)/2); 278 arguments_t::const_iterator nextenditer = argiter+(nexttypes.size()*(nexttypes.size()-1)/2); 279 arguments_t args(argiter, enditer); 280 arguments_t nextargs(argiter, nextenditer); 281 if (types.size() < nexttypes.size()) { 282 if (areValidArguments(nexttypes, nextargs)) { 281 // check first from sizes alone 282 const size_t tuplesize = types.size()*(types.size()-1)/2; 283 const size_t nexttuplesize = nexttypes.size()*(nexttypes.size()-1)/2; 284 if ((tuplesize != nexttuplesize)) { 285 if ((arguments.size() == tuplesize) && areValidArguments(types, arguments)) { 286 // only former still matches, don't increment 287 partial_args.push_back( 288 std::make_pair(*modeliter, arguments) 289 ); 290 } else if ((arguments.size() == nexttuplesize) && areValidArguments(nexttypes, arguments)) { 283 291 // latter matches, increment 284 292 ++typesiter; 285 293 partial_args.push_back( 286 std::make_pair(*(++modeliter), arguments _t(argiter, nextenditer))294 std::make_pair(*(++modeliter), arguments) 287 295 ); 288 argiter = nextenditer; 289 } else if (areValidArguments(types, args)) { 290 // only former matches, don't increment 291 partial_args.push_back( 292 std::make_pair(*modeliter, arguments_t(argiter, enditer)) 293 ); 294 argiter = enditer; 295 } else 296 } else { 296 297 ASSERT(0, 297 "CompoundPotential::splitUpArgumentsByModels() - neither type matches its argument bunch."); 298 } else { 299 if (areValidArguments(types, args)) { 300 // only former matches, don't increment 301 partial_args.push_back( 302 std::make_pair(*modeliter, arguments_t(argiter, enditer)) 303 ); 304 argiter = enditer; 305 } else if (areValidArguments(nexttypes, nextargs)) { 306 // latter matches, increment 307 ++typesiter; 308 partial_args.push_back( 309 std::make_pair(*(++modeliter), arguments_t(argiter, nextenditer)) 310 ); 311 argiter = nextenditer; 298 "CompoundPotential::splitUpArgumentsByModels() - neither this model nor next model match (size) with current tuple."); 299 } 300 } else { // same size, now we have to check the types individually 301 size_t encodeValidity = 0; 302 encodeValidity += 1*areValidArguments(types, arguments); 303 encodeValidity += 2*areValidArguments(nexttypes, arguments); 304 305 switch (encodeValidity) { 306 case 1: 307 // only former still matches, don't increment 308 partial_args.push_back( 309 std::make_pair(*modeliter, arguments) 310 ); 311 break; 312 case 2: 313 ++typesiter; 314 partial_args.push_back( 315 std::make_pair(*(++modeliter), arguments) 316 ); 317 break; 318 case 0: 319 case 3: 320 default: 321 ASSERT(0, 322 "CompoundPotential::splitUpArgumentsByModels() - neither this model nor next model match (type) with current tuple."); 323 break; 312 324 } 313 325 } 314 326 } else { 315 327 const SerializablePotential::ParticleTypes_t &types = *typesiter; 316 // we always expect N(N-1)/2 distances for N particle types 317 arguments_t::const_iterator enditer = argiter+(types.size()*(types.size()-1)/2); 318 partial_args.push_back( 319 std::make_pair(*modeliter, arguments_t(argiter, enditer)) 320 ); 321 argiter = enditer; 328 if (areValidArguments(types, arguments)) { 329 // only former matches, don't increment 330 partial_args.push_back( 331 std::make_pair(*modeliter, arguments) 332 ); 333 } else { 334 ASSERT(0, 335 "CompoundPotential::splitUpArgumentsByModels() - last model does not match with current tuple."); 336 } 322 337 } 323 338 } … … 326 341 } 327 342 328 CompoundPotential::results_t CompoundPotential::operator()(const arguments_t &arguments) const 343 CompoundPotential::results_t CompoundPotential::operator()( 344 const list_of_arguments_t &listarguments) const 329 345 { 330 346 /// first, we have to split up the given arguments 331 347 arguments_by_model_t partial_args = 332 splitUpArgumentsByModels( arguments);348 splitUpArgumentsByModels(listarguments); 333 349 // print split up argument list for debugging 334 350 if (DoLog(4)) { … … 348 364 iter != partial_args.end(); ++iter) { 349 365 partial_results.push_back( 350 (*iter->first)(iter->second) 366 (*iter->first)( 367 FunctionModel::list_of_arguments_t(1, iter->second)) 351 368 ); 352 369 } … … 366 383 } 367 384 368 CompoundPotential::results_t CompoundPotential::parameter_derivative(const arguments_t &arguments, const size_t index) const 385 CompoundPotential::results_t CompoundPotential::parameter_derivative( 386 const list_of_arguments_t &listarguments, 387 const size_t index) const 369 388 { 370 389 // first, we have to split up the given arguments 371 390 arguments_by_model_t partial_args = 372 splitUpArgumentsByModels( arguments);391 splitUpArgumentsByModels(listarguments); 373 392 // then, with each bunch of arguments, we call the specific model 374 393 // get parameter dimensions per model … … 399 418 const size_t indexbase = (iter == dimensions.begin()) ? 0 : *(iter-1); 400 419 CompoundPotential::results_t results = 401 model->parameter_derivative(argiter->second, index-indexbase); 420 model->parameter_derivative( 421 FunctionModel::list_of_arguments_t(1, argiter->second), index-indexbase); 402 422 403 423 // either set results or add … … 457 477 } 458 478 459 FunctionModel::extractor_t CompoundPotential::getSpecificExtractor() const460 {461 // create initial returnfunction462 FunctionModel::extractor_t returnfunction =463 boost::bind(&Helpers::returnEmptyArguments);464 465 // every following fragments combines its arguments with the initial function466 for (particletypes_per_model_t::const_iterator typesiter = particletypes_per_model.begin();467 typesiter != particletypes_per_model.end(); ++typesiter) {468 Fragment::charges_t charges;469 {470 charges.resize((*typesiter).size());471 std::transform((*typesiter).begin(), (*typesiter).end(),472 charges.begin(), boost::lambda::_1);473 }474 475 returnfunction =476 boost::bind(&Extractors::concatenateArguments,477 boost::bind(returnfunction, _1, _2),478 boost::bind(&Extractors::gatherAllDistancesFromFragment,479 boost::bind(&Fragment::getPositions, _1),480 boost::bind(&Fragment::getCharges, _1),481 charges, // no crefs here as are temporaries!482 _2)483 );484 }485 return returnfunction;486 }487 488 479 FunctionModel::filter_t CompoundPotential::getSpecificFilter() const 489 480 { … … 491 482 // create initial returnfunction 492 483 FunctionModel::filter_t returnfunction = 493 boost::bind(&Helpers::returnEmpty Arguments);484 boost::bind(&Helpers::returnEmptyListArguments); 494 485 495 486 // every following fragments combines its arguments with the initial function … … 497 488 modeliter != models.end(); ++modeliter) { 498 489 returnfunction = 499 boost::bind(&Extractors::concatenate Arguments,490 boost::bind(&Extractors::concatenateListOfArguments, 500 491 boost::bind(returnfunction, _1), 501 492 boost::bind((*modeliter)->getSpecificFilter(), _1) -
src/Potentials/CompoundPotential.hpp
rc73e35 rd8821e 23 23 class TrainingData; 24 24 25 /** CompoundPotential combines several FunctionModel's as one to allow for 26 * simultaneous FunctionApproximation to a single fragment/graph. 25 /** CompoundPotential combines several EmipiricalPotential's into one 26 * FunctionModel to allow for simultaneous FunctionApproximation to a single 27 * fragment/graph. 27 28 * 28 29 * The CompoundPotential obtains a Graph as parameter to cstor and looks through … … 30 31 * matches. All of these are placed into an internal vector and used for 31 32 * fitting. 33 * 34 * The main work is then in operator() and parameter_derivative(), where the 35 * contained set of models has to be evaluated one after the other: 36 * 32 37 */ 33 38 class CompoundPotential : … … 88 93 /** Evaluates the harmonic potential function for the given arguments. 89 94 * 90 * @param arguments single distance95 * @param listarguments list of tuples of distances 91 96 * @return value of the potential function 92 97 */ 93 results_t operator()(const arguments_t &arguments) const;98 results_t operator()(const list_of_arguments_t &listarguments) const; 94 99 95 100 /** Evaluates the derivative of the function with the given \a arguments 96 101 * with respect to a specific parameter indicated by \a index. 97 102 * 98 * \param arguments setof arguments as input variables to the function103 * \param arguments list of sets of arguments as input variables to the function 99 104 * \param index derivative of which parameter 100 105 * \return result vector containing the derivative with respect to the given 101 106 * input 102 107 */ 103 results_t parameter_derivative(const arguments_t &arguments, const size_t index) const;108 results_t parameter_derivative(const list_of_arguments_t &listarguments, const size_t index) const; 104 109 105 110 /** States whether lower and upper boundaries should be used to constraint … … 123 128 */ 124 129 parameters_t getUpperBoxConstraints() const; 125 126 /** Returns a bound function to be used with TrainingData, extracting distances127 * from a Fragment.128 *129 * Here, we simply concatenate the arguments delivered by the extractors of each model.130 *131 * \return bound function extracting distances from a fragment132 */133 FunctionModel::extractor_t getSpecificExtractor() const;134 130 135 131 /** Returns a bound function to be used with TrainingData, extracting distances … … 157 153 /** Helper function to split up concatenated arguments for operator() calls. 158 154 * 159 * \param arguments arguments to split up155 * \param listarguments list of tuples of distances to assign to a model each 160 156 * \return vector of partial arguments with associated model 161 157 */ 162 arguments_by_model_t splitUpArgumentsByModels(const arguments_t &arguments) const;158 arguments_by_model_t splitUpArgumentsByModels(const list_of_arguments_t &listarguments) const; 163 159 164 160 /** Helper function to split up total list of arguments for operator() calls. -
src/Potentials/EmpiricalPotential.hpp
rc73e35 rd8821e 60 60 * parameters. 61 61 * 62 * \param arguments setof arguments as input variables to the function62 * \param listarguments list of sets of arguments as input variables to the function 63 63 * \return result of the function 64 64 */ 65 virtual results_t operator()(const arguments_t &arguments) const=0;65 virtual results_t operator()(const list_of_arguments_t &listarguments) const=0; 66 66 67 67 /** Evaluates the derivative of the function with the given \a arguments 68 68 * for each component. 69 69 * 70 * \param arguments setof arguments as input variables to the function70 * \param listarguments list of sets of arguments as input variables to the function 71 71 * \return result vector containing the derivative with respect to each 72 72 * input comonent of the function 73 73 */ 74 virtual derivative_components_t derivative(const arguments_t &arguments) const=0;74 virtual derivative_components_t derivative(const list_of_arguments_t &listarguments) const=0; 75 75 76 76 /** Returns the functor that converts argument_s into the -
src/Potentials/Specifics/ConstantPotential.cpp
rc73e35 rd8821e 112 112 ConstantPotential::results_t 113 113 ConstantPotential::operator()( 114 const arguments_t &arguments114 const list_of_arguments_t &listarguments 115 115 ) const 116 116 { 117 ASSERT( arguments.size() == 0, 118 "ConstantPotential::operator() - requires no argument."); 119 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 120 arguments, getParticleTypes()), 121 "ConstantPotential::operator() - types don't match with ones in arguments."); 122 const result_t result = params[energy_offset]; 123 return std::vector<result_t>(1, result); 117 // directly set result as energy constant as independent of arg list 118 result_t result = params[energy_offset]; 119 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 120 iter != listarguments.end(); ++iter) { 121 const arguments_t &arguments = *iter; 122 ASSERT( arguments.size() == 0, 123 "ConstantPotential::operator() - requires no argument."); 124 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 125 arguments, getParticleTypes()), 126 "ConstantPotential::operator() - types don't match with ones in arguments."); 127 result += 0.; 128 } 129 return results_t(1, result); 124 130 } 125 131 126 132 ConstantPotential::derivative_components_t 127 133 ConstantPotential::derivative( 128 const arguments_t &arguments134 const list_of_arguments_t &listarguments 129 135 ) const 130 136 { 131 ASSERT( arguments.size() == 0, 132 "ConstantPotential::operator() - requires no argument."); 133 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 134 arguments, getParticleTypes()), 135 "ConstantPotential::operator() - types don't match with ones in arguments."); 136 derivative_components_t result(1, 0.); 137 return result; 137 result_t result = 0.; 138 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 139 iter != listarguments.end(); ++iter) { 140 const arguments_t &arguments = *iter; 141 ASSERT( arguments.size() == 0, 142 "ConstantPotential::operator() - requires no argument."); 143 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 144 arguments, getParticleTypes()), 145 "ConstantPotential::operator() - types don't match with ones in arguments."); 146 result += 0.; 147 } 148 return derivative_components_t(1, result); 138 149 } 139 150 140 151 ConstantPotential::results_t 141 152 ConstantPotential::parameter_derivative( 142 const arguments_t &arguments,153 const list_of_arguments_t &listarguments, 143 154 const size_t index 144 155 ) const 145 156 { 146 ASSERT( arguments.size() == 0, 147 "ConstantPotential::parameter_derivative() - requires no argument."); 148 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 149 arguments, getParticleTypes()), 150 "ConstantPotential::operator() - types don't match with ones in arguments."); 151 switch (index) { 152 case energy_offset: 153 { 154 // Maple result: 1 155 const result_t result = +1.; 156 return std::vector<result_t>(1, result); 157 break; 158 } 159 default: 160 break; 157 // Maple result: 1 158 result_t result = 1.; // energy_offset 159 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 160 iter != listarguments.end(); ++iter) { 161 const arguments_t &arguments = *iter; 162 ASSERT( arguments.size() == 0, 163 "ConstantPotential::parameter_derivative() - requires no argument."); 164 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 165 arguments, getParticleTypes()), 166 "ConstantPotential::operator() - types don't match with ones in arguments."); 167 // switch (index) { 168 // case energy_offset: 169 // { 170 // // Maple result: 1 171 // result = +1.; 172 // break; 173 // } 174 // default: 175 // break; 176 // } 161 177 } 162 return std::vector<result_t>(1, 0.); 163 } 164 165 FunctionModel::extractor_t 166 ConstantPotential::getSpecificExtractor() const 167 { 168 Fragment::charges_t charges; 169 charges.resize(getParticleTypes().size()); 170 std::transform(getParticleTypes().begin(), getParticleTypes().end(), 171 charges.begin(), boost::lambda::_1); 172 FunctionModel::extractor_t returnfunction = 173 boost::bind(&Extractors::gatherDistancesFromFragment, 174 boost::bind(&Fragment::getPositions, _1), 175 boost::bind(&Fragment::getCharges, _1), 176 charges, 177 _2); 178 return returnfunction; 178 return results_t(1, result); 179 179 } 180 180 -
src/Potentials/Specifics/ConstantPotential.hpp
rc73e35 rd8821e 36 36 friend class PotentialFactory; 37 37 // some repeated typedefs to avoid ambiguities 38 typedef FunctionModel::list_of_arguments_t list_of_arguments_t; 38 39 typedef FunctionModel::arguments_t arguments_t; 39 40 typedef FunctionModel::result_t result_t; … … 90 91 /** Evaluates the harmonic potential function for the given arguments. 91 92 * 92 * @param arguments single distance93 * @param listarguments empty list 93 94 * @return value of the potential function 94 95 */ 95 results_t operator()(const arguments_t &arguments) const;96 results_t operator()(const list_of_arguments_t &listarguments) const; 96 97 97 98 /** Evaluates the derivative of the potential function. 98 99 * 99 * @param arguments single distance100 * @param listarguments empty list 100 101 * @return vector with derivative with respect to the input degrees of freedom 101 102 */ 102 derivative_components_t derivative(const arguments_t &arguments) const;103 derivative_components_t derivative(const list_of_arguments_t &listarguments) const; 103 104 104 105 /** Evaluates the derivative of the function with the given \a arguments 105 106 * with respect to a specific parameter indicated by \a index. 106 107 * 107 * \param arguments set of arguments as input variables to the function108 * \param listarguments empty list 108 109 * \param index derivative of which parameter 109 110 * \return result vector containing the derivative with respect to the given 110 111 * input 111 112 */ 112 results_t parameter_derivative(const arguments_t &arguments, const size_t index) const;113 results_t parameter_derivative(const list_of_arguments_t &listarguments, const size_t index) const; 113 114 114 115 /** Returns the functor that converts argument_s into the … … 163 164 return parameters_t(getParameterDimension(), std::numeric_limits<double>::max()); 164 165 } 165 166 /** Returns a bound function to be used with TrainingData, extracting distances167 * from a Fragment.168 *169 * \return bound function extracting distances from a fragment170 */171 FunctionModel::extractor_t getSpecificExtractor() const;172 166 173 167 /** Returns a bound function to be used with TrainingData, extracting distances -
src/Potentials/Specifics/FourBodyPotential_Torsion.cpp
rc73e35 rd8821e 140 140 FourBodyPotential_Torsion::results_t 141 141 FourBodyPotential_Torsion::operator()( 142 const arguments_t &arguments142 const list_of_arguments_t &listarguments 143 143 ) const 144 144 { 145 ASSERT( arguments.size() == getSpecificArgumentCount(), 146 "FourBodyPotential_Torsion::operator() - requires exactly three arguments."); 147 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 148 arguments, getParticleTypes()), 149 "FourBodyPotential_Torsion::operator() - types don't match with ones in arguments."); 150 const argument_t &r_ij = arguments[0]; // 01 151 const argument_t &r_ik = arguments[1]; // 02 152 const argument_t &r_il = arguments[2]; // 03 153 const argument_t &r_jk = arguments[3]; // 12 154 const argument_t &r_jl = arguments[4]; // 13 155 const argument_t &r_kl = arguments[5]; // 23 156 const result_t result = 157 params[spring_constant] 158 * Helpers::pow( function_theta(r_ij.distance, r_ik.distance, r_il.distance, r_jk.distance, r_jl.distance, r_kl.distance) - params[equilibrium_distance], 2 ); 159 return std::vector<result_t>(1, result); 145 result_t result = 0.; 146 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 147 iter != listarguments.end(); ++iter) { 148 const arguments_t &arguments = *iter; 149 ASSERT( arguments.size() == getSpecificArgumentCount(), 150 "FourBodyPotential_Torsion::operator() - requires exactly three arguments."); 151 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 152 arguments, getParticleTypes()), 153 "FourBodyPotential_Torsion::operator() - types don't match with ones in arguments."); 154 const argument_t &r_ij = arguments[0]; // 01 155 const argument_t &r_ik = arguments[1]; // 02 156 const argument_t &r_il = arguments[2]; // 03 157 const argument_t &r_jk = arguments[3]; // 12 158 const argument_t &r_jl = arguments[4]; // 13 159 const argument_t &r_kl = arguments[5]; // 23 160 result += 161 params[spring_constant] 162 * Helpers::pow( function_theta(r_ij.distance, r_ik.distance, r_il.distance, r_jk.distance, r_jl.distance, r_kl.distance) 163 - params[equilibrium_distance], 2 ); 164 } 165 return results_t(1, result); 160 166 } 161 167 162 168 FourBodyPotential_Torsion::derivative_components_t 163 169 FourBodyPotential_Torsion::derivative( 164 const arguments_t &arguments170 const list_of_arguments_t &listarguments 165 171 ) const 166 172 { 167 ASSERT( arguments.size() == getSpecificArgumentCount(), 168 "FourBodyPotential_Torsion::operator() - requires exactly three arguments."); 169 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 170 arguments, getParticleTypes()), 171 "FourBodyPotential_Torsion::operator() - types don't match with ones in arguments."); 172 derivative_components_t result; 173 const argument_t &r_ij = arguments[0]; // 01 174 const argument_t &r_ik = arguments[1]; // 02 175 const argument_t &r_il = arguments[2]; // 03 176 const argument_t &r_jk = arguments[3]; // 12 177 const argument_t &r_jl = arguments[4]; // 13 178 const argument_t &r_kl = arguments[5]; // 23 179 result.push_back( 2. * params[spring_constant] * ( function_theta(r_ij.distance, r_ik.distance, r_il.distance, r_jk.distance, r_jl.distance, r_kl.distance) - params[equilibrium_distance]) ); 180 ASSERT( result.size() == 1, 181 "FourBodyPotential_Torsion::operator() - we did not create exactly one component."); 182 return result; 173 result_t result = 0.; 174 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 175 iter != listarguments.end(); ++iter) { 176 const arguments_t &arguments = *iter; 177 ASSERT( arguments.size() == getSpecificArgumentCount(), 178 "FourBodyPotential_Torsion::operator() - requires exactly three arguments."); 179 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 180 arguments, getParticleTypes()), 181 "FourBodyPotential_Torsion::operator() - types don't match with ones in arguments."); 182 const argument_t &r_ij = arguments[0]; // 01 183 const argument_t &r_ik = arguments[1]; // 02 184 const argument_t &r_il = arguments[2]; // 03 185 const argument_t &r_jk = arguments[3]; // 12 186 const argument_t &r_jl = arguments[4]; // 13 187 const argument_t &r_kl = arguments[5]; // 23 188 result += 189 2. * params[spring_constant] * 190 ( function_theta(r_ij.distance, r_ik.distance, r_il.distance, r_jk.distance, r_jl.distance, r_kl.distance) 191 - params[equilibrium_distance]); 192 } 193 return derivative_components_t(1, result); 183 194 } 184 195 185 196 FourBodyPotential_Torsion::results_t 186 197 FourBodyPotential_Torsion::parameter_derivative( 187 const arguments_t &arguments,198 const list_of_arguments_t &listarguments, 188 199 const size_t index 189 200 ) const 190 201 { 191 ASSERT( arguments.size() == getSpecificArgumentCount(), 192 "FourBodyPotential_Torsion::parameter_derivative() - requires exactly three arguments."); 193 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 194 arguments, getParticleTypes()), 195 "FourBodyPotential_Torsion::operator() - types don't match with ones in arguments."); 196 const argument_t &r_ij = arguments[0]; // 01 197 const argument_t &r_ik = arguments[1]; // 02 198 const argument_t &r_il = arguments[2]; // 03 199 const argument_t &r_jk = arguments[3]; // 12 200 const argument_t &r_jl = arguments[4]; // 13 201 const argument_t &r_kl = arguments[5]; // 23 202 switch (index) { 203 case spring_constant: 204 { 205 const result_t result = 206 Helpers::pow( function_theta(r_ij.distance, r_ik.distance, r_il.distance, r_jk.distance, r_jl.distance, r_kl.distance) - params[equilibrium_distance], 2 ); 207 return std::vector<result_t>(1, result); 208 break; 202 result_t result = 0.; 203 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 204 iter != listarguments.end(); ++iter) { 205 const arguments_t &arguments = *iter; 206 ASSERT( arguments.size() == getSpecificArgumentCount(), 207 "FourBodyPotential_Torsion::parameter_derivative() - requires exactly three arguments."); 208 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 209 arguments, getParticleTypes()), 210 "FourBodyPotential_Torsion::operator() - types don't match with ones in arguments."); 211 const argument_t &r_ij = arguments[0]; // 01 212 const argument_t &r_ik = arguments[1]; // 02 213 const argument_t &r_il = arguments[2]; // 03 214 const argument_t &r_jk = arguments[3]; // 12 215 const argument_t &r_jl = arguments[4]; // 13 216 const argument_t &r_kl = arguments[5]; // 23 217 switch (index) { 218 case spring_constant: 219 { 220 result += 221 Helpers::pow( function_theta(r_ij.distance, r_ik.distance, r_il.distance, r_jk.distance, r_jl.distance, r_kl.distance) - params[equilibrium_distance], 2 ); 222 break; 223 } 224 case equilibrium_distance: 225 { 226 result += 227 -2. * params[spring_constant] 228 * ( function_theta(r_ij.distance, r_ik.distance, r_il.distance, r_jk.distance, r_jl.distance, r_kl.distance) - params[equilibrium_distance]); 229 break; 230 } 231 default: 232 ASSERT(0, "FourBodyPotential_Torsion::parameter_derivative() - derivative to unknown parameter desired."); 233 break; 209 234 } 210 case equilibrium_distance:211 {212 const result_t result =213 -2. * params[spring_constant]214 * ( function_theta(r_ij.distance, r_ik.distance, r_il.distance, r_jk.distance, r_jl.distance, r_kl.distance) - params[equilibrium_distance]);215 return std::vector<result_t>(1, result);216 break;217 }218 default:219 ASSERT(0, "FourBodyPotential_Torsion::parameter_derivative() - derivative to unknown parameter desired.");220 break;221 235 } 222 return std::vector<result_t>(1); 223 } 224 225 FunctionModel::extractor_t 226 FourBodyPotential_Torsion::getSpecificExtractor() const 227 { 228 Fragment::charges_t charges; 229 charges.resize(getParticleTypes().size()); 230 std::transform(getParticleTypes().begin(), getParticleTypes().end(), 231 charges.begin(), boost::lambda::_1); 232 FunctionModel::extractor_t returnfunction = 233 boost::bind(&Extractors::gatherDistancesFromFragment, 234 boost::bind(&Fragment::getPositions, _1), 235 boost::bind(&Fragment::getCharges, _1), 236 charges, 237 _2); 238 return returnfunction; 236 return results_t(1, result); 239 237 } 240 238 -
src/Potentials/Specifics/FourBodyPotential_Torsion.hpp
rc73e35 rd8821e 37 37 friend class PotentialFactory; 38 38 // some repeated typedefs to avoid ambiguities 39 typedef FunctionModel::list_of_arguments_t list_of_arguments_t; 39 40 typedef FunctionModel::arguments_t arguments_t; 40 41 typedef FunctionModel::result_t result_t; … … 92 93 /** Evaluates the harmonic potential function for the given arguments. 93 94 * 94 * @param arguments single distance95 * @param listarguments list of six distances 95 96 * @return value of the potential function 96 97 */ 97 results_t operator()(const arguments_t &arguments) const;98 results_t operator()(const list_of_arguments_t &listarguments) const; 98 99 99 100 /** Evaluates the derivative of the potential function. 100 101 * 101 * @param arguments single distance102 * @param listarguments list of six distances 102 103 * @return vector with derivative with respect to the input degrees of freedom 103 104 */ 104 derivative_components_t derivative(const arguments_t &arguments) const;105 derivative_components_t derivative(const list_of_arguments_t &listarguments) const; 105 106 106 107 /** Evaluates the derivative of the function with the given \a arguments 107 108 * with respect to a specific parameter indicated by \a index. 108 109 * 109 * \param arguments set of arguments as input variables to the function110 * \param listarguments list of six distances 110 111 * \param index derivative of which parameter 111 112 * \return result vector containing the derivative with respect to the given 112 113 * input 113 114 */ 114 results_t parameter_derivative(const arguments_t &arguments, const size_t index) const;115 results_t parameter_derivative(const list_of_arguments_t &listarguments, const size_t index) const; 115 116 116 117 /** Returns the functor that converts argument_s into the … … 169 170 return upperbounds; 170 171 } 171 172 /** Returns a bound function to be used with TrainingData, extracting distances173 * from a Fragment.174 *175 * \return bound function extracting distances from a fragment176 */177 FunctionModel::extractor_t getSpecificExtractor() const;178 172 179 173 /** Returns a bound function to be used with TrainingData, extracting distances -
src/Potentials/Specifics/ManyBodyPotential_Tersoff.cpp
rc73e35 rd8821e 184 184 ManyBodyPotential_Tersoff::results_t 185 185 ManyBodyPotential_Tersoff::operator()( 186 const arguments_t &arguments186 const list_of_arguments_t &listarguments 187 187 ) const 188 188 { 189 189 // Info info(__func__); 190 double result = 0.; 191 for(arguments_t::const_iterator argiter = arguments.begin(); 192 argiter != arguments.end(); 193 ++argiter) { 194 const argument_t &r_ij = *argiter; 195 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 196 arguments_t(1, r_ij), getParticleTypes()), 197 "ManyBodyPotential_Tersoff::operator() - types don't match with ones in arguments."); 198 199 const double cutoff = function_cutoff(r_ij.distance); 200 const double temp = (cutoff == 0.) ? 201 0. : 202 cutoff * ( 203 function_prefactor( 204 alpha, 205 function_eta(r_ij)) 190 result_t result = 0.; 191 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 192 iter != listarguments.end(); ++iter) { 193 const arguments_t &arguments = *iter; 194 for(arguments_t::const_iterator argiter = arguments.begin(); 195 argiter != arguments.end(); 196 ++argiter) { 197 const argument_t &r_ij = *argiter; 198 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 199 arguments_t(1, r_ij), getParticleTypes()), 200 "ManyBodyPotential_Tersoff::operator() - types don't match with ones in arguments."); 201 202 const double cutoff = function_cutoff(r_ij.distance); 203 const double temp = (cutoff == 0.) ? 204 0. : 205 cutoff * ( 206 function_prefactor( 207 alpha, 208 function_eta(r_ij)) 209 * function_smoother( 210 params[A], 211 params[lambda], 212 r_ij.distance) 213 + 214 function_prefactor( 215 params[beta], 216 function_zeta(r_ij)) 217 * function_smoother( 218 -params[B], 219 params[mu], 220 r_ij.distance) 221 ); 222 result += temp; 223 } 224 } 225 // LOG(2, "DEBUG: operator()(" << r_ij.distance << ") = " << result); 226 return results_t(1, result); 227 } 228 229 ManyBodyPotential_Tersoff::derivative_components_t 230 ManyBodyPotential_Tersoff::derivative( 231 const list_of_arguments_t &listarguments 232 ) const 233 { 234 // Info info(__func__); 235 return derivative_components_t(); 236 } 237 238 ManyBodyPotential_Tersoff::results_t 239 ManyBodyPotential_Tersoff::parameter_derivative( 240 const list_of_arguments_t &listarguments, 241 const size_t index 242 ) const 243 { 244 // Info info(__func__); 245 // ASSERT( arguments.size() == 1, 246 // "ManyBodyPotential_Tersoff::parameter_derivative() - requires exactly one argument."); 247 248 result_t result = 0.; 249 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 250 iter != listarguments.end(); ++iter) { 251 const arguments_t &arguments = *iter; 252 for(arguments_t::const_iterator argiter = arguments.begin(); 253 argiter != arguments.end(); 254 ++argiter) { 255 const argument_t &r_ij = *argiter; 256 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 257 arguments_t(1, r_ij), getParticleTypes()), 258 "ManyBodyPotential_Tersoff::operator() - types don't match with ones in arguments."); 259 260 switch (index) { 261 // case R: 262 // { 263 // result += 0.; 264 // break; 265 // } 266 // case S: 267 // { 268 // result += 0.; 269 // break; 270 // } 271 case A: 272 { 273 const double cutoff = function_cutoff(r_ij.distance); 274 result += (cutoff == 0.) ? 275 0. : 276 cutoff * 277 function_prefactor( 278 alpha, 279 function_eta(r_ij)) 280 * function_smoother( 281 1., 282 params[lambda], 283 r_ij.distance); 284 // cutoff * function_prefactor( 285 // alpha, 286 // function_eta(r_ij)) 287 // * function_smoother( 288 // 1., 289 // params[mu], 290 // r_ij.distance); 291 break; 292 } 293 case B: 294 { 295 const double cutoff = function_cutoff(r_ij.distance); 296 result += (cutoff == 0.) ? 297 0. : 298 cutoff * function_prefactor( 299 params[beta], 300 function_zeta(r_ij)) 206 301 * function_smoother( 207 params[A], 208 params[lambda], 209 r_ij.distance) 210 + 302 -1., 303 params[mu], 304 r_ij.distance); 305 // cutoff * function_prefactor( 306 // beta, 307 // function_zeta(r_ij)) 308 // * function_smoother( 309 // -params[B], 310 // params[mu], 311 // r_ij.distance)/params[B]; 312 break; 313 } 314 case lambda: 315 { 316 const double cutoff = function_cutoff(r_ij.distance); 317 result += (cutoff == 0.) ? 318 0. : 319 -r_ij.distance * cutoff * 320 function_prefactor( 321 alpha, 322 function_eta(r_ij)) 323 * function_smoother( 324 params[A], 325 params[lambda], 326 r_ij.distance); 327 break; 328 } 329 case mu: 330 { 331 const double cutoff = function_cutoff(r_ij.distance); 332 result += (cutoff == 0.) ? 333 0. : 334 -r_ij.distance * cutoff *( 211 335 function_prefactor( 212 336 params[beta], … … 217 341 r_ij.distance) 218 342 ); 219 result += temp; 220 } 221 // LOG(2, "DEBUG: operator()(" << r_ij.distance << ") = " << result); 222 return std::vector<result_t>(1, result); 223 } 224 225 ManyBodyPotential_Tersoff::derivative_components_t 226 ManyBodyPotential_Tersoff::derivative( 227 const arguments_t &arguments 228 ) const 229 { 230 // Info info(__func__); 231 return ManyBodyPotential_Tersoff::derivative_components_t(); 232 } 233 234 ManyBodyPotential_Tersoff::results_t 235 ManyBodyPotential_Tersoff::parameter_derivative( 236 const arguments_t &arguments, 237 const size_t index 238 ) const 239 { 240 // Info info(__func__); 241 // ASSERT( arguments.size() == 1, 242 // "ManyBodyPotential_Tersoff::parameter_derivative() - requires exactly one argument."); 243 244 double result = 0.; 245 for(arguments_t::const_iterator argiter = arguments.begin(); 246 argiter != arguments.end(); 247 ++argiter) { 248 const argument_t &r_ij = *argiter; 249 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 250 arguments_t(1, r_ij), getParticleTypes()), 251 "ManyBodyPotential_Tersoff::operator() - types don't match with ones in arguments."); 252 253 switch (index) { 254 // case R: 255 // { 256 // result += 0.; 257 // break; 258 // } 259 // case S: 260 // { 261 // result += 0.; 262 // break; 263 // } 264 case A: 265 { 266 const double cutoff = function_cutoff(r_ij.distance); 267 result += (cutoff == 0.) ? 268 0. : 269 cutoff * 270 function_prefactor( 271 alpha, 272 function_eta(r_ij)) 273 * function_smoother( 274 1., 275 params[lambda], 276 r_ij.distance); 277 // cutoff * function_prefactor( 278 // alpha, 279 // function_eta(r_ij)) 280 // * function_smoother( 281 // 1., 282 // params[mu], 283 // r_ij.distance); 284 break; 343 break; 344 } 345 // case lambda3: 346 // { 347 // result += 0.; 348 // break; 349 // } 350 // case alpha: 351 // { 352 // const double temp = 353 // pow(alpha*function_eta(r_ij), params[n]); 354 // const double cutoff = function_cutoff(r_ij.distance); 355 // result += (cutoff == 0.) || (alpha == 0. )? 356 // 0. : 357 // function_smoother( 358 // params[A], 359 // params[lambda], 360 // r_ij.distance) 361 // * (-.5) * alpha * (temp/alpha) 362 // / (1. + temp) 363 // ; 364 // break; 365 // } 366 // case chi: 367 // { 368 // result += 0.; 369 // break; 370 // } 371 // case omega: 372 // { 373 // result += 0.; 374 // break; 375 // } 376 case beta: 377 { 378 const double temp = 379 pow(params[beta]*function_zeta(r_ij), params[n]); 380 const double cutoff = function_cutoff(r_ij.distance); 381 result += (cutoff == 0.) || (params[beta] == 0. )? 382 0. : cutoff * 383 function_smoother( 384 -params[B], 385 params[mu], 386 r_ij.distance) 387 * (-.5) 388 * function_prefactor( 389 params[beta], 390 function_zeta(r_ij)) 391 * (temp/params[beta]) 392 / (1. + temp) 393 ; 394 break; 395 } 396 case n: 397 { 398 const double zeta = function_zeta(r_ij); 399 const double temp = pow( params[beta]*zeta , params[n]); 400 const double cutoff = function_cutoff(r_ij.distance); 401 const double tempres = ((cutoff == 0.) || (zeta == 0.)) ? // zeta must be caught if zero due to log 402 0. : .5 * cutoff * 403 function_smoother( 404 -params[B], 405 params[mu], 406 r_ij.distance) 407 * function_prefactor( 408 params[beta], 409 function_zeta(r_ij)) 410 * ( log(1.+temp)/(params[n]*params[n]) - temp 411 * (log(function_zeta(r_ij)) + log(params[beta])) 412 /(params[n]*(1.+temp))) 413 ; 414 // if (tempres != tempres) 415 // LOG(2, "DEBUG: tempres is NaN."); 416 // LOG(2, "DEBUG: Adding " << tempres << " for p.d. w.r.t n, temp=" << temp << ", cutoff=" << cutoff); 417 result += tempres; 418 break; 419 } 420 case c: 421 { 422 const double zeta = function_zeta(r_ij); 423 if (zeta == 0.) 424 break; 425 const double temp = 426 pow(zeta, params[n]-1.) * pow(params[beta],params[n]); 427 const double cutoff = function_cutoff(r_ij.distance); 428 const double tempres = (cutoff == 0.) ? 429 0. : cutoff * 430 function_smoother( 431 -params[B], 432 params[mu], 433 r_ij.distance) 434 * function_prefactor( 435 params[beta], 436 zeta) 437 * (-1.) * temp / (1.+temp*zeta); 438 double factor = function_derivative_c(r_ij); 439 result += tempres*factor; 440 if (result != result) 441 ELOG(1, "result is NaN, zeta=" << zeta << ", temp=" << temp << ", cutoff=" << cutoff << ", tempres=" << tempres << ", factor=" << factor); 442 break; 443 } 444 case d: 445 { 446 const double zeta = function_zeta(r_ij); 447 const double temp = 448 pow(zeta, params[n]-1.) * pow(params[beta],params[n]); 449 const double cutoff = function_cutoff(r_ij.distance); 450 const double tempres = (cutoff == 0.) ? 451 0. : cutoff * 452 function_smoother( 453 -params[B], 454 params[mu], 455 r_ij.distance) 456 * function_prefactor( 457 params[beta], 458 zeta) 459 * (-1.) * temp / (1.+temp*zeta); 460 double factor = function_derivative_d(r_ij); 461 result += tempres*factor; 462 if (result != result) 463 ELOG(1, "result is NaN, zeta=" << zeta << ", temp=" << temp << ", cutoff=" << cutoff << ", tempres=" << tempres << ", factor=" << factor); 464 break; 465 } 466 case h: 467 { 468 const double zeta = function_zeta(r_ij); 469 const double temp = 470 pow(zeta, params[n]-1.) * pow(params[beta],params[n]); 471 const double cutoff = function_cutoff(r_ij.distance); 472 const double tempres = (cutoff == 0.) ? 473 0. : cutoff * 474 function_smoother( 475 -params[B], 476 params[mu], 477 r_ij.distance) 478 * function_prefactor( 479 params[beta], 480 zeta) 481 * (-1.) * temp / (1.+temp*zeta); 482 double factor = function_derivative_h(r_ij); 483 result += tempres*factor; 484 if (result != result) 485 ELOG(1, "result is NaN, zeta=" << zeta << ", temp=" << temp << ", cutoff=" << cutoff << ", tempres=" << tempres << ", factor=" << factor); 486 break; 487 } 488 default: 489 ASSERT(0, "ManyBodyPotential_Tersoff::parameter_derivative() - derivative to unknown parameter desired."); 490 break; 285 491 } 286 case B: 287 { 288 const double cutoff = function_cutoff(r_ij.distance); 289 result += (cutoff == 0.) ? 290 0. : 291 cutoff * function_prefactor( 292 params[beta], 293 function_zeta(r_ij)) 294 * function_smoother( 295 -1., 296 params[mu], 297 r_ij.distance); 298 // cutoff * function_prefactor( 299 // beta, 300 // function_zeta(r_ij)) 301 // * function_smoother( 302 // -params[B], 303 // params[mu], 304 // r_ij.distance)/params[B]; 305 break; 492 if (result != result) 493 ELOG(1, "result is NaN."); 306 494 } 307 case lambda:308 {309 const double cutoff = function_cutoff(r_ij.distance);310 result += (cutoff == 0.) ?311 0. :312 -r_ij.distance * cutoff *313 function_prefactor(314 alpha,315 function_eta(r_ij))316 * function_smoother(317 params[A],318 params[lambda],319 r_ij.distance);320 break;321 }322 case mu:323 {324 const double cutoff = function_cutoff(r_ij.distance);325 result += (cutoff == 0.) ?326 0. :327 -r_ij.distance * cutoff *(328 function_prefactor(329 params[beta],330 function_zeta(r_ij))331 * function_smoother(332 -params[B],333 params[mu],334 r_ij.distance)335 );336 break;337 }338 // case lambda3:339 // {340 // result += 0.;341 // break;342 // }343 // case alpha:344 // {345 // const double temp =346 // pow(alpha*function_eta(r_ij), params[n]);347 // const double cutoff = function_cutoff(r_ij.distance);348 // result += (cutoff == 0.) || (alpha == 0. )?349 // 0. :350 // function_smoother(351 // params[A],352 // params[lambda],353 // r_ij.distance)354 // * (-.5) * alpha * (temp/alpha)355 // / (1. + temp)356 // ;357 // break;358 // }359 // case chi:360 // {361 // result += 0.;362 // break;363 // }364 // case omega:365 // {366 // result += 0.;367 // break;368 // }369 case beta:370 {371 const double temp =372 pow(params[beta]*function_zeta(r_ij), params[n]);373 const double cutoff = function_cutoff(r_ij.distance);374 result += (cutoff == 0.) || (params[beta] == 0. )?375 0. : cutoff *376 function_smoother(377 -params[B],378 params[mu],379 r_ij.distance)380 * (-.5)381 * function_prefactor(382 params[beta],383 function_zeta(r_ij))384 * (temp/params[beta])385 / (1. + temp)386 ;387 break;388 }389 case n:390 {391 const double zeta = function_zeta(r_ij);392 const double temp = pow( params[beta]*zeta , params[n]);393 const double cutoff = function_cutoff(r_ij.distance);394 const double tempres = ((cutoff == 0.) || (zeta == 0.)) ? // zeta must be caught if zero due to log395 0. : .5 * cutoff *396 function_smoother(397 -params[B],398 params[mu],399 r_ij.distance)400 * function_prefactor(401 params[beta],402 function_zeta(r_ij))403 * ( log(1.+temp)/(params[n]*params[n]) - temp404 * (log(function_zeta(r_ij)) + log(params[beta]))405 /(params[n]*(1.+temp)))406 ;407 // if (tempres != tempres)408 // LOG(2, "DEBUG: tempres is NaN.");409 // LOG(2, "DEBUG: Adding " << tempres << " for p.d. w.r.t n, temp=" << temp << ", cutoff=" << cutoff);410 result += tempres;411 break;412 }413 case c:414 {415 const double zeta = function_zeta(r_ij);416 if (zeta == 0.)417 break;418 const double temp =419 pow(zeta, params[n]-1.) * pow(params[beta],params[n]);420 const double cutoff = function_cutoff(r_ij.distance);421 const double tempres = (cutoff == 0.) ?422 0. : cutoff *423 function_smoother(424 -params[B],425 params[mu],426 r_ij.distance)427 * function_prefactor(428 params[beta],429 zeta)430 * (-1.) * temp / (1.+temp*zeta);431 double factor = function_derivative_c(r_ij);432 result += tempres*factor;433 if (result != result)434 ELOG(1, "result is NaN, zeta=" << zeta << ", temp=" << temp << ", cutoff=" << cutoff << ", tempres=" << tempres << ", factor=" << factor);435 break;436 }437 case d:438 {439 const double zeta = function_zeta(r_ij);440 const double temp =441 pow(zeta, params[n]-1.) * pow(params[beta],params[n]);442 const double cutoff = function_cutoff(r_ij.distance);443 const double tempres = (cutoff == 0.) ?444 0. : cutoff *445 function_smoother(446 -params[B],447 params[mu],448 r_ij.distance)449 * function_prefactor(450 params[beta],451 zeta)452 * (-1.) * temp / (1.+temp*zeta);453 double factor = function_derivative_d(r_ij);454 result += tempres*factor;455 if (result != result)456 ELOG(1, "result is NaN, zeta=" << zeta << ", temp=" << temp << ", cutoff=" << cutoff << ", tempres=" << tempres << ", factor=" << factor);457 break;458 }459 case h:460 {461 const double zeta = function_zeta(r_ij);462 const double temp =463 pow(zeta, params[n]-1.) * pow(params[beta],params[n]);464 const double cutoff = function_cutoff(r_ij.distance);465 const double tempres = (cutoff == 0.) ?466 0. : cutoff *467 function_smoother(468 -params[B],469 params[mu],470 r_ij.distance)471 * function_prefactor(472 params[beta],473 zeta)474 * (-1.) * temp / (1.+temp*zeta);475 double factor = function_derivative_h(r_ij);476 result += tempres*factor;477 if (result != result)478 ELOG(1, "result is NaN, zeta=" << zeta << ", temp=" << temp << ", cutoff=" << cutoff << ", tempres=" << tempres << ", factor=" << factor);479 break;480 }481 default:482 ASSERT(0, "ManyBodyPotential_Tersoff::parameter_derivative() - derivative to unknown parameter desired.");483 break;484 }485 if (result != result)486 ELOG(1, "result is NaN.");487 495 } 488 496 return results_t(1,-result); … … 689 697 // LOG(2, "DEBUG: function_angle(" << r_ij << "," << r_ik << "," << r_jk << ") = " << result); 690 698 return result; 691 }692 693 FunctionModel::extractor_t694 ManyBodyPotential_Tersoff::getSpecificExtractor() const695 {696 FunctionModel::extractor_t returnfunction =697 boost::bind(&Extractors::gatherAllDistances,698 boost::bind(&Fragment::getPositions, _1),699 boost::bind(&Fragment::getCharges, _1),700 _2);701 return returnfunction;702 699 } 703 700 -
src/Potentials/Specifics/ManyBodyPotential_Tersoff.hpp
rc73e35 rd8821e 38 38 friend class PotentialFactory; 39 39 // some repeated typedefs to avoid ambiguities 40 typedef FunctionModel::list_of_arguments_t list_of_arguments_t; 40 41 typedef FunctionModel::arguments_t arguments_t; 41 42 typedef FunctionModel::result_t result_t; … … 106 107 /** Evaluates the Tersoff potential for the given arguments. 107 108 * 108 * @param arguments single distance109 * @param listarguments list of distances 109 110 * @return value of the potential function 110 111 */ 111 results_t operator()(const arguments_t &arguments) const;112 results_t operator()(const list_of_arguments_t &listarguments) const; 112 113 113 114 /** Evaluates the derivative of the Tersoff potential with respect to the 114 115 * input variables. 115 116 * 116 * @param arguments single distance117 * @param listarguments list of distances 117 118 * @return vector with components of the derivative 118 119 */ 119 derivative_components_t derivative(const arguments_t &arguments) const;120 derivative_components_t derivative(const list_of_arguments_t &listarguments) const; 120 121 121 122 /** Evaluates the derivative of the function with the given \a arguments 122 123 * with respect to a specific parameter indicated by \a index. 123 124 * 124 * \param arguments set of arguments as input variables to the function125 * \param listarguments list of distances 125 126 * \param index derivative of which parameter 126 127 * \return result vector containing the derivative with respect to the given 127 128 * input 128 129 */ 129 results_t parameter_derivative(const arguments_t &arguments, const size_t index) const;130 results_t parameter_derivative(const list_of_arguments_t &listarguments, const size_t index) const; 130 131 131 132 /** Returns the functor that converts argument_s into the … … 188 189 return parameters_t(getParameterDimension(), std::numeric_limits<double>::max()); 189 190 } 190 191 /** Returns a bound function to be used with TrainingData, extracting distances192 * from a Fragment.193 *194 * \return bound function extracting distances from a fragment195 */196 FunctionModel::extractor_t getSpecificExtractor() const;197 191 198 192 /** Returns a bound function to be used with TrainingData, extracting distances -
src/Potentials/Specifics/PairPotential_Harmonic.cpp
rc73e35 rd8821e 117 117 PairPotential_Harmonic::results_t 118 118 PairPotential_Harmonic::operator()( 119 const arguments_t &arguments119 const list_of_arguments_t &listarguments 120 120 ) const 121 121 { 122 ASSERT( arguments.size() == 1, 123 "PairPotential_Harmonic::operator() - requires exactly one argument."); 124 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 125 arguments, getParticleTypes()), 126 "PairPotential_Harmonic::operator() - types don't match with ones in arguments."); 127 const argument_t &r_ij = arguments[0]; 128 const result_t result = 129 params[spring_constant] 130 * Helpers::pow( r_ij.distance - params[equilibrium_distance], 2 ); 131 return std::vector<result_t>(1, result); 122 result_t result = 0.; 123 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 124 iter != listarguments.end(); ++iter) { 125 const arguments_t &arguments = *iter; 126 ASSERT( arguments.size() == 1, 127 "PairPotential_Harmonic::operator() - requires exactly one argument."); 128 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 129 arguments, getParticleTypes()), 130 "PairPotential_Harmonic::operator() - types don't match with ones in arguments."); 131 const argument_t &r_ij = arguments[0]; 132 result += 133 params[spring_constant] 134 * Helpers::pow( r_ij.distance - params[equilibrium_distance], 2 ); 135 } 136 return results_t(1, result); 132 137 } 133 138 134 139 PairPotential_Harmonic::derivative_components_t 135 140 PairPotential_Harmonic::derivative( 136 const arguments_t &arguments141 const list_of_arguments_t &listarguments 137 142 ) const 138 143 { 139 ASSERT( arguments.size() == 1, 140 "PairPotential_Harmonic::operator() - requires exactly one argument."); 141 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 142 arguments, getParticleTypes()), 143 "PairPotential_Harmonic::operator() - types don't match with ones in arguments."); 144 derivative_components_t result; 145 const argument_t &r_ij = arguments[0]; 146 result.push_back( 2. * params[spring_constant] * ( r_ij.distance - params[equilibrium_distance]) ); 147 ASSERT( result.size() == 1, 148 "PairPotential_Harmonic::operator() - we did not create exactly one component."); 149 return result; 144 result_t result = 0.; 145 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 146 iter != listarguments.end(); ++iter) { 147 const arguments_t &arguments = *iter; 148 ASSERT( arguments.size() == 1, 149 "PairPotential_Harmonic::operator() - requires exactly one argument."); 150 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 151 arguments, getParticleTypes()), 152 "PairPotential_Harmonic::operator() - types don't match with ones in arguments."); 153 const argument_t &r_ij = arguments[0]; 154 result += 155 2. * params[spring_constant] * 156 ( r_ij.distance - params[equilibrium_distance]); 157 } 158 return derivative_components_t(1, result); 150 159 } 151 160 152 161 PairPotential_Harmonic::results_t 153 162 PairPotential_Harmonic::parameter_derivative( 154 const arguments_t &arguments,163 const list_of_arguments_t &listarguments, 155 164 const size_t index 156 165 ) const 157 166 { 158 ASSERT( arguments.size() == 1, 159 "PairPotential_Harmonic::parameter_derivative() - requires exactly one argument."); 160 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 161 arguments, getParticleTypes()), 162 "PairPotential_Harmonic::operator() - types don't match with ones in arguments."); 163 const argument_t &r_ij = arguments[0]; 164 switch (index) { 165 case spring_constant: 166 { 167 const result_t result = 168 Helpers::pow( r_ij.distance - params[equilibrium_distance], 2 ); 169 return std::vector<result_t>(1, result); 170 break; 167 result_t result = 0.; 168 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 169 iter != listarguments.end(); ++iter) { 170 const arguments_t &arguments = *iter; 171 ASSERT( arguments.size() == 1, 172 "PairPotential_Harmonic::parameter_derivative() - requires exactly one argument."); 173 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 174 arguments, getParticleTypes()), 175 "PairPotential_Harmonic::operator() - types don't match with ones in arguments."); 176 const argument_t &r_ij = arguments[0]; 177 switch (index) { 178 case spring_constant: 179 { 180 result += 181 Helpers::pow( r_ij.distance - params[equilibrium_distance], 2 ); 182 break; 183 } 184 case equilibrium_distance: 185 { 186 result += 187 -2. * params[spring_constant] 188 * ( r_ij.distance - params[equilibrium_distance]); 189 break; 190 } 191 default: 192 ASSERT(0, "PairPotential_Harmonic::parameter_derivative() - derivative to unknown parameter desired."); 193 break; 171 194 } 172 case equilibrium_distance:173 {174 const result_t result =175 -2. * params[spring_constant]176 * ( r_ij.distance - params[equilibrium_distance]);177 return std::vector<result_t>(1, result);178 break;179 }180 default:181 ASSERT(0, "PairPotential_Harmonic::parameter_derivative() - derivative to unknown parameter desired.");182 break;183 195 } 184 185 return PairPotential_Harmonic::results_t(1, 0.); 186 } 187 188 FunctionModel::extractor_t 189 PairPotential_Harmonic::getSpecificExtractor() const 190 { 191 Fragment::charges_t charges; 192 charges.resize(getParticleTypes().size()); 193 std::transform(getParticleTypes().begin(), getParticleTypes().end(), 194 charges.begin(), boost::lambda::_1); 195 FunctionModel::extractor_t returnfunction = 196 boost::bind(&Extractors::gatherDistancesFromFragment, 197 boost::bind(&Fragment::getPositions, _1), 198 boost::bind(&Fragment::getCharges, _1), 199 charges, 200 _2); 201 return returnfunction; 196 return results_t(1, result); 202 197 } 203 198 -
src/Potentials/Specifics/PairPotential_Harmonic.hpp
rc73e35 rd8821e 35 35 friend class PotentialFactory; 36 36 // some repeated typedefs to avoid ambiguities 37 typedef FunctionModel::list_of_arguments_t list_of_arguments_t; 37 38 typedef FunctionModel::arguments_t arguments_t; 38 39 typedef FunctionModel::result_t result_t; … … 90 91 /** Evaluates the harmonic potential function for the given arguments. 91 92 * 92 * @param arguments single distance93 * @param listarguments list of single distances 93 94 * @return value of the potential function 94 95 */ 95 results_t operator()(const arguments_t &arguments) const;96 results_t operator()(const list_of_arguments_t &listarguments) const; 96 97 97 98 /** Evaluates the derivative of the potential function. 98 99 * 99 * @param arguments single distance100 * @param listarguments list of single distances 100 101 * @return vector with derivative with respect to the input degrees of freedom 101 102 */ 102 derivative_components_t derivative(const arguments_t &arguments) const;103 derivative_components_t derivative(const list_of_arguments_t &listarguments) const; 103 104 104 105 /** Evaluates the derivative of the function with the given \a arguments 105 106 * with respect to a specific parameter indicated by \a index. 106 107 * 107 * \param arguments set of arguments as input variables to the function108 * \param listarguments list of single distances 108 109 * \param index derivative of which parameter 109 110 * \return result vector containing the derivative with respect to the given 110 111 * input 111 112 */ 112 results_t parameter_derivative(const arguments_t &arguments, const size_t index) const;113 results_t parameter_derivative(const list_of_arguments_t &listarguments, const size_t index) const; 113 114 114 115 /** Returns the functor that converts argument_s into the … … 148 149 return parameters_t(getParameterDimension(), std::numeric_limits<double>::max()); 149 150 } 150 151 /** Returns a bound function to be used with TrainingData, extracting distances152 * from a Fragment.153 *154 * \return bound function extracting distances from a fragment155 */156 FunctionModel::extractor_t getSpecificExtractor() const;157 151 158 152 /** Returns a bound function to be used with TrainingData, extracting distances -
src/Potentials/Specifics/PairPotential_LennardJones.cpp
rc73e35 rd8821e 123 123 PairPotential_LennardJones::results_t 124 124 PairPotential_LennardJones::operator()( 125 const arguments_t &arguments125 const list_of_arguments_t &listarguments 126 126 ) const 127 127 { 128 ASSERT( arguments.size() == 1, 129 "PairPotential_LennardJones::operator() - requires one argument."); 130 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 131 arguments, getParticleTypes()), 132 "PairPotential_LennardJones::operator() - types don't match with ones in arguments."); 133 const double &r = arguments[0].distance; 134 const double temp = Helpers::pow(params[sigma]/r, 6); 135 const result_t result = 4.*params[epsilon] * (temp*temp - temp); 136 return std::vector<result_t>(1, result); 128 result_t result = 0.; 129 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 130 iter != listarguments.end(); ++iter) { 131 const arguments_t &arguments = *iter; 132 ASSERT( arguments.size() == 1, 133 "PairPotential_LennardJones::operator() - requires one argument."); 134 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 135 arguments, getParticleTypes()), 136 "PairPotential_LennardJones::operator() - types don't match with ones in arguments."); 137 const double &r = arguments[0].distance; 138 const double temp = Helpers::pow(params[sigma]/r, 6); 139 result += 4.*params[epsilon] * (temp*temp - temp); 140 } 141 return results_t(1, result); 137 142 } 138 143 139 144 PairPotential_LennardJones::derivative_components_t 140 145 PairPotential_LennardJones::derivative( 141 const arguments_t &arguments146 const list_of_arguments_t &listarguments 142 147 ) const 143 148 { 144 ASSERT( arguments.size() == 1,145 "PairPotential_LennardJones::operator() - requires no argument.");146 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes(147 arguments, getParticleTypes()),148 "PairPotential_LennardJones::operator() - types don't match with ones in arguments.");149 const double &r = arguments[0].distance;150 149 const double sigma6 = Helpers::pow(params[sigma], 6); 151 const result_t result = 152 4.*params[epsilon] * ( 153 sigma6*sigma6*(-12.) / Helpers::pow(r,13) 154 - sigma6*(-6.) /Helpers::pow(r,7) 155 ); 156 derivative_components_t results(1, result); 157 return results; 150 result_t result = 0.; 151 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 152 iter != listarguments.end(); ++iter) { 153 const arguments_t &arguments = *iter; 154 ASSERT( arguments.size() == 1, 155 "PairPotential_LennardJones::operator() - requires no argument."); 156 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 157 arguments, getParticleTypes()), 158 "PairPotential_LennardJones::operator() - types don't match with ones in arguments."); 159 const double &r = arguments[0].distance; 160 result += 161 4.*params[epsilon] * ( 162 sigma6*sigma6*(-12.) / Helpers::pow(r,13) 163 - sigma6*(-6.) /Helpers::pow(r,7) 164 ); 165 } 166 return derivative_components_t(1, result); 158 167 } 159 168 160 169 PairPotential_LennardJones::results_t 161 170 PairPotential_LennardJones::parameter_derivative( 162 const arguments_t &arguments,171 const list_of_arguments_t &listarguments, 163 172 const size_t index 164 173 ) const 165 174 { 166 ASSERT( arguments.size() == 1, 167 "PairPotential_LennardJones::parameter_derivative() - requires no argument."); 168 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 169 arguments, getParticleTypes()), 170 "PairPotential_LennardJones::operator() - types don't match with ones in arguments."); 171 const double &r = arguments[0].distance; 172 switch (index) { 173 case epsilon: 174 { 175 const double temp = Helpers::pow(params[sigma]/r, 6); 176 const result_t result = 4. * (temp*temp - temp); 177 return std::vector<result_t>(1, result); 178 break; 175 result_t result = 0.; 176 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 177 iter != listarguments.end(); ++iter) { 178 const arguments_t &arguments = *iter; 179 ASSERT( arguments.size() == 1, 180 "PairPotential_LennardJones::parameter_derivative() - requires no argument."); 181 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 182 arguments, getParticleTypes()), 183 "PairPotential_LennardJones::operator() - types don't match with ones in arguments."); 184 const double &r = arguments[0].distance; 185 switch (index) { 186 case epsilon: 187 { 188 const double temp = Helpers::pow(params[sigma]/r, 6); 189 result += 4. * (temp*temp - temp); 190 break; 191 } 192 case sigma: 193 { 194 const double r6 = Helpers::pow(r, 6); 195 result += 196 4.*params[epsilon] * ( 197 12. * Helpers::pow(params[sigma],11)/(r6*r6) 198 - 6. * Helpers::pow(params[sigma],5)/r6 199 ); 200 break; 201 } 202 default: 203 break; 179 204 } 180 case sigma:181 {182 const double r6 = Helpers::pow(r, 6);183 const result_t result =184 4.*params[epsilon] * (185 12. * Helpers::pow(params[sigma],11)/(r6*r6)186 - 6. * Helpers::pow(params[sigma],5)/r6187 );188 return std::vector<result_t>(1, result);189 break;190 }191 default:192 break;193 205 } 194 return std::vector<result_t>(1, 0.); 195 } 196 197 FunctionModel::extractor_t 198 PairPotential_LennardJones::getSpecificExtractor() const 199 { 200 Fragment::charges_t charges; 201 charges.resize(getParticleTypes().size()); 202 std::transform(getParticleTypes().begin(), getParticleTypes().end(), 203 charges.begin(), boost::lambda::_1); 204 FunctionModel::extractor_t returnfunction = 205 boost::bind(&Extractors::gatherDistancesFromFragment, 206 boost::bind(&Fragment::getPositions, _1), 207 boost::bind(&Fragment::getCharges, _1), 208 charges, 209 _2); 210 return returnfunction; 206 return results_t(1, result); 211 207 } 212 208 -
src/Potentials/Specifics/PairPotential_LennardJones.hpp
rc73e35 rd8821e 36 36 friend class PotentialFactory; 37 37 // some repeated typedefs to avoid ambiguities 38 typedef FunctionModel::list_of_arguments_t list_of_arguments_t; 38 39 typedef FunctionModel::arguments_t arguments_t; 39 40 typedef FunctionModel::result_t result_t; … … 92 93 /** Evaluates the harmonic potential function for the given arguments. 93 94 * 94 * @param arguments single distance95 * @param listarguments list of single distances 95 96 * @return value of the potential function 96 97 */ 97 results_t operator()(const arguments_t &arguments) const;98 results_t operator()(const list_of_arguments_t &listarguments) const; 98 99 99 100 /** Evaluates the derivative of the potential function. 100 101 * 101 * @param arguments single distance102 * @param listarguments list of single distances 102 103 * @return vector with derivative with respect to the input degrees of freedom 103 104 */ 104 derivative_components_t derivative(const arguments_t &arguments) const;105 derivative_components_t derivative(const list_of_arguments_t &listarguments) const; 105 106 106 107 /** Evaluates the derivative of the function with the given \a arguments 107 108 * with respect to a specific parameter indicated by \a index. 108 109 * 109 * \param arguments set of arguments as input variables to the function110 * \param listarguments list of single distances 110 111 * \param index derivative of which parameter 111 112 * \return result vector containing the derivative with respect to the given 112 113 * input 113 114 */ 114 results_t parameter_derivative(const arguments_t &arguments, const size_t index) const;115 results_t parameter_derivative(const list_of_arguments_t &listarguments, const size_t index) const; 115 116 116 117 /** Returns the functor that converts argument_s into the … … 165 166 return parameters_t(getParameterDimension(), std::numeric_limits<double>::max()); 166 167 } 167 168 /** Returns a bound function to be used with TrainingData, extracting distances169 * from a Fragment.170 *171 * \return bound function extracting distances from a fragment172 */173 FunctionModel::extractor_t getSpecificExtractor() const;174 168 175 169 /** Returns a bound function to be used with TrainingData, extracting distances -
src/Potentials/Specifics/PairPotential_Morse.cpp
rc73e35 rd8821e 124 124 PairPotential_Morse::results_t 125 125 PairPotential_Morse::operator()( 126 const arguments_t &arguments126 const list_of_arguments_t &listarguments 127 127 ) const 128 128 { 129 ASSERT( arguments.size() == 1, 130 "PairPotential_Morse::operator() - requires exactly one argument."); 131 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 132 arguments, getParticleTypes()), 133 "PairPotential_Morse::operator() - types don't match with ones in arguments."); 134 const argument_t &r_ij = arguments[0]; 135 // Maple: f(r,D,k,R,c) := D * (1 - exp(-k*(r-R)))^(2)+c 136 const result_t result = 137 params[dissociation_energy] * Helpers::pow( 1. 138 - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])),2); 129 result_t result = 0.; 130 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 131 iter != listarguments.end(); ++iter) { 132 const arguments_t &arguments = *iter; 133 ASSERT( arguments.size() == 1, 134 "PairPotential_Morse::operator() - requires exactly one argument."); 135 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 136 arguments, getParticleTypes()), 137 "PairPotential_Morse::operator() - types don't match with ones in arguments."); 138 const argument_t &r_ij = arguments[0]; 139 // Maple: f(r,D,k,R,c) := D * (1 - exp(-k*(r-R)))^(2)+c 140 result += 141 params[dissociation_energy] * Helpers::pow( 1. 142 - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])),2); 143 } 139 144 return std::vector<result_t>(1, result); 140 145 } … … 142 147 PairPotential_Morse::derivative_components_t 143 148 PairPotential_Morse::derivative( 144 const arguments_t &arguments149 const list_of_arguments_t &listarguments 145 150 ) const 146 151 { 147 ASSERT( arguments.size() == 1, 148 "PairPotential_Morse::operator() - requires exactly one argument."); 149 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 150 arguments, getParticleTypes()), 151 "PairPotential_Morse::operator() - types don't match with ones in arguments."); 152 derivative_components_t result; 153 const argument_t &r_ij = arguments[0]; 154 // Maple result: 2*D*(1-exp(-k*(r-R)))*k*exp(-k*(r-R)) 155 result.push_back( 156 2. * params[dissociation_energy] 157 * ( 1. - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance]))) 158 * (- params[spring_constant]) * exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])) 159 ); 160 ASSERT( result.size() == 1, 161 "PairPotential_Morse::operator() - we did not create exactly one component."); 162 return result; 152 result_t result = 0.; 153 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 154 iter != listarguments.end(); ++iter) { 155 const arguments_t &arguments = *iter; 156 ASSERT( arguments.size() == 1, 157 "PairPotential_Morse::operator() - requires exactly one argument."); 158 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 159 arguments, getParticleTypes()), 160 "PairPotential_Morse::operator() - types don't match with ones in arguments."); 161 const argument_t &r_ij = arguments[0]; 162 // Maple result: 2*D*(1-exp(-k*(r-R)))*k*exp(-k*(r-R)) 163 result += 164 2. * params[dissociation_energy] 165 * ( 1. - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance]))) 166 * (- params[spring_constant]) * exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])); 167 } 168 return derivative_components_t(1, result); 163 169 } 164 170 165 171 PairPotential_Morse::results_t 166 172 PairPotential_Morse::parameter_derivative( 167 const arguments_t &arguments,173 const list_of_arguments_t &listarguments, 168 174 const size_t index 169 175 ) const 170 176 { 171 ASSERT( arguments.size() == 1, 172 "PairPotential_Morse::parameter_derivative() - requires exactly one argument."); 173 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 174 arguments, getParticleTypes()), 175 "PairPotential_Morse::operator() - types don't match with ones in arguments."); 176 const argument_t &r_ij = arguments[0]; 177 switch (index) { 178 case spring_constant: 179 { 180 // Maple result: -2*D*(1-exp(-k*(r-R)))*(-r+R)*exp(-k*(r-R)) 181 const result_t result = 182 - 2. * params[dissociation_energy] 183 * ( 1. - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance]))) 184 * (- r_ij.distance + params[equilibrium_distance]) 185 * exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])) 186 ; 187 return std::vector<result_t>(1, result); 188 break; 177 result_t result = 0.; 178 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 179 iter != listarguments.end(); ++iter) { 180 const arguments_t &arguments = *iter; 181 ASSERT( arguments.size() == 1, 182 "PairPotential_Morse::parameter_derivative() - requires exactly one argument."); 183 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 184 arguments, getParticleTypes()), 185 "PairPotential_Morse::operator() - types don't match with ones in arguments."); 186 const argument_t &r_ij = arguments[0]; 187 switch (index) { 188 case spring_constant: 189 { 190 // Maple result: -2*D*(1-exp(-k*(r-R)))*(-r+R)*exp(-k*(r-R)) 191 result += 192 - 2. * params[dissociation_energy] 193 * ( 1. - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance]))) 194 * (- r_ij.distance + params[equilibrium_distance]) 195 * exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])) 196 ; 197 break; 198 } 199 case equilibrium_distance: 200 { 201 // Maple result: -2*D*(1-exp(-k*(r-R)))*k*exp(-k*(r-R)) 202 result += 203 - 2. * params[dissociation_energy] 204 * ( 1. - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance]))) 205 * params[spring_constant] * exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])) 206 ; 207 break; 208 } 209 case dissociation_energy: 210 { 211 // Maple result: (1-exp(-k*(r-R)))^2 212 result += 213 Helpers::pow(1. 214 - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])),2); 215 break; 216 } 217 default: 218 ASSERT(0, "PairPotential_Morse::parameter_derivative() - derivative to unknown parameter desired."); 219 break; 189 220 } 190 case equilibrium_distance:191 {192 // Maple result: -2*D*(1-exp(-k*(r-R)))*k*exp(-k*(r-R))193 const result_t result =194 - 2. * params[dissociation_energy]195 * ( 1. - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])))196 * params[spring_constant] * exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance]))197 ;198 return std::vector<result_t>(1, result);199 break;200 }201 case dissociation_energy:202 {203 // Maple result: (1-exp(-k*(r-R)))^2204 const result_t result =205 Helpers::pow(1.206 - exp( - params[spring_constant] * ( r_ij.distance - params[equilibrium_distance])),2);207 return std::vector<result_t>(1, result);208 break;209 }210 default:211 ASSERT(0, "PairPotential_Morse::parameter_derivative() - derivative to unknown parameter desired.");212 break;213 221 } 214 return std::vector<result_t>(1, 0.); 215 } 216 217 FunctionModel::extractor_t 218 PairPotential_Morse::getSpecificExtractor() const 219 { 220 Fragment::charges_t charges; 221 charges.resize(getParticleTypes().size()); 222 std::transform(getParticleTypes().begin(), getParticleTypes().end(), 223 charges.begin(), boost::lambda::_1); 224 FunctionModel::extractor_t returnfunction = 225 boost::bind(&Extractors::gatherDistancesFromFragment, 226 boost::bind(&Fragment::getPositions, _1), 227 boost::bind(&Fragment::getCharges, _1), 228 charges, 229 _2); 230 return returnfunction; 222 return results_t(1, result); 231 223 } 232 224 -
src/Potentials/Specifics/PairPotential_Morse.hpp
rc73e35 rd8821e 35 35 friend class PotentialFactory; 36 36 // some repeated typedefs to avoid ambiguities 37 typedef FunctionModel::list_of_arguments_t list_of_arguments_t; 37 38 typedef FunctionModel::arguments_t arguments_t; 38 39 typedef FunctionModel::result_t result_t; … … 91 92 /** Evaluates the harmonic potential function for the given arguments. 92 93 * 93 * @param arguments single distance94 * @param listarguments list of single distances 94 95 * @return value of the potential function 95 96 */ 96 results_t operator()(const arguments_t &arguments) const;97 results_t operator()(const list_of_arguments_t &listarguments) const; 97 98 98 99 /** Evaluates the derivative of the potential function. 99 100 * 100 * @param arguments single distance101 * @param listarguments list of single distances 101 102 * @return vector with derivative with respect to the input degrees of freedom 102 103 */ 103 derivative_components_t derivative(const arguments_t &arguments) const;104 derivative_components_t derivative(const list_of_arguments_t &listarguments) const; 104 105 105 106 /** Evaluates the derivative of the function with the given \a arguments 106 107 * with respect to a specific parameter indicated by \a index. 107 108 * 108 * \param arguments set of arguments as input variables to the function109 * \param listarguments list of single distances 109 110 * \param index derivative of which parameter 110 111 * \return result vector containing the derivative with respect to the given 111 112 * input 112 113 */ 113 results_t parameter_derivative(const arguments_t &arguments, const size_t index) const;114 results_t parameter_derivative(const list_of_arguments_t &listarguments, const size_t index) const; 114 115 115 116 /** Returns the functor that converts argument_s into the … … 165 166 return parameters_t(getParameterDimension(), std::numeric_limits<double>::max()); 166 167 } 167 168 /** Returns a bound function to be used with TrainingData, extracting distances169 * from a Fragment.170 *171 * \return bound function extracting distances from a fragment172 */173 FunctionModel::extractor_t getSpecificExtractor() const;174 168 175 169 /** Returns a bound function to be used with TrainingData, extracting distances -
src/Potentials/Specifics/ThreeBodyPotential_Angle.cpp
rc73e35 rd8821e 136 136 ThreeBodyPotential_Angle::results_t 137 137 ThreeBodyPotential_Angle::operator()( 138 const arguments_t &arguments138 const list_of_arguments_t &listarguments 139 139 ) const 140 140 { 141 ASSERT( arguments.size() == 3, 142 "ThreeBodyPotential_Angle::operator() - requires exactly three arguments."); 143 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 144 arguments, getParticleTypes()), 145 "ThreeBodyPotential_Angle::operator() - types don't match with ones in arguments."); 146 const argument_t &r_ij = arguments[0]; // 01 147 const argument_t &r_jk = arguments[2]; // 12 148 const argument_t &r_ik = arguments[1]; // 02 149 const result_t result = 150 params[spring_constant] 151 * Helpers::pow( function_theta(r_ij.distance, r_jk.distance, r_ik.distance) - params[equilibrium_distance], 2 ); 152 return std::vector<result_t>(1, result); 141 result_t result = 0.; 142 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 143 iter != listarguments.end(); ++iter) { 144 const arguments_t &arguments = *iter; 145 ASSERT( arguments.size() == 3, 146 "ThreeBodyPotential_Angle::operator() - requires exactly three arguments."); 147 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 148 arguments, getParticleTypes()), 149 "ThreeBodyPotential_Angle::operator() - types don't match with ones in arguments."); 150 const argument_t &r_ij = arguments[0]; // 01 151 const argument_t &r_jk = arguments[2]; // 12 152 const argument_t &r_ik = arguments[1]; // 02 153 result += 154 params[spring_constant] 155 * Helpers::pow( function_theta(r_ij.distance, r_jk.distance, r_ik.distance) 156 - params[equilibrium_distance], 2 ); 157 } 158 return results_t(1, result); 153 159 } 154 160 155 161 ThreeBodyPotential_Angle::derivative_components_t 156 162 ThreeBodyPotential_Angle::derivative( 157 const arguments_t &arguments163 const list_of_arguments_t &listarguments 158 164 ) const 159 165 { 160 ASSERT( arguments.size() == 3, 161 "ThreeBodyPotential_Angle::operator() - requires exactly three arguments."); 162 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 163 arguments, getParticleTypes()), 164 "ThreeBodyPotential_Angle::operator() - types don't match with ones in arguments."); 165 derivative_components_t result; 166 const argument_t &r_ij = arguments[0]; //01 167 const argument_t &r_jk = arguments[2]; //12 168 const argument_t &r_ik = arguments[1]; //02 169 result.push_back( 2. * params[spring_constant] * ( function_theta(r_ij.distance, r_jk.distance, r_ik.distance) - params[equilibrium_distance]) ); 170 ASSERT( result.size() == 1, 171 "ThreeBodyPotential_Angle::operator() - we did not create exactly one component."); 172 return result; 166 result_t result = 0.; 167 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 168 iter != listarguments.end(); ++iter) { 169 const arguments_t &arguments = *iter; 170 ASSERT( arguments.size() == 3, 171 "ThreeBodyPotential_Angle::operator() - requires exactly three arguments."); 172 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 173 arguments, getParticleTypes()), 174 "ThreeBodyPotential_Angle::operator() - types don't match with ones in arguments."); 175 const argument_t &r_ij = arguments[0]; //01 176 const argument_t &r_jk = arguments[2]; //12 177 const argument_t &r_ik = arguments[1]; //02 178 result += 179 2. * params[spring_constant] * 180 ( function_theta(r_ij.distance, r_jk.distance, r_ik.distance) 181 - params[equilibrium_distance]); 182 } 183 return derivative_components_t(1, result); 173 184 } 174 185 175 186 ThreeBodyPotential_Angle::results_t 176 187 ThreeBodyPotential_Angle::parameter_derivative( 177 const arguments_t &arguments,188 const list_of_arguments_t &listarguments, 178 189 const size_t index 179 190 ) const 180 191 { 181 ASSERT( arguments.size() == 3, 182 "ThreeBodyPotential_Angle::parameter_derivative() - requires exactly three arguments."); 183 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 184 arguments, getParticleTypes()), 185 "ThreeBodyPotential_Angle::operator() - types don't match with ones in arguments."); 186 const argument_t &r_ij = arguments[0]; //01 187 const argument_t &r_jk = arguments[2]; //12 188 const argument_t &r_ik = arguments[1]; //02 189 switch (index) { 190 case spring_constant: 191 { 192 const result_t result = 193 Helpers::pow( function_theta(r_ij.distance, r_jk.distance, r_ik.distance) - params[equilibrium_distance], 2 ); 194 return std::vector<result_t>(1, result); 195 break; 192 result_t result = 0.; 193 for(list_of_arguments_t::const_iterator iter = listarguments.begin(); 194 iter != listarguments.end(); ++iter) { 195 const arguments_t &arguments = *iter; 196 ASSERT( arguments.size() == 3, 197 "ThreeBodyPotential_Angle::parameter_derivative() - requires exactly three arguments."); 198 ASSERT( ParticleTypeChecker::checkArgumentsAgainstParticleTypes( 199 arguments, getParticleTypes()), 200 "ThreeBodyPotential_Angle::operator() - types don't match with ones in arguments."); 201 const argument_t &r_ij = arguments[0]; //01 202 const argument_t &r_jk = arguments[2]; //12 203 const argument_t &r_ik = arguments[1]; //02 204 switch (index) { 205 case spring_constant: 206 { 207 result += 208 Helpers::pow( function_theta(r_ij.distance, r_jk.distance, r_ik.distance) - params[equilibrium_distance], 2 ); 209 break; 210 } 211 case equilibrium_distance: 212 { 213 result += 214 -2. * params[spring_constant] 215 * ( function_theta(r_ij.distance, r_jk.distance, r_ik.distance) - params[equilibrium_distance]); 216 break; 217 } 218 default: 219 ASSERT(0, "ThreeBodyPotential_Angle::parameter_derivative() - derivative to unknown parameter desired."); 220 break; 196 221 } 197 case equilibrium_distance:198 {199 const result_t result =200 -2. * params[spring_constant]201 * ( function_theta(r_ij.distance, r_jk.distance, r_ik.distance) - params[equilibrium_distance]);202 return std::vector<result_t>(1, result);203 break;204 }205 default:206 ASSERT(0, "ThreeBodyPotential_Angle::parameter_derivative() - derivative to unknown parameter desired.");207 break;208 222 } 209 return std::vector<result_t>(1); 210 } 211 212 FunctionModel::extractor_t 213 ThreeBodyPotential_Angle::getSpecificExtractor() const 214 { 215 Fragment::charges_t charges; 216 charges.resize(getParticleTypes().size()); 217 std::transform(getParticleTypes().begin(), getParticleTypes().end(), 218 charges.begin(), boost::lambda::_1); 219 FunctionModel::extractor_t returnfunction = 220 boost::bind(&Extractors::gatherDistancesFromFragment, 221 boost::bind(&Fragment::getPositions, _1), 222 boost::bind(&Fragment::getCharges, _1), 223 charges, 224 _2); 225 return returnfunction; 223 return results_t(1, result); 226 224 } 227 225 -
src/Potentials/Specifics/ThreeBodyPotential_Angle.hpp
rc73e35 rd8821e 35 35 friend class PotentialFactory; 36 36 // some repeated typedefs to avoid ambiguities 37 typedef FunctionModel::list_of_arguments_t list_of_arguments_t; 37 38 typedef FunctionModel::arguments_t arguments_t; 38 39 typedef FunctionModel::result_t result_t; … … 90 91 /** Evaluates the harmonic potential function for the given arguments. 91 92 * 92 * @param arguments single distance93 * @param listarguments list of three distances 93 94 * @return value of the potential function 94 95 */ 95 results_t operator()(const arguments_t &arguments) const;96 results_t operator()(const list_of_arguments_t &listarguments) const; 96 97 97 98 /** Evaluates the derivative of the potential function. 98 99 * 99 * @param arguments single distance100 * @param listarguments list of three distances 100 101 * @return vector with derivative with respect to the input degrees of freedom 101 102 */ 102 derivative_components_t derivative(const arguments_t &arguments) const;103 derivative_components_t derivative(const list_of_arguments_t &listarguments) const; 103 104 104 105 /** Evaluates the derivative of the function with the given \a arguments 105 106 * with respect to a specific parameter indicated by \a index. 106 107 * 107 * \param arguments set of arguments as input variables to the function108 * \param listarguments list of three distances 108 109 * \param index derivative of which parameter 109 110 * \return result vector containing the derivative with respect to the given 110 111 * input 111 112 */ 112 results_t parameter_derivative(const arguments_t &arguments, const size_t index) const;113 results_t parameter_derivative(const list_of_arguments_t &listarguments, const size_t index) const; 113 114 114 115 /** Returns the functor that converts argument_s into the … … 166 167 return upperbounds; 167 168 } 168 169 /** Returns a bound function to be used with TrainingData, extracting distances170 * from a Fragment.171 *172 * \return bound function extracting distances from a fragment173 */174 FunctionModel::extractor_t getSpecificExtractor() const;175 169 176 170 /** Returns a bound function to be used with TrainingData, extracting distances -
src/Potentials/Specifics/unittests/ConstantPotentialUnitTest.cpp
rc73e35 rd8821e 82 82 Helpers::isEqual( 83 83 offset, 84 constant( FunctionModel:: arguments_t() )[0]84 constant( FunctionModel::list_of_arguments_t() )[0] 85 85 ) 86 86 ); … … 97 97 0., 98 98 constant.derivative( 99 FunctionModel:: arguments_t()99 FunctionModel::list_of_arguments_t() 100 100 )[0] 101 101 ) … … 114 114 1., 115 115 constant.parameter_derivative( 116 FunctionModel:: arguments_t(),116 FunctionModel::list_of_arguments_t(), 117 117 0 118 118 )[0] -
src/Potentials/Specifics/unittests/FourBodyPotential_ImproperUnitTest.cpp
rc73e35 rd8821e 121 121 for (size_t index = 0; index < input.size(); ++index) { 122 122 const FourBodyPotential_Improper::results_t result = 123 angle( input[index]);123 angle( FunctionModel::list_of_arguments_t(1, input[index]) ); 124 124 CPPUNIT_ASSERT( 125 125 Helpers::isEqual( … … 144 144 0., 145 145 angle.derivative( 146 input[5]146 FunctionModel::list_of_arguments_t(1, input[5]) 147 147 )[0], 148 148 10. … … 165 165 0., 166 166 angle.parameter_derivative( 167 input[5],167 FunctionModel::list_of_arguments_t(1, input[5]), 168 168 0 169 169 )[0], … … 175 175 0., 176 176 angle.parameter_derivative( 177 input[5],177 FunctionModel::list_of_arguments_t(1, input[5]), 178 178 1 179 179 )[0], -
src/Potentials/Specifics/unittests/FourBodyPotential_TorsionUnitTest.cpp
rc73e35 rd8821e 121 121 for (size_t index = 0; index < input.size(); ++index) { 122 122 const FourBodyPotential_Torsion::results_t result = 123 angle( input[index]);123 angle( FunctionModel::list_of_arguments_t(1, input[index]) ); 124 124 CPPUNIT_ASSERT( 125 125 Helpers::isEqual( … … 144 144 0., 145 145 angle.derivative( 146 input[5]146 FunctionModel::list_of_arguments_t(1, input[5]) 147 147 )[0], 148 148 10. … … 165 165 0., 166 166 angle.parameter_derivative( 167 input[5],167 FunctionModel::list_of_arguments_t(1, input[5]), 168 168 0 169 169 )[0], … … 175 175 0., 176 176 angle.parameter_derivative( 177 input[5],177 FunctionModel::list_of_arguments_t(1, input[5]), 178 178 1 179 179 )[0], -
src/Potentials/Specifics/unittests/Makefile.am
rc73e35 rd8821e 38 38 POTENTIALSSPECIFICSLIBS = \ 39 39 ../libMolecuilderPotentials.la \ 40 ../libMolecuilderFragmentationSetValues.la \41 40 ../libMolecuilderFragmentation.la \ 42 41 ../libMolecuilderFunctionApproximation.la \ 43 42 ../libMolecuilderRandomNumbers.la \ 43 ../libMolecuilderFragmentationSummation.la \ 44 ../libMolecuilderFragmentation_getFromKeysetStub.la \ 44 45 $(top_builddir)/LinearAlgebra/src/LinearAlgebra/libLinearAlgebra.la \ 45 46 ${CodePatterns_LIBS} \ -
src/Potentials/Specifics/unittests/ManyBodyPotential_TersoffUnitTest.cpp
rc73e35 rd8821e 299 299 arg.globalid = index; // this is needed for the triplefunction to the configuration 300 300 FunctionModel::arguments_t args(1,arg); 301 const ManyBodyPotential_Tersoff::results_t res = tersoff(args); 301 const ManyBodyPotential_Tersoff::results_t res = 302 tersoff( FunctionModel::list_of_arguments_t(1, args) ); 302 303 temp += res[0]; 303 304 } … … 336 337 // 0., 337 338 // tersoff.derivative( 338 // FunctionModel:: arguments_t(1,argument_t(1.))339 // FunctionModel::list_of_arguments_t(1, FunctionModel::arguments_t(1,argument_t(1.))) 339 340 // )[0] 340 341 // ) … … 361 362 // 0., 362 363 // tersoff.parameter_derivative( 363 // FunctionModel:: arguments_t(1,argument_t(1.)),364 // FunctionModel::list_of_arguments_t(1, FunctionModel::arguments_t(1,argument_t(1.))), 364 365 // 0 365 366 // )[0] … … 370 371 // 0., 371 372 // tersoff.parameter_derivative( 372 // FunctionModel:: arguments_t(1,argument_t(1.)),373 // FunctionModel::list_of_arguments_t(1, FunctionModel::arguments_t(1,argument_t(1.))), 373 374 // 1 374 375 // )[0] … … 379 380 // 1., 380 381 // tersoff.parameter_derivative( 381 // FunctionModel:: arguments_t(1,argument_t(1.)),382 // FunctionModel::list_of_arguments_t(1, FunctionModel::arguments_t(1,argument_t(1.))), 382 383 // 2 383 384 // )[0] -
src/Potentials/Specifics/unittests/PairPotential_HarmonicUnitTest.cpp
rc73e35 rd8821e 102 102 Helpers::isEqual( 103 103 output[index], 104 harmonic( FunctionModel:: arguments_t(1,arg) )[0]104 harmonic( FunctionModel::list_of_arguments_t(1, FunctionModel::arguments_t(1,arg)) )[0] 105 105 ) 106 106 ); … … 122 122 0., 123 123 harmonic.derivative( 124 FunctionModel:: arguments_t(1,arg)124 FunctionModel::list_of_arguments_t(1, FunctionModel::arguments_t(1,arg)) 125 125 )[0] 126 126 ) … … 143 143 0., 144 144 harmonic.parameter_derivative( 145 FunctionModel:: arguments_t(1,arg),145 FunctionModel::list_of_arguments_t(1, FunctionModel::arguments_t(1,arg)), 146 146 0 147 147 )[0] … … 152 152 0., 153 153 harmonic.parameter_derivative( 154 FunctionModel:: arguments_t(1,arg),154 FunctionModel::list_of_arguments_t(1, FunctionModel::arguments_t(1,arg)), 155 155 1 156 156 )[0] -
src/Potentials/Specifics/unittests/PairPotential_LennardJonesUnitTest.cpp
rc73e35 rd8821e 118 118 Helpers::isEqual( 119 119 output[index], 120 lj( FunctionModel:: arguments_t(1,arg) )[0],120 lj( FunctionModel::list_of_arguments_t(1, FunctionModel::arguments_t(1,arg)) )[0], 121 121 1.e-4/std::numeric_limits<double>::epsilon() // only compare four digits 122 122 ) … … 140 140 0., 141 141 lj.derivative( 142 FunctionModel:: arguments_t(1,arg)142 FunctionModel::list_of_arguments_t(1, FunctionModel::arguments_t(1,arg)) 143 143 )[0], 144 144 1.e+6 … … 162 162 -1., 163 163 lj.parameter_derivative( 164 FunctionModel:: arguments_t(1,arg),164 FunctionModel::list_of_arguments_t(1, FunctionModel::arguments_t(1,arg)), 165 165 0 166 166 )[0], … … 172 172 0., 173 173 lj.parameter_derivative( 174 FunctionModel:: arguments_t(1,arg),174 FunctionModel::list_of_arguments_t(1, FunctionModel::arguments_t(1,arg)), 175 175 1 176 176 )[0], -
src/Potentials/Specifics/unittests/PairPotential_MorseUnitTest.cpp
rc73e35 rd8821e 120 120 Helpers::isEqual( 121 121 output[index], 122 Morse( FunctionModel:: arguments_t(1,arg) )[0],122 Morse( FunctionModel::list_of_arguments_t(1, FunctionModel::arguments_t(1,arg)) )[0], 123 123 1.e-4/std::numeric_limits<double>::epsilon() // only compare four digits 124 124 ) … … 141 141 0., 142 142 Morse.derivative( 143 FunctionModel:: arguments_t(1,arg)143 FunctionModel::list_of_arguments_t(1, FunctionModel::arguments_t(1,arg)) 144 144 )[0], 145 145 1.e+6 … … 163 163 0., 164 164 Morse.parameter_derivative( 165 FunctionModel:: arguments_t(1,arg),165 FunctionModel::list_of_arguments_t(1, FunctionModel::arguments_t(1,arg)), 166 166 0 167 167 )[0], … … 173 173 0., 174 174 Morse.parameter_derivative( 175 FunctionModel:: arguments_t(1,arg),175 FunctionModel::list_of_arguments_t(1, FunctionModel::arguments_t(1,arg)), 176 176 1 177 177 )[0], … … 183 183 0., 184 184 Morse.parameter_derivative( 185 FunctionModel:: arguments_t(1,arg),185 FunctionModel::list_of_arguments_t(1, FunctionModel::arguments_t(1,arg)), 186 186 2 187 187 )[0], -
src/Potentials/Specifics/unittests/ThreeBodyPotential_AngleUnitTest.cpp
rc73e35 rd8821e 112 112 for (size_t index = 0; index < input.size(); ++index) { 113 113 const ThreeBodyPotential_Angle::results_t result = 114 angle( input[index]);114 angle( FunctionModel::list_of_arguments_t(1, input[index]) ); 115 115 CPPUNIT_ASSERT( 116 116 Helpers::isEqual( … … 135 135 0., 136 136 angle.derivative( 137 input[5]137 FunctionModel::list_of_arguments_t(1, input[5]) 138 138 )[0], 139 139 10. … … 156 156 0., 157 157 angle.parameter_derivative( 158 input[5],158 FunctionModel::list_of_arguments_t(1, input[5]), 159 159 0 160 160 )[0], … … 166 166 0., 167 167 angle.parameter_derivative( 168 input[5],168 FunctionModel::list_of_arguments_t(1, input[5]), 169 169 1 170 170 )[0], -
src/Potentials/helpers.hpp
rc73e35 rd8821e 108 108 } 109 109 110 inline FunctionModel::list_of_arguments_t 111 returnEmptyListArguments() 112 { 113 return FunctionModel::list_of_arguments_t(); 114 } 115 110 116 }; /* namespace Helpers */ 111 117 -
src/Potentials/unittests/CompoundPotentialUnitTest.cpp
rc73e35 rd8821e 159 159 argument_t firstarg(argument_t::indices_t(0,1), argument_t::types_t(0,1), input[index]); 160 160 argument_t secondarg(argument_t::indices_t(0,2), argument_t::types_t(0,1), input[index]); 161 FunctionModel:: arguments_targs;162 args += firstarg,secondarg;163 const double result = compound( args )[0];161 FunctionModel::list_of_arguments_t listargs; 162 listargs += FunctionModel::arguments_t(1,firstarg),FunctionModel::arguments_t(1,secondarg); 163 const double result = compound( listargs )[0]; 164 164 CPPUNIT_ASSERT( 165 165 Helpers::isEqual( … … 205 205 argument_t firstarg(argument_t::indices_t(0,1), argument_t::types_t(0,1), c); 206 206 argument_t secondarg(argument_t::indices_t(0,2), argument_t::types_t(0,1), c); 207 FunctionModel:: arguments_targs;208 args += firstarg,secondarg;209 { 210 const double result = 211 compound.parameter_derivative( 212 args,207 FunctionModel::list_of_arguments_t listargs; 208 listargs += FunctionModel::arguments_t(1,firstarg),FunctionModel::arguments_t(1,secondarg); 209 { 210 const double result = 211 compound.parameter_derivative( 212 listargs, 213 213 0)[0]; 214 214 CPPUNIT_ASSERT( … … 223 223 const double result = 224 224 compound.parameter_derivative( 225 args,225 listargs, 226 226 1)[0]; 227 227 CPPUNIT_ASSERT( … … 236 236 const double result = 237 237 compound.parameter_derivative( 238 args,238 listargs, 239 239 2)[0]; 240 240 CPPUNIT_ASSERT( … … 249 249 const double result = 250 250 compound.parameter_derivative( 251 args,251 listargs, 252 252 3)[0]; 253 253 CPPUNIT_ASSERT( -
src/Potentials/unittests/Makefile.am
rc73e35 rd8821e 34 34 ../libMolecuilderPotentials.la \ 35 35 ../libMolecuilderFragmentation.la \ 36 ../libMolecuilderFunctionApproximation.la \ 36 37 ../libMolecuilderFragmentationSummation.la \ 37 ../libMolecuilderFunctionApproximation.la \38 38 ../libMolecuilderFragmentation_getFromKeysetStub.la \ 39 39 ../libMolecuilderRandomNumbers.la \ -
src/UIElements/CommandLineUI/CommandLineWindow.cpp
rc73e35 rd8821e 73 73 if (AQ.isActionKnownByName(*CommandRunner)) { 74 74 // LOG1, "INFO: Checking presence of " << *CommandRunner << ": " << "queuing."); 75 AQ.queueAction(*CommandRunner); 75 if (AQ.getLastActionOk()) 76 AQ.queueAction(*CommandRunner); 77 else 78 LOG(1, "INFO: Skipping " << *CommandRunner << " as last action failed."); 76 79 } else { 77 80 // LOG(1, "INFO: Checking presence of " << *CommandRunner << ": " << "absent."); -
src/UIElements/Makefile.am
rc73e35 rd8821e 254 254 libMolecuilderGraph.la \ 255 255 libMolecuilderFilling.la \ 256 libMolecuilder.la 256 libMolecuilder.la \ 257 libMolecuilderFragmentationAutomation.la \ 258 libMolecuilderFragmentation_getFromKeyset.la \ 259 libMolecuilderFragmentation.la \ 260 libMolecuilderJobs.la 257 261 if CONDJOBMARKET 258 262 libMolecuilderUI_la_LIBADD += \ 259 libMolecuilderFragmentationAutomation.la260 endif261 libMolecuilderUI_la_LIBADD += \262 libMolecuilderFragmentation_getFromKeyset.la \263 libMolecuilderFragmentation.la264 if CONDJOBMARKET265 libMolecuilderUI_la_LIBADD += \266 libMolecuilderJobs.la \267 263 ${JobMarket_Controller_LIBS} 268 264 endif -
src/UIElements/Views/Qt4/QtHomologyList.cpp
rc73e35 rd8821e 184 184 if (!data.getTrainingInputs().empty()) { 185 185 // generate QSeisData 186 const TrainingData::InputVector_t &inputs = data.get TrainingInputs();186 const TrainingData::InputVector_t &inputs = data.getAllArguments(); 187 187 const TrainingData::OutputVector_t &outputs = data.getTrainingOutputs(); 188 188 std::vector<double> xvalues; -
src/cleanUp.cpp
rc73e35 rd8821e 51 51 #include "Actions/OptionRegistry.hpp" 52 52 53 #include "Fragmentation/Summation/Containers/FragmentationResultContainer.hpp" 54 53 55 #include "RandomNumbers/RandomNumberDistributionFactory.hpp" 54 56 #include "RandomNumbers/RandomNumberEngineFactory.hpp" … … 93 95 { 94 96 // make sure that ActionQueue is already purged! 95 97 FragmentationResultContainer::purgeInstance(); 96 98 Chronos::purgeInstance(); 97 99 RandomNumberDistributionFactory::purgeInstance(); -
src/documentation/constructs/potentials.dox
rc73e35 rd8821e 72 72 * perform the fit. 73 73 * 74 * \section potentials-fit-potential-action What happens in FitPotentialAction. 75 * 76 * First, either a potential file is parsed via PotentialDeserializer or charges 77 * and a potential type from the given options. This is used to instantiate 78 * EmpiricalPotentials via the PotentialFactory, stored within the 79 * PotentialRegistry. This is the available set of potentials (without requiring 80 * any knowledge as to the nature of the fragment employed in fitting). 81 * 82 * Second, the given fragment is used to get a suitable HomologyGraph from 83 * the World's HomologyContainer. This is given to a CompoundPotential, that in 84 * turn browses through the PotentialRegistry, picking out those 85 * EmpiricalPotential's that match with a subset of the FragmentNode's of the 86 * given graph. These are stored as a list of FunctionModel's within the 87 * CompoundPotential instance. Here comes the specific fragment into play, 88 * picking a subset from the available potentials. 89 * 90 * Third, we need to setup the training data. For this we need vectors of input 91 * and output data that are obtained from the HomologyContainer with the 92 * HomologyGraph as key. The output vector in our case is simply a number 93 * (although the interface allows for more). The input vector is the set of 94 * distances. In order to pre-process the input data for the specific model 95 * a filter is required in the TrainingData's constructor. The purpose of the 96 * filter is to pick out the subset of distance arguments for each model one 97 * after the other and concatenate them to a list. On evaluation of the model 98 * this concatenated list of distances is given to the model and it may easily 99 * dissect the list and hand over each contained potential its subset of 100 * arguments. See Extractors for more information. 101 * 102 * Afterwards, training may commence: The goal is to find a set of parameters 103 * for the model such that it as good as possible reproduces the output vector 104 * for a given input vector. This non-linear regression is contained in the 105 * levmar package and its functionality is wrapped in the FunctionApproximation 106 * class. An instance is initialized with both the gathered training data and 107 * the model containing a list of potentials. See 108 * [FunctionApproximation-details] for more details. 109 * 110 * During the fitting procedure, first the derivatives of the model is checked 111 * for consistency, then the model is initialized with a sensible guess of 112 * starting parameters, and afterwards the Levenberg-Marquardt algorithm 113 * commences that makes numerous calls to evaluate the model and its derivative 114 * to find the minimum in the L2-norm. 115 * 116 * This is done more than once as high-dimensional regression is sensititive the 117 * the starting values as there are possible numerous local minima. The lowest 118 * of the found minima is taken, either via a given threshold or the best of a 119 * given number of attempts. 120 * 121 * Eventually, these parameters of the best model are streamed via 122 * PotentialSerializer back into a potential file. Each EmpiricalPotential in 123 * the CompoundPotential making up the whole model is also a 124 * SerializablePotential. Hence, each in turn writes a single line with its 125 * respective subset of parameters and particle types, describing this 126 * particular fit function. 127 * 128 * \section potentials-function-evaluation How does the model evaluation work 129 * 130 * We now come to the question of how the model and its derivative are actually 131 * evaluated. We have an input vector from the training data and we have the 132 * model with a specific set of parameters. 133 * 134 * FunctionModel is just an abstract interface that is implemented by the 135 * potential functions, such as CompoundPotential, that combines multiple 136 * potentials into a single function for fitting, or PairPotential_Harmonic, 137 * that is a specific fit function for harmonic bonds. 138 * 139 * The main issue with the evaluation is picking the right set of distances from 140 * ones given in the input vector and feed it to each potential contained in 141 * CompoundPotential. Note that the distances have already been prepared by 142 * the TrainingData instantiation. 143 * 144 * Initially, the HomologyGraph only contains a list of configurations of a 145 * specific fragments (i.e. the position of each atom in the fragment) and an 146 * energy value. These first have to be converted into distances. 147 * 148 * 74 149 * \section potentials-howto-use Howto use the potentials 75 150 * -
tests/Fragmentations/Makefile.am
rc73e35 rd8821e 4 4 testsuite.at \ 5 5 $(TESTSUITE) \ 6 analyzer.in \7 6 atlocal.in \ 8 joiner.in \9 7 molecuilder.in \ 10 8 package.m4 \ 11 $(srcdir)/Analyzing/heptan \12 9 $(srcdir)/Fragmenting/1_2-dimethoxyethane \ 13 10 $(srcdir)/Fragmenting/1_2-dimethylbenzene \ … … 28 25 $(srcdir)/Fragmenting/proline \ 29 26 $(srcdir)/Fragmenting/putrescine \ 30 $(srcdir)/Fragmenting/tartaric_acid \ 31 $(srcdir)/Joining/heptan 27 $(srcdir)/Fragmenting/tartaric_acid 32 28 33 29 TESTSUITE = $(srcdir)/testsuite … … 139 135 Fragmenting/tartaric_acid/testsuite-fragmenting-tartaric_acid-order4.at \ 140 136 Fragmenting/tartaric_acid/testsuite-fragmenting-tartaric_acid-order5.at \ 141 Fragmenting/tartaric_acid/testsuite-fragmenting-tartaric_acid-order6.at \ 142 Joining/heptan/testsuite-joining-heptan.at \ 143 Analyzing/heptan/testsuite-analyzing-heptan.at 137 Fragmenting/tartaric_acid/testsuite-fragmenting-tartaric_acid-order6.at 144 138 145 139 max_jobs = 4 -
tests/Fragmentations/testsuite.at
rc73e35 rd8821e 185 185 m4_include(Fragmenting/tartaric_acid/testsuite-fragmenting-tartaric_acid-order5.at) 186 186 m4_include(Fragmenting/tartaric_acid/testsuite-fragmenting-tartaric_acid-order6.at) 187 188 # Joining of heptan189 m4_include(Joining/heptan/testsuite-joining-heptan.at)190 191 # Analyzing of heptan192 m4_include(Analyzing/heptan/testsuite-analyzing-heptan.at) -
tests/Makefile.am
rc73e35 rd8821e 2 2 3 3 SUBDIRS += \ 4 Calculations \ 4 5 CodeChecks \ 5 6 regression \ … … 8 9 Python \ 9 10 JobMarket 11 12 .PHONY: extracheck installextracheck 13 14 extracheck: 15 cd Calculations && make extracheck 16 installextracheck: 17 cd Calculations && make installextracheck -
tests/regression/Fragmentation/testsuite-fragmentation.at
rc73e35 rd8821e 30 30 # check storing saturated fragment 31 31 m4_include([Fragmentation/StoreSaturatedFragment/testsuite-fragmentation-store-saturated-fragment.at]) 32 33 # check automation 34 m4_include([Fragmentation/FragmentationAutomation/testsuite-fragmentation-fragmentation-automation.at]) -
tests/regression/Makefile.am
rc73e35 rd8821e 72 72 $(srcdir)/Fragmentation/testsuite-fragmentation.at \ 73 73 $(srcdir)/Fragmentation/AnalyseFragmentationResults/testsuite-fragmentation-analyse-fragment-results.at \ 74 $(srcdir)/Fragmentation/FragmentationAutomation/testsuite-fragmentation-fragmentation-automation.at \ 74 75 $(srcdir)/Fragmentation/FragmentMolecule/testsuite-fragmentation-fragment-molecule.at \ 75 76 $(srcdir)/Fragmentation/FragmentMolecule-MaxOrder/testsuite-fragmentation-fragment-molecule-maxorder.at \
Note:
See TracChangeset
for help on using the changeset viewer.