source: src/Actions/MoleculeAction/SaveEnergiesAction.cpp@ d40189

Candidate_v1.7.0 stable
Last change on this file since d40189 was d40189, checked in by Frederik Heber <frederik.heber@…>, 5 years ago

OutputTemperature -> OutputEnergies, SaveTemperature -> SaveEnergies.

  • added force and momentum calculation.
  • TESTS: adapted test.ekin test file and integration/MolecularDynamics tests.
  • DOCU: Adapted userguide for changed action.
  • Property mode set to 100644
File size: 2.9 KB
RevLine 
[bcf653]1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
[0aa122]4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
[d40189]5 * Copyright (C) 2019 Frederik Heber
[94d5ac6]6 *
7 *
8 * This file is part of MoleCuilder.
9 *
10 * MoleCuilder is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * MoleCuilder is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
[bcf653]22 */
23
[97ebf8]24/*
[d40189]25 * SaveEnergiesAction.cpp
[97ebf8]26 *
27 * Created on: May 10, 2010
28 * Author: heber
29 */
30
[bf3817]31// include config.h
32#ifdef HAVE_CONFIG_H
33#include <config.h>
34#endif
35
[9eb71b3]36//#include "CodePatterns/MemDebug.hpp"
[112b09]37
[6f0841]38#include "Atom/atom.hpp"
39#include "Atom/AtomSet.hpp"
[ad011c]40#include "CodePatterns/Log.hpp"
41#include "CodePatterns/Verbose.hpp"
[d40189]42#include "Dynamics/OutputEnergies.hpp"
[8009ce]43#include "molecule.hpp"
[1a3c26]44#include "World.hpp"
[97ebf8]45
46#include <iostream>
47#include <fstream>
48#include <string>
[8009ce]49#include <vector>
[97ebf8]50
[d40189]51#include "Actions/MoleculeAction/SaveEnergiesAction.hpp"
[09cf39]52
[ce7fdc]53using namespace MoleCuilder;
54
[1fd675]55// and construct the stuff
[d40189]56#include "SaveEnergiesAction.def"
[1fd675]57#include "Action_impl_pre.hpp"
58/** =========== define the function ====================== */
[d40189]59ActionState::ptr MoleculeSaveEnergiesAction::performCall() {
60 LOG(1, "Storing temperatures in " << params.energiesfile.get() << ".");
[8009ce]61 ofstream output;
[d40189]62 output.open(params.energiesfile.get().string().c_str(), ios::trunc);
[99db9b]63 AtomSetMixin<std::vector<const atom *> > set =
64 const_cast<const World &>(World::getInstance()).getSelectedAtoms();
[8009ce]65 const size_t MDSteps = set.getMaxTrajectorySize();
[d40189]66 OutputEnergies<std::vector<const atom *> > writer(set);
[26b4d62]67 if (output.fail() || !writer((ofstream * const) &output, 0, MDSteps)) {
68 STATUS("File could not be written.");
69 return Action::failure;
70 } else
[47d041]71 LOG(2, "File stored.");
[8009ce]72 output.close();
[09cf39]73 return Action::success;
[97ebf8]74}
75
[d40189]76ActionState::ptr MoleculeSaveEnergiesAction::performUndo(ActionState::ptr _state) {
77// MoleculeSaveEnergiesState *state = assert_cast<MoleculeSaveEnergiesState*>(_state.get());
[97ebf8]78
79// string newName = state->mol->getName();
80// state->mol->setName(state->lastName);
81
[26b4d62]82 return Action::success;
[97ebf8]83}
84
[d40189]85ActionState::ptr MoleculeSaveEnergiesAction::performRedo(ActionState::ptr _state){
[97ebf8]86 // Undo and redo have to do the same for this action
87 return performUndo(_state);
88}
89
[d40189]90bool MoleculeSaveEnergiesAction::canUndo() {
[97ebf8]91 return false;
92}
93
[d40189]94bool MoleculeSaveEnergiesAction::shouldUndo() {
[97ebf8]95 return false;
96}
[1fd675]97/** =========== end of function ====================== */
Note: See TracBrowser for help on using the repository browser.