mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Python: Make more well completion parameters available
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.
This commit is contained in:
parent
6894149f8e
commit
ddefd39fc2
@ -22,6 +22,8 @@
|
||||
|
||||
#include "RimWellPath.h"
|
||||
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
#include "cafPdmObjectScriptingCapability.h"
|
||||
#include "cafPdmUiObjectEditorHandle.h"
|
||||
|
||||
#include <limits>
|
||||
@ -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 );
|
||||
}
|
||||
|
||||
@ -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_InitScriptableField( &m_linerDiameter,
|
||||
"LinerDiameter",
|
||||
RimMswCompletionParameters::defaultLinerDiameter( unitSystem ),
|
||||
"Liner Inner Diameter" );
|
||||
CAF_PDM_InitScriptableField( &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_InitScriptableFieldNoDefault( &m_pressureDrop, "PressureDrop", "Pressure Drop" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &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_enforceMaxSegmentLength, "EnforceMaxSegmentLength", false, "Enforce Max Segment Length" );
|
||||
CAF_PDM_InitScriptableField( &m_maxSegmentLength, "MaxSegmentLength", 200.0, "Max Segment Length" );
|
||||
m_maxSegmentLength.uiCapability()->setUiHidden( true );
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCaseTools.h"
|
||||
#include "RimMswCompletionParameters.h"
|
||||
#include "RimPerforationCollection.h"
|
||||
#include "RimPerforationInterval.h"
|
||||
#include "RimStimPlanFractureTemplate.h"
|
||||
@ -31,6 +32,7 @@
|
||||
#include "RimTools.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimWellPathCompletionSettings.h"
|
||||
#include "RimWellPathFracture.h"
|
||||
|
||||
#include "RigStimPlanModelTools.h"
|
||||
@ -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 );
|
||||
}
|
||||
|
@ -90,3 +90,19 @@ private:
|
||||
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;
|
||||
};
|
||||
|
@ -64,3 +64,48 @@ def test_add_well_path_targets(rips_instance, initialize_test):
|
||||
assert target.use_fixed_azimuth == False
|
||||
assert target.azimuth == 0.0
|
||||
assert target.inclination == 25.6
|
||||
|
||||
|
||||
def test_add_well_path_completions(rips_instance, initialize_test):
|
||||
well_path_coll = rips_instance.project.descendants(rips.WellPathCollection)[0]
|
||||
|
||||
well_path = well_path_coll.add_new_object(rips.ModeledWellPath)
|
||||
well_path.name = "test"
|
||||
well_path.update()
|
||||
|
||||
# Update the completion settings
|
||||
completions_settings = well_path.completion_settings()
|
||||
completions_settings.msw_roughness = 12.34
|
||||
completions_settings.msw_liner_diameter = 0.2123
|
||||
completions_settings.well_name_for_export = "file name"
|
||||
completions_settings.group_name_for_export = "msj"
|
||||
completions_settings.well_type_for_export = "GAS"
|
||||
completions_settings.update() # Commit updates back to ResInsight
|
||||
|
||||
completions_settings_updated = well_path.completion_settings()
|
||||
assert completions_settings_updated.msw_roughness == 12.34
|
||||
assert completions_settings_updated.msw_liner_diameter == 0.2123
|
||||
assert completions_settings_updated.well_name_for_export == "file name"
|
||||
assert completions_settings_updated.group_name_for_export == "msj"
|
||||
assert completions_settings_updated.well_type_for_export == "GAS"
|
||||
|
||||
msw_settings = well_path.msw_settings()
|
||||
msw_settings.custom_values_for_lateral = True
|
||||
msw_settings.enforce_max_segment_length = True
|
||||
msw_settings.liner_diameter = 20.0
|
||||
msw_settings.max_segment_length = 123.05
|
||||
msw_settings.pressure_drop = "HFA"
|
||||
msw_settings.reference_md_type = "UserDefined"
|
||||
msw_settings.roughness_factor = 1.3
|
||||
msw_settings.user_defined_reference_md = 1234.56
|
||||
msw_settings.update()
|
||||
|
||||
msw_settings_updated = well_path.msw_settings()
|
||||
assert msw_settings_updated.custom_values_for_lateral == True
|
||||
assert msw_settings_updated.enforce_max_segment_length == True
|
||||
assert msw_settings_updated.liner_diameter == 20.0
|
||||
assert msw_settings_updated.max_segment_length == 123.05
|
||||
assert msw_settings_updated.pressure_drop == "HFA"
|
||||
assert msw_settings_updated.reference_md_type == "UserDefined"
|
||||
assert msw_settings_updated.roughness_factor == 1.3
|
||||
assert msw_settings_updated.user_defined_reference_md == 1234.56
|
||||
|
Loading…
Reference in New Issue
Block a user