TNO Intern

Commit 90ed71e5 authored by Florian Knappers's avatar Florian Knappers
Browse files

finished: now debugging

parent 7995cb9c
Loading
Loading
Loading
Loading
Loading
+67 −20
Original line number Diff line number Diff line
from dataclasses import dataclass

from pythermogis.workflow.utc.utc_properties import UTCConfiguration
from pythermogis.workflow.utc.doublet_utils import optimize_well_distance, calculate_injection_temp_with_heat_pump, calculate_cooling_temperature
from pythermogis.workflow.utc.doublet_utils import optimize_well_distance, calculate_injection_temp_with_heat_pump, calculate_cooling_temperature, \
    calc_lifetime
from pythermogis.workflow.utc.pressure import calculate_max_pressure, optimize_pressure


EUR_PER_CT_PER_KWH = 0.36
NPV_SCALE = 1e-6

@dataclass
class DoubletInput:
@@ -132,24 +134,69 @@ def calculate_doublet_performance(props: UTCConfiguration, input: DoubletInput)
    hp_added_power = pressure_results.hp_added_power
    production_temp = pressure_results.production_temp

    total_variable_opex = sum(variable_opex)
    total_fixed_opex = sum(fixed_opex)

    utc_eur_ct_per_kwh = (
        input.unknown_input_value
        if utc == input.unknown_input_value
        else utc * EUR_PER_CT_PER_KWH
    )

    if abs(input.unknown_input_value) < 10:
        if not (abs(utc_eur_ct_per_kwh - input.unknown_input_value) > 1e-4):
            return None
    else:
        test = abs((utc_eur_ct_per_kwh / input.unknown_input_value) - 1)
        if not (test > 1e-4):
            return None

    breakthrough_years = calc_lifetime(
        well_distance,
        input.thickness*input.ntg,
        0.001,
        input.porosity,
        flowrate,
        input.depth,
        input.temperature,
        props.salinity_surface,
        props.salinity_gradient,
        props.optim_dist_cp_rock,
        props.optim_dist_rho_rock
    )

    utc_cutoff = (
        props.utc_cutoff_deep if input.depth > props.utc_deep_depth else props.utc_cutoff
    )

    npv = (
            NPV_SCALE
            * (utc_cutoff - utc_eur_ct_per_kwh)
            * 3.6
            * discounted_heat_produced_p
            * (1 - props.tax_rate)
    )
    opex_first_prod_year = total_opex_ts[props.drilling_time]
    hp_cop = 3.0

    return DoubletOutput(
        power=0.0,
        hppower=0.0,
        capex=0.0,
        var_opex=0.0,
        fixed_opex=0.0,
        opex=0.0,
        utc=0.0,
        npv=0.0,
        hprod=0.0,
        cop=0.0,
        cophp=0.0,
        pres=0.0,
        flow=0.0,
        welld=0.0,
        breakthrough=0.0,
        cooling=0.0,
        production_temp=0.0,
        injection_temp=0.0
        power=heat_power_per_doublet,
        hppower=hp_added_power,
        capex=sum_capex,
        var_opex=total_variable_opex,
        fixed_opex=total_fixed_opex,
        opex=opex_first_prod_year,
        utc=utc_eur_ct_per_kwh,
        npv=npv,
        hprod=discounted_heat_produced_p,
        cop=cop,
        cophp=hp_cop,
        pres=drawdown_pressure / 1e5,
        flow=flowrate,
        welld=well_distance,
        breakthrough=breakthrough_years,
        cooling=end_temperature_p,
        production_temp=production_temp,
        injection_temp=injection_temperature
    )
+0 −6
Original line number Diff line number Diff line
@@ -129,9 +129,6 @@ def calc_lifetime(
    cp_rock: float,
    rho_rock: float,
) -> float:
    """
    Python equivalent of DoubletUtils.calcLifetime(...)
    """

    # --- Water properties at depth ---
    salinity = get_salinity(salinity_surface, salinity_gradient, depth)
@@ -178,9 +175,6 @@ def optimize_well_distance(
    drawdown_pressure: float,
    injection_temp: float,
) -> float:
    """
    Python equivalent of WellDistanceOptimizer.optimize(...)
    """

    dist_min = props.optim_dist_well_dist_min
    dist_max = props.optim_dist_well_dist_max