Skip to content

Commit

Permalink
Merge pull request #3579 from architecture-building-systems/hotfix-tw…
Browse files Browse the repository at this point in the history
…o-decentralised-optimisation-workflow-test

Hotfix two decentralised optimisation workflow test
  • Loading branch information
ShiZhongming committed May 14, 2024
2 parents cd9df1a + d9f93dd commit d10ec38
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 71 deletions.
Binary file modified cea/databases/CH/components/CONVERSION.xlsx
Binary file not shown.
Binary file modified cea/databases/DE/components/CONVERSION.xlsx
Binary file not shown.
Binary file modified cea/databases/SG/components/CONVERSION.xlsx
Binary file not shown.
3 changes: 1 addition & 2 deletions cea/demand/hotwater_loads.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import math

import numpy as np
import scipy

from cea.constants import HEAT_CAPACITY_OF_WATER_JPERKGK, P_WATER_KGPERM3
from cea.constants import HOURS_IN_YEAR
Expand Down Expand Up @@ -296,7 +295,7 @@ def calc_disls(tamb, Vww, V, twws, Lsww_dis, Y):
if TR > 3600:
TR = 3600
try:
exponential = scipy.exp(-(Y * Lsww_dis * TR) / (P_WATER * CP_KJPERKGK * V * 1000))
exponential = np.exp(-(Y * Lsww_dis * TR) / (P_WATER * CP_KJPERKGK * V * 1000))
except ZeroDivisionError:
print('twws: {twws:.2f}, tamb: {tamb:.2f}, p: {p:.2f}, cpw: {cpw:.2f}, V: {V:.2f}'.format(
twws=twws, tamb=tamb, p=P_WATER, cpw=CP_KJPERKGK, V=V))
Expand Down
Binary file modified cea/examples/reference-case-open.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions cea/inputlocator.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def get_optimization_checkpoint(self, generation):
def get_optimization_substations_folder(self):
"""scenario/outputs/data/optimization/substations
Substation results for decentralized buildings"""
return self._ensure_folder(self.get_optimization_results_folder(), "substations")
return self._ensure_folder(self.get_optimization_results_folder(), "decentralized", "substations")

def get_optimization_substations_results_file(self, building, network_type, district_network_barcode):
"""scenario/outputs/data/optimization/substations/${building}_result.csv"""
Expand Down Expand Up @@ -470,7 +470,7 @@ def get_weather(self, name=None):

def get_weather_names(self):
"""Return a list of all installed epw files in the system"""
weather_names = [os.path.splitext(f)[0] for f in os.listdir(self.weather_path)]
weather_names = [os.path.splitext(f)[0] for f in os.listdir(self.weather_path) if f.endswith('.epw')]
return weather_names

def get_weather_folder(self):
Expand Down
3 changes: 1 addition & 2 deletions cea/resources/sewage_heat_exchanger.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import pandas as pd
import numpy as np
import scipy
from cea.constants import HEX_WIDTH_M,VEL_FLOW_MPERS, HEAT_CAPACITY_OF_WATER_JPERKGK, H0_KWPERM2K, MIN_FLOW_LPERS, T_MIN, AT_MIN_K, P_SEWAGEWATER_KGPERM3
import cea.config
import cea.inputlocator
Expand Down Expand Up @@ -163,7 +162,7 @@ def calc_sewageheat(mcp_kWC_zone, tin_C, w_HEX_m, Vf_ms, h0, min_lps, L_HEX_m, t
tb1 = tin_C
ta1 = tin_C - ((tin_C - tmin_C) + ATmin / 2)
alpha = h0 * A_HEX * (1 / mcpa - 1 / mcp_kWC_total)
n = ( 1 - scipy.exp( -alpha ) ) / (1 - mcpa / mcp_kWC_total * scipy.exp(-alpha))
n = ( 1 - np.exp( -alpha ) ) / (1 - mcpa / mcp_kWC_total * np.exp(-alpha))
tb2 = tb1 + mcpa / mcp_kWC_total * n * (ta1 - tb1)
Q_source = mcp_kWC_total * (tb1 - tb2)
ta2 = ta1 + Q_source / mcpa
Expand Down
11 changes: 7 additions & 4 deletions cea/technologies/chiller_absorption.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,14 @@ def __init__(self, chiller_prop, ACH_type):
self.e_g = chiller_prop['e_g'].values[0]

def update_data(self, chiller_prop):
"""Due to how AbsorptionChiller is currently used (FIXME: can we fix this?), we somedimes need to update
the instance variables from the databaframe chiller_prop.
"""
if self.code != chiller_prop['code'].values[0]:
# only update if new code...
Due to how AbsorptionChiller is currently used , we sometimes need to update
the instance variables from the dataframe chiller_prop. FIXME: can we fix this?
"""
if self.code != chiller_prop['code'].values[0] \
or self.m_cw_kgpers != chiller_prop['m_cw'].values[0] \
or self.m_hw_kgpers != chiller_prop['m_hw'].values[0]:
# only update if the type or size-category of chiller changes ...
# print("Updating chiller_prop data! old code: {0}, new code: {1}".format(self.code, chiller_prop['code'].values[0]))
self.code = chiller_prop['code'].values[0]
self.m_cw_kgpers = chiller_prop['m_cw'].values[0]
Expand Down
16 changes: 8 additions & 8 deletions cea/technologies/heating_coils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,27 @@ def calc_heating_coil(Qhsf, Qhsf_0, Ta_sup_hs, Ta_re_hs, Ths_sup_0, Ths_re_0, ma
# # https: // en.wikipedia.org / wiki / Logarithmic_mean_temperature_difference
# TD10 = tsh0 - Ta_sup_0 # nominal temperature difference at hot end of heat exchanger
# TD20 = trh0 - Ta_re_0 # nominal temperature difference at cold end of heat exchanger
# LMRT0 = (TD10 - TD20) / scipy.log(TD10 / TD20)
# LMRT0 = (TD10 - TD20) / np.log(TD10 / TD20)
# UA0 = Qhsf_0 / LMRT0
#
# NTU_0 = UA0 / (ma_sup_0 * C_A)
# ec_0 = 1 - scipy.exp(-NTU_0)
# ec_0 = 1 - np.exp(-NTU_0)
#
# if Qhsf > 0 and ma_sup_hs > 0:
# AUa = UA0 * (ma_sup_hs / ma_sup_0) ** 0.77
# NTUc = AUa / (ma_sup_hs * C_A) # we removed a wrong unit conversion,
# # according to HEX graphs NTU should be in the range of 3-5 (-), see e.g.
# # http://kb.eng-software.com/display/ESKB/Difference+Between+the+Effectiveness-NTU+and+LMTD+Methods
# ec = 1 - scipy.exp(-NTUc) # this is a very strong assumption. it is only valid for boilers and condensers.
# ec = 1 - np.exp(-NTUc) # this is a very strong assumption. it is only valid for boilers and condensers.
# tc = (tasup - tare + tare * ec) / ec # (contact temperature of coil)
# # We think tc calculated here is the minimum required hot water supply temperature
#
# # minimum
# LMRT = abs((tsh0 - trh0) / scipy.log((tsh0 - tc) / (trh0 - tc))) # we don't understand what is happening here
# LMRT = abs((tsh0 - trh0) / np.log((tsh0 - tc) / (trh0 - tc))) # we don't understand what is happening here
# k1 = 1 / mCw0
#
# def fh(x):
# Eq = mCw0 * k2 - Qhsf_0 * (k2 / (scipy.log((x + k2 - tc) / (x - tc)) * LMRT))
# Eq = mCw0 * k2 - Qhsf_0 * (k2 / (np.log((x + k2 - tc) / (x - tc)) * LMRT))
# return Eq
#
# k2 = Qhsf * k1
Expand Down Expand Up @@ -199,19 +199,19 @@ def calc_cooling_coil(Qcsf, Qcsf_0, Ta_sup_cs, Ta_re_cs, Tcs_sup_0, Tcs_re_0, ma
# # log mean temperature at nominal conditions
# TD10 = Ta_sup_0 - trc0
# TD20 = Ta_re_0 - tsc0
# LMRT0 = (TD20 - TD10) / scipy.log(TD20 / TD10)
# LMRT0 = (TD20 - TD10) / np.log(TD20 / TD10)
# UA0 = Qcsf_0 / LMRT0
#
# if Qcsf < -0 and ma_sup_cs > 0:
# AUa = UA0 * (ma_sup_cs / ma_sup_0) ** 0.77
# NTUc = AUa / (ma_sup_cs * C_A * 1000)
# ec = 1 - scipy.exp(-NTUc)
# ec = 1 - np.exp(-NTUc)
# tc = (tare - tasup + tasup * ec) / ec # contact temperature of coil
#
# def fh(x):
# TD1 = tc - (k2 + x)
# TD2 = tc - x
# LMRT = (TD2 - TD1) / scipy.log(TD2 / TD1)
# LMRT = (TD2 - TD1) / np.log(TD2 / TD1)
# Eq = mCw0 * k2 - Qcsf_0 * (LMRT / LMRT0)
# return Eq
#
Expand Down
7 changes: 3 additions & 4 deletions cea/technologies/thermal_network/substation_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import pandas as pd
import time
import numpy as np
import scipy
import cea.config
from cea.constants import HEAT_CAPACITY_OF_WATER_JPERKGK, P_WATER_KGPERM3
from cea.technologies.constants import DT_COOL, DT_HEAT, U_COOL, U_HEAT, \
Expand Down Expand Up @@ -651,7 +650,7 @@ def calc_plate_HEX(NTU, cr):
:return:
eff: efficiency of heat exchange
'''
eff = 1 - scipy.exp((1 / cr) * (NTU ** 0.22) * (scipy.exp(-cr * (NTU) ** 0.78) - 1))
eff = 1 - np.exp((1 / cr) * (NTU ** 0.22) * (np.exp(-cr * (NTU) ** 0.78) - 1))
return eff


Expand All @@ -666,7 +665,7 @@ def calc_shell_HEX(NTU, cr):
eff: efficiency of heat exchange
'''
eff = 2 * ((1 + cr + (1 + cr ** 2) ** (1 / 2)) * (
(1 + scipy.exp(-(NTU) * (1 + cr ** 2))) / (1 - scipy.exp(-(NTU) * (1 + cr ** 2))))) ** -1
(1 + np.exp(-(NTU) * (1 + cr ** 2))) / (1 - np.exp(-(NTU) * (1 + cr ** 2))))) ** -1
return eff


Expand Down Expand Up @@ -786,7 +785,7 @@ def calc_dTm_HEX(thi, tho, tci, tco):
if dT1 == dT2:
dTm = dT1
else:
dTm = (dT1 - dT2) / scipy.log(dT1 / dT2)
dTm = (dT1 - dT2) / np.log(dT1 / dT2)
return abs(dTm.real)


Expand Down
48 changes: 23 additions & 25 deletions cea/tests/workflow_medium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,18 @@
network-type: DH
network-model: simplified
- script: decentralized
- script: optimization
- script: optimization-new
parameters:
network-type: DH
number-of-generations: 2
population-size: 5
random-seed: 100
- script: multi-criteria-analysis
parameters:
generation: 2
- script: run-all-plots
parameters:
network-type: DH
network-name: ""
ga-number-of-generations: 2
ga-population-size: 5
#- script: multi-criteria-analysis
# parameters:
# generation: 2
#- script: run-all-plots
# parameters:
# network-type: DH
# network-name: ""

# COOLING CASE (SG)
- script: data-initializer
Expand Down Expand Up @@ -124,17 +123,16 @@
network-type: DC
network-model: simplified
- script: decentralized
- script: optimization
parameters:
network-type: DC
number-of-generations: 2
population-size: 5
random-seed: 100
- script: multi-criteria-analysis
parameters:
generation: 2
- script: run-all-plots
parameters:
plant-node: NODE41
network-type: DC
network-name: ""
#- script: optimization-new
# parameters:
# network-type: DC
# ga-number-of-generations: 2
# ga-population-size: 5
#- script: multi-criteria-analysis
# parameters:
# generation: 2
#- script: run-all-plots
# parameters:
# plant-node: NODE41
# network-type: DC
# network-name: ""
55 changes: 31 additions & 24 deletions cea/tests/workflow_slow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
parameters:
databases-path: CH
databases: [archetypes, assemblies, components]
- script: archetypes-mapper
parameters:
input-databases: [comfort, architecture, air-conditioning, internal-loads, supply, schedules]
- script: surroundings-helper
- script: streets-helper
- script: terrain-helper
- script: weather-helper
parameters:
weather: Zug-inducity_1990_2010_TMY
Expand Down Expand Up @@ -54,28 +60,30 @@
network-type: DH
network-model: simplified
- script: decentralized
- script: optimization
- script: optimization-new
parameters:
network-type: DH
number-of-generations: 2
population-size: 5
random-seed: 100
- script: multi-criteria-analysis
parameters:
generation: 2
- script: run-all-plots
parameters:
network-type: DH
network-name: ""
ga-number-of-generations: 2
ga-population-size: 5
#- script: multi-criteria-analysis
# parameters:
# generation: 2
#- script: run-all-plots
# parameters:
# network-type: DH
# network-name: ""

# COOLING CASE (SG)
## COOLING CASE (SG)
- script: data-initializer
parameters:
databases-path: SG
databases: [archetypes, assemblies, components]
- script: archetypes-mapper
parameters:
input-databases: [comfort, architecture, air-conditioning, internal-loads, supply, schedules]
#- script: surroundings-helper
#- script: streets-helper
#- script: terrain-helper
- script: weather-helper
parameters:
weather: Singapore-Changi_1990_2010_TMY
Expand Down Expand Up @@ -116,17 +124,16 @@
network-type: DC
network-model: simplified
- script: decentralized
- script: optimization
parameters:
network-type: DC
number-of-generations: 2
population-size: 5
random-seed: 100
- script: multi-criteria-analysis
parameters:
generation: 2
- script: run-all-plots
- script: optimization-new
parameters:
plant-node: NODE41
network-type: DC
network-name: ""
ga-number-of-generations: 2
ga-population-size: 5
#- script: multi-criteria-analysis
# parameters:
# generation: 2
#- script: run-all-plots
# parameters:
## plant-node: NODE41
# network-type: DC
# network-name: ""

0 comments on commit d10ec38

Please sign in to comment.