Skip to content

Commit

Permalink
WIP in supporting WINJGAS
Browse files Browse the repository at this point in the history
  • Loading branch information
GitPaean committed Nov 11, 2024
1 parent 7f35201 commit 5f80b49
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
7 changes: 7 additions & 0 deletions opm/input/eclipse/Schedule/Well/Well.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ class Well {

double rsRvInj;

// injection stream compostion for compositional simulation
std::optional<std::vector<double>> gas_inj_composition{};

bool operator==(const WellInjectionProperties& other) const;
bool operator!=(const WellInjectionProperties& other) const;

Expand Down Expand Up @@ -226,6 +229,8 @@ class Well {
void update_uda(const UDQConfig& udq_config, UDQActive& udq_active, UDAControl control, const UDAValue& value);
void handleWTMULT(Well::WELTARGCMode cmode, double factor);

void setGasInjComposition(const std::vector<double>& composition);

template<class Serializer>
void serializeOp(Serializer& serializer)
{
Expand All @@ -244,6 +249,7 @@ class Well {
serializer(injectorType);
serializer(controlMode);
serializer(rsRvInj);
serializer(gas_inj_composition);
}
};

Expand Down Expand Up @@ -562,6 +568,7 @@ class Well {
double inj_temperature() const;
bool hasInjTemperature() const;
void setWellInjTemperature(const double temp);
void setGasInjComposition(const std::vector<double>& composition);
bool hasInjected( ) const;
bool hasProduced( ) const;
bool updateHasInjected( );
Expand Down
13 changes: 11 additions & 2 deletions opm/input/eclipse/Schedule/Well/WellInjectionProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ namespace Opm {
injectionControls(0),
injectorType(InjectorType::WATER),
controlMode(InjectorCMode::CMODE_UNDEFINED),
rsRvInj(0.0)
rsRvInj(0.0),
gas_inj_composition(std::nullopt)
{
}

Expand All @@ -82,6 +83,7 @@ namespace Opm {
result.injectorType = InjectorType::OIL;
result.controlMode = InjectorCMode::BHP;
result.rsRvInj = 11;
result.gas_inj_composition = std::vector<double>{1.0, 2.0, 3.0};

return result;
}
Expand Down Expand Up @@ -284,7 +286,8 @@ namespace Opm {
(injectionControls == other.injectionControls) &&
(injectorType == other.injectorType) &&
(controlMode == other.controlMode) &&
(rsRvInj == other.rsRvInj))
(rsRvInj == other.rsRvInj) &&
(gas_inj_composition == other.gas_inj_composition))
return true;
else
return false;
Expand Down Expand Up @@ -324,6 +327,7 @@ namespace Opm {
<< "injector type: " << InjectorType2String(wp.injectorType) << ", "
<< "control mode: " << WellInjectorCMode2String(wp.controlMode) << " , "
<< "rs/rv concentration: " << wp.rsRvInj << " }";
// TODO: add gas_inj_composition
}


Expand All @@ -344,6 +348,7 @@ namespace Opm {
controls.vfp_table_number = this->VFPTableNumber;
controls.prediction_mode = this->predictionMode;
controls.rs_rv_inj = this->rsRvInj;
// TODO: should we add gas_inj_composition here?

return controls;
}
Expand Down Expand Up @@ -491,5 +496,9 @@ namespace Opm {
else throw std::invalid_argument("Invalid keyword (MODE) supplied");
}

void Well::WellInjectionProperties::setGasInjComposition(const std::vector<double>& composition) {
gas_inj_composition = composition;
}


}
36 changes: 36 additions & 0 deletions opm/input/eclipse/Schedule/Well/WellKeywordHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,41 @@ void handleWELOPEN(HandlerContext& handlerContext)
}
}

void handleWINJGAS(HandlerContext& HandlerContext)
{
for (const auto& record : HandlerContext.keyword) {
const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);
const auto well_names = HandlerContext.wellNames(wellNamePattern, false);
const std::string& fluid_nature = record.getItem("FLUID").getTrimmedString(0);
// TODO: technically, only the firt two characters are significant
// TODO: we need to test it out whether only the first two characters matter
if (fluid_nature != "STREAM") {
std::string msg = fmt::format("The fluid nature '{}' is not supported in WINJGAS keyword.", fluid_nature);
throw OpmInputError(msg, HandlerContext.keyword.location());
}
const std::string& stream_name = record.getItem("STREAM").getTrimmedString(0);
// TODO: we do not handle other records for now

// we make sure the stream is defined in WELLSTRE keyword
const auto& inj_streams = HandlerContext.state().inj_streams;
if (inj_streams.find(stream_name) == inj_streams.end()) {
std::string msg = fmt::format("The stream '{}' is not defined in WELLSTRE keyword.", stream_name);
throw OpmInputError(msg, HandlerContext.keyword.location());
}

auto well2 = HandlerContext.state().wells.get(well_names[0]);
if (well2.isProducer()) {
std::string msg = fmt::format("The well '{}' is a producer, not an injector.", well_names[0]);
throw OpmInputError(msg, HandlerContext.keyword.location());
}
auto injection = std::make_shared<Well::WellInjectionProperties>(well2.getInjectionProperties());

// TODO: should we make it a injection event?
const auto& inj_stream = inj_streams.at(stream_name);
injection->setGasInjComposition(inj_stream);
}
}

void handleWELSPECS(HandlerContext& handlerContext)
{
using Kw = ParserKeywords::WELSPECS;
Expand Down Expand Up @@ -910,6 +945,7 @@ getWellHandlers()
{ "WCONINJE", &handleWCONINJE },
{ "WCONINJH", &handleWCONINJH },
{ "WCONPROD", &handleWCONPROD },
{ "WINJGAS", &handleWINJGAS },
{ "WELOPEN" , &handleWELOPEN },
{ "WELLSTRE", &handleWELLSTRE },
{ "WELSPECS", &handleWELSPECS },
Expand Down

0 comments on commit 5f80b49

Please sign in to comment.