def test_calc(inputdata, expectedvalue): # 検証用 with open("inputdata.json",'w') as fw: json.dump(inputdata, fw, indent=4, ensure_ascii=False) if expectedvalue[0] != "err": # passが期待されるテスト # 計算実行 resultJson = airconditioning.calc_energy(inputdata) if convert2number(expectedvalue[0],0) == 0: diff_Dc = 0 else: diff_Dc = (abs(resultJson["Qroom"]["1F_room1"]["QroomDc_anual"] - convert2number(expectedvalue[0],0))) / abs( convert2number(expectedvalue[0],0) ) if convert2number(expectedvalue[1],0) == 0: diff_Dh = 0 else: diff_Dh = (abs(resultJson["Qroom"]["1F_room1"]["QroomDh_anual"] - convert2number(expectedvalue[1],0))) / abs( convert2number(expectedvalue[1],0) ) # 比較(0.01%まで) assert diff_Dc < 0.0001 assert diff_Dh < 0.0001 else: # エラーが期待される場合 with pytest.raises(Exception): resultJson = airconditioning.calc_energy(inputdata)
def test_calc(inputdata, expectedvalue): # 計算実行 resultJson = airconditioning.calc_energy(inputdata) diff_Eac = (abs(resultJson["E_airconditioning"] - expectedvalue)) / abs(expectedvalue) # 比較(0.01%まで) assert diff_Eac < 0.0001
def test_calc(inputdata, expectedvalue): # 検証用 with open("inputdata.json", 'w') as fw: json.dump(inputdata, fw, indent=4, ensure_ascii=False) # 計算実行 resultJson = airconditioning.calc_energy(inputdata) diff_Eac = (abs(resultJson["E_airconditioning"] - expectedvalue)) / abs(expectedvalue) # 比較(0.01%まで) assert diff_Eac < 0.0001
# 出力 with open(inputfile_name_split[0] + "_input.json",'w') as fw: json.dump(inputdata, fw, indent=4, ensure_ascii=False, cls = MyEncoder) #------------------------------------ # 空気調和設備の計算の実行 #------------------------------------ # 実行 resultdata_AC = {} if exec_calculation: try: if inputdata["AirConditioningZone"]: # AirConditioningZone が 空 でなければ resultdata_AC = airconditioning.calc_energy(inputdata, DEBUG = False) # CGSの計算に必要となる変数 resultJson_for_CGS["AC"] = resultdata_AC["for_CGS"] # 設計一次エネ・基準一次エネに追加 calc_reuslt["設計一次エネルギー消費量 [MJ]"] += resultdata_AC["E_airconditioning"] calc_reuslt["基準一次エネルギー消費量 [MJ]"] += resultdata_AC["Es_airconditioning"] calc_reuslt["設計一次エネルギー消費量(空調) [MJ]"] = resultdata_AC["E_airconditioning"] calc_reuslt["基準一次エネルギー消費量(空調) [MJ]"] = resultdata_AC["Es_airconditioning"] calc_reuslt["BEI_AC"] = math.ceil(resultdata_AC["BEI_AC"] * 100) / 100 else: resultdata_AC = { "message": "空気調和設備はありません。" }
# 入力データの読み込み with open(filename, 'r') as f: inputdata = json.load(f) # 地域 inputdata["Building"]["Region"] = str(testdata[3]).replace( "地域", "") # 冷熱源 inputdata["HeatsourceSystem"]["PAC1"]["冷房"]["Heatsource"][0][ "HeatsourceType"] = testdata[1] # 温熱源 inputdata["HeatsourceSystem"]["PAC1"]["暖房"]["Heatsource"][0][ "HeatsourceType"] = testdata[2] # 実行 resultJson = airconditioning.calc_energy(inputdata) # 結果 resultALL = [ str(resultJson["E_airconditioning"]), str(resultJson["ENERGY"]["E_fan"] * bc.fprime), str(resultJson["ENERGY"]["E_aex"] * bc.fprime), str(resultJson["ENERGY"]["E_pump"] * bc.fprime), str(resultJson["ENERGY"]["E_refsysr"]), str(resultJson["ENERGY"]["E_refac"] * bc.fprime), str(resultJson["ENERGY"]["E_pumpP"] * bc.fprime), str(resultJson["ENERGY"]["E_ctfan"] * bc.fprime), str(resultJson["ENERGY"]["E_ctpump"] * bc.fprime) ] with open("resultALL.txt", 'a') as fw: