ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
core/accumulators/TimeSeries.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include "AccumulatorBase.hpp"
23#include "observables/Observable.hpp"
24
25#include <cstddef>
26#include <memory>
27#include <string>
28#include <utility>
29#include <vector>
30
31namespace Accumulators {
32
33/**
34 * @brief Record values of an observable.
35 *
36 * This is a very simple accumulator that stores
37 * the current value of an observable every time
38 * it is updated.
39 *
40 */
42public:
44 std::shared_ptr<Observables::Observable> obs)
45 : AccumulatorBase(system, delta_N), m_obs(std::move(obs)) {}
46
47 void update(boost::mpi::communicator const &comm) override;
48 std::string get_internal_state() const final;
49 void set_internal_state(std::string const &) final;
50
51 const std::vector<std::vector<double>> &time_series() const { return m_data; }
52 std::vector<std::size_t> shape() const override {
53 std::vector<std::size_t> shape{m_data.size()};
54 auto obs_shape = m_obs->shape();
55 shape.insert(shape.end(), obs_shape.begin(), obs_shape.end());
56 return shape;
57 }
58 void clear() { m_data.clear(); }
59
60private:
61 std::shared_ptr<Observables::Observable> m_obs;
62 std::vector<std::vector<double>> m_data;
63};
64
65} // namespace Accumulators
Record values of an observable.
std::vector< std::size_t > shape() const override
void update(boost::mpi::communicator const &comm) override
TimeSeries(::System::System const *system, int delta_N, std::shared_ptr< Observables::Observable > obs)
void set_internal_state(std::string const &) final
std::string get_internal_state() const final
const std::vector< std::vector< double > > & time_series() const
Main system class.