Пример #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)
def main(opts, flgs):
    """
    Parameters
    ----------

    ground_conductivity: k [W m-1 K-1]
        thermal conductivity
    ground_diffusivity: α [m2 day-1]
        thermal diffusivity
    ground_temperature: Tg [°C]
        Undisturbed ground temperature
    g_loads_6h [W]
        Peak of 6 hours ground load
    g_loads_1m:  [W]
        Maximum monthly ground load
    g_loads_1y: qy [W]
        Average ground load
    fluid_capacity: Cp [J kg-1 K-1]
        Thermal heat capacity of the fluid
    fluid_massflow: mfls [kg s-1 kW-1]
        total mass flow rate per kW of peak hourly ground load
    fluid_inlettemp: TinHP [°C]
        max/min heat pump inlet temperature
    bh_radius: radius [m]
        borehole radius
    bh_convection: hconv [W m-2 K-1]
        Internal convection coefficient
    pipe_inner: rpin [m]
        pipe inner radius
    pipe_outer: rpext [m]
        pipe outer radius
    pipe_distance: LU [m]
        center-to-center distance between pipes
    k_pipe: kpipe [W m-1 K-1]
        pipe thermal conductivity
    k_grout: kgrout [W m-1 K-1]
        grout thermal conductivity
    distance_bhe: B [m]
        distance between boreholes (BHE)
    number_bhe: [n]
        number of boreholes (BHE)
    ratio_bhe: [-]
        borefield aspect ratio

    >>> bhe = BoreholeExchanger(
    ...           ground_loads=GroundLoads(hourly='g_loads_6h',
    ...                                    monthly='g_loads_1m',
    ...                                    yearly='g_loads_1y'),
    ...           ground=GroundProperties(conductivity='g_conductivity',
    ...                                   diffusivity='g_diffusivity',
    ...                                   temperature='g_temperature'),
    ...           fluid=FluidProperties(capacity=4200, massflow=0.050,
    ...                                 inlettemp=40.2),
    ...           borehole=Borehole(radius=0.06,
    ...                             pipe_inner_radius=0.01365,
    ...                             pipe_outer_radius=0.0167,
    ...                             k_pipe=0.42, k_grout=1.5, distance=0.0511,
    ...                             convection=1000.)
    ...           )
    >>> infovars = InfoVars('l_term', 'm_term', 's_term', 'f_temp', 'res')
    >>> r_bhe_length('bhe_length', bhe, infovars, execute=False)
    """
    DEBUG = flags['d']
    OVER = gcore.overwrite()
    tmpbase = "tmprgreen_%i" % os.getpid()
    atexit.register(cleanup, pattern=(tmpbase + '*'), debug=DEBUG)

    # ================================================
    # GROUND
    # get raster or scalar value
    ground = GroundProperties(
        opts['ground_conductivity'],
        rast_or_numb('ground_diffusivity_rast', 'ground_diffusivity_value',
                     opts),
        rast_or_numb('ground_temp_rast', 'ground_temp_value', opts))

    # ================================================
    # GROUND LOADS
    ground_loads = GroundLoads(
        rast_or_numb('g_loads_6h_rast', 'g_loads_6h_value', opts),
        rast_or_numb('g_loads_1m_rast', 'g_loads_1m_value', opts),
        rast_or_numb('g_loads_1y_rast', 'g_loads_1y_value', opts))

    # ================================================
    # FLUID
    fluid = FluidProperties(float(opts['fluid_capacity']),
                            float(opts['fluid_massflow']),
                            float(opts['fluid_inlettemp']))

    # ================================================
    # BOREHOLE
    borehole = Borehole(radius=float(opts['bh_radius']),
                        pipe_inner_radius=float(opts['pipe_inner_radius']),
                        pipe_outer_radius=float(opts['pipe_outer_radius']),
                        k_pipe=float(opts['k_pipe']),
                        k_grout=float(opts['k_grout']),
                        distance=float(opts['pipe_distance']),
                        convection=float(opts['bh_convection']))

    bhe = BoreholeExchanger(ground_loads, ground, fluid, borehole)

    field = BoreholeField(float(opts['field_distance']),
                          float(opts['field_number']),
                          float(opts['field_ratio']), bhe)

    # ================================================
    # START COMPUTATIONS
    infovars = get_vars(opts['bhe_length'],
                        bhe,
                        tmpbase,
                        execute=True,
                        overwrite=OVER)

    r_bhe_length(opts['bhe_length'],
                 bhe,
                 infovars,
                 execute=True,
                 overwrite=OVER)
    r_field_length(opts['bhe_field_length'],
                   field,
                   infovars,
                   basename=tmpbase,
                   length_single=opts['bhe_length'],
                   execute=True,
                   overwrite=OVER)
Пример #3
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)