| 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 | // obtain information | 
|---|
| 45 | getParametersfromValueStorage(); | 
|---|
| 46 |  | 
|---|
| 47 |  | 
|---|
| 48 | LOG(1, "Parsing forces file and Verlet integrating."); | 
|---|
| 49 | // TODO: sollte besser stream nutzen, nicht filename direkt (es sei denn, ist prefix), besser fuer unit test | 
|---|
| 50 | char outputname[MAXSTRINGSIZE]; | 
|---|
| 51 | strcpy(outputname, params.forcesfile.string().c_str()); | 
|---|
| 52 | AtomSetMixin<std::vector<atom *> > set(World::getInstance().getSelectedAtoms()); | 
|---|
| 53 | for (int step = 0; step < params.MDSteps; ++step) { | 
|---|
| 54 | VerletForceIntegration<std::vector<atom *> > Verlet(set, params.Deltat, step, false); | 
|---|
| 55 | if (!Verlet(outputname, 1, 0, params.FixedCenterOfMass)) | 
|---|
| 56 | LOG(2, "File " << params.forcesfile << " not found."); | 
|---|
| 57 | else | 
|---|
| 58 | LOG(2, "File " << params.forcesfile << " found and parsed."); | 
|---|
| 59 | } | 
|---|
| 60 |  | 
|---|
| 61 | return Action::success; | 
|---|
| 62 | } | 
|---|
| 63 |  | 
|---|
| 64 | Action::state_ptr MoleculeVerletIntegrationAction::performUndo(Action::state_ptr _state) { | 
|---|
| 65 | //  MoleculeVerletIntegrationState *state = assert_cast<MoleculeVerletIntegrationState*>(_state.get()); | 
|---|
| 66 |  | 
|---|
| 67 | //  string newName = state->mol->getName(); | 
|---|
| 68 | //  state->mol->setName(state->lastName); | 
|---|
| 69 |  | 
|---|
| 70 | return Action::failure; | 
|---|
| 71 | } | 
|---|
| 72 |  | 
|---|
| 73 | Action::state_ptr MoleculeVerletIntegrationAction::performRedo(Action::state_ptr _state){ | 
|---|
| 74 | return Action::failure; | 
|---|
| 75 | } | 
|---|
| 76 |  | 
|---|
| 77 | bool MoleculeVerletIntegrationAction::canUndo() { | 
|---|
| 78 | return true; | 
|---|
| 79 | } | 
|---|
| 80 |  | 
|---|
| 81 | bool MoleculeVerletIntegrationAction::shouldUndo() { | 
|---|
| 82 | return true; | 
|---|
| 83 | } | 
|---|
| 84 | /** =========== end of function ====================== */ | 
|---|