Skip to content

Commit

Permalink
adding accessing function for gas injection composition
Browse files Browse the repository at this point in the history
  • Loading branch information
GitPaean committed Dec 5, 2024
1 parent bea8906 commit e5c5bc1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion opm/input/eclipse/Schedule/Well/Well.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ class Well {
void handleWTMULT(Well::WELTARGCMode cmode, double factor);

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

template<class Serializer>
void serializeOp(Serializer& serializer)
Expand Down Expand Up @@ -568,7 +569,6 @@ 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
6 changes: 6 additions & 0 deletions opm/input/eclipse/Schedule/Well/WellInjectionProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,5 +509,11 @@ namespace Opm {
gas_inj_composition = composition;
}

const std::vector<double>& Well::WellInjectionProperties::gasInjComposition() const {
if (!gas_inj_composition.has_value()) {
throw std::invalid_argument("Gas injection composition not set");
}
return gas_inj_composition.value();
}

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

void handleWINJGAS(HandlerContext& HandlerContext)
void handleWINJGAS(HandlerContext& handlerContext)
{
for (const auto& record : HandlerContext.keyword) {
for (const auto& record : handlerContext.keyword) {
const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0);
const auto well_names = HandlerContext.wellNames(wellNamePattern, false);
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());
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;
const auto& inj_streams = handlerContext.state().inj_streams;
if (!inj_streams.has(stream_name)) {
std::string msg = fmt::format("The stream '{}' is not defined in WELLSTRE keyword.", stream_name);
throw OpmInputError(msg, HandlerContext.keyword.location());
throw OpmInputError(msg, handlerContext.keyword.location());
}

auto well2 = HandlerContext.state().wells.get(well_names[0]);
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());
Expand All @@ -547,6 +547,10 @@ void handleWINJGAS(HandlerContext& HandlerContext)
// TODO: should we make it a injection event?
const auto& inj_stream = inj_streams.get(stream_name);
injection->setGasInjComposition(inj_stream);

if (well2.updateInjection(injection)) {
handlerContext.state().wells.update( std::move(well2) );
}
}
}

Expand Down

0 comments on commit e5c5bc1

Please sign in to comment.