TNO Intern

Commit a1077b00 authored by Hen Brett's avatar Hen Brett 🐔
Browse files

Adding extra performance tests to compare more directly with the Java code

parent 3d885b8f
Loading
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
import math
from dataclasses import dataclass
from pythermogis.workflow.utc.utc_properties import UTCConfiguration

from numba import njit
from pydoubletcalc import Aquifer, Doublet, Well, WellPipeSegment
from pythermogis.workflow.utc.water import get_salinity

from pythermogis.workflow.utc.rock import get_geothermal_gradient
from numba import njit
from pythermogis.workflow.utc.utc_properties import UTCConfiguration
from pythermogis.workflow.utc.water import get_salinity

INCH_SI = 0.0254

@dataclass
@@ -96,7 +99,7 @@ def doubletcalc(
        well_distance=well_distance,
        cooling_fraction=0.1,
        yearly_operating_hours=props.load_hours,
        pressure_balance_tolerance=1e-2,
        pressure_balance_tolerance=1e-1,
        viscosity_mode=props.viscosity_mode,
        heat_exchanger_exit_temperature=injection_temp,
    )
+1 −1
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ def test_calculate_doublet_performance_precise():
    assert np.isclose(result.var_opex, -7.510325908660889, rtol=rtol)
    assert np.isclose(result.fixed_opex, -11.227973937988281, rtol=rtol)

@pytest.skip("This is for timing performance and comparing to the Java code, not needed to run on the pipeline")
def test_calculate_doublet_performance_approximate():
    # Arrange: instantiate default UTCConfiguration
    props = UTCConfiguration(
@@ -81,7 +82,6 @@ def test_calculate_doublet_performance_approximate():
    print(f"{n_sims} simulations took: {time_elapsed:.1f} seconds\n"
          f"{n_sims/time_elapsed:.1f} simulations per second")


    # Assert
    rtol = 0.01 # accurate to 1%
    assert np.isclose(result.flow, 227.2757568359375, rtol=rtol)
+8 −6
Original line number Diff line number Diff line
from pythermogis.workflow.utc.utc_properties import UTCConfiguration
from pythermogis.workflow.utc.doublet import DoubletInput
from pythermogis.workflow.utc.doubletcalc import doubletcalc
import numpy as np
import timeit

from utils.timer import print_time
import numpy as np
import pytest

from pythermogis.workflow.utc.doublet import DoubletInput
from pythermogis.workflow.utc.doubletcalc import doubletcalc
from pythermogis.workflow.utc.utc_properties import UTCConfiguration


def test_doubletcalc():
@@ -30,7 +31,7 @@ def test_doubletcalc():
    assert np.isclose(results.production_temp, 41.36211427733413, rtol=0.01)
    assert np.isclose(results.heat_power_produced[0], 0.027926914290870505, rtol=0.01)


@pytest.skip("This is for timing performance and comparing to the Java code, not needed to run on the pipeline")
def test_doubletcalc_performance():
    props = UTCConfiguration(segment_length=1)

@@ -48,6 +49,7 @@ def test_doubletcalc_performance():
    nsims = 10000
    # one iteration to warm up the JIT compiled functions
    doubletcalc(props, input_data, 600000, 1550, 40)

    start = timeit.default_timer()
    for _ in range(nsims):
        results = doubletcalc(props, input_data, 600000, 1550, 40)