[bcf653] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
| 4 | * Copyright (C) 2010 University of Bonn. All rights reserved.
|
---|
| 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 |
|
---|
[435065] | 22 | #include "atom.hpp"
|
---|
| 23 | #include "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 |
|
---|
| 35 | using namespace std;
|
---|
| 36 |
|
---|
[1fd675] | 37 | #include "Actions/MoleculeAction/VerletIntegrationAction.hpp"
|
---|
[bcd16a] | 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 |
|
---|
| 48 | DoLog(1) && (Log() << Verbose(1) << "Parsing forces file and Verlet integrating." << endl);
|
---|
| 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))
|
---|
[1fd675] | 56 | DoLog(2) && (Log() << Verbose(2) << "File " << params.forcesfile << " not found." << endl);
|
---|
[97ebf8] | 57 | else
|
---|
[1fd675] | 58 | DoLog(2) && (Log() << Verbose(2) << "File " << params.forcesfile << " found and parsed." << endl);
|
---|
[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){
|
---|
| 74 | // Undo and redo have to do the same for this action
|
---|
| 75 | return performUndo(_state);
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | bool MoleculeVerletIntegrationAction::canUndo() {
|
---|
| 79 | return false;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | bool MoleculeVerletIntegrationAction::shouldUndo() {
|
---|
| 83 | return false;
|
---|
| 84 | }
|
---|
[1fd675] | 85 | /** =========== end of function ====================== */
|
---|