Reaktoro
A unified framework for modeling chemically reactive systems
ChemicalPlot.hpp
1 // Reaktoro is a unified framework for modeling chemically reactive systems.
2 //
3 // Copyright (C) 2014-2018 Allan Leal
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library. If not, see <http://www.gnu.org/licenses/>.
17 
18 #pragma once
19 
20 // C++ includes
21 #include <memory>
22 #include <vector>
23 #include <sstream>
24 #include <string>
25 
26 namespace Reaktoro {
27 
28 // Forward declarations
29 class ChemicalState;
30 class ChemicalSystem;
31 class ReactionSystem;
32 class StringList;
33 
36 {
37 public:
39  ChemicalPlot();
40 
42  explicit ChemicalPlot(const ChemicalSystem& system);
43 
45  explicit ChemicalPlot(const ReactionSystem& reactions);
46 
48  virtual ~ChemicalPlot();
49 
51  auto name(std::string name) -> void;
52 
59  auto x(std::string quantity) -> void;
60 
70  auto y(std::string quantity) -> void;
71 
82  auto y(std::string quantity, std::string label) -> void;
83 
89  auto points(std::string label, std::vector<double> xpoints, std::vector<double> ypoints) -> void;
90 
95  auto points(std::string label, std::string xpoints, std::string ypoints) -> void;
96 
104  auto legend(std::string) -> void;
105 
107  auto showlegend(bool active) -> void;
108 
110  auto showlegend() const -> bool;
111 
113  auto title(std::string title) -> void;
114 
117  auto xlabel(std::string) -> void;
118 
121  auto ylabel(std::string) -> void;
122 
125  auto xtics(std::string) -> void;
126 
129  auto ytics(std::string) -> void;
130 
144  auto xformat(std::string) -> void;
145 
159  auto yformat(std::string) -> void;
160 
162  auto xlogscale(int base=10) -> void;
163 
165  auto ylogscale(int base=10) -> void;
166 
168  auto frequency(unsigned frequency) -> void;
169 
171  auto operator<<(std::string command) -> ChemicalPlot&;
172 
174  auto operator<<(std::stringstream command) -> ChemicalPlot&;
175 
177  auto open() -> void;
178 
180  auto update(const ChemicalState& state, double t) -> void;
181 
183  auto operator==(const ChemicalPlot& other) -> bool;
184 
185 private:
186  struct Impl;
187 
188  std::shared_ptr<Impl> pimpl;
189 };
190 
191 } // namespace Reaktoro
auto x(std::string quantity) -> void
Set the quantity to be plotted along the x-axis.
Definition: ChemicalPlot.cpp:355
auto xlabel(std::string) -> void
Set the label of the x-axis.
Definition: ChemicalPlot.cpp:408
auto ytics(std::string) -> void
Set the tics of the y-axis.
Definition: ChemicalPlot.cpp:425
auto operator==(const ChemicalPlot &other) -> bool
Compare a ChemicalPlot instance for equality.
Definition: ChemicalPlot.cpp:477
virtual ~ChemicalPlot()
Destroy this ChemicalPlot instance.
Definition: ChemicalPlot.cpp:347
auto xtics(std::string) -> void
Set the tics of the x-axis.
Definition: ChemicalPlot.cpp:420
auto xformat(std::string) -> void
Set the numeric display format of the x-axis.
Definition: ChemicalPlot.cpp:430
A class to represent a system and its attributes and properties.
Definition: ChemicalSystem.hpp:38
Provides a computational representation of the state of a multiphase chemical system.
Definition: ChemicalState.hpp:61
auto name(std::string name) -> void
Set the name of the plot and the file names exported.
Definition: ChemicalPlot.cpp:350
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
auto title(std::string title) -> void
Set the title of the plot.
Definition: ChemicalPlot.cpp:403
auto ylabel(std::string) -> void
Set the label of the y-axis.
Definition: ChemicalPlot.cpp:414
auto operator<<(std::string command) -> ChemicalPlot &
Inject a gnuplot command to the script file.
Definition: ChemicalPlot.cpp:455
auto y(std::string quantity) -> void
Add a quantity to be plotted along the y-axis.
Definition: ChemicalPlot.cpp:360
auto points(std::string label, std::vector< double > xpoints, std::vector< double > ypoints) -> void
Add discrete points in the plot.
Definition: ChemicalPlot.cpp:370
A class that represents a system of chemical reactions.
Definition: ReactionSystem.hpp:42
auto ylogscale(int base=10) -> void
Set the y-axis to log-scale.
Definition: ChemicalPlot.cpp:445
auto frequency(unsigned frequency) -> void
Set the refresh rate of the real-time plot.
Definition: ChemicalPlot.cpp:450
auto yformat(std::string) -> void
Set the numeric display format of the y-axis.
Definition: ChemicalPlot.cpp:435
auto open() -> void
Open the plot.
Definition: ChemicalPlot.cpp:467
ChemicalPlot()
Construct a default ChemicalPlot instance.
Definition: ChemicalPlot.cpp:335
auto xlogscale(int base=10) -> void
Set the x-axis to log-scale.
Definition: ChemicalPlot.cpp:440
A class used to create plots from sequence of chemical states.
Definition: ChemicalPlot.hpp:36
auto legend(std::string) -> void
Set the legend options.
Definition: ChemicalPlot.cpp:387
auto update(const ChemicalState &state, double t) -> void
Update the plot with a new chemical state and a tag.
Definition: ChemicalPlot.cpp:472
auto showlegend() const -> bool
Return true if legend should be displayed in the plot.
Definition: ChemicalPlot.cpp:398