| 1 | /*
 | 
|---|
| 2 |  * Project: MoleCuilder
 | 
|---|
| 3 |  * Description: creates and alters molecular systems
 | 
|---|
| 4 |  * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
 | 
|---|
| 5 |  * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
 | 
|---|
| 6 |  */
 | 
|---|
| 7 | 
 | 
|---|
| 8 | /*
 | 
|---|
| 9 |  * VerletIntegrationAction.cpp
 | 
|---|
| 10 |  *
 | 
|---|
| 11 |  *  Created on: May 10, 2010
 | 
|---|
| 12 |  *      Author: heber
 | 
|---|
| 13 |  */
 | 
|---|
| 14 | 
 | 
|---|
| 15 | // include config.h
 | 
|---|
| 16 | #ifdef HAVE_CONFIG_H
 | 
|---|
| 17 | #include <config.h>
 | 
|---|
| 18 | #endif
 | 
|---|
| 19 | 
 | 
|---|
| 20 | #include "CodePatterns/MemDebug.hpp"
 | 
|---|
| 21 | 
 | 
|---|
| 22 | #include "Atom/atom.hpp"
 | 
|---|
| 23 | #include "Atom/AtomSet.hpp"
 | 
|---|
| 24 | #include "CodePatterns/Log.hpp"
 | 
|---|
| 25 | #include "CodePatterns/Verbose.hpp"
 | 
|---|
| 26 | #include "Dynamics/VerletForceIntegration.hpp"
 | 
|---|
| 27 | #include "molecule.hpp"
 | 
|---|
| 28 | #include "World.hpp"
 | 
|---|
| 29 | 
 | 
|---|
| 30 | #include <vector>
 | 
|---|
| 31 | #include <iostream>
 | 
|---|
| 32 | #include <fstream>
 | 
|---|
| 33 | #include <string>
 | 
|---|
| 34 | 
 | 
|---|
| 35 | #include "Actions/MoleculeAction/VerletIntegrationAction.hpp"
 | 
|---|
| 36 | 
 | 
|---|
| 37 | using namespace MoleCuilder;
 | 
|---|
| 38 | 
 | 
|---|
| 39 | // and construct the stuff
 | 
|---|
| 40 | #include "VerletIntegrationAction.def"
 | 
|---|
| 41 | #include "Action_impl_pre.hpp"
 | 
|---|
| 42 | /** =========== define the function ====================== */
 | 
|---|
| 43 | Action::state_ptr MoleculeVerletIntegrationAction::performCall() {
 | 
|---|
| 44 |   LOG(1, "Parsing forces file and Verlet integrating.");
 | 
|---|
| 45 |   // TODO: sollte besser stream nutzen, nicht filename direkt (es sei denn, ist prefix), besser fuer unit test
 | 
|---|
| 46 |   char outputname[MAXSTRINGSIZE];
 | 
|---|
| 47 |   strcpy(outputname, params.forcesfile.string().c_str());
 | 
|---|
| 48 |   AtomSetMixin<std::vector<atom *> > set(World::getInstance().getSelectedAtoms());
 | 
|---|
| 49 |   for (int step = 0; step < params.MDSteps; ++step) {
 | 
|---|
| 50 |     VerletForceIntegration<std::vector<atom *> > Verlet(set, params.Deltat, step, false);
 | 
|---|
| 51 |     if (!Verlet(outputname, 1, 0, params.FixedCenterOfMass))
 | 
|---|
| 52 |       LOG(2, "File " << params.forcesfile << " not found.");
 | 
|---|
| 53 |     else
 | 
|---|
| 54 |       LOG(2, "File " << params.forcesfile << " found and parsed.");
 | 
|---|
| 55 |   }
 | 
|---|
| 56 | 
 | 
|---|
| 57 |   return Action::success;
 | 
|---|
| 58 | }
 | 
|---|
| 59 | 
 | 
|---|
| 60 | Action::state_ptr MoleculeVerletIntegrationAction::performUndo(Action::state_ptr _state) {
 | 
|---|
| 61 | //  MoleculeVerletIntegrationState *state = assert_cast<MoleculeVerletIntegrationState*>(_state.get());
 | 
|---|
| 62 | 
 | 
|---|
| 63 | //  string newName = state->mol->getName();
 | 
|---|
| 64 | //  state->mol->setName(state->lastName);
 | 
|---|
| 65 | 
 | 
|---|
| 66 |   return Action::failure;
 | 
|---|
| 67 | }
 | 
|---|
| 68 | 
 | 
|---|
| 69 | Action::state_ptr MoleculeVerletIntegrationAction::performRedo(Action::state_ptr _state){
 | 
|---|
| 70 |   return Action::failure;
 | 
|---|
| 71 | }
 | 
|---|
| 72 | 
 | 
|---|
| 73 | bool MoleculeVerletIntegrationAction::canUndo() {
 | 
|---|
| 74 |   return true;
 | 
|---|
| 75 | }
 | 
|---|
| 76 | 
 | 
|---|
| 77 | bool MoleculeVerletIntegrationAction::shouldUndo() {
 | 
|---|
| 78 |   return true;
 | 
|---|
| 79 | }
 | 
|---|
| 80 | /** =========== end of function ====================== */
 | 
|---|