Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// MatData.h
#pragma once
#include "pugixml.hpp"
#include "Logger.h"
#include "Station.h"
#include "Channel.h"
#include "Options.h"
#include <ctime>
namespace math1d_cl
{
typedef std::vector<std::pair<time_t ,std::vector<double>>> precipitationsVector;
///
/// Main class of Math1D model that contains whole data structure and methods to run computation of model.
///
class MatData
{
public:
//MatData(); ///< Constructor
///
/// Constructor. Param fileName is filename/path to XML file with schematization modifications.
///
MatData(std::string fileName);
///
/// Copy constructor
///
MatData(const MatData& origin);
///
/// Starts model computation
///
int runRR();
///
/// Computes RR model
///
void rainfallRunoffModel();
///
/// Returns date and time in format dd.mm.yyyy hh:mm
///
std::string printDateTime(const time_t& dateTime);
// Getters & Setters
std::vector<std::shared_ptr<Station>>& getSourceStations();
void setSourceStations(const std::vector<std::shared_ptr<Station>>& sourceStations);
std::vector<std::shared_ptr<Station>>& getRiverStations();
void setRiverStations(const std::vector<std::shared_ptr<Station>>& riverStations);
const int& getBasinId();
void setBasinId(const int& basinId);
std::vector<std::shared_ptr<Station>>& getWeatherStations();
void setWeatherStations(const std::vector<std::shared_ptr<Station>>& weatherStations);
std::vector<std::shared_ptr<Channel>>& getChannels();
void setChannels(const std::vector<std::shared_ptr<Channel>>& channels);
std::vector<std::shared_ptr<Subbasin>>& getSubbasins();
void setSubbasins(const std::vector<std::shared_ptr<Subbasin>>& subbasins);
precipitationsVector getPrecipitations();
void setPrecipitations(const precipitationsVector precipitations);
Options& getOptions();
void setOptions(Options options);
// Getters for model results
std::vector<std::vector<double>> getMeasuredHydrographsQ();
std::vector<std::shared_ptr<Station>>& getMeasureStations();
// Search getters
std::shared_ptr<Channel> getChannelById(int id);
std::shared_ptr<Subbasin> getSubbasinById(int id);
///
/// Loads input data from CSV files and schematization from XML file.
///
void collectMatDataCsv();
///
/// Check Flood Warning levels exceeding (SPA) in simulated discharge volumes
//
int checkFWL();
private:
///
/// Implementation of SCS-CN Method
///
void scsMethod(std::vector<double>& q, size_t& index);
///
/// Sets default options of model
///
void setOptions();
///
/// Converts integer to string
///
std::string intToString(const int& number);
///
/// Loads measured discharge volumes and creates 2d vector of values
///
void loadSchematization();
///
/// Loads stations data from XML and creates stations object
///
void loadStationsFromXml(std::vector<std::shared_ptr<Station>>& stations, pugi::xml_node& xml_stations);
///
/// Loads channels data from XML and creates channels object
///
void loadChannelsFromXml(std::vector<std::shared_ptr<Channel>>& channels, pugi::xml_node& xml_channels);
///
/// Loads subbasins data from XML and creates subbasins object
///
void loadSubbasinsFromXml(std::vector<std::shared_ptr<Subbasin>>& subbasins, pugi::xml_node& xml_subbasins);
///
/// Loads measured discharge volumes and creates 2d vector of values
///
void loadMeasuredDischargeVolumesFromCsv();
///
/// Loads precipitations and creates 2d vector of time and values
///
void loadPrecipitationsFromCsv();
///
/// Compute measured Hydrographs
///
void getMeasuredHydrographs();
///
/// Finds station by given id in collection of Stations
///
std::shared_ptr<Station> findStation(std::vector<std::shared_ptr<Station>>&, int& id);
///
/// Converts Q to H
///
std::vector<double> qToH(std::vector<double>& q, std::shared_ptr<Channel> channel, int& rectangleProfile);
///
/// Computes velocity
///
double velocity(std::shared_ptr<Channel> channel);
///
/// Fitting (Calibration in matlab code) sets alpha and beta to params passed by reference.
///
void fit(double& alpha, double& beta, std::vector<double>& x, std::vector<double>& y, std::vector<double>& wage);
///
/// Saves results as CSV files
///
void collectRRResultCsv();
///
/// Clear results
///
void clearResults();
/// Members
std::vector<std::shared_ptr<Station>> m_sourceStations;
std::vector<std::shared_ptr<Station>> m_riverStations;
int m_basinId;
std::vector<std::shared_ptr<Station>> m_weatherStations; ///< Contains only Id, Name, Code, Location in MatData.mat
std::vector<std::shared_ptr<Station>> m_measureStations;
//std::vector<int> m_measureStations;
std::vector<std::shared_ptr<Channel>> m_channels;
std::vector<std::shared_ptr<Subbasin>> m_subbasins;
std::vector<std::vector<double>> m_measuredDischargeVolumes;
precipitationsVector m_precipitations;
std::vector<std::vector<double>> m_measuredHydrographsQ;
Options m_options;
std::string m_configFilePath;
std::string m_matDataXmlFilePath;
std::string m_measuredDischargeVolumesCsvFilePath;
std::string m_precipitationsCsvFilePath;
std::string m_qCsvFilePath;
std::string m_hCsvFilePath;
std::string m_vCsvFilePath;
int m_nTimeSteps;
int m_minuteStep;
std::vector<int> m_precStationIds;
std::vector<int> m_mdvStationIds;
//std::vector<int> m_times;
//bool m_checkModifications;
//pugi::xml_parse_result m_schemaConfig;
bool m_simulationDone = false;
};
}