| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- from copy import deepcopy
- import numpy as np
- import pandas as pd
- import psychrolib
- psychrolib.SetUnitSystem(psychrolib.SI)
- get_Enthalpy = np.vectorize(psychrolib.GetMoistAirEnthalpy)
- from .._model._base import BaseModel
- from ..components.coil import CoolingCoil
- from ..components.wheel import WheelS2,WheelS3
- from ..components.mixed import Mixed
- class DHU_1(BaseModel):
-
-
- def __init__(self) -> None:
- super().__init__()
-
- def fit(self,param):
- self.record_model(
- model_name = 'AIR',
- model = param,
- train_data = {'x':np.array([1])},
- train_metric = {'R2':1,'MAE':1,'MAPE':1}
- )
- return self
-
- def fit2(self,input_data:dict,observe_data:dict):
- import pymc as pm
- with pm.Model() as self.MODEL:
- prior = {
- 'coil_1' : CoolingCoil.prior('coil_1'),
- 'coil_2' : CoolingCoil.prior('coil_2'),
- 'coil_3' : CoolingCoil.prior('coil_3'),
- 'wheel_1': WheelS2.prior('wheel_1'),
- 'wheel_2': WheelS3.prior('wheel_2'),
- }
- output = self.model(**input_data,engine='pymc',param=prior)
-
-
- def predict(self,**kwargs) -> dict:
- param = self.model_info['model_AIR']
- kwargs = deepcopy(kwargs)
- COP = kwargs.pop('COP')
- price_E = kwargs.pop('price_E')
- price_S = kwargs.pop('price_S')
- pred_res = self.model(**kwargs,engine='numpy',param=param)
-
- # 中表冷冷量
- coil_2_Ein = get_Enthalpy(pred_res['mixed_1']['ToutA'],pred_res['mixed_1']['HoutA'])
- coil_2_Eout = get_Enthalpy(pred_res['coil_2']['ToutA'],pred_res['coil_2']['HoutA'])
- pred_res['coil_2']['Q'] = (coil_2_Eout - coil_2_Ein) * (pred_res['F_air']['FF_air']*66000) / (3.6*10**6)
-
- # 后表冷冷量
- coil_3_Ein = get_Enthalpy(pred_res['wheel_2']['ToutP'],pred_res['wheel_2']['HoutP'])
- coil_3_Eout = get_Enthalpy(pred_res['coil_3']['ToutA'],pred_res['coil_3']['HoutA'])
- pred_res['coil_3']['Q'] = (coil_3_Eout - coil_3_Ein) * (pred_res['F_air']['FR_air']*66000) / (3.6*10**6)
-
- # 前再生热量
- steamcoil_1_Ein = get_Enthalpy(pred_res['mixed_2']['ToutA'],pred_res['mixed_2']['HoutA'])
- steamcoil_1_Eout = get_Enthalpy(kwargs['wheel_1_TinR'],pred_res['mixed_2']['HoutA'])
- pred_res['steamcoil_1']['Q'] = (steamcoil_1_Eout - steamcoil_1_Ein) * (pred_res['F_air']['FO_air']*66000) / (3.6*10**6)
-
- # 后再生热量
- steamcoil_2_Ein = get_Enthalpy(pred_res['wheel_2']['ToutC'],pred_res['wheel_2']['HoutC'])
- steamcoil_2_Eout = get_Enthalpy(kwargs['wheel_2_TinR'],pred_res['wheel_2']['HoutC'])
- pred_res['steamcoil_2']['Q'] = (steamcoil_2_Eout - steamcoil_2_Ein) * ((pred_res['F_air']['FO_air']-pred_res['F_air']['FS_air'])*66000) / (3.6*10**6)
-
- # 前转轮焓升
- wheel_1_EinP = get_Enthalpy(pred_res['coil_1']['ToutA'],pred_res['coil_1']['HoutA'])
- wheel_1_EoutP = get_Enthalpy(pred_res['wheel_1']['ToutP'],pred_res['wheel_1']['HoutP'])
- pred_res['wheel_1']['E_diff'] = (wheel_1_EoutP - wheel_1_EinP) / 1000
-
- # 后转轮焓升
- wheel_2_EinP = get_Enthalpy(pred_res['coil_2']['ToutA'],pred_res['coil_2']['HoutA'])
- wheel_2_EoutP = get_Enthalpy(pred_res['wheel_2']['ToutP'],pred_res['wheel_2']['HoutP'])
- pred_res['wheel_2']['E_diff'] = (wheel_2_EoutP - wheel_2_EinP) / 1000
-
- # 耗冷费用折算
- pred_res['summary']['cost_cooling'] = np.abs(pred_res['coil_2']['Q'] + pred_res['coil_3']['Q']) / COP * price_E
-
- # 耗热费用折算
- pred_res['summary']['cost_heating'] = (pred_res['steamcoil_1']['Q'] + pred_res['steamcoil_2']['Q']) *3600/2260/1000*price_S
-
- # 冷热费用合计
- pred_res['summary']['cost_total'] = pred_res['summary']['cost_cooling'] + pred_res['summary']['cost_heating']
-
- return pred_res
-
- def predict_system(self,**kwargs) -> pd.DataFrame:
- pred_res = self.predict(**kwargs)
- system_output = {}
- for equp_name,output_info in pred_res.items():
- for output_name,output_value in output_info.items():
- system_output[f'{equp_name}_{output_name}'] = output_value
- system_output = dict(zip(
- system_output.keys(),
- np.broadcast_arrays(*system_output.values())
- ))
- system_output = pd.DataFrame(system_output)
- return system_output
-
-
- @classmethod
- def model(
- cls,
- Tin_F, # 新风温度
- Hin_F, # 新风湿度
- HzP, # 处理侧风机频率
- HzR, # 再生侧风机频率
- coil_1_TinW, # 前表冷进水温度
- coil_2_TinW, # 中表冷进水温度
- coil_3_TinW, # 后表冷进水温度
- coil_1_Val, # 前表冷阀门开度
- coil_2_Val, # 中表冷阀门开度
- coil_3_Val, # 后表冷阀门开度
- wheel_1_TinR, # 前转轮再生侧温度
- wheel_2_TinR, # 后转轮再生侧温度
- mixed_1_TinM, # 回风温度(处理侧)
- mixed_1_HinM, # 回风湿度(处理侧)
- mixed_2_TinM, # 补风温度(再生侧)
- mixed_2_HinM, # 补风湿度(再生侧)
- engine,
- param
- ) -> dict:
- # 空气的质量流量
- FF_air = 1 # 新风
- FB_air = 0 # 回风
- FR_air = 0.74 # 送风
- FS_air = 0.2 # 补风
- FO_air = FF_air + FB_air + FS_air - FR_air # 排风
-
- # 水的质量流量
- coil_1_FW = coil_1_Val
- coil_2_FW = coil_2_Val
- coil_3_FW = coil_3_Val
-
-
- # 前表冷
- coil_1_res = CoolingCoil.model(
- TinA = Tin_F,
- HinA = Hin_F,
- FA = FF_air,
- TinW = coil_1_TinW,
- FW = coil_1_FW,
- engine = engine,
- param = param['coil_1']
- )
-
- # 前转轮
- wheel_1_res = WheelS2.model(
- TinP = coil_1_res['ToutA'],
- HinP = coil_1_res['HoutA'],
- FP = FF_air,
- TinR = wheel_1_TinR,
- HinR = 0,
- FR = FO_air,
- engine = engine,
- param = param['wheel_1']
- )
-
- # 处理侧混风(回风)
- mixed_1_res = Mixed.model(
- TinA = wheel_1_res['ToutP'],
- HinA = wheel_1_res['HoutP'],
- FA = FF_air,
- TinM = mixed_1_TinM,
- HinM = mixed_1_HinM,
- FM = FB_air,
- engine = engine
- )
-
- # 中表冷
- coil_2_res = CoolingCoil.model(
- TinA = mixed_1_res['ToutA'],
- HinA = mixed_1_res['HoutA'],
- FA = FR_air,
- TinW = coil_2_TinW,
- FW = coil_2_FW,
- engine = engine,
- param = param['coil_2']
- )
-
-
- # 后转轮
- wheel_2_res = WheelS3.model(
- TinP = coil_2_res['ToutA'],
- HinP = coil_2_res['HoutA'],
- FP = FR_air,
- TinC = wheel_1_res['ToutP'],
- HinC = wheel_1_res['HoutP'],
- FC = FO_air-FS_air,
- TinR = wheel_2_TinR,
- HinR = wheel_1_res['HoutP'],
- FR = FO_air-FS_air,
- engine = engine,
- param = param['wheel_2'],
- )
-
- # 后表冷
- coil_3_res = CoolingCoil.model(
- TinA = wheel_2_res['ToutP'],
- HinA = wheel_2_res['HoutP'],
- FA = FR_air,
- TinW = coil_3_TinW,
- FW = coil_3_FW,
- engine = engine,
- param = param['coil_3']
- )
-
- # 再生侧混风(排风)
- mixed_2_res = Mixed.model(
- TinA = wheel_2_res['ToutR'],
- HinA = wheel_2_res['HoutR'],
- FA = FO_air-FS_air,
- TinM = mixed_2_TinM,
- HinM = mixed_2_HinM,
- FM = FS_air,
- engine = engine
- )
-
- # 前转轮湿度修正
- wheel_1_res_adj = WheelS2.model(
- TinP = coil_1_res['ToutA'],
- HinP = coil_1_res['HoutA'],
- FP = FF_air,
- TinR = wheel_1_TinR,
- HinR = mixed_2_res['HoutA'],
- FR = FO_air,
- engine = engine,
- param = param['wheel_1']
- )
-
- return {
- 'coil_1' : coil_1_res,
- 'coil_2' : coil_2_res,
- 'coil_3' : coil_3_res,
- 'wheel_1' : wheel_1_res_adj,
- 'wheel_2' : wheel_2_res,
- 'mixed_1' : mixed_1_res,
- 'mixed_2' : mixed_2_res,
- 'steamcoil_1': {},
- 'steamcoil_2': {},
- 'F_air' : {
- 'FF_air': FF_air,
- 'FB_air': FB_air,
- 'FR_air': FR_air,
- 'FS_air': FS_air,
- 'FO_air': FO_air
- },
- 'summary':{}
- }
-
|