TNO Intern

Commit 0ad030a6 authored by Hen Brett's avatar Hen Brett 🐔
Browse files

Trying out tests of the simulations

parent e8e5fce2
Loading
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -74,7 +74,6 @@ def calculate_doublet_performance(props: UTCConfiguration, input: DoubletInput)
            props.hp_minimum_injection_temperature,
        )

    timer = timeit.default_timer()
    drawdown_pressure = calculate_max_pressure(
        props,
        input,
@@ -82,7 +81,6 @@ def calculate_doublet_performance(props: UTCConfiguration, input: DoubletInput)
        well_distance,
        injection_temperature,
    )
    timer = print_time(timer, "\tmax pressure: ")

    if drawdown_pressure == 0:
        return None
@@ -108,7 +106,6 @@ def calculate_doublet_performance(props: UTCConfiguration, input: DoubletInput)
            drawdown_pressure,
            injection_temperature,
        )
    print_time(timer, "\twell distance optimizer: ")

    stimulation_capex = (
        0.0
+17 −12
Original line number Diff line number Diff line
@@ -39,16 +39,22 @@ def doubletcalc(
        thermal_conductivity=3,
        thermal_diffusivity=1.2e-6,
    )

    injector = Well(
        aquifer=aquifer,
        well_type="injector",
        pipe_segments=[WellPipeSegment(
            ah_depth=get_along_hole_length(input.depth, well_distance, props.well_curv_scaling, props.max_tvd_stepout_factor),
        pipe_segments=[
            WellPipeSegment(
                ah_depth=get_along_hole_length(
                    input.depth,
                    well_distance,
                    props.well_curv_scaling,
                    props.max_tvd_stepout_factor,
                ),
                tv_depth=input.depth,
                inner_diameter=props.inner_diameter * INCH_SI,
            roughness=props.roughness * 1e-3 * INCH_SI
        )],
                roughness=props.roughness * 1e-3 * INCH_SI,
            )
        ],
        aquifer_top_depth=input.depth,
        pipe_scaling=0,
        target_segment_length=props.segment_length,
@@ -95,9 +101,8 @@ def doubletcalc(
        viscosity_mode=props.viscosity_mode,
        heat_exchanger_exit_temperature=injection_temp,
    )
    timer = print_time(timer,"\t\t\t\tdoublet instantiation: ")
    doublet.simulate()
    print_time(timer,"\t\t\t\tdoublet simulation: ")

    return Doublet1DResults(
        geothermal_powers=doublet.geothermal_power,
        cop=doublet.cop,
@@ -132,7 +137,6 @@ def get_along_hole_length(
    curve_scaling_factor: float,
    max_true_vertical_depth_stepout_factor: float,
) -> float:

    if curve_scaling_factor == 0:
        # Vertical well: along-hole length equals TVD
        return true_vertical_depth
@@ -145,6 +149,7 @@ def get_along_hole_length(

    stepout -= horizontal_distance

    oblique_distance = math.sqrt(stepout**2 + true_vertical_depth**2) * curve_scaling_factor

    oblique_distance = (
        math.sqrt(stepout**2 + true_vertical_depth**2) * curve_scaling_factor
    )
    return oblique_distance + horizontal_distance
 No newline at end of file
+0 −2
Original line number Diff line number Diff line
@@ -20,11 +20,9 @@ def calculate_max_pressure(

    pres = min(props.max_pump * 1e5, max_pres)

    start = timeit.default_timer()
    results = calculate_volumetric_flow(
        props, input_data, pres, well_distance, injection_temp
    )
    print_time(start, "\t\tcalculate volumetric flow: ")

    if results is None:
        pres_tol = 1e3
+1 −1
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ class UTCConfiguration:
    default_well_distance: float = 1500.0
    pump_efficiency: float = 0.6
    pump_depth: float = 300.0
    segment_length: float = 50.0
    segment_length: float = 1.0
    outer_diameter: float = 8.5
    inner_diameter: float = 8.5
    roughness: float = 1.38
+17 −10
Original line number Diff line number Diff line
@@ -25,19 +25,26 @@ def test_calculate_doublet_performance():
    )

    # Act
    result = calculate_doublet_performance(props, input_data)
    start = timeit.default_timer()
    n_sims = 100
    for i in range(n_sims):
        result = calculate_doublet_performance(props, input_data)
    print_time(start, "Full Simulation: ")
    time_elapsed = timeit.default_timer() - start
    print(f"{n_sims} simulations took: {time_elapsed:.1f} seconds\n"
          f"{n_sims/time_elapsed:.1f} simulations per second")


    # Assert
    assert np.isclose(result.flow, 227.2757568359375, atol=1.5)
    assert np.isclose(result.pres, 60, atol=0.001)
    assert np.isclose(result.utc, 6.616096470753937, atol=0.001)
    assert np.isclose(result.welld, 1159.17968, atol=0.001)
    assert np.isclose(result.power, 8.636903762817383, atol=0.01)
    assert np.isclose(result.cop, 13.627557754516602, atol=0.01)
    assert np.isclose(result.var_opex, -7.510325908660889, atol=0.01)
    assert np.isclose(result.fixed_opex, -11.227973937988281, atol=0.01)
    rtol = 0.005
    assert np.isclose(result.flow, 227.2757568359375, rtol=rtol)
    assert np.isclose(result.pres, 60, rtol=rtol)
    assert np.isclose(result.utc, 6.616096470753937, rtol=rtol)
    assert np.isclose(result.welld, 1159.17968, rtol=rtol)
    assert np.isclose(result.power, 8.636903762817383, rtol=rtol)
    assert np.isclose(result.cop, 13.627557754516602, rtol=rtol)
    assert np.isclose(result.var_opex, -7.510325908660889, rtol=rtol)
    assert np.isclose(result.fixed_opex, -11.227973937988281, rtol=rtol)