|
@@ -6,10 +6,10 @@ import pytensor.tensor as pt
|
|
|
from .._base._base_device import BaseDevice
|
|
from .._base._base_device import BaseDevice
|
|
|
from ...components.coil_water import CoolingCoil2
|
|
from ...components.coil_water import CoolingCoil2
|
|
|
from ...components.coil_steam import SteamCoilFs,SteamCoilFs2,SteamCoil
|
|
from ...components.coil_steam import SteamCoilFs,SteamCoilFs2,SteamCoil
|
|
|
-from ...components.wheel import WheelS3
|
|
|
|
|
|
|
+from ...components.wheel3 import WheelS3,WheelS3V2,WheelS3V3
|
|
|
from ...components.mixed import Mixed
|
|
from ...components.mixed import Mixed
|
|
|
from ..utils.fit_utils import (
|
|
from ..utils.fit_utils import (
|
|
|
- observe,record,reorder_posterior,get_fitted_result
|
|
|
|
|
|
|
+ observe,record,reorder_posterior
|
|
|
)
|
|
)
|
|
|
from ...tools.optimizer import optimizer
|
|
from ...tools.optimizer import optimizer
|
|
|
|
|
|
|
@@ -48,8 +48,8 @@ class DHU_A(BaseDevice):
|
|
|
'steamcoil_2_FP' : 'steamcoil_2_FP',
|
|
'steamcoil_2_FP' : 'steamcoil_2_FP',
|
|
|
'steamcoil_1_Fs' : 'steamcoil_1_Fs',
|
|
'steamcoil_1_Fs' : 'steamcoil_1_Fs',
|
|
|
'steamcoil_2_Fs' : 'steamcoil_2_Fs',
|
|
'steamcoil_2_Fs' : 'steamcoil_2_Fs',
|
|
|
- 'steamcoil_1_Val': 'steamcoil_1_Val',
|
|
|
|
|
- 'steamcoil_2_Val': 'steamcoil_2_Val',
|
|
|
|
|
|
|
+ # 'steamcoil_1_Val': 'steamcoil_1_Val',
|
|
|
|
|
+ # 'steamcoil_2_Val': 'steamcoil_2_Val',
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
def __init__(self) -> None:
|
|
def __init__(self) -> None:
|
|
@@ -59,10 +59,10 @@ class DHU_A(BaseDevice):
|
|
|
WheelS3('wheel_2'),
|
|
WheelS3('wheel_2'),
|
|
|
CoolingCoil2('coil_2'),
|
|
CoolingCoil2('coil_2'),
|
|
|
CoolingCoil2('coil_3'),
|
|
CoolingCoil2('coil_3'),
|
|
|
- # SteamCoil('steamcoil_1'),
|
|
|
|
|
- # SteamCoil('steamcoil_2'),
|
|
|
|
|
- SteamCoilFs2('steamcoil_1'),
|
|
|
|
|
- SteamCoilFs('steamcoil_2'),
|
|
|
|
|
|
|
+ SteamCoil('steamcoil_1'),
|
|
|
|
|
+ SteamCoil('steamcoil_2'),
|
|
|
|
|
+ # SteamCoilFs2('steamcoil_1'),
|
|
|
|
|
+ # SteamCoilFs('steamcoil_2'),
|
|
|
Mixed('mixed_1'),
|
|
Mixed('mixed_1'),
|
|
|
Mixed('mixed_2'),
|
|
Mixed('mixed_2'),
|
|
|
]
|
|
]
|
|
@@ -72,14 +72,21 @@ class DHU_A(BaseDevice):
|
|
|
self,
|
|
self,
|
|
|
input_data : pd.DataFrame,
|
|
input_data : pd.DataFrame,
|
|
|
observed_data: pd.DataFrame,
|
|
observed_data: pd.DataFrame,
|
|
|
|
|
+ exist_Fa_H : bool,
|
|
|
|
|
+ exist_Fa_B : bool,
|
|
|
rw_FA_val : bool = False,
|
|
rw_FA_val : bool = False,
|
|
|
- plot_TVP : bool = True
|
|
|
|
|
|
|
+ plot_TVP : bool = True,
|
|
|
):
|
|
):
|
|
|
with pm.Model() as self.MODEL_PYMC:
|
|
with pm.Model() as self.MODEL_PYMC:
|
|
|
param_prior = {name:comp.prior() for name,comp in self.components.items()}
|
|
param_prior = {name:comp.prior() for name,comp in self.components.items()}
|
|
|
- param_prior['F_air'] = AirFlow.prior(rw_FA_val=rw_FA_val,N=len(input_data))
|
|
|
|
|
|
|
+ param_prior['F_air'] = AirFlow_DHU_AB.prior(
|
|
|
|
|
+ rw_FA_val = rw_FA_val,
|
|
|
|
|
+ N = len(input_data),
|
|
|
|
|
+ exist_Fa_H = exist_Fa_H,
|
|
|
|
|
+ exist_Fa_B = exist_Fa_B
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
- res = DHU_A.model(
|
|
|
|
|
|
|
+ res = self.model(
|
|
|
**{k:input_data.loc[:,v].values for k,v in self.model_input_data_columns.items()},
|
|
**{k:input_data.loc[:,v].values for k,v in self.model_input_data_columns.items()},
|
|
|
engine = 'pymc',
|
|
engine = 'pymc',
|
|
|
components = self.components,
|
|
components = self.components,
|
|
@@ -95,14 +102,15 @@ class DHU_A(BaseDevice):
|
|
|
observe('coil_2_ToutA',res['coil_2']['ToutA'],observed=observed_data)
|
|
observe('coil_2_ToutA',res['coil_2']['ToutA'],observed=observed_data)
|
|
|
observe('coil_2_DoutA',res['coil_2']['DoutA'],observed=observed_data)
|
|
observe('coil_2_DoutA',res['coil_2']['DoutA'],observed=observed_data)
|
|
|
observe('wheel_2_ToutP',res['wheel_2']['ToutP'],observed=observed_data)
|
|
observe('wheel_2_ToutP',res['wheel_2']['ToutP'],observed=observed_data)
|
|
|
- observe('wheel_2_DoutP',res['wheel_2']['DoutP'],observed=observed_data)
|
|
|
|
|
|
|
+ observe('wheel_2_DoutP',res['wheel_2']['DoutP'],observed=observed_data,sigma=0.3)
|
|
|
observe('wheel_2_ToutR',res['wheel_2']['ToutR'],observed=observed_data)
|
|
observe('wheel_2_ToutR',res['wheel_2']['ToutR'],observed=observed_data)
|
|
|
|
|
+ #TODO observe wheel_2_ToutC
|
|
|
|
|
|
|
|
- observe('steamcoil_1_FP',res['steamcoil_1']['FP'],observed=observed_data,sigma=1000)
|
|
|
|
|
- observe('steamcoil_1_Fs',res['steamcoil_1']['Fs'],observed=observed_data,sigma=20)
|
|
|
|
|
- observe('steamcoil_2_Fs',res['steamcoil_2']['Fs'],observed=observed_data,sigma=20)
|
|
|
|
|
- # record('steamcoil_1_Fs',res['steamcoil_1']['Fs'])
|
|
|
|
|
- # record('steamcoil_2_Fs',res['steamcoil_2']['Fs'])
|
|
|
|
|
|
|
+ # observe('steamcoil_1_FP',res['steamcoil_1']['FP'],observed=observed_data,sigma=10000)
|
|
|
|
|
+ # observe('steamcoil_1_Fs',res['steamcoil_1']['Fs'],observed=observed_data,sigma=20)
|
|
|
|
|
+ # observe('steamcoil_2_Fs',res['steamcoil_2']['Fs'],observed=observed_data,sigma=20)
|
|
|
|
|
+ record('steamcoil_1_Fs',res['steamcoil_1']['Fs'])
|
|
|
|
|
+ record('steamcoil_2_Fs',res['steamcoil_2']['Fs'])
|
|
|
|
|
|
|
|
record('wheel_2_ToutC',res['wheel_2']['ToutC'])
|
|
record('wheel_2_ToutC',res['wheel_2']['ToutC'])
|
|
|
record('mixed_2_ToutA',res['mixed_2']['ToutA'])
|
|
record('mixed_2_ToutA',res['mixed_2']['ToutA'])
|
|
@@ -117,34 +125,17 @@ class DHU_A(BaseDevice):
|
|
|
self.param_posterior = pm.find_MAP(maxeval=50000,include_transformed=False)
|
|
self.param_posterior = pm.find_MAP(maxeval=50000,include_transformed=False)
|
|
|
|
|
|
|
|
self.record_model(
|
|
self.record_model(
|
|
|
- model_name = 'DHU',
|
|
|
|
|
|
|
+ model_name = 'ATD',
|
|
|
model = reorder_posterior(param_prior,self.param_posterior),
|
|
model = reorder_posterior(param_prior,self.param_posterior),
|
|
|
train_data = {'x':np.array([1])},
|
|
train_data = {'x':np.array([1])},
|
|
|
train_metric = {'R2':1,'MAE':1,'MAPE':1}
|
|
train_metric = {'R2':1,'MAE':1,'MAPE':1}
|
|
|
)
|
|
)
|
|
|
- self.TVP_data,self.TVP_metric = get_fitted_result(self.param_posterior,observed_data,plot_TVP)
|
|
|
|
|
|
|
+ self.TVP_data = self.get_TVP(self.param_posterior,observed_data)
|
|
|
|
|
+ self.TVP_metric = self.get_metric(self.TVP_data)
|
|
|
|
|
+ if plot_TVP:
|
|
|
|
|
+ self.plot_TVP(self.TVP_data).show()
|
|
|
return self
|
|
return self
|
|
|
|
|
|
|
|
- def predict(self,input_data:pd.DataFrame) -> dict:
|
|
|
|
|
- param_posterior = self.model_info['model_DHU']
|
|
|
|
|
- res = DHU_A.model(
|
|
|
|
|
- **{k:input_data.loc[:,v].values for k,v in self.model_input_data_columns.items()},
|
|
|
|
|
- engine = 'numpy',
|
|
|
|
|
- components = self.components,
|
|
|
|
|
- param = param_posterior
|
|
|
|
|
- )
|
|
|
|
|
- return res
|
|
|
|
|
-
|
|
|
|
|
- def predict_system(self,input_data:pd.DataFrame) -> pd.DataFrame:
|
|
|
|
|
- pred_res = self.predict(input_data)
|
|
|
|
|
- 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 = pd.DataFrame(system_output)
|
|
|
|
|
- system_output['Fs'] = system_output.steamcoil_1_Fs + system_output.steamcoil_2_Fs
|
|
|
|
|
- return system_output
|
|
|
|
|
-
|
|
|
|
|
def optimize(
|
|
def optimize(
|
|
|
self,
|
|
self,
|
|
|
cur_input_data : pd.DataFrame,
|
|
cur_input_data : pd.DataFrame,
|
|
@@ -152,7 +143,8 @@ class DHU_A(BaseDevice):
|
|
|
wheel_1_TinR_lb: float = 70,
|
|
wheel_1_TinR_lb: float = 70,
|
|
|
wheel_2_TinR_ub: float = 120,
|
|
wheel_2_TinR_ub: float = 120,
|
|
|
wheel_2_TinR_lb: float = 70,
|
|
wheel_2_TinR_lb: float = 70,
|
|
|
- constrains : list = None
|
|
|
|
|
|
|
+ constrains : list = None,
|
|
|
|
|
+ logging : bool = True
|
|
|
) -> list:
|
|
) -> list:
|
|
|
constrains = [] if constrains is None else constrains
|
|
constrains = [] if constrains is None else constrains
|
|
|
cur_input_data = cur_input_data.iloc[[0],:]
|
|
cur_input_data = cur_input_data.iloc[[0],:]
|
|
@@ -171,7 +163,11 @@ class DHU_A(BaseDevice):
|
|
|
opt_var_boundary = opt_var_boundary,
|
|
opt_var_boundary = opt_var_boundary,
|
|
|
opt_var_value = opt_var_value,
|
|
opt_var_value = opt_var_value,
|
|
|
oth_var_value = oth_var_value,
|
|
oth_var_value = oth_var_value,
|
|
|
- constrains = constrains
|
|
|
|
|
|
|
+ target = 'Fs',
|
|
|
|
|
+ target_min = True,
|
|
|
|
|
+ constrains = constrains,
|
|
|
|
|
+ logging = logging,
|
|
|
|
|
+ other_kwargs = {'NIND':2000,'MAXGEN':50}
|
|
|
)
|
|
)
|
|
|
return opt_res
|
|
return opt_res
|
|
|
|
|
|
|
@@ -203,7 +199,7 @@ class DHU_A(BaseDevice):
|
|
|
coil_2_FW = coil_2_Val / 100
|
|
coil_2_FW = coil_2_Val / 100
|
|
|
coil_3_FW = coil_3_Val / 100
|
|
coil_3_FW = coil_3_Val / 100
|
|
|
# 空气的质量流量
|
|
# 空气的质量流量
|
|
|
- air_flow = AirFlow.model(fan_1_Hz=fan_1_Hz,fan_2_Hz=fan_2_Hz,param=param)
|
|
|
|
|
|
|
+ air_flow = AirFlow_DHU_AB.model(fan_1_Hz=fan_1_Hz,fan_2_Hz=fan_2_Hz,param=param,type='DHU_A')
|
|
|
|
|
|
|
|
# 前转轮
|
|
# 前转轮
|
|
|
wheel_1_res = components['wheel_1'].model(
|
|
wheel_1_res = components['wheel_1'].model(
|
|
@@ -336,53 +332,82 @@ class DHU_A(BaseDevice):
|
|
|
'mixed_2' : mixed_2_res,
|
|
'mixed_2' : mixed_2_res,
|
|
|
'steamcoil_1': steamcoil_1_res,
|
|
'steamcoil_1': steamcoil_1_res,
|
|
|
'steamcoil_2': steamcoil_2_res,
|
|
'steamcoil_2': steamcoil_2_res,
|
|
|
- 'Fa' : air_flow,
|
|
|
|
|
- 'summary' : {}
|
|
|
|
|
|
|
+ 'Fa' : air_flow,
|
|
|
|
|
+ 'summary' : {
|
|
|
|
|
+ 'Fs':steamcoil_1_res['Fs'] + steamcoil_2_res['Fs'],
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-class AirFlow:
|
|
|
|
|
|
|
+class AirFlow_DHU_AB:
|
|
|
|
|
|
|
|
@classmethod
|
|
@classmethod
|
|
|
- def model(cls,fan_1_Hz,fan_2_Hz,param):
|
|
|
|
|
- # 空气的质量流量
|
|
|
|
|
- F_air_HzP_H = param['F_air']['HzP_H']
|
|
|
|
|
- F_air_HzP_X = param['F_air']['HzP_X']
|
|
|
|
|
- F_air_HzP_S = F_air_HzP_H + F_air_HzP_X
|
|
|
|
|
- F_air_HzR_B = param['F_air']['HzR_B']
|
|
|
|
|
|
|
+ def model(cls,fan_1_Hz,fan_2_Hz,param,type):
|
|
|
|
|
|
|
|
|
|
+ # 当定频风机固定的时候,各出入口处的基准的风量
|
|
|
F_air_S_base = 1
|
|
F_air_S_base = 1
|
|
|
F_air_X_base = param['F_air']['X_base']
|
|
F_air_X_base = param['F_air']['X_base']
|
|
|
- F_air_H_base = param['F_air']['H_base']
|
|
|
|
|
- F_air_B_base = param['F_air']['B_base']
|
|
|
|
|
|
|
+ F_air_H_base = param['F_air'].get('H_base',0)
|
|
|
|
|
+ F_air_B_base = param['F_air'].get('B_base',0)
|
|
|
F_air_val_rw = param['F_air'].get('val_rw',0)
|
|
F_air_val_rw = param['F_air'].get('val_rw',0)
|
|
|
F_air_val_pct = param['F_air'].get('val_pct',0)
|
|
F_air_val_pct = param['F_air'].get('val_pct',0)
|
|
|
|
|
|
|
|
|
|
+ # 新风阀的变化造成的基准风量变化
|
|
|
|
|
+ F_air_S_base_adj = F_air_S_base
|
|
|
F_air_X_base_adj = F_air_X_base + F_air_val_rw
|
|
F_air_X_base_adj = F_air_X_base + F_air_val_rw
|
|
|
- F_air_H_base_adj = F_air_H_base - F_air_val_rw * F_air_val_pct
|
|
|
|
|
- F_air_B_base_adj = F_air_B_base - F_air_val_rw * (1 - F_air_val_pct)
|
|
|
|
|
|
|
+ F_air_H_base_adj = F_air_H_base - F_air_val_rw * F_air_val_pct if 'H_base' in param['F_air'] else 0
|
|
|
|
|
+ F_air_B_base_adj = F_air_B_base - F_air_val_rw * (1 - F_air_val_pct) if 'B_base' in param['F_air'] else 0
|
|
|
|
|
+ # F_air_X_base_adj = F_air_X_base + F_air_val_rw
|
|
|
|
|
+ # F_air_B_base_adj = F_air_B_base - F_air_val_rw * F_air_val_pct[0] if 'B_base' in param['F_air'] else 0
|
|
|
|
|
+ # F_air_S_base_adj = F_air_S_base + F_air_val_rw * F_air_val_pct[1] if 'H_base' in param['F_air'] else 0
|
|
|
|
|
+ # F_air_H_base_adj = F_air_H_base - F_air_val_rw * F_air_val_pct[2] if 'H_base' in param['F_air'] else 0
|
|
|
|
|
+
|
|
|
|
|
+ # 考虑风机频率变化对风量的影响,得到最终风量
|
|
|
|
|
+ # 因为从数据上看,排风机的频率不会影响到新风量,所以在新风阀不动的情况下,新风的增加量可以认为全部进入送风
|
|
|
|
|
+ F_air_HzP_X = param['F_air']['HzP_X']
|
|
|
|
|
+ F_air_HzP_H = param['F_air'].get('HzP_H',0)
|
|
|
|
|
+ F_air_HzP_S = F_air_HzP_X + F_air_HzP_H
|
|
|
|
|
+ F_air_HzR_B = param['F_air'].get('HzR_B',0)
|
|
|
|
|
+ Fa_S = F_air_S_base_adj + F_air_HzP_S * (fan_1_Hz / 50)
|
|
|
|
|
+ Fa_H = F_air_H_base_adj + F_air_HzP_H * (fan_1_Hz / 50)
|
|
|
|
|
+ Fa_X = F_air_X_base_adj + F_air_HzP_X * (fan_1_Hz / 50)
|
|
|
|
|
+ Fa_B = F_air_B_base_adj + F_air_HzR_B * (fan_2_Hz / 50)
|
|
|
|
|
+ Fa_P = Fa_B + Fa_X + Fa_H - Fa_S
|
|
|
|
|
|
|
|
- Fa_S = F_air_S_base + F_air_HzP_S * (fan_1_Hz / 50)
|
|
|
|
|
- Fa_H = F_air_H_base_adj + F_air_HzP_H * (fan_1_Hz / 50)
|
|
|
|
|
- Fa_X = F_air_X_base_adj + F_air_HzP_X * (fan_1_Hz / 50)
|
|
|
|
|
- Fa_B = F_air_B_base_adj + F_air_HzR_B * (fan_2_Hz / 50)
|
|
|
|
|
- Fa_P = Fa_B + Fa_X + Fa_H - Fa_S
|
|
|
|
|
|
|
+ if type == 'DHU_A':
|
|
|
|
|
+ wheel_1_FaP = Fa_S - Fa_H
|
|
|
|
|
+ wheel_1_FaC = Fa_X - wheel_1_FaP
|
|
|
|
|
+ wheel_1_FaR = Fa_P
|
|
|
|
|
+ wheel_2_FaP = Fa_S
|
|
|
|
|
+ wheel_2_FaC = wheel_1_FaC
|
|
|
|
|
+ wheel_2_FaR = wheel_1_FaC
|
|
|
|
|
+ mixed_1_FaM = Fa_H
|
|
|
|
|
+ mixed_1_FaA = wheel_1_FaP
|
|
|
|
|
+ mixed_2_FaM = Fa_B
|
|
|
|
|
+ mixed_2_FaA = wheel_1_FaC
|
|
|
|
|
+ coil_2_FaA = Fa_S
|
|
|
|
|
+ coil_3_FaA = Fa_S
|
|
|
|
|
+ steamcoil_1_Fa = Fa_P
|
|
|
|
|
+ steamcoil_2_Fa = wheel_1_FaC
|
|
|
|
|
|
|
|
- wheel_1_FaP = Fa_S - Fa_H
|
|
|
|
|
- wheel_1_FaC = Fa_X - wheel_1_FaP
|
|
|
|
|
- wheel_1_FaR = Fa_P
|
|
|
|
|
- wheel_2_FaP = Fa_S
|
|
|
|
|
- wheel_2_FaC = wheel_1_FaC
|
|
|
|
|
- wheel_2_FaR = wheel_1_FaC
|
|
|
|
|
- mixed_1_FaM = Fa_H
|
|
|
|
|
- mixed_1_FaA = wheel_1_FaP
|
|
|
|
|
- mixed_2_FaM = Fa_B
|
|
|
|
|
- mixed_2_FaA = wheel_1_FaC
|
|
|
|
|
- coil_2_FaA = Fa_S
|
|
|
|
|
- coil_3_FaA = Fa_S
|
|
|
|
|
- steamcoil_1_Fa = Fa_P
|
|
|
|
|
- steamcoil_2_Fa = wheel_1_FaC
|
|
|
|
|
|
|
+ elif type == 'DHU_B':
|
|
|
|
|
+ wheel_1_FaP = Fa_X
|
|
|
|
|
+ wheel_1_FaC = None
|
|
|
|
|
+ wheel_1_FaR = Fa_P
|
|
|
|
|
+ wheel_2_FaP = Fa_S
|
|
|
|
|
+ wheel_2_FaC = Fa_X + Fa_H - Fa_S
|
|
|
|
|
+ wheel_2_FaR = wheel_2_FaC
|
|
|
|
|
+ mixed_1_FaM = Fa_H
|
|
|
|
|
+ mixed_1_FaA = Fa_X
|
|
|
|
|
+ mixed_2_FaM = Fa_B
|
|
|
|
|
+ mixed_2_FaA = wheel_2_FaC
|
|
|
|
|
+ coil_2_FaA = Fa_S
|
|
|
|
|
+ coil_3_FaA = Fa_S
|
|
|
|
|
+ steamcoil_1_Fa = Fa_P
|
|
|
|
|
+ steamcoil_2_Fa = wheel_2_FaC
|
|
|
|
|
|
|
|
|
|
+ else:
|
|
|
|
|
+ raise Exception('type error')
|
|
|
return {
|
|
return {
|
|
|
'Fa_S':Fa_S,'Fa_H':Fa_H,'Fa_X':Fa_X,'Fa_B':Fa_B,'Fa_P':Fa_P,
|
|
'Fa_S':Fa_S,'Fa_H':Fa_H,'Fa_X':Fa_X,'Fa_B':Fa_B,'Fa_P':Fa_P,
|
|
|
'wheel_1_FaP':wheel_1_FaP,'wheel_1_FaC':wheel_1_FaC,'wheel_1_FaR':wheel_1_FaR,
|
|
'wheel_1_FaP':wheel_1_FaP,'wheel_1_FaC':wheel_1_FaC,'wheel_1_FaR':wheel_1_FaR,
|
|
@@ -392,31 +417,41 @@ class AirFlow:
|
|
|
'coil_2_FaA':coil_2_FaA,'coil_3_FaA':coil_3_FaA,
|
|
'coil_2_FaA':coil_2_FaA,'coil_3_FaA':coil_3_FaA,
|
|
|
'steamcoil_1_Fa':steamcoil_1_Fa,'steamcoil_2_Fa':steamcoil_2_Fa
|
|
'steamcoil_1_Fa':steamcoil_1_Fa,'steamcoil_2_Fa':steamcoil_2_Fa
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@classmethod
|
|
@classmethod
|
|
|
- def prior(cls,rw_FA_val,N) -> dict:
|
|
|
|
|
- HzP_X = pm.HalfNormal('F_air_HzP_X',sigma=1,initval=1)
|
|
|
|
|
- HzP_H = pm.HalfNormal('F_air_HzP_H',sigma=1,initval=0.1)
|
|
|
|
|
- HzR_B = pm.HalfNormal('F_air_HzR_B',sigma=1,initval=0.5)
|
|
|
|
|
- X_base = pm.TruncatedNormal('F_air_X_base',mu=0.5,sigma=0.2,lower=0,initval=0.5)
|
|
|
|
|
- H_base = pm.TruncatedNormal('F_air_H_base',mu=0.6,sigma=0.2,lower=0,upper=0.999,initval=0.6)
|
|
|
|
|
- B_base = pm.TruncatedNormal('F_air_B_base',mu=0.2,sigma=0.1,lower=0,initval=0.1)
|
|
|
|
|
|
|
+ def prior(
|
|
|
|
|
+ cls,
|
|
|
|
|
+ rw_FA_val : bool,
|
|
|
|
|
+ N : int,
|
|
|
|
|
+ exist_Fa_H: bool,
|
|
|
|
|
+ exist_Fa_B: bool
|
|
|
|
|
+ ) -> dict:
|
|
|
|
|
+ param = {}
|
|
|
|
|
+
|
|
|
|
|
+ # 新风参数
|
|
|
|
|
+ param['HzP_X'] = pm.HalfNormal('F_air_HzP_X',sigma=1,initval=1)
|
|
|
|
|
+ param['X_base'] = pm.TruncatedNormal('F_air_X_base',mu=0.5,sigma=0.2,lower=0,initval=0.5)
|
|
|
|
|
+
|
|
|
|
|
+ if exist_Fa_H:
|
|
|
|
|
+ param['HzP_H'] = pm.HalfNormal('F_air_HzP_H',sigma=1,initval=0.1)
|
|
|
|
|
+ param['H_base'] = pm.TruncatedNormal('F_air_H_base',mu=0.6,sigma=0.2,lower=0,upper=0.999,initval=0.6)
|
|
|
|
|
+
|
|
|
|
|
+ if exist_Fa_B:
|
|
|
|
|
+ param['HzR_B'] = pm.HalfNormal('F_air_HzR_B',sigma=1,initval=0.5)
|
|
|
|
|
+ param['B_base'] = pm.TruncatedNormal('F_air_B_base',mu=0.2,sigma=0.1,lower=0,initval=0.1)
|
|
|
|
|
|
|
|
if rw_FA_val:
|
|
if rw_FA_val:
|
|
|
- period = 30
|
|
|
|
|
|
|
+ period = 48
|
|
|
n_segments = int(np.ceil(N/period))
|
|
n_segments = int(np.ceil(N/period))
|
|
|
remainder = N % period
|
|
remainder = N % period
|
|
|
repeat = [period] * (n_segments - 1) + ([remainder] if remainder != 0 else [])
|
|
repeat = [period] * (n_segments - 1) + ([remainder] if remainder != 0 else [])
|
|
|
rw = pm.GaussianRandomWalk(
|
|
rw = pm.GaussianRandomWalk(
|
|
|
'rw',sigma=0.1,init_dist=pm.Normal.dist(mu=0,sigma=0.3),shape=n_segments)
|
|
'rw',sigma=0.1,init_dist=pm.Normal.dist(mu=0,sigma=0.3),shape=n_segments)
|
|
|
- val_rw = pm.Deterministic('F_air_val_rw',pt.repeat(rw,repeat))
|
|
|
|
|
- val_pct = pm.Beta('F_air_val_pct',alpha=8,beta=1,initval=0.9)
|
|
|
|
|
|
|
+ param['val_rw'] = pm.Deterministic('F_air_val_rw',pt.repeat(rw,repeat))
|
|
|
|
|
+ param['val_pct'] = pm.Beta('F_air_val_pct',alpha=8,beta=1,initval=0.9)
|
|
|
|
|
+ # param['val_pct'] = pm.Dirichlet('F_air_val_pct',np.array([0.1,0.1,0.8]),initval=np.array([0.1,0.1,0.8]))
|
|
|
else:
|
|
else:
|
|
|
- val_rw = 0
|
|
|
|
|
- val_pct = 0
|
|
|
|
|
|
|
+ param['val_rw'] = 0
|
|
|
|
|
+ param['val_pct'] = 0
|
|
|
|
|
|
|
|
- return {
|
|
|
|
|
- 'HzP_X':HzP_X,'HzP_H':HzP_H,'HzR_B':HzR_B,
|
|
|
|
|
- 'X_base':X_base,'H_base':H_base,'B_base':B_base,
|
|
|
|
|
- 'val_rw':val_rw,'val_pct':val_pct
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return param
|