TNO Intern

Commit 8d2da62b authored by Hen Brett's avatar Hen Brett 🐔
Browse files

Allowing the code to calculate transmissivity with a provided P-value

parent b5f00788
Loading
Loading
Loading
Loading
+0 −0

Empty file added.

+2 −0
Original line number Diff line number Diff line
def calculate_temperature_from_gradient(depth, thickness, degrees_per_km, surface_temperature):
    return surface_temperature + (depth + thickness / 2) * (degrees_per_km * 0.001)
 No newline at end of file
+0 −0

Empty file added.

+19 −0
Original line number Diff line number Diff line
import numpy as np
from scipy import stats


def generate_thickness_permeability_transmissivity_for_pvalue(thickness_mean, thickness_sd, ln_permeability_mean, ln_permeability_sd, Pvalue):
    if Pvalue > 1.0:
        Pvalue /= 100

    thickness_dist = stats.norm(loc=thickness_mean, scale=thickness_sd)
    thickness_pvalue = thickness_dist.ppf(1 - Pvalue)

    ln_permeability_dist = stats.norm(loc=ln_permeability_mean, scale=ln_permeability_sd)
    permeability_pvalue = np.exp(ln_permeability_dist.ppf(1 - Pvalue))

    nSamples = 10000
    transmissivity_samples = np.sort(np.exp(ln_permeability_dist.rvs(nSamples) + np.log(thickness_dist.rvs(nSamples))))
    transmissivity_pvalue = transmissivity_samples[int((1 - Pvalue) * nSamples)]

    return thickness_pvalue, permeability_pvalue, transmissivity_pvalue
+44 −58
Original line number Diff line number Diff line
import numpy as np
import xarray as xr


def calculate_performance(hydrocarbons: float, depth: float, thickness: float, porosity: float, ntg: float, temperature: float, transmissivity: float, transmissivity_with_ntg: float, doublet=None,
                          input_params: dict = None, return_dict: bool = False):
    output_values ={"power": 0.0,
                "heat_pump_power": 0.0,
                "capex": 0.0,
                "opex": 0.0,
                "utc": 0.0,
                "npv": 0.0,
                "hprod": 0.0,
                "cop": 0.0,
                "cophp": 0.0,
                "pres": 0.0,
                "flow_rate": 0.0,
                "welld": 0.0,
                }
                          input_params: dict = None):
    # Returns the values from a doublet simulation in order of;
    # power, heat_pump_power,  capex, opex, utc, npv, hprod, cop, cophp, pres, flow_rate, welld

    if np.isnan(thickness):
        return np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan

    if hydrocarbons == 0.0:
        return 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0

    if hydrocarbons != 0.0:
    set_doublet_parameters(doublet, transmissivity_with_ntg, depth, porosity, ntg, temperature, input_params["use_stimulation"], input_params["stimKhMax"], input_params["surface_temperature"],
                           input_params["return_temperature"], input_params["use_heat_pump"], input_params["max_cooling_temperature_range"], input_params["hp_minimum_injection_temperature"])

        doublet.calculateDoubletPerformance(-99999.0, thickness, transmissivity)
    doublet.calculateDoubletPerformance(-9999.0, thickness, transmissivity)

    if doublet.getUtcPeurctkWh() == -9999.0:    # If calculation was not successful, return all 0.0
        return 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0

    # calculate net-present-value using the utc-cutoffs
    if depth > input_params["utc_cutoff_depth"]:
@@ -48,12 +44,8 @@ def calculate_performance(hydrocarbons: float, depth: float, thickness: float, p
                     "welld": doublet.doubletCalc1DData.getWellDistP(),
                     }

        # Reset doublet variables
    # Reset doublet variables for next calculation
    doublet.setProjectVariables(False, 0.0)

    if return_dict:
        return output_values
    else:
    return output_values["power"], output_values["heat_pump_power"], output_values["capex"], output_values["opex"], output_values["utc"], output_values["npv"], output_values["hprod"], output_values["cop"], output_values["cophp"], output_values["pres"], output_values["flow_rate"], output_values["welld"]


@@ -77,9 +69,3 @@ def set_doublet_parameters(doublet, transmissivity_with_ntg, depth, porosity, nt
    doublet.doubletCalc1DData.setInjectionTemp(injectionTemp)
    doublet.doubletCalc1DData.setDhReturnTemp(return_temperature)

def get_doublet_output(doublet):
    flowr = doublet.doubletCalc1DData.getFlowrate()
    cop = doublet.doubletCalc1DData.getCop()
    power = doublet.doubletCalc1DData.getHpP()
    return flowr, cop, power
Loading