Skip to content

Commit

Permalink
#11901 Python: Make more well completion parameters available
Browse files Browse the repository at this point in the history
Add access to all MSW parameters in Python : "msw_settings = well_path.msw_settings()"

Make all parameters of the well completion object available in Python.
  • Loading branch information
magnesj committed Nov 22, 2024
1 parent 036ed8b commit 05208a2
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#include "RimWellPath.h"

#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiObjectEditorHandle.h"

#include <limits>
Expand All @@ -31,8 +33,8 @@ namespace caf
template <>
void RimMswCompletionParameters::ReferenceMDEnum::setUp()
{
addItem( RimMswCompletionParameters::ReferenceMDType::AUTO_REFERENCE_MD, "GridIntersectionRefMD", "Grid Entry Point" );
addItem( RimMswCompletionParameters::ReferenceMDType::MANUAL_REFERENCE_MD, "ManualRefMD", "User Defined" );
addItem( RimMswCompletionParameters::ReferenceMDType::AUTO_REFERENCE_MD, "GridEntryPoint", "Grid Entry Point", { "GridIntersectionRefMD" } );
addItem( RimMswCompletionParameters::ReferenceMDType::MANUAL_REFERENCE_MD, "UserDefined", "User Defined", { "ManualRefMD" } );
setDefault( RimMswCompletionParameters::ReferenceMDType::AUTO_REFERENCE_MD );
}

Expand Down Expand Up @@ -61,22 +63,33 @@ CAF_PDM_SOURCE_INIT( RimMswCompletionParameters, "RimMswCompletionParameters" );
//--------------------------------------------------------------------------------------------------
RimMswCompletionParameters::RimMswCompletionParameters()
{
CAF_PDM_InitObject( "MSW Completion Parameters", ":/CompletionsSymbol16x16.png" );
CAF_PDM_InitScriptableObjectWithNameAndComment( "MSW Completion Parameters",
":/CompletionsSymbol16x16.png",
"",
"",
"MswSettings",
"Multi Segment Well Completion Settings" );

CAF_PDM_InitFieldNoDefault( &m_refMDType, "RefMDType", "Reference MD" );
CAF_PDM_InitField( &m_refMD, "RefMD", 0.0, "" );
CAF_PDM_InitScriptableFieldWithScriptKeywordNoDefault( &m_refMDType, "RefMDType", "ReferenceMdType", "" );
CAF_PDM_InitScriptableFieldWithScriptKeyword( &m_refMD, "RefMD", "UserDefinedReferenceMd", 0.0, "User Defined Reference MD" );

CAF_PDM_InitField( &m_customValuesForLateral, "CustomValuesForLateral", false, "Custom Values for Lateral" );
CAF_PDM_InitScriptableField( &m_customValuesForLateral, "CustomValuesForLateral", false, "Custom Values for Lateral" );

const auto unitSystem = RiaDefines::EclipseUnitSystem::UNITS_METRIC;
CAF_PDM_InitField( &m_linerDiameter, "LinerDiameter", RimMswCompletionParameters::defaultLinerDiameter( unitSystem ), "Liner Inner Diameter" );
CAF_PDM_InitField( &m_roughnessFactor, "RoughnessFactor", RimMswCompletionParameters::defaultRoughnessFactor( unitSystem ), "Roughness Factor" );

CAF_PDM_InitFieldNoDefault( &m_pressureDrop, "PressureDrop", "Pressure Drop" );
CAF_PDM_InitFieldNoDefault( &m_lengthAndDepth, "LengthAndDepth", "Length and Depth" );

CAF_PDM_InitField( &m_enforceMaxSegmentLength, "EnforceMaxSegmentLength", false, "Enforce Max Segment Length" );
CAF_PDM_InitField( &m_maxSegmentLength, "MaxSegmentLength", 200.0, "Max Segment Length" );
CAF_PDM_InitScriptableField( &m_linerDiameter,
"LinerDiameter",
RimMswCompletionParameters::defaultLinerDiameter( unitSystem ),
"Liner Inner Diameter" );
CAF_PDM_InitScriptableField( &m_roughnessFactor,
"RoughnessFactor",
RimMswCompletionParameters::defaultRoughnessFactor( unitSystem ),
"Roughness Factor" );

CAF_PDM_InitScriptableFieldNoDefault( &m_pressureDrop, "PressureDrop", "Pressure Drop" );
CAF_PDM_InitScriptableFieldNoDefault( &m_lengthAndDepth, "LengthAndDepth", "Length and Depth" );

CAF_PDM_InitScriptableField( &m_enforceMaxSegmentLength, "EnforceMaxSegmentLength", false, "Enforce Max Segment Length" );
CAF_PDM_InitScriptableField( &m_maxSegmentLength, "MaxSegmentLength", 200.0, "Max Segment Length" );
m_maxSegmentLength.uiCapability()->setUiHidden( true );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,20 @@ CAF_PDM_SOURCE_INIT( RimWellPathCompletionSettings, "WellPathCompletionSettings"
RimWellPathCompletionSettings::RimWellPathCompletionSettings()
{
CAF_PDM_InitScriptableObject( "Completion Settings", ":/CompletionsSymbol16x16.png" );

CAF_PDM_InitScriptableField( &m_wellNameForExport, "WellNameForExport", QString(), "Well Name" );
m_wellNameForExport.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() );

CAF_PDM_InitScriptableFieldWithScriptKeyword( &m_groupName, "WellGroupNameForExport", "GroupNameForExport", QString(), "Group Name" );
CAF_PDM_InitField( &m_referenceDepth, "ReferenceDepthForExport", QString(), "Reference Depth for BHP" );
CAF_PDM_InitScriptableField( &m_referenceDepth, "ReferenceDepthForExport", QString(), "Reference Depth for BHP" );
CAF_PDM_InitScriptableFieldNoDefault( &m_preferredFluidPhase, "WellTypeForExport", "Preferred Fluid Phase" );
CAF_PDM_InitField( &m_drainageRadiusForPI, "DrainageRadiusForPI", QString( "0.0" ), "Drainage Radius for PI" );
CAF_PDM_InitFieldNoDefault( &m_gasInflowEquation, "GasInflowEq", "Gas Inflow Equation" );
CAF_PDM_InitFieldNoDefault( &m_automaticWellShutIn, "AutoWellShutIn", "Automatic well shut-in" );
CAF_PDM_InitField( &m_allowWellCrossFlow, "AllowWellCrossFlow", true, "Allow Well Cross-Flow" );
CAF_PDM_InitField( &m_wellBoreFluidPVTTable, "WellBoreFluidPVTTable", 0, "Wellbore Fluid PVT table" );
CAF_PDM_InitFieldNoDefault( &m_hydrostaticDensity, "HydrostaticDensity", "Hydrostatic Density" );
CAF_PDM_InitField( &m_fluidInPlaceRegion, "FluidInPlaceRegion", 0, "Fluid In-Place Region" );
CAF_PDM_InitScriptableField( &m_drainageRadiusForPI, "DrainageRadiusForPI", QString( "0.0" ), "Drainage Radius for PI" );
CAF_PDM_InitScriptableFieldNoDefault( &m_gasInflowEquation, "GasInflowEq", "Gas Inflow Equation" );
CAF_PDM_InitScriptableFieldNoDefault( &m_automaticWellShutIn, "AutoWellShutIn", "Automatic well shut-in" );
CAF_PDM_InitScriptableField( &m_allowWellCrossFlow, "AllowWellCrossFlow", true, "Allow Well Cross-Flow" );
CAF_PDM_InitScriptableField( &m_wellBoreFluidPVTTable, "WellBoreFluidPVTTable", 0, "Wellbore Fluid PVT table" );
CAF_PDM_InitScriptableFieldNoDefault( &m_hydrostaticDensity, "HydrostaticDensity", "Hydrostatic Density" );
CAF_PDM_InitScriptableField( &m_fluidInPlaceRegion, "FluidInPlaceRegion", 0, "Fluid In-Place Region" );

CAF_PDM_InitFieldNoDefault( &m_mswParameters, "MswParameters", "Multi Segment Well Parameters" );
m_mswParameters = new RimMswCompletionParameters;
Expand Down
58 changes: 58 additions & 0 deletions ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "RimEclipseCase.h"
#include "RimEclipseCaseTools.h"
#include "RimMswCompletionParameters.h"
#include "RimPerforationCollection.h"
#include "RimPerforationInterval.h"
#include "RimStimPlanFractureTemplate.h"
Expand All @@ -31,6 +32,7 @@
#include "RimTools.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RimWellPathCompletionSettings.h"
#include "RimWellPathFracture.h"

#include "RigStimPlanModelTools.h"
Expand Down Expand Up @@ -223,3 +225,59 @@ std::unique_ptr<caf::PdmObjectHandle> RimcWellPath_appendPerforationInterval::de
{
return std::unique_ptr<caf::PdmObjectHandle>( new RimPerforationInterval );
}

CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimWellPath, RimcWellPath_multiSegmentWellSettings, "MswSettings" );

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimcWellPath_multiSegmentWellSettings::RimcWellPath_multiSegmentWellSettings( caf::PdmObjectHandle* self )
: caf::PdmObjectMethod( self )
{
CAF_PDM_InitObject( "MSW Settings", "", "", "Multi Segment Well Settings" );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObjectHandle* RimcWellPath_multiSegmentWellSettings::execute()
{
auto wellPath = self<RimWellPath>();

// RimMswCompletionParameters is a child object of RimWellPathCompletionSettings. To simplify the Python API, we return
// RimMswCompletionParameters directly from a well path object in Python. Two parameters are already exposed as part of the completion
// settings object, see RimWellPathCompletionSettings and the proxy fields liner_diameter and roughness. These fields are kept to
// ensure backward compatibility with existing scripts.
//
// https://github.com/OPM/ResInsight/issues/11901

if ( auto completionSettings = wellPath->completionSettings() )
{
return completionSettings->mswCompletionParameters();
}
return nullptr;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimcWellPath_multiSegmentWellSettings::resultIsPersistent() const
{
return true;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimcWellPath_multiSegmentWellSettings::isNullptrValidResult() const
{
return true;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::unique_ptr<caf::PdmObjectHandle> RimcWellPath_multiSegmentWellSettings::defaultResult() const
{
return std::unique_ptr<caf::PdmObjectHandle>( new RimMswCompletionParameters );
}
16 changes: 16 additions & 0 deletions ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,19 @@ class RimcWellPath_appendPerforationInterval : public caf::PdmObjectMethod
caf::PdmField<double> m_diameter;
caf::PdmField<double> m_skinFactor;
};

//==================================================================================================
///
//==================================================================================================
class RimcWellPath_multiSegmentWellSettings : public caf::PdmObjectMethod
{
CAF_PDM_HEADER_INIT;

public:
RimcWellPath_multiSegmentWellSettings( caf::PdmObjectHandle* self );

caf::PdmObjectHandle* execute() override;
bool resultIsPersistent() const override;
bool isNullptrValidResult() const override;
std::unique_ptr<PdmObjectHandle> defaultResult() const override;
};

0 comments on commit 05208a2

Please sign in to comment.