Пример #1
0
    def report_outputs(self) -> dict:
        d = {}
        for comp in self.components:
            d = merge_dicts(d, comp.report_outputs())

        d_self = {
            '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.FlowRate):
            self.flow_rate,
            '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.InletTemp):
            self.inlet_temperature,
            '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.OutletTemp):
            self.outlet_temperature
        }

        return merge_dicts(d, d_self)
Пример #2
0
    def test_merge_dict(self):
        d_merged = merge_dicts({'key 1': 1}, {'key 2': 2})
        self.assertTrue('key 1' in d_merged.keys())
        self.assertTrue('key 2' in d_merged.keys())

        self.assertEqual(d_merged['key 1'], 1)
        self.assertEqual(d_merged['key 2'], 2)
Пример #3
0
    def report_outputs(self) -> dict:
        d = {}
        for seg in self.segments:
            d = merge_dicts(d, seg.report_outputs())

        d = merge_dicts(d, self.pipe_1.report_outputs())

        d_self = {'{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.HeatRate): self.heat_rate,
                  '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.HeatRateBH): self.heat_rate_bh,
                  '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.InletTemp): self.inlet_temperature,
                  '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.OutletTemp): self.outlet_temperature,
                  '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.BHResist): self.resist_bh_ave,
                  '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.BHIntResist): self.resist_bh_total_internal,
                  '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.BHDCResist): self.resist_bh_direct_coupling}

        return merge_dicts(d, d_self)
Пример #4
0
    def collect_outputs(self, sim_time):

        # record current time
        d = {'Elapsed Time [s]': sim_time}

        # report outputs from the PlantLoop object
        d = merge_dicts(d, self.report_outputs())

        # collect reports from demand components
        for comp in self.demand_comps:
            d = merge_dicts(d, comp.report_outputs())

        # collect outputs from the supply components
        for comp in self.supply_comps:
            d = merge_dicts(d, comp.report_outputs())

        # finalize collection by the OutputProcessor
        self.op.collect_output(d)
    def report_outputs(self):
        d = {}
        d = merge_dicts(d, self.ave_bh.report_outputs())
        d_self = {
            '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.HeatRate):
            self.heat_rate,
            '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.InletTemp):
            self.inlet_temperature,
            '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.OutletTemp):
            self.outlet_temperature,
            '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.BHWallTemp):
            self.bh_wall_temperature,
            '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.BHResist):
            self.resist_b,
            '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.BHEffResist):
            self.resist_b_eff
        }

        return merge_dicts(d, d_self)
    def report_outputs(self) -> dict:
        d = {}
        for path in self.paths:
            d = merge_dicts(d, path.report_outputs())

        d_self = {
            '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.HeatRate):
            self.heat_rate,
            '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.HeatRateBH):
            self.heat_rate_bh,
            '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.InletTemp):
            self.inlet_temperature,
            '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.OutletTemp):
            self.outlet_temperature,
            '{:s}:{:s}:{:s}'.format(self.Type, self.name, ReportTypes.BHWallTemp):
            self.bh_wall_temperature
        }

        return merge_dicts(d, d_self)
    def __init__(self, inputs: dict, ip: InputProcessor, op: OutputProcessor):
        SimulationEntryPoint.__init__(self, inputs)
        self.ip = ip
        self.op = op

        # props instances
        self.fluid = ip.props_mgr.fluid
        self.soil = ip.props_mgr.soil

        # init paths
        self.paths = []
        for path in inputs['flow-paths']:
            self.paths.append(Path(path, ip, op))

        # some stats about the bh field
        self.h = self.calc_bh_ave_length()
        self.num_bh = self.count_bhs()
        self.num_paths = len(self.paths)

        # generate the g-function data
        self.ts = self.h**2 / (9 * self.soil.diffusivity)
        self.lntts = None
        self.g = None
        self.lntts_b = None
        self.g_b = None

        if 'g-function-path' in inputs:
            data_g = np.genfromtxt(inputs['g-function-path'], delimiter=',')
            self.lntts = data_g[:, 0]
            self.g = data_g[:, 1]
        else:
            self.generate_g()

        # load aggregation method
        la_inputs = merge_dicts(inputs['load-aggregation'], {
            'lntts': self.lntts,
            'g-values': self.g,
            'time-scale': self.ts
        })
        self.load_agg = make_agg_method(la_inputs, ip)

        # other
        self.energy = 0
        self.c_0 = 1 / (2 * pi * self.soil.conductivity)

        # report variables
        self.heat_rate = 0
        self.heat_rate_bh = 0
        self.flow_rate = 0
        self.inlet_temperature = ip.init_temp()
        self.outlet_temperature = ip.init_temp()
        self.bh_wall_temperature = ip.init_temp()
Пример #8
0
    def __init__(self, inputs, ip, op):
        try:  # pragma: no cover
            self.name = inputs['name'].upper()
        except KeyError:  # pragma: no cover
            pass  # pragma: no cover

        self.ip = ip
        self.op = op

        self.h = inputs['length']
        self.start_time = inputs['start-time']
        sim_time = ip.input_dict['simulation']['runtime']

        self.load_agg = Dynamic(merge_dicts(inputs['load-aggregation'], {'runtime': sim_time - self.start_time}))
        self.loads = ExternalBase(inputs['load-data-path'], col_num=0)
Пример #9
0
    def __init__(self, inputs, ip, op):
        SimulationEntryPoint.__init__(self, inputs)
        self.ip = ip
        self.op = op

        try:
            self.sim_mode = inputs['simulation-mode']
        except KeyError:
            raise KeyError(
                "'simulation-mode' key not found")  # pragma: no cover

        if self.sim_mode == 'enhanced':
            # init TRCM model
            self.sts_ghe = GroundHeatExchangerSTS(inputs, ip, op)

            if 'g_b-function-path' not in inputs:
                if 'g_b-flow-rate' not in inputs:
                    self.sts_ghe.generate_g_b()
                else:
                    self.sts_ghe.generate_g_b(inputs['g_b-flow-rate'])

            # init enhanced model
            d_bh_ave = self.sts_ghe.average_bh()
            lts_inputs = merge_dicts(
                inputs, {
                    'length': self.sts_ghe.h,
                    'number-boreholes': self.sts_ghe.num_bh,
                    'average-borehole': d_bh_ave
                })

            self.lts_ghe = GroundHeatExchangerLTS(lts_inputs, ip, op)

            # alias functions based on sim mode
            self.simulate_time_step = self.lts_ghe.simulate_time_step
            self.report_outputs = self.lts_ghe.report_outputs

        elif self.sim_mode == 'direct':
            # init TRCM model only
            self.sts_ghe = GroundHeatExchangerSTS(inputs, ip, op)

            # alias functions based on sim mode
            self.simulate_time_step = self.sts_ghe.simulate_time_step
            self.report_outputs = self.sts_ghe.report_outputs

        else:
            raise ValueError("Simulation mode '{]' is not valid".format(
                self.sim_mode))  # pragma: no cover
Пример #10
0
def make_agg_method(inputs: dict, ip: InputProcessor):
    """
    Factory method for creating load aggregation objects

    :param inputs: load aggregation inputs
    :param ip: input processor instance
    :return: load aggregation object
    """

    method = inputs['method']
    if method == 'static':
        return Static(inputs)
    elif method == 'dynamic':
        inputs = merge_dicts(
            inputs, {'runtime': ip.input_dict['simulation']['runtime']})
        return Dynamic(inputs)
    elif method == 'none':
        return NoAgg(inputs)
    else:
        raise ValueError(
            "Load aggregation method '{}' is not valid.".format(method))
    def __init__(self, inputs: dict, ip: InputProcessor, op: OutputProcessor):
        SimulationEntryPoint.__init__(self, inputs)
        self.ip = ip
        self.op = op

        # props instances
        self.fluid = ip.props_mgr.fluid
        self.soil = ip.props_mgr.soil

        # geometry and other config parameters needed externally
        self.h = inputs['length']
        self.num_bh = inputs['number-boreholes']
        self.num_paths = len(inputs['flow-paths'])

        # load aggregation method
        ts = self.h**2 / (9 * self.soil.diffusivity)
        la_inputs = merge_dicts(
            inputs['load-aggregation'], {
                'g-function-path': inputs['g-function-path'],
                'g_b-function-path': inputs['g_b-function-path'],
                'time-scale': ts
            })

        if 'g_b-flow-rates' in inputs:
            la_inputs['g_b-flow-rates'] = inputs['g_b-flow-rates']
        self.load_agg = make_agg_method(la_inputs, ip)

        # average borehole
        d_ave_bh = {
            'average-borehole': inputs['average-borehole'],
            'name': 'average-borehole',
            'borehole-type': 'single-grouted'
        }
        self.ave_bh = make_borehole(d_ave_bh, ip, op)

        self.cross_ghe_present = False
        self.cross_ghe = []
        if 'cross-loads' in inputs:
            self.cross_ghe_present = True
            for x_ghe in inputs['cross-loads']:
                d_x = {
                    'load-aggregation':
                    merge_dicts(
                        inputs['load-aggregation'], {
                            'g-function-path': x_ghe['g-function-path'],
                            'time-scale': ts
                        }),
                    'load-data-path':
                    x_ghe['load-data-path'],
                    'start-time':
                    x_ghe['start-time'],
                    'length':
                    x_ghe['length']
                }
                if 'number-of-instances' in x_ghe:
                    num_duplicates = x_ghe['number-of-instances']
                else:
                    num_duplicates = 1
                for idx in range(num_duplicates):
                    self.cross_ghe.append(CrossGHE(d_x, ip, op))

        # method constants
        k_s = self.soil.conductivity
        self.c_0 = 1 / (2 * pi * k_s)

        # heat rate (W/m)
        self.q = 0

        # energy (J/m)
        self.energy = 0

        # report variables
        self.heat_rate = 0
        self.inlet_temperature = ip.init_temp()
        self.outlet_temperature = ip.init_temp()
        self.bh_wall_temperature = ip.init_temp()
        self.resist_b = 0
        self.resist_b_eff = 0