TNO Intern

Commit 799596ae authored by Hen Brett's avatar Hen Brett 🐔
Browse files

Adding an extra performance test

parent 1c19ca30
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ def doubletcalc(
        well_distance=well_distance,
        cooling_fraction=0.1,
        yearly_operating_hours=props.load_hours,
        pressure_balance_tolerance=1e-1,
        pressure_balance_tolerance=1e-2,
        viscosity_mode=props.viscosity_mode,
        heat_exchanger_exit_temperature=injection_temp,
    )
+37 −1
Original line number Diff line number Diff line
@@ -2,6 +2,10 @@ 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


def test_doubletcalc():
    props = UTCConfiguration()
@@ -25,3 +29,35 @@ def test_doubletcalc():
    assert np.isclose(results.pump_power_required, 5.175418689587975, rtol=0.01)
    assert np.isclose(results.production_temp, 41.36211427733413, rtol=0.01)
    assert np.isclose(results.heat_power_produced[0], 0.027926914290870505, rtol=0.01)


def test_doubletcalc_performance():
    props = UTCConfiguration(segment_length=1)

    input_data = DoubletInput(
        unknown_input_value=-999.0,
        thickness=100.0,
        transmissivity=17500.0,
        transmissivity_with_ntg=17500.0,
        ntg=1.0,
        depth=2000,
        porosity=0.0,
        temperature=50.0,
    )

    nsims = 1000
    # 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)
    time_elapsed = timeit.default_timer() - start
    print(f"{(nsims/time_elapsed):.1f} sims/s")

    rtol=0.25
    assert np.isclose(results.geothermal_powers, 0.027926914290870505, rtol=rtol)
    assert np.isclose(results.cop, 5.396068601571214, rtol=rtol)
    assert np.isclose(results.flowrate, 18.631507399806665, rtol=rtol)
    assert np.isclose(results.pump_power_required, 5.175418689587975, rtol=rtol)
    assert np.isclose(results.production_temp, 41.36211427733413, rtol=rtol)
    assert np.isclose(results.heat_power_produced[0], 0.027926914290870505, rtol=rtol)
 No newline at end of file