Exemple #1
0
def main(opts, flgs):
    """
    Parameters
    ----------
    heating_season: int [days]
        Number of heating days, default: 180 days
    ground_conductivity: float [W m-1 K-1]
        Depth averaged thermal conductivity
    ground_capacity: float []
        Depth averaged thermal capacity
    lifetime: int [years]
        Simulated lifetime of the plant, default: 50 years
    borehole_radius: float [m]
        Borehole radius
    pipe_radius: float [m]
        Pipe radius, default:
    number_pipes: int
        Number of pipes in the borehole, default: 4
    grout_conductivity: [W m-1 K-1]
        Thermal conductivity of the borehole filling (geothermal grout).
        Default: 2
    borehole_resistence: [m K W-1]
        Borehole thermal resistence
    borehole_length: [m]
        Borehole length, default: 100m
    ground_temperature: [°C]
        Initial ground temperature, default: 10 °C
    fluid_limit_temperature: [°C]
        Minimum or maximum fluid temperature, default: -2 °C
    """
    pid = os.getpid()
    DEBUG = flags['d']
    OVER = gcore.overwrite()
    tmpbase = "tmprgreen_%i" % pid
    atexit.register(cleanup, pattern=(tmpbase + '*'), debug=DEBUG)

    heating_season = rast_or_numb('heating_season_raster',
                                  'heating_season_value', opts)
    lifetime = float(opts['lifetime']) * 365 * 24 * 60 * 60

    # ================================================
    # GROUND
    # get raster or scalar value
    ground_conductivity = opts['ground_conductivity']
    ground_capacity = rast_or_numb('ground_capacity_raster',
                                   'ground_capacity_value', opts)
    ground_temperature = rast_or_numb('ground_temp_raster',
                                      'ground_temp_value', opts)

    # ================================================
    # BHE
    pipe_radius = float(opts['pipe_radius'])
    number_pipes = float(opts['number_pipes'])
    grout_conductivity = float(opts['grout_conductivity'])
    fluid_limit_temperature = float(opts['fluid_limit_temperature'])

    # ================================================s
    # BOREHOLE
    borehole_radius = float(opts['borehole_radius'])
    borehole_length = float(opts['borehole_length'])
    if opts['borehole_resistence'] == 'nan':
        borehole_resistence = gpot.get_borehole_resistence(
            borehole_radius, pipe_radius, number_pipes, grout_conductivity)
    else:
        borehole_resistence = float(opts['borehole_resistence'])

    # START COMPUTATIONS
    uc = tmpbase + '_uc'
    gpot.r_norm_time(uc,
                     heating_season,
                     borehole_radius,
                     ground_conductivity,
                     ground_capacity,
                     execute=True,
                     overwrite=OVER)
    us = tmpbase + '_us'
    gpot.r_norm_time(us,
                     lifetime,
                     borehole_radius,
                     ground_conductivity,
                     ground_capacity,
                     execute=True,
                     overwrite=OVER)

    tc = tmpbase + '_tc'
    gpot.r_tc(tc, heating_season)

    gmax = tmpbase + '_gmax'
    gpot.r_norm_thermal_alteration(gmax,
                                   tc,
                                   uc,
                                   us,
                                   execute=True,
                                   overwrite=OVER)

    power = opts['power']
    gpot.r_power(power,
                 tc,
                 ground_conductivity,
                 ground_temperature,
                 fluid_limit_temperature,
                 borehole_length,
                 borehole_resistence,
                 gmax,
                 execute=True,
                 overwrite=OVER)
    command = "{new} = if({old}<0, null(), {old})".format(old=power, new=power)
    mapcalc(command, overwrite=True)

    energy = opts['energy']
    gpot.r_energy(energy, power, execute=True, overwrite=OVER)
Exemple #2
0
def main(opts, flgs):
    """
    Parameters
    ----------
    heating_season: int [days]
        Number of heating days, default: 180 days
    ground_conductivity: float [W m-1 K-1]
        Depth averaged thermal conductivity
    ground_capacity: float [M J m-3 K-1]
        Depth averaged thermal capacity
    lifetime: int [years]
        Simulated lifetime of the plant, default: 50 years
    borehole_radius: float [m]
        Borehole radius
    pipe_radius: float [m]
        Pipe radius, default:
    number_pipes: int
        Number of pipes in the borehole, default: 4
    grout_conductivity: [W m-1 K-1]
        Thermal conductivity of the borehole filling (geothermal grout).
        Default: 2
    borehole_resistence: [m K W-1]
        Borehole thermal resistence
    borehole_length: [m]
        Borehole length, default: 100m
    ground_temperature: [°C]
        Initial ground temperature, default: 10 °C
    fluid_limit_temperature: [°C]
        Minimum or maximum fluid temperature, default: -2 °C
    """
    pid = os.getpid()
    DEBUG = flags["d"]
    OVER = gcore.overwrite()
    tmpbase = "tmprgreen_%i" % pid
    atexit.register(cleanup, pattern=(tmpbase + "*"), debug=DEBUG)

    heating_season = rast_or_numb("heating_season_raster",
                                  "heating_season_value", opts)
    lifetime = float(opts["lifetime"]) * 365 * 24 * 60 * 60

    # ================================================
    # GROUND
    # get raster or scalar value
    ground_conductivity = opts["ground_conductivity"]
    ground_capacity = rast_or_numb("ground_capacity_raster",
                                   "ground_capacity_value", opts)
    ground_temperature = rast_or_numb("ground_temp_raster",
                                      "ground_temp_value", opts)

    # ================================================
    # BHE
    pipe_radius = float(opts["pipe_radius"])
    number_pipes = float(opts["number_pipes"])
    grout_conductivity = float(opts["grout_conductivity"])
    fluid_limit_temperature = float(opts["fluid_limit_temperature"])

    # ================================================s
    # BOREHOLE
    borehole_radius = float(opts["borehole_radius"])
    borehole_length = float(opts["borehole_length"])
    if opts["borehole_resistence"] == "nan":
        borehole_resistence = gpot.get_borehole_resistence(
            borehole_radius, pipe_radius, number_pipes, grout_conductivity)
    else:
        borehole_resistence = float(opts["borehole_resistence"])

    # START COMPUTATIONS
    uc = tmpbase + "_uc"
    season_temp = tmpbase + "_season_sec"
    mapcalc("{}={}*24*3600".format(season_temp, heating_season),
            overwrite=True)
    gpot.r_norm_time(
        uc,
        season_temp,
        borehole_radius,
        ground_conductivity,
        ground_capacity,
        execute=True,
        overwrite=OVER,
    )
    us = tmpbase + "_us"
    gpot.r_norm_time(
        us,
        lifetime,
        borehole_radius,
        ground_conductivity,
        ground_capacity,
        execute=True,
        overwrite=OVER,
    )

    tc = tmpbase + "_tc"
    gpot.r_tc(tc, heating_season)

    gmax = tmpbase + "_gmax"
    gpot.r_norm_thermal_alteration(gmax,
                                   tc,
                                   uc,
                                   us,
                                   execute=True,
                                   overwrite=OVER)

    power = opts["power"]
    gpot.r_power(
        power,
        tc,
        ground_conductivity,
        ground_temperature,
        fluid_limit_temperature,
        borehole_length,
        borehole_resistence,
        gmax,
        execute=True,
        overwrite=OVER,
    )
    command = "{new} = if({old}<0, null(), {old})".format(old=power, new=power)
    mapcalc(command, overwrite=True)
    # TODO: add warning

    energy = opts["energy"]
    gpot.r_energy(energy, power, execute=True, overwrite=OVER)