Bin Method(温频法)计算的Python程序

基本概念

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
tbal —— 平衡点温度,℃
to —— 室外温度,℃
ti —— 室内温度,℃
Ktol —— 建筑总的热损失系数,W/K
qgain —— 总的热损失,W/m2
ηh —— 供暖系统的效率
θ —— 时间,s
在这里插入图片描述
在这里插入图片描述

例题

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
这个例题用的是Nashville,TN(纳什维尔,田纳西州)的数据

在这里插入图片描述
计算结果:
在这里插入图片描述
在这里插入图片描述

代码

#The Bin Method
#设计温差为dT=30℃时,建筑设计热损失为HL=11700W
#室内设计温度ti=21℃,平均内热源为q_gain=1250W
#假设有一个额定功率为10.5kW的热泵
dT = 30    #设计温差dT
HL = 11700    #建筑设计热损失HL
t_i = 21    #室内设计温度ti
q_gain=1250    #平均内热源为q_gain
T_Bin = [16, 13, 10, 7, 4, 1, -2, -5, -8, -11]
Weather_Bin = [693, 801, 670, 858, 639, 793, 141, 89, 29, 0]
K_tol = HL/dT    #建筑总的热损失系数W/K
t_bol = t_i - q_gain/K_tol    #平衡点温度t_bol,℃
print('建筑总的热损失系数K_to:',K_tol)
print('平衡点温度t_bol:',t_bol)

结果:

建筑总的热损失系数K_to: 390.0
平衡点温度t_bol: 17.794871794871796

计算一年总的能耗

代码1(计算过程不保留小数点位数,按原数据计算)

#The Bin Method
#设计温差为dT=30℃时,建筑设计热损失为HL=11700W
#室内设计温度ti=21℃,平均内热源为q_gain=1250W
#假设有一个额定功率为10.5kW的热泵
import pandas as pd
dT = 30    #设计温差dT
HL = 11700    #建筑设计热损失HL
t_i = 21    #室内设计温度ti
q_gain=1250    #平均内热源为q_gain
T_Bin = [16, 13, 10, 7, 4, 1, -2, -5, -8]
Weather_Bin = [693, 801, 670, 858, 639, 793, 141, 89, 29]
Heat_Pump_capacity = [12.80, 12.01, 11.22, 9.8, 8.49, 7.98, 7.47, 6.95, 6.48]    #Heat Pump Integrated Heating Capacity,KW
Electric_input_Rated = [3.74, 3.63, 3.52, 3.40, 3.18, 3.10, 3.02, 2.93, 2.85]    #Rated Electric Input,KW
K_tol = HL/dT    #建筑总的热损失系数W/K
t_bol = t_i - q_gain/K_tol    #平衡点温度t_bol,℃
print('建筑总的热损失系数K_to:',K_tol)
print('平衡点温度t_bol:',t_bol)
frame = [['Temp_Bin', 'Temp_Diff', 'Weather_Data_bin', 'Heat_Loss_Rate', 'Heat_Pump_Integrated_Heating_Capacity', 'Cycling_Capacity_Adjustment_Factor', 'Adjusted_Heat_Pump_Capacity', 'Rated_Electric_Input', 'Operating_Time_Fraction', 'Heat_Pump_Supplied_Heating', 'Seasonal_Heat_Pump_Electric_Consumption', 'Space_Load', 'Supplemental_Heating_Required', 'Total_Electric_Energy_Consumption'],
         ['℃','℃','h','kW','kW',' ','kW','kW',' ','kWh','kWh','kWh','kWh','kWh']]
Heat_Pump_supplyheating_sum = 0    #一年里热泵总的供热量
Heat_Pump_Electric_Consumption_sum = 0    #一年里热泵总的耗电量
Space_Load_sum = 0    #一年里总的房间负荷
Supplemental_Heating_required_sum = 0    #一年里除热泵以外需要补充的总热量
Total_Electric_Consumption_sum = 0    #一年里总的电能消耗
for i in range(len(T_Bin)):
    result = []
    result.append(T_Bin[i])
    dT_bal = t_bol - T_Bin[i]    #平衡点温度与Bin温度的温差
    result.append(round(dT_bal,1))
    result.append(Weather_Bin[i])
    Heat_Loss = dT_bal * K_tol/1000    #某温差下的额定热损失,KW
    result.append(round(Heat_Loss,2))
    result.append(Heat_Pump_capacity[i])
    if Heat_Loss < Heat_Pump_capacity[i]:
        C_d = 0.25    #degradation coefficient退化系数
        Capacity_adjustment_factor = 1 - C_d * (1-Heat_Loss/Heat_Pump_capacity[i])    #Cycling Capacity Adjustment Factor循环修正因子
    else:
        Capacity_adjustment_factor = 1.000
    result.append(round(Capacity_adjustment_factor, 3))
    Heat_Pump_adjusted_capacity = Heat_Pump_capacity[i] * Capacity_adjustment_factor    #修正后的热泵功率
    result.append(round(Heat_Pump_adjusted_capacity, 2))
    result.append(Electric_input_Rated[i])
    if Heat_Loss < Heat_Pump_capacity[i]:
        Operating_Time_fraction = Heat_Loss / Heat_Pump_adjusted_capacity    #工作时间分数
    else:
        Operating_Time_fraction = 1.000
    result.append(round(Operating_Time_fraction, 3))
    Heat_Pump_supplyheating = Operating_Time_fraction * Heat_Pump_adjusted_capacity * Weather_Bin[i]    #热泵供热量,KWh
    result.append(round(Heat_Pump_supplyheating, 0))
    Heat_Pump_supplyheating_sum += Heat_Pump_supplyheating
    Heat_Pump_Electric_Consumption = Operating_Time_fraction * Electric_input_Rated[i] * Weather_Bin[i]    #热泵用电量,KWh
    result.append(round(Heat_Pump_Electric_Consumption, 0))
    Heat_Pump_Electric_Consumption_sum += Heat_Pump_Electric_Consumption
    Space_Load = Heat_Loss * Weather_Bin[i]    #Space Load空间负荷,KWh
    result.append(round(Space_Load, 0))
    Space_Load_sum += Space_Load
    Supplemental_Heating_required = Space_Load - Heat_Pump_supplyheating    #需要补充的热量,KWh
    result.append(round(Supplemental_Heating_required, 0))
    Supplemental_Heating_required_sum += Supplemental_Heating_required
    Total_Electric_Consumption = Heat_Pump_Electric_Consumption + Supplemental_Heating_required    #总的电能消耗,KWh
    result.append(round(Total_Electric_Consumption, 0))
    Total_Electric_Consumption_sum += Total_Electric_Consumption
    frame.append(result)
data_frame = pd.DataFrame(frame)
# 横向最多显示多少个字符, 一般80不适合横向的屏幕,平时多用200
pd.set_option('display.width', 500)
# 显示所有列
pd.set_option('display.max_columns', None)
print(data_frame)
print(f'一年里热泵总的供热量:{round(Heat_Pump_supplyheating_sum,0)} kwh')
print(f'一年里热泵总的耗电量:{round(Heat_Pump_Electric_Consumption_sum,0)} kwh')
print(f'一年里总的房间负荷:{round(Space_Load_sum,0)} kwh')
print(f'一年里除热泵以外需要补充的总热量:{round(Supplemental_Heating_required_sum,0)} kwh')
print(f'一年里总的电能消耗:{round(Total_Electric_Consumption_sum,0)} kwh')

结果:

建筑总的热损失系数K_to: 390.0
平衡点温度t_bol: 17.794871794871796
           0          1                 2               3                                      4                                   5                            6                     7                        8                           9                                       10          11                             12                                 13
0   Temp_Bin  Temp_Diff  Weather_Data_bin  Heat_Loss_Rate  Heat_Pump_Integrated_Heating_Capacity  Cycling_Capacity_Adjustment_Factor  Adjusted_Heat_Pump_Capacity  Rated_Electric_Input  Operating_Time_Fraction  Heat_Pump_Supplied_Heating  Seasonal_Heat_Pump_Electric_Consumption  Space_Load  Supplemental_Heating_Required  Total_Electric_Energy_Consumption
1          ℃          ℃                 h              kW                                     kW                                                               kW                    kW                                                  kWh                                      kWh         kWh                            kWh                                kWh
2         16        1.8               693             0.7                                   12.8                               0.764                         9.78                  3.74                    0.072                         485                                      186         485                              0                                186
3         13        4.8               801            1.87                                  12.01                               0.789                         9.47                  3.63                    0.197                        1498                                      574        1498                              0                                574
4         10        7.8               670            3.04                                  11.22                               0.818                         9.18                  3.52                    0.331                        2037                                      781        2037                              0                                781
5          7       10.8               858            4.21                                    9.8                               0.857                          8.4                   3.4                    0.501                        3612                                     1462        3612                              0                               1462
6          4       13.8               639            5.38                                   8.49                               0.908                         7.71                  3.18                    0.698                        3438                                     1417        3438                              0                               1417
7          1       16.8               793            6.55                                   7.98                               0.955                         7.62                   3.1                    0.859                        5194                                     2112        5194                              0                               2112
8         -2       19.8               141            7.72                                   7.47                                   1                         7.47                  3.02                        1                        1053                                      426        1089                             35                                461
9         -5       22.8                89            8.89                                   6.95                                   1                         6.95                  2.93                        1                         619                                      261         791                            173                                433
10        -8       25.8                29           10.06                                   6.48                                   1                         6.48                  2.85                        1                         188                                       83         292                            104                                186
一年里热泵总的供热量:18124.0 kwh
一年里热泵总的耗电量:7302.0 kwh
一年里总的房间负荷:18435.0 kwh
一年里除热泵以外需要补充的总热量:312.0 kwh
一年里总的电能消耗:7613.0 kwh

代码2(计算过程保留小数点位数,按保留小数点后的数据计算)

#The Bin Method
#设计温差为dT=30℃时,建筑设计热损失为HL=11700W
#室内设计温度ti=21℃,平均内热源为q_gain=1250W
#假设有一个额定功率为10.5kW的热泵
import pandas as pd
dT = 30    #设计温差dT
HL = 11700    #建筑设计热损失HL
t_i = 21    #室内设计温度ti
q_gain=1250    #平均内热源为q_gain
T_Bin = [16, 13, 10, 7, 4, 1, -2, -5, -8]
Weather_Bin = [693, 801, 670, 858, 639, 793, 141, 89, 29]
Heat_Pump_capacity = [12.80, 12.01, 11.22, 9.8, 8.49, 7.98, 7.47, 6.95, 6.48]    #Heat Pump Integrated Heating Capacity,KW
Electric_input_Rated = [3.74, 3.63, 3.52, 3.40, 3.18, 3.10, 3.02, 2.93, 2.85]    #Rated Electric Input,KW
K_tol = HL/dT    #建筑总的热损失系数W/K
t_bol = t_i - q_gain/K_tol    #平衡点温度t_bol,℃
print('建筑总的热损失系数K_to:',K_tol)
print('平衡点温度t_bol:',t_bol)
frame = [['Temp_Bin', 'Temp_Diff', 'Weather_Data_bin', 'Heat_Loss_Rate', 'Heat_Pump_Integrated_Heating_Capacity', 'Cycling_Capacity_Adjustment_Factor', 'Adjusted_Heat_Pump_Capacity', 'Rated_Electric_Input', 'Operating_Time_Fraction', 'Heat_Pump_Supplied_Heating', 'Seasonal_Heat_Pump_Electric_Consumption', 'Space_Load', 'Supplemental_Heating_Required', 'Total_Electric_Energy_Consumption'],
         ['℃','℃','h','kW','kW',' ','kW','kW',' ','kWh','kWh','kWh','kWh','kWh']]
Heat_Pump_supplyheating_sum = 0    #一年里热泵总的供热量
Heat_Pump_Electric_Consumption_sum = 0    #一年里热泵总的耗电量
Space_Load_sum = 0    #一年里总的房间负荷
Supplemental_Heating_required_sum = 0    #一年里除热泵以外需要补充的总热量
Total_Electric_Consumption_sum = 0    #一年里总的电能消耗
for i in range(len(T_Bin)):
    result = []
    result.append(T_Bin[i])
    dT_bal = t_bol - T_Bin[i]    #平衡点温度与Bin温度的温差
    dT_bal = round(dT_bal,1)
    result.append(dT_bal)
    result.append(Weather_Bin[i])
    Heat_Loss = dT_bal * K_tol/1000    #某温差下的额定热损失,KW
    Heat_Loss = round(Heat_Loss,2)
    result.append(Heat_Loss)
    result.append(Heat_Pump_capacity[i])
    if Heat_Loss < Heat_Pump_capacity[i]:
        C_d = 0.25    #degradation coefficient退化系数
        Capacity_adjustment_factor = 1 - C_d * (1-Heat_Loss/Heat_Pump_capacity[i])   #Cycling Capacity Adjustment Factor循环修正因子

    else:
        Capacity_adjustment_factor = 1.000
    Capacity_adjustment_factor = round(Capacity_adjustment_factor, 3)
    result.append(Capacity_adjustment_factor)
    Heat_Pump_adjusted_capacity = Heat_Pump_capacity[i] * Capacity_adjustment_factor    #修正后的热泵功率
    Heat_Pump_adjusted_capacity = round(Heat_Pump_adjusted_capacity, 2)
    result.append(Heat_Pump_adjusted_capacity)
    result.append(Electric_input_Rated[i])
    if Heat_Loss < Heat_Pump_capacity[i]:
        Operating_Time_fraction = Heat_Loss / Heat_Pump_adjusted_capacity   #工作时间分数
    else:
        Operating_Time_fraction = 1.000
    Operating_Time_fraction = round(Operating_Time_fraction, 3)
    result.append(Operating_Time_fraction)
    Heat_Pump_supplyheating = Operating_Time_fraction * Heat_Pump_adjusted_capacity * Weather_Bin[i]    #热泵供热量,KWh
    Heat_Pump_supplyheating = round(Heat_Pump_supplyheating, 0)
    result.append(Heat_Pump_supplyheating)
    Heat_Pump_supplyheating_sum += Heat_Pump_supplyheating
    Heat_Pump_Electric_Consumption = Operating_Time_fraction * Electric_input_Rated[i] * Weather_Bin[i]    #热泵用电量,KWh
    Heat_Pump_Electric_Consumption = round(Heat_Pump_Electric_Consumption, 0)
    result.append(Heat_Pump_Electric_Consumption)
    Heat_Pump_Electric_Consumption_sum += Heat_Pump_Electric_Consumption
    Space_Load = Heat_Loss * Weather_Bin[i]    #Space Load空间负荷,KWh
    Space_Load = round(Space_Load, 0)
    result.append(Space_Load)
    Space_Load_sum += Space_Load
    Supplemental_Heating_required = Space_Load - Heat_Pump_supplyheating    #需要补充的热量,KWh
    if Heat_Loss >= Heat_Pump_capacity[i]:
        Supplemental_Heating_required = round(Supplemental_Heating_required, 0)
    else:
        Supplemental_Heating_required = 0
    result.append(Supplemental_Heating_required)
    Supplemental_Heating_required_sum += Supplemental_Heating_required
    Total_Electric_Consumption = Heat_Pump_Electric_Consumption + Supplemental_Heating_required    #总的电能消耗,KWh
    result.append(Total_Electric_Consumption)
    Total_Electric_Consumption_sum += Total_Electric_Consumption
    frame.append(result)
data_frame = pd.DataFrame(frame)
# 横向最多显示多少个字符, 一般80不适合横向的屏幕,平时多用200
pd.set_option('display.width', 500)
# 显示所有列
pd.set_option('display.max_columns', None)
print(data_frame)
print(f'一年里热泵总的供热量:{round(Heat_Pump_supplyheating_sum,0)} kwh')
print(f'一年里热泵总的耗电量:{round(Heat_Pump_Electric_Consumption_sum,0)} kwh')
print(f'一年里总的房间负荷:{round(Space_Load_sum,0)} kwh')
print(f'一年里除热泵以外需要补充的总热量:{round(Supplemental_Heating_required_sum,0)} kwh')
print(f'一年里总的电能消耗:{round(Total_Electric_Consumption_sum,0)} kwh')

结果:

建筑总的热损失系数K_to: 390.0
平衡点温度t_bol: 17.794871794871796
           0          1                 2               3                                      4                                   5                            6                     7                        8                           9                                       10          11                             12                                 13
0   Temp_Bin  Temp_Diff  Weather_Data_bin  Heat_Loss_Rate  Heat_Pump_Integrated_Heating_Capacity  Cycling_Capacity_Adjustment_Factor  Adjusted_Heat_Pump_Capacity  Rated_Electric_Input  Operating_Time_Fraction  Heat_Pump_Supplied_Heating  Seasonal_Heat_Pump_Electric_Consumption  Space_Load  Supplemental_Heating_Required  Total_Electric_Energy_Consumption
1          ℃          ℃                 h              kW                                     kW                                                               kW                    kW                                                  kWh                                      kWh         kWh                            kWh                                kWh
2         16        1.8               693             0.7                                   12.8                               0.764                         9.78                  3.74                    0.072                         488                                      187         485                              0                                187
3         13        4.8               801            1.87                                  12.01                               0.789                         9.48                  3.63                    0.197                        1496                                      573        1498                              0                                573
4         10        7.8               670            3.04                                  11.22                               0.818                         9.18                  3.52                    0.331                        2036                                      781        2037                              0                                781
5          7       10.8               858            4.21                                    9.8                               0.857                          8.4                   3.4                    0.501                        3611                                     1462        3612                              0                               1462
6          4       13.8               639            5.38                                   8.49                               0.908                         7.71                  3.18                    0.698                        3439                                     1418        3438                              0                               1418
7          1       16.8               793            6.55                                   7.98                               0.955                         7.62                   3.1                     0.86                        5197                                     2114        5194                              0                               2114
8         -2       19.8               141            7.72                                   7.47                                   1                         7.47                  3.02                        1                        1053                                      426        1089                             36                                462
9         -5       22.8                89            8.89                                   6.95                                   1                         6.95                  2.93                        1                         619                                      261         791                            172                                433
10        -8       25.8                29           10.06                                   6.48                                   1                         6.48                  2.85                        1                         188                                       83         292                            104                                187
一年里热泵总的供热量:18127.0 kwh
一年里热泵总的耗电量:7305.0 kwh
一年里总的房间负荷:18436.0 kwh
一年里除热泵以外需要补充的总热量:312.0 kwh
一年里总的电能消耗:7617.0 kwh
以下是一个python代码示例,用于计算脑电信号的柯尔莫哥洛夫熵: ``` import numpy as np from scipy.signal import welch def spectral_entropy(signal, sf, method='fft', nperseg=None, normalize=False): """Spectral Entropy. Parameters: ----------- signal: list or np.array One-dimensional time series of measurement values sf: float Sampling frequency method: str Spectral estimation method :: 'fft' : Fourier Transform (via scipy.signal.welch) 'welch': Welch periodogram (via scipy.signal.welch) nperseg: str or int Length of each Welch segment for FFT method. If None, uses scipy default of 256 samples. normalize: bool If True, divides by log2 of frequency bin count (some methods use raw spectral entropy, not normalized) Returns: -------- se: float Spectral Entropy Notes: ------ Spectral Entropy is defined to be the Shannon Entropy of the Power Spectral Density (PSD) of the data after normalization of the PSD to have unit area. This implementation first estimates the PSD using welch or FFT, optionally normalizes the PSD, and then applies the Shannon Entropy function. To reduce memory requirements, the Welch method can be used to divide the signal into segments. This implementation is based on the spectral_entropy function from the Entropy package authored by Raphael Vallat. (https://raphaelvallat.com/entropy/build/html/index.html) """ # Compute and normalize power spectrum if method == 'fft': freqs, psd = welch(signal, sf, nperseg=nperseg) elif method == 'welch': freqs, psd = welch(signal, sf, nperseg=nperseg) else: raise ValueError('Method must be "fft" or "welch"') psd_norm = np.divide(psd, psd.sum()) # Compute Shannon entropy se = -np.multiply(psd_norm, np.log2(psd_norm)).sum() # Normalize according to the spectral resolution if normalize: se /= np.log2(len(freqs)) return se ``` 请注意,该代码的详细说明包括输入和输出的每个参数。此外,它使用scipy库中的welch函数来计算功率谱密度。该代码也可以使用其他信号源作为输入,而不仅仅是脑电信号。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值