Merge pull request #3835 from GitPaean/scaling_segment_pressure

using addition to update segment pressure when bhp is changed
This commit is contained in:
Kai Bao 2022-03-11 10:24:54 +01:00 committed by GitHub
commit 6394c89f77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -60,15 +60,16 @@ std::size_t SegmentState::size() const {
}
void SegmentState::scale_pressure(double bhp) {
void SegmentState::scale_pressure(const double bhp) {
if (this->empty())
throw std::logic_error("Tried to pressure scale empty SegmentState");
auto scale_factor = bhp / this->pressure[0];
const auto pressure_change = bhp - this->pressure[0];
std::transform(this->pressure.begin(),
this->pressure.end(),
this->pressure.begin(),
[scale_factor] (const double& p) { return p*scale_factor;});
[pressure_change] (const double& p) { return p + pressure_change;});
}
const std::vector<int>& SegmentState::segment_number() const {

View File

@ -539,7 +539,7 @@ BOOST_AUTO_TEST_CASE(TESTSegmentState2) {
segments.scale_pressure(bhp);
for (std::size_t i=0; i < segments.pressure.size(); i++)
BOOST_CHECK_EQUAL(segments.pressure[i], 2*(i+1));
BOOST_CHECK_EQUAL(segments.pressure[i], 1.+(i+1));
BOOST_CHECK_EQUAL( segments.size(), well.getSegments().size() );
}