diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp index 07d539542f..6a3dd73c6b 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicMswValveAccumulators.cpp @@ -44,11 +44,25 @@ bool RicMswICDAccumulator::accumulateValveParameters( const RimWellPathValve* we CVF_ASSERT( wellPathValve ); if ( wellPathValve->componentType() == RiaDefines::ICV || wellPathValve->componentType() == RiaDefines::ICD ) { + double lengthFraction = 1.0; + + if ( wellPathValve->componentType() == RiaDefines::WellPathComponentType::ICD ) + { + std::pair valveSegment = wellPathValve->valveSegments()[subValve]; + double valveSegmentLength = std::fabs( valveSegment.second - valveSegment.first ); + if ( totalValveLengthOpenForFlow > 1.0e-8 ) + { + lengthFraction = valveSegmentLength / totalValveLengthOpenForFlow; + } + } + + double combinedFraction = contributionFraction * lengthFraction; + double icdOrificeRadius = wellPathValve->orificeDiameter( m_unitSystem ) / 2; double icdArea = icdOrificeRadius * icdOrificeRadius * cvf::PI_D; - m_areaSum += icdArea * contributionFraction; - m_coefficientCalculator.addValueAndWeight( wellPathValve->flowCoefficient(), icdArea * contributionFraction ); + m_areaSum += icdArea * combinedFraction; + m_coefficientCalculator.addValueAndWeight( wellPathValve->flowCoefficient(), icdArea * combinedFraction ); return true; } return false; @@ -98,15 +112,6 @@ bool RicMswAICDAccumulator::accumulateValveParameters( const RimWellPathValve* w m_deviceOpen = m_deviceOpen || params->isOpen(); if ( params->isOpen() ) { - std::array values = params->doubleValues(); - for ( size_t i = 0; i < (size_t)AICD_NUM_PARAMS; ++i ) - { - if ( RiaStatisticsTools::isValidNumber( values[i] ) ) - { - m_meanCalculators[i].addValueAndWeight( values[i], contributionFraction ); - } - } - std::pair valveSegment = wellPathValve->valveSegments()[subValve]; double valveSegmentLength = std::fabs( valveSegment.second - valveSegment.first ); double lengthFraction = 1.0; @@ -115,6 +120,17 @@ bool RicMswAICDAccumulator::accumulateValveParameters( const RimWellPathValve* w lengthFraction = valveSegmentLength / totalValveLengthOpenForFlow; } + double combinedFraction = contributionFraction * lengthFraction; + + std::array values = params->doubleValues(); + for ( size_t i = 0; i < (size_t)AICD_NUM_PARAMS; ++i ) + { + if ( RiaStatisticsTools::isValidNumber( values[i] ) ) + { + m_meanCalculators[i].addValueAndWeight( values[i], combinedFraction ); + } + } + // https://github.com/OPM/ResInsight/issues/6126 // // flowScalingFactor = 1 / (length_fraction * N_AICDs) @@ -122,11 +138,11 @@ bool RicMswAICDAccumulator::accumulateValveParameters( const RimWellPathValve* w // length_fraction = length_COMPSEGS / Sum_lenght_COMPSEGS_for_valve // N_AICDs = number of AICDs in perforation interval - double divisor = wellPathValve->valveLocations().size() * lengthFraction * contributionFraction; + double divisor = wellPathValve->valveLocations().size() * combinedFraction; m_accumulatedFlowScalingFactorDivisor += divisor; - m_accumulatedLength += lengthFraction * contributionFraction; + m_accumulatedLength += combinedFraction; } } return true;