Пример #1
0
    def test_pipe_pvt_model(self, default_case, default_well):
        """
        If a Elements on case uses an invalid PvtModel, the pvt_model must reset to None when calling ResetInvalidReferences()
        """
        case = attr.evolve(
            default_case,
            nodes=[
                case_description.NodeDescription(
                    name="Node 1",
                    node_type=NodeCellType.Pressure,
                    pvt_model="InvalidPVT",
                )
            ],
            wells=[
                attr.evolve(
                    default_well,
                    pvt_model="InvalidPVT",
                    annulus=case_description.AnnulusDescription(
                        has_annulus_flow=False,
                        pvt_model="InvalidPVT",
                        top_node="Node 1",
                    ),
                )
            ],
            pipes=[
                case_description.PipeDescription(
                    name="Pipe 1",
                    pvt_model="InvalidPVT",
                    source="in",
                    target="out",
                    profile=_empty_profile(),
                    segments=build_simple_segment(),
                    equipment=case_description.EquipmentDescription(
                        mass_sources={
                            "Mass Equip. 1": case_description.MassSourceEquipmentDescription(
                                position=Scalar(0, "m")
                            )
                        }
                    ),
                )
            ],
        )

        case.reset_invalid_references()
        assert case.pipes[0].pvt_model is None
        assert case.nodes[0].pvt_model is None
        assert case.wells[0].pvt_model is None
        assert case.wells[0].annulus.pvt_model is None
def test_invalid_fluid_reference_on_pipes():
    """
    Ensure that only declared Fluids can be used on:
       PipeDescription, MassSourceEquipmentDescription, ReservoirInflowEquipmentDescription.
    """
    case = case_description.CaseDescription(
        pvt_models=case_description.PvtModelsDescription(
            default_model="PVT",
            compositions={
                "PVT":
                case_description.PvtModelCompositionalDescription(
                    fluids={"Fluid 1": case_description.FluidDescription()})
            },
        ),
        pipes=[
            case_description.PipeDescription(
                name="Pipe 1",
                source="",
                target="",
                segments=build_simple_segment(),
                initial_conditions=case_description.
                InitialConditionsDescription(fluid="acme5"),
                equipment=case_description.EquipmentDescription(
                    mass_sources={
                        "MassSource":
                        case_description.MassSourceEquipmentDescription(
                            position=Scalar(1, "m"), fluid="a6")
                    },
                    reservoir_inflows={
                        "Reservoir":
                        case_description.ReservoirInflowEquipmentDescription(
                            start=Scalar(1, "m"),
                            length=Scalar(10, "m"),
                            fluid="a7")
                    },
                ),
            )
        ],
    )
    expected_error = "The following elements have an invalid fluid assigned: 'MassSource from Pipe 1', 'Pipe 1', 'Reservoir from Pipe 1'."
    with pytest.raises(InvalidReferenceError, match=re.escape(expected_error)):
        case.ensure_valid_references()
    type=constants.ValveType.ChokeValveWithFlowCoefficient,
    cv_table=CV_TABLE_DESCRIPTION_SCHEMA,
    opening_type=constants.ValveOpeningType.ConstantOpening,
    opening=Scalar("dimensionless", 42, "%"),
)
WALL_DESCRIPTION = case_description.WallDescription(
    name="Flowline",
    inner_roughness=Scalar(1, "mm"),
    wall_layer_container=[WALL_LAYER_DESCRIPTION, WALL_LAYER_DESCRIPTION],
)
EQUIPMENT_DESCRIPTION = case_description.EquipmentDescription(
    mass_sources={"MASS SOURCE": MASS_SOURCE_DESCRIPTION},
    pumps={"PUMP": PUMP_DESCRIPTION},
    valves={
        "VALVE": VALVE_DESCRIPTION,
        "VALVE CONSTANT OPENING": VALVE_DESCRIPTION_CONSTANT_OPENING,
    },
    reservoir_inflows={"RESERVOIR": RESERVOIR_INFLOW_DESCRIPTION},
    heat_sources={"HEAT": HEAT_SOURCE_DESCRIPTION},
    compressors={"COMPRESSOR": COMPRESSOR_DESCRIPTION},
)
ENVIRONMENT_PROPERTY_DESCRIPTION = case_description.EnvironmentPropertyDescription(
    position=Scalar(1, "m"),
    temperature=Scalar(1, "degC"),
    type=constants.PipeEnvironmentHeatTransferCoefficientModelType.WallsAndEnvironment,
    heat_transfer_coefficient=Scalar(1.0e50, "W/m2.K"),
    overall_heat_transfer_coefficient=Scalar(2, "W/m2.K"),
    fluid_velocity=Scalar(1, "m/s"),
)
ENVIRONMENT_DESCRIPTION = case_description.EnvironmentDescription(
    thermal_model=constants.PipeThermalModelType.SteadyState,