forked from PetroleumCyberneticsGroup/FieldOpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
84 changed files
with
17,211 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "FieldOpt/WellIndexCalculator"] | ||
path = FieldOpt/WellIndexCalculator | ||
url = [email protected]:PetroleumCyberneticsGroup/WellIndexCalculator.git | ||
[submodule "FieldOpt/AdgprsSummaryConverter"] | ||
path = FieldOpt/AdgprsSummaryConverter | ||
url = [email protected]:PetroleumCyberneticsGroup/AdgprsSummaryConverter.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
include(../defaults.pri) | ||
|
||
CONFIG -= app_bundle | ||
CONFIG += c++11 | ||
TEMPLATE = lib | ||
|
||
LIBS += -lhdf5_cpp | ||
|
||
TARGET = adgprsresultsreader | ||
|
||
SOURCES += \ | ||
json_summary_reader.cpp \ | ||
adgprs_results_reader.cpp | ||
|
||
HEADERS += \ | ||
json_summary_reader.h \ | ||
adgprs_results_reader.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "adgprs_results_reader.h" | ||
#include <QStringList> | ||
#include "Utilities/unix/execution.h" | ||
#include "Utilities/file_handling/filehandling.h" | ||
|
||
namespace AdgprsResultsReader { | ||
|
||
AdgprsResultsReader::AdgprsResultsReader(QString summary_path) | ||
{ | ||
hdf5_path_ = summary_path; | ||
json_path_ = summary_path.split(".SIM.H5").first() + ".json"; | ||
convertHdfSummaryToJson(); | ||
json_reader_ = new JsonSummaryReader(json_path_); | ||
} | ||
|
||
void AdgprsResultsReader::convertHdfSummaryToJson() | ||
{ | ||
QString conversion_script_path = Utilities::FileHandling::GetBuildDirectoryPath() + "/AdgprsSummaryConverter/AdgprsSummaryConverter.py"; | ||
QStringList params = {hdf5_path_, json_path_}; | ||
Utilities::Unix::ExecShellScript(conversion_script_path, params); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef ADGPRSRESULTSREADER_H | ||
#define ADGPRSRESULTSREADER_H | ||
|
||
#include <QString> | ||
#include "json_summary_reader.h" | ||
|
||
namespace AdgprsResultsReader { | ||
|
||
class AdgprsResultsReader | ||
{ | ||
public: | ||
/*! | ||
* \brief AdgprsResultsReader | ||
* \param summary_path Path to a ADGPRS summary file in the HDF5 format, including the .SIM.H5 suffix. | ||
*/ | ||
AdgprsResultsReader(QString summary_path); | ||
|
||
/*! | ||
* \brief results Get the object allowing access to the results. | ||
* \return | ||
*/ | ||
JsonSummaryReader *results() const { return json_reader_; } | ||
|
||
private: | ||
QString hdf5_path_; | ||
QString json_path_; | ||
JsonSummaryReader *json_reader_; | ||
|
||
void convertHdfSummaryToJson(); | ||
|
||
}; | ||
|
||
} | ||
#endif // ADGPRSRESULTSREADER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
#include "json_summary_reader.h" | ||
#include <stdexcept> | ||
#include <iostream> | ||
#include <QJsonDocument> | ||
#include <QJsonArray> | ||
#include <QFile> | ||
#include <QList> | ||
#include <stdexcept> | ||
#include <cmath> | ||
|
||
namespace AdgprsResultsReader { | ||
|
||
JsonSummaryReader::JsonSummaryReader(QString file_path) | ||
{ | ||
QFile *file = new QFile(file_path); | ||
if (!file->open(QIODevice::ReadOnly)) | ||
throw std::runtime_error("Unable to open JSON summary file " + file_path.toStdString()); | ||
QByteArray data = file->readAll(); | ||
QJsonDocument json = QJsonDocument::fromJson(data); | ||
if (json.isNull()) | ||
throw std::runtime_error("Unable to parse the JSON summary file " + file_path.toStdString()); | ||
if (!json.isObject()) | ||
throw std::runtime_error("The json summary must be a valid json object " + file_path.toStdString()); | ||
|
||
QJsonObject json_summary = QJsonObject(json.object()); | ||
readGlobal(json_summary["Field"].toObject()); | ||
readFieldProps(json_summary["Field"].toObject()["Properties"].toObject()); | ||
readWellProps(json_summary["Wells"].toArray()); | ||
file->close(); | ||
|
||
} | ||
|
||
QList<QString> JsonSummaryReader::GetAvalableFieldPropertyNames() const | ||
{ | ||
return field_properties_.keys(); | ||
} | ||
|
||
QVector<double> *JsonSummaryReader::GetFieldProperty(QString prop_name) const | ||
{ | ||
if (QString::compare(prop_name, "TIME") == 0) | ||
return time_; | ||
if (!field_properties_.contains(prop_name)) | ||
throw std::runtime_error("Field property " + prop_name.toStdString() + " not recognized."); | ||
return field_properties_[prop_name]; | ||
} | ||
|
||
QList<QString> JsonSummaryReader::GetAvailableWellPropertyNames() const | ||
{ | ||
return getWell(0)->properties_.keys(); | ||
} | ||
|
||
QVector<double> *JsonSummaryReader::GetWellProperty(int well, QString prop_name) const | ||
{ | ||
if (!getWell(well)->properties_.contains(prop_name)) | ||
throw std::runtime_error("Well property " + prop_name.toStdString() + " not recognized."); | ||
return getWell(well)->properties_[prop_name]; | ||
} | ||
|
||
bool JsonSummaryReader::IsInjector(int well) const | ||
{ | ||
return getWell(well)->is_injector; | ||
} | ||
|
||
int JsonSummaryReader::GetNumberOfPerforations(int well) const | ||
{ | ||
return getWell(well)->num_perforations; | ||
} | ||
|
||
JsonSummaryReader::WellData *JsonSummaryReader::getWell(int well) const | ||
{ | ||
if (well < 0 || well >= wells_.size()) | ||
throw std::runtime_error(QString::number(well).toStdString() + " not a valid well number."); | ||
return wells_[well]; | ||
} | ||
|
||
void JsonSummaryReader::readGlobal(QJsonObject field) | ||
{ | ||
num_wells_ = field["NumWells"].toInt(); | ||
|
||
time_ = new QVector<double>(); | ||
QJsonArray json_time = field["TIME"].toArray(); | ||
foreach (QJsonValue t, json_time) { | ||
time_->append(t.toDouble()); | ||
} | ||
} | ||
|
||
void JsonSummaryReader::readFieldProps(QJsonObject field_props) | ||
{ | ||
field_properties_ = QHash<QString, QVector<double> *>(); | ||
QList<QString> keys = {"FGPT", "FOPT", "FWPT", "FOPR", "FGPR", "FWPR", | ||
"FGIT", "FGIR", "FOIT", "FOIR", "FWIT", "FWIR"}; | ||
|
||
foreach (QString key, keys) { | ||
field_properties_[key] = new QVector<double>(); | ||
foreach (QJsonValue v, field_props[key].toArray()) { | ||
field_properties_[key]->append(std::abs(v.toDouble())); | ||
} | ||
} | ||
} | ||
|
||
void JsonSummaryReader::readWellProps(QJsonArray well_props) | ||
{ | ||
foreach (QJsonValue w, well_props) { | ||
WellData *data = new WellData(); | ||
if (w.toObject()["IsInjector"].toInt() == 1) | ||
data->is_injector = true; | ||
else | ||
data->is_injector = false; | ||
|
||
data->num_perforations = w.toObject()["NumPerforations"].toInt(); | ||
|
||
data->properties_ = QHash<QString, QVector<double> *>(); | ||
QList<QString> keys = {"WBHP","WGR","WOR","WWR","WGT","WOT","WWT"}; | ||
foreach (QString key, keys) { | ||
data->properties_[key] = new QVector<double>(); | ||
foreach (QJsonValue v, w.toObject()["Properties"].toObject()[key].toArray()) { | ||
data->properties_[key]->append(v.toDouble()); | ||
} | ||
} | ||
wells_.append(data); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#ifndef JSON_SUMMARY_READER_H | ||
#define JSON_SUMMARY_READER_H | ||
|
||
#include <QString> | ||
#include <QVector> | ||
#include <QHash> | ||
#include <QJsonObject> | ||
|
||
namespace AdgprsResultsReader { | ||
|
||
/*! | ||
* \brief The JsonSummaryReader class reads the JSON summary files created | ||
* by the AdgprsSummaryConverter pythnon script. This class should not be instantiated directly. | ||
* | ||
* \note All field values are absolute values. I.e. borth production and injection numbers will | ||
* be positive. | ||
*/ | ||
class JsonSummaryReader | ||
{ | ||
public: | ||
/*! | ||
* \brief JsonSummaryReader reads the summary file and stores the data in arrays. | ||
* \param file_path Path to a valid .json file. | ||
*/ | ||
JsonSummaryReader(QString file_path); | ||
|
||
/*! | ||
* \brief GetNumberOfWells Returns the number of wells found in the summary. | ||
*/ | ||
int GetNumberOfWells() const { return num_wells_; } | ||
|
||
/*! | ||
* \brief GetTimeVector Get the time vector for the summary data. | ||
*/ | ||
QVector<double> *GetTimeVector() const { return time_; } | ||
|
||
/*! | ||
* \brief GetAvalableFieldPropertyNames Get a list of all the valid field property names. | ||
*/ | ||
QList<QString> GetAvalableFieldPropertyNames() const; | ||
|
||
/*! | ||
* \brief GetFieldProperty Returns a data vector for a specific property. | ||
* \param prop_name name of the property, using the ECLIPSE summary naming scheme (e.g. FOPT, FWPR). | ||
*/ | ||
QVector<double> *GetFieldProperty(QString prop_name) const; | ||
|
||
/*! | ||
* \brief GetAvailableWellPropertyNames Get a list of all the valid well property names. | ||
*/ | ||
QList<QString> GetAvailableWellPropertyNames() const; | ||
|
||
/*! | ||
* \brief GetWellProperty Returns a data vector for a specific property for a specific well. | ||
* \param well The number of the well to get data from. | ||
* \param prop_name The name of the property to get. | ||
*/ | ||
QVector<double> *GetWellProperty(int well, QString prop_name) const; | ||
|
||
/*! | ||
* \brief IsInjector Check if a well is an injector. | ||
* \param well The number of the well to check. | ||
*/ | ||
bool IsInjector(int well) const; | ||
|
||
/*! | ||
* \brief GetNumberOfPerforations Get the number of perforations in a specific well. | ||
* \param well The number of the well to check. | ||
*/ | ||
int GetNumberOfPerforations(int well) const; | ||
|
||
|
||
private: | ||
struct WellData { | ||
bool is_injector; | ||
int num_perforations; | ||
QHash<QString, QVector<double> *> properties_; | ||
}; | ||
|
||
QVector<double> *time_; | ||
int num_wells_; | ||
|
||
QHash<QString, QVector<double> *> field_properties_; | ||
QList<WellData *> wells_; | ||
WellData *getWell(int well) const; | ||
|
||
void readGlobal(QJsonObject field); | ||
void readFieldProps(QJsonObject field_props); | ||
void readWellProps(QJsonArray well_props); | ||
}; | ||
|
||
} | ||
|
||
#endif // JSON_SUMMARY_READER_H |
Submodule AdgprsSummaryConverter
added at
577fc4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
FieldOpt/GTest/AdgprsResultsReader/test_adgprs_results_reader.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "GTest/Simulation/results/test_fixture_adgprs.h" | ||
#include "AdgprsResultsReader/adgprs_results_reader.h" | ||
|
||
namespace { | ||
|
||
class AdgprsResultsReaderTest : public AdgprsTestFixture { | ||
protected: | ||
AdgprsResultsReaderTest() { | ||
reader_ = new AdgprsResultsReader::AdgprsResultsReader(hdf5_summary_path_); | ||
} | ||
virtual ~AdgprsResultsReaderTest() {} | ||
virtual void SetUp() {} | ||
AdgprsResultsReader::AdgprsResultsReader *reader_; | ||
}; | ||
|
||
TEST_F(AdgprsResultsReaderTest, Global) { | ||
EXPECT_EQ(5, reader_->results()->GetNumberOfWells()); | ||
} | ||
|
||
} | ||
|
||
|
Oops, something went wrong.