[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() {
|
---|
[1fd675] | 44 | // obtain information
|
---|
| 45 | getParametersfromValueStorage();
|
---|
[97ebf8] | 46 |
|
---|
[435065] | 47 |
|
---|
[47d041] | 48 | LOG(1, "Parsing forces file and Verlet integrating.");
|
---|
[435065] | 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))
|
---|
[47d041] | 56 | LOG(2, "File " << params.forcesfile << " not found.");
|
---|
[97ebf8] | 57 | else
|
---|
[47d041] | 58 | LOG(2, "File " << params.forcesfile << " found and parsed.");
|
---|
[97ebf8] | 59 | }
|
---|
[435065] | 60 |
|
---|
[bcd16a] | 61 | return Action::success;
|
---|
[97ebf8] | 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){
|
---|
[e69c87] | 74 | return Action::failure;
|
---|
[97ebf8] | 75 | }
|
---|
| 76 |
|
---|
| 77 | bool MoleculeVerletIntegrationAction::canUndo() {
|
---|
[e69c87] | 78 | return true;
|
---|
[97ebf8] | 79 | }
|
---|
| 80 |
|
---|
| 81 | bool MoleculeVerletIntegrationAction::shouldUndo() {
|
---|
[e69c87] | 82 | return true;
|
---|
[97ebf8] | 83 | }
|
---|
[1fd675] | 84 | /** =========== end of function ====================== */
|
---|