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